19 #include <Riostream.h>
29 #include <AliEMCALGeometry.h>
31 #include <AliAODEvent.h>
50 fCurrentRunNumber(-1),
55 fCellStartDCal(12288),
101 fCurrentRunNumber(-1),
106 fCellStartDCal(12288),
152 gROOT->ProcessLine(
"gErrorIgnoreLevel = kWarning;");
176 fRootFile =
new TFile(fileName,
"recreate");
193 cout<<
"Number of supermod: "<<nModules<<endl;
257 cout<<
". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ."<<endl;
258 cout<<
". . .Start process by converting files. . . . . . . . . . . ."<<endl;
263 Printf(
"File not produced, exit");
271 cout<<
". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ."<<endl;
272 cout<<
". . .Start process by loading external file. . . . . . . . . . ."<<endl;
278 cout<<
". . .Load inputfile with name: "<<
fMergedFileName<<
" . . . . . . . ."<<endl;
283 if(!mergedFileInput->IsOpen())
285 Printf(
"Error! Input file not found, abort");
292 cout<<
". . .Continue process by . . . . . . . . . . . ."<<endl;
298 cout<<
"o o o Flag dead cells o o o"<<endl;
307 cout<<
"o o o Flag bad cells o o o"<<endl;
314 if(
fPrint==1)cout<<
"o o o Write .txt for each period analyis with bad cells o o o"<<endl;
317 if(
fPrint==1)cout<<
"o o o Create summary documents for the entire analysis o o o"<<endl;
328 Int_t binHeightOne = hRefDistr->FindLastBinAbove(1.0/totalevents);
329 Double_t binCentreHeightOne = hRefDistr->GetBinCenter(binHeightOne);
330 cout<<
". . .Recomendation:"<<endl;
331 cout<<
". . .With the current statistic on average a cell has 1 hit at "<<binCentreHeightOne<<
" GeV"<<endl;
332 cout<<
". . .so it makes no sense to select energy ranges >"<<binCentreHeightOne<<
" as cells will be"<<endl;
333 cout<<
". . .marked bad just due to the lack of statistic"<<endl;
334 cout<<
". . .End of process . . . . . . . . . . . . . . . . . . . . ."<<endl;
335 cout<<
". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ."<<endl;
348 cout<<
"o o o Start conversion process o o o"<<endl;
352 TH1F *hNEventsProcessedPerRun=
new TH1F(
"hNEvents",
"Number of processed events in analyzed runs",1,0,1);
353 TH2F *hCellAmplitude;
357 cout<<
"o o o Open .txt file with run indices. Name = " <<
fRunList << endl;
358 FILE *pFile = fopen(
fRunList.Data(),
"r");
361 cout<<
"couldn't open file!"<<endl;
372 ncols = fscanf(pFile,
" %d ",&q);
381 const Int_t nRun = nlines ;
386 cout<<
"o o o Start merging process of " << nRun <<
" files"<< endl;
389 for(
Int_t i = 0 ; i < nRun ; i++)
393 infile = Form(
"%s.root",base.Data()) ;
395 cout<<
" o Open .root file with name: "<<infile<<endl;
396 TFile *f = TFile::Open(infile);
401 cout<<
"Couldn't open/find .root file: "<<infile<<endl;
404 TDirectoryFile *
dir = (TDirectoryFile *)f->Get(
fQADirect);
407 cout<<
"Couln't open directory file in .root file: "<<infile<<
", directory: "<<
fQADirect<<endl;
413 cout <<
"Couln't get TList from directory file: "<<
fQADirect<<endl;
421 hAmpId =(
TH2F*)outputList->FindObject(
"EMCAL_hAmpId");
424 Printf(
"hAmpId not found");
430 hAmpId->SetName(
"hCellAmplitude");
431 hAmpId->SetTitle(
"Cell Amplitude");
434 hTimeId =(
TH2F*)outputList->FindObject(
"EMCAL_hTimeId");
437 Printf(
"hTimeId not found");
443 hTimeId->SetName(
"hCellTime");
444 hTimeId->SetTitle(
"Cell Time");
450 hCellAmplitude=(
TH2F*)hAmpId->Clone(
"DummyName1");
451 hCellAmplitude->Reset();
452 hCellAmplitude->SetDirectory(0);
454 hCellTime=(
TH2F*)hTimeId->Clone(
"DummyName2");
456 hCellTime->SetDirectory(0);
459 hNEvents =(TH1F *)outputList->FindObject(
"hNEvents");
462 Printf(
"hNEvents not found");
466 nEntr = (
Int_t)hNEvents->GetEntries();
471 cout <<
" o File to small to be merged. Only N entries " << nEntr << endl;
474 cout <<
" o File with N entries " << nEntr<<
" will be merged"<< endl;
476 hCellAmplitude->Add(hAmpId);
477 hCellTime->Add(hTimeId);
478 hNEventsProcessedPerRun->Add(hNEvents);
483 TFile *singleRunFile = TFile::Open(singleRunFileName,
"recreate");
490 singleRunFile->Close();
492 outputList->Delete();
501 cout<<
"o o o Save the merged histogramms to .root file with name: "<<
fMergedFileName<<endl;
502 cout<<
"o o o "<<nEntrTot<<
" events were merged"<<endl;
506 hNEventsProcessedPerRun->Write();
507 hCellAmplitude->SetName(
"hCellAmplitude");
508 hCellAmplitude->SetTitle(
"Cell Amplitude");
509 hCellAmplitude->Write();
510 hCellTime->SetName(
"hCellTime");
511 hCellTime->SetTitle(
"Cell Time");
514 cout<<
"o o o End conversion process o o o"<<endl;
541 PeriodAnalysis(periodArray.At(0),periodArray.At(1),periodArray.At(2),periodArray.At(3));
546 cout<<
"o o o End of bad channel analysis o o o"<<endl;
562 periodArray.AddAt((
Double_t)criteria,0);
563 periodArray.AddAt(nsigma,1);
564 periodArray.AddAt(emin,2);
565 periodArray.AddAt(emax,3);
587 if(
fPrint==1)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;
588 if(
fPrint==1)cout<<
"o o o PeriodAnalysis for flag "<<criterion<<
" o o o"<<endl;
589 if(
fPrint==1 && criterion < 3)cout<<
"o o o Done in the energy range E "<<emin<<
" - "<<emax<<endl;
590 if(
fPrint==1 && criterion == 3)cout<<
"o o o Done in the time range t "<<emin<<
" - "<<emax<<endl;
601 if(
fPrint==1)cout<<
"o o o Analyze average cell distributions o o o"<<endl;
604 if(criterion == 3) histogram =
BuildTimeMean(criterion, emin, emax);
608 if(emin>2)
FlagAsBad(criterion, histogram, nsigma, -1);
609 else FlagAsBad(criterion, histogram, nsigma, 400);
613 if(emin>2)
FlagAsBad(criterion, histogram, nsigma, -1);
614 else FlagAsBad(criterion, histogram, nsigma, 601);
618 if(criterion==3)
FlagAsBad(criterion, histogram, nsigma, 602);
632 if(
fPrint==1)cout<<
" o Calculate average cell hit per event and average cell energy per hit "<<endl;
634 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);
635 if(crit==2)histogram =
new TH1F(Form(
"hCellNtoEvt_E%.2f-%.2f",emin,emax),Form(
"Number of hits in cell, %.2f < E < %.2f GeV",emin,emax),
fNoOfCells,0,
fNoOfCells);
636 histogram->SetXTitle(
"Abs. Cell Id");
637 if(crit==1)histogram->SetYTitle(
"Energy per hit");
638 if(crit==2)histogram->SetYTitle(
"Number of hits in cell");
639 histogram->GetXaxis()->SetNdivisions(510);
642 TH1F* pojection = (TH1F*)
fCellAmplitude->ProjectionX(
"Intermediate");
643 fnEventsInRange = pojection->Integral(pojection->GetBinContent(emin),pojection->GetBinContent(emax));
657 if (E < emin || E > emax ||
fFlag[cell]!=0)
continue;
664 if(crit==2) histogram->SetBinContent(cell+1, Nsum);
665 if(Nsum > 0. && crit==1)histogram->SetBinContent(cell+1, Esum/(Nsum));
677 if(
fPrint==1)cout<<
" o Calculate maximum of cell time distribution "<<endl;
680 histogram =
new TH1F(Form(
"timeMax_t%.2f-%.2f",tmin,tmax),Form(
"Maximum of time distr., %.2f < t < %.2f GeV",tmin,tmax),
fNoOfCells,0,
fNoOfCells);
681 histogram->SetXTitle(
"Abs. Cell Id");
682 histogram->SetYTitle(
"time max");
683 histogram->GetXaxis()->SetNdivisions(510);
690 name=Form(
"Cell %d",cell);
692 TH1 *hCell =
fCellTime->ProjectionX(name,cell+1,cell+1);
693 hCell->GetXaxis()->SetRangeUser(tmin,tmax);
695 timeMax = hCell->GetXaxis()->GetBinCenter(hCell->GetMaximumBin());
696 if(cell>55 &&cell<65)cout<<
"Integral: "<<hCell->Integral()<<endl;
697 if(hCell->Integral()<=0)timeMax=-40;
701 histogram->SetBinContent(cell+1, timeMax);
705 histogram->SetBinContent(cell+1, -50);
720 Int_t manualMaskCounter=0;
737 if(nSum == 0 &&
fFlag[cell]==0)
751 if(
fPrint==1)cout<<
" o Number of dead cells: "<<sumOfExcl<<endl;
752 if(
fPrint==1)cout<<
" ("<<sumOfExcl<<
")"<<endl;
772 gStyle->SetOptStat(0);
773 gStyle->SetOptFit(0);
774 if(
fPrint==1 && crit==1)cout<<
" o Fit average energy per hit distribution"<<endl;
775 if(
fPrint==1 && crit==2)cout<<
" o Fit average hit per event distribution"<<endl;
776 if(
fPrint==1 && crit==3)cout<<
" o Fit average hit maximum distribution"<<endl;
778 Int_t cellColumn=0,cellRow=0;
779 Int_t cellColumnAbs=0,cellRowAbs=0;
782 TString histoName=inhisto->GetName();
787 Double_t dminVal = inhisto->GetMinimum(0);
788 Double_t dmaxVal = inhisto->GetMaximum();
794 if(crit==2 && inputBins==-1) dnbins=dmaxVal-dminVal;
795 if(crit==1 && inputBins==-1) dnbins=400;
797 if(crit==2 && inputBins!=-1)
800 Int_t numBins = inhisto->GetXaxis()->GetNbins();
805 for (
int i = 0; i < numBins; i++)
811 Double_t medianOfHisto = TMath::Median(numBins,x,y);
816 if(medianOfHisto*10<dmaxVal)
819 dmaxVal=medianOfHisto+0.2*(dmaxVal-medianOfHisto);
821 dnbins=dmaxVal-dminVal;
823 if(dmaxVal-dminVal>100)
825 if(dnbins>2000)dnbins=0.01*(dmaxVal-dminVal);
826 if(dnbins>2000)dnbins=0.001*(dmaxVal-dminVal);
827 if(dnbins<100) dnbins=0.02*(dmaxVal-dminVal);
835 dnbins =
fCellTime->GetXaxis()->GetNbins();
836 dminVal=
fCellTime->GetXaxis()->GetBinCenter(1)-(binWidth*1.0)/2.0;
837 dmaxVal=
fCellTime->GetXaxis()->GetBinCenter(dnbins)+(binWidth*1.0)/2.0;
838 cout<<
"set the new histo with following settings- bins: "<<dnbins<<
", min val = "<<dminVal<<
", max val:"<<dmaxVal<<endl;
841 TH1F *distrib =
new TH1F(Form(
"%sDistr",(
const char*)histoName),
"", dnbins, dminVal, dmaxVal);
842 distrib->SetXTitle(inhisto->GetYaxis()->GetTitle());
843 distrib->SetYTitle(
"Entries");
844 TH1F *distrib_wTRDStruc =
new TH1F(Form(
"%sDistr_wTRD",(
const char*)histoName),
"", dnbins, dminVal, dmaxVal);
845 TH1F *distrib_woTRDStruc=
new TH1F(Form(
"%sDistr_woTRD",(
const char*)histoName),
"", dnbins, dminVal, dmaxVal);
849 plot2D->GetXaxis()->SetTitle(
"cell column (#eta direction)");
850 plot2D->GetYaxis()->SetTitle(
"cell row (#phi direction)");
864 distrib->Fill(inhisto->GetBinContent(cell+1));
871 cout<<
"Problem! wrong calculated number of max col and max rows"<<endl;
872 cout<<
"current col: "<<cellColumnAbs<<
", max col"<<
fNMaxColsAbs<<endl;
873 cout<<
"current row: "<<cellRowAbs<<
", max row"<<
fNMaxRowsAbs<<endl;
875 plot2D->SetBinContent(cellColumnAbs,cellRowAbs,inhisto->GetBinContent(cell+1));
879 distrib_wTRDStruc->Fill(inhisto->GetBinContent(cell+1));
883 distrib_woTRDStruc ->Fill(inhisto->GetBinContent(cell+1));
891 TCanvas *c1 =
new TCanvas(histoName,histoName,900,900);
892 c1->ToggleEventStatus();
893 TPad* upperPad =
new TPad(
"upperPad",
"upperPad",.005, .5, .995, .995);
894 TPad* lowerPadLeft =
new TPad(
"lowerPadL",
"lowerPadL",.005, .005, .5, .5);
895 TPad* lowerPadRight =
new TPad(
"lowerPadR",
"lowerPadR",.5, .005, .995, .5);
897 lowerPadLeft->Draw();
898 lowerPadRight->Draw();
901 upperPad->SetLeftMargin(0.05);
902 upperPad->SetRightMargin(0.05);
903 if(crit<3)upperPad->SetLogy();
904 inhisto->SetTitleOffset(0.6,
"Y");
905 inhisto->GetXaxis()->SetRangeUser(0,fNoOfCells+1);
906 inhisto->GetYaxis()->SetTitleOffset(0.7);
907 inhisto->SetLineColor(kBlue+1);
911 lowerPadRight->SetLeftMargin(0.09);
912 lowerPadRight->SetRightMargin(0.12);
913 plot2D->GetYaxis()->SetTitleOffset(1.3);
914 plot2D->Draw(
"colz");
917 lowerPadLeft->SetLeftMargin(0.09);
918 lowerPadLeft->SetRightMargin(0.07);
919 lowerPadLeft->SetLogy();
920 distrib->SetLineColor(kBlue+1);
921 distrib->GetYaxis()->SetTitleOffset(1.3);
923 distrib_wTRDStruc->SetLineColor(kGreen+1);
924 distrib_wTRDStruc->DrawCopy(
"same");
925 distrib_woTRDStruc->SetLineColor(kMagenta+1);
926 distrib_woTRDStruc->DrawCopy(
"same");
933 distrib->GetXaxis()->SetRangeUser(distrib->GetBinCenter(2),distrib->GetBinCenter(dnbins));
934 Double_t maxDistr = distrib->GetMaximum();
935 Int_t maxBin = distrib->GetMaximumBin();
936 Double_t maxCenter = distrib->GetBinCenter(maxBin);
940 for(
Int_t i = maxBin ; i<=dnbins ; i++)
942 if(distrib->GetBinContent(i)<2)
break ;
943 goodmax = distrib->GetBinCenter(i);
945 for(
Int_t i = maxBin ; i>2 ; i--)
947 if(distrib->GetBinContent(i)<2)
break ;
948 goodmin = distrib->GetBinLowEdge(i);
957 if(crit==3)minFitRange=-20;
958 if(crit==3)maxFitRange=20;
963 TF1 *fit2 =
new TF1(
"fit2",
"gaus",minFitRange,maxFitRange);
965 fit2->SetParLimits(0,0,maxDistr);
966 fit2->SetParameter(1,maxCenter);
967 fit2->SetParLimits(1,0,dmaxVal);
970 distrib->Fit(fit2,
"0LQEM",
"", minFitRange, maxFitRange);
972 mean = fit2->GetParameter(1);
973 sig = fit2->GetParameter(2);
976 if(crit<3 && mean <0.) mean=0.;
978 goodmin = mean - nsigma*sig ;
979 goodmax = mean + nsigma*sig ;
981 if(crit<3 && goodmin <0.) goodmin=0.;
982 if(inputBins==-1) goodmin=-1;
984 if(
fPrint==1)cout<<
" o Result of fit: "<<endl;
985 if(
fPrint==1)cout<<
" o "<<endl;
986 if(
fPrint==1)cout<<
" o Mean: "<<mean <<
" sigma: "<<sig<<endl;
987 if(
fPrint==1)cout<<
" o good range : "<<goodmin <<
" - "<<goodmax<<endl;
992 TLine *lline =
new TLine(goodmin, 0, goodmin, distrib->GetMaximum());
993 lline->SetLineColor(kGreen+2);
994 lline->SetLineStyle(7);
997 TLine *rline =
new TLine(goodmax, 0, goodmax, distrib->GetMaximum());
998 rline->SetLineColor(kGreen+2);
999 rline->SetLineStyle(7);
1002 TLegend *leg =
new TLegend(0.60,0.70,0.9,0.85);
1003 leg->AddEntry(lline,
"Good region boundary",
"l");
1004 leg->AddEntry(distrib_wTRDStruc,
"Covered by TRD",
"l");
1005 leg->AddEntry(distrib_woTRDStruc,
"wo TRD structure",
"l");
1006 leg->SetBorderSize(0);
1009 fit2->SetLineColor(kOrange-3);
1010 fit2->SetLineStyle(1);
1014 if(crit==1) text =
new TLatex(0.12,0.85,Form(
"Good range: %.2f-%.2f",goodmin,goodmax));
1015 if(crit==2) text =
new TLatex(0.12,0.85,Form(
"Good range: %.2f-%.2f",goodmin,goodmax));
1016 if(crit==3) text =
new TLatex(0.12,0.85,Form(
"Good range: %.2f-%.2f",goodmin,goodmax));
1017 text->SetTextSize(0.06);
1019 text->SetTextColor(1);
1023 TLine *uline =
new TLine(0, goodmax,fNoOfCells,goodmax);
1024 uline->SetLineColor(kGreen+2);
1025 uline->SetLineStyle(7);
1027 TLine *lowline =
new TLine(0, goodmin,fNoOfCells,goodmin);
1028 lowline->SetLineColor(kGreen+2);
1029 lowline->SetLineStyle(7);
1036 if(crit==1)name=Form(
"%s/%s/AverageEperHit_%s.gif",
fWorkdir.Data(),
fAnalysisOutput.Data(), (
const char*)histoName);
1037 if(crit==2)name=Form(
"%s/%s/AverageHitperEvent_%s.gif",
fWorkdir.Data(),
fAnalysisOutput.Data(), (
const char*)histoName);
1038 if(crit==3)name=Form(
"%s/%s/AverageTimeMax_%s.gif",
fWorkdir.Data(),
fAnalysisOutput.Data(), (
const char*)histoName);
1041 fRootFile->WriteObject(c1,c1->GetName());
1042 fRootFile->WriteObject(plot2D,plot2D->GetName());
1043 fRootFile->WriteObject(distrib,distrib->GetName());
1044 fRootFile->WriteObject(inhisto,inhisto->GetName());
1051 if(
fPrint==1)cout<<
" o Flag bad cells that are outside the good range "<<endl;
1056 if(inhisto->GetBinContent(cell+1) <= goodmin &&
fFlag[cell]==0)
1061 if(inhisto->GetBinContent(cell+1) > goodmax && fFlag[cell]==0)
1067 if(
fPrint==1)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;
1093 ofstream file2(aliceTwikiTable, ios::out | ios::trunc);
1096 file2<<
"|*Criterium* | *E_min !GeV* | *E_max !GeV* | *sigma* | *Excluded Cells* |"<<endl;
1103 criterion =periodArray.At(0);
1104 emin =periodArray.At(2);
1105 emax =periodArray.At(3);
1106 sig =periodArray.At(1);
1110 output.Form(
"%s/%s/Criterion%d_Emin-%.2f_Emax-%.2f.txt",
fWorkdir.Data(),
fAnalysisOutput.Data(), criterion,emin,emax);
1111 ofstream
file(output, ios::out | ios::trunc);
1114 cout<<
"#### Major Error. Check the textfile!"<<endl;
1116 file<<
"fFlag="<<i+2<<
"means Criterion : "<<criterion<<
", emin = "<<emin<<
" GeV"<<
", emax = "<<emax<<
" GeV"<<endl;
1117 if(
fPrint==1)cout<<
" o Criterion : "<<criterion<<
", emin = "<<emin<<
" GeV"<<
", emax = "<<emax<<
" GeV"<<
" (Method "<<i<<
")"<<endl;
1122 if(
fFlag[cellID]==(i+2))
1128 file<<
"Total number of bad cells with fFlag=="<<i+2<<endl;
1129 file<<
"("<<nb1<<
")"<<endl;
1131 if(
fPrint==1)cout<<
" o Total number of bad cells ("<<nb1<<
")"<<endl;
1136 ofstream file2(aliceTwikiTable, ios::out | ios::app);
1139 file2<<
"| "<<criterion<<
" | "<<emin<<
" | "<<emax<<
" | "<<sig<<
" | "<<nb1<<
" |"<<endl;
1153 Int_t cellID, nDeadDCalCells = 0, nDeadEMCalCells = 0, nDCalCells = 0, nEMCalCells = 0;
1154 Double_t perDeadEMCal,perDeadDCal,perBadEMCal,perBadDCal,perWarmEMCal,perWarmDCal;
1155 TString aliceTwikiTable, cellSummaryFile, deadPdfName, badPdfName, ratioOfBad,goodCells,goodCellsRatio,cellProp;
1168 cout<<
" o Final results o "<<endl;
1180 cellAmp_masked->SetBinContent(amp,cell+1,0);
1189 cellTime_masked->SetBinContent(time,cell+1,0);
1196 TCanvas *c1 =
new TCanvas(
"CellProp",
"I summary of cell properties",1000,1000);
1197 c1->ToggleEventStatus();
1199 c1->cd(1)->SetLogz();
1206 c1->cd(2)->SetLogz();
1209 fCellTime->GetYaxis()->SetTitleOffset(1.6);
1211 c1->cd(3)->SetLogz();
1214 cellAmp_masked->SetTitle(
"Masked Cell Amplitude");
1215 cellAmp_masked->SetXTitle(
"Cell Energy [GeV]");
1216 cellAmp_masked->SetYTitle(
"Abs. Cell Id");
1217 cellAmp_masked->GetYaxis()->SetTitleOffset(1.6);
1218 cellAmp_masked->Draw(
"colz");
1219 c1->cd(4)->SetLogz();
1220 cellTime_masked->SetTitle(
"Masked Cell Time");
1221 cellTime_masked->SetXTitle(
"Cell Time [ns]");
1222 cellTime_masked->SetYTitle(
"Abs. Cell Id");
1223 cellTime_masked->GetYaxis()->SetTitleOffset(1.6);
1224 cellTime_masked->Draw(
"colz");
1227 TCanvas *c1_ratio =
new TCanvas(
"CellPropRatio",
"II summary of cell properties ratio",1000,500);
1228 c1_ratio->ToggleEventStatus();
1229 c1_ratio->Divide(2);
1230 c1_ratio->cd(1)->SetLogz();
1231 cellAmp_masked->SetTitle(
"Masked Cell Amplitude");
1232 cellAmp_masked->GetZaxis()->SetRangeUser(0.0001,10e7);
1233 cellAmp_masked->Draw(
"colz");
1234 c1_ratio->cd(2)->SetLogz();
1237 TH2F* ratio2DAmp =(
TH2F*)cellAmp_masked->Clone(
"ratio2DAmp");
1238 TH2F* Sum2DIdeal =(
TH2F*)cellAmp_masked->Clone(
"Sum2DIdeal");
1239 Sum2DIdeal->Reset();
1243 for(
Int_t eBin=0;eBin<Sum2DIdeal->GetNbinsX();eBin++)
1245 Double_t binVal=hRefDistr->GetBinContent(eBin+1);
1246 for(
Int_t icell=0;icell<Sum2DIdeal->GetNbinsY();icell++)
1248 Sum2DIdeal->SetBinContent(eBin+1,icell+1,binVal);
1251 ratio2DAmp->SetTitle(
"Ratio of cell Amplitude to mean cell ampl.");
1252 ratio2DAmp->Divide(Sum2DIdeal);
1253 ratio2DAmp->GetZaxis()->UnZoom();
1254 ratio2DAmp->Draw(
"colz");
1256 TCanvas *c1_proj =
new TCanvas(
"CellPropPProj",
"III summary of cell properties",1000,500);
1257 c1_proj->ToggleEventStatus();
1259 c1_proj->cd(1)->SetLogy();
1260 TH1* projEnergyMask = cellAmp_masked->ProjectionX(Form(
"%sMask_Proj",cellAmp_masked->GetName()),
fStartCell,fNoOfCells);
1261 projEnergyMask->SetXTitle(
"Cell Energy [GeV]");
1262 projEnergyMask->GetYaxis()->SetTitleOffset(1.6);
1263 projEnergyMask->SetLineColor(kTeal+3);
1264 projEnergyMask->DrawCopy(
" hist");
1267 projEnergy->DrawCopy(
"same hist");
1269 c1_proj->cd(2)->SetLogy();
1270 TH1* projTimeMask = cellTime_masked->ProjectionX(Form(
"%s_Proj",cellTime_masked->GetName()),
fStartCell,fNoOfCells);
1271 projTimeMask->SetXTitle(
"Cell Time [ns]");
1272 projTimeMask->GetYaxis()->SetTitleOffset(1.6);
1273 projTimeMask->SetLineColor(kGreen+3);
1274 projTimeMask->DrawCopy(
"hist");
1276 projTime->DrawCopy(
"same hist");
1280 c1 ->Print(Form(
"%s(",cellProp.Data()));
1281 c1_ratio ->Print(Form(
"%s",cellProp.Data()));
1282 c1_proj ->Print(Form(
"%s)",cellProp.Data()));
1288 cellAmp_masked ->Scale(1.0/totalevents);
1294 ofstream
file(cellSummaryFile, ios::out | ios::trunc);
1297 file<<
"Dead cells : "<<endl;
1298 cout<<
" o Dead cells : "<<endl;
1303 file<<
"In EMCal: "<<endl;
1308 file<<
"In DCal: "<<endl;
1310 if(
fFlag[cellID]==1)
1314 else nDeadDCalCells++;
1320 file<<
"EMCal ("<<nDeadEMCalCells<<
" ="<<perDeadEMCal<<
"%), DCal ("<<nDeadDCalCells<<
" ="<<perDeadDCal<<
"%)"<<endl;
1321 cout<<
" o EMCal ("<<nDeadEMCalCells<<
" ="<<perDeadEMCal<<
"%), DCal ("<<nDeadDCalCells<<
" ="<<perDeadDCal<<
"%)"<<endl;
1323 file<<
"Bad cells: "<<endl;
1324 cout<<
" o Bad cells: "<<endl;
1329 file<<
"In EMCal: "<<endl;
1334 file<<
"In DCal: "<<endl;
1346 file<<
"EMCal ("<<nEMCalCells<<
" ="<<perBadEMCal<<
"%), DCal ("<<nDCalCells<<
" ="<<perBadDCal<<
"%)"<<endl;
1347 cout<<
" o EMCal ("<<nEMCalCells<<
" ="<<perBadEMCal<<
"%), DCal ("<<nDCalCells<<
" ="<<perBadDCal<<
"%)"<<endl;
1354 if(
fPrint==1)cout<<
" o Save the bad channel spectra to a .pdf file"<<endl;
1368 TCanvas *c2 =
new TCanvas(
"CellFlag",
"summary of cell flags",1200,800);
1369 c2->ToggleEventStatus();
1374 fhCellFlag->SetYTitle(
"flag by which cell was excluded");
1396 c1_ratio->SaveAs(name1);
1400 c1_proj->SaveAs(name3);
1402 fRootFile->WriteObject(c1,c1->GetName());
1403 fRootFile->WriteObject(c1_ratio,c1_ratio->GetName());
1404 fRootFile->WriteObject(c1_proj,c1_proj->GetName());
1405 fRootFile->WriteObject(c2,c2->GetName());
1407 fRootFile->WriteObject(cellAmp_masked,cellAmp_masked->GetName());
1408 fRootFile->WriteObject(ratio2DAmp,ratio2DAmp->GetName());
1413 fRootFile->WriteObject(projEnergyMask,projEnergyMask->GetName());
1414 fRootFile->WriteObject(projEnergy,projEnergy->GetName());
1421 Int_t nWEMCalCells =0;
1422 Int_t nWDCalCells =0;
1423 file.open(cellSummaryFile, ios::out | ios::app);
1426 file<<
"Warm cells : "<<endl;
1427 if(
fPrint==1)cout<<
" o Warm cells : "<<endl;
1432 file<<
"In EMCal: "<<endl;
1437 file<<
"In DCal: "<<endl;
1449 file<<
"EMCal ("<<nWEMCalCells<<
" ="<<perWarmEMCal<<
"%), DCal ("<<nWDCalCells<<
" ="<<perWarmDCal<<
"%)"<<endl;
1450 if(
fPrint==1)cout<<
" o EMCal ("<<nWEMCalCells<<
" ="<<perWarmEMCal<<
"%), DCal ("<<nWDCalCells<<
" ="<<perWarmDCal<<
"%)"<<endl;
1456 ofstream file2(aliceTwikiTable, ios::out | ios::app);
1459 file2<<
"1=energy/hit, 2= hit/event"<<endl;
1461 file2<<
"| *Detector* | *No of cells* | *percentage* |"<<endl;
1462 file2<<
"| Dead EMCal | "<<nDeadEMCalCells<<
" | "<<perDeadEMCal<<
"% |"<<endl;
1463 file2<<
"| Bad EMCal | "<<nEMCalCells<<
" | "<<perBadEMCal<<
"% |"<<endl;
1464 file2<<
"| - Warm EMCal | "<<nWEMCalCells<<
" | "<<perWarmEMCal<<
"% |"<<endl;
1465 file2<<
"| Dead DCal | "<<nDeadDCalCells<<
" | "<<perDeadDCal<<
"% |"<<endl;
1466 file2<<
"| Bad DCal | "<<nDCalCells<<
" | "<<perBadDCal<<
"% |"<<endl;
1467 file2<<
"| - Warm DCal | "<<nWDCalCells<<
" | "<<perWarmDCal<<
"% |"<<endl;
1492 gROOT->SetStyle(
"Plain");
1493 gStyle->SetOptStat(0);
1494 gStyle->SetFillColor(kWhite);
1495 gStyle->SetTitleFillColor(kWhite);
1496 gStyle->SetPalette(1);
1502 fRootFile->WriteObject(hRefDistr,hRefDistr->GetName());
1503 Int_t firstCanvas=0;
1505 TLatex* text =
new TLatex(0.2,0.8,
"*Candidate*");
1506 text->SetTextSize(0.07);
1507 text->SetTextColor(kOrange-3);
1510 TLatex* text2 =
new TLatex(0.2,0.8,
"*Not a Candidate*");
1511 text2->SetTextSize(0.08);
1512 text2->SetTextColor(8);
1515 TLatex* textA =
new TLatex(0.65,0.62,
"*test*");
1516 textA->SetTextSize(0.04);
1517 textA->SetTextColor(1);
1523 std::vector<Int_t> channelVector;
1524 channelVector.clear();
1525 cout<<
" o Start printing into .pdf for version: "<<version<<endl;
1528 if(
fFlag[cell]==1 && version==0)channelVector.push_back(cell);
1529 if(
fFlag[cell]>1 && version==1)channelVector.push_back(cell);
1530 if(
fFlag[cell]==0 && version==2)channelVector.push_back(cell);
1531 if(
fFlag[cell]>1 && version==10)channelVector.push_back(cell);
1532 if(
fFlag[cell]==0 && version==20)channelVector.push_back(cell);
1534 if(cell%2000==0)cout<<
"...cell No."<<cell<<endl;
1536 if(channelVector.size()==9 || cell == fNoOfCells-1)
1541 TCanvas *c1 =
new TCanvas(
"badcells",
"badcells",1000,750);
1542 if(channelVector.size() > 6) c1->Divide(3,3);
1543 else if (channelVector.size() > 3) c1->Divide(3,2);
1544 else c1->Divide(3,1);
1546 TLegend *leg =
new TLegend(0.7, 0.7, 0.9, 0.9);
1547 for(
Int_t i=0; i< (
Int_t)channelVector.size() ; i++)
1549 sprintf(name,
"Cell %d",channelVector.at(i)) ;
1550 TH1 *hCell =
fCellAmplitude->ProjectionX(name,channelVector.at(i)+1,channelVector.at(i)+1);
1551 sprintf(title,
"Cell No: %d Entries: %d",channelVector.at(i), (
Int_t)hCell->GetEntries()) ;
1554 c1->cd(i%9 + 1)->SetLogy();
1557 leg->AddEntry(hRefDistr,
"mean of good",
"l");
1558 leg->AddEntry(hCell,
"current",
"l");
1562 if(candidate==1)
fWarmCell[channelVector.at(i)]=candidate;
1565 hCell->Divide(hRefDistr);
1573 hCell->SetLineColor(kBlue+1);
1574 hCell->GetXaxis()->SetTitle(
"E (GeV)");
1575 hCell->GetYaxis()->SetTitle(
"N Entries");
1576 hCell->GetXaxis()->SetRangeUser(0.,10.);
1577 hCell->SetLineWidth(1) ;
1578 hCell->SetTitle(title);
1579 hRefDistr->SetLineColor(kGray+2);
1580 hRefDistr->SetLineWidth(1);
1582 hCell->Draw(
"hist");
1584 if(version==1 || version==2)hRefDistr->Draw(
"same") ;
1587 if(candidate==1 && (version==1 || version==10))
1589 gPad->SetFrameFillColor(kYellow-10);
1594 textA->SetTitle(Form(
"Excluded by No. %d",
fFlag[channelVector.at(i)]));
1595 textA->DrawLatex(0.65,0.62,Form(
"Excluded by No. %d",
fFlag[channelVector.at(i)]));
1597 if(candidate==0 && (version==2 || version==20))
1599 gPad->SetFrameFillColor(kYellow-10);
1603 if(version<2)leg->Draw();
1606 if(channelVector.size()<9 || cell == fNoOfCells-1)
1608 internal_pdfName +=
")";
1609 c1->Print(internal_pdfName.Data());
1611 else if(firstCanvas==0)
1613 internal_pdfName +=
"(";
1614 c1->Print(internal_pdfName.Data());
1619 c1->Print(internal_pdfName.Data());
1623 channelVector.clear();
1649 if(warmIn==0 &&
fFlag[cell]!=0 )
continue;
1651 if(warmIn==2 &&
fWarmCell[cell]==0)
continue;
1655 hgoodMean->Add(hGoodAmp);
1657 hgoodMean->Scale(1.0/NrGood);
1674 TString Name = Form(
"%s_ratio",histogram->GetName());
1675 TH1* ratio=(
TH1*)histogram->Clone(Name);
1676 ratio->Divide(reference);
1689 Int_t binHeightOne = reference->FindLastBinAbove(1.0/totalevents);
1690 Double_t binCentreHeightOne = reference->GetBinCenter(binHeightOne);
1691 Double_t thirdBinCentre = reference->GetBinCenter(3);
1700 if(ratio->FindLastBinAbove(0)<ratio->FindBin(binCentreHeightOne*percentageOfLast))
1709 ratio->GetXaxis()->SetRangeUser(thirdBinCentre,10);
1710 if(ratio->GetMaximum()>highestRatio)
1720 Int_t nullEntries=0;
1721 for(
Int_t i=2;i<binHeightOne;i++)
1723 if(ratio->GetBinContent(i)!=0)mean+=ratio->GetBinContent(i);
1726 mean*=1.0/(binHeightOne-1-nullEntries);
1727 if(mean>maxMean || mean<minMean)
1739 ratio->GetXaxis()->SetRangeUser(0,binCentreHeightOne);
1740 Double_t localMaxBin=ratio->GetMaximumBin();
1742 for(
Int_t i=2;i<binHeightOne;i++)
1745 if(ratio->GetBinContent(i)<=0)
continue;
1746 if(i>localMaxBin-3 && i<localMaxBin+3)
continue;
1747 mean+=ratio->GetBinContent(i);
1749 mean*=1.0/(binHeightOne-1);
1750 ratio->GetXaxis()->SetRangeUser(thirdBinCentre,binCentreHeightOne);
1752 if(ratio->GetMaximum()>mean*higherThanMean)
1764 Int_t cliffBin = ratio->FindBin(4);
1765 for(
Int_t i=cliffBin-10;i<cliffBin+11;i++)
1768 if(ratio->GetBinContent(i)<=0)
continue;
1769 if(i<=cliffBin) binsBefore++;
1770 if(i>cliffBin) binsAfter++;
1771 if(i<=cliffBin) beforeCliff+=ratio->GetBinContent(i);
1772 if(i>cliffBin) afterCliff+=ratio->GetBinContent(i);
1773 beforeCliff*=1.0/binsBefore;
1774 afterCliff*=1.0/binsAfter;
1776 if((beforeCliff-afterCliff)>cliffSize*afterCliff)
1778 if(beforeCliff!=0 && afterCliff!=0)candidate=0;
1779 if(beforeCliff!=0 && afterCliff!=0)cout<<
"5"<<endl;
1810 Bool_t coveredByTRDSupportStruc=0;
1812 if((collumn>3 && collumn<9) || (collumn>32 && collumn<37) || (collumn>57 && collumn<61) || (collumn>84 && collumn<90) ||
1813 (row==1) ||(row>20 && row<25) || (row>44 && row<49) || (row>68 && row<73) || (row>91 && row<96) ||
1814 (row>116 && row<120)|| row==127 || (row>148 && row<152) || (row>172 && row<177) || (row>197 && row<201)
1817 coveredByTRDSupportStruc=1;
1819 return coveredByTRDSupportStruc;
1834 histoName = Form(
"2DChannelMap_Flag%d",flagBegin);
1835 if(flagBegin==0 && flagEnd==0)histoName = Form(
"2DChannelMap_Flag100");
1838 plot2D->GetXaxis()->SetTitle(
"cell column (#eta direction)");
1839 plot2D->GetYaxis()->SetTitle(
"cell row (#phi direction)");
1841 Int_t cellColumn=0,cellRow=0;
1842 Int_t cellColumnAbs=0,cellRowAbs=0;
1854 cout<<
"Problem! wrong calculated number of max col and max rows"<<endl;
1855 cout<<
"current col: "<<cellColumnAbs<<
", max col"<<
fNMaxColsAbs<<endl;
1856 cout<<
"current row: "<<cellRowAbs<<
", max row"<<
fNMaxRowsAbs<<endl;
1858 if(flagEnd==-1 &&
fFlag[cell]==flagBegin) plot2D->SetBinContent(cellColumnAbs,cellRowAbs,1);
1859 if(flagEnd!=0 && flagEnd!=-1 &&
fFlag[cell]>=flagBegin &&
fFlag[cell]<=flagEnd)plot2D->SetBinContent(cellColumnAbs,cellRowAbs,1);
1860 if(flagBegin==0 && flagEnd==0 &&
fWarmCell[cell]==1) plot2D->SetBinContent(cellColumnAbs,cellRowAbs,1);
1864 TCanvas *c1 =
new TCanvas(histoName,histoName,500,500);
1865 c1->ToggleEventStatus();
1869 plot2D->Draw(
"colz");
1872 if(flagBegin==0 && flagEnd==-1) text =
new TLatex(0.2,0.8,
"Good Cells");
1873 if(flagBegin==1) text =
new TLatex(0.2,0.8,
"Dead Cells");
1874 if(flagBegin>1) text =
new TLatex(0.2,0.8,
"Bad Cells");
1875 if(flagBegin==0 && flagEnd==0) text =
new TLatex(0.2,0.8,
"Warm Cells");
1876 text->SetTextSize(0.06);
1878 text->SetTextColor(1);
1885 fRootFile->WriteObject(plot2D,plot2D->GetName());
1897 sprintf(name,
"Cell %d",cell) ;
TH2F * fCellTime
! possible histogram for the analysis. Cell ID vs. time, read from the input merged file ...
TString fAnalysisOutput
The list with bad channels and histograms are saved in this folder.
TList * fOutputListGood
! list with good channel amplitudes, stored in fRootFile
TH1F * fProcessedEvents
! Stores the number of events in the run
void Run(Bool_t mergeOnly=0)
TString fQADirect
Dierctory in the QA.root files where the input histograms are stored.
TList * fOutputListBadRatio
! list with bad channel amplitude ratios, stored in fRootFile
void PlotFlaggedCells2D(Int_t flagBegin, Int_t flagEnd=-1)
void SetRunNumber(Int_t run)
void SaveBadCellsToPDF(Int_t version, TString pdfName)
TString fPeriod
The name of the analyzed period.
TString fWorkdir
Directory which contains the folders fMergeOutput, fAnalysisInput and fAnalysisOutput. By default it is './'.
TH1D * BuildMeanFromGood(Int_t warmIn=0)
Bool_t CheckDistribution(TH1 *ratio, TH1 *reference)
Bool_t fTestRoutine
This is a flag, if set true will produce some extra quality check histograms.
TString fRunListFileName
This is the name of the file with the run numbers to be merged, by default it's 'runList.txt'.
TList * fOutputListBad
! list with bad channel amplitudes, stored in fRootFile
void AddPeriodAnalysis(Int_t criteria, Double_t nsigma, Double_t emin, Double_t emax)
void FlagAsBad(Int_t crit, TH1F *inhisto, Double_t nsigma=4., Double_t dnbins=200)
Int_t * fFlag
! fFlag[CellID] = 0 (ok),1 (dead),2 and higher (bad certain criteria) start at 0 (cellID 0 = histobin...
Int_t fCriterionCounter
! This value will be written in fflag and updates after each PeriodAnalysis, to distinguish the steps...
Bool_t fPrint
If set true more couts with information of the excluded cells will be printed.
AliEMCALGeometry * GetEMCALGeometry() const
Analyses cell properties and identifies bad cells.
TList * fOutputListGoodRatio
! list with good channel amplitude ratios, stored in fRootFile
TString fTrainNo
Train number of the analyszed data (can deduce pass & trigger from that etc.)
Int_t fNMaxColsAbs
Maximum No of colums in Calorimeter.
Int_t fNoOfCells
Number of cells in EMCal and DCal.
void PeriodAnalysis(Int_t criterum=7, Double_t nsigma=4.0, Double_t emin=0.1, Double_t emax=2.0)
std::vector< Int_t > fManualMask
! Is a list of cells that should be addidionally masked by hand.
TH1F * fhCellWarm
! histogram that stores whether the cell was marked as warm
Bool_t * fWarmCell
! fWarmCell[CellID] = 0 (really bad), fWarmCell[CellID] = 1 (candidate for warm), ...
TH2F * fCellAmplitude
! main histogram for the analysis. Cell ID vs. amplitude, read from the input merged file ...
void SummarizeResultsByFlag()
TH1F * BuildTimeMean(Int_t crit, Double_t tmin, Double_t tmax)
ClassImp(AliAnalysisTaskDeltaPt) AliAnalysisTaskDeltaPt
std::vector< TArrayD > fAnalysisVector
Vector of analysis information. Each place is filled with 4 doubles: version, sigma, lower, and upper energy range.
Int_t fNMaxRows
Maximum No of rows in module (phi direction)
TString fMergedFileName
Filename of the .root file containing the merged runs.
Int_t fCurrentRunNumber
A run number of an analyzed period. This is important for the AliCalorimeterUtils initialization...
TString fExternalFileName
If you have already a file that contains many runs merged together you can place it in fMergeOutput a...
TString fRunList
Thats the full path and name of the file which contains a list of all runs to be merged together...
AliCalorimeterUtils * fCaloUtils
! Calorimeter information for the investigated runs
TH1F * BuildHitAndEnergyMean(Int_t crit, Double_t emin=0.1, Double_t emax=2.)
TFile * file
TList with histograms for a given trigger.
Int_t fTrial
Number of trial that this specific analyis is. By default '0' so one can try different settings witho...
Bool_t IsCoveredByTRD(Int_t row, Int_t collumn)
Int_t fStartCell
ID of the first cell you want to check.
Int_t fNMaxCols
Maximum No of colums in module (eta direction)
TString fTrigger
Selected trigger for the analysis.
Class with utils specific to calorimeter clusters/cells.
void AccessGeometry(AliVEvent *inputEvent)
TH1F * fhCellFlag
! histogram that stores by which flag the cell has been excluded
TFile * fRootFile
! root file with all histograms from this analysis
Int_t fCellStartDCal
ID of the first cell in the DCal.
TString fAnalysisInput
Here the .root files of each run of the period are saved.
Int_t fNMaxRowsAbs
Maximum No of rows in Calorimeter.
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