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");
454 hNEvents =(TH1F *)outputList->FindObject(
"hNEvents");
457 Printf(
"hNEvents not found");
461 nEntr = (
Int_t)hNEvents->GetEntries();
466 cout <<
" o File to small to be merged. Only N entries " << nEntr << endl;
469 cout <<
" o File with N entries " << nEntr<<
" will be merged"<< endl;
471 hCellAmplitude->Add(hAmpId);
472 hCellTime->Add(hTimeId);
473 hNEventsProcessedPerRun->Add(hNEvents);
478 TFile *singleRunFile = TFile::Open(singleRunFileName,
"recreate");
479 hNEventsProcessedPerRun->Write();
480 hCellAmplitude->Write();
482 singleRunFile->Close();
484 outputList->Delete();
491 cout<<
"o o o Save the merged histogramms to .root file with name: "<<
fMergedFileName<<endl;
492 cout<<
"o o o "<<nEntrTot<<
" events were merged"<<endl;
494 hNEventsProcessedPerRun->Write();
495 hCellAmplitude->Write();
498 cout<<
"o o o End conversion process o o o"<<endl;
520 PeriodAnalysis(periodArray.At(0),periodArray.At(1),periodArray.At(2),periodArray.At(3));
525 cout<<
"o o o End of bad channel analysis o o o"<<endl;
541 periodArray.AddAt((
Double_t)criteria,0);
542 periodArray.AddAt(nsigma,1);
543 periodArray.AddAt(emin,2);
544 periodArray.AddAt(emax,3);
566 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;
567 cout<<
"o o o PeriodAnalysis for flag "<<criterion<<
" o o o"<<endl;
568 if(criterion < 3)cout<<
"o o o Done in the energy range E "<<emin<<
" - "<<emax<<endl;
569 if(criterion == 3)cout<<
"o o o Done in the time range t "<<emin<<
" - "<<emax<<endl;
580 cout<<
"o o o Analyze average cell distributions o o o"<<endl;
583 if(criterion == 3) histogram =
BuildTimeMean(criterion, emin, emax);
595 if(emin>0.49)range=0.05;
596 if(emin>0.99)range=0.01;
597 if(emin>1.99)range=0.0002;
600 if(criterion==1)
FlagAsBad(criterion, histogram, nsigma, 400,-1);
601 if(criterion==2)
FlagAsBad(criterion, histogram, nsigma, 600,range);
602 if(criterion==3)
FlagAsBad(criterion, histogram, nsigma, 600,30);
622 cout<<
" o Calculate average cell hit per event and average cell energy per hit "<<endl;
624 if(crit==1)histogram =
new TH1F(Form(
"hCellEtoN_E%.2f-%.2f",emin,emax),Form(
"Energy per hit, %.2f < E < %.2f GeV",emin,emax),
fNoOfCells,0,
fNoOfCells);
625 if(crit==2)histogram =
new TH1F(Form(
"hCellNtoEvt_E%.2f-%.2f",emin,emax),Form(
"Number of hits per event, %.2f < E < %.2f GeV",emin,emax),
fNoOfCells,0,
fNoOfCells);
626 histogram->SetXTitle(
"Abs. Cell Id");
627 if(crit==1)histogram->SetYTitle(
"Energy per hit");
628 if(crit==2)histogram->SetYTitle(
"Number of hits per event");
629 histogram->GetXaxis()->SetNdivisions(510);
643 if (E < emin || E > emax ||
fFlag[cell]!=0)
continue;
650 if(totalevents> 0. && crit==2)histogram->SetBinContent(cell+1, Nsum/totalevents);
651 if(Nsum > 0. && crit==1)histogram->SetBinContent(cell+1, Esum/Nsum);
663 cout<<
" o Calculate maximum of cell time distribution "<<endl;
666 histogram =
new TH1F(Form(
"timeMax_t%.2f-%.2f",tmin,tmax),Form(
"Maximum of time distr., %.2f < t < %.2f GeV",tmin,tmax),
fNoOfCells,0,
fNoOfCells);
667 histogram->SetXTitle(
"Abs. Cell Id");
668 histogram->SetYTitle(
"time max");
669 histogram->GetXaxis()->SetNdivisions(510);
677 name=Form(
"Cell %d",cell);
679 TH1 *hCell =
fCellTime->ProjectionX(name,cell+1,cell+1);
680 hCell->GetXaxis()->SetRangeUser(tmin,tmax);
682 timeMax = hCell->GetXaxis()->GetBinCenter(hCell->GetMaximumBin());
683 if(cell>55 &&cell<65)cout<<
"Integral: "<<hCell->Integral()<<endl;
684 if(hCell->Integral()<=0)timeMax=-40;
688 histogram->SetBinContent(cell+1, timeMax);
692 histogram->SetBinContent(cell+1, -50);
720 if(nSum < 0.5 &&
fFlag[cell]==0)
728 cout<<
" o Number of dead cells: "<<sumOfExcl<<endl;
729 cout<<
" ("<<sumOfExcl<<
")"<<endl;
749 gStyle->SetOptStat(0);
750 gStyle->SetOptFit(0);
752 if(crit==1)cout<<
" o Fit average energy per hit distribution"<<endl;
753 if(crit==2)cout<<
" o Fit average hit per event distribution"<<endl;
754 if(crit==3)cout<<
" o Fit average hit maximum distribution"<<endl;
756 Int_t cellColumn=0,cellRow=0;
757 Int_t cellColumnAbs=0,cellRowAbs=0;
760 TString histoName=inhisto->GetName();
763 Double_t dminVal=inhisto->GetMinimum();
766 dmaxVal = inhisto->GetMaximum()*1.01;
767 if(crit==2 && dmaxVal > 1) dmaxVal =1. ;
778 if(((dmaxVal-inhisto->GetMinimum())/(dnbins*1.0))<1.0/totalevents)
780 dnbins=(dmaxVal-inhisto->GetMinimum())*totalevents;
781 cout<<
"Problem - Reset dnbins to new value:"<<dnbins<<endl;
788 dnbins =
fCellTime->GetXaxis()->GetNbins();
789 dminVal=
fCellTime->GetXaxis()->GetBinCenter(1)-(binWidth*1.0)/2.0;
790 dmaxVal=
fCellTime->GetXaxis()->GetBinCenter(dnbins)+(binWidth*1.0)/2.0;
792 cout<<
"set the new histo with following settings- bins: "<<dnbins<<
", min val = "<<dminVal<<
", max val:"<<dmaxVal<<endl;
795 TH1F *distrib =
new TH1F(Form(
"%sDistr",(
const char*)histoName),
"", dnbins, dminVal, dmaxVal);
796 distrib->SetXTitle(inhisto->GetYaxis()->GetTitle());
797 distrib->SetYTitle(
"Entries");
798 TH1F *distrib_wTRDStruc =
new TH1F(Form(
"%sDistr_wTRD",(
const char*)histoName),
"", dnbins, dminVal, dmaxVal);
799 TH1F *distrib_woTRDStruc=
new TH1F(Form(
"%sDistr_woTRD",(
const char*)histoName),
"", dnbins, dminVal, dmaxVal);
804 plot2D->GetXaxis()->SetTitle(
"cell column (#eta direction)");
805 plot2D->GetYaxis()->SetTitle(
"cell row (#phi direction)");
816 distrib->Fill(inhisto->GetBinContent(cell+1));
823 cout<<
"Problem! wrong calculated number of max col and max rows"<<endl;
824 cout<<
"current col: "<<cellColumnAbs<<
", max col"<<
fNMaxColsAbs<<endl;
825 cout<<
"current row: "<<cellRowAbs<<
", max row"<<
fNMaxRowsAbs<<endl;
827 plot2D->SetBinContent(cellColumnAbs,cellRowAbs,inhisto->GetBinContent(cell+1));
831 distrib_wTRDStruc->Fill(inhisto->GetBinContent(cell+1));
835 distrib_woTRDStruc ->Fill(inhisto->GetBinContent(cell+1));
844 TCanvas *c1 =
new TCanvas(histoName,histoName,900,900);
845 c1->ToggleEventStatus();
846 TPad* upperPad =
new TPad(
"upperPad",
"upperPad",.005, .5, .995, .995);
847 TPad* lowerPadLeft =
new TPad(
"lowerPadL",
"lowerPadL",.005, .005, .5, .5);
848 TPad* lowerPadRight =
new TPad(
"lowerPadR",
"lowerPadR",.5, .005, .995, .5);
850 lowerPadLeft->Draw();
851 lowerPadRight->Draw();
854 upperPad->SetLeftMargin(0.05);
855 upperPad->SetRightMargin(0.05);
856 if(crit<3)upperPad->SetLogy();
857 inhisto->SetTitleOffset(0.6,
"Y");
858 inhisto->GetXaxis()->SetRangeUser(0,fNoOfCells+1);
859 inhisto->GetYaxis()->SetTitleOffset(0.7);
860 inhisto->SetLineColor(kBlue+1);
864 lowerPadRight->SetLeftMargin(0.09);
865 lowerPadRight->SetRightMargin(0.12);
866 plot2D->GetYaxis()->SetTitleOffset(1.3);
867 plot2D->Draw(
"colz");
870 lowerPadLeft->SetLeftMargin(0.09);
871 lowerPadLeft->SetRightMargin(0.07);
872 lowerPadLeft->SetLogy();
873 distrib->SetLineColor(kBlue+1);
874 distrib->GetYaxis()->SetTitleOffset(1.3);
876 distrib_wTRDStruc->SetLineColor(kGreen+1);
877 distrib_wTRDStruc->DrawCopy(
"same");
878 distrib_woTRDStruc->SetLineColor(kMagenta+1);
879 distrib_woTRDStruc->DrawCopy(
"same");
885 for(i = 2; i <= dnbins; i++)
887 if(distrib->GetBinContent(higherbin) < distrib->GetBinContent(i)) higherbin = i ;
891 for(i = higherbin ; i<=dnbins ; i++)
893 if(distrib->GetBinContent(i)<2)
break ;
894 goodmax = distrib->GetBinCenter(i);
896 for(i = higherbin ; i>1 ; i--)
898 if(distrib->GetBinContent(i)<2)
break ;
899 goodmin = distrib->GetBinLowEdge(i);
904 Int_t maxFitRange=10;
905 if(crit==3)minFitRange=-20;
906 if(crit==3)maxFitRange=20;
908 TF1 *fit2 =
new TF1(
"fit2",
"gaus",minFitRange,maxFitRange);
910 fit2->SetParameter(1,higherbin);
912 distrib->Fit(fit2,
"0LQEM",
"", goodmin, goodmax);
915 mean = fit2->GetParameter(1);
916 sig = fit2->GetParameter(2);
920 if(crit<3 && mean <0.) mean=0.;
922 goodmin = mean - nsigma*sig ;
923 goodmax = mean + nsigma*sig ;
926 if(crit<3 && goodmin <0.) goodmin=0.;
928 cout<<
" o Result of fit: "<<endl;
930 cout<<
" o Mean: "<<mean <<
" sigma: "<<sig<<endl;
931 cout<<
" o good range : "<<goodmin <<
" - "<<goodmax<<endl;
936 TLine *lline =
new TLine(goodmin, 0, goodmin, distrib->GetMaximum());
937 lline->SetLineColor(kGreen+2);
938 lline->SetLineStyle(7);
941 TLine *rline =
new TLine(goodmax, 0, goodmax, distrib->GetMaximum());
942 rline->SetLineColor(kGreen+2);
943 rline->SetLineStyle(7);
946 TLegend *leg =
new TLegend(0.60,0.70,0.9,0.85);
947 leg->AddEntry(lline,
"Good region boundary",
"l");
948 leg->AddEntry(distrib_wTRDStruc,
"Covered by TRD",
"l");
949 leg->AddEntry(distrib_woTRDStruc,
"wo TRD structure",
"l");
950 leg->SetBorderSize(0);
953 fit2->SetLineColor(kOrange-3);
954 fit2->SetLineStyle(1);
958 if(crit==1) text =
new TLatex(0.12,0.85,Form(
"Good range: %.2f-%.2f",goodmin,goodmax));
959 if(crit==2) text =
new TLatex(0.12,0.85,Form(
"Good range: %.2f-%.2fx10^-5",goodmin*100000,goodmax*100000));
960 if(crit==3) text =
new TLatex(0.12,0.85,Form(
"Good range: %.2f-%.2f",goodmin,goodmax));
961 text->SetTextSize(0.06);
963 text->SetTextColor(1);
968 TLine *uline =
new TLine(0, goodmax,fNoOfCells,goodmax);
969 uline->SetLineColor(kGreen+2);
970 uline->SetLineStyle(7);
972 TLine *lowline =
new TLine(0, goodmin,fNoOfCells,goodmin);
973 lowline->SetLineColor(kGreen+2);
974 lowline->SetLineStyle(7);
981 if(crit==1)name=Form(
"%s/%s/AverageEperHit_%s.gif",
fWorkdir.Data(),
fAnalysisOutput.Data(), (
const char*)histoName);
982 if(crit==2)name=Form(
"%s/%s/AverageHitperEvent_%s.gif",
fWorkdir.Data(),
fAnalysisOutput.Data(), (
const char*)histoName);
983 if(crit==3)name=Form(
"%s/%s/AverageTimeMax_%s.gif",
fWorkdir.Data(),
fAnalysisOutput.Data(), (
const char*)histoName);
986 fRootFile->WriteObject(c1,c1->GetName());
987 fRootFile->WriteObject(plot2D,plot2D->GetName());
988 fRootFile->WriteObject(distrib,distrib->GetName());
989 fRootFile->WriteObject(inhisto,inhisto->GetName());
996 cout<<
" o Flag bad cells that are outside the good range "<<endl;
1001 if (inhisto->GetBinContent(cell+1) <= goodmin &&
fFlag[cell]==0)
1005 if (inhisto->GetBinContent(cell+1) > goodmax && fFlag[cell]==0)
1010 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;
1038 ofstream file2(aliceTwikiTable, ios::out | ios::trunc);
1041 file2<<
"|*Criterium* | *E_min !GeV* | *E_max !GeV* | *sigma* | *Excluded Cells* |"<<endl;
1048 criterion =periodArray.At(0);
1049 emin =periodArray.At(2);
1050 emax =periodArray.At(3);
1051 sig =periodArray.At(1);
1055 output.Form(
"%s/%s/Criterion%d_Emin-%.2f_Emax-%.2f.txt",
fWorkdir.Data(),
fAnalysisOutput.Data(), criterion,emin,emax);
1056 ofstream
file(output, ios::out | ios::trunc);
1059 cout<<
"#### Major Error. Check the textfile!"<<endl;
1061 file<<
"fFlag="<<i+2<<
"means Criterion : "<<criterion<<
", emin = "<<emin<<
" GeV"<<
", emax = "<<emax<<
" GeV"<<endl;
1062 cout<<
" o Criterion : "<<criterion<<
", emin = "<<emin<<
" GeV"<<
", emax = "<<emax<<
" GeV"<<
" (Method "<<i<<
")"<<endl;
1067 if(
fFlag[cellID]==(i+2))
1073 file<<
"Total number of bad cells with fFlag=="<<i+2<<endl;
1074 file<<
"("<<nb1<<
")"<<endl;
1076 cout<<
" o Total number of bad cells ("<<nb1<<
")"<<endl;
1081 ofstream file2(aliceTwikiTable, ios::out | ios::app);
1084 file2<<
"| "<<criterion<<
" | "<<emin<<
" | "<<emax<<
" | "<<sig<<
" | "<<nb1<<
" |"<<endl;
1098 Int_t cellID, nDeadDCalCells = 0, nDeadEMCalCells = 0, nDCalCells = 0, nEMCalCells = 0;
1099 Double_t perDeadEMCal,perDeadDCal,perBadEMCal,perBadDCal,perWarmEMCal,perWarmDCal;
1100 TString aliceTwikiTable, cellSummaryFile, deadPdfName, badPdfName, ratioOfBad,goodCells,goodCellsRatio;
1112 cout<<
" o Final results o "<<endl;
1117 ofstream
file(cellSummaryFile, ios::out | ios::trunc);
1120 file<<
"Dead cells : "<<endl;
1121 cout<<
" o Dead cells : "<<endl;
1126 file<<
"In EMCal: "<<endl;
1132 file<<
"In DCal: "<<endl;
1136 if(
fFlag[cellID]==1)
1142 else nDeadDCalCells++;
1149 file<<
"EMCal ("<<nDeadEMCalCells<<
" ="<<perDeadEMCal<<
"%), DCal ("<<nDeadDCalCells<<
" ="<<perDeadDCal<<
"%)"<<endl;
1150 cout<<
" o EMCal ("<<nDeadEMCalCells<<
" ="<<perDeadEMCal<<
"%), DCal ("<<nDeadDCalCells<<
" ="<<perDeadDCal<<
"%)"<<endl;
1152 file<<
"Bad cells: "<<endl;
1153 cout<<
" o Bad cells: "<<endl;
1158 file<<
"In EMCal: "<<endl;
1164 file<<
"In DCal: "<<endl;
1181 file<<
"EMCal ("<<nEMCalCells<<
" ="<<perBadEMCal<<
"%), DCal ("<<nDCalCells<<
" ="<<perBadDCal<<
"%)"<<endl;
1182 cout<<
" o EMCal ("<<nEMCalCells<<
" ="<<perBadEMCal<<
"%), DCal ("<<nDCalCells<<
" ="<<perBadDCal<<
"%)"<<endl;
1188 ofstream file2(aliceTwikiTable, ios::out | ios::app);
1191 file2<<
"1=energy/hit, 2= hit/event"<<endl;
1193 file2<<
"| *Detector* | *No of cells* | *percentage* |"<<endl;
1194 file2<<
"| Dead EMCal | "<<nDeadEMCalCells<<
" | "<<perDeadEMCal<<
"% |"<<endl;
1195 file2<<
"| Bad EMCal | "<<nEMCalCells<<
" | "<<perBadEMCal<<
"% |"<<endl;
1196 file2<<
"EMCal Warm cell row"<<endl;
1197 file2<<
"| Dead DCal | "<<nDeadDCalCells<<
" | "<<perDeadDCal<<
"% |"<<endl;
1198 file2<<
"| Bad DCal | "<<nDCalCells<<
" | "<<perBadDCal<<
"% |"<<endl;
1204 cout<<
" o Save the bad channel spectra to a .pdf file"<<endl;
1223 cellAmp_masked->SetBinContent(amp,cell+1,0);
1232 cellTime_masked->SetBinContent(time,cell+1,0);
1251 TCanvas *c1 =
new TCanvas(
"CellProp",
"summary of cell properties",1000,1000);
1252 c1->ToggleEventStatus();
1254 c1->cd(1)->SetLogz();
1261 c1->cd(2)->SetLogz();
1264 fCellTime->GetYaxis()->SetTitleOffset(1.6);
1266 c1->cd(3)->SetLogz();
1269 cellAmp_masked->SetTitle(
"Masked Cell Amplitude");
1270 cellAmp_masked->SetXTitle(
"Cell Energy [GeV]");
1271 cellAmp_masked->SetYTitle(
"Abs. Cell Id");
1272 cellAmp_masked->GetYaxis()->SetTitleOffset(1.6);
1273 cellAmp_masked->Draw(
"colz");
1274 c1->cd(4)->SetLogz();
1275 cellTime_masked->SetTitle(
"Masked Cell Time");
1276 cellTime_masked->SetXTitle(
"Cell Time [ns]");
1277 cellTime_masked->SetYTitle(
"Abs. Cell Id");
1278 cellTime_masked->GetYaxis()->SetTitleOffset(1.6);
1279 cellTime_masked->Draw(
"colz");
1282 TCanvas *c2 =
new TCanvas(
"CellFlag",
"summary of cell flags",1200,800);
1283 c2->ToggleEventStatus();
1288 fhCellFlag->SetYTitle(
"flag by which cell was excluded");
1301 fRootFile->WriteObject(c1,c1->GetName());
1302 fRootFile->WriteObject(c2,c2->GetName());
1313 file.open(cellSummaryFile, ios::out | ios::app);
1316 file<<
"Warm cells : "<<endl;
1317 cout<<
" o Warm cells : "<<endl;
1324 file<<
"In EMCal: "<<endl;
1329 file<<
"In DCal: "<<endl;
1341 file<<
"EMCal ("<<nEMCalCells<<
" ="<<perWarmEMCal<<
"%), DCal ("<<nDCalCells<<
" ="<<perWarmDCal<<
"%)"<<endl;
1342 cout<<
" o EMCal ("<<nEMCalCells<<
" ="<<perWarmEMCal<<
"%), DCal ("<<nDCalCells<<
" ="<<perWarmDCal<<
"%)"<<endl;
1348 ofstream file3(aliceTwikiTable, ios::out | ios::app);
1351 file3<<
"| Warm DCal | "<<nDCalCells<<
" | "<<perWarmDCal<<
"% |"<<endl;
1353 file3<<
"Insert above:"<<endl;
1354 file3<<
"| Warm EMCal | "<<nEMCalCells<<
" | "<<perWarmEMCal<<
"% |"<<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);
1405 TLatex* textA =
new TLatex(0.65,0.62,
"*test*");
1406 textA->SetTextSize(0.04);
1407 textA->SetTextColor(1);
1413 std::vector<Int_t> channelVector;
1414 channelVector.clear();
1415 cout<<
"Start printing into .pdf for version: "<<version<<endl;
1418 if(
fFlag[cell]==1 && version==0)channelVector.push_back(cell);
1419 if(
fFlag[cell]>1 && version==1)channelVector.push_back(cell);
1420 if(
fFlag[cell]==0 && version==2)channelVector.push_back(cell);
1421 if(
fFlag[cell]>1 && version==10)channelVector.push_back(cell);
1422 if(
fFlag[cell]==0 && version==20)channelVector.push_back(cell);
1424 if(cell%2000==0)cout<<
"...cell No."<<cell<<endl;
1426 if(channelVector.size()==9 || cell == fNoOfCells-1)
1431 TCanvas *c1 =
new TCanvas(
"badcells",
"badcells",1000,750);
1432 if(channelVector.size() > 6) c1->Divide(3,3);
1433 else if (channelVector.size() > 3) c1->Divide(3,2);
1434 else c1->Divide(3,1);
1436 TLegend *leg =
new TLegend(0.7, 0.7, 0.9, 0.9);
1437 for(
Int_t i=0; i< (
Int_t)channelVector.size() ; i++)
1439 sprintf(name,
"Cell %d",channelVector.at(i)) ;
1440 TH1 *hCell =
fCellAmplitude->ProjectionX(name,channelVector.at(i)+1,channelVector.at(i)+1);
1441 sprintf(title,
"Cell No: %d Entries: %d",channelVector.at(i), (
Int_t)hCell->GetEntries()) ;
1444 c1->cd(i%9 + 1)->SetLogy();
1447 leg->AddEntry(hRefDistr,
"mean of good",
"l");
1448 leg->AddEntry(hCell,
"current",
"l");
1452 if(candidate==1)
fWarmCell[channelVector.at(i)]=candidate;
1455 hCell->Divide(hRefDistr);
1463 hCell->SetLineColor(kBlue+1);
1464 hCell->GetXaxis()->SetTitle(
"E (GeV)");
1465 hCell->GetYaxis()->SetTitle(
"N Entries");
1466 hCell->GetXaxis()->SetRangeUser(0.,10.);
1467 hCell->SetLineWidth(1) ;
1468 hCell->SetTitle(title);
1469 hRefDistr->SetLineColor(kGray+2);
1470 hRefDistr->SetLineWidth(1);
1472 hCell->Draw(
"hist");
1474 if(version==1 || version==10)hRefDistr->Draw(
"same") ;
1477 if(candidate==1 && (version==1 || version==10))
1479 gPad->SetFrameFillColor(kYellow-10);
1484 textA->SetTitle(Form(
"Excluded by No. %d",
fFlag[channelVector.at(i)]));
1487 if(candidate==0 && (version==2 || version==20))
1489 gPad->SetFrameFillColor(kYellow-10);
1493 if(version<2)leg->Draw();
1496 if(channelVector.size()<9 || cell == fNoOfCells-1)
1498 internal_pdfName +=
")";
1499 c1->Print(internal_pdfName.Data());
1501 else if(firstCanvas==0)
1503 internal_pdfName +=
"(";
1504 c1->Print(internal_pdfName.Data());
1509 c1->Print(internal_pdfName.Data());
1513 channelVector.clear();
1536 if(
fFlag[cell]!=0)
continue;
1538 if(NrGood==1)hgoodMean = (
TH1D*)
fCellAmplitude->ProjectionX(
"hgoodMean",cell+1,cell+1);
1542 hgoodMean->Add(hGoodAmp);
1545 hgoodMean->Scale(1.0/NrGood);
1562 TString Name = Form(
"%s_ratio",histogram->GetName());
1563 TH1* ratio=(
TH1*)histogram->Clone(Name);
1564 ratio->Divide(reference);
1576 Int_t binHeihgtOne = reference->FindLastBinAbove(1);
1577 Double_t binCentreHeightOne = reference->GetBinCenter(binHeihgtOne);
1578 Double_t thirdBinCentre = reference->GetBinCenter(3);
1587 if(ratio->FindLastBinAbove(0)<ratio->FindBin(binCentreHeightOne*percentageOfLast))
1595 ratio->GetXaxis()->SetRangeUser(thirdBinCentre,10);
1596 if(ratio->GetMaximum()>highestRatio)
1605 for(
Int_t i=2;i<binHeihgtOne;i++)
1607 mean+=ratio->GetBinContent(i);
1609 mean*=1.0/(binHeihgtOne-1);
1610 if(mean>maxMean || mean<minMean)
1621 ratio->GetXaxis()->SetRangeUser(0,binCentreHeightOne);
1622 Double_t localMaxBin=ratio->GetMaximumBin();
1624 for(
Int_t i=2;i<binHeihgtOne;i++)
1627 if(ratio->GetBinContent(i)<=0)
continue;
1628 if(i>localMaxBin-3 && i<localMaxBin+3)
continue;
1629 mean+=ratio->GetBinContent(i);
1631 mean*=1.0/(binHeihgtOne-1);
1632 ratio->GetXaxis()->SetRangeUser(thirdBinCentre,binCentreHeightOne);
1634 if(ratio->GetMaximum()>mean*higherThanMean)
1645 Int_t cliffBin = ratio->FindBin(4);
1646 for(
Int_t i=cliffBin-10;i<cliffBin+11;i++)
1649 if(ratio->GetBinContent(i)<=0)
continue;
1650 if(i<=cliffBin) binsBefore++;
1651 if(i>cliffBin) binsAfter++;
1652 if(i<=cliffBin) beforeCliff+=ratio->GetBinContent(i);
1653 if(i>cliffBin) afterCliff+=ratio->GetBinContent(i);
1654 beforeCliff*=1.0/binsBefore;
1655 afterCliff*=1.0/binsAfter;
1657 if((beforeCliff-afterCliff)>cliffSize*afterCliff)
1659 if(beforeCliff!=0 && afterCliff!=0)candidate=0;
1690 Bool_t coveredByTRDSupportStruc=0;
1692 if((collumn>3 && collumn<9) || (collumn>32 && collumn<37) || (collumn>57 && collumn<61) || (collumn>84 && collumn<90) ||
1693 (row==1) ||(row>20 && row<25) || (row>44 && row<49) || (row>68 && row<73) || (row>91 && row<96) ||
1694 (row>116 && row<120)|| row==127 || (row>148 && row<152) || (row>172 && row<177) || (row>197 && row<201)
1697 coveredByTRDSupportStruc=1;
1699 return coveredByTRDSupportStruc;
1714 histoName = Form(
"2DChannelMap_Flag%d",flagBegin);
1715 if(flagBegin==0 && flagEnd==0)histoName = Form(
"2DChannelMap_Flag100");
1718 plot2D->GetXaxis()->SetTitle(
"cell column (#eta direction)");
1719 plot2D->GetYaxis()->SetTitle(
"cell row (#phi direction)");
1721 Int_t cellColumn=0,cellRow=0;
1722 Int_t cellColumnAbs=0,cellRowAbs=0;
1734 cout<<
"Problem! wrong calculated number of max col and max rows"<<endl;
1735 cout<<
"current col: "<<cellColumnAbs<<
", max col"<<
fNMaxColsAbs<<endl;
1736 cout<<
"current row: "<<cellRowAbs<<
", max row"<<
fNMaxRowsAbs<<endl;
1738 if(flagEnd==-1 &&
fFlag[cell]==flagBegin) plot2D->SetBinContent(cellColumnAbs,cellRowAbs,1);
1739 if(flagEnd!=0 && flagEnd!=-1 &&
fFlag[cell]>=flagBegin &&
fFlag[cell]<=flagEnd)plot2D->SetBinContent(cellColumnAbs,cellRowAbs,1);
1740 if(flagBegin==0 && flagEnd==0 &&
fWarmCell[cell]==1) plot2D->SetBinContent(cellColumnAbs,cellRowAbs,1);
1744 TCanvas *c1 =
new TCanvas(histoName,histoName,500,500);
1745 c1->ToggleEventStatus();
1749 plot2D->Draw(
"colz");
1752 if(flagBegin==0 && flagEnd==-1) text =
new TLatex(0.2,0.8,
"Good Cells");
1753 if(flagBegin==1) text =
new TLatex(0.2,0.8,
"Dead Cells");
1754 if(flagBegin>1) text =
new TLatex(0.2,0.8,
"Bad Cells");
1755 if(flagBegin==0 && flagEnd==0) text =
new TLatex(0.2,0.8,
"Warm Cells");
1756 text->SetTextSize(0.06);
1758 text->SetTextColor(1);
1765 fRootFile->WriteObject(plot2D,plot2D->GetName());
1777 sprintf(name,
"Cell %d",cell) ;
TH1D * BuildMeanFromGood()
TH1F * BuildTimeMean(Int_t crit, Double_t tmin, Double_t tmax)
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
TH1F * BuildHitAndEnergyMean(Int_t crit, Double_t emin=0.1, Double_t emax=2.)
TString fAnalysisInput
Here the .root files of each run of the period are saved.
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)
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