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