16 for(
int i=0; i<gr->GetN(); i++){
37 std::cout << start.Data();
38 for(
int i=0; i<n; i++){
39 std::cout << array[i];
40 if(i<n-1) std::cout << delimiter.Data();
42 std::cout << end.Data();
60 printArray(gr->GetN(), gr->GetY(), delimiter, start, end);
78 printArray(gr->GetN(), gr->GetX(), delimiter, start, end);
93 TGraph* grDer =
new TGraph();
94 Int_t nDer = gr->GetN()-1;
96 for(
int samp=0; samp<nDer; samp++){
97 Double_t dy = gr->GetY()[samp+1]-gr->GetY()[samp];
98 Double_t dx = gr->GetX()[samp+1]-gr->GetX()[samp];
99 grDer->SetPoint(samp, gr->GetX()[samp], dy/dx);
117 Int_t n = gr->GetN();
118 Double_t dt = gr->GetX()[1] - gr->GetX()[0];
119 TGraph* grUnwrapped =
new TGraph();
122 for(Int_t samp=n/2; samp<n; samp++){
123 grUnwrapped->SetPoint(samp2, (samp - n)*dt, gr->GetY()[samp]);
126 for(Int_t samp=0; samp<n/2; samp++){
127 grUnwrapped->SetPoint(samp2, samp*dt, gr->GetY()[samp]);
148 Double_t maxX=0, minX=0;
166 Double_t& minY, Double_t& minX){
173 for(
int i=0; i<gr->GetN(); i++){
174 if(gr->GetY()[i] > maxY){
175 maxY = gr->GetY()[i];
176 maxX = gr->GetX()[i];
178 if(gr->GetY()[i] < minY){
179 minY = gr->GetY()[i];
180 minX = gr->GetX()[i];
202 Double_t& minY, Double_t& minX,
203 Double_t lowerLimit, Double_t upperLimit){
206 Double_t minPoss = -DBL_MAX;
207 Double_t maxPoss = DBL_MAX;
213 for(
int i=0; i<gr->GetN(); i++){
214 if(gr->GetX()[i] >= lowerLimit && gr->GetX()[i] <=upperLimit){
215 if(gr->GetY()[i] > maxY){
216 maxY = gr->GetY()[i];
217 maxX = gr->GetX()[i];
219 if(gr->GetY()[i] < minY){
220 minY = gr->GetY()[i];
221 minX = gr->GetX()[i];
227 std::cerr <<
"Warning in " << __PRETTY_FUNCTION__ <<
"!" << std::endl;
228 std::cerr <<
"Unable to find value in " << gr->GetName() <<
" > " << minPoss << std::endl;
231 std::cerr <<
"Warning in " << __PRETTY_FUNCTION__ <<
"!" << std::endl;
232 std::cerr <<
"Unable to find value in " << gr->GetName() <<
" < " << maxPoss << std::endl;
248 for(
int i=0; i<gr->GetN(); i++){
249 gr->GetY()[i] -= offset;
269 Double_t deltaAngle = angle1 - angle2;
271 const Int_t maxLoopCount = 5;
272 if(deltaAngle > 180){
273 while(deltaAngle >= 180){
276 if(loopCount >= maxLoopCount){
283 while(deltaAngle < -180){
286 if(loopCount >= maxLoopCount){
326 for(
int i=0; i<gr->GetN(); i++){
327 gr->GetY()[i] -= mean;
328 gr->GetY()[i] /= rms;
345 TGraph* grCopy = (TGraph*) gr->Clone();
364 TGraph* grCopy = (TGraph*) gr->Clone();
384 for(
int i=0; i<gr->GetN(); i++){
385 sum += gr->GetY()[i];
386 square += gr->GetY()[i]*gr->GetY()[i];
388 mean = sum/gr->GetN();
389 rms = TMath::Sqrt(square/gr->GetN() - mean*mean);
405 Double_t max=-DBL_MAX;
407 for(Int_t i=0; i < len; ++i){
414 std::cerr <<
"Warning in " << __PRETTY_FUNCTION__ <<
"!" << std::endl;
415 std::cerr <<
"Could not find an index > " << max << std::endl;
433 std::vector<Int_t> nanIndices;
434 for(Int_t i=0; i<gr->GetN(); i++){
435 if(TMath::IsNaN(gr->GetY()[i])){
436 nanIndices.push_back(i);
453 std::cout <<
"******************************************************************************" << std::endl;
454 std::cout <<
"RootTools::printTGraphValues(TGraph* gr = " << gr <<
"):" << std::endl;
455 std::cout <<
"Name: " << gr->GetName() << std::endl;
456 std::cout <<
"Title: " << gr->GetTitle() << std::endl;
457 std::cout <<
"Num points: " << gr->GetN() << std::endl;
458 std::cout <<
"Xvals: ";
459 for(Int_t i=0; i<gr->GetN(); i++){
460 std::cout << gr->GetX()[i];
465 std::cout << std::endl;
466 std::cout <<
"Yvals: ";
467 for(Int_t i=0; i<gr->GetN(); i++){
468 std::cout << gr->GetY()[i];
473 std::cout << std::endl;
474 std::cout <<
"******************************************************************************" << std::endl;
493 const Int_t nEntries = tree->Draw(drawText, cutString,
"goff");
496 std::vector<Int_t> sortedIndices(nEntries);
497 TMath::Sort(nEntries, tree->GetV2(), &sortedIndices.front(), kFALSE);
498 std::vector<Double_t> newX(nEntries);
499 std::vector<Double_t> newY(nEntries);
501 for(
int i=0; i<nEntries; i++){
502 newX.at(i) = tree->GetV2()[sortedIndices.at(i)];
503 newY.at(i) = tree->GetV1()[sortedIndices.at(i)];
509 for(
int i=1; i<nEntries; i++){
513 while (newY.at(i) - newY.at(i-1) > wrapValue/2){
514 newY.at(i) -= wrapValue;
520 while (newY.at(i) - newY.at(i-1) < -wrapValue/2){
521 newY.at(i) += wrapValue;
528 TGraph* gr(
new TGraph(nEntries,&newX.front(), &newY.front()));
529 TString title = cutString.Length() == 0 ? drawText : drawText +
", " + cutString;
531 TObjArray* tokens = drawText.Tokenize(
":");
532 gr->GetXaxis()->SetTitle(((TObjString*) tokens->At(1))->String());
533 gr->GetYaxis()->SetTitle(((TObjString*) tokens->At(0))->String());
554 TH1D* h =
new TH1D(hName, hName, nBins, xMin, xMax);
555 for(
int xBin=1; xBin<=h2->GetNbinsX(); xBin++){
556 for(
int yBin=1; yBin<=h2->GetNbinsY(); yBin++){
557 Double_t val = h2->GetBinContent(xBin, yBin);
577 Int_t oldLen = gr->GetN();
580 Double_t x0 = gr->GetX()[oldLen-1];
581 for(Int_t samp=oldLen; samp<newLen; samp++){
582 gr->GetX()[samp] = x0 + samp*dt;
602 Int_t nIn = grIn->GetN();
603 Int_t newPoints = Int_t((grIn->GetX()[nIn-1] - grIn->GetX()[0])/dt) + 1;
604 std::vector<Double_t> newTimes(newPoints);
605 std::vector<Double_t> newVolts(newPoints);
607 Double_t time = grIn->GetX()[0];
608 Double_t lastTime = grIn->GetX()[nIn-1];
613 Double_t y1 = grIn->GetY()[sampIn];
614 Double_t x1 = grIn->GetX()[sampIn];
615 Double_t x2 = grIn->GetX()[sampIn+1];
616 Double_t m = (grIn->GetY()[sampIn+1]-y1)/(grIn->GetX()[sampIn+1]-x1);
618 while(time < lastTime){
623 if(sampIn < (nIn - 1)){
626 x2 = grIn->GetX()[sampIn+1];
629 std::cerr <<
"You can't do logic very well" << std::endl;
630 std::cerr << time <<
"\t" << x1 <<
"\t" << x2 <<
"\t" << nIn <<
"\t" << sampIn << std::endl;
634 x1 = grIn->GetX()[sampIn];
635 y1 = grIn->GetY()[sampIn];
637 m = (grIn->GetY()[sampIn+1]-y1)/(x2-x1);
648 Double_t newY = y1 + m * (time - x1);
650 newTimes.at(sampOut) = time;
651 newVolts.at(sampOut) = newY;
656 TGraph* grOut =
new TGraph(newTimes.size(), &newTimes[0], &newVolts[0]);
681 std::vector<Double_t> newTimes = std::vector<Double_t>(nSamp, 0);
682 std::vector<Double_t> newVolts = std::vector<Double_t>(nSamp, 0);
683 Double_t thisStartTime = grIn->GetX()[0];
684 Double_t lastTime = grIn->GetX()[grIn->GetN()-1];
690 startTime = dt*TMath::Nint(startTime/dt + 0.5);
691 lastTime = dt*TMath::Nint(lastTime/dt - 0.5);
694 std::vector<Double_t> tVec(grIn->GetX(), grIn->GetX() + grIn->GetN());
695 std::vector<Double_t> vVec(grIn->GetY(), grIn->GetY() + grIn->GetN());
698 ROOT::Math::Interpolator chanInterp(tVec,vVec,ROOT::Math::Interpolation::kAKIMA);
701 Double_t time = startTime;
702 for(Int_t samp = 0; samp < nSamp; samp++){
703 newTimes.at(samp) = time;
704 if(time >= thisStartTime && time <= lastTime){
705 newVolts.at(samp) = chanInterp.Eval(time);
708 newVolts.at(samp) = 0;
712 return new TGraph(nSamp, &newTimes[0], &newVolts[0]);
738 Double_t maxCol = 255;
739 if(colWeights!=NULL){
740 maxCol = TMath::MaxElement(numHists, colWeights);
741 minCol = TMath::MinElement(numHists, colWeights);
747 for(Int_t histInd=0; histInd < numHists; histInd++){
748 if(hs[histInd] != NULL){
752 TString opt = numDrawn == 0 ?
"" :
"same";
753 if(colWeights!=NULL){
754 hs[histInd]->SetLineColor(gStyle->GetColorPalette(Int_t(250.*(colWeights[histInd] - minCol)/(maxCol-minCol))));
761 hs[histInd]->SetLineColor(gStyle->GetColorPalette(histInd*Int_t(255./numHists)));
763 hs[histInd]->Draw(opt);
764 if(hs[histInd]->GetMaximum() > max){
765 max = hs[histInd]->GetMaximum()*1.1;
766 hs[first]->SetMaximum(max);
788 for(Int_t grInd=0; grInd < numGrs; grInd++){
789 for(Int_t samp=0; samp < grs[grInd]->GetN(); samp++){
790 grs[grInd]->GetX()[samp] += offsets[grInd];
810 for(Int_t grInd=0; grInd < numGrs; grInd++){
811 for(Int_t samp=0; samp < grs[grInd]->GetN(); samp++){
812 grs[grInd]->GetY()[samp] *= factors[grInd];
833 TString drawOpt, TCanvas* can, Double_t* colWeights){
840 Double_t colFactor = 1;
841 if(colWeights!=NULL){
842 Double_t maxCol = TMath::MaxElement(numGrs, colWeights);
843 Double_t minCol = TMath::MinElement(numGrs, colWeights);
844 colFactor = 254./(maxCol-minCol);
847 Double_t max = -DBL_MAX;
848 Double_t min = DBL_MAX;
851 for(Int_t grInd=0; grInd < numGrs; grInd++){
852 if(grs[grInd]!=NULL){
853 if(grs[grInd]->GetN() > 0){
854 TString opt = numDrawn == 0 ?
"a" + drawOpt : drawOpt +
"same";
859 if(colWeights!=NULL){
860 grs[grInd]->SetLineColor(gStyle->GetColorPalette(Color_t(colWeights[grInd]*colFactor)));
861 grs[grInd]->SetMarkerColor(gStyle->GetColorPalette(Color_t(colWeights[grInd]*colFactor)));
862 grs[grInd]->SetMarkerColor(gStyle->GetColorPalette(Color_t(colWeights[grInd]*colFactor)));
865 grs[grInd]->SetLineColor(gStyle->GetColorPalette(grInd*Int_t(254./(numGrs-1))));
866 grs[grInd]->SetMarkerColor(gStyle->GetColorPalette(grInd*Int_t(254./(numGrs-1))));
867 grs[grInd]->SetMarkerColor(gStyle->GetColorPalette(grInd*Int_t(254./(numGrs-1))));
870 grs[grInd]->Draw(opt);
872 Double_t thisMax = TMath::MaxElement(grs[grInd]->GetN(), grs[grInd]->GetY());
874 Double_t fact = thisMax > 0 ? 1.1 : 0.9;
876 grs[first]->SetMaximum(max);
879 Double_t thisMin = TMath::MinElement(grs[grInd]->GetN(), grs[grInd]->GetY());
881 Double_t fact = thisMin < 0 ? 1.1 : 0.9;
883 grs[first]->SetMinimum(min);
914 TString titles[], TString opt,
915 Double_t minX, Double_t minY,
916 Double_t maxX, Double_t maxY){
918 TLegend* l =
new TLegend(minX, minY, maxX, maxY);
919 for(Int_t grInd=0; grInd < numGrs; grInd++){
920 if(grs[grInd]!=NULL){
921 l->AddEntry(grs[grInd], titles[grInd], opt);
946 TString titles[], TString opt,
947 Double_t minX, Double_t minY,
948 Double_t maxX, Double_t maxY){
950 TLegend* l =
new TLegend(minX, minY, maxX, maxY);
951 for(Int_t histInd=0; histInd < numHists; histInd++){
952 if(hs[histInd]!=NULL){
953 l->AddEntry(hs[histInd], titles[histInd], opt);
992 Double_t& maxY, Double_t& maxX,
993 Double_t& minY, Double_t& minX){
1016 Double_t& maxY, Double_t& maxX,
1017 Double_t& minY, Double_t& minX,
1018 Double_t lowerLimit, Double_t upperLimit){
1023 std::vector<Int_t> extremaSamps;
1025 for(Int_t samp=1; samp < gr->GetN()-1; samp++){
1026 if(gr->GetX()[samp] >= lowerLimit && gr->GetX()[samp] <=upperLimit){
1027 Double_t y0 = gr->GetY()[samp-1];
1028 Double_t y1 = gr->GetY()[samp];
1029 Double_t y2 = gr->GetY()[samp+1];
1032 if(y0 > y1 && y1 < y2){
1034 extremaSamps.push_back(samp);
1036 else if(y0 < y1 && y1 > y2){
1038 extremaSamps.push_back(samp);
1043 Double_t maxOffset = -DBL_MAX;
1044 Int_t maxSampInd = -1;
1045 for(UInt_t sampInd = 0; sampInd < extremaSamps.size()-1; sampInd++){
1046 Double_t offset = TMath::Abs(gr->GetY()[extremaSamps.at(sampInd)] - gr->GetY()[extremaSamps.at(sampInd+1)]);
1047 if(offset > maxOffset){
1049 maxSampInd = sampInd;
1053 if(gr->GetY()[extremaSamps.at(maxSampInd)] > gr->GetY()[extremaSamps.at(maxSampInd+1)]){
1054 maxY = gr->GetY()[extremaSamps.at(maxSampInd)];
1055 maxX = gr->GetX()[extremaSamps.at(maxSampInd)];
1057 minY = gr->GetY()[extremaSamps.at(maxSampInd+1)];
1058 minX = gr->GetX()[extremaSamps.at(maxSampInd+1)];
1061 maxY = gr->GetY()[extremaSamps.at(maxSampInd+1)];
1062 maxX = gr->GetX()[extremaSamps.at(maxSampInd+1)];
1064 minY = gr->GetY()[extremaSamps.at(maxSampInd)];
1065 minX = gr->GetX()[extremaSamps.at(maxSampInd)];
1080 std::cout <<
"Saving this canvas as an .eps, .png, and .C file..." << std::endl;
1081 TString fName = fileName +
".eps";
1083 fName = fileName +
".png";
1085 fName = fileName +
".C";
1087 std::cout <<
"...Complete!" << std::endl;
1105 Int_t n = h->GetNbinsX();
1106 Double_t max = h->GetBinContent(maxBin);
1109 Double_t halfMaxPos = 0;
1110 for(Int_t bin=maxBin; bin<=n; bin++){
1111 Double_t val = h->GetBinContent(bin);
1113 halfMaxPos = h->GetBinLowEdge(bin);
1118 Double_t halfMaxNeg = 0;
1119 for(Int_t bin=maxBin; bin>=1; bin--){
1120 Double_t val = h->GetBinContent(bin);
1122 halfMaxNeg = h->GetBinLowEdge(bin);
1127 return halfMaxPos - halfMaxNeg;
1143 Int_t n = h->GetNbinsX();
1144 Double_t max = -DBL_MAX;
1146 for(Int_t bin=1; bin<n; bin++){
1147 Double_t val = h->GetBinContent(bin);
1171 Int_t nx = hist->GetNbinsX();
1172 Int_t ny = hist->GetNbinsY();
1173 Double_t histPeak = -DBL_MAX;
1174 for(Int_t by = 1; by<=ny; by++){
1175 for(Int_t bx = 1; bx<=nx; bx++){
1176 Double_t val = hist->GetBinContent(bx, by);
1203 Double_t lowBinEdgeOfPeak = h->GetXaxis()->GetBinLowEdge(peakBin);
1204 return lowBinEdgeOfPeak;
1220 Double_t min = h->GetMinimum();
1221 Double_t max = h->GetMaximum();
1223 if(TMath::Abs(min) > max){
1224 h->SetMaximum(-min);
1227 h->SetMinimum(-max);
1243 return ((bitMask >> bitIndex) & 1);
1258 Int_t numBitsHigh = 0;
1259 for(Int_t bitInd=0; bitInd < numBitsToCheck; bitInd++){
1260 if(
getBit(bitInd, bitMask) > 0){
1278 const int NRGBs = 3, NCont = 999;
1279 gStyle->SetNumberContours(NCont);
1280 Double_t stops[NRGBs] = { 0.00, 0.50, 1.00};
1281 Double_t red[NRGBs] = { 0.00, 1.00, 1.00};
1282 Double_t green[NRGBs] = { 0.00, 1.00, 0.00};
1283 Double_t blue[NRGBs] = { 1.00, 1.00, 0.00};
1285 color.InitializeColors();
1286 color.CreateGradientColorTable(NRGBs, stops, red, green, blue, NCont);
1303 Double_t max = TMath::Abs(hist->GetMaximum());
1304 Double_t min = TMath::Abs(hist->GetMinimum());
1305 Double_t limit = min > max ? min : max;
1306 hist->SetMaximum(limit);
1307 hist->SetMinimum(-limit);
1323 TChain* c =
new TChain(
"headTree");
1324 for(Int_t run=firstRun; run <= lastRun; run++){
1325 c->Add(TString::Format(
"~/UCL/ANITA/flight1415/root/run%d/headFile%d.root", run, run));
1327 c->SetBranchAddress(
"header", &headPtr);
1344 TChain* c =
new TChain(
"adu5PatTree");
1345 for(Int_t run=firstRun; run <= lastRun; run++){
1346 c->Add(TString::Format(
"~/UCL/ANITA/flight1415/root/run%d/gpsFile%d.root", run, run));
1348 c->SetBranchAddress(
"pat", &pat);
1367 Int_t phi = (antInd % NUM_PHI) + 1;
1369 Int_t ring = antInd / NUM_PHI;
1371 TString antName = TString::Format(
"%d", phi);
1373 antName += AnitaRing::ringAsChar(AnitaRing::AnitaRing_t(ring));
1374 antName += AnitaPol::polAsChar(pol);
1392 return gStyle->GetColorPalette(index*Int_t(255./maxVal));
1411 gStyle->SetOptStat(statsOption);
1412 TCanvas* theCan =
new TCanvas();
1414 Double_t boxSize = 0.2;
1415 const Int_t maxNumBoxes = 1./boxSize;
1417 Int_t divisor = (numHists/maxNumBoxes) + 1;
1422 for(Int_t histInd=0; histInd < numHists; histInd++){
1424 TString thisDrawOpt = histInd == 0 ? drawOpt : drawOpt+
"sames";
1425 hs[histInd]->Draw(thisDrawOpt);
1428 TPaveStats* sbox = (TPaveStats*) hs[histInd]->FindObject(
"stats");
1429 sbox->SetTextColor(hs[histInd]->GetLineColor());
1430 sbox->SetX1NDC(0.8);
1431 sbox->SetY1NDC(1 - (histInd+1)*boxSize);
1432 sbox->SetX2NDC(0.98);
1433 sbox->SetY2NDC(0.98 - histInd*boxSize);