Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:22:51

0001 void xTalkMacro(){
0002 //proccess in batch mode. this takes a VERY long time out of batch mode
0003 gROOT->SetBatch();
0004 //contains several functions used in other macros as well
0005 gROOT->ProcessLine(".L GenFuncMacro.C");
0006 
0007 //get myFile. this is for batch processecing 
0008 //copies the name of any file beginning with "c" from the /tmp/csccalib directory. 
0009 char *myFileName;  //new file name for directory name
0010 char *myFilePath; //for accessing file by root 
0011 void *dirp = gSystem->OpenDirectory("/tmp/csccalib"); //read tmp directory
0012 char *afile; //temp file name
0013 while(afile = gSystem->GetDirEntry(dirp)) { //parse directory
0014    char *bfile[0] = afile[0]; //new temp file name
0015    if (bfile[0]=='c') { //if file begins with c
0016      printf("file: %s\n",afile); //check name
0017      myFileName = afile; //set for out of scope processing
0018    }
0019    myFilePath = Form("/tmp/csccalib/%s", myFileName);
0020 }
0021 
0022 
0023 //set global parameters
0024 int nDDU  = 1;  
0025 int nCham =  1; //set default to one chamber, recalculates later
0026  int nLayer = 6; //may as well be hardcoded 
0027 
0028 //style-ize all canvases 
0029 gStyle->SetCanvasColor(0); 
0030 gStyle->SetPadColor(0); 
0031 gStyle->SetPadBorderMode(0);
0032 gStyle->SetCanvasBorderMode(0);
0033 gStyle->SetFrameBorderMode(0);
0034 gStyle->SetStatH(0.2);
0035 gStyle->SetStatW(0.3);
0036 
0037 //see GenFuncMacro.C
0038 directoryCheck();
0039 
0040 std::cout << "opening: " << myFileName << std::endl; 
0041 TFile *myFile = TFile::Open(myFilePath);
0042 
0043 //get number of chambers per DDU, don't save graph. reatains value for NEntires. 
0044 TCanvas *ChamberEntryCanvas = new TCanvas("ChamberDummyCanvas", "ChamberDummyCanvas");
0045 TH1F *ChamberEntryGraph = new TH1F ("ChamberGraph", "ChamberGraph",480,0,480);
0046 ChamberEntryCanvas->cd();
0047 Calibration->Draw("cham>>ChamberGraph");
0048 int NEntries = ChamberEntryGraph->GetEntries();
0049 
0050 //calculate the number of chambers
0051 nCham = (NEntries/480);
0052 std::cout << "number of chambers is: " << nCham << std::endl;
0053 //make sure it doesn't crash if the file is empty
0054  if (nCham == 0){
0055    std::cout << "no chambers, quitting." << std::endl;
0056    gROOT->ProcessLine(".q");
0057  }
0058  /*
0059 //check that file has the right number of events. if not, don't process it!!!
0060 TCanvas *canv_pulseCheck = new TCanvas("EventCheckCanv","EventCheckCanv",1100,700); ; 
0061 TH2F *pulseCheck = (TH2F*)myFile->Get("pulse01"); 
0062 canv_pulseCheck->cd();
0063 pulseCheck->Draw(); 
0064 int NPulses = pulseCheck->GetEntries();
0065 //this "9" might have to be changed (at some point) to the varialbe nCham, if the graphs are filled differently
0066 int NEvents = (NPulses/9);
0067 std::cout << "number of events is: " << NEvents << std::endl;
0068  if (NEvents != 320) {
0069    std::cout << "wrong number of events! file " << myFileName << " is not being processed." << std::endl; 
0070    gROOT->ProcessLine(".q"); 
0071  }
0072  */
0073 
0074 //this is one big section of linux directory processing
0075 //if this is edited, be careful! it's easy to mess up. 
0076 gSystem->cd("/afs/cern.ch/cms/CSC/html/csccalib/");
0077 //see GenFuncMacro.C
0078 makeDirectory("images");
0079  
0080 gSystem->cd("images");
0081  //create subdirectory Crosstalk
0082 makeDirectory("Crosstalk");
0083 //open file generated from analyzer
0084 gSystem->cd("../");
0085 
0086  //create folder for this run
0087 gSystem->cd("images/Crosstalk/");
0088 makeDirectory(myFileName);
0089   
0090 gSystem->cd(myFileName);
0091 
0092  ///this is a bit ridiculous, but if this graph is not drawn, chamberID's cannot
0093  ///cannot be accessed. The graph does not need to be kept. 
0094 TCanvas *Maxdummy = new TCanvas("Maxdummy", "Maxdummy");
0095 Maxdummy->Divide(1,2);
0096 Maxdummy->cd(1); 
0097 Calibration->Draw("MaxPed");  
0098 Maxdummy->cd(2); 
0099 Calibration->Draw("MaxRMS");
0100 
0101 gSystem->cd("../../../");
0102 
0103 //create pedestal  flag graphs 
0104 pedRMSFlagGraph(myFileName, myFilePath); 
0105 //create all pedestal RMS
0106 gStyle->SetOptStat(0); 
0107 pedRMSGraphs(nDDU,nCham,nLayer, myFileName, myFilePath);
0108 //create all pedestal MEAN graphs 
0109 pedMeanGraphs(nDDU,nCham,nLayer, myFileName, myFilePath); 
0110 gStyle->SetOptStat(1);
0111 //create noise graphs 
0112 pedNoiseFlagGraph(myFileName, myFilePath); 
0113 //create CrossTalk pulse graphs
0114 
0115 gSystem->cd("/afs/cern.ch/user/c/csccalib/scratch0/CMSSW_1_5_1/src/OnlineDB/CSCCondDB/test");
0116 std::cout << "now in : " << gSystem->pwd() << std::endl;
0117 
0118 //PeakGraphs(myFileName, myFilePath, nCham);
0119 
0120 myFile->Close();
0121 myFilePath = Form("/tmp/csccalib/%s", myFileName); 
0122 std::cout << "just before PulseGraphs" << std::endl;
0123 std::cout << " fileName: " << myFileName << std::endl;
0124 std::cout << " filePath: " << myFilePath << std::endl;
0125 PulseGraphs(myFileName, myFilePath); 
0126 gROOT->ProcessLine(".q"); 
0127 } 
0128 
0129 //proper usage: 
0130 //  int idArray[9];
0131 //  GetChamberIDs(idArray);
0132 //  std::cout << "id for chamber 0: " << idArray[0] << std::endl;
0133 void GetChamberIDs(int IDArray[9]){
0134   TCanvas *IDcanv = new TCanvas ("idGraph", "idGraph");
0135   IDcanv->cd();
0136   TH1F *idDummy = new TH1F("idDummy", "idDummy", 480, 111000, 250000);
0137   idDummy->Draw();
0138   for (int chamber=0; chamber<9; ++chamber){
0139     TString idCut = Form ("cham==%d", chamber);
0140     Calibration->Project("idDummy", "id", idCut);
0141     Int_t idNum = idDummy->GetMean();
0142     IDArray[chamber]=idNum;
0143   }
0144   idDummy->Draw();
0145 }
0146 
0147 void pedRMSGraphs(int nDDU, int nCham, int nLayer, TString myFileName, TString myFilePath){
0148 
0149 gSystem->cd("images/Crosstalk");
0150 gSystem->cd(myFileName);
0151 makeDirectory("pedRMSGraphs");
0152 gSystem->cd("pedRMSGraphs");
0153 makeDirectory("pedRMSStrips");
0154 makeDirectory("pedRMSLayerMean");
0155 
0156 //create rms canvas arrays
0157  TObjArray CANV_PEDRMS_STRIP_ARRAY(nCham*nDDU);
0158  TObjArray CANV_PEDRMS_MEAN_ARRAY(nCham*nDDU);
0159 
0160 //create rms lines for comparison to standards
0161 //warning levels are guesses based on other work
0162 TLine *horiz_low_pedrms = new TLine(0,0,80,0);
0163 TLine *horiz_high_pedrms = new TLine(0,5,80,5);
0164 TLine *vert_low_pedrms = new TLine(5, 0, 5, 200);
0165 TLine *vert_high_pedrms = new TLine(0, 0, 0, 200);
0166 
0167 horiz_low_pedrms->SetLineStyle(3);//dotted
0168 horiz_high_pedrms->SetLineStyle(3);
0169 vert_low_pedrms->SetLineStyle(3); 
0170 vert_high_pedrms->SetLineStyle(3);
0171 
0172 horiz_low_pedrms->SetLineColor(6);//red
0173 horiz_low_pedrms->SetLineWidth(2);//visible but not overwhelming width
0174 horiz_high_pedrms->SetLineColor(6);
0175 horiz_high_pedrms->SetLineWidth(2);
0176 
0177 vert_low_pedrms->SetLineColor(6);
0178 vert_low_pedrms->SetLineWidth(2);
0179 vert_high_pedrms->SetLineColor(6);
0180 vert_high_pedrms->SetLineWidth(2);
0181 
0182 //Ideally, cha would take nDDU*nCham as it's argument,and lay would take nDDU*nCham*nLay. 
0183 //But ROOT doesn't like having a varialbe there, so it is created at it's largest useful value. 
0184 TH1F *cha[480]; 
0185 TH2F *lay[2880]; 
0186  //loop over all DDU's
0187   for(int i=0; i<nDDU; ++i){
0188     int idArray[9];
0189     GetChamberIDs(idArray);
0190     //loop over each chamber in a given DDU
0191     for (int j=0; j<nCham; ++j){
0192       
0193       gStyle->SetMarkerStyle(20);
0194       gStyle->SetMarkerSize(0.8);
0195       
0196       //get the chamber ID number
0197       Int_t chamber_id_int = idArray[j];
0198       //get the max RMS value for the chamber
0199       Float_t chamber_maxRMSval = Calibration->GetLeaf("MaxRMS")->GetValue(j);      
0200             
0201       Float_t chamber_axisMax = chamber_maxRMSval + (.1)*chamber_maxRMSval; 
0202       if (chamber_axisMax < 5.5){
0203     chamber_axisMax = 5.5;
0204       }
0205 
0206       //RMS mean Canvases
0207       TString CANV_PEDRMS_MEAN_NAME = Form("ChamberID_%d_RMS", chamber_id_int);
0208       TCanvas* canv_rms1 ;
0209       canv_rms1 =  new TCanvas(CANV_PEDRMS_MEAN_NAME,CANV_PEDRMS_MEAN_NAME, 200, 10, 1200, 800); 
0210       canv_rms1->SetCanvasSize(1200,800);
0211       
0212       //add to this array, for out-of-scope acess
0213       CANV_PEDRMS_MEAN_ARRAY.Add(canv_rms1);
0214 
0215       //RMS strip Canvases
0216       TString CANV_PEDRMS_STRIP_NAME = Form("ChamberID_%d_RMS_per_Layer", chamber_id_int);
0217 
0218       TCanvas* canv_rms2;
0219       canv_rms2 = new TCanvas(CANV_PEDRMS_STRIP_NAME,CANV_PEDRMS_STRIP_NAME, 200, 10, 1200, 800);
0220       canv_rms2->SetCanvasSize(1200,800);
0221       canv_rms2->Divide(2,3);
0222       CANV_PEDRMS_STRIP_ARRAY.Add(canv_rms2);
0223 
0224       //create, fill and draw overall RMS graphs
0225              
0226       int chamber_access_int =( (nCham*i)+ j);
0227       
0228       //this access one of the (*TH1F's) initialized outside the DDU loop
0229       TString hist_name= Form("cha[%d]", chamber_access_int);
0230       cha[j] = new TH1F(hist_name, "rms mean plot", 100, -0.5, chamber_axisMax);
0231 
0232       TCanvas *thisCanv_mean = CANV_PEDRMS_MEAN_ARRAY[chamber_access_int]; 
0233       thisCanv_mean->cd();
0234 
0235       TString xAxisTitle = Form("Mean RMS for Chamber %d",chamber_id_int);
0236       cha[j]->GetXaxis()->SetTitle(xAxisTitle);
0237 
0238       const char val[7];
0239       //cuts based on each chamber
0240       sprintf(val, "cham==%d", j);
0241       const char *val_ = val;
0242 
0243       Calibration->UseCurrentStyle();
0244       //this draws an empty graph called cha[j] with the chosen options
0245       //into the proper canvas, thisCanv_mean
0246       cha[j]->Draw();
0247       //this pipes histo pedRMS from Tree Calibration into graph cha[j] with cut val_
0248       Calibration->Project(hist_name, "pedRMS", val_);
0249       
0250       //retrieve the max, so the scale of the graph and vertical lines can be redrawn appropriately
0251       Double_t yMaxVal = cha[j]->GetMaximum();
0252       Double_t yMaxRan = yMaxVal + (yMaxVal*.1);
0253 
0254       //reset the line range
0255       vert_low_pedrms->SetY2(yMaxRan);
0256       vert_high_pedrms->SetY2(yMaxRan);
0257 
0258       //reset the axis range
0259       cha[j]->SetAxisRange(0,yMaxRan,"Y");
0260       vert_low_pedrms->Draw();  
0261       vert_high_pedrms->Draw();
0262     
0263       thisCanv_mean->Update();
0264       gSystem->cd("pedRMSLayerMean");
0265       TString canvName = CANV_PEDRMS_MEAN_ARRAY[chamber_access_int]->GetName(); 
0266       PrintAsGif(thisCanv_mean, canvName);  
0267       gSystem->cd("../");
0268       
0269       int NStrips = 0;
0270       int xStripMax = 1;
0271       //dummy graph to retrieve number of strips, to set graph accordingly
0272       TCanvas *StripEntryCanvas = new TCanvas("StripDummyCanvas", "StripDummyCanvas");
0273       TH1F *StripEntryDummy = new TH1F("StripEntryDummy", "StripEntryDummy",10,0,100);
0274       TString chamVar = Form("cham==%d",j);
0275       StripEntryCanvas->cd();
0276       Calibration->Draw("strip>>StripEntryDummy", chamVar);
0277       //number of strips in a given chamber. should be 480 for 5 CFEBs or 384 for 4 CFEBs
0278       NStrips= StripEntryDummy->GetEntries();
0279       
0280       if (NStrips==480){
0281     xStripMax=80;
0282       }if (NStrips==384){
0283     xStripMax=64;
0284      }
0285      
0286       for (int k=0; k<nLayer; ++k){
0287     int layer_access_int = ( (nCham*nLayer*i) + (nLayer*j) + k );
0288     //RMS: create, fill and draw strip graphs
0289     TString hist_name_= Form("lay[%d]",layer_access_int);
0290     
0291     lay[layer_access_int] = new TH2F(hist_name_,"RMS strip plot", xStripMax, 0, xStripMax, 10, -0.5, chamber_axisMax);
0292     //  lay[layer_access_int] = new TH2F(hist_name_,"RMS strip plot", xStripMax, 0, xStripMax, 10, 1.5, 3);
0293     
0294     TCanvas *thisCanv_rms_strip = CANV_PEDRMS_STRIP_ARRAY[chamber_access_int];
0295     thisCanv_rms_strip -> cd(k+1);
0296     
0297     lay[layer_access_int]->SetMarkerStyle(20);
0298     TString new_title2 = Form("Layer_%d", k+1);
0299     lay[layer_access_int]->SetTitle(new_title2);
0300 
0301     TString newTitle = Form("strip RMS in chamber %d, per layer",chamber_id_int,k);
0302     //TString newTitle = Form("strip RMS in chamber %d, per layer",j+1,k);
0303         thisCanv_rms_strip->SetTitle(newTitle);
0304     lay[layer_access_int]->GetXaxis()->SetTitle("Strip");
0305     lay[layer_access_int]->GetYaxis()->SetTitle("RMS");
0306 
0307     lay[layer_access_int]->GetXaxis()->SetTitleSize(0.070);
0308     lay[layer_access_int]->GetXaxis()->SetTitleOffset(0.5);
0309     lay[layer_access_int]->GetYaxis()->SetTitleSize(0.070);
0310     lay[layer_access_int]->GetXaxis()->SetTitleOffset(0.5);
0311 
0312     lay[layer_access_int]->GetXaxis()->SetLabelSize(0.07);
0313     lay[layer_access_int]->GetYaxis()->SetLabelSize(0.07);
0314 
0315     horiz_low_pedrms->SetX2(xStripMax);
0316     horiz_high_pedrms->SetX2(xStripMax);
0317 
0318     TString graph_name_TH2F = Form("lay[%d]" ,layer_access_int);
0319     
0320     const char valu[17];
0321     sprintf(valu, "cham==%d&&layer==%d",j,k);
0322     const char *valu_ = valu;
0323 
0324     Calibration->UseCurrentStyle();
0325     lay[layer_access_int]->Draw();
0326     Calibration->Project(hist_name_, "pedRMS:strip", valu_);
0327     horiz_low_pedrms->Draw(); 
0328     horiz_high_pedrms->Draw();
0329 
0330     thisCanv_rms_strip->Update();
0331 
0332       }//layer loop 
0333       //      process at end of looping
0334       gSystem->cd("pedRMSStrips");
0335       TString canvName = CANV_PEDRMS_STRIP_ARRAY[chamber_access_int]->GetName();
0336       PrintAsGif(thisCanv_rms_strip, canvName); 
0337       gSystem->cd("../");    
0338  
0339     }//chamber loop
0340   }//DDU loop
0341   gSystem->cd("../../../../");
0342   directoryCheck();
0343 }//pedRMSGraph()
0344 
0345 void pedMeanGraphs(int nDDU, int nCham, int nLayer, TString myFileName, TString myFilePath){
0346  gSystem->cd("images/Crosstalk");
0347  gSystem->cd(myFileName);
0348  makeDirectory("pedMeanGraphs");
0349  gSystem->cd("pedMeanGraphs");
0350  makeDirectory("pedMeanStrips");
0351  makeDirectory("pedMeanLayerMean");
0352 
0353 //create mean canvas arrays
0354  TObjArray CANV_PEDMEAN_STRIP_ARRAY(nCham*nDDU);     
0355  TObjArray CANV_PEDMEAN_MEAN_ARRAY(nCham*nDDU); 
0356 
0357 //create mean lines 
0358 TLine *horiz_low_pedmean = new TLine(0,400,80,400);  
0359 TLine *horiz_high_pedmean = new TLine(0,800,80,800);  
0360 TLine *vert_low_pedmean = new TLine(400, 0, 400, 200);  
0361 TLine *vert_high_pedmean = new TLine(800, 0, 800, 200);  
0362  
0363 horiz_low_pedmean->SetLineStyle(3); 
0364 horiz_high_pedmean->SetLineStyle(3);  
0365 vert_low_pedmean->SetLineStyle(3);   
0366 vert_high_pedmean->SetLineStyle(3); 
0367 
0368 horiz_low_pedmean->SetLineColor(6); 
0369 horiz_low_pedmean->SetLineWidth(2); 
0370 horiz_high_pedmean->SetLineColor(6);
0371 horiz_high_pedmean->SetLineWidth(2);
0372 
0373 vert_low_pedmean->SetLineColor(6); 
0374 vert_low_pedmean->SetLineWidth(2); 
0375 vert_high_pedmean->SetLineColor(6); 
0376 vert_high_pedmean->SetLineWidth(2); 
0377 
0378  TH1F *chamber[480]; 
0379  TH2F *layer[2880];
0380   for(int i=0; i<nDDU; ++i){
0381     int idArray[9];
0382     GetChamberIDs(idArray);
0383     for (int j=0; j<nCham; ++j){
0384 
0385       gStyle->SetMarkerStyle(20);
0386       gStyle->SetMarkerSize(1.0);
0387 
0388       Int_t chamber_id_int = idArray[j];
0389       //get the max RMS value for the chamber
0390       Float_t chamber_maxPedval = Calibration->GetLeaf("MaxPed")->GetValue(j);      
0391       Float_t chamber_axisMax = chamber_maxPedval + (.1)*chamber_maxPedval; 
0392 
0393       if (chamber_axisMax<900.0){
0394     chamber_axisMax = 900.0;
0395       }
0396 
0397       //Mean mean Cavases
0398       TString CANV_PEDMEAN_MEAN_NAME = Form("ChamberID_%d_ped_Mean",chamber_id_int);
0399       TCanvas* canv_mean1;
0400       canv_mean1 =  new TCanvas(CANV_PEDMEAN_MEAN_NAME,CANV_PEDMEAN_MEAN_NAME, 200, 10, 1200, 800);
0401       CANV_PEDMEAN_MEAN_ARRAY.Add(canv_mean1);
0402       //Mean strip Canvases
0403       TString CANV_PEDMEAN_STRIP_NAME = Form("ChamberID_%d_ped_Mean_per_Layer",chamber_id_int);
0404       TCanvas* canv_mean2;
0405       canv_mean2= new TCanvas(CANV_PEDMEAN_STRIP_NAME,CANV_PEDMEAN_STRIP_NAME, 200, 10, 1200, 800);
0406       canv_mean2->SetCanvasSize(1200,800);
0407       canv_mean2->Divide(2,3);
0408       CANV_PEDMEAN_STRIP_ARRAY.Add(canv_mean2);
0409       
0410       //create, fill and draw overall MEAN graphs
0411       int chamber_access_int =( (nCham*i)+ j);
0412       TString hist_name= Form("chamber[%d]",chamber_access_int);
0413       chamber[j] = new TH1F(hist_name, "mean mean plot", 100, 300, chamber_axisMax);
0414 
0415       TCanvas *thisCanv_meanMean = CANV_PEDMEAN_MEAN_ARRAY[chamber_access_int];
0416       thisCanv_meanMean->SetCanvasSize(1200,800);
0417       thisCanv_meanMean->cd();
0418         
0419       const char value[7];
0420       sprintf(value, "cham==%d", j);
0421       const char *value_ = value;
0422  
0423       TString new_title1_mean = Form("Mean_ChamberID_%d_DDU_%d", chamber_id_int, i+1);
0424       chamber[j]->SetTitle(new_title1_mean);
0425 
0426       TString new_title1_mean = Form("ChamberID_%d_DDU_%d_Mean", chamber_id_int, i+1);
0427       TString xAxisTitle = Form("Mean Pedestal for Chamber %d",chamber_id_int);
0428 
0429       chamber[j]->SetTitle(new_title1_mean);
0430       chamber[j]->GetXaxis()->SetTitle(xAxisTitle);
0431 
0432       Calibration->UseCurrentStyle();
0433       chamber[j]->Draw();
0434       Calibration->Project(hist_name, "pedMean", value_);
0435 
0436       Double_t yMaxVal = chamber[j]->GetMaximum();
0437       Double_t yMaxRan = yMaxVal + (yMaxVal*.1);
0438 
0439       vert_low_pedmean->SetY2(yMaxRan);
0440       vert_high_pedmean->SetY2(yMaxRan);
0441 
0442       chamber[j]->SetAxisRange(0,yMaxRan,"Y");
0443       
0444       vert_low_pedmean->Draw(); 
0445       vert_high_pedmean->Draw(); 
0446 
0447       thisCanv_meanMean->Update();
0448 
0449       gSystem->cd("pedMeanLayerMean");
0450       TString canvName = CANV_PEDMEAN_MEAN_ARRAY[chamber_access_int]->GetName();
0451       PrintAsGif(thisCanv_meanMean, canvName); 
0452       gSystem->cd("../");
0453 
0454       int NStrips = 0;
0455       int xStripMax = 1;
0456       //dummy graph to retrieve number of strips, to set graph accordingly
0457       TCanvas *StripEntryCanvas = new TCanvas("StripDummyCanvas", "StripDummyCanvas");
0458       TH1F *StripEntryDummy = new TH1F("StripEntryDummy", "StripEntryDummy",10,0,100);
0459       TString chamVar = Form("cham==%d",j);
0460       StripEntryCanvas->cd();
0461       Calibration->Draw("strip>>StripEntryDummy", chamVar);
0462       //number of strips in a given chamber. should be 480 for 5 CFEBs or 384 for 4 CFEBs
0463       NStrips=StripEntryDummy->GetEntries();
0464       
0465       if (NStrips==480){
0466     xStripMax=80;
0467       }if (NStrips==384){
0468     xStripMax=64;
0469      }
0470 
0471       for (int k=0; k<nLayer; ++k){
0472         gStyle->SetMarkerStyle(20);
0473     gStyle->SetMarkerSize(1.0); 
0474     int layer_access_int = ( (nCham*nLayer*i) + (nLayer*j) + k );
0475     //MEAN: create, fill and draw strip graphs
0476     TString hist_name_mean= Form("layer[%d]",layer_access_int);
0477     layer[layer_access_int] = new TH2F(hist_name_mean,"MEAN strip plot", xStripMax, 0, xStripMax, 100, 300, chamber_axisMax);
0478       
0479     TCanvas *thisCanv_mean_strip=CANV_PEDMEAN_STRIP_ARRAY[chamber_access_int];
0480     thisCanv_mean_strip-> cd(k+1);
0481 
0482     layer[layer_access_int]->GetXaxis()->SetTitle("Strip");
0483     layer[layer_access_int]->GetXaxis()->SetTitleSize(0.070);
0484     layer[layer_access_int]->GetXaxis()->SetTitleOffset(0.5);
0485 
0486     layer[layer_access_int]->GetYaxis()->SetTitle("Pedestal Mean");
0487     layer[layer_access_int]->GetYaxis()->SetTitleSize(0.070);
0488     layer[layer_access_int]->GetYaxis()->SetTitleOffset(0.5);
0489     
0490     const char value2[17];
0491     sprintf(value2, "cham==%d&&layer==%d",j,k);
0492     const char *value2_ = value2;
0493 
0494     layer[layer_access_int]->SetMarkerStyle(20);
0495 
0496     horiz_low_pedmean->SetX2(xStripMax);
0497     horiz_high_pedmean->SetX2(xStripMax);
0498 
0499         Calibration->UseCurrentStyle();
0500     layer[layer_access_int]->Draw();
0501     Calibration->Project(hist_name_mean, "pedMean:strip", value2_);
0502     horiz_low_pedmean->Draw("same"); 
0503     horiz_high_pedmean->Draw("same"); 
0504     
0505       }//layer
0506 
0507       gSystem->cd("pedMeanStrips");
0508       TString canvName = CANV_PEDMEAN_STRIP_ARRAY[chamber_access_int]->GetName();
0509       PrintAsGif(thisCanv_mean_strip, canvName); 
0510       gSystem->cd("../");
0511     }//chamber
0512   }//DDU
0513   
0514   gSystem->cd("../../../../");
0515   directoryCheck();
0516 }//pedMeanGraphs()
0517 
0518 void pedRMSFlagGraph(TString myFileName, TString myFilePath){ 
0519   gStyle->SetOptStat(0); 
0520   gSystem->cd("images/Crosstalk");
0521   gSystem->cd(myFileName);
0522 
0523   //1D Graph, straight from Calibration Tree
0524   TCanvas *flagRMSCanv = new TCanvas("flagRMSCanv", "flagRMSCanv", 200,10,800,800);
0525   flagRMSCanv->SetCanvasSize(1200,800);
0526   flagRMSGraph_1D = new TH1F("flagRMSGraph_1D", "flagRMSGraph_1D", 5, 0, 5);
0527   flagRMSGraph_1D->GetYaxis()->SetTitle("Number");
0528   flagRMSGraph_1D->GetYaxis()->SetLabelSize(0.035);
0529   flagRMSGraph_1D->GetXaxis()->SetTitle("Flag");
0530   flagRMSGraph_1D->GetXaxis()->SetLabelSize(0.035);
0531 
0532   TLegend *LegRMS = new TLegend(0.85,0.8,0.98,0.98);
0533   LegRMS->SetHeader("RMS Flags Definitions");
0534   LegRMS->SetFillColor(0);
0535   LegRMS->SetTextSize(0);
0536 
0537   Calibration->UseCurrentStyle(); 
0538   Calibration->Draw("flagRMS>>flagRMSGraph_1D");
0539 
0540   LegRMS->AddEntry("", "1: Good");
0541   LegRMS->AddEntry("", "2: High CFEB Noise");
0542   LegRMS->AddEntry("", "3: Too low Noise");
0543   LegRMS->AddEntry("", "4: Too high Noise");
0544   LegRMS->Draw("same");
0545 
0546   flagRMSCanv->Update();
0547 
0548   //print as gif
0549 
0550   PrintAsGif(flagRMSCanv, "flagRMS");
0551 
0552   /////////////////////////////////       2D GRAPHS            ////////////////////////////////
0553   //no statistics shown
0554   gStyle->SetOptStat(0);
0555 
0556   ////////// Strip Flag Graphs///////////////
0557   //canvas
0558   TCanvas *flagRMSStripCanv = new TCanvas("flagRMSStripCanv", "flagRMSStripCanv", 200,10,800,800);
0559   flagRMSStripCanv->SetCanvasSize(1200,800);
0560 
0561   //create legend 
0562   TLegend *LegRMSStrip = new TLegend(0.85,0.8,0.98,0.98);
0563   LegRMSStrip->SetHeader("RMS Flags Definitions");
0564   LegRMSStrip->SetFillColor(0);
0565   LegRMSStrip->SetTextSize(0);
0566 
0567   //final histogram for display
0568   flagRMSGraph_2D_Strip = new TH2F("flagRMSGraph_2D_Strip", "flagRMSGraph_2D_Strip", 80, 0, 80, 6, 0, 6);
0569   ///dummy histo to get bin maximum
0570   flagRMSGraph_2D_Strip0 = new TH2F("flagRMSGraph_2D_Strip0", "flagRMSGraph_2D_Strip0", 80, 0, 80, 6, 0, 6);
0571   //one histo for each flag value. 
0572   flagRMSGraph_2D_Strip1 = new TH2F("flagRMSGraph_2D_Strip1", "flagRMSGraph_2D_Strip1", 80, 0, 80, 6, 0, 6);
0573   flagRMSGraph_2D_Strip2 = new TH2F("flagRMSGraph_2D_Strip2", "flagRMSGraph_2D_Strip2", 80, 0, 80, 6, 0, 6);
0574   flagRMSGraph_2D_Strip3 = new TH2F("flagRMSGraph_2D_Strip3", "flagRMSGraph_2D_Strip3", 80, 0, 80, 6, 0, 6);
0575   flagRMSGraph_2D_Strip4 = new TH2F("flagRMSGraph_2D_Strip4", "flagRMSGraph_2D_Strip4", 80, 0, 80, 6, 0, 6);
0576   flagRMSGraph_2D_Strip5 = new TH2F("flagRMSGraph_2D_Strip5", "flagRMSGraph_2D_Strip5", 80, 0, 80, 6, 0, 6);
0577   flagRMSGraph_2D_Strip6 = new TH2F("flagRMSGraph_2D_Strip6", "flagRMSGraph_2D_Strip6", 80, 0, 80, 6, 0, 6);
0578 
0579   //fill completley, get bin maximum, set it for overall graph
0580   Calibration->Project("flagRMSGraph_2D_Strip0","flagRMS:strip"); 
0581   Double_t binMaxValStrip = flagRMSGraph_2D_Strip0->GetMaximum();
0582   //normalize each box appropriately, with respect to the most filled box
0583   flagRMSGraph_2D_Strip->SetMaximum(binMaxValStrip);
0584 
0585   //fill each "bin"
0586   Calibration->Project("flagRMSGraph_2D_Strip1","flagRMS:strip", "flagRMS==1","box"); 
0587   Calibration->Project("flagRMSGraph_2D_Strip2","flagRMS:strip", "flagRMS==2","box"); 
0588   Calibration->Project("flagRMSGraph_2D_Strip3","flagRMS:strip", "flagRMS==3","box"); 
0589   Calibration->Project("flagRMSGraph_2D_Strip4","flagRMS:strip", "flagRMS==4","box"); 
0590   Calibration->Project("flagRMSGraph_2D_Strip5","flagRMS:strip", "flagRMS==5","box"); 
0591 
0592   //set appropriate colors
0593   flagRMSGraph_2D_Strip1->SetFillColor(1);//Black for eveything is OK
0594   flagRMSGraph_2D_Strip2->SetFillColor(2);//red for VERY BAD
0595   flagRMSGraph_2D_Strip3->SetFillColor(3);//Green for pretty good
0596   flagRMSGraph_2D_Strip4->SetFillColor(4);//blue for less good
0597 
0598   flagRMSStripCanv->cd(); 
0599   flagRMSGraph_2D_Strip->GetYaxis()->SetTitle("Flag");
0600   flagRMSGraph_2D_Strip->GetXaxis()->SetTitle("Strip, all Chambers");
0601   
0602   //draw original histogram, empty
0603   flagRMSGraph_2D_Strip->Draw("box");
0604   //overlay the individual "bin" graphs
0605   flagRMSGraph_2D_Strip1->Draw("samebox");
0606   flagRMSGraph_2D_Strip2->Draw("samebox");
0607   flagRMSGraph_2D_Strip3->Draw("samebox");
0608   flagRMSGraph_2D_Strip4->Draw("samebox");
0609   flagRMSGraph_2D_Strip5->Draw("samebox");
0610   flagRMSGraph_2D_Strip6->Draw("samebox");
0611 
0612   //set legend entries appropriately
0613   LegRMSStrip->AddEntry(flagRMSGraph_2D_Strip1, "Good", "f");
0614   LegRMSStrip->AddEntry(flagRMSGraph_2D_Strip2, "High CFEB Noise", "f");
0615   LegRMSStrip->AddEntry(flagRMSGraph_2D_Strip3, "Too low Noise", "f");
0616   LegRMSStrip->AddEntry(flagRMSGraph_2D_Strip4, "Too high Noise", "f");
0617   LegRMSStrip->Draw("same");
0618   //print as gif
0619   PrintAsGif(flagRMSStripCanv, "flagRMSStrip");
0620 
0621   ///////// CHAMBER flag Graph ///////////////////////
0622   TCanvas *flagRMSChamberCanv = new TCanvas("flagRMSChamberCanv", "flagRMSChamberCanv", 200,10,800,800);
0623   flagRMSChamberCanv->SetCanvasSize(1200,800);
0624 
0625   //create legend 
0626   TLegend *LegRMSChamber = new TLegend(0.85,0.8,0.98,0.98);
0627   LegRMSChamber->SetHeader("RMS Flags Definitions");
0628   LegRMSChamber->SetFillColor(0);
0629   LegRMSChamber->SetTextSize(0);
0630 
0631   //final histogram for display
0632   flagRMSGraph_2D_Chamber = new TH2F("flagRMSGraph_2D_Chamber", "flagRMSGraph_2D_Chamber", 9, 0, 9, 6, 0, 6);
0633   ///dummy histo to get bin maximum
0634   flagRMSGraph_2D_Chamber0 = new TH2F("flagRMSGraph_2D_Chamber0", "flagRMSGraph_2D_Chamber0", 9, 0, 9, 6, 0, 6);
0635   //one histo for each flag value. 
0636   flagRMSGraph_2D_Chamber1 = new TH2F("flagRMSGraph_2D_Chamber1", "flagRMSGraph_2D_Chamber1", 9, 0, 9, 6, 0, 6);
0637   flagRMSGraph_2D_Chamber2 = new TH2F("flagRMSGraph_2D_Chamber2", "flagRMSGraph_2D_Chamber2", 9, 0, 9, 6, 0, 6);
0638   flagRMSGraph_2D_Chamber3 = new TH2F("flagRMSGraph_2D_Chamber3", "flagRMSGraph_2D_Chamber3", 9, 0, 9, 6, 0, 6);
0639   flagRMSGraph_2D_Chamber4 = new TH2F("flagRMSGraph_2D_Chamber4", "flagRMSGraph_2D_Chamber4", 9, 0, 9, 6, 0, 6);
0640   flagRMSGraph_2D_Chamber5 = new TH2F("flagRMSGraph_2D_Chamber5", "flagRMSGraph_2D_Chamber5", 9, 0, 9, 6, 0, 6);
0641   flagRMSGraph_2D_Chamber6 = new TH2F("flagRMSGraph_2D_Chamber6", "flagRMSGraph_2D_Chamber6", 9, 0, 9, 6, 0, 6);
0642 
0643   //fill completley, get bin maximum, set it for overall graph
0644   Calibration->Project("flagRMSGraph_2D_Chamber0","flagRMS:cham"); 
0645   Double_t binMaxValCham = flagRMSGraph_2D_Chamber0->GetMaximum();
0646   //normalize each box appropriately, with respect to the most filled box
0647   flagRMSGraph_2D_Chamber->SetMaximum(binMaxValCham);
0648 
0649   //fill each "bin"
0650   Calibration->Project("flagRMSGraph_2D_Chamber1","flagRMS:cham", "flagRMS==1", "box"); 
0651   Calibration->Project("flagRMSGraph_2D_Chamber2","flagRMS:cham", "flagRMS==2", "box"); 
0652   Calibration->Project("flagRMSGraph_2D_Chamber3","flagRMS:cham", "flagRMS==3", "box"); 
0653   Calibration->Project("flagRMSGraph_2D_Chamber4","flagRMS:cham", "flagRMS==4", "box"); 
0654   Calibration->Project("flagRMSGraph_2D_Chamber5","flagRMS:cham", "flagRMS==5", "box"); 
0655 
0656   //set appropriate colors
0657   flagRMSGraph_2D_Chamber1->SetFillColor(1);//Black for eveything is OK
0658   flagRMSGraph_2D_Chamber2->SetFillColor(2);//red for VERY BAD
0659   flagRMSGraph_2D_Chamber3->SetFillColor(3);//Green for pretty good
0660   flagRMSGraph_2D_Chamber4->SetFillColor(4);//blue for less good
0661 
0662   int idArray[9];
0663   GetChamberIDs(idArray);
0664   for (int chamNum = 0; chamNum<9; ++chamNum){
0665     int chamNumPlus = chamNum + 1; //for bin access
0666     
0667     Int_t chamber_id_int = idArray[chamNum]; //set individual id as int
0668     std::stringstream chamber_id_stream;     //define variable in intermediate format
0669     chamber_id_stream << chamber_id_int;     //convert from int to intermediate "stringstream" format
0670     TString chamber_id_str = chamber_id_stream.str();  //convert from stream into string
0671     if (chamber_id_str.BeginsWith("220")==0 ){  //binary check, i.e. if the string doesn't begin with 220
0672       chamber_id_str=0;                         //clean out; set to 0.
0673     }else{
0674       chamber_id_str.Remove(8,8);               //remove 0 at end
0675       chamber_id_str.Remove(0,3);               //remove 220 at beginning 
0676     }
0677     flagRMSGraph_2D_Chamber->GetXaxis()->SetBinLabel(chamNumPlus,chamber_id_str); //set bins to have chamber names
0678   }
0679   
0680   flagRMSChamberCanv->cd(); 
0681   flagRMSGraph_2D_Chamber->GetYaxis()->SetTitle("Flag");
0682   flagRMSGraph_2D_Chamber->GetXaxis()->SetTitle("Chamber");
0683 
0684   //draw original histogram, empty
0685   flagRMSGraph_2D_Chamber->Draw("box");
0686   //overlay the individual "bin" graphs
0687   flagRMSGraph_2D_Chamber1->Draw("samebox");
0688   flagRMSGraph_2D_Chamber2->Draw("samebox");
0689   flagRMSGraph_2D_Chamber3->Draw("samebox");
0690   flagRMSGraph_2D_Chamber4->Draw("samebox");
0691   flagRMSGraph_2D_Chamber5->Draw("samebox");
0692   flagRMSGraph_2D_Chamber6->Draw("samebox");
0693 
0694   //set legend entries appropriately
0695   LegRMSChamber->AddEntry(flagRMSGraph_2D_Chamber1, "Good", "f");
0696   LegRMSChamber->AddEntry(flagRMSGraph_2D_Chamber2, "High CFEB Noise", "f");
0697   LegRMSChamber->AddEntry(flagRMSGraph_2D_Chamber3, "Too low Noise", "f");
0698   LegRMSChamber->AddEntry(flagRMSGraph_2D_Chamber4, "Too high Noise", "f");
0699   LegRMSChamber->Draw("same");
0700 
0701   //print as gif
0702   PrintAsGif(flagRMSChamberCanv, "flagRMSChamber");
0703 
0704 /////////////////////// Layer Graphs //////////////
0705 
0706   TCanvas *flagRMSLayerCanv = new TCanvas("flagRMSLayerCanv", "flagRMSLayerCanv", 200,10,800,800);
0707   flagRMSLayerCanv->SetCanvasSize(1200,800);
0708 
0709   //create legend 
0710   TLegend *LegRMSLayer = new TLegend(0.85,0.8,0.98,0.98);
0711   LegRMSLayer->SetHeader("RMS Flags Definitions");
0712   LegRMSLayer->SetFillColor(0);
0713   LegRMSLayer->SetTextSize(0);
0714 
0715   //final histogram for display
0716   flagRMSGraph_2D_Layer = new TH2F("flagRMSGraph_2D_Layer", "flagRMSGraph_2D_Layer", 6, 0, 6, 6, 0, 6);
0717   ///dummy histo to get bin maximum
0718   flagRMSGraph_2D_Layer0 = new TH2F("flagRMSGraph_2D_Layer0", "flagRMSGraph_2D_Layer0", 6, 0, 6, 6, 0, 6);
0719   //one histo for each flag value. 
0720   flagRMSGraph_2D_Layer1 = new TH2F("flagRMSGraph_2D_Layer1", "flagRMSGraph_2D_Layer1", 6, 0, 6, 6, 0, 6);
0721   flagRMSGraph_2D_Layer2 = new TH2F("flagRMSGraph_2D_Layer2", "flagRMSGraph_2D_Layer2", 6, 0, 6, 6, 0, 6);
0722   flagRMSGraph_2D_Layer3 = new TH2F("flagRMSGraph_2D_Layer3", "flagRMSGraph_2D_Layer3", 6, 0, 6, 6, 0, 6);
0723   flagRMSGraph_2D_Layer4 = new TH2F("flagRMSGraph_2D_Layer4", "flagRMSGraph_2D_Layer4", 6, 0, 6, 6, 0, 6);
0724   flagRMSGraph_2D_Layer5 = new TH2F("flagRMSGraph_2D_Layer5", "flagRMSGraph_2D_Layer5", 6, 0, 6, 6, 0, 6);
0725   flagRMSGraph_2D_Layer6 = new TH2F("flagRMSGraph_2D_Layer6", "flagRMSGraph_2D_Layer6", 6, 0, 6, 6, 0, 6);
0726 
0727   //fill completley, get bin maximum, set it for overall graph
0728   Calibration->Project("flagRMSGraph_2D_Layer0","flagRMS:layer"); 
0729   Double_t binMaxValLayer = flagRMSGraph_2D_Layer0->GetMaximum();
0730   //normalize each box appropriately, with respect to the most filled box
0731   flagRMSGraph_2D_Layer->SetMaximum(binMaxValLayer);
0732 
0733   //fill each "bin"
0734   Calibration->Project("flagRMSGraph_2D_Layer1","flagRMS:layer", "flagRMS==1", "box"); 
0735   Calibration->Project("flagRMSGraph_2D_Layer2","flagRMS:layer", "flagRMS==2", "box"); 
0736   Calibration->Project("flagRMSGraph_2D_Layer3","flagRMS:layer", "flagRMS==3", "box"); 
0737   Calibration->Project("flagRMSGraph_2D_Layer4","flagRMS:layer", "flagRMS==4", "box"); 
0738   Calibration->Project("flagRMSGraph_2D_Layer5","flagRMS:layer", "flagRMS==5", "box"); 
0739 
0740   //set appropriate colors
0741   flagRMSGraph_2D_Layer1->SetFillColor(1);//Black for eveything is OK
0742   flagRMSGraph_2D_Layer2->SetFillColor(2);//red for VERY BAD
0743   flagRMSGraph_2D_Layer3->SetFillColor(3);//Green for pretty good
0744   flagRMSGraph_2D_Layer4->SetFillColor(4);//blue for less good
0745   
0746 
0747   flagRMSLayerCanv->cd(); 
0748   flagRMSGraph_2D_Layer->GetYaxis()->SetTitle("Flag");
0749   flagRMSGraph_2D_Layer->GetXaxis()->SetTitle("Layer, all Chambers");
0750   
0751   //draw original histogram, empty
0752   flagRMSGraph_2D_Layer->Draw("box");
0753   //overlay the individual "bin" graphs
0754   flagRMSGraph_2D_Layer1->Draw("samebox");
0755   flagRMSGraph_2D_Layer2->Draw("samebox");
0756   flagRMSGraph_2D_Layer3->Draw("samebox");
0757   flagRMSGraph_2D_Layer4->Draw("samebox");
0758   flagRMSGraph_2D_Layer5->Draw("samebox");
0759   flagRMSGraph_2D_Layer6->Draw("samebox");
0760 
0761   //set legend entries appropriately
0762   LegRMSLayer->AddEntry(flagRMSGraph_2D_Layer1, "Good", "f");
0763   LegRMSLayer->AddEntry(flagRMSGraph_2D_Layer2, "High CFEB Noise", "f");
0764   LegRMSLayer->AddEntry(flagRMSGraph_2D_Layer3, "Too low Noise", "f");
0765   LegRMSLayer->AddEntry(flagRMSGraph_2D_Layer4, "Too high Noise", "f");
0766   LegRMSLayer->Draw("same");
0767   //print as gif
0768   PrintAsGif(flagRMSLayerCanv, "flagRMSLayer");
0769 
0770   gSystem->cd("../../../");
0771   gStyle->SetOptStat(1); 
0772 } 
0773 
0774 void pedNoiseFlagGraph(TString myFileName, TString myFilePath){
0775   //  TFile *myFile = new TFile(myFilePath, "read");
0776   gStyle->SetOptStat(0); 
0777   gSystem->cd("images/Crosstalk");
0778   gSystem->cd(myFileName);
0779 
0780     //1D Graph, straight from Calibration Tree
0781   TCanvas *flagMeanCanv = new TCanvas("flagMeanCanv", "flagMeanCanv", 200,10,800,800);
0782   flagMeanCanv->SetCanvasSize(1200,800);
0783   flagMeanGraph_1D = new TH1F("flagMeanGraph_1D", "flagMeanGraph_1D", 5, 0, 5);
0784   flagMeanGraph_1D->GetYaxis()->SetTitle("Number");
0785   flagMeanGraph_1D->GetYaxis()->SetLabelSize(0.035);
0786   flagMeanGraph_1D->GetXaxis()->SetTitle("Flag");
0787   flagMeanGraph_1D->GetXaxis()->SetLabelSize(0.035);
0788 
0789   TLegend *LegMean = new TLegend(0.85,0.8,0.98,0.98);
0790   LegMean->SetHeader("Mean Flags Definitions");
0791   LegMean->SetFillColor(0);
0792   LegMean->SetTextSize(0);
0793 
0794   Calibration->UseCurrentStyle(); 
0795   Calibration->Draw("flagNoise>>flagMeanGraph_1D");
0796 
0797   LegMean->AddEntry(flagMeanGraph_1D, "1: Normal Pedestal", "f");
0798   LegMean->AddEntry(flagMeanGraph_1D, "2: Low Failure", "f");
0799   LegMean->AddEntry(flagMeanGraph_1D, "3: Low Warning", "f");
0800   LegMean->AddEntry(flagMeanGraph_1D, "4: High Warning", "f");
0801   LegMean->AddEntry(flagMeanGraph_1D, "5: High Failure", "f");
0802 
0803   LegMean->Draw("same");
0804 
0805   flagMeanCanv->Update();
0806 
0807   //print as gif
0808   PrintAsGif(flagMeanCanv, "flagMean");
0809 
0810   /////////////////////////////////       2D GRAPHS            ////////////////////////////////
0811   //no statistics shown
0812   gStyle->SetOptStat(0);
0813 
0814   ////////// Strip Flag Graphs///////////////
0815   //canvas
0816   TCanvas *flagMeanStripCanv = new TCanvas("flagMeanStripCanv", "flagMeanStripCanv", 200,10,800,800);
0817   flagMeanStripCanv->SetCanvasSize(1200,800);
0818 
0819   //create legend 
0820   TLegend *LegMeanStrip = new TLegend(0.85,0.8,0.98,0.98);
0821   LegMeanStrip->SetHeader("Mean Flags Definitions");
0822   LegMeanStrip->SetFillColor(0);
0823   LegMeanStrip->SetTextSize(0);
0824 
0825   //final histogram for display
0826   flagMeanGraph_2D_Strip = new TH2F("flagMeanGraph_2D_Strip", "flagMeanGraph_2D_Strip", 80, 0, 80, 6, 0, 6);
0827   ///dummy histo to get bin maximum
0828   flagMeanGraph_2D_Strip0 = new TH2F("flagMeanGraph_2D_Strip0", "flagMeanGraph_2D_Strip0", 80, 0, 80, 6, 0, 6);
0829   //one histo for each flag value. 
0830   flagMeanGraph_2D_Strip1 = new TH2F("flagMeanGraph_2D_Strip1", "flagMeanGraph_2D_Strip1", 80, 0, 80, 6, 0, 6);
0831   flagMeanGraph_2D_Strip2 = new TH2F("flagMeanGraph_2D_Strip2", "flagMeanGraph_2D_Strip2", 80, 0, 80, 6, 0, 6);
0832   flagMeanGraph_2D_Strip3 = new TH2F("flagMeanGraph_2D_Strip3", "flagMeanGraph_2D_Strip3", 80, 0, 80, 6, 0, 6);
0833   flagMeanGraph_2D_Strip4 = new TH2F("flagMeanGraph_2D_Strip4", "flagMeanGraph_2D_Strip4", 80, 0, 80, 6, 0, 6);
0834   flagMeanGraph_2D_Strip5 = new TH2F("flagMeanGraph_2D_Strip5", "flagMeanGraph_2D_Strip5", 80, 0, 80, 6, 0, 6);
0835   flagMeanGraph_2D_Strip6 = new TH2F("flagMeanGraph_2D_Strip6", "flagMeanGraph_2D_Strip6", 80, 0, 80, 6, 0, 6);
0836 
0837   //fill completley, get bin maximum, set it for overall graph
0838   Calibration->Project("flagMeanGraph_2D_Strip0","flagNoise:strip"); 
0839   Double_t binMaxValStrip = flagMeanGraph_2D_Strip0->GetMaximum();
0840   //normalize each box appropriately, with respect to the most filled box
0841   flagMeanGraph_2D_Strip->SetMaximum(binMaxValStrip);
0842 
0843   //fill each "bin"
0844   Calibration->Project("flagMeanGraph_2D_Strip1","flagNoise:strip", "flagNoise==1","box"); 
0845   Calibration->Project("flagMeanGraph_2D_Strip2","flagNoise:strip", "flagNoise==2","box"); 
0846   Calibration->Project("flagMeanGraph_2D_Strip3","flagNoise:strip", "flagNoise==3","box"); 
0847   Calibration->Project("flagMeanGraph_2D_Strip4","flagNoise:strip", "flagNoise==4","box"); 
0848   Calibration->Project("flagMeanGraph_2D_Strip5","flagNoise:strip", "flagNoise==5","box"); 
0849 
0850   //set appropriate colors
0851   flagMeanGraph_2D_Strip1->SetFillColor(1);//Black for eveything is OK
0852   flagMeanGraph_2D_Strip2->SetFillColor(2);//red for VERY BAD
0853   flagMeanGraph_2D_Strip3->SetFillColor(3);//Green for pretty good
0854   flagMeanGraph_2D_Strip4->SetFillColor(4);//blue for less good
0855   flagMeanGraph_2D_Strip5->SetFillColor(5);//red for VERY BAD
0856 
0857 
0858   flagMeanStripCanv->cd(); 
0859   flagMeanGraph_2D_Strip->GetYaxis()->SetTitle("Flag");
0860   flagMeanGraph_2D_Strip->GetXaxis()->SetTitle("Strip, all Chambers");
0861   
0862   //draw original histogram, empty
0863   flagMeanGraph_2D_Strip->Draw("box");
0864   //overlay the individual "bin" graphs
0865   flagMeanGraph_2D_Strip1->Draw("samebox");
0866   flagMeanGraph_2D_Strip2->Draw("samebox");
0867   flagMeanGraph_2D_Strip3->Draw("samebox");
0868   flagMeanGraph_2D_Strip4->Draw("samebox");
0869   flagMeanGraph_2D_Strip5->Draw("samebox");
0870   flagMeanGraph_2D_Strip6->Draw("samebox");
0871 
0872   //set legend entries appropriately
0873   LegMeanStrip->AddEntry(flagMeanGraph_2D_Strip1, "1: Normal Pedestal", "f");
0874   LegMeanStrip->AddEntry(flagMeanGraph_2D_Strip2, "2: Low Failure", "f");
0875   LegMeanStrip->AddEntry(flagMeanGraph_2D_Strip3, "3: Low Warning", "f");
0876   LegMeanStrip->AddEntry(flagMeanGraph_2D_Strip4, "4: High Warning", "f");
0877   LegMeanStrip->AddEntry(flagMeanGraph_2D_Strip5, "5: High Failure", "f");
0878   LegMeanStrip->Draw("same");
0879 
0880   //print as gif
0881   PrintAsGif(flagMeanStripCanv, "flagMeanStrip");
0882 
0883   ///////// CHAMBER flag Graph ///////////////////////
0884   TCanvas *flagMeanChamberCanv = new TCanvas("flagMeanChamberCanv", "flagMeanChamberCanv", 200,10,800,800);
0885   flagMeanChamberCanv->SetCanvasSize(1200,800);
0886 
0887   //create legend 
0888   TLegend *LegMeanChamber = new TLegend(0.85,0.8,0.98,0.98);
0889   LegMeanChamber->SetHeader("Mean Flags Definitions");
0890   LegMeanChamber->SetFillColor(0);
0891   LegMeanChamber->SetTextSize(0);
0892 
0893   //final histogram for display
0894   flagMeanGraph_2D_Chamber = new TH2F("flagMeanGraph_2D_Chamber", "flagMeanGraph_2D_Chamber", 9, 0, 9, 6, 0, 6);
0895   ///dummy histo to get bin maximum
0896   flagMeanGraph_2D_Chamber0 = new TH2F("flagMeanGraph_2D_Chamber0", "flagMeanGraph_2D_Chamber0", 9, 0, 9, 6, 0, 6);
0897   //one histo for each flag value. 
0898   flagMeanGraph_2D_Chamber1 = new TH2F("flagMeanGraph_2D_Chamber1", "flagMeanGraph_2D_Chamber1", 9, 0, 9, 6, 0, 6);
0899   flagMeanGraph_2D_Chamber2 = new TH2F("flagMeanGraph_2D_Chamber2", "flagMeanGraph_2D_Chamber2", 9, 0, 9, 6, 0, 6);
0900   flagMeanGraph_2D_Chamber3 = new TH2F("flagMeanGraph_2D_Chamber3", "flagMeanGraph_2D_Chamber3", 9, 0, 9, 6, 0, 6);
0901   flagMeanGraph_2D_Chamber4 = new TH2F("flagMeanGraph_2D_Chamber4", "flagMeanGraph_2D_Chamber4", 9, 0, 9, 6, 0, 6);
0902   flagMeanGraph_2D_Chamber5 = new TH2F("flagMeanGraph_2D_Chamber5", "flagMeanGraph_2D_Chamber5", 9, 0, 9, 6, 0, 6);
0903   flagMeanGraph_2D_Chamber6 = new TH2F("flagMeanGraph_2D_Chamber6", "flagMeanGraph_2D_Chamber6", 9, 0, 9, 6, 0, 6);
0904 
0905   //fill completley, get bin maximum, set it for overall graph
0906   Calibration->Project("flagMeanGraph_2D_Chamber0","flagNoise:cham"); 
0907   Double_t binMaxValCham = flagMeanGraph_2D_Chamber0->GetMaximum();
0908   //normalize each box appropriately, with respect to the most filled box
0909   flagMeanGraph_2D_Chamber->SetMaximum(binMaxValCham);
0910 
0911   //fill each "bin"
0912   Calibration->Project("flagMeanGraph_2D_Chamber1","flagNoise:cham", "flagNoise==1", "box"); 
0913   Calibration->Project("flagMeanGraph_2D_Chamber2","flagNoise:cham", "flagNoise==2", "box"); 
0914   Calibration->Project("flagMeanGraph_2D_Chamber3","flagNoise:cham", "flagNoise==3", "box"); 
0915   Calibration->Project("flagMeanGraph_2D_Chamber4","flagNoise:cham", "flagNoise==4", "box"); 
0916   Calibration->Project("flagMeanGraph_2D_Chamber5","flagNoise:cham", "flagNoise==5", "box"); 
0917 
0918   //set appropriate colors
0919   flagMeanGraph_2D_Chamber1->SetFillColor(1);//Black for eveything is OK
0920   flagMeanGraph_2D_Chamber2->SetFillColor(2);//red for VERY BAD
0921   flagMeanGraph_2D_Chamber3->SetFillColor(3);//Green for pretty good
0922   flagMeanGraph_2D_Chamber4->SetFillColor(4);//blue for less good
0923   flagMeanGraph_2D_Chamber5->SetFillColor(5);//blue for less good
0924 
0925   int idArray[9];
0926   GetChamberIDs(idArray);
0927   for (int chamNum = 0; chamNum<9; ++chamNum){
0928     int chamNumPlus = chamNum + 1; //for bin access
0929     
0930     Int_t chamber_id_int = idArray[chamNum]; //set individual id as int
0931     std::stringstream chamber_id_stream;     //define variable in intermediate format
0932     chamber_id_stream << chamber_id_int;     //convert from int to intermediate "stringstream" format
0933     TString chamber_id_str = chamber_id_stream.str();  //convert from stream into string
0934     if (chamber_id_str.BeginsWith("220")==0 ){  //binary check, i.e. if the string doesn't begin with 220
0935       chamber_id_str=0;                         //clean out; set to 0.
0936     }else{
0937       chamber_id_str.Remove(8,8);               //remove 0 at end
0938       chamber_id_str.Remove(0,3);               //remove 220 at beginning 
0939     }
0940     flagMeanGraph_2D_Chamber->GetXaxis()->SetBinLabel(chamNumPlus,chamber_id_str); //set bins to have chamber names
0941   }
0942   
0943   flagMeanChamberCanv->cd(); 
0944   flagMeanGraph_2D_Chamber->GetYaxis()->SetTitle("Flag");
0945   flagMeanGraph_2D_Chamber->GetXaxis()->SetTitle("Chamber");
0946   //draw original histogram, empty
0947   flagMeanGraph_2D_Chamber->Draw("box");
0948   //overlay the individual "bin" graphs
0949   flagMeanGraph_2D_Chamber1->Draw("samebox");
0950   flagMeanGraph_2D_Chamber2->Draw("samebox");
0951   flagMeanGraph_2D_Chamber3->Draw("samebox");
0952   flagMeanGraph_2D_Chamber4->Draw("samebox");
0953   flagMeanGraph_2D_Chamber5->Draw("samebox");
0954   flagMeanGraph_2D_Chamber6->Draw("samebox");
0955 
0956   //set legend entries appropriately
0957   LegMeanChamber->AddEntry(flagMeanGraph_2D_Chamber1, "1: Normal Pedestal", "f");
0958   LegMeanChamber->AddEntry(flagMeanGraph_2D_Chamber2, "2: Low Failure", "f");
0959   LegMeanChamber->AddEntry(flagMeanGraph_2D_Chamber3, "3: Low Warning", "f");
0960   LegMeanChamber->AddEntry(flagMeanGraph_2D_Chamber4, "4: High Warning", "f");
0961   LegMeanChamber->AddEntry(flagMeanGraph_2D_Chamber5, "5: High Failure", "f");
0962   LegMeanChamber->Draw("same");
0963 
0964   //print as gif
0965   PrintAsGif(flagMeanChamberCanv, "flagMeanChamber");
0966 
0967 /////////////////////// Layer Graphs //////////////
0968 
0969   TCanvas *flagMeanLayerCanv = new TCanvas("flagMeanLayerCanv", "flagMeanLayerCanv", 200,10,800,800);
0970   flagMeanLayerCanv->SetCanvasSize(1200,800);
0971 
0972   //create legend 
0973   TLegend *LegMeanLayer = new TLegend(0.85,0.8,0.98,0.98);
0974   LegMeanLayer->SetHeader("Mean Flags Definitions");
0975   LegMeanLayer->SetFillColor(0);
0976   LegMeanLayer->SetTextSize(0);
0977 
0978   //final histogram for display
0979   flagMeanGraph_2D_Layer = new TH2F("flagMeanGraph_2D_Layer", "flagMeanGraph_2D_Layer", 6, 0, 6, 6, 0, 6);
0980   ///dummy histo to get bin maximum
0981   flagMeanGraph_2D_Layer0 = new TH2F("flagMeanGraph_2D_Layer0", "flagMeanGraph_2D_Layer0", 6, 0, 6, 6, 0, 6);
0982   //one histo for each flag value. 
0983   flagMeanGraph_2D_Layer1 = new TH2F("flagMeanGraph_2D_Layer1", "flagMeanGraph_2D_Layer1", 6, 0, 6, 6, 0, 6);
0984   flagMeanGraph_2D_Layer2 = new TH2F("flagMeanGraph_2D_Layer2", "flagMeanGraph_2D_Layer2", 6, 0, 6, 6, 0, 6);
0985   flagMeanGraph_2D_Layer3 = new TH2F("flagMeanGraph_2D_Layer3", "flagMeanGraph_2D_Layer3", 6, 0, 6, 6, 0, 6);
0986   flagMeanGraph_2D_Layer4 = new TH2F("flagMeanGraph_2D_Layer4", "flagMeanGraph_2D_Layer4", 6, 0, 6, 6, 0, 6);
0987   flagMeanGraph_2D_Layer5 = new TH2F("flagMeanGraph_2D_Layer5", "flagMeanGraph_2D_Layer5", 6, 0, 6, 6, 0, 6);
0988   flagMeanGraph_2D_Layer6 = new TH2F("flagMeanGraph_2D_Layer6", "flagMeanGraph_2D_Layer6", 6, 0, 6, 6, 0, 6);
0989 
0990   //fill completley, get bin maximum, set it for overall graph
0991   Calibration->Project("flagMeanGraph_2D_Layer0","flagNoise:layer"); 
0992   Double_t binMaxValLayer = flagMeanGraph_2D_Layer0->GetMaximum();
0993   //normalize each box appropriately, with respect to the most filled box
0994   flagMeanGraph_2D_Layer->SetMaximum(binMaxValLayer);
0995 
0996   //fill each "bin"
0997   Calibration->Project("flagMeanGraph_2D_Layer1","flagNoise:layer", "flagNoise==1", "box"); 
0998   Calibration->Project("flagMeanGraph_2D_Layer2","flagNoise:layer", "flagNoise==2", "box"); 
0999   Calibration->Project("flagMeanGraph_2D_Layer3","flagNoise:layer", "flagNoise==3", "box"); 
1000   Calibration->Project("flagMeanGraph_2D_Layer4","flagNoise:layer", "flagNoise==4", "box"); 
1001   Calibration->Project("flagMeanGraph_2D_Layer5","flagNoise:layer", "flagNoise==5", "box"); 
1002 
1003   //set appropriate colors
1004   flagMeanGraph_2D_Layer1->SetFillColor(1);//Black for eveything is OK
1005   flagMeanGraph_2D_Layer2->SetFillColor(2);//red for VERY BAD
1006   flagMeanGraph_2D_Layer3->SetFillColor(3);//Green for pretty good
1007   flagMeanGraph_2D_Layer4->SetFillColor(4);//blue for less good
1008   flagMeanGraph_2D_Layer5->SetFillColor(5);
1009 
1010   flagMeanLayerCanv->cd(); 
1011   flagMeanGraph_2D_Layer->GetYaxis()->SetTitle("Flag");
1012   flagMeanGraph_2D_Layer->GetXaxis()->SetTitle("Layer, per Chamber");
1013   
1014   //draw original histogram, empty
1015   flagMeanGraph_2D_Layer->Draw("box");
1016   //overlay the individual "bin" graphs
1017   flagMeanGraph_2D_Layer1->Draw("samebox");
1018   flagMeanGraph_2D_Layer2->Draw("samebox");
1019   flagMeanGraph_2D_Layer3->Draw("samebox");
1020   flagMeanGraph_2D_Layer4->Draw("samebox");
1021   flagMeanGraph_2D_Layer5->Draw("samebox");
1022   flagMeanGraph_2D_Layer6->Draw("samebox");
1023 
1024   //set legend entries appropriately
1025   LegMeanLayer->AddEntry(flagMeanGraph_2D_Layer1, "1: Normal Pedestal", "f");
1026   LegMeanLayer->AddEntry(flagMeanGraph_2D_Layer2, "2: Low Failure", "f");
1027   LegMeanLayer->AddEntry(flagMeanGraph_2D_Layer3, "3: Low Warning", "f");
1028   LegMeanLayer->AddEntry(flagMeanGraph_2D_Layer4, "4: High Warning", "f");
1029   LegMeanLayer->AddEntry(flagMeanGraph_2D_Layer5, "5: High Failure", "f");
1030   LegMeanChamber->Draw("same");
1031 
1032   PrintAsGif(flagMeanLayerCanv, "flagMeanLayer");
1033 
1034   gSystem->cd("../../../");
1035   gStyle->SetOptStat(1); 
1036 }
1037 
1038 void PulseGraphs(TString myFileName, TString myFilePath){  
1039   TFile *myfile = TFile::Open(myFilePath);
1040   std::cout << "begginng of PulseGraphs, now in : " << gSystem->pwd() << std::endl;
1041   std::cout << "opening file: " << myFilePath << std::endl; 
1042 
1043   gSystem->cd("/afs/cern.ch/cms/CSC/html/csccalib/");
1044   gSystem->cd("images/Crosstalk");  
1045   gSystem->cd(myFileName);  
1046   makeDirectory("PulseGraphs"); 
1047 
1048   TCanvas *canv_pulse; 
1049   TH2F *gPulse; 
1050   TString cname="Pulse_Graph_all_chambers";
1051   TString ctitle="Pulse Graph over all Chambers";
1052   canv_pulse =  new TCanvas(cname,ctitle,1100,700);
1053   gPulse = (TH2F*)myfile->Get("pulse"); 
1054   gPulse->GetXaxis()->SetLabelSize(0.07);
1055   gPulse->GetYaxis()->SetLabelSize(0.07);
1056   gPulse->GetXaxis()->SetTitleSize(0.07);
1057   gPulse->GetXaxis()->SetTitleOffset(0.7);
1058   gPulse->GetXaxis()->SetTitle("Time (ns)");
1059   gPulse->GetYaxis()->SetTitle("ADC Count");
1060   canv_pulse->cd();
1061   gPulse->Draw();   
1062   /*
1063   int idArray[9];
1064   GetChamberIDs(idArray);
1065    for (int cham_num=0; cham_num<nCham; ++cham_num){
1066      int NStrips = 0;
1067      int nCFEB = 0;
1068      //dummy graph to retrieve number of strips, to set graph accordingly
1069      TCanvas *StripEntryCanvas = new TCanvas("StripDummyCanvas", "StripDummyCanvas");
1070      TH1F *StripEntryDummy = new TH1F("StripEntryDummy", "StripEntryDummy",10,0,100);
1071      TString chamVar = Form("cham==%d",cham_num);
1072      StripEntryCanvas->cd();
1073      Calibration->Draw("strip>>StripEntryDummy", chamVar);
1074      //number of strips in a given chamber. should be 480 for 5 CFEBs or 384 for 4 CFEBs
1075      NStrips= StripEntryDummy->GetEntries();
1076      
1077      TString cname  = Form("Chamber_%d_Pulse_Graphs",idArray[cham_num]); 
1078      //TString cname  = Form("Chamber_%d_Pulse_Graphs",cham_num); 
1079      TString ctitle = Form("Pulse for Chamber %d",idArray[cham_num]);
1080      //TString ctitle = Form("Pulse for Chamber %d",cham_num);
1081      canv_pulse =  new TCanvas(cname,ctitle,1100,700); 
1082      
1083 
1084      if (NStrips==480){
1085        nCFEB=6;
1086        canv_pulse->Divide(2,3);
1087      }if (NStrips==384){
1088        nCFEB=5; 
1089        canv_pulse->Divide(2,2);
1090      }
1091      
1092      for (int CFEB_num=1; CFEB_num<nCFEB; ++CFEB_num){ 
1093        TString graphname= Form("pulse%d%d",cham_num,CFEB_num); 
1094        canv_pulse->cd(CFEB_num); 
1095        pulse = (TH2F*)myfile->Get(graphname); 
1096        pulse->GetXaxis()->SetLabelSize(0.07);
1097        pulse->GetYaxis()->SetLabelSize(0.07);
1098        pulse->GetXaxis()->SetTitleSize(0.07);
1099        pulse->GetXaxis()->SetTitleOffset(0.7);
1100        pulse->GetXaxis()->SetTitle("Time (ns)");
1101        pulse->GetYaxis()->SetTitle("ADC Count");
1102        pulse->Draw();   
1103      }//for CFEB 
1104 }//for cham    
1105   */ 
1106   gSystem->cd("PulseGraphs");   
1107   TString PulseGraphCanvName = canv_pulse->GetName();
1108   PrintAsGif(canv_pulse,PulseGraphCanvName);
1109   
1110   gSystem->cd("/afs/cern.ch/user/c/csccalib/scratch0/CMSSW_1_5_1/src/OnlineDB/CSCCondDB/test");
1111   directoryCheck();   
1112   myfile->Close(); 
1113 }//PulseGraphs() 
1114 
1115 void PeakGraphs(TString myFileName, TString myFilePath, int nCham){ 
1116 std::cout << "begginng of PeakGraphs, now in : " << gSystem->pwd() << std::endl;
1117 std::cout << "opening file: " << myFilePath << std::endl; 
1118 gSystem->cd("/afs/cern.ch/cms/CSC/html/csccalib/");
1119 
1120 gSystem->cd("images/Crosstalk");
1121 gSystem->cd(myFileName);
1122 makeDirectory("PeakADCTimingGraphs");
1123 
1124 TLine *vert_min_Time = new TLine(250, 0, 250, 200);
1125 TLine *vert_max_Time = new TLine(360, 0, 360, 200);
1126 TLine *vert_min_ADC = new TLine(700, 0, 700, 200);
1127 TLine *vert_max_ADC = new TLine(1200, 0, 1200, 200);
1128 
1129 vert_min_Time->SetLineStyle(3);//dotted
1130 vert_min_Time->SetLineColor(6);//red
1131 vert_min_Time->SetLineWidth(2);//visible but not overwhelming width
1132 
1133 vert_max_Time->SetLineStyle(3);//dotted
1134 vert_max_Time->SetLineColor(6);//red
1135 vert_max_Time->SetLineWidth(2);//visible but not overwhelming width
1136 
1137 vert_min_ADC->SetLineStyle(3);//dotted
1138 vert_min_ADC->SetLineColor(6);//red
1139 vert_min_ADC->SetLineWidth(2);//visible but not overwhelming width
1140 
1141 vert_max_ADC->SetLineStyle(3);//dotted
1142 vert_max_ADC->SetLineColor(6);//red
1143 vert_max_ADC->SetLineWidth(2);//visible but not overwhelming width
1144 
1145 //Time and ADC Graphs for everything 
1146 TCanvas *PeakCanv = new TCanvas("Peak Timing", "Peak Time and ADC for all Chambers", 200, 10, 1200, 800);
1147 PeakCanv->Divide(2,1); 
1148 PeakCanv->SetCanvasSize(1200,800);
1149 
1150 PeakCanv->cd(1);
1151 TH1F *PeakADC = new TH1F("PeakADC", "Peak ADC over all Chambers", 100, 600, 1400);
1152 PeakADC->Draw(); 
1153 PeakADC->GetXaxis()->SetTitle("ADC Count at Peak Time");
1154 PeakADC->GetXaxis()->SetTitleSize(0.070);
1155 PeakADC->GetXaxis()->SetTitleOffset(0.5);
1156 Calibration->Project("PeakADC", "maxADC");   
1157 
1158 Double_t yMaxValADC = PeakADC->GetMaximum();
1159 Double_t yMaxRanADC = yMaxValADC + (yMaxValADC*.1);
1160 vert_max_ADC->SetY2(yMaxRanADC);
1161 vert_min_ADC->SetY2(yMaxRanADC);
1162 PeakADC->SetAxisRange(0,yMaxRanADC,"Y");
1163 vert_max_ADC->Draw(); 
1164 vert_min_ADC->Draw();
1165 
1166 PeakCanv->cd(2);
1167 TH1F *PeakTime = new TH1F("PeakTime", "Peak Time over all Chambers", 100, 200, 400);
1168 PeakTime->Draw(); 
1169 PeakTime->GetXaxis()->SetTitle("Peak Time (ns)");
1170 PeakTime->GetXaxis()->SetTitleSize(0.070);
1171 PeakTime->GetXaxis()->SetTitleOffset(0.5);
1172 Calibration->Project("PeakTime", "peakTime");   
1173 
1174 Double_t yMaxValTime = PeakTime->GetMaximum();
1175 Double_t yMaxRanTime = yMaxValTime + (yMaxValTime*.1);
1176 vert_max_Time->SetY2(yMaxRanTime);
1177 vert_min_Time->SetY2(yMaxRanTime);
1178 PeakTime->SetAxisRange(0,yMaxRanTime,"Y");
1179 vert_max_Time->Draw(); 
1180 vert_min_Time->Draw(); 
1181 
1182 //take the new line into account 
1183 PeakCanv->Update();
1184 PrintAsGif(PeakCanv, "PeakTimingADC");
1185 
1186 ///Time and ADC Graphs per chamber
1187 TObjArray PeakGraphCanvArray(nCham);
1188 
1189 TH1F *PeakADCGraphs[9];
1190 TH1F *PeakTimeGraphs[9];
1191 
1192 int idArray[9];
1193 GetChamberIDs(idArray);
1194 for (int cham_num=0; cham_num < nCham; ++cham_num){
1195 gSystem->cd("PeakADCTimingGraphs");
1196 Int_t chamber_id_int = idArray[cham_num];
1197  
1198 Float_t MaxPeakTimeVal = Calibration->GetLeaf("MaxPeakTime")->GetValue(cham_num);
1199 Float_t MinPeakTimeVal = Calibration->GetLeaf("MinPeakTime")->GetValue(cham_num);
1200 Float_t MaxPeakADCVal = Calibration->GetLeaf("MaxPeakADC")->GetValue(cham_num);
1201 Float_t MinPeakADCVal = Calibration->GetLeaf("MinPeakADC")->GetValue(cham_num);
1202 
1203 Float_t MaxPeakTimeValue = MaxPeakTimeVal + (.1)*MaxPeakTimeVal; 
1204 if (MaxPeakTimeValue < 400.0){
1205    MaxPeakTimeValue = 400.0;
1206  }
1207 Float_t MinPeakTimeValue = MinPeakTimeVal + (.1)*MinPeakTimeVal; 
1208 if (MinPeakTimeValue > 200.0){
1209    MinPeakTimeValue = 200.0;
1210 }
1211 Float_t MaxPeakADCValue = MaxPeakADCVal + (.1)*MaxPeakADCVal; 
1212 if (MaxPeakADCValue < 1300.0){
1213    MaxPeakADCValue = 1300.0;
1214  }
1215 Float_t MinPeakADCValue = MinPeakADCVal + (.1)*MinPeakADCVal; 
1216 if (MinPeakADCValue < 600.0){
1217   MinPeakADCValue = 600.0;
1218 }
1219 
1220 TString PeakGraphCanvName = Form ("Chamber_%d_Peak_Graphs", chamber_id_int);
1221 TCanvas *canv_peak =  new TCanvas(PeakGraphCanvName,PeakGraphCanvName, 200, 10, 1200, 800); 
1222 canv_peak->Divide(2,1);
1223 canv_peak->SetCanvasSize(1200,800);
1224 
1225 canv_peak->cd(1);
1226 TString hist_name = Form("PeakADCGraph_Chamber_%d", chamber_id_int);
1227 PeakADCGraphs[cham_num] = new TH1F(hist_name, "peakADC Plot", 50, MinPeakADCValue, MaxPeakADCValue);
1228 PeakADCGraphs[cham_num]->Draw();
1229 
1230 TString xTitleName = Form("ADC Count at Peak Time for chamber %d", chamber_id_int);
1231 PeakADCGraphs[cham_num]->GetXaxis()->SetTitle(xTitleName);
1232 PeakADCGraphs[cham_num]->GetXaxis()->SetTitleSize(0.050);
1233 PeakADCGraphs[cham_num]->GetXaxis()->SetTitleOffset(0.5);
1234 
1235 const char value[7];
1236 sprintf(value, "cham==%d", cham_num);
1237 const char *value_ = value;
1238 Calibration->Project(hist_name, "maxADC", value_); 
1239 
1240 Double_t yMaxValADC = PeakADCGraphs[cham_num]->GetMaximum();
1241 Double_t yMaxRanADC = yMaxValADC + (yMaxValADC*.1);
1242 vert_max_ADC->SetY2(yMaxRanADC); 
1243 vert_min_ADC->SetY2(yMaxRanADC); 
1244 PeakADCGraphs[cham_num]->SetAxisRange(0,yMaxRanADC,"Y"); 
1245 vert_max_ADC->Draw(); 
1246 vert_min_ADC->Draw(); 
1247 
1248 canv_peak->cd(2);
1249 TString hist_name_ = Form("PeakTimeGraph_Chamber_%d", chamber_id_int);
1250 PeakTimeGraphs[cham_num] = new TH1F(hist_name_, "peakTime Plot", 50, MinPeakTimeValue, MaxPeakTimeValue);
1251 PeakTimeGraphs[cham_num]->Draw();
1252 
1253 PeakTimeGraphs[cham_num]->GetXaxis()->SetTitle("Peak Time in nano seconds");
1254 PeakTimeGraphs[cham_num]->GetXaxis()->SetTitleSize(0.070);
1255 PeakTimeGraphs[cham_num]->GetXaxis()->SetTitleOffset(0.5);
1256 
1257 const char valu[7];
1258 sprintf(valu, "cham==%d", cham_num);
1259 const char *valu_ = valu;
1260 Calibration->Project(hist_name_, "peakTime", valu_); 
1261 
1262 Double_t yMaxValTime = PeakTimeGraphs[cham_num]->GetMaximum();
1263 Double_t yMaxRanTime = yMaxValTime + (yMaxValTime*.1);
1264 vert_max_Time->SetY2(yMaxRanTime);
1265 vert_min_Time->SetY2(yMaxRanTime);
1266 PeakTimeGraphs[cham_num]->SetAxisRange(0,yMaxRanTime,"Y");
1267 vert_max_Time->Draw(); 
1268 vert_min_Time->Draw(); 
1269  
1270 canv_peak->Update();
1271 
1272 PeakGraphCanvArray.Add(canv_peak);
1273 
1274 PrintAsGif(canv_peak, PeakGraphCanvName); 
1275 }//for chamber
1276 gSystem->cd("/afs/cern.ch/user/c/csccalib/scratch0/CMSSW_1_5_1/src/OnlineDB/CSCCondDB/test");
1277 directoryCheck(); 
1278 }//PeakGraphs