AliPhysics  59e0e03 (59e0e03)
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,tRange2;
493  //tRange1=-200;
494  //tRange2=400;
495  //..uncalibrated:
496  tRange1 =400;
497  tRange2 =900;
498  Int_t shift=0;
499 
500  //......................................................
501  //..open the text file and save the run IDs into the RunId vector
502  TString ListName = Form("./AnalysisOutput/%s/Train_%i/%s",period.Data(),trainNo,cellList.Data());
503  cout<<"o o o Open .txt suggested cell IDs. Name = " << ListName << endl;
504  FILE *pFile = fopen(ListName.Data(), "r");
505  if(!pFile)
506  {
507  cout<<"couldn't open file "<<ListName<<"!"<<endl;
508  return;
509  }
510  Int_t q;
511  Int_t ncols;
512  Int_t nlines = 0 ;
513  Int_t cellId[500] ;
514  std::vector<Int_t> cellIdVec;
515  while (1)
516  {
517  ncols = fscanf(pFile," %d ",&q);
518  if (ncols< 0) break;
519  cellId[nlines]=q;
520  cellIdVec.push_back(q);
521  nlines++;
522  }
523  fclose(pFile);
524  //..sort the vector by size to be shure to use the right order
525  std::sort (cellIdVec.begin(), cellIdVec.end());
526  Int_t nCells=cellIdVec.size();
527  cout<<"o found "<<cellIdVec.size()<<" cells in list"<<endl;
528  //......................................................
529  //..Get the .root file with the original histogram to compare if they coincide
530  TString path = Form("./AnalysisOutput/%s/Train_%i",period.Data(),trainNo);
531  TString rootFileName[nBlocks];
532  TFile* outputRoot[nBlocks];
533  TH2F* h2DAmp[nBlocks];
534  TH2F* h2DRatio[nBlocks];
535  TH2F* h2DCellTime[nBlocks];
536  //TString rootFileName= Form("Version%s/%s_INT7_Histograms_V%s.root",period.Data(),version.Data());
537  for(Int_t iBlock=0;iBlock<nBlocks;iBlock++)
538  {
539  //..mostly set by hand
540  //..15l
541  /*
542  if(iBlock==0)rootFileName[iBlock]= Form("Version1OADB/%s_INT7_Histograms_V1.root",period.Data());
543  if(iBlock==1)rootFileName[iBlock]= Form("Version2OADB/%s_INT7_Histograms_V2.root",period.Data());
544  if(iBlock==2)rootFileName[iBlock]= Form("Version3OADB/%s_INT7_Histograms_V3.root",period.Data());
545  if(iBlock==3)rootFileName[iBlock]= Form("Version4OADB/%s_INT7_Histograms_V4.root",period.Data());
546  */
547  //..15o
548  /*if(iBlock==0)rootFileName[iBlock]= Form("Version1ManMasked/%s_INT7_Histograms_V1.root",period.Data());
549  if(iBlock==1)rootFileName[iBlock]= Form("Version2ManMasked/%s_INT7_Histograms_V2.root",period.Data());
550  if(iBlock==2)rootFileName[iBlock]= Form("Version3ManMasked/%s_INT7_Histograms_V3.root",period.Data());
551  if(iBlock==3)rootFileName[iBlock]= Form("Version4ManMasked/%s_INT7_Histograms_V4.root",period.Data());
552  */
553  /*
554  //..16s
555  if(iBlock==0)rootFileName[iBlock]= Form("Version1OADB/%s_INT7_Histograms_V1.root",period.Data());
556  if(iBlock==1)rootFileName[iBlock]= Form("Version2OADB/%s_INT7_Histograms_V2.root",period.Data());
557  if(iBlock==2)rootFileName[iBlock]= Form("Version4OADB/%s_INT7_Histograms_V4.root",period.Data());
558  */
559  //..16k
560  //if(iBlock==0)rootFileName[iBlock]= Form("Version0/%s_INT7_Histograms_V0.root",period.Data());
561  //..17n
562  if(iBlock==0)rootFileName[iBlock]= Form("Version1OADB/%s_INT7_Histograms_V1.root",period.Data());
563 
564  outputRoot[iBlock] = TFile::Open(Form("%s/%s",path.Data(),rootFileName[iBlock].Data()));
565  if(!outputRoot[iBlock])cout<<"File "<<outputRoot[iBlock]->GetName()<<" does not exist"<<endl;
566  h2DAmp[iBlock] =(TH2F*)outputRoot[iBlock]->Get("hCellAmplitude");
567  h2DRatio[iBlock] =(TH2F*)outputRoot[iBlock]->Get("ratio2DAmp");
568  h2DCellTime[iBlock]=(TH2F*)outputRoot[iBlock]->Get("hCellTime");
569  }
570 
571  TCanvas *c1 = new TCanvas(1);
572  c1->Divide(2);
573  c1->cd(1);
574  SetHisto(h2DAmp[0],"","");
575  h2DAmp[0]->Draw("colz");
576  c1->cd(2);
577  SetHisto(h2DRatio[0],"","");
578  h2DRatio[0]->Draw("colz");
579 
580  //.. be aware of the special sturcture of the canvas
581  //.. canvas has totalperCv*2 pads
582  Int_t totalperCv = 5;
583 // Int_t totalperCv = 8;
584  Int_t nPad = TMath::Sqrt(totalperCv);
585  Int_t nCv = nCells/totalperCv+1;
586  if(nCv<1)nCv=1;
587 
588  cout<<" o create: "<<nCv<<" Canvases with "<<nPad*nPad<<" pads"<<endl;
589  //..to compare specific cells over the runs
590  TCanvas **cCompAll = new TCanvas*[nCv];
591  for(Int_t i=0;i<nCv;i++)
592  {
593  cCompAll[i] = new TCanvas(TString::Format("CompareGoodAll%d", i), TString::Format("V) Both (%d/%d)", i+1, nCv), 1200,600);
594 // CanvasPartition(cCompAll[i],4,totalperCv/2,0.15,0.02,0.13,0.05);
595  CanvasPartition(cCompAll[i],5,3,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  //..Amplitude
620  cCompAll[(icell)/totalperCv]->cd(((icell)%5)+1)->SetLogy();
621  if(iBlock==0)htmpCellAllRuns[iBlock]->GetXaxis()->SetRangeUser(0,range);
622  if(iBlock==0)htmpCellAllRuns[iBlock]->Draw("hist");
623  if(iBlock==1)htmpCellAllRuns[iBlock]->SetLineColor(kBlue-7);
624  if(iBlock==2)htmpCellAllRuns[iBlock]->SetLineColor(kGreen-2);
625  if(iBlock==3)htmpCellAllRuns[iBlock]->SetLineColor(kViolet-1);
626  if(iBlock>0)htmpCellAllRuns[iBlock]->DrawCopy("same hist");
627 
628  if(icell==0)
629  {
630  leg2->AddEntry(htmpCellAllRuns[iBlock],Form("Block%i",iBlock),"l");
631  leg2->SetTextSize(0.07);
632  leg2->SetBorderSize(0);
633  leg2->SetFillColorAlpha(10, 0);
634  leg2->Draw("same");
635  }
636  else if((icell)%5==0)
637  {
638  leg2->Draw("same");
639  }
640 
641  //..Ratio
642  cCompAll[(icell)/totalperCv]->cd(((icell)%5)+6)->SetLogy();
643  if(iBlock==0)htmpCellRatioAllRuns[iBlock]->GetXaxis()->SetRangeUser(0,range);
644  if(iBlock==0)htmpCellRatioAllRuns[iBlock]->Draw("hist");
645  if(iBlock==1)htmpCellRatioAllRuns[iBlock]->SetLineColor(kBlue-7);
646  if(iBlock==2)htmpCellRatioAllRuns[iBlock]->SetLineColor(kGreen-2);
647  if(iBlock==3)htmpCellRatioAllRuns[iBlock]->SetLineColor(kViolet-1);
648  if(iBlock>0)htmpCellRatioAllRuns[iBlock]->DrawCopy("same hist");
649 
650  //..Time
651  cCompAll[(icell)/totalperCv]->cd(((icell)%5)+11)->SetLogy();
652  if(iBlock==0)htmpCellTimeRuns[iBlock]->GetXaxis()->SetRangeUser(tRange1,tRange2);
653  if(iBlock==0)htmpCellTimeRuns[iBlock]->Draw("hist");
654  if(iBlock==1)htmpCellTimeRuns[iBlock]->SetLineColor(kBlue-7);
655  if(iBlock==2)htmpCellTimeRuns[iBlock]->SetLineColor(kGreen-2);
656  if(iBlock==3)htmpCellTimeRuns[iBlock]->SetLineColor(kViolet-1);
657  if(iBlock>0)htmpCellTimeRuns[iBlock]->DrawCopy("same hist");
658  }
659  }
660  cout<<endl;
661 // TString pdfName= Form("%s_MoreBadCellsCandidates.pdf",period.Data());
662  TString pdfName= Form("./AnalysisOutput/%s/Train_%i/%s_MoreBadCellsCandidates.pdf",period.Data(),trainNo,period.Data());
663  //..plot the canvases of cells into a .pdf file
664  for(Int_t can=0;can<nCv;can++)
665  {
666  //TString internal_pdfName1=pdfName+"Low.pdf";
667  if(can==0)
668  {
669  //..first pad
670  if(nCv>1)
671  {
672  cCompAll[can] ->Print(Form("%s(",pdfName.Data()));
673  }
674  else
675  {
676  cCompAll[can] ->Print(Form("%s",pdfName.Data()));
677  }
678  }
679  else if(can==(nCv-1))//..last canvas
680  {
681  //..last pad
682  cCompAll[can] ->Print(Form("%s)",pdfName.Data()));
683  }
684  else
685  {
686  //..all pads in between
687  cCompAll[can] ->Print(Form("%s",pdfName.Data()));
688  }
689  }
690 }
694 //________________________________________________________________________
695 void SetHisto(TH1 *Histo,TString Xtitel,TString Ytitel)
696 {
697  Histo->SetStats(0);
698  Histo->SetTitle("");
699 
700  Histo->GetYaxis()->SetTitleOffset(1.1);
701  Histo->GetXaxis()->SetTitleOffset(1.1);
702  Histo->GetXaxis()->SetLabelSize(0.05);
703  Histo->GetYaxis()->SetLabelSize(0.05);
704  Histo->GetXaxis()->SetTitleSize(0.06);
705  Histo->GetYaxis()->SetTitleSize(0.06);
706  Histo->GetXaxis()->SetNdivisions(505);
707  Histo->GetYaxis()->SetNdivisions(505);
708 
709  Histo->GetXaxis()->SetLabelFont(42);
710  Histo->GetYaxis()->SetLabelFont(42);
711  Histo->GetXaxis()->SetTitleFont(42);
712  Histo->GetYaxis()->SetTitleFont(42);
713  if(Xtitel!="")Histo->GetXaxis()->SetTitle(Xtitel);
714  if(Ytitel!="")Histo->GetYaxis()->SetTitle(Ytitel);
715 
716  Histo->SetLineColor(1);
717  Histo->SetMarkerColor(1);
718  Histo->SetMarkerStyle(20);
719  Histo->SetMarkerSize(0.5);
720 }
724 //___________________________________________
725 void CanvasPartition(TCanvas *C,const Int_t Nx,const Int_t Ny,
726  Float_t lMargin, Float_t rMargin,
727  Float_t bMargin, Float_t tMargin)
728 {
729  if (!C) return;
730 
731  C->Divide(Nx,Ny,0.000,0.000);
732  //..Top row
733  for (Int_t i=0;i<Nx;i++)
734  {
735  C->cd(i+1)->SetLogy();
736  gPad->SetLeftMargin(lMargin);
737  gPad->SetRightMargin(rMargin);
738  gPad->SetBottomMargin(0);
739  gPad->SetTopMargin(tMargin);
740  //pad->Draw();??
741  }
742  //..Bottom row
743  for (Int_t i=0;i<Nx;i++)
744  {
745  C->cd(i+1+Nx);
746  gPad->SetLeftMargin(lMargin);
747  gPad->SetRightMargin(rMargin);
748  gPad->SetBottomMargin(bMargin);
749  gPad->SetTopMargin(0);
750  }
751  //..Top row
752  for (Int_t i=0;i<Nx;i++)
753  {
754  C->cd(i+1+2*Nx)->SetLogy();
755  gPad->SetLeftMargin(lMargin);
756  gPad->SetRightMargin(rMargin);
757  //gPad->SetBottomMargin(0);
758  gPad->SetBottomMargin(bMargin);
759  gPad->SetTopMargin(tMargin);
760  }
761  /*
762 
763  //..Bottom row
764  for (Int_t i=0;i<Nx;i++)
765  {
766  C->cd(i+1+3*Nx);
767  gPad->SetLeftMargin(lMargin);
768  gPad->SetRightMargin(rMargin);
769  gPad->SetBottomMargin(bMargin);
770  gPad->SetTopMargin(0);
771  }
772 */
773 }
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