Back to home page

EIC code displayed by LXR

 
 

    


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

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,string settings, string histPrefix){
0184     
0185     int Index = getIndex(board,i)+1;
0186     if (Index == 100000000) throw std::exception();
0187     int padInd;
0188     if (Index >4 )padInd = 9;
0189     if (Index <5)padInd=-4;
0190     c->cd(abs(padInd-(Index)));
0191     //printf(" found channel %d in vector %s in channel %d and Pad index %d\n",i,assembly.c_str(),Index,abs(padInd-(Index-1)));
0192     hist=GetHist(inputfile, hist,Form("%s_HG_B%d_C%02d",histPrefix.c_str(),j,i));
0193     hist->RebinX(rebinfac);
0194     
0195     hist->SetStats(0);
0196     hist->SetLineColor(color);
0197 //    hist->SetLineWidth(2);
0198     hist->Scale(1./hist->Integral());
0199     hist->SetMaximum(y_max*1.1);
0200     
0201     hist->GetXaxis()->SetRangeUser(0.001,xrange);
0202     hist->GetXaxis()->SetLabelSize(0.04);
0203     hist->GetXaxis()->SetNdivisions(5);
0204     //hist->GetXaxis()->SetLabelOffset(0.500001);
0205     if(iflog==true){gPad->SetLogy();}
0206     //gStyle->SetTitleFontSize(.08);
0207      //gStyle->SetLabelSize(.05, "XY");
0208     hist->GetXaxis()->SetTitleSize(0.05);
0209     hist->GetXaxis()->SetLabelSize(0.052);
0210     hist->GetYaxis()->SetLabelSize(0.052);
0211     hist->GetXaxis()->SetTitleOffset(1.01);
0212     hist->GetYaxis()->SetTitleOffset(0.5000009);
0213     hist->GetYaxis()->SetTitleSize(0.05);
0214 
0215 //    hist->GetXaxis()->SetLabelOffset(1.01);
0216 //    hist->GetYaxis()->SetTitle("Entries");
0217     hist->Draw("SAME Hist");
0218     if (abs(padInd-(Index)) ==4) setLegend(leg,0,0,45,10,hist,label.c_str());
0219     if (abs(padInd-(Index)) ==8)  hist->GetXaxis()->SetTitle("ADC");
0220     if (abs(padInd-(Index)) ==1) {
0221         hist->GetYaxis()->SetTitle("Entries");
0222         TLatex latex11;
0223         latex11.SetNDC ();
0224         latex11.SetTextSize(0.06);
0225         c->cd(1);
0226         latex11.DrawLatex(0.65,0.85 ,Form("%s %s",assembly.c_str(), settings.c_str()));
0227         }
0228         
0229        // gPad->SetTickx(2);
0230     }
0231 
0232 void graphingChannelSorted(TCanvas* c, std::vector <pair<int,int>> channel,  TFile* inputfile, string assembly,TH1D* hist,int color,bool iflog,float y_max, int rebinfac, float xrange, TLegend* leg,string label, string settings,string histPrefix){
0233     //int Index = getIndex(board,i)+1;
0234    //if (Index == 100000000) throw std::exception();
0235     //int padInd;
0236 //    if (Index >4 )padInd = 9;
0237 //    if (Index <5)padInd=-4;
0238     
0239     
0240     //wanna loop thru all the layers here!!
0241     for (Int_t i=0; i<channel.size();i++){
0242         c->cd();
0243         //c->cd(i+1);
0244         hist=GetHist(inputfile, hist,Form("%s_HG_B%d_C%02d",histPrefix.c_str(),channel[i].first,channel[i].second));
0245         hist->RebinX(rebinfac);
0246         
0247         hist->SetStats(0);
0248         hist->SetLineColor(color);
0249         hist->SetLineWidth(2);
0250         hist->Scale(1./hist->Integral());
0251         //hist->SetMaximum(y_max*1.1);
0252         hist->SetMinimum(10);
0253         hist->GetXaxis()->SetRangeUser(0.001,xrange);
0254         hist->GetXaxis()->SetLabelSize(0.04);
0255         hist->GetXaxis()->SetNdivisions(5);
0256         //hist->GetXaxis()->SetLabelOffset(0.500001);
0257         if(iflog==true){gPad->SetLogy();}
0258         //gStyle->SetTitleFontSize(.08);
0259          //gStyle->SetLabelSize(.05, "XY");
0260         hist->GetXaxis()->SetTitleSize(0.05);
0261         hist->GetXaxis()->SetLabelSize(0.052);
0262         hist->GetYaxis()->SetLabelSize(0.052);
0263         hist->GetXaxis()->SetTitleOffset(1.01);
0264         hist->GetYaxis()->SetTitleOffset(0.5000009);
0265         hist->GetYaxis()->SetTitleSize(0.05);
0266 
0267         //setLegend(leg,0,0,45,23,hist,assembly.c_str());
0268     //    hist->GetXaxis()->SetLabelOffset(1.01);
0269     //    hist->GetYaxis()->SetTitle("Entries");
0270         hist->Draw("SAME Hist");
0271         setLegend(leg,0,0,45,25,hist,label.c_str());
0272         hist->GetXaxis()->SetTitle("ADC");
0273        // if (i ==4) setLegend(leg,0,0,45,15,hist,label.c_str());
0274         //if (i == 12  )hist->GetXaxis()->SetTitle("ADC");
0275         //if (i ==1) {
0276             hist->GetYaxis()->SetTitle("Entries");
0277             TLatex latex11;
0278             latex11.SetNDC ();
0279             latex11.SetTextSize(0.06);
0280             //c->cd(1);
0281             latex11.DrawLatex(0.2,0.91 ,assembly.c_str());
0282            // }
0283        // if (i==2){
0284 //            TLatex latex11;
0285 //            latex11.SetNDC ();
0286 //            latex11.SetTextSize(0.06);
0287        //     c->cd(2);
0288             latex11.DrawLatex(0.35,0.91 , Form("%s",settings.c_str()));
0289        // }
0290             
0291     }
0292     
0293     
0294        // gPad->SetTickx(2);
0295 }
0296 
0297 //double getHistMean(TFile* inputfile,TH1D* hist,Int_t i, Int_t j ){
0298 //    hist=GetHist(inputfile, hist,Form("%s_HG_B%d_C%02d",histPrefix.c_str(),j,i));
0299 //    double mean = hist->GetMaximum();
0300 //    return mean;
0301 //}
0302 
0303 
0304 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* lege, int rebinfac,string histPrefix){
0305     int Index = getIndex(board,i)+1;
0306     if (Index == 100000000) throw std::exception();
0307     int padInd;
0308     if (Index >4 )padInd = 9;
0309     if (Index <5)padInd=-4;
0310     canvas->SetFillColor(0);
0311     canvas->SetFrameFillStyle(0);
0312     canvas->cd(abs(padInd-(Index)));
0313 //    int padnum = abs(padInd-(Index));
0314 //    string num = std::to_string(padnum);
0315 //    std::stringstream ss;
0316 //    ss<<"pad"<<num;
0317 //    std::string padname = ss.str();
0318 //    canvas->cd(padnum);
0319     //printf(" found channel %d in vector %s in channel %d and Pad index %d\n",i,assembly.c_str(),Index,abs(padInd-(Index-1)));
0320     hist=GetHist(inputfile, hist,Form("%s_HG_B%d_C%02d",histPrefix.c_str(),j,i));
0321     hist->SetStats(0);
0322     hist->GetXaxis()->SetNdivisions(4);
0323     hist->GetXaxis()->SetTitleSize(0.05);
0324     hist->GetXaxis()->SetLabelSize(0.052);
0325     hist->GetYaxis()->SetLabelSize(0.052);
0326     hist->SetLineColor(color[assembly_number]);
0327     hist->RebinX(rebinfac);
0328     hist->Scale(1./hist->Integral());
0329     hist->GetYaxis()->SetRangeUser(0,y_max*1.1);
0330     hist->SetLineWidth(2);
0331     hist->GetXaxis()->SetRangeUser(5,xrange);
0332     hist->GetXaxis()->SetTitleOffset(1.012);
0333     hist->GetYaxis()->SetTitleOffset(0.9000009);
0334     hist->GetYaxis()->SetTitleSize(0.05);
0335     if(iflog==true){gPad->SetLogy();}
0336     if (abs(padInd-(Index)) ==8)  hist->GetXaxis()->SetTitle("ADC");
0337     if (abs(padInd-(Index)) ==1) {
0338         hist->GetYaxis()->SetTitle("Entries");
0339     
0340     }
0341     //hist->SetLineWidth(6);
0342     hist->Draw("SAME");
0343     if (abs(padInd-(Index)) ==4) setLegend(lege,0,0,10,15,hist,assembly.c_str());
0344     
0345 }
0346 
0347 void DrawGammaCanvasSettings( TCanvas* c1,
0348               Double_t leftMargin,
0349               Double_t rightMargin,
0350               Double_t topMargin,
0351               Double_t bottomMargin){
0352  c1->SetTickx();
0353  c1->SetTicky();
0354  c1->SetGridx(0);
0355  c1->SetGridy(0);
0356  c1->SetLogy(0);
0357  c1->SetLeftMargin(leftMargin);
0358  c1->SetRightMargin(rightMargin);
0359  c1->SetTopMargin(topMargin);
0360  c1->SetBottomMargin(bottomMargin);
0361  c1->SetFillColor(0);
0362 }
0363 void DrawGammaPadSettings( TPad* pad1,
0364             Double_t leftMargin,
0365             Double_t rightMargin,
0366             Double_t topMargin,
0367             Double_t bottomMargin){
0368   pad1->SetFillColor(0);
0369   pad1->GetFrame()->SetFillColor(0);
0370   pad1->SetBorderMode(0);
0371   pad1->SetLeftMargin(leftMargin);
0372   pad1->SetBottomMargin(bottomMargin);
0373   pad1->SetRightMargin(rightMargin);
0374   pad1->SetTopMargin(topMargin);
0375   pad1->SetTickx();
0376   pad1->SetTicky();
0377 }
0378 
0379 
0380 void testBeamPlotterMacrof_only1channel(int assemblynum, string fileName, string energy, string Wlayers, bool energyScan, bool Plot3D, bool Overlay, string outputDir, bool iflog, int rebinfac, float xrange, string scan, bool channelSorted, int Voltage, string particle, bool noiseSubtracted) {
0381     
0382     //create output rootfile
0383     string runNumber =fileName.substr(fileName.find_last_of("R"),fileName.find_last_of("/")-fileName.find_last_of("R"));
0384     cout <<runNumber<<endl;
0385     string rootOutName = outputDir+runNumber +string("_")+scan+string(".root");
0386     cout <<"HEREEEEEEE " <<rootOutName <<endl;
0387     TFile outRoot(rootOutName.c_str(),"RECREATE");
0388     
0389     string histPrefix;
0390     if (noiseSubtracted) histPrefix = "sh";
0391     else histPrefix = "h";
0392         
0393     TH1D* noNoiseHistsLG[gMaxBoard][gMaxChannels];
0394     TH1D* noNoiseHistsHG[gMaxBoard][gMaxChannels];
0395     TH1D* noiseHistsLG[gMaxBoard][gMaxChannels];
0396     TH1D* AllSignalsHistsLG[gMaxBoard][gMaxChannels];
0397     
0398     //given a specific input Voltage find the VoV.
0399     string VoV;
0400     map<int,string> VtoVov = {{58,"5.5 VoV"},{57.5,"5.5 VoV"},{57,"4.5 VoV"},{56.5,"4 VoV"},{56,"3.5 VoV"}};
0401     auto noiseIt = VtoVov.find(Voltage);
0402     VoV = noiseIt->second;
0403     
0404     string settings = particle+ " , "+Wlayers+ " , "+VoV;
0405     //Colors for histograms of energy and tungsten scan
0406     int  col[6] = {kTeal-1, kPink+7, kOrange+4, kBlue-7, kGreen+4, kPink+1};
0407     //Colors for overlaid histograms of all boards
0408     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};
0409 //std::vector <TString> Digiti
0410     
0411     //board 1 channels
0412     //we eventually want to read these from the run setup .txt for the mean time we will hard code them
0413     std::vector <int> A13, A12, A11, A9, A8, A7, A6, A5, A4, A3, A2, A1, A0;
0414     std::vector <pair<int,int>> channel1, channel2,channel3,channel4,channel5,channel6,channel7,channel8;
0415 if(assemblynum==1 && !channelSorted)//we only want these whenever we are plotting the channels for every layer
0416 {
0417    // A11 = {30,28,26,24,22,20,18,16};
0418    // A8 = {14,12,10,8,6,4,2,0};
0419     A2 = {32,34,36,38,40,42,44,46};
0420 //    A3 = {48,50,52,54,56,58,60,62};
0421 //    A13 = {33,35,37,39,41,43,45,47};
0422 //    A5 = {49,51,53,55,57,59,61,63};
0423 //    A6 = {31,29,27,25,23,21,19,17};
0424 //    A7 = {15,13,11,9,7,5,3,1};
0425 //    
0426 //    //board 0 channels
0427 //    A1 = {30,28,26,24,22,20,18,16};
0428 //    A9 = {14,12,10,8,6,4,2,0};
0429 //    A0 = {62,60,58,56,54,52,50,48};
0430 //    A12 = {46,44,42,40,38,36,34,32};A4 = {31,29,27,25,23,21,19,17};
0431    }
0432 
0433 else{
0434     if(energy == 3)
0435     {
0436         A0 = {30,28,26,24,22,20,18,16};
0437         A1 = {14,12,10,8,6,4,2,0};
0438         A2 = {32,34,36,38,40,42,44,46};
0439         A3 = {48,50,52,54,56,58,60,62};
0440         A4 = {33,35,37,39,41,43,45,47};
0441         A5 = {49,51,53,55,57,59,61,63};
0442         A6 = {31,29,27,25,23,21,19,17};
0443         A7 = {15,13,11,9,7,5,3,1};
0444         
0445         //board 0 channels
0446         A8 = {30,28,26,24,22,20,18,16};
0447         A9 = {14,12,10,8,6,4,2,0};
0448         A11 = {62,60,58,56,54,52,50,48};
0449         A12 = {46,44,42,40,38,36,34,32};
0450         A13 = {31,29,27,25,23,21,19,17};
0451     }
0452 }
0453     std::vector <float> maxes;
0454     //we need to find the max y values and any rebinning for alllllll the different data we want!
0455     std::vector<string> getMaxEntriesInFiles = testParserTStrings(fileName);
0456     for (Int_t k = 0; k< getMaxEntriesInFiles.size(); k++){
0457         TFile *inputfileMaxEntries = new TFile(getMaxEntriesInFiles[k].c_str());
0458         //for (Int_t j = 0; j ==1; j++){
0459         for (Int_t j = 0; j < gMaxBoard; j++){
0460             printf("Going thru board  %d to get max y range \n",j);
0461             //for (Int_t i = 0; i ==0; i++){
0462             for (Int_t i = 0; i < gMaxChannels; i++){
0463                 noNoiseHistsHG[j][i] = GetHist(inputfileMaxEntries,noNoiseHistsLG[j][i],Form("%s_HG_B%d_C%02d",histPrefix.c_str(),j,i));
0464                 noNoiseHistsHG[j][i]->RebinX(rebinfac);
0465                 noNoiseHistsHG[j][i]->Scale(1./noNoiseHistsHG[j][i]->Integral());
0466                 maxes.push_back(noNoiseHistsHG[j][i]->GetMaximum());
0467             }
0468         }
0469         printf("Going thru file %d to get max y range \n",k);
0470     }//finished looped thru file names :)
0471     int max_y = distance(maxes.begin(), max_element(maxes.begin(), maxes.end()));
0472     float y_max = maxes[max_y]*1.10;
0473     
0474     cout<<y_max<<endl;
0475     
0476     //channel sorted means we want the plot of the same assembly channel for all layers.
0477     if (channelSorted){
0478         
0479         //channel mapping from first entry is CAEN board # and second entry is the channel
0480 //        channel1 =  {
0481 //            {1,30},{1,14},{1,32},{1,48},{1,33},{1,49},{1,31},{1,15},{0,30},{0,14},{0,62},{0,46},{0,31} };
0482 //        
0483 //        channel2 =  {
0484 //            {1,28},{1,12},{1,34},{1,50},{1,35},{1,51},{1,29},{1,13},{0,28},{0,12},{0,60},{0,44},{0,29} };
0485  //       channel3 =  { {1,10}};
0486 //            {1,26},{1,10},{1,36},{1,52},{1,37},{1,53},{1,27},{1,11},{0,26},{0,10},{0,58},{0,42},{0,27} };
0487 //        channel4 =  {
0488 //            {1,24},{1,8},{1,38},{1,54},{1,39},{1,55},{1,25},{1,9},{0,24},{0,8},{0,56},{0,40},{0,25} };
0489 //        channel5 =  {
0490 //            {1,22},{1,6},{1,40},{1,56},{1,41},{1,57},{1,23},{1,7},{0,22},{0,6},{0,54},{0,38},{0,23} };
0491 //        channel6={{1,42}};
0492         //        channel6 =  {
0493 //            {1,20},{1,4},{1,42},{1,58},{1,43},{1,59},{1,21},{1,5},{0,20},{0,4},{0,52},{0,36},{0,21} };
0494        // channel7 =  {
0495          //   {1,18},{1,2},{1,44},{1,60},{1,45},{1,61},{1,19},{1,3},{0,18},{0,2},{0,50},{0,34},{0,19} };
0496         
0497         channel5={ {1,40}};
0498         //channel8 =  {
0499            // {1,16},{1,0},{1,46},{1,62},{1,47},{1,63},{1,17},{1,1},{0,16},{0,0},{0,48},{0,32},{0,17} };
0500         //we need 8 Canvases
0501         TCanvas *c8 = new TCanvas("Chan1","Channe1 info",1800,1600);
0502 //        c1->Divide(5,3,0,0);
0503 //        TCanvas *c2 = new TCanvas("Chan2","Channel2 info",1800,1600);
0504 //        c2->Divide(5,3,0,0);
0505 //        TCanvas *c3 = new TCanvas("Chan3","Channel3 info",1800,1600);
0506 //        c3->Divide(5,3,0,0);
0507 //        TCanvas *c4 = new TCanvas("Chan4","Channel4 info",1800,1600);
0508 //        c4->Divide(5,3,0,0);
0509 //        TCanvas *c5 = new TCanvas("Chan5","Channel5 info",1800,1600);
0510 //        c5->Divide(5,3,0,0);
0511 //        TCanvas *c6 = new TCanvas("Chan6","Channel6 info",1800,1600);
0512 //        c6->Divide(5,3,0,0);
0513 //        TCanvas *c7 = new TCanvas("Chan7","Channel7 info",1800,1600);
0514 //        c7->Divide(5,3,0,0);
0515 //        TCanvas *c8 = new TCanvas("Chan8","Channel8 info",1800,1600);
0516 //        c8->Divide(5,3,0,0);
0517 //    
0518         //first we want to loop thru all the channels we give them :0
0519         //we want to loop thru the all the entries in the channel vectors
0520         std::vector<string> fileNames = testParserTStrings(fileName);
0521         std::vector<string> energiesLegend = testParserTStrings(energy);
0522         
0523         for (Int_t k = 0; k< fileNames.size(); k++){
0524             //now i want to set the different labels
0525             string label = energiesLegend[k];
0526             TFile *inputfile = new TFile(fileNames[k].c_str());
0527             int color = col[k];
0528             float x1, x2;
0529             if (k ==0){
0530                 x1 = 0.65;
0531                 x2 = 0.89;
0532             }
0533             else{
0534                 x1 = 0.65 + 0.06*(k/20);
0535                 x2 = 0.89 + 0.06*(k/20);
0536             }
0537             float y1 = 0.89 - 0.05*k;
0538             float y2 = 0.85 - 0.05*k;
0539             
0540             cout << x1 << " " <<y1 << " " << x2 << " "<<y2 <<endl;
0541             //printf("%d %d %d %d \n",x1,x2,y1,y2);
0542             //now loop thru the channels and plot them :D
0543             
0544             TLegend* leg1 = new TLegend(x1, y1, x2, y2);
0545 //            TLegend* leg2 = new TLegend(x1, y1, x2, y2);
0546 //            TLegend* leg3 = new TLegend(x1, y1, x2, y2);
0547 //            TLegend* leg4 = new TLegend(x1, y1, x2, y2);
0548 //            TLegend* leg5 = new TLegend(x1, y1, x2, y2);
0549 //            TLegend* leg6 = new TLegend(x1, y1, x2, y2);
0550 //            TLegend* leg7 = new TLegend(x1, y1, x2, y2);
0551 //            TLegend* leg8 = new TLegend(x1, y1, x2, y2);
0552             
0553             //(TCanvas* c, std::vector <pair<int,int>> channel,  TFile* inputfile, string assembly,TH1D* hist,int color,float y_max,bool iflog, int rebinfac, float xrange, TLegend* leg,string label)
0554 //            graphingChannelSorted(c1,channel1,inputfile,"Channel1",noNoiseHistsLG[0][0],color,true,y_max,rebinfac,xrange,leg1,label,settings,histPrefix);
0555 //            graphingChannelSorted(c2,channel2,inputfile,"Channel2",noNoiseHistsLG[0][0],color,true,y_max,rebinfac,xrange,leg2,label,settings,histPrefix);
0556 //            graphingChannelSorted(c3,channel3,inputfile,"Channel3",noNoiseHistsLG[0][0],color,true,y_max,rebinfac,xrange,leg3,label,settings,histPrefix);
0557 //            graphingChannelSorted(c4,channel4,inputfile,"Channel4",noNoiseHistsLG[0][0],color,true,y_max,rebinfac,xrange,leg4,label,settings,histPrefix);
0558 //            graphingChannelSorted(c5,channel5,inputfile,"Channel5",noNoiseHistsLG[0][0],color,true,y_max,rebinfac,xrange,leg5,label,settings,histPrefix);
0559 //            graphingChannelSorted(c6,channel6,inputfile,"Channel6",noNoiseHistsLG[0][0],color,true,y_max,rebinfac,xrange,leg6,label,settings,histPrefix);
0560 //            graphingChannelSorted(c7,channel7,inputfile,"Channel7",noNoiseHistsLG[0][0],color,true,y_max,rebinfac,xrange,leg7,label,settings,histPrefix);
0561             graphingChannelSorted(c8,channel5,inputfile,"Channel5",noNoiseHistsLG[0][0],color,true,y_max,rebinfac,xrange,leg1,label,settings,histPrefix);
0562             
0563             string CanvasName=outputDir+scan+string("Chan5.pdf");
0564             TPaveLabel* pl = new TPaveLabel(-2.722343,6.44797,1.572668,6.937022,"Channel6","br");
0565             pl->Draw();
0566 //            c1->SaveAs(CanvasName.c_str());
0567 //            CanvasName=outputDir+scan+string("Chan2.pdf");
0568 //            c2->SaveAs(CanvasName.c_str());
0569 //            CanvasName=outputDir+scan+string("Chan3.pdf");
0570 //            c3->SaveAs(CanvasName.c_str());
0571 //            CanvasName=outputDir+scan+string("Chan4.pdf");
0572 //            c4->SaveAs(CanvasName.c_str());
0573 //            CanvasName=outputDir+scan+string("Chan5.pdf");
0574 //            c5->SaveAs(CanvasName.c_str());
0575 //            CanvasName=outputDir+scan+string("Chan6.pdf");
0576 //            c6->SaveAs(CanvasName.c_str());
0577 //            CanvasName=outputDir+scan+string("Chan7.pdf");
0578 //            c7->SaveAs(CanvasName.c_str());
0579             CanvasName=outputDir+scan+string("Chan5.pdf");
0580             c8->SaveAs(CanvasName.c_str());
0581             outRoot.cd();
0582 //            c1->Write();
0583 //            c2->Write();
0584 //            c3->Write();
0585 //            c4->Write();
0586 //            c5->Write();
0587 //            c6->Write();
0588 //            c7->Write();
0589             c8->Write();
0590             //            graphingHistOnPad(c11,i,j,A11,inputfile,"A11",noNoiseHistsLG[j][i],color,y_max,true,rebinfac,xrange,leg1,label);
0591             
0592         }//finishing all channels plots
0593         
0594 //        delete c1;
0595 //        delete c2;
0596 //        delete c3;
0597 //        delete c4;
0598 //        delete c5;
0599 //        delete c6;
0600 //        delete c7;
0601         delete c8;
0602     }//finishing channel sort!
0603     
0604     
0605     //std::vector <int> chan8 ={16,0,}
0606 //    if (energyScan){
0607 //        
0608 //        
0609 //        
0610 //        //now i want to make a canvas per board for energy scan!
0611 //        TCanvas *c0 = new TCanvas("A0","A0 info",1800,1600);
0612 //        c0->Divide(4,2,0,0);
0613 //        //c0->Divide(4,2,0.00000000001,0.00000000001);
0614 //        
0615 //        TCanvas *c1 = new TCanvas("A1","A1 info",1800,1600);
0616 //        c1->Divide(4,2,0,0);
0617 //        
0618 //        TCanvas *c2 = new TCanvas("A2","A2 info",1800,1600);
0619 //        c2->Divide(4,2,0,0);
0620 //        TCanvas *c3 = new TCanvas("A3","A3 info",1800,1600);
0621 //        c3->Divide(4,2,0,0);
0622 //        TCanvas *c4 = new TCanvas("A4","A4 info",1800,1600);
0623 //        c4->Divide(4,2,0,0);
0624 //        TCanvas *c5 = new TCanvas("A5","A5 info",1800,1600);
0625 //        c5->Divide(4,2,0,0);
0626 //        TCanvas *c6 = new TCanvas("A6","A6 info",1800,1600);
0627 //        c6->Divide(4,2,0,0);
0628 //        TCanvas *c7 = new TCanvas("A7","A7 info",1800,1600);
0629 //        c7->Divide(4,2,0,0);
0630 //        TCanvas *c8 = new TCanvas("A8","A8 info",1800,1600);
0631 //        c8->Divide(4,2,0,0);
0632 //        TCanvas *c9 = new TCanvas("A9","A9 info",1800,1600);
0633 //        c9->Divide(4,2,0,0);
0634 //        TCanvas *c11 = new TCanvas("A11","A11 info",1800,1600);
0635 //        c11->Divide(4,2,0,0);
0636 //        TCanvas *c12 = new TCanvas("A12","A12 info",1800,1600);
0637 //        c12->Divide(4,2,0,0);
0638 //        TCanvas *c13 = new TCanvas("A13","A13 info",1800,1600);
0639 //        c13->Divide(4,2,0,0);
0640 //        
0641 //       
0642 //        //
0643 //        
0644 //        //update the first parameter so we can take different root files as inputs
0645 //        std::vector<string> fileNames = testParserTStrings(fileName);
0646 //        std::vector<string> energiesLegend = testParserTStrings(energy);
0647 ////        std::vector<string> ColorsHists = testParserTStrings(graphColors);
0648 //        //std::vector<string> wlayersLegend = testPartTString(Wlayers);
0649 //        
0650 //        //with_separator(fileNames,", ");
0651 //        //cout<< energiesLegend[0] <<" , "<< energiesLegend[1]<<std::endl;
0652 //        //loop thru the different files
0653 //        for (Int_t k = 0; k< fileNames.size(); k++){
0654 //            //now i want to set the different labels
0655 //            string label = energiesLegend[k];
0656 //            cout<< label<<endl;
0657 //            if(label == "3 GeV") {cout<<"3 GeV beam energy had a different assembly configuration. Skipped!"<<endl;continue;}//3GeV files had different assembly
0658 ////            {
0659 ////                std::vector <int> A0 = {30,28,26,24,22,20,18,16};
0660 ////                std::vector <int> A1 = {14,12,10,8,6,4,2,0};
0661 ////                std::vector <int> A2 = {32,34,36,38,40,42,44,46};
0662 ////                std::vector <int> A3 = {48,50,52,54,56,58,60,62};
0663 ////                std::vector <int> A4 = {33,35,37,39,41,43,45,47};
0664 ////                std::vector <int> A5 = {49,51,53,55,57,59,61,63};
0665 ////                std::vector <int> A6 = {31,29,27,25,23,21,19,17};
0666 ////                std::vector <int> A7 = {15,13,11,9,7,5,3,1};
0667 ////
0668 ////                //board 0 channels
0669 ////                std::vector <int> A8 = {30,28,26,24,22,20,18,16};
0670 ////                std::vector <int> A9 = {14,12,10,8,6,4,2,0};
0671 ////                std::vector <int> A11 = {62,60,58,56,54,52,50,48};
0672 ////                std::vector <int> A12 = {46,44,42,40,38,36,34,32};
0673 ////                std::vector <int> A13 = {31,29,27,25,23,21,19,17};
0674 ////            }
0675 //            ////===============================
0676 //            int color = col[k];
0677 //            //==============
0678 //            
0679 //            float x1, x2;
0680 //            if (k ==0){
0681 //                x1 = 0.50;
0682 //                x2 = 0.80;
0683 //            }
0684 //            else{
0685 //                x1 = 0.50 + 0.05*(k/20);
0686 //                x2 = 0.80 + 0.05*(k/20);
0687 //            }
0688 //            float y1 = 0.95 - 0.07*k;
0689 //            float y2 = 0.90 - 0.07*k;
0690 //            
0691 //            cout << x1 << " " <<y1 << " " << x2 << " "<<y2 <<endl;
0692 //            //printf("%d %d %d %d \n",x1,x2,y1,y2);
0693 //            TFile *inputfile = new TFile(fileNames[k].c_str());
0694 //            
0695 //            //Now we want to loop through the TH1Fs from the file and get them all!
0696 //            for (Int_t j = 0; j < gMaxBoard; j++){
0697 //                for (Int_t i = 0; i < gMaxChannels; i++){
0698 //                    if (j == 0){
0699 //                        if (std::find(A11.begin(), A11.end(),i)!=A11.end() ){
0700 //                            TLegend* leg1 = new TLegend(x1, y1, x2, y2);
0701 //                            graphingHistOnPad(c11,i,j,A11,inputfile,"A11",noNoiseHistsLG[j][i],color,y_max,true,rebinfac,xrange,leg1,label,settings,histPrefix);
0702 //                                
0703 //                        }
0704 //                        if (std::find(A8.begin(), A8.end(),i)!=A8.end() ){
0705 //                            TLegend* leg2 = new TLegend(x1, y1, x2, y2);
0706 //                            graphingHistOnPad(c8,i,j,A8,inputfile,"A8",noNoiseHistsLG[j][i],color,y_max,true,rebinfac,xrange,leg2,label,settings,histPrefix);
0707 //                     
0708 //                        }
0709 //                        if (std::find(A2.begin(), A2.end(),i)!=A2.end() ){
0710 //                            TLegend* leg3 = new TLegend(x1, y1, x2, y2);
0711 //                            graphingHistOnPad(c2,i,j,A2,inputfile,"A2",noNoiseHistsLG[j][i],color,y_max,true,rebinfac,xrange,leg3,label,settings,histPrefix);
0712 //                         
0713 //                        }
0714 //                        if (std::find(A3.begin(), A3.end(),i)!=A3.end() ){
0715 //                            TLegend* leg4 = new TLegend(x1, y1, x2, y2);
0716 //                            graphingHistOnPad(c3,i,j,A3,inputfile,"A3",noNoiseHistsLG[j][i],color,y_max,true,rebinfac,xrange,leg4,label,settings,histPrefix);
0717 //                            
0718 //                        }
0719 //                        if (std::find(A13.begin(), A13.end(),i)!=A13.end() ){
0720 //                            TLegend* leg5 = new TLegend(x1, y1, x2, y2);
0721 //                            graphingHistOnPad(c13,i,j,A13,inputfile,"A13",noNoiseHistsLG[j][i],color,y_max,true,rebinfac,xrange,leg5,label,settings,histPrefix);
0722 //                            
0723 //                            
0724 //                        }
0725 //                        if (std::find(A5.begin(), A5.end(),i)!=A5.end() ){
0726 //                            TLegend* leg6 = new TLegend(x1, y1, x2, y2);
0727 //                            graphingHistOnPad(c5,i,j,A5,inputfile,"A5",noNoiseHistsLG[j][i],color,y_max,true,rebinfac,xrange,leg6,label,settings,histPrefix);
0728 //
0729 //                        }
0730 //                        if (std::find(A6.begin(), A6.end(),i)!=A6.end() ){
0731 //                            TLegend* leg7 = new TLegend(x1, y1, x2, y2);
0732 //                            graphingHistOnPad(c6,i,j,A6,inputfile,"A6",noNoiseHistsLG[j][i],color,y_max,true,rebinfac,xrange,leg7,label,settings,histPrefix);
0733 //
0734 //                        }
0735 //                        if (std::find(A7.begin(), A7.end(),i)!=A7.end() ){
0736 //                            TLegend* leg8 = new TLegend(x1, y1, x2, y2);
0737 //                            graphingHistOnPad(c7,i,j,A7,inputfile,"A7",noNoiseHistsLG[j][i],color,y_max,true,rebinfac,xrange,leg8,label,settings,histPrefix);
0738 //                            
0739 //                        }
0740 //                        
0741 //                        
0742 //                    }//checking if digitizer board 0
0743 //                    if (j==1){
0744 //                        if (std::find(A0.begin(), A0.end(),i)!=A0.end() ){
0745 //                            TLegend* leg9 = new TLegend(x1, y1, x2, y2);
0746 //                            graphingHistOnPad(c0,i,j,A0,inputfile,"A0",noNoiseHistsLG[j][i],color,y_max,true,rebinfac,xrange,leg9,label,settings,histPrefix);
0747 //                            
0748 //                        }
0749 //                        if (std::find(A1.begin(), A1.end(),i)!=A1.end() ){
0750 //                            TLegend* leg10 = new TLegend(x1, y1, x2, y2);
0751 //                            graphingHistOnPad(c1,i,j,A1,inputfile,"A1",noNoiseHistsLG[j][i],color,y_max,true,rebinfac,xrange,leg10,label,settings,histPrefix);
0752 //                            
0753 //                        }
0754 //                        if (std::find(A9.begin(), A9.end(),i)!=A9.end() ){
0755 //                            TLegend* leg11 = new TLegend(x1, y1, x2, y2);
0756 //                            graphingHistOnPad(c9,i,j,A9,inputfile,"A9",noNoiseHistsLG[j][i],color,y_max,true,rebinfac,xrange,leg11,label,settings,histPrefix);
0757 //                            
0758 //                        }
0759 //                        if (std::find(A12.begin(), A12.end(),i)!=A12.end() ){
0760 //                            TLegend* leg12 = new TLegend(x1, y1, x2, y2);
0761 //                            graphingHistOnPad(c12,i,j,A12,inputfile,"A12",noNoiseHistsLG[j][i],color,y_max,true,rebinfac,xrange,leg12,label,settings,histPrefix);
0762 //                            
0763 //                        }
0764 //                        if (std::find(A4.begin(), A4.end(),i)!=A4.end() ){
0765 //                            TLegend* leg13 = new TLegend(x1, y1, x2, y2);
0766 //                            graphingHistOnPad(c4,i,j,A4,inputfile,"A4",noNoiseHistsLG[j][i],color,y_max,true,rebinfac,xrange,leg13,label,settings,histPrefix);
0767 //        
0768 //                        }
0769 //                        
0770 //                        
0771 //                    }//checking if digitizer board 1
0772 //                    
0773 //                }//
0774 //            }//end of board loop
0775 //            
0776 //        }//end of TFile loop!
0777 //        string CanvasName=outputDir+scan+string("BoardA11.pdf");
0778 //        TPaveLabel* pl = new TPaveLabel(-2.722343,6.44797,1.572668,6.937022,"A11","br");
0779 //        pl->Draw();
0780 //        c11->SaveAs(CanvasName.c_str());
0781 //        
0782 //        CanvasName=outputDir+scan+string("BoardA4.pdf");
0783 //        c4->SaveAs(CanvasName.c_str());
0784 //        CanvasName=outputDir+scan+string("BoardA12.pdf");
0785 //        c12->SaveAs(CanvasName.c_str());
0786 //        CanvasName=outputDir+scan+string("BoardA9.pdf");
0787 //        c9->SaveAs(CanvasName.c_str());
0788 //        CanvasName=outputDir+scan+string("BoardA1.pdf");
0789 //        c1->SaveAs(CanvasName.c_str());
0790 //        CanvasName=outputDir+scan+string("BoardA0.pdf");
0791 //        c0->SaveAs(CanvasName.c_str());
0792 //        CanvasName=outputDir+scan+string("BoardA7.pdf");
0793 //        c7->SaveAs(CanvasName.c_str());
0794 //        CanvasName=outputDir+scan+string("BoardA6.pdf");
0795 //        c6->SaveAs(CanvasName.c_str());
0796 //         CanvasName=outputDir+scan+string("BoardA5.pdf");
0797 //        c5->SaveAs(CanvasName.c_str());
0798 //         CanvasName=outputDir+scan+string("BoardA13.pdf");
0799 //        c13->SaveAs(CanvasName.c_str());
0800 //         CanvasName=outputDir+scan+string("BoardA2.pdf");
0801 //        c2->SaveAs(CanvasName.c_str());
0802 //         CanvasName=outputDir+scan+string("BoardA3.pdf");
0803 //        c3->SaveAs(CanvasName.c_str());
0804 //         CanvasName=outputDir+scan+string("BoardA8.pdf");
0805 //        c8->SaveAs(CanvasName.c_str());
0806 //        
0807 //        outRoot.cd();
0808 //        c1->Write();
0809 //        c2->Write();
0810 //        c3->Write();
0811 //        c4->Write();
0812 //        c5->Write();
0813 //        c6->Write();
0814 //        c7->Write();
0815 //        c8->Write();
0816 //        c9->Write();
0817 //        c11->Write();
0818 //        c12->Write();
0819 //        c13->Write();
0820 //        c0->Write();
0821 //        
0822 //
0823 //        delete c1;
0824 //        delete c2;
0825 //        delete c3;
0826 //        delete c4;
0827 //        delete c5;
0828 //        delete c6;
0829 //        delete c7;
0830 //        delete c8;
0831 //        delete c9;
0832 //        delete c11;
0833 //        delete c12;
0834 //        delete c13;
0835 //        delete c0;
0836 //    }//end of checkiing for energy loop
0837 //    
0838 //
0839 //    
0840 //            
0841 //            if (Plot3D){
0842 //                TH3D* hist3DMap = new TH3D("h_map_z_x_y", "3D Average Energy Distribution;Depth ;x - Row ;y - Column", 13, -0.5, 12.5, 4, -0.5, 3.5, 2, -0.5, 1.5);
0843 //                //want to
0844 //                A11 = {30,28,26,24,22,20,18,16};
0845 //                A8 = {14,12,10,8,6,4,2,0};
0846 //                A2 = {32,34,36,38,40,42,44,46};
0847 //                A3 = {48,50,52,54,56,58,60,62};
0848 //                A13 = {33,35,37,39,41,43,45,47};
0849 //                A5 = {49,51,53,55,57,59,61,63};
0850 //                A6 = {31,29,27,25,23,21,19,17};
0851 //                A7 = {15,13,11,9,7,5,3,1};
0852 //                
0853 //                //board 0 channels
0854 //                A1 = {30,28,26,24,22,20,18,16};
0855 //                A9 = {14,12,10,8,6,4,2,0};
0856 //                A0 = {62,60,58,56,54,52,50,48};
0857 //                A12 = {46,44,42,40,38,36,34,32};
0858 //                A4 = {31,29,27,25,23,21,19,17};
0859 //                
0860 //                //now we want the board location
0861 //                
0862 //                map<int,pair<int,int>> boardLocationMapping = {
0863 //                    {1,{0,0}},{2,{0,1}},{3,{0,2}},{4,{0,3}},{5,{1,3}},{6,{1,2}},{7,{1,1}},{8,{1,0}}
0864 //                };
0865 //                
0866 //                
0867 //                
0868 //                //now i want to loop thru all the files, boards and channels
0869 //                //std::vector<string> energiesLegend = testParserTStrings(energy);
0870 //                //string Label = energiesLegend[k];
0871 //
0872 //                for (Int_t k = 0; k< getMaxEntriesInFiles.size(); k++){
0873 //                    TFile *inputfileMaxEntries = new TFile(getMaxEntriesInFiles[k].c_str());
0874 //                   
0875 //                    for (Int_t j = 0; j < gMaxBoard; j++){
0876 //                        printf("Going thru board  %d to get max y range \n",j);
0877 //                        for (Int_t i = 0; i < gMaxChannels; i++){
0878 //                            //cout << " HEREEEEEEE: "<<i<<endl;
0879 //                            int padInd,channel,Index;
0880 //                            double mean;
0881 //                            TH1D* meanHist;
0882 //                            //auto it = boardLocationMapping.find(i);
0883 //                            //iterator it;
0884 //                            if (j == 1){
0885 //                                if (std::find(A11.begin(), A11.end(),i)!=A11.end() )
0886 //                                {
0887 //                                    Index = getIndex(A11,i)+1;
0888 //                                    if (Index >4 )padInd = 9;
0889 //                                    if (Index <5)padInd=-4;
0890 //                                    channel = abs(padInd-(Index));
0891 //                                    meanHist= (TH1D*)(inputfileMaxEntries->Get(Form("%s_HG_B%d_C%02d",histPrefix.c_str(),j,i)));
0892 //                                    //mean = meanHist->GetMean();
0893 //                                    mean = meanHist->GetMean();
0894 //                                    
0895 //                                    //GetHist(inputfileMaxEntries,noNoiseHistsLG[j][i],Form("%s_HG_B%d_C%02d",histPrefix.c_str(),j,i));
0896 //                                    //mean = getHistMean(inputfileMaxEntries,noNoiseHistsLG[j][i],j,i);
0897 //                                    auto it = boardLocationMapping.find(channel);
0898 //                                    if (mean>1000)cout << mean << " " << i << " "<<(double)it->second.second<<" "<<(double)it->second.first<<endl;
0899 //                                    //now we want to get the 3d plot.
0900 //                                    //cout << mean << " " << i << " "<<(double)it->second.second<<" "<<(double)it->second.first<<endl;
0901 //                                    hist3DMap->Fill((double)0,(double)it->second.second,(double)it->second.first,mean);
0902 //                                }
0903 //                                if (std::find(A8.begin(), A8.end(),i)!=A8.end() ){
0904 //                                    Index = getIndex(A8,i)+1;
0905 //                                    if (Index >4 )padInd = 9;
0906 //                                    if (Index <5)padInd=-4;
0907 //                                    channel = abs(padInd-(Index));
0908 //                                    meanHist= (TH1D*)(inputfileMaxEntries->Get(Form("%s_HG_B%d_C%02d",histPrefix.c_str(),j,i)));
0909 //                                    mean = meanHist->GetMean();
0910 //                                    auto it1 = boardLocationMapping.find(channel);
0911 //                                    cout << mean << " " << i << " "<<(double)it1->second.second<<" "<<(double)it1->second.first<<endl;
0912 //                                    //now we want to get the 3d plot.
0913 //                                    hist3DMap->Fill((double)1,(double)it1->second.second,(double)it1->second.first,mean);
0914 //
0915 //                                }
0916 //                                if (std::find(A2.begin(), A2.end(),i)!=A2.end() ){
0917 //                                    Index = getIndex(A2,i)+1;
0918 //                                    if (Index >4 )padInd = 9;
0919 //                                    if (Index <5)padInd=-4;
0920 //                                    channel = abs(padInd-(Index));
0921 //                                    meanHist= (TH1D*)(inputfileMaxEntries->Get(Form("%s_HG_B%d_C%02d",histPrefix.c_str(),j,i)));
0922 //                                    mean = meanHist->GetMean();
0923 //                                    auto it2 = boardLocationMapping.find(channel);
0924 //                                    if (mean>1000)cout << mean << " " << i << " "<<(double)it2->second.second<<" "<<(double)it2->second.first<<endl;
0925 //                                    //now we want to get the 3d plot.
0926 //                                    hist3DMap->Fill((double)2,(double)it2->second.second,(double)it2->second.first,mean);
0927 //
0928 //                                }
0929 //                                if (std::find(A3.begin(), A3.end(),i)!=A3.end() ){
0930 //                                    Index = getIndex(A3,i)+1;
0931 //                                    if (Index >4 )padInd = 9;
0932 //                                    if (Index <5)padInd=-4;
0933 //                                    channel = abs(padInd-(Index));
0934 //                                    meanHist= (TH1D*)(inputfileMaxEntries->Get(Form("%s_HG_B%d_C%02d",histPrefix.c_str(),j,i)));
0935 //                                    mean = meanHist->GetMean();
0936 //                                    auto it3 = boardLocationMapping.find(channel);
0937 //                                    if (mean>1000)cout << mean << " " << i << " "<<(double)it3->second.second<<" "<<(double)it3->second.first<<endl;
0938 //                                    //now we want to get the 3d plot.
0939 //                                    hist3DMap->Fill((double)3,(double)it3->second.second,(double)it3->second.first,mean);
0940 //                                }
0941 //                                if (std::find(A13.begin(), A13.end(),i)!=A13.end() ){
0942 //                                    Index = getIndex(A13,i)+1;
0943 //                                    if (Index >4 )padInd = 9;
0944 //                                    if (Index <5)padInd=-4;
0945 //                                    channel = abs(padInd-(Index));
0946 //                                    meanHist= (TH1D*)(inputfileMaxEntries->Get(Form("%s_HG_B%d_C%02d",histPrefix.c_str(),j,i)));
0947 //                                    mean = meanHist->GetMean();
0948 //                                    
0949 //                                    //GetHist(inputfileMaxEntries,noNoiseHistsLG[j][i],Form("%s_HG_B%d_C%02d",histPrefix.c_str(),j,i));
0950 //                                    //mean = getHistMean(inputfileMaxEntries,noNoiseHistsLG[j][i],j,i);
0951 //                                    auto it4 = boardLocationMapping.find(channel);
0952 //                                    if (mean>1000)cout << mean << " " << i << " "<<(double)it4->second.second<<" "<<(double)it4->second.first<<endl;
0953 //                                    //now we want to get the 3d plot.
0954 //                                    //cout << mean << " " << i << " "<<(double)it4->second.second<<" "<<(double)it4->second.first<<endl;
0955 //                                    //auto it = boardLocationMapping.find(channel);
0956 //                                    //now we want to get the 3d plot.
0957 //                                    hist3DMap->Fill((double)4,(double)it4->second.second,(double)it4->second.first,mean);
0958 //
0959 //                                }
0960 //                                if (std::find(A5.begin(), A5.end(),i)!=A5.end() ){
0961 //                                    int Index = getIndex(A5,i)+1;
0962 //                                    if (Index >4 )padInd = 9;
0963 //                                    if (Index <5)padInd=-4;
0964 //                                    channel = abs(padInd-(Index));
0965 //                                    meanHist= (TH1D*)(inputfileMaxEntries->Get(Form("%s_HG_B%d_C%02d",histPrefix.c_str(),j,i)));
0966 //                                    mean = meanHist->GetMean();
0967 //                                    
0968 //                                    //GetHist(inputfileMaxEntries,noNoiseHistsLG[j][i],Form("%s_HG_B%d_C%02d",histPrefix.c_str(),j,i));
0969 //                                    //mean = getHistMean(inputfileMaxEntries,noNoiseHistsLG[j][i],j,i);
0970 //                                    auto it = boardLocationMapping.find(channel);
0971 //                                    if (mean>1000)cout << mean << " " << i << " "<<(double)it->second.second<<" "<<(double)it->second.first<<endl;
0972 //                                    //now we want to get the 3d plot.
0973 //                                    //cout << mean << " " << i << " "<<(double)it->second.second<<" "<<(double)it->second.first<<endl;
0974 //                                   // auto it = boardLocationMapping.find(channel);
0975 //                                    //now we want to get the 3d plot.
0976 //                                    hist3DMap->Fill((double)5,(double)it->second.second,(double)it->second.first,mean);
0977 //
0978 //                                }
0979 //                                if (std::find(A6.begin(), A6.end(),i)!=A6.end() ){
0980 //                                    int Index = getIndex(A6,i)+1;
0981 //                                    if (Index >4 )padInd = 9;
0982 //                                    if (Index <5)padInd=-4;
0983 //                                    channel = abs(padInd-(Index));
0984 //                                    meanHist= (TH1D*)(inputfileMaxEntries->Get(Form("%s_HG_B%d_C%02d",histPrefix.c_str(),j,i)));
0985 //                                    mean = meanHist->GetMean();
0986 //                                    
0987 //                                    //GetHist(inputfileMaxEntries,noNoiseHistsLG[j][i],Form("%s_HG_B%d_C%02d",histPrefix.c_str(),j,i));
0988 //                                    //mean = getHistMean(inputfileMaxEntries,noNoiseHistsLG[j][i],j,i);
0989 //                                    auto it = boardLocationMapping.find(channel);
0990 //                                    if (mean>1000)cout << mean << " " << i << " "<<(double)it->second.second<<" "<<(double)it->second.first<<endl;
0991 //                                    //now we want to get the 3d plot.
0992 //                                    //cout << mean << " " << i << " "<<(double)it->second.second<<" "<<(double)it->second.first<<endl;
0993 //                                    //now we want to get the 3d plot.
0994 //                                    hist3DMap->Fill((double)6,(double)it->second.second,(double)it->second.first,mean);
0995 //
0996 //                                }
0997 //                                if (std::find(A7.begin(), A7.end(),i)!=A7.end() ){
0998 //                                    int Index = getIndex(A7,i)+1;
0999 //                                    if (Index >4 )padInd = 9;
1000 //                                    if (Index <5)padInd=-4;
1001 //                                    channel = abs(padInd-(Index));
1002 //                                    meanHist= (TH1D*)(inputfileMaxEntries->Get(Form("%s_HG_B%d_C%02d",histPrefix.c_str(),j,i)));
1003 //                                    mean = meanHist->GetMean();
1004 //                                    
1005 //                                    //GetHist(inputfileMaxEntries,noNoiseHistsLG[j][i],Form("%s_HG_B%d_C%02d",histPrefix.c_str(),j,i));
1006 //                                    //mean = getHistMean(inputfileMaxEntries,noNoiseHistsLG[j][i],j,i);
1007 //                                    auto it = boardLocationMapping.find(channel);
1008 //                                    if (mean>1000)cout << mean << " " << i << " "<<(double)it->second.second<<" "<<(double)it->second.first<<endl;
1009 //                                    //now we want to get the 3d plot.
1010 //                                    //cout << mean << " " << i << " "<<(double)it->second.second<<" "<<(double)it->second.first<<endl;
1011 //                                    //now we want to get the 3d plot.
1012 //                                    hist3DMap->Fill((double)7,(double)it->second.second,(double)it->second.first,mean);
1013 //                                    
1014 //                                }
1015 //                                
1016 //                                
1017 //                            }//checking if digitizer board 1
1018 //                            if (j==0){
1019 //                                if (std::find(A0.begin(), A0.end(),i)!=A0.end() ){
1020 //                                    int Index = getIndex(A0,i)+1;
1021 //                                    if (Index >4 )padInd = 9;
1022 //                                    if (Index <5)padInd=-4;
1023 //                                    channel = abs(padInd-(Index));
1024 //                                    meanHist= (TH1D*)(inputfileMaxEntries->Get(Form("%s_HG_B%d_C%02d",histPrefix.c_str(),j,i)));
1025 //                                    mean = meanHist->GetMean();
1026 //                                    
1027 //                                    //GetHist(inputfileMaxEntries,noNoiseHistsLG[j][i],Form("%s_HG_B%d_C%02d",histPrefix.c_str(),j,i));
1028 //                                    //mean = getHistMean(inputfileMaxEntries,noNoiseHistsLG[j][i],j,i);
1029 //                                    auto it = boardLocationMapping.find(channel);
1030 //                                    if (mean>1000)cout << mean << " " << i << " "<<(double)it->second.second<<" "<<(double)it->second.first<<endl;
1031 //                                    //now we want to get the 3d plot.
1032 //                                    ////cout << mean << " " << i << " "<<(double)it->second.second<<" "<<(double)it->second.first<<endl;                                    //auto it = boardLocationMapping.find(channel);
1033 //                                    //now we want to get the 3d plot.
1034 //                                    hist3DMap->Fill((double)10,(double)it->second.second,(double)it->second.first,mean);
1035 //                                }
1036 //                                if (std::find(A1.begin(), A1.end(),i)!=A1.end() ){
1037 //                                    int Index = getIndex(A1,i)+1;
1038 //                                    if (Index >4 )padInd = 9;
1039 //                                    if (Index <5)padInd=-4;
1040 //                                    channel = abs(padInd-(Index));
1041 //                                    meanHist= (TH1D*)(inputfileMaxEntries->Get(Form("%s_HG_B%d_C%02d",histPrefix.c_str(),j,i)));
1042 //                                    mean = meanHist->GetMean();
1043 //                                    
1044 //                                    //GetHist(inputfileMaxEntries,noNoiseHistsLG[j][i],Form("%s_HG_B%d_C%02d",histPrefix.c_str(),j,i));
1045 //                                    //mean = getHistMean(inputfileMaxEntries,noNoiseHistsLG[j][i],j,i);
1046 //                                    auto it = boardLocationMapping.find(channel);
1047 //                                    //now we want to get the 3d plot.
1048 //                                    ////cout << mean << " " << i << " "<<(double)it->second.second<<" "<<(double)it->second.first<<endl;                                    //auto it = boardLocationMapping.find(channel);
1049 //                                    //now we want to get the 3d plot.
1050 //                                    if (mean>1000)cout << mean << " " << i << " "<<(double)it->second.second<<" "<<(double)it->second.first<<endl;
1051 //                                    hist3DMap->Fill((double)8,(double)it->second.second,(double)it->second.first,mean);
1052 //                                }
1053 //                                if (std::find(A9.begin(), A9.end(),i)!=A9.end() ){
1054 //                                    int Index = getIndex(A9,i)+1;
1055 //                                    if (Index >4 )padInd = 9;
1056 //                                    if (Index <5)padInd=-4;
1057 //                                    channel = abs(padInd-(Index));
1058 //                                    meanHist= (TH1D*)(inputfileMaxEntries->Get(Form("%s_HG_B%d_C%02d",histPrefix.c_str(),j,i)));
1059 //                                    mean = meanHist->GetMean();
1060 //                                    
1061 //                                    //GetHist(inputfileMaxEntries,noNoiseHistsLG[j][i],Form("%s_HG_B%d_C%02d",histPrefix.c_str(),j,i));
1062 //                                    //mean = getHistMean(inputfileMaxEntries,noNoiseHistsLG[j][i],j,i);
1063 //                                    auto it = boardLocationMapping.find(channel);
1064 //                                    if (mean>1000)cout << mean << " " << i << " "<<(double)it->second.second<<" "<<(double)it->second.first<<endl;
1065 //                                    //now we want to get the 3d plot.
1066 //                                    //cout << mean << " " << i << " "<<(double)it->second.second<<" "<<(double)it->second.first<<endl;                                    //auto it = boardLocationMapping.find(channel);
1067 //                                    //now we want to get the 3d plot.
1068 //                                    hist3DMap->Fill((double)9,(double)it->second.second,(double)it->second.first,mean);
1069 //
1070 //                                }
1071 //                                if (std::find(A12.begin(), A12.end(),i)!=A12.end() ){
1072 //                                    int Index = getIndex(A12,i)+1;
1073 //                                    if (Index >4 )padInd = 9;
1074 //                                    if (Index <5)padInd=-4;
1075 //                                    channel = abs(padInd-(Index));
1076 //                                    meanHist= (TH1D*)(inputfileMaxEntries->Get(Form("%s_HG_B%d_C%02d",histPrefix.c_str(),j,i)));
1077 //                                    mean = meanHist->GetMean();
1078 //                                    
1079 //                                    //GetHist(inputfileMaxEntries,noNoiseHistsLG[j][i],Form("%s_HG_B%d_C%02d",histPrefix.c_str(),j,i));
1080 //                                    //mean = getHistMean(inputfileMaxEntries,noNoiseHistsLG[j][i],j,i);
1081 //                                    auto it = boardLocationMapping.find(channel);
1082 //                                    if (mean>1000)cout << mean << " " << i << " "<<(double)it->second.second<<" "<<(double)it->second.first<<endl;
1083 //                                    //now we want to get the 3d plot.
1084 //                                    //cout << mean << " " << i << " "<<(double)it->second.second<<" "<<(double)it->second.first<<endl;                                    //auto it = boardLocationMapping.find(channel);
1085 //                                    //now we want to get the 3d plot.
1086 //                                    hist3DMap->Fill((double)11,(double)it->second.second,(double)it->second.first,mean);
1087 //
1088 //                                }
1089 //                                if (std::find(A4.begin(), A4.end(),i)!=A4.end() ){
1090 //                                    int Index = getIndex(A4,i)+1;
1091 //                                    if (Index >4 )padInd = 9;
1092 //                                    if (Index <5)padInd=-4;
1093 //                                    channel = abs(padInd-(Index));
1094 //                                    meanHist= (TH1D*)(inputfileMaxEntries->Get(Form("%s_HG_B%d_C%02d",histPrefix.c_str(),j,i)));
1095 //                                    mean = meanHist->GetMean();
1096 //                                    
1097 //                                    //GetHist(inputfileMaxEntries,noNoiseHistsLG[j][i],Form("%s_HG_B%d_C%02d",histPrefix.c_str(),j,i));
1098 //                                    //mean = getHistMean(inputfileMaxEntries,noNoiseHistsLG[j][i],j,i);
1099 //                                    auto it = boardLocationMapping.find(channel);
1100 //                                    if (mean>1000)cout << mean << " " << i << " "<<(double)it->second.second<<" "<<(double)it->second.first<<endl;
1101 //                                    //now we want to get the 3d plot.
1102 //                                    //cout << mean << " " << i << " "<<(double)it->second.second<<" "<<(double)it->second.first<<endl;                                    //auto it = boardLocationMapping.find(channel);
1103 //                                    //now we want to get the 3d plot.
1104 //                                    hist3DMap->Fill((double)12,(double)it->second.second,(double)it->second.first,mean);
1105 //
1106 //                                }
1107 //                                
1108 //                                
1109 //                            }//checking if digitizer board 0
1110 //                            
1111 //                        }
1112 //                    }
1113 //                }//finished looped thru file names :)
1114 //                //hist3DMap->Fill((double)-2,-2.0,-2.0,2000);
1115 //                TCanvas *c0 = new TCanvas("Plot3D","3D plot ADC distribution",1800,1600);
1116 //                gStyle->SetPalette(55);
1117 ////                TLatex latex11;
1118 ////                latex11.SetNDC ();
1119 ////                latex11.SetTextSize(0.06);
1120 ////                //c->cd(1);
1121 ////                latex11.DrawLatex(-0.9,0.5 ,settings.c_str());
1122 //                
1123 //                //}
1124 //    //gStyle->SetPalette(55);
1125 //                // Draw the 3D histogram
1126 //                //hist3DMap->GetZaxis()->SetRangeUser(0,1200);
1127 //                hist3DMap->Draw("BOX2 Z");
1128 //                hist3DMap->GetXaxis()->SetTitleOffset(1.35);
1129 //                TPaveText *l4 = new TPaveText(-0.9,0.8,-0.5,0.95);
1130 //                //l4->SetFillColor(42);
1131 //                l4->SetTextAlign(12);
1132 //                l4->AddText(Form("%s %s",energy.c_str(),settings.c_str()));
1133 //                l4->Draw("same");
1134 //                c0->Update();
1135 //                c0->Draw();
1136 //                outRoot.cd();
1137 //            
1138 //                hist3DMap->Write();
1139 //                c0->Write();
1140 //                
1141 //                
1142 //            }
1143 //            
1144 //    if (Overlay){
1145 //        TCanvas *canvasPReso8PanelPlot = new TCanvas("A1","A1 info",1800,1600);
1146 //        canvasPReso8PanelPlot->Divide(4,2,0,0);
1147 //        
1148 ////        Double_t arrayBound8PanPResoX1_4[5];
1149 ////        Double_t arrayBound8PanPResoY1_4[4];
1150 ////        Double_t relativeMarginsEResoX[3];
1151 ////        Double_t relativeMarginsEResoY[3];
1152 ////
1153 ////        Double_t textSizeSinglePad        = 0.05;
1154 ////        Double_t textSizeLabelsPixel      = 35;
1155 ////        Double_t textSizeLabelsRel        = 58./1300;
1156 ////        textSizeLabelsPixel       = 750*0.05;
1157 ////        ReturnCorrectValuesForCanvasScaling(2250,750, 4, 2,0.035, 0.003, 0.01,0.095,arrayBound8PanPResoX1_4,arrayBound8PanPResoY1_4,relativeMarginsEResoX,relativeMarginsEResoY);
1158 ////        TCanvas* canvasPReso8PanelPlot = new TCanvas("canvasPReso8PanelPlot","",0,0,2250,750); // gives the page size
1159 ////        DrawGammaCanvasSettings( canvasPReso8PanelPlot, 0.05, 0.01, 0.01,0.095);
1160 ////
1161 ////        TPad* pad1      = new TPad("pad1", "", arrayBound8PanPResoX1_4[0], arrayBound8PanPResoY1_4[2], arrayBound8PanPResoX1_4[1], arrayBound8PanPResoY1_4[1],-1, -1, -2);
1162 ////        DrawGammaPadSettings( pad1, relativeMarginsEResoX[0], relativeMarginsEResoX[1], relativeMarginsEResoY[0], relativeMarginsEResoY[2]);
1163 ////        pad1->SetNumber(1);
1164 ////        pad1->Draw();
1165 ////
1166 ////        TPad* pad2       = new TPad("pad2", "", arrayBound8PanPResoX1_4[1], arrayBound8PanPResoY1_4[2], arrayBound8PanPResoX1_4[2], arrayBound8PanPResoY1_4[1],-1, -1, -2);
1167 ////        DrawGammaPadSettings( pad2, relativeMarginsEResoX[1], relativeMarginsEResoX[1], relativeMarginsEResoY[0], relativeMarginsEResoY[2]);
1168 ////        pad2->SetNumber(2);
1169 ////        pad2->Draw();
1170 ////
1171 ////        TPad* pad3       = new TPad("pad3", "", arrayBound8PanPResoX1_4[2], arrayBound8PanPResoY1_4[2], arrayBound8PanPResoX1_4[3], arrayBound8PanPResoY1_4[1],-1, -1, -2);
1172 ////        DrawGammaPadSettings( pad3, relativeMarginsEResoX[1], relativeMarginsEResoX[1], relativeMarginsEResoY[0], relativeMarginsEResoY[2]);
1173 ////        pad3->SetNumber(3);
1174 ////        pad3->Draw();
1175 ////
1176 ////        TPad* pad4      = new TPad("pad4", "", arrayBound8PanPResoX1_4[3], arrayBound8PanPResoY1_4[2], arrayBound8PanPResoX1_4[4], arrayBound8PanPResoY1_4[1],-1, -1, -2);
1177 ////        DrawGammaPadSettings( pad4, relativeMarginsEResoX[1], relativeMarginsEResoX[2], relativeMarginsEResoY[0], relativeMarginsEResoY[2]);
1178 ////        pad4->SetNumber(4);
1179 ////        pad4->Draw();
1180 ////
1181 ////        TPad* pad8       = new TPad("pad8", "", arrayBound8PanPResoX1_4[0], arrayBound8PanPResoY1_4[1], arrayBound8PanPResoX1_4[1], arrayBound8PanPResoY1_4[0],-1, -1, -2);
1182 ////        DrawGammaPadSettings( pad8, relativeMarginsEResoX[0], relativeMarginsEResoX[1], relativeMarginsEResoY[0], relativeMarginsEResoY[2]);
1183 ////        pad8->SetNumber(8);
1184 ////        pad8->Draw();
1185 ////
1186 ////        TPad* pad7       = new TPad("pad7", "", arrayBound8PanPResoX1_4[1], arrayBound8PanPResoY1_4[1], arrayBound8PanPResoX1_4[2], arrayBound8PanPResoY1_4[0],-1, -1, -2);
1187 ////        DrawGammaPadSettings( pad7, relativeMarginsEResoX[1], relativeMarginsEResoX[1], relativeMarginsEResoY[0], relativeMarginsEResoY[2]);
1188 ////        pad7->SetNumber(7);
1189 ////        pad7->Draw();
1190 ////
1191 ////        TPad* pad6       = new TPad("pad6", "", arrayBound8PanPResoX1_4[2], arrayBound8PanPResoY1_4[1], arrayBound8PanPResoX1_4[3], arrayBound8PanPResoY1_4[0],-1, -1, -2);
1192 ////        DrawGammaPadSettings( pad6, relativeMarginsEResoX[1], relativeMarginsEResoX[1], relativeMarginsEResoY[0], relativeMarginsEResoY[2]);
1193 ////        pad6->SetNumber(6);
1194 ////        pad6->Draw();
1195 ////
1196 ////        TPad* pad5       = new TPad("pad5", "", arrayBound8PanPResoX1_4[3], arrayBound8PanPResoY1_4[1], arrayBound8PanPResoX1_4[4], arrayBound8PanPResoY1_4[0],-1, -1, -2);
1197 ////        DrawGammaPadSettings( pad5, relativeMarginsEResoX[1], relativeMarginsEResoX[2], relativeMarginsEResoY[0], relativeMarginsEResoY[2]);
1198 ////        pad5->SetNumber(5);
1199 ////        pad5->Draw();
1200 //    
1201 //        
1202 //        //update the first parameter so we can take different root files as inputs
1203 //        std::vector<string> fileNames = testParserTStrings(fileName);
1204 //        std::vector<string> energiesLegend = testParserTStrings(energy);
1205 //        //std::vector<string> wlayersLegend = testPartTString(Wlayers);
1206 //        
1207 //        //loop thru the different files
1208 //        for (Int_t k = 0; k< fileNames.size(); k++){
1209 //  
1210 //            if(fileNames.size()>1) {cout<<"Too many files to overlay assembly boards. Please input a single file"<<endl; break;}
1211 //            TFile *inputfile = new TFile(fileNames[k].c_str());
1212 //            
1213 //            float x1[13]={};
1214 //            float y1[13]={};
1215 //            float x2[13]={};
1216 //            float y2[13]={};
1217 //            for(int i = 0; i<6; i++){
1218 //            if(i==6)break;
1219 //                if (i ==0){
1220 //                    x1[i] = 0.50;
1221 //                    x2[i] = 0.70;
1222 //                }
1223 //                else{
1224 //                    x1[i] = 0.50 ;
1225 //                    x2[i] = 0.70 ;
1226 //                }
1227 //                y1[i] = 0.95 - 0.07*i;
1228 //                y2[i] = 0.90 - 0.07*i;
1229 //            }
1230 //            for(int i = 6; i<13; i++){
1231 //                if (i ==6){
1232 //                    x1[i] = 0.50+0.2;
1233 //                    x2[i] = 0.90;
1234 //                    cout<<"x1 "<<x1[i]<<" x2 "<<x2[i]<<endl;
1235 //                }
1236 //                else{
1237 //                    x1[i] = 0.70 ;
1238 //                    x2[i] = 0.90 ;
1239 //                     cout<<"x1 "<<x1[i]<<" x2 "<<x2[i]<<endl;
1240 //                }
1241 //                y1[i] = 0.95 - 0.07*(i-6);
1242 //                y2[i] = 0.90 - 0.07*(i-6);
1243 //                 cout<<"y1 "<<y1[i]<<" y2 "<<y2[i]<<endl;
1244 //            }
1245 //            //Now we want to loop through the TH1Fs from the file and get them all!
1246 //            for (Int_t j = 0; j < gMaxBoard; j++){
1247 //                for (Int_t i = 0; i < gMaxChannels; i++){
1248 //                    if (j == 1){
1249 //                        if (std::find(A11.begin(), A11.end(),i)!=A11.end() ){
1250 //                            TLegend* leg11 = new TLegend(x1[0], y1[0], x2[0], y2[0]);
1251 //                            graphingHistOnSepPad(canvasPReso8PanelPlot,i,j,A11,11,inputfile,"A11",noNoiseHistsLG[j][i],col_overlay,y_max,true,xrange,leg11,rebinfac,histPrefix);
1252 //            
1253 //                        }
1254 //                        if (std::find(A8.begin(), A8.end(),i)!=A8.end() ){
1255 //                             TLegend* leg2 = new TLegend(x1[1], y1[1], x2[1], y2[1]);
1256 //                            graphingHistOnSepPad(canvasPReso8PanelPlot,i,j,A8,8,inputfile,"A8",noNoiseHistsLG[j][i],col_overlay,y_max,true,xrange,leg2,rebinfac,histPrefix);
1257 //                            
1258 //                        }
1259 //                        if (std::find(A2.begin(), A2.end(),i)!=A2.end() ){
1260 //                            TLegend* leg3 = new TLegend(x1[2], y1[2], x2[2], y2[2]);
1261 //                            graphingHistOnSepPad(canvasPReso8PanelPlot,i,j,A2,2,inputfile,"A2",noNoiseHistsLG[j][i],col_overlay,y_max,true,xrange,leg3,rebinfac,histPrefix);
1262 //                            
1263 //                        }
1264 //                        if (std::find(A3.begin(), A3.end(),i)!=A3.end() ){
1265 //                            TLegend* leg4 = new TLegend(x1[3], y1[3], x2[3], y2[3]);
1266 //                            graphingHistOnSepPad(canvasPReso8PanelPlot,i,j,A3,3,inputfile,"A3",noNoiseHistsLG[j][i],col_overlay,y_max,true,xrange,leg4,rebinfac,histPrefix);
1267 //                        }
1268 //                        if (std::find(A13.begin(), A13.end(),i)!=A13.end() ){
1269 //                            TLegend* leg5 = new TLegend(x1[4], y1[4], x2[4], y2[4]);
1270 //                            graphingHistOnSepPad(canvasPReso8PanelPlot,i,j,A13,13,inputfile,"A13",noNoiseHistsLG[j][i],col_overlay,y_max,true,xrange,leg5,rebinfac,histPrefix);
1271 //                            
1272 //                        }
1273 //                        if (std::find(A5.begin(), A5.end(),i)!=A5.end() ){
1274 //                           TLegend* leg6 = new TLegend(x1[5], y1[5], x2[5], y2[5]);
1275 //                            graphingHistOnSepPad(canvasPReso8PanelPlot,i,j,A5,5,inputfile,"A5",noNoiseHistsLG[j][i],col_overlay,y_max,true,xrange,leg6,rebinfac,histPrefix);
1276 //                            
1277 //                        }
1278 //                        if (std::find(A6.begin(), A6.end(),i)!=A6.end() ){
1279 //                            TLegend* leg7 = new TLegend(x1[6], y1[6], x2[6], y2[6]);
1280 //                            graphingHistOnSepPad(canvasPReso8PanelPlot,i,j,A6,6,inputfile,"A6",noNoiseHistsLG[j][i],col_overlay,y_max,true,xrange,leg7,rebinfac,histPrefix);
1281 //                            
1282 //                        }
1283 //                        if (std::find(A7.begin(), A7.end(),i)!=A7.end() ){
1284 //                           TLegend* leg8 = new TLegend(x1[7], y1[7], x2[7], y2[7]);
1285 //                            graphingHistOnSepPad(canvasPReso8PanelPlot,i,j,A7,7,inputfile,"A7",noNoiseHistsLG[j][i],col_overlay,y_max,true,xrange,leg8,rebinfac,histPrefix);
1286 //                            
1287 //                        }
1288 //                        
1289 //                        
1290 //                    }//checking if digitizer board 0
1291 //                    if (j==0){
1292 //                        if (std::find(A0.begin(), A0.end(),i)!=A0.end() ){
1293 //                             TLegend* leg0 = new TLegend(x1[8], y1[8], x2[8], y2[8]);
1294 //                            graphingHistOnSepPad(canvasPReso8PanelPlot,i,j,A0,0,inputfile,"A0",noNoiseHistsLG[j][i],col_overlay,y_max,true,xrange,leg0,rebinfac,histPrefix);
1295 //                        }
1296 //                        if (std::find(A1.begin(), A1.end(),i)!=A1.end() ){
1297 //                              TLegend* leg1 = new TLegend(x1[9], y1[9], x2[9], y2[9]);
1298 //                            graphingHistOnSepPad(canvasPReso8PanelPlot,i,j,A1,1,inputfile,"A1",noNoiseHistsLG[j][i],col_overlay,y_max,true,xrange,leg1,rebinfac,histPrefix);
1299 //                            
1300 //                        }
1301 //                        if (std::find(A9.begin(), A9.end(),i)!=A9.end() ){
1302 //                            TLegend* leg9 = new TLegend(x1[10], y1[10], x2[10], y2[10]);
1303 //                            graphingHistOnSepPad(canvasPReso8PanelPlot,i,j,A9,9,inputfile,"A9",noNoiseHistsLG[j][i],col_overlay,y_max,true,xrange,leg9,rebinfac,histPrefix);
1304 //                            
1305 //                        }
1306 //                        if (std::find(A12.begin(), A12.end(),i)!=A12.end() ){
1307 //                             TLegend* leg12 = new TLegend(x1[11], y1[11], x2[11], y2[11]);
1308 //                            graphingHistOnSepPad(canvasPReso8PanelPlot,i,j,A12,12,inputfile,"A12",noNoiseHistsLG[j][i],col_overlay,y_max,true,xrange,leg12,rebinfac,histPrefix);
1309 //                            
1310 //                        }
1311 //                        if (std::find(A4.begin(), A4.end(),i)!=A4.end() ){
1312 //                            TLegend* leg4 = new TLegend(x1[12], y1[12], x2[12], y2[12]);
1313 //                            graphingHistOnSepPad(canvasPReso8PanelPlot,i,j,A4,4,inputfile,"A4",noNoiseHistsLG[j][i],col_overlay,y_max,true,xrange,leg4,rebinfac,histPrefix);
1314 //                            
1315 //                        }
1316 //                        
1317 //                        
1318 //                    }//checking if digitizer board 1
1319 //                    
1320 //                }//
1321             //}//end of board loop
1322             
1323       //  }//end of TFile loop!
1324   //  }//end of checkiing for overlay :)  loop
1325     outRoot.Close();
1326     
1327 }
1328 
1329 
1330 
1331                         
1332