Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:15:51

0001 #include <TROOT.h>
0002 #include <TString.h>
0003 #include <TObject.h>
0004 #include <TObjString.h>
0005 #include <TSystem.h>
0006 #include <TChain.h>
0007 #include <TMath.h>
0008 #include <TVector3.h>
0009 #include <iostream>
0010 #include <fstream>
0011 #include <TParticlePDG.h>
0012 #include <TDatabasePDG.h>
0013 #include <algorithm>
0014 
0015 #include <TCanvas.h>
0016 #include <TPad.h>
0017 #include <TH1.h>
0018 #include <TH1D.h>
0019 #include <TH1F.h>
0020 #include <TH2.h>
0021 #include <TH3.h>
0022 #include <TFile.h>
0023 #include <TH2D.h>
0024 #include <TH2F.h>
0025 #include <TString.h>
0026 #include <TDatime.h>
0027 #include <TF1.h>
0028 #include <TF2.h>
0029 #include <THStack.h>
0030 #include <TGraph.h>
0031 #include <TStyle.h>
0032 #include <TGraphAsymmErrors.h>
0033 #include <TLine.h>
0034 #include <TLatex.h>
0035 #include <TArrow.h>
0036 #include <TGraphErrors.h>
0037 #include <TGaxis.h>
0038 #include <TLegend.h>
0039 #include <TFrame.h>
0040 #include <TLorentzVector.h>
0041 
0042 
0043 const int gMaxChannels = 64;
0044 const int gMaxBoard    = 2;
0045 using namespace std;
0046 void ReturnCorrectValuesForCanvasScaling(   Int_t sizeX,
0047                                             Int_t sizeY,
0048                                             Int_t nCols,
0049                                             Int_t nRows,
0050                                             Double_t leftMargin,
0051                                             Double_t rightMargin,
0052                                             Double_t upperMargin,
0053                                             Double_t lowerMargin,
0054                                             Double_t* arrayBoundariesX,
0055                                             Double_t* arrayBoundariesY,
0056                                             Double_t* relativeMarginsX,
0057                                             Double_t* relativeMarginsY,
0058                                             Bool_t verbose = kTRUE){
0059   Int_t realsizeX             = sizeX- (Int_t)(sizeX*leftMargin)- (Int_t)(sizeX*rightMargin);
0060   Int_t realsizeY             = sizeY- (Int_t)(sizeY*upperMargin)- (Int_t)(sizeY*lowerMargin);
0061 
0062   Int_t nPixelsLeftColumn     = (Int_t)(sizeX*leftMargin);
0063   Int_t nPixelsRightColumn    = (Int_t)(sizeX*rightMargin);
0064   Int_t nPixelsUpperColumn    = (Int_t)(sizeY*upperMargin);
0065   Int_t nPixelsLowerColumn    = (Int_t)(sizeY*lowerMargin);
0066 
0067   Int_t nPixelsSinglePlotX    = (Int_t) (realsizeX/nCols);
0068   Int_t nPixelsSinglePlotY    = (Int_t) (realsizeY/nRows);
0069   if(verbose){
0070     std::cout << realsizeX << "\t" << nPixelsSinglePlotX << std::endl;
0071     std::cout << realsizeY << "\t" << nPixelsSinglePlotY << std::endl;
0072     std::cout << nPixelsLeftColumn << "\t" << nPixelsRightColumn  << "\t" << nPixelsLowerColumn << "\t" << nPixelsUpperColumn << std::endl;
0073   }
0074   Int_t pixel = 0;
0075   if(verbose)std::cout << "boundaries X" << std::endl;
0076   for (Int_t i = 0; i < nCols+1; i++){
0077     if (i == 0){
0078       arrayBoundariesX[i] = 0.;
0079       pixel = pixel+nPixelsLeftColumn+nPixelsSinglePlotX;
0080     } else if (i == nCols){
0081       arrayBoundariesX[i] = 1.;
0082       pixel = pixel+nPixelsRightColumn;
0083     } else {
0084       arrayBoundariesX[i] = (Double_t)pixel/sizeX;
0085       pixel = pixel+nPixelsSinglePlotX;
0086     }
0087     if(verbose)std::cout << i << "\t" << arrayBoundariesX[i] << "\t" << pixel<<std::endl;
0088   }
0089 
0090   if(verbose)std::cout << "boundaries Y" << std::endl;
0091   pixel = sizeY;
0092   for (Int_t i = 0; i < nRows+1; i++){
0093     if (i == 0){
0094       arrayBoundariesY[i] = 1.;
0095       pixel = pixel-nPixelsUpperColumn-nPixelsSinglePlotY;
0096     } else if (i == nRows){
0097       arrayBoundariesY[i] = 0.;
0098       pixel = pixel-nPixelsLowerColumn;
0099     } else {
0100       arrayBoundariesY[i] = (Double_t)pixel/sizeY;
0101       pixel = pixel-nPixelsSinglePlotY;
0102     }
0103     if(verbose)std::cout << i << "\t" << arrayBoundariesY[i] <<"\t" << pixel<<std::endl;
0104   }
0105 
0106   relativeMarginsX[0]         = (Double_t)nPixelsLeftColumn/(nPixelsLeftColumn+nPixelsSinglePlotX);
0107   relativeMarginsX[1]         = 0;
0108   relativeMarginsX[2]         = (Double_t)nPixelsRightColumn/(nPixelsRightColumn+nPixelsSinglePlotX);;
0109 
0110   relativeMarginsY[0]         = (Double_t)nPixelsUpperColumn/(nPixelsUpperColumn+nPixelsSinglePlotY);
0111   relativeMarginsY[1]         = 0;
0112   relativeMarginsY[2]         = (Double_t)nPixelsLowerColumn/(nPixelsLowerColumn+nPixelsSinglePlotY);;
0113 
0114   return;
0115 }
0116 
0117 TH1D* GetHist(TFile* inputTfile, TH1D *hist, char* histName){
0118     
0119     //TFile *inputTfile = new TFile(inputfile);
0120     if (inputTfile){
0121         //std::cout <<" Opened things properly"<<std::endl;
0122         hist= (TH1D*)inputTfile->Get(histName);
0123         //hist->Draw("hist");
0124         
0125     }
0126     else{
0127         std::cout<<"Shit didn't open"<< std::endl;
0128         
0129     }
0130     return hist;
0131     
0132 }
0133 
0134 
0135 std::vector<string> testParserTStrings(string fileName)
0136 {
0137     
0138     //string str = "1,2,3,4,5,6";
0139     vector<string> v;
0140  
0141     stringstream ss(fileName);
0142  
0143     while (ss.good()) {
0144         string substr;
0145         getline(ss, substr, ',');
0146         v.push_back(substr);
0147     }
0148     return v;
0149     //for (size_t i = 0; i < v.size(); i++)
0150       //  cout << v[i] << endl;
0151 }
0152 
0153 int getIndex(vector<int> v, int K)
0154 {
0155     auto it = find(v.begin(), v.end(), K);
0156   
0157     // If element was found
0158     if (it != v.end())
0159     {
0160       
0161         // calculating the index
0162         // of K
0163         int index = it - v.begin();
0164         return index;
0165     }
0166     else {
0167         // If the element is not
0168         // present in the vector
0169         cout<<"Couldn't find index" <<endl;
0170         return 99999999;
0171     }
0172 }
0173 void setLegend(TLegend* leg, int color, int BorderSize, int FontSize, float TextSize, TH1D* hist, string label)
0174 {
0175     leg->SetFillColor(color);
0176     leg->SetBorderSize(BorderSize);
0177     leg->SetTextFont(FontSize);
0178     leg->SetTextSize(TextSize);
0179     leg->AddEntry(hist,label.c_str());
0180     leg->Draw();
0181     
0182 }
0183 void graphingHistOnPad(TCanvas* c, Int_t i, Int_t j, std::vector <int> board,  TFile* inputfile, string assembly,TH1D* hist,int color,float y_max,bool iflog, int rebinfac, float xrange, TLegend* leg,string label){
0184     int Index = getIndex(board,i)+1;
0185     if (Index == 100000000) throw std::exception();
0186     int padInd;
0187     if (Index >4 )padInd = 9;
0188     if (Index <5)padInd=-4;
0189     c->cd(abs(padInd-(Index)));
0190     //printf(" found channel %d in vector %s in channel %d and Pad index %d\n",i,assembly.c_str(),Index,abs(padInd-(Index-1)));
0191     hist=GetHist(inputfile, hist,Form("h_HG_B%d_C%02d",j,i));
0192     hist->RebinX(rebinfac);
0193     
0194     hist->SetStats(0);
0195     hist->SetLineColor(color);
0196 //    hist->SetLineWidth(2);
0197     hist->Scale(1./hist->Integral());
0198     hist->SetMaximum(y_max*1.1);
0199     
0200     hist->GetXaxis()->SetRangeUser(0.001,xrange);
0201     hist->GetXaxis()->SetLabelSize(0.04);
0202     hist->GetXaxis()->SetNdivisions(5);
0203     //hist->GetXaxis()->SetLabelOffset(0.500001);
0204     if(iflog==true){gPad->SetLogy();}
0205     //gStyle->SetTitleFontSize(.08);
0206      //gStyle->SetLabelSize(.05, "XY");
0207     hist->GetXaxis()->SetTitleSize(0.05);
0208     hist->GetXaxis()->SetLabelSize(0.052);
0209     hist->GetYaxis()->SetLabelSize(0.052);
0210     hist->GetXaxis()->SetTitleOffset(1.01);
0211     hist->GetYaxis()->SetTitleOffset(0.5000009);
0212     hist->GetYaxis()->SetTitleSize(0.05);
0213 
0214 //    hist->GetXaxis()->SetLabelOffset(1.01);
0215 //    hist->GetYaxis()->SetTitle("Entries");
0216     hist->Draw("SAME Hist");
0217     if (abs(padInd-(Index)) ==4) setLegend(leg,0,0,45,23,hist,label.c_str());
0218     if (abs(padInd-(Index)) ==8)  hist->GetXaxis()->SetTitle("ADC");
0219     if (abs(padInd-(Index)) ==1) {
0220         hist->GetYaxis()->SetTitle("Entries");
0221         TLatex latex11;
0222         latex11.SetNDC ();
0223         latex11.SetTextSize(0.06);
0224         c->cd(1);
0225         latex11.DrawLatex(0.65,0.85 ,assembly.c_str());
0226         }
0227         
0228        // gPad->SetTickx(2);
0229     }
0230 
0231 
0232 
0233 
0234 void graphingHistOnSepPad(TCanvas* canvas, Int_t i, Int_t j, std::vector <int> board, int assembly_number, TFile* inputfile, string assembly, TH1D* hist, int color[13],float y_max, bool iflog, float xrange, TLegend* leg, int rebinfac){
0235     int Index = getIndex(board,i)+1;
0236     if (Index == 100000000) throw std::exception();
0237     int padInd;
0238     if (Index >4 )padInd = 9;
0239     if (Index <5)padInd=-4;
0240     canvas->SetFillColor(0);
0241     canvas->SetFrameFillStyle(0);
0242     canvas->cd(abs(padInd-(Index)));
0243 //    int padnum = abs(padInd-(Index));
0244 //    string num = std::to_string(padnum);
0245 //    std::stringstream ss;
0246 //    ss<<"pad"<<num;
0247 //    std::string padname = ss.str();
0248 //    canvas->cd(padnum);
0249     //printf(" found channel %d in vector %s in channel %d and Pad index %d\n",i,assembly.c_str(),Index,abs(padInd-(Index-1)));
0250     hist=GetHist(inputfile, hist,Form("h_HG_B%d_C%02d",j,i));
0251     hist->SetStats(0);
0252     hist->GetXaxis()->SetNdivisions(4);
0253     hist->GetXaxis()->SetTitleSize(0.05);
0254     hist->GetXaxis()->SetLabelSize(0.052);
0255     hist->GetYaxis()->SetLabelSize(0.052);
0256     hist->SetLineColor(color[assembly_number]);
0257     hist->RebinX(rebinfac);
0258     hist->Scale(1./hist->Integral());
0259     hist->SetMaximum(y_max*1.1);
0260     hist->SetLineWidth(2);
0261     hist->GetXaxis()->SetRangeUser(5,xrange);
0262     hist->GetXaxis()->SetTitleOffset(1.012);
0263     hist->GetYaxis()->SetTitleOffset(0.9000009);
0264     hist->GetYaxis()->SetTitleSize(0.05);
0265     if(iflog==true){gPad->SetLogy();}
0266     if (abs(padInd-(Index)) ==8)  hist->GetXaxis()->SetTitle("ADC");
0267     if (abs(padInd-(Index)) ==1) {
0268         hist->GetYaxis()->SetTitle("Entries");
0269     
0270     }
0271     //hist->SetLineWidth(6);
0272     hist->Draw("SAME");
0273     if (abs(padInd-(Index)) ==4) setLegend(leg,0,0,45,23,hist,assembly.c_str());
0274     
0275 }
0276 
0277 void DrawGammaCanvasSettings( TCanvas* c1,
0278               Double_t leftMargin,
0279               Double_t rightMargin,
0280               Double_t topMargin,
0281               Double_t bottomMargin){
0282  c1->SetTickx();
0283  c1->SetTicky();
0284  c1->SetGridx(0);
0285  c1->SetGridy(0);
0286  c1->SetLogy(0);
0287  c1->SetLeftMargin(leftMargin);
0288  c1->SetRightMargin(rightMargin);
0289  c1->SetTopMargin(topMargin);
0290  c1->SetBottomMargin(bottomMargin);
0291  c1->SetFillColor(0);
0292 }
0293 void DrawGammaPadSettings( TPad* pad1,
0294             Double_t leftMargin,
0295             Double_t rightMargin,
0296             Double_t topMargin,
0297             Double_t bottomMargin){
0298   pad1->SetFillColor(0);
0299   pad1->GetFrame()->SetFillColor(0);
0300   pad1->SetBorderMode(0);
0301   pad1->SetLeftMargin(leftMargin);
0302   pad1->SetBottomMargin(bottomMargin);
0303   pad1->SetRightMargin(rightMargin);
0304   pad1->SetTopMargin(topMargin);
0305   pad1->SetTickx();
0306   pad1->SetTicky();
0307 }
0308 
0309 
0310 void testBeamPlotterMacrof(int assemblynum, string fileName, string energy, string Wlayers, bool energyScan, bool tungstenScan, bool Overlay, string outputDir, bool iflog, int rebinfac, float xrange, string scan) {
0311     //TH1D* trial;
0312     //trial = GetHist((char*)"output_basics.root",trial);
0313     //trial->Draw("hist");
0314     
0315     TH1D* noNoiseHistsLG[gMaxBoard][gMaxChannels];
0316     TH1D* noNoiseHistsHG[gMaxBoard][gMaxChannels];
0317     TH1D* noiseHistsLG[gMaxBoard][gMaxChannels];
0318     TH1D* AllSignalsHistsLG[gMaxBoard][gMaxChannels];
0319      
0320     //Colors for histograms of energy and tungsten scan
0321     int  col[6] = {kTeal-1, kPink+7, kOrange+4, kBlue-7, kGreen+4, kPink+1};
0322     //Colors for overlaid histograms of all boards
0323     int  col_overlay[14] = {kTeal-1, kPink+7, kOrange+4, kBlue-7, kGreen+4, kPink+1, kRed+3, kAzure-6, kRed, kMagenta+2, kGray+2, kCyan-3, kMagenta-8,kGreen};
0324 //std::vector <TString> Digiti
0325     //board 1 channels 
0326     //we eventually want to read these from the run setup .txt for the mean time we will hard code them
0327     std::vector <int> A13, A12, A11, A9, A8, A7, A6, A5, A4, A3, A2, A1, A0;
0328 if(assemblynum==1)
0329 {
0330     A11 = {30,28,26,24,22,20,18,16};
0331     A8 = {14,12,10,8,6,4,2,0};
0332     A2 = {32,34,36,38,40,42,44,46};
0333     A3 = {48,50,52,54,56,58,60,62};
0334     A13 = {33,35,37,39,41,43,45,47};
0335     A5 = {49,51,53,55,57,59,61,63};
0336     A6 = {31,29,27,25,23,21,19,17};
0337     A7 = {15,13,11,9,7,5,3,1};
0338     
0339     //board 0 channels
0340     A1 = {30,28,26,24,22,20,18,16};
0341     A9 = {14,12,10,8,6,4,2,0};
0342     A0 = {62,60,58,56,54,52,50,48};
0343     A12 = {46,44,42,40,38,36,34,32};A4 = {31,29,27,25,23,21,19,17};
0344    }
0345 else{
0346     if(energy == 3)
0347     {
0348         A0 = {30,28,26,24,22,20,18,16};
0349         A1 = {14,12,10,8,6,4,2,0};
0350         A2 = {32,34,36,38,40,42,44,46};
0351         A3 = {48,50,52,54,56,58,60,62};
0352         A4 = {33,35,37,39,41,43,45,47};
0353         A5 = {49,51,53,55,57,59,61,63};
0354         A6 = {31,29,27,25,23,21,19,17};
0355         A7 = {15,13,11,9,7,5,3,1};
0356         
0357         //board 0 channels
0358         A8 = {30,28,26,24,22,20,18,16};
0359         A9 = {14,12,10,8,6,4,2,0};
0360         A11 = {62,60,58,56,54,52,50,48};
0361         A12 = {46,44,42,40,38,36,34,32};
0362         A13 = {31,29,27,25,23,21,19,17};
0363     }
0364 }
0365     std::vector <float> maxes;
0366     //we need to find the max y values and any rebinning for alllllll the different data we want!
0367     std::vector<string> getMaxEntriesInFiles = testParserTStrings(fileName);
0368     for (Int_t k = 0; k< getMaxEntriesInFiles.size(); k++){
0369         TFile *inputfileMaxEntries = new TFile(getMaxEntriesInFiles[k].c_str());
0370         for (Int_t j = 0; j < gMaxBoard; j++){
0371             for (Int_t i = 0; i < gMaxChannels; i++){
0372                 noNoiseHistsHG[j][i] = GetHist(inputfileMaxEntries,noNoiseHistsLG[j][i],Form("h_HG_B%d_C%02d",j,i));
0373                 noNoiseHistsHG[j][i]->RebinX(rebinfac);
0374                 noNoiseHistsHG[j][i]->Scale(1./noNoiseHistsHG[j][i]->Integral());
0375                 maxes.push_back(noNoiseHistsHG[j][i]->GetMaximum());
0376             }
0377         }
0378     }//finished looped thru file names :)
0379     int max_y = distance(maxes.begin(), max_element(maxes.begin(), maxes.end()));
0380     float y_max = maxes[max_y]*1.10;
0381     
0382     cout<<y_max<<endl;
0383     //std::vector <int> chan8 ={16,0,}
0384     if (energyScan){
0385         
0386         
0387         
0388         //now i want to make a canvas per board for energy scan!
0389         TCanvas *c0 = new TCanvas("A0","A0 info",1800,1600);
0390         c0->Divide(4,2,0,0);
0391         //c0->Divide(4,2,0.00000000001,0.00000000001);
0392         
0393         TCanvas *c1 = new TCanvas("A1","A1 info",1800,1600);
0394         c1->Divide(4,2,0,0);
0395         
0396         TCanvas *c2 = new TCanvas("A2","A2 info",1800,1600);
0397         c2->Divide(4,2,0,0);
0398         TCanvas *c3 = new TCanvas("A3","A3 info",1800,1600);
0399         c3->Divide(4,2,0,0);
0400         TCanvas *c4 = new TCanvas("A4","A4 info",1800,1600);
0401         c4->Divide(4,2,0,0);
0402         TCanvas *c5 = new TCanvas("A5","A5 info",1800,1600);
0403         c5->Divide(4,2,0,0);
0404         TCanvas *c6 = new TCanvas("A6","A6 info",1800,1600);
0405         c6->Divide(4,2,0,0);
0406         TCanvas *c7 = new TCanvas("A7","A7 info",1800,1600);
0407         c7->Divide(4,2,0,0);
0408         TCanvas *c8 = new TCanvas("A8","A8 info",1800,1600);
0409         c8->Divide(4,2,0,0);
0410         TCanvas *c9 = new TCanvas("A9","A9 info",1800,1600);
0411         c9->Divide(4,2,0,0);
0412         TCanvas *c11 = new TCanvas("A11","A11 info",1800,1600);
0413         c11->Divide(4,2,0,0);
0414         TCanvas *c12 = new TCanvas("A12","A12 info",1800,1600);
0415         c12->Divide(4,2,0,0);
0416         TCanvas *c13 = new TCanvas("A13","A13 info",1800,1600);
0417         c13->Divide(4,2,0,0);
0418         
0419        
0420         //
0421         
0422         //update the first parameter so we can take different root files as inputs
0423         std::vector<string> fileNames = testParserTStrings(fileName);
0424         std::vector<string> energiesLegend = testParserTStrings(energy);
0425 //        std::vector<string> ColorsHists = testParserTStrings(graphColors);
0426         //std::vector<string> wlayersLegend = testPartTString(Wlayers);
0427         
0428         //with_separator(fileNames,", ");
0429         //cout<< energiesLegend[0] <<" , "<< energiesLegend[1]<<std::endl;
0430         //loop thru the different files
0431         for (Int_t k = 0; k< fileNames.size(); k++){
0432             //now i want to set the different labels
0433             string label = energiesLegend[k];
0434             cout<< label<<endl;
0435             if(label == "3 GeV") {cout<<"3 GeV beam energy had a different assembly configuration. Skipped!"<<endl;continue;}//3GeV files had different assembly
0436 //            {
0437 //                std::vector <int> A0 = {30,28,26,24,22,20,18,16};
0438 //                std::vector <int> A1 = {14,12,10,8,6,4,2,0};
0439 //                std::vector <int> A2 = {32,34,36,38,40,42,44,46};
0440 //                std::vector <int> A3 = {48,50,52,54,56,58,60,62};
0441 //                std::vector <int> A4 = {33,35,37,39,41,43,45,47};
0442 //                std::vector <int> A5 = {49,51,53,55,57,59,61,63};
0443 //                std::vector <int> A6 = {31,29,27,25,23,21,19,17};
0444 //                std::vector <int> A7 = {15,13,11,9,7,5,3,1};
0445 //
0446 //                //board 0 channels
0447 //                std::vector <int> A8 = {30,28,26,24,22,20,18,16};
0448 //                std::vector <int> A9 = {14,12,10,8,6,4,2,0};
0449 //                std::vector <int> A11 = {62,60,58,56,54,52,50,48};
0450 //                std::vector <int> A12 = {46,44,42,40,38,36,34,32};
0451 //                std::vector <int> A13 = {31,29,27,25,23,21,19,17};
0452 //            }
0453             ////===============================
0454             int color = col[k];
0455             //==============
0456             
0457             float x1, x2;
0458             if (k ==0){
0459                 x1 = 0.50;
0460                 x2 = 0.80;
0461             }
0462             else{
0463                 x1 = 0.50 + 0.05*(k/20);
0464                 x2 = 0.80 + 0.05*(k/20);
0465             }
0466             float y1 = 0.95 - 0.07*k;
0467             float y2 = 0.90 - 0.07*k;
0468             
0469             cout << x1 << " " <<y1 << " " << x2 << " "<<y2 <<endl;
0470             //printf("%d %d %d %d \n",x1,x2,y1,y2);
0471             TFile *inputfile = new TFile(fileNames[k].c_str());
0472             
0473             //Now we want to loop through the TH1Fs from the file and get them all!
0474             for (Int_t j = 0; j < gMaxBoard; j++){
0475                 for (Int_t i = 0; i < gMaxChannels; i++){
0476                     if (j == 0){
0477                         if (std::find(A11.begin(), A11.end(),i)!=A11.end() ){
0478                             TLegend* leg1 = new TLegend(x1, y1, x2, y2);
0479                             graphingHistOnPad(c11,i,j,A11,inputfile,"A11",noNoiseHistsLG[j][i],color,y_max,true,rebinfac,xrange,leg1,label);
0480                                 
0481                         }
0482                         if (std::find(A8.begin(), A8.end(),i)!=A8.end() ){
0483                             TLegend* leg2 = new TLegend(x1, y1, x2, y2);
0484                             graphingHistOnPad(c8,i,j,A8,inputfile,"A8",noNoiseHistsLG[j][i],color,y_max,true,rebinfac,xrange,leg2,label);
0485                      
0486                         }
0487                         if (std::find(A2.begin(), A2.end(),i)!=A2.end() ){
0488                             TLegend* leg3 = new TLegend(x1, y1, x2, y2);
0489                             graphingHistOnPad(c2,i,j,A2,inputfile,"A2",noNoiseHistsLG[j][i],color,y_max,true,rebinfac,xrange,leg3,label);
0490                          
0491                         }
0492                         if (std::find(A3.begin(), A3.end(),i)!=A3.end() ){
0493                             TLegend* leg4 = new TLegend(x1, y1, x2, y2);
0494                             graphingHistOnPad(c3,i,j,A3,inputfile,"A3",noNoiseHistsLG[j][i],color,y_max,true,rebinfac,xrange,leg4,label);
0495                             
0496                         }
0497                         if (std::find(A13.begin(), A13.end(),i)!=A13.end() ){
0498                             TLegend* leg5 = new TLegend(x1, y1, x2, y2);
0499                             graphingHistOnPad(c13,i,j,A13,inputfile,"A13",noNoiseHistsLG[j][i],color,y_max,true,rebinfac,xrange,leg5,label);
0500                             
0501                             
0502                         }
0503                         if (std::find(A5.begin(), A5.end(),i)!=A5.end() ){
0504                             TLegend* leg6 = new TLegend(x1, y1, x2, y2);
0505                             graphingHistOnPad(c5,i,j,A5,inputfile,"A5",noNoiseHistsLG[j][i],color,y_max,true,rebinfac,xrange,leg6,label);
0506 
0507                         }
0508                         if (std::find(A6.begin(), A6.end(),i)!=A6.end() ){
0509                             TLegend* leg7 = new TLegend(x1, y1, x2, y2);
0510                             graphingHistOnPad(c6,i,j,A6,inputfile,"A6",noNoiseHistsLG[j][i],color,y_max,true,rebinfac,xrange,leg7,label);
0511 
0512                         }
0513                         if (std::find(A7.begin(), A7.end(),i)!=A7.end() ){
0514                             TLegend* leg8 = new TLegend(x1, y1, x2, y2);
0515                             graphingHistOnPad(c7,i,j,A7,inputfile,"A7",noNoiseHistsLG[j][i],color,y_max,true,rebinfac,xrange,leg8,label);
0516                             
0517                         }
0518                         
0519                         
0520                     }//checking if digitizer board 0
0521                     if (j==1){
0522                         if (std::find(A0.begin(), A0.end(),i)!=A0.end() ){
0523                             TLegend* leg9 = new TLegend(x1, y1, x2, y2);
0524                             graphingHistOnPad(c0,i,j,A0,inputfile,"A0",noNoiseHistsLG[j][i],color,y_max,true,rebinfac,xrange,leg9,label);
0525                             
0526                         }
0527                         if (std::find(A1.begin(), A1.end(),i)!=A1.end() ){
0528                             TLegend* leg10 = new TLegend(x1, y1, x2, y2);
0529                             graphingHistOnPad(c1,i,j,A1,inputfile,"A1",noNoiseHistsLG[j][i],color,y_max,true,rebinfac,xrange,leg10,label);
0530                             
0531                         }
0532                         if (std::find(A9.begin(), A9.end(),i)!=A9.end() ){
0533                             TLegend* leg11 = new TLegend(x1, y1, x2, y2);
0534                             graphingHistOnPad(c9,i,j,A9,inputfile,"A9",noNoiseHistsLG[j][i],color,y_max,true,rebinfac,xrange,leg11,label);
0535                             
0536                         }
0537                         if (std::find(A12.begin(), A12.end(),i)!=A12.end() ){
0538                             TLegend* leg12 = new TLegend(x1, y1, x2, y2);
0539                             graphingHistOnPad(c12,i,j,A12,inputfile,"A12",noNoiseHistsLG[j][i],color,y_max,true,rebinfac,xrange,leg12,label);
0540                             
0541                         }
0542                         if (std::find(A4.begin(), A4.end(),i)!=A4.end() ){
0543                             TLegend* leg13 = new TLegend(x1, y1, x2, y2);
0544                             graphingHistOnPad(c4,i,j,A4,inputfile,"A4",noNoiseHistsLG[j][i],color,y_max,true,rebinfac,xrange,leg13,label);
0545         
0546                         }
0547                         
0548                         
0549                     }//checking if digitizer board 1
0550                     
0551                 }//
0552             }//end of board loop
0553             
0554         }//end of TFile loop!
0555         string CanvasName=outputDir+scan+string("BoardA11.pdf");
0556         TPaveLabel* pl = new TPaveLabel(-2.722343,6.44797,1.572668,6.937022,"A11","br");
0557         pl->Draw();
0558         c11->SaveAs(CanvasName.c_str());
0559         
0560         CanvasName=outputDir+scan+string("BoardA4.pdf");
0561         c4->SaveAs(CanvasName.c_str());
0562         CanvasName=outputDir+scan+string("BoardA12.pdf");
0563         c12->SaveAs(CanvasName.c_str());
0564         CanvasName=outputDir+scan+string("BoardA9.pdf");
0565         c9->SaveAs(CanvasName.c_str());
0566         CanvasName=outputDir+scan+string("BoardA1.pdf");
0567         c1->SaveAs(CanvasName.c_str());
0568         CanvasName=outputDir+scan+string("BoardA0.pdf");
0569         c0->SaveAs(CanvasName.c_str());
0570         CanvasName=outputDir+scan+string("BoardA7.pdf");
0571         c7->SaveAs(CanvasName.c_str());
0572         CanvasName=outputDir+scan+string("BoardA6.pdf");
0573         c6->SaveAs(CanvasName.c_str());
0574          CanvasName=outputDir+scan+string("BoardA5.pdf");
0575         c5->SaveAs(CanvasName.c_str());
0576          CanvasName=outputDir+scan+string("BoardA13.pdf");
0577         c13->SaveAs(CanvasName.c_str());
0578          CanvasName=outputDir+scan+string("BoardA2.pdf");
0579         c2->SaveAs(CanvasName.c_str());
0580          CanvasName=outputDir+scan+string("BoardA3.pdf");
0581         c3->SaveAs(CanvasName.c_str());
0582          CanvasName=outputDir+scan+string("BoardA8.pdf");
0583         c8->SaveAs(CanvasName.c_str());
0584     }//end of checkiing for energy loop
0585     
0586     if (tungstenScan){
0587         
0588         //now i want to make a canvas per board for energy scan!
0589         TCanvas *c0 = new TCanvas("A0","A0 info",1800,1600);
0590         c0->Divide(4,2,0,0);
0591         TCanvas *c1 = new TCanvas("A1","A1 info",1800,1600);
0592         c1->Divide(4,2,0,0);
0593         TCanvas *c2 = new TCanvas("A2","A2 info",1800,1600);
0594         c2->Divide(4,2,0,0);
0595         TCanvas *c3 = new TCanvas("A3","A3 info",1800,1600);
0596         c3->Divide(4,2,0,0);
0597         TCanvas *c4 = new TCanvas("A4","A4 info",1800,1600);
0598         c4->Divide(4,2);
0599         TCanvas *c5 = new TCanvas("A5","A5 info",1800,1600);
0600         c5->Divide(4,2);
0601         TCanvas *c6 = new TCanvas("A6","A6 info",1800,1600);
0602         c6->Divide(4,2);
0603         TCanvas *c7 = new TCanvas("A7","A7 info",1800,1600);
0604         c7->Divide(4,2);
0605         TCanvas *c8 = new TCanvas("A8","A8 info",1800,1600);
0606         c8->Divide(4,2);
0607         TCanvas *c9 = new TCanvas("A9","A9 info",1800,1600);
0608         c9->Divide(4,2);
0609         TCanvas *c11 = new TCanvas("A11","A11 info",1800,1600);
0610         c11->Divide(4,2);
0611         TCanvas *c12 = new TCanvas("A12","A12 info",1800,1600);
0612         c12->Divide(4,2);
0613         TCanvas *c13 = new TCanvas("A13","A13 info",1800,1600);
0614         c13->Divide(4,2);
0615         //
0616         
0617         //update the first parameter so we can take different root files as inputs
0618         std::vector<string> fileNames = testParserTStrings(fileName);
0619         std::vector<string> tungstenLegend = testParserTStrings(Wlayers);
0620         //std::vector<string> wlayersLegend = testPartTString(Wlayers);
0621         
0622         //with_separator(fileNames,", ");
0623         //cout<< fileNames[0] <<" , "<< fileNames[1]<<std::endl;
0624         //loop thru the different files
0625        
0626         for (Int_t k = 0; k< fileNames.size(); k++){
0627             //now i want to set the different labels
0628             string label = tungstenLegend[k];
0629             int color = (int)k*10 + 20;
0630             TFile *inputfile = new TFile(fileNames[k].c_str());
0631             
0632             float x1, x2;
0633             if (k ==0){
0634                 x1 = 0.50;
0635                 x2 = 0.80;
0636             }
0637             else{
0638                 x1 = 0.50 + 0.05*(k/20);
0639                 x2 = 0.80 + 0.05*(k/20);
0640             }
0641             float y1 = 0.95 - 0.07*k;
0642             float y2 = 0.90 - 0.07*k;
0643             
0644             //Now we want to loop through the TH1Fs from the file and get them all!
0645             for (Int_t j = 0; j < gMaxBoard; j++){
0646                 for (Int_t i = 0; i < gMaxChannels; i++){
0647                     if (j == 0){
0648                         if (std::find(A11.begin(), A11.end(),i)!=A11.end() ){
0649                             TLegend* leg1 = new TLegend(x1, y1, x2, y2);
0650                             graphingHistOnPad(c11,i,j,A11,inputfile,"A11",noNoiseHistsLG[j][i],color,y_max,true,rebinfac,xrange,leg1,label);
0651                             
0652                             
0653                         }
0654                         if (std::find(A8.begin(), A8.end(),i)!=A8.end() ){
0655                             TLegend* leg2 = new TLegend(x1, y1, x2, y2);
0656                             graphingHistOnPad(c8,i,j,A8,inputfile,"A8",noNoiseHistsLG[j][i],color,y_max,true,rebinfac,xrange,leg2,label);
0657                             
0658                             
0659                         }
0660                         if (std::find(A2.begin(), A2.end(),i)!=A2.end() ){
0661                            TLegend* leg3 = new TLegend(x1, y1, x2, y2);
0662                             graphingHistOnPad(c2,i,j,A2,inputfile,"A2",noNoiseHistsLG[j][i],color,y_max,true,rebinfac,xrange,leg3,label);
0663                             
0664                         }
0665                         if (std::find(A3.begin(), A3.end(),i)!=A3.end() ){
0666                            TLegend* leg4 = new TLegend(x1, y1, x2, y2);
0667                             graphingHistOnPad(c3,i,j,A3,inputfile,"A3",noNoiseHistsLG[j][i],color,y_max,true,rebinfac,xrange,leg4,label);
0668                         }
0669                         if (std::find(A13.begin(), A13.end(),i)!=A13.end() ){
0670                            TLegend* leg5 = new TLegend(x1, y1, x2, y2);
0671                             graphingHistOnPad(c13,i,j,A13,inputfile,"A13",noNoiseHistsLG[j][i],color,y_max,true,rebinfac,xrange,leg5,label);
0672                             
0673                         }
0674                         if (std::find(A5.begin(), A5.end(),i)!=A5.end() ){
0675                           TLegend* leg6 = new TLegend(x1, y1, x2, y2);
0676                             graphingHistOnPad(c5,i,j,A5,inputfile,"A5",noNoiseHistsLG[j][i],color,y_max,true,rebinfac,xrange,leg6,label);
0677                             
0678                         }
0679                         if (std::find(A6.begin(), A6.end(),i)!=A6.end() ){
0680                             TLegend* leg7 = new TLegend(x1, y1, x2, y2);
0681                             graphingHistOnPad(c6,i,j,A6,inputfile,"A6",noNoiseHistsLG[j][i],color,y_max,true,rebinfac,xrange,leg7,label);
0682                             
0683                         }
0684                         if (std::find(A7.begin(), A7.end(),i)!=A7.end() ){
0685                            TLegend* leg8 = new TLegend(x1, y1, x2, y2);
0686                             graphingHistOnPad(c7,i,j,A7,inputfile,"A7",noNoiseHistsLG[j][i],color,y_max,true,rebinfac,xrange,leg8,label);
0687                             
0688                         }
0689                         
0690                         
0691                     }//checking if digitizer board 0
0692                     if (j==1){
0693                         if (std::find(A0.begin(), A0.end(),i)!=A0.end() ){
0694                             TLegend* leg0 = new TLegend(x1, y1, x2, y2);
0695                             graphingHistOnPad(c0,i,j,A0,inputfile,"A0",noNoiseHistsLG[j][i],color,y_max,true,rebinfac,xrange,leg0,label);
0696                         }
0697                         if (std::find(A1.begin(), A1.end(),i)!=A1.end() ){
0698                            TLegend* leg1 = new TLegend(x1, y1, x2, y2);
0699                             graphingHistOnPad(c1,i,j,A1,inputfile,"A1",noNoiseHistsLG[j][i],color,y_max,true,rebinfac,xrange,leg1,label);
0700                             
0701                         }
0702                         if (std::find(A9.begin(), A9.end(),i)!=A9.end() ){
0703                            TLegend* leg9 = new TLegend(x1, y1, x2, y2);
0704                             graphingHistOnPad(c9,i,j,A9,inputfile,"A9",noNoiseHistsLG[j][i],color,y_max,true,rebinfac,xrange,leg9,label);
0705                             
0706                         }
0707                         if (std::find(A12.begin(), A12.end(),i)!=A12.end() ){
0708                           TLegend* leg12 = new TLegend(x1, y1, x2, y2);
0709                             graphingHistOnPad(c12,i,j,A12,inputfile,"A12",noNoiseHistsLG[j][i],color,y_max,true,rebinfac,xrange,leg12,label);
0710                             
0711                         }
0712                         if (std::find(A4.begin(), A4.end(),i)!=A4.end() ){
0713                           TLegend* leg4 = new TLegend(x1, y1, x2, y2);
0714                             graphingHistOnPad(c4,i,j,A4,inputfile,"A4",noNoiseHistsLG[j][i],color,y_max,true,rebinfac,xrange,leg4,label);
0715                             
0716                         }
0717                         
0718                         
0719                     }//checking if digitizer board 1
0720                     
0721                 }//
0722             }//end of board loop
0723             
0724         }//end of TFile loop!
0725     }//end of checkiing for tungsten loop
0726     
0727     if (Overlay){
0728         TCanvas *canvasPReso8PanelPlot = new TCanvas("A1","A1 info",1800,1600);
0729         canvasPReso8PanelPlot->Divide(4,2,0,0);
0730         
0731 //        Double_t arrayBound8PanPResoX1_4[5];
0732 //        Double_t arrayBound8PanPResoY1_4[4];
0733 //        Double_t relativeMarginsEResoX[3];
0734 //        Double_t relativeMarginsEResoY[3];
0735 //
0736 //        Double_t textSizeSinglePad        = 0.05;
0737 //        Double_t textSizeLabelsPixel      = 35;
0738 //        Double_t textSizeLabelsRel        = 58./1300;
0739 //        textSizeLabelsPixel       = 750*0.05;
0740 //        ReturnCorrectValuesForCanvasScaling(2250,750, 4, 2,0.035, 0.003, 0.01,0.095,arrayBound8PanPResoX1_4,arrayBound8PanPResoY1_4,relativeMarginsEResoX,relativeMarginsEResoY);
0741 //        TCanvas* canvasPReso8PanelPlot = new TCanvas("canvasPReso8PanelPlot","",0,0,2250,750); // gives the page size
0742 //        DrawGammaCanvasSettings( canvasPReso8PanelPlot, 0.05, 0.01, 0.01,0.095);
0743 //
0744 //        TPad* pad1      = new TPad("pad1", "", arrayBound8PanPResoX1_4[0], arrayBound8PanPResoY1_4[2], arrayBound8PanPResoX1_4[1], arrayBound8PanPResoY1_4[1],-1, -1, -2);
0745 //        DrawGammaPadSettings( pad1, relativeMarginsEResoX[0], relativeMarginsEResoX[1], relativeMarginsEResoY[0], relativeMarginsEResoY[2]);
0746 //        pad1->SetNumber(1);
0747 //        pad1->Draw();
0748 //
0749 //        TPad* pad2       = new TPad("pad2", "", arrayBound8PanPResoX1_4[1], arrayBound8PanPResoY1_4[2], arrayBound8PanPResoX1_4[2], arrayBound8PanPResoY1_4[1],-1, -1, -2);
0750 //        DrawGammaPadSettings( pad2, relativeMarginsEResoX[1], relativeMarginsEResoX[1], relativeMarginsEResoY[0], relativeMarginsEResoY[2]);
0751 //        pad2->SetNumber(2);
0752 //        pad2->Draw();
0753 //
0754 //        TPad* pad3       = new TPad("pad3", "", arrayBound8PanPResoX1_4[2], arrayBound8PanPResoY1_4[2], arrayBound8PanPResoX1_4[3], arrayBound8PanPResoY1_4[1],-1, -1, -2);
0755 //        DrawGammaPadSettings( pad3, relativeMarginsEResoX[1], relativeMarginsEResoX[1], relativeMarginsEResoY[0], relativeMarginsEResoY[2]);
0756 //        pad3->SetNumber(3);
0757 //        pad3->Draw();
0758 //
0759 //        TPad* pad4      = new TPad("pad4", "", arrayBound8PanPResoX1_4[3], arrayBound8PanPResoY1_4[2], arrayBound8PanPResoX1_4[4], arrayBound8PanPResoY1_4[1],-1, -1, -2);
0760 //        DrawGammaPadSettings( pad4, relativeMarginsEResoX[1], relativeMarginsEResoX[2], relativeMarginsEResoY[0], relativeMarginsEResoY[2]);
0761 //        pad4->SetNumber(4);
0762 //        pad4->Draw();
0763 //
0764 //        TPad* pad8       = new TPad("pad8", "", arrayBound8PanPResoX1_4[0], arrayBound8PanPResoY1_4[1], arrayBound8PanPResoX1_4[1], arrayBound8PanPResoY1_4[0],-1, -1, -2);
0765 //        DrawGammaPadSettings( pad8, relativeMarginsEResoX[0], relativeMarginsEResoX[1], relativeMarginsEResoY[0], relativeMarginsEResoY[2]);
0766 //        pad8->SetNumber(8);
0767 //        pad8->Draw();
0768 //
0769 //        TPad* pad7       = new TPad("pad7", "", arrayBound8PanPResoX1_4[1], arrayBound8PanPResoY1_4[1], arrayBound8PanPResoX1_4[2], arrayBound8PanPResoY1_4[0],-1, -1, -2);
0770 //        DrawGammaPadSettings( pad7, relativeMarginsEResoX[1], relativeMarginsEResoX[1], relativeMarginsEResoY[0], relativeMarginsEResoY[2]);
0771 //        pad7->SetNumber(7);
0772 //        pad7->Draw();
0773 //
0774 //        TPad* pad6       = new TPad("pad6", "", arrayBound8PanPResoX1_4[2], arrayBound8PanPResoY1_4[1], arrayBound8PanPResoX1_4[3], arrayBound8PanPResoY1_4[0],-1, -1, -2);
0775 //        DrawGammaPadSettings( pad6, relativeMarginsEResoX[1], relativeMarginsEResoX[1], relativeMarginsEResoY[0], relativeMarginsEResoY[2]);
0776 //        pad6->SetNumber(6);
0777 //        pad6->Draw();
0778 //
0779 //        TPad* pad5       = new TPad("pad5", "", arrayBound8PanPResoX1_4[3], arrayBound8PanPResoY1_4[1], arrayBound8PanPResoX1_4[4], arrayBound8PanPResoY1_4[0],-1, -1, -2);
0780 //        DrawGammaPadSettings( pad5, relativeMarginsEResoX[1], relativeMarginsEResoX[2], relativeMarginsEResoY[0], relativeMarginsEResoY[2]);
0781 //        pad5->SetNumber(5);
0782 //        pad5->Draw();
0783     
0784         
0785         //update the first parameter so we can take different root files as inputs
0786         std::vector<string> fileNames = testParserTStrings(fileName);
0787         std::vector<string> energiesLegend = testParserTStrings(energy);
0788         //std::vector<string> wlayersLegend = testPartTString(Wlayers);
0789         
0790         //loop thru the different files
0791         for (Int_t k = 0; k< fileNames.size(); k++){
0792   
0793             if(fileNames.size()>1) {cout<<"Too many files to overlay assembly boards. Please input a single file"<<endl; break;}
0794             TFile *inputfile = new TFile(fileNames[k].c_str());
0795             
0796             float x1[13]={};
0797             float y1[13]={};
0798             float x2[13]={};
0799             float y2[13]={};
0800             for(int i = 0; i<6; i++){
0801             if(i==6)break;
0802                 if (i ==0){
0803                     x1[i] = 0.50;
0804                     x2[i] = 0.70;
0805                 }
0806                 else{
0807                     x1[i] = 0.50 ;
0808                     x2[i] = 0.70 ;
0809                 }
0810                 y1[i] = 0.95 - 0.07*i;
0811                 y2[i] = 0.90 - 0.07*i;
0812             }
0813             for(int i = 6; i<13; i++){
0814                 if (i ==6){
0815                     x1[i] = 0.50+0.2;
0816                     x2[i] = 0.90;
0817                     cout<<"x1 "<<x1[i]<<" x2 "<<x2[i]<<endl;
0818                 }
0819                 else{
0820                     x1[i] = 0.70 ;
0821                     x2[i] = 0.90 ;
0822                      cout<<"x1 "<<x1[i]<<" x2 "<<x2[i]<<endl;
0823                 }
0824                 y1[i] = 0.95 - 0.07*(i-6);
0825                 y2[i] = 0.90 - 0.07*(i-6);
0826                  cout<<"y1 "<<y1[i]<<" y2 "<<y2[i]<<endl;
0827             }
0828             //Now we want to loop through the TH1Fs from the file and get them all!
0829             for (Int_t j = 0; j < gMaxBoard; j++){
0830                 for (Int_t i = 0; i < gMaxChannels; i++){
0831                     if (j == 1){
0832                         if (std::find(A11.begin(), A11.end(),i)!=A11.end() ){
0833                             TLegend* leg11 = new TLegend(x1[0], y1[0], x2[0], y2[0]);
0834                             graphingHistOnSepPad(canvasPReso8PanelPlot,i,j,A11,11,inputfile,"A11",noNoiseHistsLG[j][i],col_overlay,y_max,true,xrange,leg11,rebinfac);
0835             
0836                         }
0837                         if (std::find(A8.begin(), A8.end(),i)!=A8.end() ){
0838                              TLegend* leg2 = new TLegend(x1[1], y1[1], x2[1], y2[1]);
0839                             graphingHistOnSepPad(canvasPReso8PanelPlot,i,j,A8,8,inputfile,"A8",noNoiseHistsLG[j][i],col_overlay,y_max,true,xrange,leg2,rebinfac);
0840                             
0841                         }
0842                         if (std::find(A2.begin(), A2.end(),i)!=A2.end() ){
0843                             TLegend* leg3 = new TLegend(x1[2], y1[2], x2[2], y2[2]);
0844                             graphingHistOnSepPad(canvasPReso8PanelPlot,i,j,A2,2,inputfile,"A2",noNoiseHistsLG[j][i],col_overlay,y_max,true,xrange,leg3,rebinfac);
0845                             
0846                         }
0847                         if (std::find(A3.begin(), A3.end(),i)!=A3.end() ){
0848                             TLegend* leg4 = new TLegend(x1[3], y1[3], x2[3], y2[3]);
0849                             graphingHistOnSepPad(canvasPReso8PanelPlot,i,j,A3,3,inputfile,"A3",noNoiseHistsLG[j][i],col_overlay,y_max,true,xrange,leg4,rebinfac);
0850                         }
0851                         if (std::find(A13.begin(), A13.end(),i)!=A13.end() ){
0852                             TLegend* leg5 = new TLegend(x1[4], y1[4], x2[4], y2[4]);
0853                             graphingHistOnSepPad(canvasPReso8PanelPlot,i,j,A13,13,inputfile,"A13",noNoiseHistsLG[j][i],col_overlay,y_max,true,xrange,leg5,rebinfac);
0854                             
0855                         }
0856                         if (std::find(A5.begin(), A5.end(),i)!=A5.end() ){
0857                            TLegend* leg6 = new TLegend(x1[5], y1[5], x2[5], y2[5]);
0858                             graphingHistOnSepPad(canvasPReso8PanelPlot,i,j,A5,5,inputfile,"A5",noNoiseHistsLG[j][i],col_overlay,y_max,true,xrange,leg6,rebinfac);
0859                             
0860                         }
0861                         if (std::find(A6.begin(), A6.end(),i)!=A6.end() ){
0862                             TLegend* leg7 = new TLegend(x1[6], y1[6], x2[6], y2[6]);
0863                             graphingHistOnSepPad(canvasPReso8PanelPlot,i,j,A6,6,inputfile,"A6",noNoiseHistsLG[j][i],col_overlay,y_max,true,xrange,leg7,rebinfac);
0864                             
0865                         }
0866                         if (std::find(A7.begin(), A7.end(),i)!=A7.end() ){
0867                            TLegend* leg8 = new TLegend(x1[7], y1[7], x2[7], y2[7]);
0868                             graphingHistOnSepPad(canvasPReso8PanelPlot,i,j,A7,7,inputfile,"A7",noNoiseHistsLG[j][i],col_overlay,y_max,true,xrange,leg8,rebinfac);
0869                             
0870                         }
0871                         
0872                         
0873                     }//checking if digitizer board 0
0874                     if (j==0){
0875                         if (std::find(A0.begin(), A0.end(),i)!=A0.end() ){
0876                              TLegend* leg0 = new TLegend(x1[8], y1[8], x2[8], y2[8]);
0877                             graphingHistOnSepPad(canvasPReso8PanelPlot,i,j,A0,0,inputfile,"A0",noNoiseHistsLG[j][i],col_overlay,y_max,true,xrange,leg0,rebinfac);
0878                         }
0879                         if (std::find(A1.begin(), A1.end(),i)!=A1.end() ){
0880                               TLegend* leg1 = new TLegend(x1[9], y1[9], x2[9], y2[9]);
0881                             graphingHistOnSepPad(canvasPReso8PanelPlot,i,j,A1,1,inputfile,"A1",noNoiseHistsLG[j][i],col_overlay,y_max,true,xrange,leg1,rebinfac);
0882                             
0883                         }
0884                         if (std::find(A9.begin(), A9.end(),i)!=A9.end() ){
0885                             TLegend* leg9 = new TLegend(x1[10], y1[10], x2[10], y2[10]);
0886                             graphingHistOnSepPad(canvasPReso8PanelPlot,i,j,A9,9,inputfile,"A9",noNoiseHistsLG[j][i],col_overlay,y_max,true,xrange,leg9,rebinfac);
0887                             
0888                         }
0889                         if (std::find(A12.begin(), A12.end(),i)!=A12.end() ){
0890                              TLegend* leg12 = new TLegend(x1[11], y1[11], x2[11], y2[11]);
0891                             graphingHistOnSepPad(canvasPReso8PanelPlot,i,j,A12,12,inputfile,"A12",noNoiseHistsLG[j][i],col_overlay,y_max,true,xrange,leg12,rebinfac);
0892                             
0893                         }
0894                         if (std::find(A4.begin(), A4.end(),i)!=A4.end() ){
0895                             TLegend* leg4 = new TLegend(x1[12], y1[12], x2[12], y2[12]);
0896                             graphingHistOnSepPad(canvasPReso8PanelPlot,i,j,A4,4,inputfile,"A4",noNoiseHistsLG[j][i],col_overlay,y_max,true,xrange,leg4,rebinfac);
0897                             
0898                         }
0899                         
0900                         
0901                     }//checking if digitizer board 1
0902                     
0903                 }//
0904             }//end of board loop
0905             
0906         }//end of TFile loop!
0907     }//end of checkiing for overlay :)  loop
0908     
0909     
0910 }
0911 
0912 
0913 
0914                         
0915