21 #include <TSpectrum.h>
32 #include <Riostream.h>
42 #include <AliEMCALGeometry.h>
44 #include <AliAODEvent.h>
63 fCurrentRunNumber(-1),
68 fCellStartDCal(12288),
97 fPass =
"muon_caloLego";
112 fCurrentRunNumber(-1),
117 fCellStartDCal(12288),
182 fRootFile =
new TFile(fileName,
"recreate");
198 cout<<
"Number of supermod: "<<nModules<<endl;
262 cout<<
". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ."<<endl;
263 cout<<
". . .Start process by converting files. . . . . . . . . . . ."<<endl;
268 Printf(
"File not produced, exit");
276 cout<<
". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ."<<endl;
277 cout<<
". . .Start process by loading external file. . . . . . . . . . ."<<endl;
280 cout<<
". . .Load inputfile with name: "<<
fMergedFileName<<
" . . . . . . . ."<<endl;
286 if(!mergedFileInput->IsOpen())
288 Printf(
"Error! Input file not found, abort");
295 cout<<
". . .Continue process by . . . . . . . . . . . ."<<endl;
301 cout<<
"o o o Flag dead cells o o o"<<endl;
310 cout<<
"o o o Flag bad cells o o o"<<endl;
317 cout<<
"o o o Write .txt for each period analyis with bad cells o o o"<<endl;
320 cout<<
"o o o Create summary documents for the entire analysis o o o"<<endl;
330 Int_t binHeihgtOne = hRefDistr->FindLastBinAbove(1);
331 Double_t binCentreHeightOne = hRefDistr->GetBinCenter(binHeihgtOne);
332 cout<<
". . .Recomendation:"<<endl;
333 cout<<
". . .With the current statistic on average a cell has 1 hit at "<<binCentreHeightOne<<
" GeV"<<endl;
334 cout<<
". . .so it makes no sense to select energy ranges >"<<binCentreHeightOne<<
" as cells will be maked bad just due to the lack of statistic"<<endl;
335 cout<<
". . .End of process . . . . . . . . . . . . . . . . . . . . ."<<endl;
336 cout<<
". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ."<<endl;
348 cout<<
"o o o Start conversion process o o o"<<endl;
353 TH2F *hCellAmplitude =
new TH2F(
"hCellAmplitude",
"Cell Amplitude",200,0,10,23040,0,23040);
354 TH2F *hCellTime =
new TH2F(
"hCellTime",
"Cell Time",250,-275,975,23040,0,23040);
355 TH1F *hNEventsProcessedPerRun =
new TH1F(
"hNEventsProcessedPerRun",
"Number of processed events in analyzed runs",1,0,1);
358 cout<<
"o o o Open .txt file with run indices. Name = " <<
fRunList << endl;
359 FILE *pFile = fopen(
fRunList.Data(),
"r");
362 cout<<
"couldn't open file!"<<endl;
373 ncols = fscanf(pFile,
" %d ",&q);
382 const Int_t nRun = nlines ;
387 cout<<
"o o o Start merging process of " << nRun <<
" files"<< endl;
389 for(
Int_t i = 0 ; i < nRun ; i++)
406 infile = Form(
"%s.root",base.Data()) ;
409 cout<<
" o Open .root file with name: "<<infile<<endl;
410 TFile *f = TFile::Open(infile);
415 cout<<
"Couldn't open/find .root file: "<<infile<<endl;
418 TDirectoryFile *dir = (TDirectoryFile *)f->Get(
fQADirect);
421 cout<<
"Couln't open directory file in .root file: "<<infile<<
", directory: "<<
fQADirect<<endl;
427 cout <<
"Couln't get TList from directory file: "<<
fQADirect<<endl;
436 hAmpId =(
TH2F *)outputList->FindObject(
"EMCAL_hAmpId");
439 Printf(
"hAmpId not found");
443 hTimeId =(
TH2F *)outputList->FindObject(
"EMCAL_hTimeId");
446 Printf(
"hTimeId not found");
450 hNEvents =(TH1F *)outputList->FindObject(
"hNEvents");
453 Printf(
"hNEvents not found");
457 nEntr = (
Int_t)hNEvents->GetEntries();
462 cout <<
" o File to small to be merged. Only N entries " << nEntr << endl;
465 cout <<
" o File with N entries " << nEntr<<
" will be merged"<< endl;
467 hCellAmplitude->Add(hAmpId);
468 hCellTime->Add(hTimeId);
469 hNEventsProcessedPerRun->Add(hNEvents);
474 TFile *singleRunFile = TFile::Open(singleRunFileName,
"recreate");
475 hNEventsProcessedPerRun->Write();
476 hCellAmplitude->Write();
478 singleRunFile->Close();
480 outputList->Delete();
487 cout<<
"o o o Save the merged histogramms to .root file with name: "<<
fMergedFileName<<endl;
488 cout<<
"o o o "<<nEntrTot<<
" events were merged"<<endl;
490 hNEventsProcessedPerRun->Write();
491 hCellAmplitude->Write();
494 cout<<
"o o o End conversion process o o o"<<endl;
516 PeriodAnalysis(periodArray.At(0),periodArray.At(1),periodArray.At(2),periodArray.At(3));
521 cout<<
"o o o End of bad channel analysis o o o"<<endl;
537 periodArray.AddAt((
Double_t)criteria,0);
538 periodArray.AddAt(nsigma,1);
539 periodArray.AddAt(emin,2);
540 periodArray.AddAt(emax,3);
562 cout<<
"o o o o o o o o o o o o o o o o o o o o o o o o o"<<endl;
563 cout<<
"o o o PeriodAnalysis for flag "<<criterion<<
" o o o"<<endl;
564 cout<<
"o o o Done in the energy range E "<<emin<<
"-"<<emax<<endl;
576 if(criterion < 6)cout<<
"o o o Analyze average cell distributions o o o"<<endl;
580 else if (criterion < 6)
TestCellShapes(criterion, emin, emax, nsigma);
583 if(emin>0.49)range=0.0005;
584 if(emin>0.99)range=0.0001;
585 if(emin>1.99)range=0.00005;
587 if(criterion==1)
FlagAsBad(criterion, histogram, nsigma, 200,-1);
588 if(criterion==2)
FlagAsBad(criterion, histogram, nsigma, 600,range);
609 cout<<
" o Calculate average cell hit per event and average cell energy per hit "<<endl;
611 if(crit==1)histogram =
new TH1F(Form(
"hCellEtoNtotal_E%.2f-%.2f",emin,emax),Form(
"Energy per hit, %.2f < E < %.2f GeV",emin,emax),
fNoOfCells,0,
fNoOfCells);
612 if(crit==2)histogram =
new TH1F(Form(
"hCellNtotal_E%.2f-%.2f",emin,emax),Form(
"Number of hits per event, %.2f < E < %.2f GeV",emin,emax),
fNoOfCells,0,
fNoOfCells);
613 histogram->SetXTitle(
"Abs. Cell Id");
614 if(crit==1)histogram->SetYTitle(
"Energy per hit");
615 if(crit==2)histogram->SetYTitle(
"Number of hits per event");
616 histogram->GetXaxis()->SetNdivisions(510);
630 if (E < emin || E > emax ||
fFlag[cell]!=0)
continue;
637 if(totalevents> 0. && crit==2)histogram->SetBinContent(cell+1, Nsum/totalevents);
638 if(Nsum > 0. && crit==1)histogram->SetBinContent(cell+1, Esum/Nsum);
650 TH1F *Histogram =
new TH1F(Form(
"hSomethingWithTime_E%.2f-%.2f",emin,emax),Form(
"I don't know, %.2f < E < %.2f GeV",emin,emax), 2,0,2);
671 cout <<
"ncells " << ncells <<
" amin = " << amin <<
"amax = " << amax<< endl;
674 TH1 *hFitA =
new TH1F(
"hFitA_hCellAmplitude",
"Fit A value", ncells,amin,amax);
675 hFitA->SetXTitle(
"AbsId");
676 hFitA->SetYTitle(
"A");
678 TH1 *hFitB =
new TH1F(
"hFitB_hCellAmplitude",
"Fit B value", ncells,amin,amax);
679 hFitB->SetXTitle(
"AbsIdhname");
680 hFitB->SetYTitle(
"B");
682 TH1 *hFitChi2Ndf =
new TH1F(
"hFitChi2Ndf_hCellAmplitude",
"Fit #chi^{2}/ndf value", ncells,amin,amax);
683 hFitChi2Ndf->SetXTitle(
"AbsId");
684 hFitChi2Ndf->SetYTitle(
"#chi^{2}/ndf");
686 Double_t maxval1=0., maxval2=0., maxval3=0.;
687 Double_t prev=0., MSA=0., AvA = 0. ;
688 Double_t prev2=0., MSB=0., AvB = 0. ;
689 Double_t prev3=0., MSki2=0., Avki2 = 0. ;
693 TF1 *fit =
new TF1(
"fit",
"[0]*exp(-[1]*x)/x^2");
695 if (hCell->GetEntries() == 0)
continue;
697 hCell->Fit(fit,
"0QEM",
"", fitemin, fitemax);
700 if(fit->GetParameter(0) < 5000.)
702 hFitA->SetBinContent(k, fit->GetParameter(0));
705 AvA += fit->GetParameter(0);
706 if(k==2999) maxval1 = AvA/3000. ;
707 if (prev < fit->GetParameter(0)) MSA += fit->GetParameter(0) - prev;
708 else MSA -= (fit->GetParameter(0) - prev) ;
709 prev = fit->GetParameter(0);
713 if((fit->GetParameter(0) - maxval1) > 0. && (fit->GetParameter(0) - maxval1) < (MSA/1000.))
715 maxval1 = fit->GetParameter(0);
719 else hFitA->SetBinContent(k, 5000.);
721 if(fit->GetParameter(1) < 5000.)
723 hFitB->SetBinContent(k, fit->GetParameter(1));
726 AvB += fit->GetParameter(1);
727 if(k==2999) maxval2 = AvB/3000. ;
728 if (prev2 < fit->GetParameter(1)) MSB += fit->GetParameter(1) - prev2;
729 else MSB -= (fit->GetParameter(1) - prev2) ;
730 prev2 = fit->GetParameter(1);
734 if((fit->GetParameter(1) - maxval2) > 0. && (fit->GetParameter(1) - maxval2) < (MSB/1000.))
736 maxval2 = fit->GetParameter(1);
740 else hFitB->SetBinContent(k, 5000.);
743 if (fit->GetNDF() != 0 ) ki2 = fit->GetChisquare()/fit->GetNDF();
748 hFitChi2Ndf->SetBinContent(k, ki2);
752 if(k==2999) maxval3 = Avki2/3000. ;
753 if (prev3 < ki2) MSki2 += ki2 - prev3;
754 else MSki2 -= (ki2 - prev3) ;
759 if((ki2 - maxval3) > 0. && (ki2 - maxval3) < (MSki2/1000.))
765 else hFitChi2Ndf->SetBinContent(k, 1000.);
809 if(nSum < 0.5 &&
fFlag[cell]==0)
817 cout<<
" o Number of dead cells: "<<sumOfExcl<<endl;
818 cout<<
" ("<<sumOfExcl<<
")"<<endl;
838 gStyle->SetOptStat(0);
839 gStyle->SetOptFit(0);
841 if(crit==1)cout<<
" o Fit average energy per hit distribution"<<endl;
842 if(crit==2)cout<<
" o Fit average hit per event distribution"<<endl;
844 Int_t cellColumn=0,cellRow=0;
845 Int_t cellColumnAbs=0,cellRowAbs=0;
848 TString histoName=inhisto->GetName();
853 dmaxval = inhisto->GetMaximum()*1.01;
854 if(crit==2 && dmaxval > 1) dmaxval =1. ;
863 if(((dmaxval-inhisto->GetMinimum())/(dnbins*1.0))<1.0/totalevents)
865 dnbins=(dmaxval-inhisto->GetMinimum())*totalevents;
866 cout<<
"Problem - Reset dnbins to new value:"<<dnbins<<endl;
870 TH1F *distrib =
new TH1F(Form(
"%sDistr",(
const char*)histoName),
"", dnbins, inhisto->GetMinimum(), dmaxval);
871 distrib->SetXTitle(inhisto->GetYaxis()->GetTitle());
872 distrib->SetYTitle(
"Entries");
873 TH1F *distrib_wTRDStruc =
new TH1F(Form(
"%sDistr_wTRD",(
const char*)histoName),
"", dnbins, inhisto->GetMinimum(), dmaxval);
874 TH1F *distrib_woTRDStruc=
new TH1F(Form(
"%sDistr_woTRD",(
const char*)histoName),
"", dnbins, inhisto->GetMinimum(), dmaxval);
879 plot2D->GetXaxis()->SetTitle(
"cell column (#eta direction)");
880 plot2D->GetYaxis()->SetTitle(
"cell row (#phi direction)");
891 distrib->Fill(inhisto->GetBinContent(cell+1));
898 cout<<
"Problem! wrong calculated number of max col and max rows"<<endl;
899 cout<<
"current col: "<<cellColumnAbs<<
", max col"<<
fNMaxColsAbs<<endl;
900 cout<<
"current row: "<<cellRowAbs<<
", max row"<<
fNMaxRowsAbs<<endl;
902 plot2D->SetBinContent(cellColumnAbs,cellRowAbs,inhisto->GetBinContent(cell+1));
906 distrib_wTRDStruc->Fill(inhisto->GetBinContent(cell+1));
910 distrib_woTRDStruc ->Fill(inhisto->GetBinContent(cell+1));
919 TCanvas *c1 =
new TCanvas(histoName,histoName,900,900);
920 c1->ToggleEventStatus();
921 TPad* upperPad =
new TPad(
"upperPad",
"upperPad",.005, .5, .995, .995);
922 TPad* lowerPadLeft =
new TPad(
"lowerPadL",
"lowerPadL",.005, .005, .5, .5);
923 TPad* lowerPadRight =
new TPad(
"lowerPadR",
"lowerPadR",.5, .005, .995, .5);
925 lowerPadLeft->Draw();
926 lowerPadRight->Draw();
929 upperPad->SetLeftMargin(0.045);
930 upperPad->SetRightMargin(0.05);
932 inhisto->SetTitleOffset(0.6,
"Y");
933 inhisto->GetXaxis()->SetRangeUser(0,fNoOfCells+1);
935 inhisto->SetLineColor(kBlue+1);
939 lowerPadRight->SetLeftMargin(0.09);
940 lowerPadRight->SetRightMargin(0.1);
941 plot2D->Draw(
"colz");
944 lowerPadLeft->SetLeftMargin(0.09);
945 lowerPadLeft->SetRightMargin(0.07);
946 lowerPadLeft->SetLogy();
947 distrib->SetLineColor(kBlue+1);
949 distrib_wTRDStruc->SetLineColor(kGreen+1);
950 distrib_wTRDStruc->DrawCopy(
"same");
951 distrib_woTRDStruc->SetLineColor(kMagenta+1);
952 distrib_woTRDStruc->DrawCopy(
"same");
958 for(i = 2; i <= dnbins; i++)
960 if(distrib->GetBinContent(higherbin) < distrib->GetBinContent(i)) higherbin = i ;
964 for(i = higherbin ; i<=dnbins ; i++)
966 if(distrib->GetBinContent(i)<2)
break ;
967 goodmax = distrib->GetBinCenter(i);
969 for(i = higherbin ; i>1 ; i--)
971 if(distrib->GetBinContent(i)<2)
break ;
972 goodmin = distrib->GetBinLowEdge(i);
977 TF1 *fit2 =
new TF1(
"fit2",
"gaus",0,10);
979 fit2->SetParameter(1,higherbin);
981 distrib->Fit(fit2,
"0LQEM",
"", goodmin, goodmax);
984 mean = fit2->GetParameter(1);
985 sig = fit2->GetParameter(2);
988 if (mean <0.) mean=0.;
990 goodmin = mean - nsigma*sig ;
991 goodmax = mean + nsigma*sig ;
993 if (goodmin<0) goodmin=0.;
995 cout<<
" o Result of fit: "<<endl;
997 cout<<
" o Mean: "<<mean <<
" sigma: "<<sig<<endl;
998 cout<<
" o good range : "<<goodmin <<
" - "<<goodmax<<endl;
1003 TLine *lline =
new TLine(goodmin, 0, goodmin, distrib->GetMaximum());
1004 lline->SetLineColor(kGreen+2);
1005 lline->SetLineStyle(7);
1008 TLine *rline =
new TLine(goodmax, 0, goodmax, distrib->GetMaximum());
1009 rline->SetLineColor(kGreen+2);
1010 rline->SetLineStyle(7);
1013 TLegend *leg =
new TLegend(0.60,0.70,0.9,0.85);
1014 leg->AddEntry(lline,
"Good region boundary",
"l");
1015 leg->AddEntry(distrib_wTRDStruc,
"Covered by TRD",
"l");
1016 leg->AddEntry(distrib_woTRDStruc,
"wo TRD structure",
"l");
1017 leg->SetBorderSize(0);
1020 fit2->SetLineColor(kOrange-3);
1021 fit2->SetLineStyle(1);
1025 if(crit==1) text =
new TLatex(0.12,0.85,Form(
"Good range: %.2f-%.2f",goodmin,goodmax));
1026 if(crit==2) text =
new TLatex(0.12,0.85,Form(
"Good range: %.2f-%.2fx10^-5",goodmin*100000,goodmax*100000));
1027 text->SetTextSize(0.06);
1029 text->SetTextColor(1);
1034 TLine *uline =
new TLine(0, goodmax,fNoOfCells,goodmax);
1035 uline->SetLineColor(kGreen+2);
1036 uline->SetLineStyle(7);
1038 TLine *lowline =
new TLine(0, goodmin,fNoOfCells,goodmin);
1039 lowline->SetLineColor(kGreen+2);
1040 lowline->SetLineStyle(7);
1047 if(crit==1)name=Form(
"%s/%s/AverageEperHit_%s.gif",
fWorkdir.Data(),
fAnalysisOutput.Data(), (
const char*)histoName);
1048 if(crit==2)name=Form(
"%s/%s/AverageHitperEvent_%s.gif",
fWorkdir.Data(),
fAnalysisOutput.Data(), (
const char*)histoName);
1051 fRootFile->WriteObject(c1,c1->GetName());
1052 fRootFile->WriteObject(plot2D,plot2D->GetName());
1053 fRootFile->WriteObject(distrib,distrib->GetName());
1054 fRootFile->WriteObject(inhisto,inhisto->GetName());
1061 cout<<
" o Flag bad cells that are outside the good range "<<endl;
1066 if (inhisto->GetBinContent(cell+1) <= goodmin &&
fFlag[cell]==0)
1070 if (inhisto->GetBinContent(cell+1) > goodmax && fFlag[cell]==0)
1075 cout<<
" o o o o o o o o o o o o o o o o o o o o o o o"<<endl;
1103 criterion =periodArray.At(0);
1104 emin =periodArray.At(2);
1105 emax =periodArray.At(3);
1109 output.Form(
"%s/%s/Criterion%d_Emin-%.2f_Emax-%.2f.txt",
fWorkdir.Data(),
fAnalysisOutput.Data(), criterion,emin,emax);
1110 ofstream
file(output, ios::out | ios::trunc);
1113 cout<<
"#### Major Error. Check the textfile!"<<endl;
1115 file<<
"fFlag="<<i+2<<
"means Criterion : "<<criterion<<
", emin = "<<emin<<
" GeV"<<
", emax = "<<emax<<
" GeV"<<endl;
1116 cout<<
" o Criterion : "<<criterion<<
", emin = "<<emin<<
" GeV"<<
", emax = "<<emax<<
" GeV"<<
" (Method "<<i<<
")"<<endl;
1121 if(
fFlag[cellID]==(i+2))
1127 file<<
"Total number of bad cells with fFlag=="<<i+2<<endl;
1128 file<<
"("<<nb1<<
")"<<endl;
1130 cout<<
" o Total number of bad cells ("<<nb1<<
")"<<endl;
1143 Int_t cellID, nDCalCells = 0, nEMCalCells = 0;
1144 TString cellSummaryFile, deadPdfName, badPdfName, ratioOfBad,goodCells;
1154 cout<<
" o Final results o "<<endl;
1159 ofstream
file(cellSummaryFile, ios::out | ios::trunc);
1162 file<<
"Dead cells : "<<endl;
1163 cout<<
" o Dead cells : "<<endl;
1170 file<<
"In EMCal: "<<endl;
1176 file<<
"In DCal: "<<endl;
1180 if(
fFlag[cellID]==1)
1191 file<<
"EMCal ("<<nEMCalCells<<
" ="<<100*nEMCalCells/(1.0*
fCellStartDCal)<<
"%), DCal ("<<nDCalCells<<
" ="<<100*nDCalCells/(1.0*fNoOfCells-
fCellStartDCal)<<
"%)"<<endl;
1192 cout<<
" o EMCal ("<<nEMCalCells<<
" ="<<100*nEMCalCells/(1.0*
fCellStartDCal)<<
"%), DCal ("<<nDCalCells<<
" ="<<100*nDCalCells/(1.0*fNoOfCells-
fCellStartDCal)<<
"%)"<<endl;
1194 file<<
"Bad cells: "<<endl;
1195 cout<<
" o Bad cells: "<<endl;
1202 file<<
"In EMCal: "<<endl;
1208 file<<
"In DCal: "<<endl;
1223 file<<
"EMCal ("<<nEMCalCells<<
" ="<<100*nEMCalCells/(1.0*
fCellStartDCal)<<
"%), DCal ("<<nDCalCells<<
" ="<<100*nDCalCells/(1.0*fNoOfCells-
fCellStartDCal)<<
"%)"<<endl;
1224 cout<<
" o EMCal ("<<nEMCalCells<<
" ="<<100*nEMCalCells/(1.0*
fCellStartDCal)<<
"%), DCal ("<<nDCalCells<<
" ="<<100*nDCalCells/(1.0*fNoOfCells-
fCellStartDCal)<<
"%)"<<endl;
1231 cout<<
" o Save the bad channel spectra to a .pdf file"<<endl;
1249 cellAmp_masked->SetBinContent(amp,cell+1,0);
1250 cellTime_masked->SetBinContent(amp,cell+1,0);
1269 TCanvas *c1 =
new TCanvas(
"CellProp",
"summary of cell properties",1000,1000);
1270 c1->ToggleEventStatus();
1272 c1->cd(1)->SetLogz();
1278 c1->cd(2)->SetLogz();
1282 c1->cd(3)->SetLogz();
1285 cellAmp_masked->SetTitle(
"Masked Cell Amplitude");
1286 cellAmp_masked->SetXTitle(
"Cell Energy [GeV]");
1287 cellAmp_masked->SetYTitle(
"Abs. Cell Id");
1288 cellAmp_masked->Draw(
"colz");
1289 c1->cd(4)->SetLogz();
1290 cellTime_masked->SetTitle(
"Masked Cell Time");
1291 cellTime_masked->SetXTitle(
"Cell Time [ns]");
1292 cellTime_masked->SetYTitle(
"Abs. Cell Id");
1293 cellTime_masked->Draw(
"colz");
1296 TCanvas *c2 =
new TCanvas(
"CellFlag",
"summary of cell flags",1200,800);
1297 c2->ToggleEventStatus();
1315 fRootFile->WriteObject(c1,c1->GetName());
1316 fRootFile->WriteObject(c2,c2->GetName());
1327 file.open(cellSummaryFile, ios::out | ios::app);
1330 file<<
"Warm cells : "<<endl;
1331 cout<<
" o Warm cells : "<<endl;
1338 file<<
"In EMCal: "<<endl;
1343 file<<
"In DCal: "<<endl;
1353 file<<
"EMCal ("<<nEMCalCells<<
" ="<<100*nEMCalCells/(1.0*
fCellStartDCal)<<
"%), DCal ("<<nDCalCells<<
" ="<<100*nDCalCells/(1.0*fNoOfCells-
fCellStartDCal)<<
"%)"<<endl;
1354 cout<<
" o EMCal ("<<nEMCalCells<<
" ="<<100*nEMCalCells/(1.0*
fCellStartDCal)<<
"%), DCal ("<<nDCalCells<<
" ="<<100*nDCalCells/(1.0*fNoOfCells-
fCellStartDCal)<<
"%)"<<endl;
1382 gROOT->SetStyle(
"Plain");
1383 gStyle->SetOptStat(0);
1384 gStyle->SetFillColor(kWhite);
1385 gStyle->SetTitleFillColor(kWhite);
1386 gStyle->SetPalette(1);
1392 fRootFile->WriteObject(hRefDistr,hRefDistr->GetName());
1393 Int_t firstCanvas=0;
1395 TLatex* text =
new TLatex(0.2,0.8,
"*Candidate*");
1396 text->SetTextSize(0.07);
1397 text->SetTextColor(kOrange-3);
1400 TLatex* text2 =
new TLatex(0.2,0.8,
"*Not a Candidate*");
1401 text2->SetTextSize(0.08);
1402 text2->SetTextColor(8);
1404 TLatex* textA =
new TLatex(0.65,0.62,
"*test*");
1405 textA->SetTextSize(0.04);
1406 textA->SetTextColor(1);
1412 std::vector<Int_t> channelVector;
1413 channelVector.clear();
1414 cout<<
"Start printing into .pdf for version: "<<version<<endl;
1417 if(
fFlag[cell]==1 && version==0)channelVector.push_back(cell);
1418 if(
fFlag[cell]>1 && version==1)channelVector.push_back(cell);
1419 if(
fFlag[cell]==0 && version==2)channelVector.push_back(cell);
1420 if(
fFlag[cell]>1 && version==10)channelVector.push_back(cell);
1422 if(cell%2000==0)cout<<
"...cell No."<<cell<<endl;
1424 if(channelVector.size()==9 || cell == fNoOfCells-1)
1429 TCanvas *c1 =
new TCanvas(
"badcells",
"badcells",1000,750);
1430 if(channelVector.size() > 6) c1->Divide(3,3);
1431 else if (channelVector.size() > 3) c1->Divide(3,2);
1432 else c1->Divide(3,1);
1434 TLegend *leg =
new TLegend(0.7, 0.7, 0.9, 0.9);
1435 for(
Int_t i=0; i< (
Int_t)channelVector.size() ; i++)
1437 sprintf(name,
"Cell %d",channelVector.at(i)) ;
1438 TH1 *hCell =
fCellAmplitude->ProjectionX(name,channelVector.at(i)+1,channelVector.at(i)+1);
1439 sprintf(title,
"Cell No: %d Entries: %d",channelVector.at(i), (
Int_t)hCell->GetEntries()) ;
1442 c1->cd(i%9 + 1)->SetLogy();
1445 leg->AddEntry(hRefDistr,
"mean of good",
"l");
1446 leg->AddEntry(hCell,
"current",
"l");
1450 if(candidate==1)
fWarmCell[channelVector.at(i)]=candidate;
1453 hCell->Divide(hRefDistr);
1460 hCell->SetLineColor(kBlue+1);
1461 hCell->GetXaxis()->SetTitle(
"E (GeV)");
1462 hCell->GetYaxis()->SetTitle(
"N Entries");
1463 hCell->GetXaxis()->SetRangeUser(0.,10.);
1464 hCell->SetLineWidth(1) ;
1465 hCell->SetTitle(title);
1466 hRefDistr->SetLineColor(kGray+2);
1467 hRefDistr->SetLineWidth(1);
1469 hCell->Draw(
"hist");
1471 if(version==1)hRefDistr->Draw(
"same") ;
1474 if(candidate==1 && (version==1 || version==10))
1476 gPad->SetFrameFillColor(kYellow-10);
1481 textA->SetTitle(Form(
"Excluded by No. %d",
fFlag[channelVector.at(i)]));
1484 if(version==2 && candidate==0)
1486 gPad->SetFrameFillColor(kYellow-10);
1490 if(version<2)leg->Draw();
1493 if(channelVector.size()<9 || cell == fNoOfCells-1)
1495 internal_pdfName +=
")";
1496 c1->Print(internal_pdfName.Data());
1498 else if(firstCanvas==0)
1500 internal_pdfName +=
"(";
1501 c1->Print(internal_pdfName.Data());
1506 c1->Print(internal_pdfName.Data());
1510 channelVector.clear();
1532 if(
fFlag[cell]!=0)
continue;
1534 if(NrGood==1)hgoodMean = (
TH1D*)
fCellAmplitude->ProjectionX(
"hgoodMean",cell+1,cell+1);
1538 hgoodMean->Add(hGoodAmp);
1541 hgoodMean->Scale(1.0/NrGood);
1558 TString Name = Form(
"%s_ratio",histogram->GetName());
1559 TH1* ratio=(
TH1*)histogram->Clone(Name);
1560 ratio->Divide(reference);
1572 Int_t binHeihgtOne = reference->FindLastBinAbove(1);
1573 Double_t binCentreHeightOne = reference->GetBinCenter(binHeihgtOne);
1574 Double_t thirdBinCentre = reference->GetBinCenter(3);
1583 if(ratio->FindLastBinAbove(0)<ratio->FindBin(binCentreHeightOne*percentageOfLast))
1591 ratio->GetXaxis()->SetRangeUser(thirdBinCentre,10);
1592 if(ratio->GetMaximum()>highestRatio)
1601 for(
Int_t i=2;i<binHeihgtOne;i++)
1603 mean+=ratio->GetBinContent(i);
1605 mean*=1.0/(binHeihgtOne-1);
1606 if(mean>maxMean || mean<minMean)
1617 ratio->GetXaxis()->SetRangeUser(0,binCentreHeightOne);
1618 Double_t localMaxBin=ratio->GetMaximumBin();
1620 for(
Int_t i=2;i<binHeihgtOne;i++)
1623 if(ratio->GetBinContent(i)<=0)
continue;
1624 if(i>localMaxBin-3 && i<localMaxBin+3)
continue;
1625 mean+=ratio->GetBinContent(i);
1627 mean*=1.0/(binHeihgtOne-1);
1628 ratio->GetXaxis()->SetRangeUser(thirdBinCentre,binCentreHeightOne);
1630 if(ratio->GetMaximum()>mean*higherThanMean)
1641 Int_t cliffBin = ratio->FindBin(4);
1642 for(
Int_t i=cliffBin-10;i<cliffBin+11;i++)
1645 if(ratio->GetBinContent(i)<=0)
continue;
1646 if(i<=cliffBin) binsBefore++;
1647 if(i>cliffBin) binsAfter++;
1648 if(i<=cliffBin) beforeCliff+=ratio->GetBinContent(i);
1649 if(i>cliffBin) afterCliff+=ratio->GetBinContent(i);
1650 beforeCliff*=1.0/binsBefore;
1651 afterCliff*=1.0/binsAfter;
1653 if((beforeCliff-afterCliff)>cliffSize*afterCliff)
1655 if(beforeCliff!=0 && afterCliff!=0)candidate=0;
1686 Bool_t coveredByTRDSupportStruc=0;
1688 if((collumn>3 && collumn<9) || (collumn>32 && collumn<37) || (collumn>57 && collumn<61) || (collumn>84 && collumn<90) ||
1689 (row==1) ||(row>20 && row<25) || (row>44 && row<49) || (row>68 && row<73) || (row>91 && row<96) ||
1690 (row>116 && row<120)|| row==127 || (row>148 && row<152) || (row>172 && row<177) || (row>197 && row<201)
1693 coveredByTRDSupportStruc=1;
1695 return coveredByTRDSupportStruc;
1710 histoName = Form(
"2DChannelMap_Flag%d",flagBegin);
1711 if(flagBegin==0 && flagEnd==0)histoName = Form(
"2DChannelMap_Flag100");
1714 plot2D->GetXaxis()->SetTitle(
"cell column (#eta direction)");
1715 plot2D->GetYaxis()->SetTitle(
"cell row (#phi direction)");
1717 Int_t cellColumn=0,cellRow=0;
1718 Int_t cellColumnAbs=0,cellRowAbs=0;
1730 cout<<
"Problem! wrong calculated number of max col and max rows"<<endl;
1731 cout<<
"current col: "<<cellColumnAbs<<
", max col"<<
fNMaxColsAbs<<endl;
1732 cout<<
"current row: "<<cellRowAbs<<
", max row"<<
fNMaxRowsAbs<<endl;
1734 if(flagEnd==-1 &&
fFlag[cell]==flagBegin) plot2D->SetBinContent(cellColumnAbs,cellRowAbs,1);
1735 if(flagEnd!=0 && flagEnd!=-1 &&
fFlag[cell]>=flagBegin &&
fFlag[cell]<=flagEnd)plot2D->SetBinContent(cellColumnAbs,cellRowAbs,1);
1736 if(flagBegin==0 && flagEnd==0 &&
fWarmCell[cell]==1) plot2D->SetBinContent(cellColumnAbs,cellRowAbs,1);
1740 TCanvas *c1 =
new TCanvas(histoName,histoName,500,500);
1741 c1->ToggleEventStatus();
1745 plot2D->Draw(
"colz");
1748 if(flagBegin==0 && flagEnd==-1) text =
new TLatex(0.2,0.8,
"Good Cells");
1749 if(flagBegin==1) text =
new TLatex(0.2,0.8,
"Dead Cells");
1750 if(flagBegin>1) text =
new TLatex(0.2,0.8,
"Bad Cells");
1751 if(flagBegin==0 && flagEnd==0) text =
new TLatex(0.2,0.8,
"Warm Cells");
1752 text->SetTextSize(0.06);
1754 text->SetTextColor(1);
1761 fRootFile->WriteObject(plot2D,plot2D->GetName());
1773 sprintf(name,
"Cell %d",cell) ;
TH1F * BuildTimeMean(Int_t crit, Double_t emin, Double_t emax, Double_t nsigma)
TH1D * BuildMeanFromGood()
void SetRunNumber(Int_t run)
void AddPeriodAnalysis(Int_t criteria, Double_t nsigma, Double_t emin, Double_t emax)
TH2F * fCellTime
! possible histogram for the analysis. Cell ID vs. time, read from the input merged file ...
Int_t fNMaxRows
Maximum No of rows in module (phi direction)
Int_t fTrial
Number of trial that this specific analyis is. By default '0' so one can try different settings witho...
void SummarizeResultsByFlag()
TFile * fRootFile
! root file with all histograms from this analysis
std::vector< TArrayD > fAnalysisVector
Vector of analysis information. Each place is filled with 4 doubles: version, sigma, lower, and upper energy range.
TH1F * fProcessedEvents
! Stores the number of events in the run
Int_t fNoOfCells
Number of cells in EMCal and DCal.
AliCalorimeterUtils * fCaloUtils
! Calorimeter information for the investigated runs
Int_t fCellStartDCal
ID of the first cell in the DCal.
TString fPass
Pass of the analyzed data.
Int_t * fFlag
! fFlag[CellID] = 0 (ok),1 (dead),2 and higher (bad certain criteria) start at 0 (cellID 0 = histobin...
Int_t fNMaxCols
Maximum No of colums in module (eta direction)
Int_t fCriterionCounter
! This value will be written in fflag and updates after each PeriodAnalysis, to distinguish the steps...
TString fMergedFileName
Filename of the .root file containing the merged runs.
AliEMCALGeometry * GetEMCALGeometry() const
TList * fOutputListBadRatio
! list with bad channel amplitude ratios, stored in fRootFile
TString fAnalysisInput
Here the .root files of each run of the period are saved.
void TestCellShapes(Int_t crit, Double_t fitemin, Double_t fitemax, Double_t nsigma=4.)
TString fQADirect
Dierctory in the QA.root files where the input histograms are stored.
Bool_t * fWarmCell
! fWarmCell[CellID] = 0 (really bad), fWarmCell[CellID] = 1 (candidate for warm), ...
TString fWorkdir
Directory which contains the folders fMergeOutput, fAnalysisInput and fAnalysisOutput. By default it is './'.
void FlagAsBad(Int_t crit, TH1F *inhisto, Double_t nsigma=4., Int_t dnbins=200, Double_t dmaxval=-1.)
TList * fOutputListBad
! list with bad channel amplitudes, stored in fRootFile
Bool_t IsCoveredByTRD(Int_t row, Int_t collumn)
TH1F * fhCellFlag
! histogram that stores by which flag the cell has been excluded
TString fExternalFileName
If you have already a file that contains many runs merged together you can place it in fMergeOutput a...
TString fPeriod
The name of the analyzed period.
void PlotFlaggedCells2D(Int_t flagBegin, Int_t flagEnd=-1)
TH1F * BuildHitAndEnergyMean(Int_t crit, Double_t emin=0.1, Double_t emax=2., Double_t nsigma=4.)
TString fTrigger
Selected trigger for the analysis.
Bool_t CheckDistribution(TH1 *ratio, TH1 *reference)
AliAnaCaloChannelAnalysis()
Int_t fNMaxRowsAbs
Maximum No of rows in Calorimeter.
Int_t fNMaxColsAbs
Maximum No of colums in Calorimeter.
void PeriodAnalysis(Int_t criterum=7, Double_t nsigma=4.0, Double_t emin=0.1, Double_t emax=2.0)
Bool_t fTestRoutine
This is a flag, if set true will produce some extra quality check histograms.
TList * fOutputListGood
! list with good channel amplitudes, stored in fRootFile
Analyses cell properties and identifies bad cells.
TString fAnalysisOutput
The list with bad channels and histograms are saved in this folder.
ClassImp(AliAnalysisTaskCRC) AliAnalysisTaskCRC
TH1F * fhCellWarm
! histogram that stores whether the cell was marked as warm
TList * fOutputListGoodRatio
! list with good channel amplitude ratios, stored in fRootFile
Class with utils specific to calorimeter clusters/cells.
void AccessGeometry(AliVEvent *inputEvent)
TH2F * fCellAmplitude
! main histogram for the analysis. Cell ID vs. amplitude, read from the input merged file ...
void SaveBadCellsToPDF(Int_t version, TString pdfName)
TString fRunListFileName
This is the name of the file with the run numbers to be merged, by default it's 'runList.txt'.
Int_t fCurrentRunNumber
A run number of an analyzed period. This is important for the AliCalorimeterUtils initialization...
TString fRunList
Thats the full path and name of the file which contains a list of all runs to be merged together...
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