Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:00:02

0001 
0002 void DrawEECosmicPlots(Char_t* infile = 0, Int_t runNum=0, Bool_t doEEPlus=kTRUE, Bool_t printPics = kTRUE, Char_t* fileType = "png", Char_t* dirName = ".", Bool_t doWait=kFALSE)
0003 {
0004 
0005   gROOT->SetStyle("Plain");
0006   gStyle->SetPalette(1,0); gStyle->SetOptStat(10);
0007 
0008   if (!infile) {
0009     cout << " No input file specified !" << endl;
0010     return;
0011   }
0012 
0013   cout << "Producing cosmics plots for: " << infile << endl;
0014 
0015   TFile* f = new TFile(infile);
0016 
0017   int runNumber = 0;
0018   if (runNum==0) {
0019     runNumber = runNumberHist->GetBinContent(1);
0020     cout << "Run Number: " << runNumber << endl;
0021   } else {
0022     runNumber = runNum;
0023   }
0024 
0025   char name[100];  
0026 
0027   char runChar[50];
0028   sprintf(runChar,", run %i",runNumber);
0029 
0030 
0031   char hname[200];  char fname[200]; char dname[200]; char sname[200];
0032 
0033   if (doEEPlus) {
0034     sprintf(dname,"EEPlus");      
0035     sprintf(sname,"EEP");      
0036   } else {
0037     sprintf(dname,"EEMinus");      
0038     sprintf(sname,"EEM");      
0039   } 
0040 
0041   // First for EE-
0042 
0043   // occupancy plots
0044 
0045   const int nHists1 = 5+4+4+4+4+4;
0046 
0047   char* occupPlots[nHists1] = {
0048     "OccupancyAllEvents",
0049     "OccupancyAllEventsCoarse",
0050     "OccupancySingleXtal",
0051     "OccupancyHighEnergyEvents",
0052     "OccupancyHighEnergyEventsCoarse",
0053     "OccupancyAllEventsCoarse_ECAL",
0054     "OccupancyAllEvents_ECAL",
0055     "OccupancyAllEventsCoarse_ExclusiveECAL",
0056     "OccupancyAllEvents_ExclusiveHCAL",
0057     "OccupancyAllEventsCoarse_HCAL",
0058     "OccupancyAllEvents_HCAL",
0059     "OccupancyAllEventsCoarse_ExclusiveHCAL",
0060     "OccupancyAllEvents_ExclusiveHCAL",
0061     "OccupancyAllEventsCoarse_DT",
0062     "OccupancyAllEvents_DT",
0063     "OccupancyAllEventsCoarse_ExclusiveDT",
0064     "OccupancyAllEvents_ExclusiveDT",
0065     "OccupancyAllEventsCoarse_RPC",
0066     "OccupancyAllEvents_RPC",
0067     "OccupancyAllEventsCoarse_ExclusiveRPC",
0068     "OccupancyAllEvents_ExclusiveRPC",
0069     "OccupancyAllEventsCoarse_CSC",
0070     "OccupancyAllEvents_CSC",
0071     "OccupancyAllEventsCoarse_ExclusiveCSC",
0072     "OccupancyAllEvents_ExclusiveCSC"
0073   };
0074 
0075   TCanvas* c1[nHists1];
0076   char cname[100]; 
0077 
0078   for (int i=0; i<nHists1; i++) {
0079     sprintf(cname,"c1_%i",i);
0080     int x = (i%3)*500;     //int x = (i%3)*600;
0081     int y = (i/3)*100;     //int y = (i/3)*200;
0082     c1[i] =  new TCanvas(cname,cname,x,y,500,500);
0083     //    cout << "Hists " << i << " : " << x << " , " << y << endl;
0084   }
0085 
0086 
0087   cout << nHists1 << endl;
0088   for (int ic=0; ic<nHists1; ic++) {
0089     cout << ic << endl;
0090     c1[ic]->cd();
0091     sprintf(fname,occupPlots[ic]);  
0092     draw2D(10,fname,dname,c1[ic],f,runNum);
0093     c1[ic]->SetLogy(0);
0094     c1[ic]->SetLogz(1);
0095     drawEELines();
0096     if (printPics) { sprintf(name,"%s/cosmicsAnalysis_%s_%s_%i.%s",dirName,fname,sname,runNumber,fileType); c1[ic]->Print(name); }  
0097   }
0098   
0099 
0100   // 1D Log plots  
0101   // energies
0102   const int nHists2 = 6;
0103   char* oneDimLogPlots[nHists2] = {
0104     "SeedEnergyAllFEDs",
0105      "E2_AllClusters",
0106     "energy_AllClusters",
0107     "energyHigh_AllClusters",
0108     "energyHigh_HighEnergyClusters",
0109     "energy_SingleXtalClusters"
0110   };
0111 
0112   TCanvas* c2[nHists2];
0113 
0114   for (int i=0; i<nHists2; i++) {
0115     sprintf(cname,"c2_%i",i);
0116     int x = ((i)%3)*600;     //int x = (i%3)*600;
0117     int y = ((i)/3)*100;     //int y = (i/3)*200;
0118     c2[i] =  new TCanvas(cname,cname,x,y,600,400);
0119   }
0120   
0121   cout << nHists1 << " " << nHists1+nHists2 << endl;
0122   for (int ic=0; ic<nHists2; ic++) {
0123     cout << ic << endl;
0124     c2[ic]->cd();
0125     sprintf(fname,oneDimLogPlots[ic]);  
0126     draw1D(10,fname,dname,c2[ic],f,runNum);
0127     c2[ic]->SetLogy(1);
0128     if (printPics) { sprintf(name,"%s/cosmicsAnalysis_%s_%s_%i.%s",dirName,fname,sname,runNumber,fileType); c2[ic]->Print(name); }  
0129   }
0130 
0131   // 1D Lin plots
0132 
0133   const int nHists3 = 13;
0134   char* oneDimPlots[nHists3] = {
0135      "NumXtalsInClusterAllHist",
0136      "NumActiveXtalsInClusterAllHist",
0137      "numberofBCinSC",
0138      "numberofCosmicsPerEvent",
0139      "NumXtalsVsHighEnergy",
0140      "timeForAllFeds",
0141      "timeForAllFeds_ECAL",
0142      "timeForAllFeds_HCAL",
0143      "timeForAllFeds_DT",
0144      "timeForAllFeds_RPC",
0145      "timeForAllFeds_CSC",
0146      "triggerHist",
0147      "triggerExclusiveHist" 
0148   };
0149 
0150   TCanvas* c3[nHists3];
0151 
0152   for (int i=0; i<nHists3; i++) {
0153     sprintf(cname,"c3_%i",i);
0154     int x = ((i)%3)*600;     //int x = (i%3)*600;
0155     int y = ((i)/3)*100;     //int y = (i/3)*200;
0156     c3[i] =  new TCanvas(cname,cname,x,y,600,400);
0157   }
0158   
0159   for (int ic=0; ic<nHists3; ic++) {
0160     cout << ic << endl;
0161     c3[ic]->cd();
0162     sprintf(fname,oneDimPlots[ic]);  
0163     draw1D(10,fname,dname,c3[ic],f,runNum);
0164     c3[ic]->SetLogy(0);
0165     if (printPics) { sprintf(name,"%s/cosmicsAnalysis_%s_%s_%i.%s",dirName,fname,sname,runNumber,fileType); c3[ic]->Print(name); }  
0166   }
0167 
0168 
0169   //2D
0170 
0171   const int nHists4 = 2;
0172   char* twoDimPlots[nHists4] = {
0173     "energyvsE1_AllClusters",
0174     "timeVsAmpAllEvents"
0175   };
0176 
0177   TCanvas* c4[nHists4];
0178 
0179   for (int i=0; i<nHists4; i++) {
0180     sprintf(cname,"c4_%i",i);
0181     int x = ((i)%3)*600;     //int x = (i%3)*600;
0182     int y = ((i)/3)*100;     //int y = (i/3)*200;
0183     c4[i] =  new TCanvas(cname,cname,x,y,600,400);
0184   }
0185   
0186   for (int ic=0; ic<nHists4; ic++) {
0187     cout << ic << endl;
0188     c4[ic]->cd();
0189     sprintf(fname,twoDimPlots[ic]);  
0190     draw2D(10,fname,dname,c4[ic],f,runNum);
0191     c4[ic]->SetLogy(0);
0192     c4[ic]->SetLogx(0);
0193     c4[ic]->SetLogz(1);
0194     if (printPics) { sprintf(name,"%s/cosmicsAnalysis_%s_%s_%i.%s",dirName,fname,sname,runNumber,fileType); c4[ic]->Print(name); }  
0195   }
0196 
0197 
0198   // 2D profile
0199 
0200   const int nHists5 = 2;
0201   char* twoDimProfilePlots[nHists5] = {
0202     "NumXtalsVsEnergy",
0203     "NumXtalsVsHighEnergy"
0204   };
0205 
0206   TCanvas* c5[nHists5];
0207 
0208   for (int i=0; i<nHists5; i++) {
0209     sprintf(cname,"c5_%i",i);
0210     int x = ((i)%3)*600;     //int x = (i%3)*600;
0211     int y = ((i)/3)*100;     //int y = (i/3)*200;
0212     c5[i] =  new TCanvas(cname,cname,x,y,600,400);
0213   }
0214   
0215   for (int ic=0; ic<nHists5; ic++) {
0216     cout << ic << endl;
0217     c5[ic]->cd();
0218     sprintf(fname,twoDimProfilePlots[ic]);  
0219     draw2DProfile(10,fname,dname,c5[ic],f,runNum);
0220     //    c5[ic]->SetLogy(1);
0221     if (printPics) { sprintf(name,"%s/cosmicsAnalysis_%s_%s_%i.%s",dirName,fname,sname,runNumber,fileType); c5[ic]->Print(name); }  
0222   }
0223 
0224 
0225   // TT binned
0226 
0227   const int nHists6 = 6;
0228   char* threeDimProjectionPlots[nHists6] = {
0229     "timeTTAllFEDs",
0230     "timeTTAllFEDs_ECAL",
0231     "timeTTAllFEDs_HCAL",
0232     "timeTTAllFEDs_DT",
0233     "timeTTAllFEDs_RPC",
0234     "timeTTAllFEDs_CSC"
0235   };
0236 
0237   TCanvas* c6[nHists6];
0238 
0239   for (int i=0; i<nHists6; i++) {
0240     sprintf(cname,"c6_%i",i);
0241     int x = (i%3)*500;     //int x = (i%3)*600;
0242     int y = (i/3)*100;     //int y = (i/3)*200;
0243     c6[i] =  new TCanvas(cname,cname,x,y,500,500);
0244   }
0245   
0246   for (int ic=0; ic<nHists6; ic++) {
0247     cout << ic << " " << fname << endl;
0248     c6[ic]->cd();
0249     sprintf(fname,threeDimProjectionPlots[ic]);  
0250     draw3DProjection(10,fname,dname,c6[ic],f,runNum);
0251     c6[ic]->SetLogy(0);
0252     c6[ic]->SetLogx(0);
0253     drawEELines();
0254     if (printPics) { sprintf(name,"%s/cosmicsAnalysis_%s_%s_%i.%s",dirName,fname,sname,runNumber,fileType); c6[ic]->Print(name); }  
0255   }
0256 
0257   return;
0258 }
0259 
0260 void draw1D(int ic, Char_t* fname, Char_t* dname, TCanvas* c, TFile* f, int runNumber) {
0261 
0262   c->cd();
0263   char runChar[50];  sprintf(runChar,", run %i",runNumber);
0264   char hname[200]; 
0265 
0266   gStyle->SetOptStat(111110);
0267   sprintf(hname,"%s/%s",dname,fname);  
0268   TH1F* h1 = (TH1F*)f->Get(hname);
0269   h1->Draw();
0270   char mytitle[100]; sprintf(mytitle,"%s",h1->GetTitle()); 
0271   strcat(mytitle,runChar); h1->SetTitle(mytitle);
0272   return;
0273 }
0274 
0275 void draw2D(int ic, Char_t* fname, Char_t* dname, TCanvas* c, TFile* f, int runNumber) {
0276   c->cd();
0277   char runChar[50];  sprintf(runChar,", run %i",runNumber);
0278   char hname[200]; 
0279   
0280   gStyle->SetOptStat(10);
0281   //  if (simpleStats) { gStyle->SetOptStat(10); }
0282   //  else { gStyle->SetOptStat(111110); }
0283   //  c->Update();
0284 
0285   sprintf(hname,"%s/%s",dname,fname);  
0286   TH2F* h2 = (TH2F*)f->Get(hname);
0287   h2->Draw("colz");
0288   h2->SetMinimum(1);
0289   char mytitle[100]; sprintf(mytitle,"%s",h2->GetTitle()); 
0290   strcat(mytitle,runChar); h2->SetTitle(mytitle);
0291   return;
0292 }
0293 
0294 void draw2DProfile(int ic, Char_t* fname, Char_t* dname, TCanvas* c, TFile* f, int runNumber) {
0295 
0296   c->cd();
0297   char runChar[50];  sprintf(runChar,", run %i",runNumber);
0298   char hname[200]; 
0299 
0300   gStyle->SetOptStat(10);
0301   sprintf(hname,"%s/%s",dname,fname);  
0302   TH2F* h2 = (TH2F*)f->Get(hname);
0303   h2->ProfileX()->Draw();
0304   char mytitle[100]; sprintf(mytitle,"%s",h2->GetTitle()); 
0305   strcat(mytitle,runChar); h2->SetTitle(mytitle);
0306   return;
0307 }
0308 
0309 
0310 void draw3DProjection(int ic, Char_t* fname, Char_t* dname, TCanvas* c, TFile* f, int runNumber) {
0311 
0312   gStyle->SetOptStat(10);
0313 
0314   c->cd();
0315   char runChar[50];  sprintf(runChar,", run %i",runNumber);
0316   char hname[200]; 
0317 
0318   gStyle->SetOptStat(10);
0319   sprintf(hname,"%s/%s",dname,fname);  
0320 
0321   TH3F* h3 = (TH3F*)f->Get(hname);
0322   TProfile2D* ayx = (TProfile2D*) h3->Project3DProfile("yx");
0323   //  h3->Draw();
0324   ayx->Draw("colz");
0325   ayx->GetXaxis()->SetTitle("ix");
0326   ayx->GetYaxis()->SetTitle("iy");
0327 
0328   char mytitle[100]; sprintf(mytitle,"%s",ayx->GetTitle()); 
0329   strcat(mytitle,runChar); ayx->SetTitle(mytitle);
0330   return;
0331 
0332 }
0333 
0334 void drawEELines() {
0335 
0336   int ixSectorsEE[202] = {61, 61, 60, 60, 59, 59, 58, 58, 57, 57, 55, 55, 45, 45, 43, 43, 42, 42, 41, 41, 40, 40, 39, 39, 40, 40, 41, 41, 42, 42, 43, 43, 45, 45, 55, 55, 57, 57, 58, 58, 59, 59, 60, 60, 61, 61, 0,100,100, 97, 97, 95, 95, 92, 92, 87, 87, 85, 85, 80, 80, 75, 75, 65, 65, 60, 60, 40, 40, 35, 35, 25, 25, 20, 20, 15, 15, 13, 13,  8,  8,  5,  5,  3,  3,  0,  0,  3,  3,  5,  5,  8,  8, 13, 13, 15, 15, 20, 20, 25, 25, 35, 35, 40, 40, 60, 60, 65, 65, 75, 75, 80, 80, 85, 85, 87, 87, 92, 92, 95, 95, 97, 97,100,100,  0, 61, 65, 65, 70, 70, 80, 80, 90, 90, 92,  0, 61, 65, 65, 90, 90, 97,  0, 57, 60, 60, 65, 65, 70, 70, 75, 75, 80, 80,  0, 50, 50,  0, 43, 40, 40, 35, 35, 30, 30, 25, 25, 20, 20,  0, 39, 35, 35, 10, 10,  3,  0, 39, 35, 35, 30, 30, 20, 20, 10, 10,  8,  0, 45, 45, 40, 40, 35, 35,  0, 55, 55, 60, 60, 65, 65};
0337  
0338   int iySectorsEE[202] = {50, 55, 55, 57, 57, 58, 58, 59, 59, 60, 60, 61, 61, 60, 60, 59, 59, 58, 58, 57, 57, 55, 55, 45, 45, 43, 43, 42, 42, 41, 41, 40, 40, 39, 39, 40, 40, 41, 41, 42, 42, 43, 43, 45, 45, 50,  0, 50, 60, 60, 65, 65, 75, 75, 80, 80, 85, 85, 87, 87, 92, 92, 95, 95, 97, 97,100,100, 97, 97, 95, 95, 92, 92, 87, 87, 85, 85, 80, 80, 75, 75, 65, 65, 60, 60, 40, 40, 35, 35, 25, 25, 20, 20, 15, 15, 13, 13,  8,  8,  5,  5,  3,  3,  0,  0,  3,  3,  5,  5,  8,  8, 13, 13, 15, 15, 20, 20, 25, 25, 35, 35, 40, 40, 50,  0, 45, 45, 40, 40, 35, 35, 30, 30, 25, 25,  0, 50, 50, 55, 55, 60, 60,  0, 60, 60, 65, 65, 70, 70, 75, 75, 85, 85, 87,  0, 61,100,  0, 60, 60, 65, 65, 70, 70, 75, 75, 85, 85, 87,  0, 50, 50, 55, 55, 60, 60,  0, 45, 45, 40, 40, 35, 35, 30, 30, 25, 25,  0, 39, 30, 30, 15, 15,  5,  0, 39, 30, 30, 15, 15,  5};
0339 
0340  TLine l;
0341  l.SetLineWidth(1);
0342  for ( int i=0; i<201; i=i+1) {
0343    if ( (ixSectorsEE[i]!=0 || iySectorsEE[i]!=0) && 
0344     (ixSectorsEE[i+1]!=0 || iySectorsEE[i+1]!=0) ) {
0345      l.DrawLine(ixSectorsEE[i], iySectorsEE[i], 
0346         ixSectorsEE[i+1], iySectorsEE[i+1]);
0347    }
0348  }
0349 
0350 
0351 }