AliPhysics  ced2227 (ced2227)
helperMacrosOADBBC.C
Go to the documentation of this file.
1 
30 
31 // --- ROOT system ---
32 #include <Riostream.h>
33 #include <TH2D.h>
34 #include <TFile.h>
35 #include <TCanvas.h>
36 #include <TLatex.h>
37 #include <TLegend.h>
38 #include <TStyle.h>
39 
40 // --- ANALYSIS system ---
41 #include "AliEMCALGeometry.h" //include when compile
42 #include "AliCalorimeterUtils.h" //include when compile
43 #include "AliAODEvent.h" //include when compile
44 #include "AliOADBContainer.h" //include when compile
45 #include "AliDataFile.h" //include when compile
46 
47 void SetHisto(TH1 *Histo,TString Xtitel,TString Ytitel);
48 void CanvasPartition(TCanvas *C,const Int_t Nx = 2,const Int_t Ny = 2, Float_t lMargin = 0.15, Float_t rMargin = 0.05, Float_t bMargin = 0.15, Float_t tMargin = 0.05);
49 
54 Bool_t Plot_BCMap(TString runList="", TString pathOADB ="")
55 {
56  gStyle->SetOptStat(0); //..Do not plot stat boxes
57  //......................................................
58  // Test if the file committed to OADB is correct
59  //......................................................
60  Int_t nSM = 20;
61  TH1C *h[20];
62  Int_t cellColumnAbs,cellRowAbs,trash,cellID;
63  TString summaryPDF=Form("./OADB_Summary.pdf");
64 
65  //......................................................
66  //..open the text file and save the run IDs into the RunId vector
67  cout<<" o Open .txt file with run indices. Name = " << runList << endl;
68  TString RunPath = Form("./%s",runList.Data());
69  FILE *pFile = fopen(RunPath.Data(), "r");
70  if(!pFile)
71  {
72  cout<<"couldn't open file "<<RunPath<<"!"<<endl;
73  return 0;
74  }
75  Int_t q;
76  Int_t ncols;
77  Int_t nlines = 0 ;
78  std::vector<Int_t> RunIdVec;
79  while (1)
80  {
81  ncols = fscanf(pFile," %d ",&q);
82  if (ncols< 0) break;
83  RunIdVec.push_back(q);
84  nlines++;
85  }
86  fclose(pFile);
87  //..sort the vector by size to be shure to use the right order
88  std::sort (RunIdVec.begin(), RunIdVec.end());
89  Int_t nRuns=RunIdVec.size();
90 
91  //......................................................
92  //..Get the OADB information
93  //$ALICE_DATA
94  cout<<" o Alice path: "<<pathOADB<<endl;
95  cout<<" o Alice path+: "<<pathOADB<<"/OADB/EMCAL/EMCALBadChannels.root"<<endl;
96  //pathOADB="."; //..locally from OADB commit/e-mail to test quickly
97 
98  AliOADBContainer *cont=new AliOADBContainer("");
99  if(pathOADB!="")
100  {
101  //..open the .root file directly to see if one can access it
102  TFile *fbad=new TFile(Form("%s/OADB/EMCAL/EMCALBadChannels.root",pathOADB.Data()),"read");
103  if (!fbad || fbad->IsZombie())
104  {
105  cout<<"couldn't find OADB container with help of pathOADB !"<<endl;
106  return 0;
107  }
108  else delete fbad;
109  cont->InitFromFile(Form("%s/OADB/EMCAL/EMCALBadChannels.root",pathOADB.Data()),"AliEMCALBadChannels");
110  }
111  else
112  {
113  //..open the .root file directly to see if one can access it
114  TFile *fbad=new TFile(AliDataFile::GetFileNameOADB("EMCAL/EMCALBadChannels.root").data(),"read");
115  if (!fbad || fbad->IsZombie())
116  {
117  cout<<"OADB/EMCAL/EMCALBadChannels.root was not found !"<<endl;
118  return 0;
119  }
120  else delete fbad;
121  cont->InitFromFile(AliDataFile::GetFileNameOADB("EMCAL/EMCALBadChannels.root").data(),"AliEMCALBadChannels");
122  }
123  //......................................................
124  //..Initialize EMCal/DCal geometry
125  AliCalorimeterUtils* fCaloUtils = new AliCalorimeterUtils();
126  //..Create a dummy event for the CaloUtils
127  AliAODEvent* aod = new AliAODEvent();
128  fCaloUtils->SetRunNumber(RunIdVec.at(0));
129  fCaloUtils->AccessGeometry(aod);
130  AliEMCALGeometry * geom = fCaloUtils->GetEMCALGeometry();
131  cout<<" o Geometry loaded for Run "<<RunIdVec.at(0)<<endl;
132 
133  //.......................................................
134  //..build two dimensional histogram with values row vs. column
135  //..with info from OADB
136  Int_t fNMaxCols = 48; //eta direction
137  Int_t fNMaxRows = 24; //phi direction
138 
139  Int_t fNMaxColsAbs = 2*fNMaxCols;
140  Int_t fNMaxRowsAbs = Int_t (nSM/2)*fNMaxRows; //multiply by number of supermodules
141  TString histoName;
142  histoName = Form("2DChannelMap_Flag_Bad");
143  TH2F *plot2D_Bad_OADB = new TH2F(histoName,histoName,fNMaxColsAbs+1,-0.5,fNMaxColsAbs+0.5, fNMaxRowsAbs+1,-0.5,fNMaxRowsAbs+0.5);
144  //*OADB figure that looks like Marcels figures*/ TH2F *plot2D_Bad_OADB = new TH2F(histoName,histoName,fNMaxColsAbs,0,fNMaxColsAbs, fNMaxRowsAbs,0,fNMaxRowsAbs);
145  plot2D_Bad_OADB->GetXaxis()->SetTitle("cell column (#eta direction)");
146  plot2D_Bad_OADB->GetYaxis()->SetTitle("cell row (#phi direction)");
147  histoName = Form("2DChannelMap_Flag_Dead");
148  TH2F *plot2D_Dead_OADB = new TH2F(histoName,histoName,fNMaxColsAbs+1,-0.5,fNMaxColsAbs+0.5, fNMaxRowsAbs+1,-0.5,fNMaxRowsAbs+0.5);
149  //*OADB figure that looks like Marcels figures*/ TH2F *plot2D_Dead_OADB = new TH2F(histoName,histoName,fNMaxColsAbs,0,fNMaxColsAbs, fNMaxRowsAbs,0,fNMaxRowsAbs);
150  plot2D_Dead_OADB->GetXaxis()->SetTitle("cell column (#eta direction)");
151  plot2D_Dead_OADB->GetYaxis()->SetTitle("cell row (#phi direction)");
152  histoName = Form("2DChannelMap_Flag_Good");
153  TH2F *plot2D_Good_OADB = new TH2F(histoName,histoName,fNMaxColsAbs+1,-0.5,fNMaxColsAbs+0.5, fNMaxRowsAbs+1,-0.5,fNMaxRowsAbs+0.5);
154  //*OADB figure that looks like Marcels figures*/ TH2F *plot2D_Good_OADB = new TH2F(histoName,histoName,fNMaxColsAbs,0,fNMaxColsAbs, fNMaxRowsAbs,0,fNMaxRowsAbs);
155  plot2D_Good_OADB->GetXaxis()->SetTitle("cell column (#eta direction)");
156  plot2D_Good_OADB->GetYaxis()->SetTitle("cell row (#phi direction)");
157 
158  //.......................................................
159  //.. Read the Bad Channel map from OADB
160  TCanvas* C2 = new TCanvas("CompareCanvas","Compare OADB to LocalFile",1400,500);
161  C2->Divide(3);
162 
163  cout<<" o Checking "<<nRuns<<" runs: "<<endl;
164  std::vector<Int_t> RunsWithoutMap;
165  std::vector<Int_t> RunsWithMap;
166  //Int_t dummyRun = 000276462;
167  Int_t dummyRun = 282367;
168  for(Int_t iRun = 0; iRun < nRuns; iRun++)
169  {
170  //cout<<"run number: "<<RunIdVec.at(iRun)<<endl;
171  if(iRun%5==0 && iRun!=0)cout<<"."<<flush;
172  if(iRun%20==0)cout<<" o Run No."<<RunIdVec.at(iRun)<<endl;
173  TObjArray *recal=(TObjArray*)cont->GetObject(RunIdVec.at(iRun));
174  if(!recal)
175  {
176  cout<<"Error - No bad map for run Number "<<RunIdVec.at(iRun)<<" online!!"<<endl;
177  cout<<"Check if you have the latest EOS version and/or check the BadChannelTwiki"<<endl;
178  RunsWithoutMap.push_back(RunIdVec.at(iRun));
179  continue;
180  }
181  RunsWithMap.push_back(RunIdVec.at(iRun));
182 
183  //..clear content from previous loop
184  plot2D_Bad_OADB ->Reset();
185  plot2D_Dead_OADB->Reset();
186  plot2D_Good_OADB->Reset();
187  for(Int_t iSM = 0; iSM < nSM; iSM++)
188  {
189  //..Bad map for each module
190  h[iSM]=(TH1C *)recal->FindObject(Form("EMCALBadChannelMap_Mod%d",iSM));
191  //..Loop though the SM to set which cells are bad
192  for(Int_t column=0;column<48;column++)
193  {
194  for(Int_t row=0;row<24;row++)
195  {
196  Int_t inRow=row;
197  Int_t inCol=column;
198  cellID=geom->GetAbsCellIdFromCellIndexes(iSM,inRow,inCol);
199  fCaloUtils->GetModuleNumberCellIndexesAbsCaloMap(cellID,0,inCol,inRow,trash,cellColumnAbs,cellRowAbs);
200  if(h[iSM]->GetBinContent(column,row)>1)//..bad and warm
201  {
202  plot2D_Bad_OADB->SetBinContent(cellColumnAbs,cellRowAbs,1);
203  }
204  if(h[iSM]->GetBinContent(column,row)==1)//..dead
205  {
206  plot2D_Dead_OADB->SetBinContent(cellColumnAbs,cellRowAbs,1);
207  }
208  if(h[iSM]->GetBinContent(column,row)==0)//..Good
209  {
210  plot2D_Good_OADB->SetBinContent(cellColumnAbs,cellRowAbs,1);
211  }
212  }
213  }
214  }
215  //..................................................................
216  TLatex* text=new TLatex(0.15,0.85,Form("Run Number %i",RunIdVec.at(iRun)));
217  text->SetTextSize(0.05);
218  text->SetNDC();
219  text->SetTextColor(1);
220  text->SetTextAngle(0);
221  C2->cd(1);
222  plot2D_Good_OADB->SetTitle("Good Cells OADB");
223  plot2D_Good_OADB->DrawCopy("colz");
224  text->Draw();
225  C2->cd(2);
226  plot2D_Dead_OADB->SetTitle("Dead Cells OADB");
227  plot2D_Dead_OADB->DrawCopy("colz");
228  C2->cd(3);
229  plot2D_Bad_OADB->SetTitle("Bad Cells OADB");
230  plot2D_Bad_OADB->DrawCopy("colz");
231 
232  //..................................................................
233  //..Save to PDF
234  //..Add figures to the summary canvas
235  if(iRun==0) C2 ->Print(Form("%s(",summaryPDF.Data()));
236  else if (iRun==nRuns-1) C2 ->Print(Form("%s)",summaryPDF.Data()));
237  else C2 ->Print(Form("%s",summaryPDF.Data()));
238  }//..end of run loop
239 
240  //..................................................................
241  //..Summarize how many bad maps were found
242  cout<<"==Total Summary=="<<endl;
243  //..print run numbers without a correct map.
244  cout<<"Runs with a bad map ("<<RunsWithMap.size()<<"): "<<flush;
245  for(Int_t i=0;i<(Int_t)RunsWithMap.size();i++)
246  {
247  cout<<RunsWithMap.at(i)<<","<<flush;
248  }
249  cout<<endl;
250  cout<<"Runs without a bad map ("<<RunsWithoutMap.size()<<"): "<<flush;
251  for(Int_t i=0;i<(Int_t)RunsWithoutMap.size();i++)
252  {
253  cout<<RunsWithoutMap.at(i)<<","<<flush;
254  }
255  cout<<endl;
256 
257  return 1;
258 }
259 
267 void Test_OADB(TString period="LHC15n",Int_t trainNo=603,TString version="INT7Emc",TString runList="")
268 {
269  gStyle->SetOptStat(0); //..Do not plot stat boxes
270  //......................................................
271  // Test if the file committed to OADB is correct
272  //......................................................
273  Int_t nSM = 20;
274  TH1C *h[20];
275  Int_t cellColumnAbs,cellRowAbs,trash,cellID;
276  TString summaryPDF=Form("./AnalysisOutput/%s/Train_%i/OADB_Summary.pdf",period.Data(),trainNo);
277 
278  //......................................................
279  //..open the text file and save the run IDs into the RunId vector
280  cout<<"o o o Open .txt file with run indices. Name = " << runList << endl;
281  TString RunPath = Form("./AnalysisInput/%s/Train_%i/%s",period.Data(),trainNo,runList.Data());
282  cout<<"o o o Open .txt file with run indices = " << RunPath << endl;
283  FILE *pFile = fopen(RunPath.Data(), "r");
284  if(!pFile)
285  {
286  cout<<"couldn't open file "<<RunPath<<"!"<<endl;
287  return;
288  }
289  Int_t q;
290  Int_t ncols;
291  Int_t nlines = 0 ;
292  std::vector<Int_t> RunIdVec;
293  while (1)
294  {
295  ncols = fscanf(pFile," %d ",&q);
296  if (ncols< 0) break;
297  RunIdVec.push_back(q);
298  nlines++;
299  }
300  fclose(pFile);
301  //..sort the vector by size to be shure to use the right order
302  std::sort (RunIdVec.begin(), RunIdVec.end());
303  Int_t nRuns=RunIdVec.size();
304  //......................................................
305  //..Get the OADB information
306  //TString fBasePath="/Users/Eliane/Software/alice/sw/osx_x86-64/AliPhysics/latest-ali-master/OADB/EMCAL"; //..from AliPhysics
307  TString fBasePath="."; //..locally from OADB commit/e-mail to test quickly
308 
309  AliOADBContainer *cont=new AliOADBContainer("");
310  cont->InitFromFile(Form("%s/EMCALBadChannels.root",fBasePath.Data()),"AliEMCALBadChannels");
311  //......................................................
312  //..Get the .root file with the original histogram to compare if they coincide
313  //TString path = Form("/Users/Eliane/Software/BadChannelAnalysis/AnalysisOutput/%s/Train_%i/VersionINT7Glob",period.Data(),trainNo);
314  //TString path = Form("/Users/Eliane/Software/BadChannelAnalysis/AnalysisOutput/%s/Train_%i/Version4ManMasked",period.Data(),trainNo);
315  TString path = Form("./AnalysisOutput/%s/Train_%i/Version%s",period.Data(),trainNo,version.Data());
316  TString rootFileName= Form("%s_INT7_Histograms_V%s.root",period.Data(),version.Data());
317  TFile* outputRoot = TFile::Open(Form("%s/%s",path.Data(),rootFileName.Data()));
318 
319  if(!outputRoot)cout<<"File "<<outputRoot->GetName()<<" does not exist"<<endl;
320  TH2F* h2DChannelMap_FlagBad =(TH2F*)outputRoot->Get("2DChannelMap_Flag2");
321  TH2F* h2DChannelMap_FlagDead=(TH2F*)outputRoot->Get("2DChannelMap_Flag1");
322 
323  //......................................................
324  //..Initialize EMCal/DCal geometry
325  AliCalorimeterUtils* fCaloUtils = new AliCalorimeterUtils();
326  //..Create a dummy event for the CaloUtils
327  AliAODEvent* aod = new AliAODEvent();
328  fCaloUtils->SetRunNumber(RunIdVec.at(0));
329  fCaloUtils->AccessGeometry(aod);
330  AliEMCALGeometry * geom = fCaloUtils->GetEMCALGeometry();
331 
332  //.......................................................
333  //..build two dimensional histogram with values row vs. column
334  //..with info from OADB
335  Int_t fNMaxCols = 48; //eta direction
336  Int_t fNMaxRows = 24; //phi direction
337 
338  Int_t fNMaxColsAbs = 2*fNMaxCols;
339  Int_t fNMaxRowsAbs = Int_t (nSM/2)*fNMaxRows; //multiply by number of supermodules
340  TString histoName;
341  histoName = Form("2DChannelMap_Flag_Bad");
342  TH2F *plot2D_Bad_OADB = new TH2F(histoName,histoName,fNMaxColsAbs+1,-0.5,fNMaxColsAbs+0.5, fNMaxRowsAbs+1,-0.5,fNMaxRowsAbs+0.5);
343  //*OADB looks like Marcels figures*/ TH2F *plot2D_Bad_OADB = new TH2F(histoName,histoName,fNMaxColsAbs,0,fNMaxColsAbs, fNMaxRowsAbs,0,fNMaxRowsAbs);
344  plot2D_Bad_OADB->GetXaxis()->SetTitle("cell column (#eta direction)");
345  plot2D_Bad_OADB->GetYaxis()->SetTitle("cell row (#phi direction)");
346  histoName = Form("2DChannelMap_Flag_Dead");
347  TH2F *plot2D_Dead_OADB = new TH2F(histoName,histoName,fNMaxColsAbs+1,-0.5,fNMaxColsAbs+0.5, fNMaxRowsAbs+1,-0.5,fNMaxRowsAbs+0.5);
348  //*OADB looks like Marcels figures*/ TH2F *plot2D_Dead_OADB = new TH2F(histoName,histoName,fNMaxColsAbs,0,fNMaxColsAbs, fNMaxRowsAbs,0,fNMaxRowsAbs);
349  plot2D_Dead_OADB->GetXaxis()->SetTitle("cell column (#eta direction)");
350  plot2D_Dead_OADB->GetYaxis()->SetTitle("cell row (#phi direction)");
351 
352  //.......................................................
353  //.. Read the Bad Channel map from OADB
354  TCanvas* C2 = new TCanvas("CompareCanvas","Compare OADB to LocalFile",1400,800);
355  C2->Divide(4,2);
356  TLatex* textA = new TLatex(0.5,0.8,"If empty -> good!");
357  textA->SetTextSize(0.04);
358  textA->SetTextColor(1);
359  textA->SetNDC();
360 
361  cout<<"Checking "<<nRuns<<" runs: "<<endl;
362  std::vector<Int_t> RunsWithoutMap;
363  std::vector<Int_t> RunsWithMap;
364 
365  for(Int_t iRun = 0; iRun < nRuns; iRun++)
366  {
367  //cout<<"------ run "<<RunIdVec.at(iRun)<<endl;
368  if(iRun%5==0)cout<<"."<<flush;
369  if(iRun%20==0)cout<<"Run No."<<iRun<<endl;
370  TObjArray *recal=(TObjArray*)cont->GetObject(RunIdVec.at(iRun));
371  if(!recal)
372  {
373  cout<<"Error - No bad map for run Number "<<RunIdVec.at(iRun)<<" online!!"<<endl;
374  RunsWithoutMap.push_back(RunIdVec.at(iRun));
375  continue;
376  }
377  RunsWithMap.push_back(RunIdVec.at(iRun));
378 
379  plot2D_Bad_OADB ->Reset();
380  plot2D_Dead_OADB->Reset();
381  for(Int_t iSM = 0; iSM < nSM; iSM++)
382  {
383  //..Bad map fore each module
384  h[iSM]=(TH1C *)recal->FindObject(Form("EMCALBadChannelMap_Mod%d",iSM));
385  //..Loop though the SM to set which cells are bad
386  for(Int_t column=0;column<48;column++)
387  {
388  for(Int_t row=0;row<24;row++)
389  {
390  Int_t inRow=row;
391  Int_t inCol=column;
392  cellID=geom->GetAbsCellIdFromCellIndexes(iSM,inRow,inCol);
393  fCaloUtils->GetModuleNumberCellIndexesAbsCaloMap(cellID,0,inCol,inRow,trash,cellColumnAbs,cellRowAbs);
394  if(h[iSM]->GetBinContent(column,row)>1)//..bad and warm
395  {
396  plot2D_Bad_OADB->SetBinContent(cellColumnAbs,cellRowAbs,1);
397  }
398  if(h[iSM]->GetBinContent(column,row)==1)//..dead
399  {
400  plot2D_Dead_OADB->SetBinContent(cellColumnAbs,cellRowAbs,1);
401  }
402  }
403  }
404  }
405  //..................................................................
406  TLatex* text=new TLatex(0.15,0.85,Form("Run Number %i",RunIdVec.at(iRun)));
407  text->SetTextSize(0.05);
408  text->SetNDC();
409  text->SetTextColor(1);
410  text->SetTextAngle(0);
411 
412 
413  C2->cd(1);
414  plot2D_Dead_OADB->SetTitle("Dead Cells OADB");
415  plot2D_Dead_OADB->DrawCopy("colz");
416  text->Draw();
417  C2->cd(5);
418  plot2D_Bad_OADB->SetTitle("Bad Cells OADB");
419  plot2D_Bad_OADB->DrawCopy("colz");
420  C2->cd(2);
421  h2DChannelMap_FlagDead->SetTitle("Dead Cells LocalFile");
422  h2DChannelMap_FlagDead->DrawCopy("colz");
423  C2->cd(6);
424  h2DChannelMap_FlagBad->SetTitle("Bad Cells LocalFile");
425  h2DChannelMap_FlagBad->DrawCopy("colz");
426 
427  //..................................................................
428  C2->cd(4);
429  plot2D_Dead_OADB->SetTitle("OADB-Local File (Dead)");
430  plot2D_Dead_OADB->Add(h2DChannelMap_FlagDead,-1);
431  plot2D_Dead_OADB->DrawCopy("colz");
432  plot2D_Dead_OADB->Add(h2DChannelMap_FlagDead,+1);
433  textA->Draw();
434  C2->cd(8);
435  plot2D_Bad_OADB->SetTitle("OADB-Local File (Bad)");
436  plot2D_Bad_OADB->Add(h2DChannelMap_FlagBad,-1);
437  plot2D_Bad_OADB->DrawCopy("colz");
438  plot2D_Bad_OADB->Add(h2DChannelMap_FlagBad,+1);
439  textA->Draw();
440  C2->cd(3);
441  plot2D_Dead_OADB->SetTitle("OADB/Local File (Dead)");
442  plot2D_Dead_OADB->Divide(h2DChannelMap_FlagDead);
443  plot2D_Dead_OADB->DrawCopy("colz");
444  C2->cd(7);
445  plot2D_Bad_OADB->SetTitle("OADB/Local File (Bad)");
446  plot2D_Bad_OADB->Divide(h2DChannelMap_FlagBad);
447  plot2D_Bad_OADB->DrawCopy("colz");
448 
449  //..................................................................
450  //..Save to PDF
451  //..Add figures to the summary canvas
452  if(iRun==0) C2 ->Print(Form("%s(",summaryPDF.Data()));
453  else if (iRun==nRuns-1) C2 ->Print(Form("%s)",summaryPDF.Data()));
454  else C2 ->Print(Form("%s",summaryPDF.Data()));
455  }//end of run loop
456  cout<<"==Total Summary=="<<endl;
457  //..print runs without a correct map.
458  cout<<"Runs with a bad map ("<<RunsWithMap.size()<<"): "<<flush;
459  for(Int_t i=0;i<(Int_t)RunsWithMap.size();i++)
460  {
461  cout<<RunsWithMap.at(i)<<","<<flush;
462  }
463  cout<<endl;
464  cout<<"Runs without a bad map ("<<RunsWithoutMap.size()<<"): "<<flush;
465  for(Int_t i=0;i<(Int_t)RunsWithoutMap.size();i++)
466  {
467  cout<<RunsWithoutMap.at(i)<<","<<flush;
468  }
469  cout<<endl;
470 }
477 void Plot_CellList(TString period="LHC15n",Int_t trainNo=603,TString cellList="")
478 {
479  gStyle->SetPadTopMargin(0.05);//0.05
480  gStyle->SetPadBottomMargin(0.18);//0.15
481  gStyle->SetPadRightMargin(0.05);
482  gStyle->SetPadLeftMargin(0.17);
483  gStyle->SetFrameFillColor(10);
484 
485 
486  //......................................................
487  //..Settings
488  const Int_t nBlocks=1; //..number of different runblocks of the period
489 
490  Int_t zoomRange=20;
491  Double_t range=5; //10 GeV
492  Double_t tRange1=-200;
493  Double_t tRange2=400;
494  //..uncalibrated:
495  //tRange1 =400;
496  //tRange2 =900;
497  Int_t shift=0;
498 
499  //......................................................
500  //..open the text file and save the run IDs into the RunId vector
501  TString ListName = Form("./AnalysisOutput/%s/Train_%i/%s",period.Data(),trainNo,cellList.Data());
502  cout<<"o o o Open .txt suggested cell IDs. Name = " << ListName << endl;
503  FILE *pFile = fopen(ListName.Data(), "r");
504  if(!pFile)
505  {
506  cout<<"couldn't open file "<<ListName<<"!"<<endl;
507  return;
508  }
509  Int_t q;
510  Int_t ncols;
511  Int_t nlines = 0 ;
512  Int_t cellId[500] ;
513  std::vector<Int_t> cellIdVec;
514  while (1)
515  {
516  ncols = fscanf(pFile," %d ",&q);
517  if (ncols< 0) break;
518  cellId[nlines]=q;
519  cellIdVec.push_back(q);
520  nlines++;
521  }
522  fclose(pFile);
523  //..sort the vector by size to be shure to use the right order
524  std::sort (cellIdVec.begin(), cellIdVec.end());
525  Int_t nCells=cellIdVec.size();
526 
527  //......................................................
528  //..Get the .root file with the original histogram to compare if they coincide
529  TString path = Form("./AnalysisOutput/%s/Train_%i",period.Data(),trainNo);
530  TString rootFileName[nBlocks];
531  TFile* outputRoot[nBlocks];
532  TH2F* h2DAmp[nBlocks];
533  TH2F* h2DRatio[nBlocks];
534  TH2F* h2DCellTime[nBlocks];
535  //TString rootFileName= Form("Version%s/%s_INT7_Histograms_V%s.root",period.Data(),version.Data());
536  for(Int_t iBlock=0;iBlock<nBlocks;iBlock++)
537  {
538  //..mostly set by hand
539  //..15l
540  /*
541  if(iBlock==0)rootFileName[iBlock]= Form("Version1OADB/%s_INT7_Histograms_V1.root",period.Data());
542  if(iBlock==1)rootFileName[iBlock]= Form("Version2OADB/%s_INT7_Histograms_V2.root",period.Data());
543  if(iBlock==2)rootFileName[iBlock]= Form("Version3OADB/%s_INT7_Histograms_V3.root",period.Data());
544  if(iBlock==3)rootFileName[iBlock]= Form("Version4OADB/%s_INT7_Histograms_V4.root",period.Data());
545  */
546  //..15o
547  /*if(iBlock==0)rootFileName[iBlock]= Form("Version1ManMasked/%s_INT7_Histograms_V1.root",period.Data());
548  if(iBlock==1)rootFileName[iBlock]= Form("Version2ManMasked/%s_INT7_Histograms_V2.root",period.Data());
549  if(iBlock==2)rootFileName[iBlock]= Form("Version3ManMasked/%s_INT7_Histograms_V3.root",period.Data());
550  if(iBlock==3)rootFileName[iBlock]= Form("Version4ManMasked/%s_INT7_Histograms_V4.root",period.Data());
551  */
552  /*
553  //..16s
554  if(iBlock==0)rootFileName[iBlock]= Form("Version1OADB/%s_INT7_Histograms_V1.root",period.Data());
555  if(iBlock==1)rootFileName[iBlock]= Form("Version2OADB/%s_INT7_Histograms_V2.root",period.Data());
556  if(iBlock==2)rootFileName[iBlock]= Form("Version4OADB/%s_INT7_Histograms_V4.root",period.Data());
557  */
558  //..16k
559  if(iBlock==0)rootFileName[iBlock]= Form("Version0/%s_INT7_Histograms_V0.root",period.Data());
560 
561  outputRoot[iBlock] = TFile::Open(Form("%s/%s",path.Data(),rootFileName[iBlock].Data()));
562  if(!outputRoot[iBlock])cout<<"File "<<outputRoot[iBlock]->GetName()<<" does not exist"<<endl;
563  h2DAmp[iBlock] =(TH2F*)outputRoot[iBlock]->Get("hCellAmplitude");
564  h2DRatio[iBlock] =(TH2F*)outputRoot[iBlock]->Get("ratio2DAmp");
565  h2DCellTime[iBlock]=(TH2F*)outputRoot[iBlock]->Get("hCellTime");
566  }
567 
568  TCanvas *c1 = new TCanvas(1);
569  c1->Divide(2);
570  c1->cd(1);
571  SetHisto(h2DAmp[0],"","");
572  h2DAmp[0]->Draw("colz");
573  c1->cd(2);
574  SetHisto(h2DRatio[0],"","");
575  h2DRatio[0]->Draw("colz");
576 
577  //.. be aware of the special sturcture of the canvas
578  //.. canvas has totalperCv*2 pads
579 // Int_t totalperCv = 4;
580  Int_t totalperCv = 8;
581  Int_t nPad = TMath::Sqrt(totalperCv);
582  Int_t nCv = nCells/totalperCv+1;
583  if(nCv<1)nCv=1;
584 
585  cout<<" o create: "<<nCv<<" Canvases with "<<nPad*nPad<<" pads"<<endl;
586  //..to compare specific cells over the runs
587  TCanvas **cCompAll = new TCanvas*[nCv];
588  TCanvas **cCompTimeAll = new TCanvas*[nCv];
589  for(Int_t i=0;i<nCv;i++)
590  {
591  cCompAll[i] = new TCanvas(TString::Format("CompareGoodAll%d", i), TString::Format("V) Both (%d/%d)", i+1, nCv), 1000,750);
592  CanvasPartition(cCompAll[i],4,totalperCv/2,0.15,0.02,0.13,0.05);
593  cCompTimeAll[i] = new TCanvas(TString::Format("CompareGoodTimeAll%d", i), TString::Format("V) Time (%d/%d)", i+1, nCv), 1000,750);
594  cCompTimeAll[i]->Divide(4,4,0.001,0.001);
595  //CanvasPartition(cCompTimeAll[i],4,totalperCv/2,0.15,0.02,0.13,0.05);
596  }
597  TLegend *leg2 = new TLegend(0.60,0.60,0.9,0.85);
598  cout<<" o Fill Canvases with bad cells histograms"<<endl;
599 
600  TH1D *htmpCellAllRuns[nBlocks];
601  TH1D *htmpCellTimeRuns[nBlocks];
602  TH1D *htmpCellRatioAllRuns[nBlocks];
603  cout<<"cell number: "<<endl;
604  for(Int_t icell = 0; icell < nCells; icell++)
605  {
606  Int_t cellID=cellIdVec.at(icell);
607  cout<<cellID<<", "<<flush;
608 
609  for(Int_t iBlock=0;iBlock<nBlocks;iBlock++)
610  {
611  htmpCellAllRuns[iBlock] =h2DAmp[iBlock] ->ProjectionX(TString::Format("hIDProj%i_cell%d",iBlock, cellID), cellID+1, cellID+1);
612  SetHisto(htmpCellAllRuns[iBlock],Form("Energy [cell %i]",cellID),"Number of Hits/Events");
613  htmpCellRatioAllRuns[iBlock] =h2DRatio[iBlock]->ProjectionX(TString::Format("hIDRProj%i_cell%d", iBlock, cellID), cellID+1, cellID+1);
614  SetHisto(htmpCellRatioAllRuns[iBlock],Form("Energy [cell %i]",cellID),"No. Hits/av. No. Hits");
615 
616  htmpCellTimeRuns[iBlock] =h2DCellTime[iBlock]->ProjectionX(TString::Format("hIDTimeProj%i_cell%d", iBlock, cellID), cellID+1, cellID+1);
617  SetHisto(htmpCellTimeRuns[iBlock],Form("Time, ns [cell %i]",cellID),"Entries/Events");
618 
619  if(((icell)%8)<4) shift=0;
620  else shift=8;
621  //..Amplitude
622  cCompAll[(icell)/totalperCv]->cd(((icell)%4)+1+shift)->SetLogy();
623  if(iBlock==0)htmpCellAllRuns[iBlock]->GetXaxis()->SetRangeUser(0,range);
624  if(iBlock==0)htmpCellAllRuns[iBlock]->Draw("hist");
625  if(iBlock==1)htmpCellAllRuns[iBlock]->SetLineColor(kBlue-7);
626  if(iBlock==2)htmpCellAllRuns[iBlock]->SetLineColor(kGreen-2);
627  if(iBlock==3)htmpCellAllRuns[iBlock]->SetLineColor(kViolet-1);
628  if(iBlock>0)htmpCellAllRuns[iBlock]->DrawCopy("same hist");
629 
630  if(icell==0)
631  {
632  leg2->AddEntry(htmpCellAllRuns[iBlock],Form("Block%i",iBlock),"l");
633  leg2->SetTextSize(0.07);
634  leg2->SetBorderSize(0);
635  leg2->SetFillColorAlpha(10, 0);
636  leg2->Draw("same");
637  }
638  else if((icell)%4==0)
639  {
640  leg2->Draw("same");
641  }
642 
643  //..Ratio
644  cCompAll[(icell)/totalperCv]->cd(((icell)%4)+5+shift)->SetLogy();
645  if(iBlock==0)htmpCellRatioAllRuns[iBlock]->GetXaxis()->SetRangeUser(0,range);
646  if(iBlock==0)htmpCellRatioAllRuns[iBlock]->Draw("hist");
647  if(iBlock==1)htmpCellRatioAllRuns[iBlock]->SetLineColor(kBlue-7);
648  if(iBlock==2)htmpCellRatioAllRuns[iBlock]->SetLineColor(kGreen-2);
649  if(iBlock==3)htmpCellRatioAllRuns[iBlock]->SetLineColor(kViolet-1);
650  if(iBlock>0)htmpCellRatioAllRuns[iBlock]->DrawCopy("same hist");
651 
652  //..Time
653  cCompTimeAll[(icell)/totalperCv]->cd(((icell)%4)+1+shift)->SetLogy();
654  if(iBlock==0)htmpCellTimeRuns[iBlock]->GetXaxis()->SetRangeUser(tRange1,tRange2);
655  if(iBlock==0)htmpCellTimeRuns[iBlock]->Draw("hist");
656  if(iBlock==1)htmpCellTimeRuns[iBlock]->SetLineColor(kBlue-7);
657  if(iBlock==2)htmpCellTimeRuns[iBlock]->SetLineColor(kGreen-2);
658  if(iBlock==3)htmpCellTimeRuns[iBlock]->SetLineColor(kViolet-1);
659  if(iBlock>0)htmpCellTimeRuns[iBlock]->DrawCopy("same hist");
660  }
661  }
662  cout<<endl;
663 // TString pdfName= Form("%s_MoreBadCellsCandidates.pdf",period.Data());
664  TString pdfName= Form("./AnalysisOutput/%s/Train_%i/%s_MoreBadCellsCandidates.pdf",period.Data(),trainNo,period.Data());
665  //..plot the canvases of cells into a .pdf file
666  for(Int_t can=0;can<nCv;can++)
667  {
668  //TString internal_pdfName1=pdfName+"Low.pdf";
669  if(can==0)
670  {
671  //..first pad
672  if(nCv>1)
673  {
674  cCompAll[can] ->Print(Form("%s(",pdfName.Data()));
675  cCompTimeAll[can]->Print(Form("%s",pdfName.Data()));
676  }
677  else
678  {
679  cCompAll[can] ->Print(Form("%s(",pdfName.Data()));
680  cCompTimeAll[can]->Print(Form("%s)",pdfName.Data()));
681  }
682  }
683  else if(can==(nCv-1))//..last canvas
684  {
685  //..last pad
686  cCompAll[can] ->Print(Form("%s",pdfName.Data()));
687  cCompTimeAll[can]->Print(Form("%s)",pdfName.Data()));
688  }
689  else
690  {
691  //..all pads in between
692  cCompAll[can] ->Print(Form("%s",pdfName.Data()));
693  cCompTimeAll[can] ->Print(Form("%s",pdfName.Data()));
694  }
695  }
696 }
700 //________________________________________________________________________
701 void SetHisto(TH1 *Histo,TString Xtitel,TString Ytitel)
702 {
703  Histo->SetStats(0);
704  Histo->SetTitle("");
705 
706  Histo->GetYaxis()->SetTitleOffset(1.1);
707  Histo->GetXaxis()->SetTitleOffset(1.1);
708  Histo->GetXaxis()->SetLabelSize(0.05);
709  Histo->GetYaxis()->SetLabelSize(0.05);
710  Histo->GetXaxis()->SetTitleSize(0.06);
711  Histo->GetYaxis()->SetTitleSize(0.06);
712  Histo->GetXaxis()->SetNdivisions(505);
713  Histo->GetYaxis()->SetNdivisions(505);
714 
715  Histo->GetXaxis()->SetLabelFont(42);
716  Histo->GetYaxis()->SetLabelFont(42);
717  Histo->GetXaxis()->SetTitleFont(42);
718  Histo->GetYaxis()->SetTitleFont(42);
719  if(Xtitel!="")Histo->GetXaxis()->SetTitle(Xtitel);
720  if(Ytitel!="")Histo->GetYaxis()->SetTitle(Ytitel);
721 
722  Histo->SetLineColor(1);
723  Histo->SetMarkerColor(1);
724  Histo->SetMarkerStyle(20);
725  Histo->SetMarkerSize(0.5);
726 }
730 //___________________________________________
731 void CanvasPartition(TCanvas *C,const Int_t Nx,const Int_t Ny,
732  Float_t lMargin, Float_t rMargin,
733  Float_t bMargin, Float_t tMargin)
734 {
735  if (!C) return;
736 
737  C->Divide(Nx,Ny,0.000,0.000);
738  //..Top row
739  for (Int_t i=0;i<Nx;i++)
740  {
741  C->cd(i+1)->SetLogy();
742  gPad->SetLeftMargin(lMargin);
743  gPad->SetRightMargin(rMargin);
744  gPad->SetBottomMargin(0);
745  gPad->SetTopMargin(tMargin);
746  //pad->Draw();??
747  }
748  //..Bottom row
749  for (Int_t i=0;i<Nx;i++)
750  {
751  C->cd(i+1+Nx);
752  gPad->SetLeftMargin(lMargin);
753  gPad->SetRightMargin(rMargin);
754  gPad->SetBottomMargin(bMargin);
755  gPad->SetTopMargin(0);
756  }
757  //..Top row
758  for (Int_t i=0;i<Nx;i++)
759  {
760  C->cd(i+1+2*Nx)->SetLogy();
761  gPad->SetLeftMargin(lMargin);
762  gPad->SetRightMargin(rMargin);
763  gPad->SetBottomMargin(0);
764  gPad->SetTopMargin(tMargin);
765  }
766  //..Bottom row
767  for (Int_t i=0;i<Nx;i++)
768  {
769  C->cd(i+1+3*Nx);
770  gPad->SetLeftMargin(lMargin);
771  gPad->SetRightMargin(rMargin);
772  gPad->SetBottomMargin(bMargin);
773  gPad->SetTopMargin(0);
774  }
775 }
double Double_t
Definition: External.C:58
void SetRunNumber(Int_t run)
Definition: External.C:236
TLatex * text[5]
option to what and if export to output file
void CanvasPartition(TCanvas *C, const Int_t Nx=2, const Int_t Ny=2, Float_t lMargin=0.15, Float_t rMargin=0.05, Float_t bMargin=0.15, Float_t tMargin=0.05)
void Test_OADB(TString period="LHC15n", Int_t trainNo=603, TString version="INT7Emc", TString runList="")
Bool_t Plot_BCMap(TString runList="", TString pathOADB="")
AliEMCALGeometry * GetEMCALGeometry() const
void SetHisto(TH1 *Histo, TString Xtitel, TString Ytitel)
int Int_t
Definition: External.C:63
float Float_t
Definition: External.C:68
Definition: External.C:212
const char * pdfName
Definition: DrawAnaELoss.C:30
void Plot_CellList(TString period="LHC15n", Int_t trainNo=603, TString cellList="")
bool Bool_t
Definition: External.C:53
Class with utils specific to calorimeter clusters/cells.
void AccessGeometry(AliVEvent *inputEvent)
Definition: External.C:196
Int_t GetModuleNumberCellIndexesAbsCaloMap(Int_t absId, Int_t calo, Int_t &icol, Int_t &irow, Int_t &iRCU, Int_t &icolAbs, Int_t &irowAbs) const