22 #include <Riostream.h> 32 #include "AliEMCALGeometry.h" 34 #include "AliAODEvent.h" 41 void Plot2DCells(
TString Block,
Int_t runNo, std::vector<Int_t> cellVectorMergeB, std::vector<Int_t> cellVectorMergeA);
52 cout<<
"o o o Open .txt file with run indices. Name = " << runList1 << endl;
53 TString RunPath1 = Form(
"./AnalysisInput/%s/Train_%i/%s",period.Data(),trainNo,runList1.Data());
54 cout<<
"o o o Open .txt file with run indices = " << RunPath1 << endl;
55 FILE *pFile1 = fopen(RunPath1.Data(),
"r");
58 cout<<
"couldn't open file "<<RunPath1<<
"!"<<endl;
64 std::vector<Int_t> RunIdVec1;
67 ncols1 = fscanf(pFile1,
" %d ",&q1);
69 RunIdVec1.push_back(q1);
73 std::sort (RunIdVec1.begin(), RunIdVec1.end());
77 cout<<
"o o o Open .txt file with run indices. Name = " << runList2 << endl;
78 TString RunPath2 = Form(
"./AnalysisInput/%s/Train_%i/%s",period.Data(),trainNo,runList2.Data());
79 cout<<
"o o o Open .txt file with run indices = " << RunPath2 << endl;
80 FILE *pFile2 = fopen(RunPath2.Data(),
"r");
83 cout<<
"couldn't open file "<<RunPath2<<
"!"<<endl;
89 std::vector<Int_t> RunIdVec2;
92 ncols2 = fscanf(pFile2,
" %d ",&q2);
94 RunIdVec2.push_back(q2);
98 std::sort (RunIdVec2.begin(), RunIdVec2.end());
110 std::vector<Int_t> RunIdVecSum;
111 cout<<
"Elements in Vector Sum a ("<<RunIdVecSum.size()<<
")"<<endl;
112 RunIdVecSum.insert( RunIdVecSum.end(),RunIdVec1.begin(), RunIdVec1.end());
113 cout<<
"Elements in Vector Sum b("<<RunIdVecSum.size()<<
")"<<endl;
114 RunIdVecSum.insert( RunIdVecSum.end(),RunIdVec2.begin(), RunIdVec2.end());
115 cout<<
"Elements in Vector Sum c("<<RunIdVecSum.size()<<
")"<<endl;
116 std::sort (RunIdVecSum.begin(), RunIdVecSum.end());
119 std::vector<int>::iterator it;
120 it = std::unique (RunIdVecSum.begin(), RunIdVecSum.end());
121 RunIdVecSum.resize( std::distance(RunIdVecSum.begin(),it) );
122 cout<<
"Elements in Vector Sum d("<<RunIdVecSum.size()<<
")"<<endl;
125 cout<<
"Elements in Vector 1 ("<<RunIdVec1.size()<<
")"<<endl;
126 cout<<
"Elements in Vector 2 ("<<RunIdVec2.size()<<
")"<<endl;
128 cout<<
"##Unique elements in vector(not really) ("<<RunIdVecSum.size()<<
"):"<<endl;
129 for(
Int_t i=0;i<(
Int_t)RunIdVecSum.size();i++)
131 cout<<RunIdVecSum.at(i)<<
", "<<flush;
151 Int_t cellColumn=0,cellRow=0;
152 Int_t cellColumnAbs=0,cellRowAbs=0;
156 cout<<
"...................................................."<<endl;
161 cout<<
"Cell Id provided: "<<inputCellID<<endl;
162 cout<<
"This corresponds to absolute row: "<<cellRowAbs<<
" and absolute collumn: "<<cellColumnAbs<<endl;
164 else if(inputRow!=-1 && inputCollumn!=-1 && inputSM!=-1)
166 cout<<
"Supermodule provided: "<<inputSM<<endl;
167 cout<<
"Absolute row provided: "<< inputRow<<
" and absolute collumn provided : "<<inputCollumn<<endl;
168 cellID=geom->GetAbsCellIdFromCellIndexes(inputSM,inputRow,inputCollumn);
169 cout<<
"This corresponds to Cell Id: "<<cellID<<endl;
171 else cout<<
"need more information!"<<endl;
173 cout<<
"...................................................."<<endl;
184 gROOT->ProcessLine(
"gErrorIgnoreLevel = kWarning;");
185 gStyle->SetOptStat(0);
186 gStyle->SetPadLeftMargin(0.13);
187 gStyle->SetPadRightMargin(0.1);
188 gStyle->SetPadBottomMargin(0.12);
189 gStyle->SetPadTopMargin(0.06);
191 Int_t noOfCells=17674;
192 Int_t nBadCellMerged =noOfCells;
193 Int_t nBadCellRbR =noOfCells;
194 Int_t array_StartCellSM_Value[21] ={0,1152,2304,3456,4608,5760,6912,8064,9216,10368,11520,11904,12288,13056,13824,14592,15360,16128,16896,17280,17664};
198 std::vector<Int_t> badcellsBlock1;
202 std::vector<Int_t> vOnlyMaskedInMergedA;
203 std::vector<Int_t> vOnlyMaskedInMergedB;
208 cout<<
"** Open file A with merged runlist analysis: "<<endl;
209 TString pathA = Form(
"./AnalysisOutput/%s/Train_%i/Version%i",period.Data(),trainNo,versionA);
210 TString rootFileNameA= Form(
"%s_INT7_Histograms_V%i.root",period.Data(),versionA);
211 TFile* outputRootA = TFile::Open(Form(
"%s/%s",pathA.Data(),rootFileNameA.Data()));
212 if(!outputRootA)cout<<
"File "<<outputRootA->GetName()<<
" does not exist"<<endl;
213 else cout<<
"file A: "<<outputRootA->GetName()<<endl;
216 TH2F* hCellAmplitudeA =(
TH2F*)outputRootA->Get(
"hCellAmplitude");
217 TH1F* hnEventsA =(TH1F*)outputRootA->Get(
"hNEvents");
218 hCellAmplitudeA->Scale(hnEventsA->GetBinContent(1));
219 TH2F* hCellAmplitudeBlockMaskA=(
TH2F*)hCellAmplitudeA->Clone(
"hCellAmplitudeMask");
220 TH1F* hCellFlagA =(TH1F*)outputRootA->Get(
"fhCellFlag");
226 cout<<
"**Open file B with merged runlist analysis: "<<endl;
227 TString pathB = Form(
"./AnalysisOutput/%s/Train_%i/Version%i",period.Data(),trainNo,versionB);
228 TString rootFileNameB= Form(
"%s_INT7_Histograms_V%i.root",period.Data(),versionB);
229 TFile* outputRootB = TFile::Open(Form(
"%s/%s",pathB.Data(),rootFileNameB.Data()));
230 if(!outputRootB)cout<<
"File "<<outputRootB->GetName()<<
" does not exist"<<endl;
231 else cout<<
"file B: "<<outputRootB->GetName()<<endl;
234 TH2F* hCellAmplitudeB =(
TH2F*)outputRootB->Get(
"hCellAmplitude");
235 TH1F* hnEventsB =(TH1F*)outputRootB->Get(
"hNEvents");
236 hCellAmplitudeB->Scale(hnEventsB->GetBinContent(1));
237 TH2F* hCellAmplitudeBlockMaskB=(
TH2F*)hCellAmplitudeB->Clone(
"hCellAmplitudeMask");
238 TH1F* hCellFlagB =(TH1F*)outputRootB->Get(
"fhCellFlag");
246 for(
Int_t ic = 0; ic < noOfCells; ic++)
255 for (
Int_t amp = 1; amp <= hCellAmplitudeBlockMaskA->GetNbinsX(); amp++)
257 if(hCellFlagA->GetBinContent(ic+1)>0 || maskA==1)
259 hCellAmplitudeBlockMaskA->SetBinContent(amp,ic+1,0);
260 if(amp==1)nBadCellMerged--;
271 for (
Int_t amp = 1; amp <= hCellAmplitudeBlockMaskB->GetNbinsX(); amp++)
273 if(hCellFlagB->GetBinContent(ic+1)>0 || maskB==1)
275 hCellAmplitudeBlockMaskB->SetBinContent(amp,ic+1,0);
276 if(amp==1)nBadCellRbR--;
285 if(hCellFlagA->GetBinContent(ic+1)>0 && hCellFlagB->GetBinContent(ic+1)==0)vOnlyMaskedInMergedA.push_back(ic);
286 if(hCellFlagA->GetBinContent(ic+1)==0 && hCellFlagB->GetBinContent(ic+1)>0) vOnlyMaskedInMergedB.push_back(ic);
290 TH1* projMaskedCellsA = hCellAmplitudeBlockMaskA->ProjectionX(
"MaskedCellsMergedBlockA");
291 TH1* projMaskedCellsB = hCellAmplitudeBlockMaskB->ProjectionX(
"MaskedCellsMergedBlockB");
296 TCanvas* C1 =
new TCanvas(
"-1-",
"Projections of A and B",900,900);
298 C1->cd(1)->SetLogy();
299 SetHisto(projMaskedCellsA,
"",
"hits/event",0);
300 projMaskedCellsA->DrawCopy(
"hist");
301 projMaskedCellsB->SetLineColor(8);
302 projMaskedCellsB->DrawCopy(
"same hist");
304 projMaskedCellsA->Divide(projMaskedCellsB);
305 SetHisto(projMaskedCellsA,
"",
"Merged Version A/Merged Version B",0);
306 projMaskedCellsA->DrawCopy(
"hist");
307 projMaskedCellsA->Multiply(projMaskedCellsB);
309 TLatex* textSM =
new TLatex(0.1,0.1,
"*test*");
310 textSM->SetTextSize(0.06);
311 textSM->SetTextColor(1);
314 TCanvas *c1_projSM =
new TCanvas(
"-1a-",
"Projections of A and B per SM",1200,900);
315 c1_projSM->Divide(5,4,0.001,0.001);
316 TH1* projEnergyMaskASM[20];
317 TH1* projEnergyMaskBSM[20];
318 for(
Int_t iSM=0;iSM<20;iSM++)
320 c1_projSM->cd(iSM+1)->SetLogy();
321 gPad->SetTopMargin(0.03);
322 gPad->SetBottomMargin(0.11);
323 projEnergyMaskASM[iSM] = hCellAmplitudeBlockMaskA->ProjectionX(Form(
"%sMask_ProjSM%i",hCellAmplitudeBlockMaskA->GetName(),iSM),array_StartCellSM_Value[iSM],array_StartCellSM_Value[iSM+1]-1);
324 projEnergyMaskASM[iSM]->SetTitle(
"");
325 projEnergyMaskASM[iSM]->SetXTitle(Form(
"Cell Energy [GeV], SM%i",iSM));
326 projEnergyMaskASM[iSM]->GetYaxis()->SetTitleOffset(1.6);
327 projEnergyMaskASM[iSM]->GetYaxis()->SetLabelSize(0.06);
328 projEnergyMaskASM[iSM]->GetXaxis()->SetLabelSize(0.06);
329 projEnergyMaskASM[iSM]->GetXaxis()->SetRangeUser(0,20);
330 projEnergyMaskASM[iSM]->GetXaxis()->SetTitleSize(0.06);
331 projEnergyMaskASM[iSM]->SetLineColor(kGreen+1);
332 projEnergyMaskASM[iSM]->DrawCopy(
" hist");
334 projEnergyMaskBSM[iSM] = hCellAmplitudeBlockMaskB->ProjectionX(Form(
"%s_ProjSM%i",hCellAmplitudeBlockMaskB->GetName(),iSM),array_StartCellSM_Value[iSM],array_StartCellSM_Value[iSM+1]-1);
335 projEnergyMaskBSM[iSM]->DrawCopy(
"same hist");
337 textSM->SetTitle(Form(
"Includes cell IDs %d-%d",array_StartCellSM_Value[iSM],array_StartCellSM_Value[iSM+1]-1));
338 textSM->DrawLatex(0.2,0.8,Form(
"Includes cell IDs %d-%d",array_StartCellSM_Value[iSM],array_StartCellSM_Value[iSM+1]-1));
340 TCanvas *c1_projSMR =
new TCanvas(
"-1b-",
"Ratio of A/B per SM",1200,900);
341 c1_projSMR->Divide(5,4,0.001,0.001);
342 TH1* projEnergyMaskSM[20];
343 TH1* projEnergySM[20];
344 for(
Int_t iSM=0;iSM<20;iSM++)
346 c1_projSMR->cd(iSM+1);
347 gPad->SetTopMargin(0.03);
348 gPad->SetBottomMargin(0.11);
349 projEnergyMaskASM[iSM]->Divide(projEnergyMaskBSM[iSM]);
350 projEnergyMaskASM[iSM]->SetLineColor(kGray+1);
351 projEnergyMaskASM[iSM]->DrawCopy(
" hist");
353 textSM->SetTitle(Form(
"Includes cell IDs %d-%d",array_StartCellSM_Value[iSM],array_StartCellSM_Value[iSM+1]-1));
354 textSM->DrawLatex(0.2,0.8,Form(
"Includes cell IDs %d-%d",array_StartCellSM_Value[iSM],array_StartCellSM_Value[iSM+1]-1));
357 TCanvas* C3 =
new TCanvas(
"-3-",
"2D of A and B",900,900);
359 C3->cd(1)->SetLogz();
360 SetHisto(hCellAmplitudeBlockMaskA,
"",
"cell ID",0);
361 hCellAmplitudeBlockMaskA->DrawCopy(
"colz");
362 C3->cd(2)->SetLogz();
363 SetHisto(hCellAmplitudeBlockMaskB,
"",
"cell ID",0);
364 hCellAmplitudeBlockMaskB->DrawCopy(
"colz");
370 projMaskedCellsA->Scale(1.0/nBadCellMerged);
371 projMaskedCellsB->Scale(1.0/nBadCellRbR);
374 cout<<
" Cells masked in version A and not in version B ("<<vOnlyMaskedInMergedA.size()<<
"):"<<endl;
375 for(
Int_t i=0; i<(
Int_t)vOnlyMaskedInMergedA.size();i++)
377 cout<<vOnlyMaskedInMergedA.at(i)<<
","<<flush;
380 TString outNameA = Form(
"./AnalysisOutput/%s/Train_%i/cOnlyMergedBlockA.pdf",period.Data(),trainNo);
381 CreateCellCompPDF(hCellAmplitudeBlockMaskB,vOnlyMaskedInMergedA,projMaskedCellsA,projMaskedCellsB,outNameA);
382 cout<<
" Cells masked in version B and not in version A ("<<vOnlyMaskedInMergedB.size()<<
"):"<<endl;
383 for(
Int_t i=0; i<(
Int_t)vOnlyMaskedInMergedB.size();i++)
385 cout<<vOnlyMaskedInMergedB.at(i)<<
","<<flush;
388 TString outNameB = Form(
"./AnalysisOutput/%s/Train_%i/cOnlyMergedBlockB.pdf",period.Data(),trainNo);
389 CreateCellCompPDF(hCellAmplitudeBlockMaskA,vOnlyMaskedInMergedB,projMaskedCellsA,projMaskedCellsB,outNameB);
395 Plot2DCells(
"-",244917,vOnlyMaskedInMergedB,vOnlyMaskedInMergedA);
417 Int_t fNMaxColsAbs = 2*48;
420 TH2F *plot2D_VersionB =
new TH2F(Form(
"Block%s_VersionB",Block.Data()),Form(
"Block%s_VersionB",Block.Data()),fNMaxColsAbs+1,-0.5,fNMaxColsAbs+0.5, fNMaxRowsAbs+1,-0.5,fNMaxRowsAbs+0.5);
421 plot2D_VersionB->GetXaxis()->SetTitle(
"cell column (#eta direction)");
422 plot2D_VersionB->GetYaxis()->SetTitle(
"cell row (#phi direction)");
423 TH2F *plot2D_VersionA =
new TH2F(Form(
"Block%s_VersionA",Block.Data()),Form(
"Block%s_VersionA",Block.Data()),fNMaxColsAbs+1,-0.5,fNMaxColsAbs+0.5, fNMaxRowsAbs+1,-0.5,fNMaxRowsAbs+0.5);
424 plot2D_VersionA->GetXaxis()->SetTitle(
"cell column (#eta direction)");
425 plot2D_VersionA->GetYaxis()->SetTitle(
"cell row (#phi direction)");
427 Int_t cellColumn=0,cellRow=0;
428 Int_t cellColumnAbs=0,cellRowAbs=0;
431 for(
Int_t i = 0; i < (
Int_t)cellVectorMergeB.size(); i++)
433 Int_t cell=cellVectorMergeB.at(i);
439 if(cellColumnAbs> fNMaxColsAbs || cellRowAbs>fNMaxRowsAbs)
441 cout<<
"Problem! wrong calculated number of max col and max rows"<<endl;
442 cout<<
"current col: "<<cellColumnAbs<<
", max col"<<fNMaxColsAbs<<endl;
443 cout<<
"current row: "<<cellRowAbs<<
", max row"<<fNMaxRowsAbs<<endl;
445 plot2D_VersionB->Fill(cellColumnAbs,cellRowAbs);
447 for(
Int_t i = 0; i < (
Int_t)cellVectorMergeA.size(); i++)
449 Int_t cell=cellVectorMergeA.at(i);
455 if(cellColumnAbs> fNMaxColsAbs || cellRowAbs>fNMaxRowsAbs)
457 cout<<
"Problem! wrong calculated number of max col and max rows"<<endl;
458 cout<<
"current col: "<<cellColumnAbs<<
", max col"<<fNMaxColsAbs<<endl;
459 cout<<
"current row: "<<cellRowAbs<<
", max row"<<fNMaxRowsAbs<<endl;
461 plot2D_VersionA->Fill(cellColumnAbs,cellRowAbs,1);
464 TCanvas *c1 =
new TCanvas(Form(
"2DMapForBlock%s",Block.Data()),Form(
"2DMapForBlock%s",Block.Data()),900,500);
465 c1->ToggleEventStatus();
468 plot2D_VersionB->Draw(
"colz");
470 plot2D_VersionA->Draw(
"colz");
478 for(
Int_t i=0; i<(
Int_t)cellVector.size();i++)
480 if(cell==cellVector.at(i))bad=1;
490 Int_t NoOfCells=cellVector.size();
498 for(
Int_t cell=0;cell<NoOfCells;cell++)
504 c1 =
new TCanvas(Form(
"badcells%i",cell),
"badcells",1000,750);
505 if(cellVector.size() > 6) c1->Divide(3,3);
506 else if (cellVector.size() > 3) c1->Divide(3,2);
507 else c1->Divide(3,1);
509 TH1 *hCell = hAmpIDMasked->ProjectionX(Form(
"Cell %d",cellVector.at(cell)),cellVector.at(cell)+1,cellVector.at(cell)+1);
510 TH1 *hCell2 = (
TH1*)hCell->Clone(
"hCell2");
512 c1->cd(cell%9 + 1)->SetLogy();
513 hCell->Divide(goodCellsRbR);
514 hCell2->Divide(goodCellsMerged);
516 hCell->SetLineColor(kBlue-8);
517 hCell2->SetLineColor(kRed-9);
518 hCell->GetXaxis()->SetTitle(
"E (GeV)");
519 hCell->GetYaxis()->SetTitle(
"cell/mean of good");
520 hCell->GetXaxis()->SetRangeUser(0.,10.);
521 hCell->SetLineWidth(1) ;
522 hCell->SetTitle(Form(
"Cell No. %d",cellVector.at(cell)));
524 hCell2->DrawCopy(
"same hist");
530 if(cell%9==8 ||cell == NoOfCells-1)
532 if(cell == NoOfCells-1)
535 c1->Print(Form(
"%s)",pdfName.Data()));
537 else if(firstCanvas==0)
539 internal_pdfName +=
"(";
540 c1->Print(internal_pdfName.Data());
545 c1->Print(internal_pdfName.Data());
562 Histo->GetYaxis()->SetTitleOffset(1.4);
563 Histo->GetXaxis()->SetTitleOffset(1.4);
564 Histo->GetXaxis()->SetLabelSize(0.05);
565 Histo->GetYaxis()->SetLabelSize(0.05);
566 Histo->GetXaxis()->SetTitleSize(0.045);
567 Histo->GetYaxis()->SetTitleSize(0.045);
568 Histo->GetXaxis()->SetNdivisions(505);
569 Histo->GetYaxis()->SetNdivisions(505);
574 Histo->GetYaxis()->SetTitleOffset(0.2);
575 Histo->GetXaxis()->SetTitleOffset(1.0);
578 Histo->GetXaxis()->SetLabelSize(0.07);
579 Histo->GetYaxis()->SetLabelSize(0.07);
580 Histo->GetXaxis()->SetTitleSize(0.08);
581 Histo->GetYaxis()->SetTitleSize(0.08);
584 Histo->GetXaxis()->SetNdivisions(520);
585 Histo->GetYaxis()->SetNdivisions(10);
588 Histo->GetXaxis()->SetLabelFont(42);
589 Histo->GetYaxis()->SetLabelFont(42);
590 Histo->GetXaxis()->SetTitleFont(42);
591 Histo->GetYaxis()->SetTitleFont(42);
592 if(Xtitel!=
"")Histo->GetXaxis()->SetTitle(Xtitel);
593 if(Ytitel!=
"")Histo->GetYaxis()->SetTitle(Ytitel);
595 Histo->SetLineColor(1);
596 Histo->SetMarkerColor(1);
597 Histo->SetMarkerStyle(20);
598 Histo->SetMarkerSize(0.5);
void SetRunNumber(Int_t run)
Bool_t IsCellMaskedByHand(Int_t cell, std::vector< Int_t > cellVector)
void SetHisto(TH1 *Histo, TString Xtitel, TString Ytitel, Bool_t longhisto)
void Compare_RunNumbers(TString period="LHC15n", Int_t trainNo=603, TString runList1="", TString runList2="")
void Compare2Blocks(TString period="LHC15n", Int_t trainNo=603, Int_t versionA=0, Int_t versionB=1)
AliEMCALGeometry * GetEMCALGeometry() const
void Get_RowCollumnID(Int_t runNum=244411, Int_t inputCellID=-1, Int_t inputRow=-1, Int_t inputCollumn=-1, Int_t inputSM=-1)
void Plot2DCells(TString Block, Int_t runNo, std::vector< Int_t > cellVectorMergeB, std::vector< Int_t > cellVectorMergeA)
Class with utils specific to calorimeter clusters/cells.
void AccessGeometry(AliVEvent *inputEvent)
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
void CreateCellCompPDF(TH2F *hAmpIDMasked, std::vector< Int_t > cellVector, TH1 *goodCellsMerged, TH1 *goodCellsRbR, TString pdfName)