20 #include <Riostream.h> 30 #include <AliEMCALGeometry.h> 32 #include <AliAODEvent.h> 51 fCurrentRunNumber(-1),
56 fCellStartDCal(12288),
67 fExternalFileName(
""),
68 fExternalBadMapName(
""),
77 fCriterionCounter(0x0),
162 gROOT->ProcessLine(
"gErrorIgnoreLevel = kWarning;");
191 fRootFile =
new TFile(fileName,
"recreate");
206 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};
211 cout<<
"Number of supermod: "<<nModules<<endl;
293 gStyle->SetPalette(55);
299 cout<<
". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ."<<endl;
300 cout<<
". . .Start process by converting files. . . . . . . . . . . ."<<endl;
305 Printf(
"File not produced, exit");
313 cout<<
". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ."<<endl;
314 cout<<
". . .Start process by loading external file. . . . . . . . . . ."<<endl;
321 cout<<
". . .Load inputfile with name: "<<
fMergedFileName<<
" . . . . . . . ."<<endl;
326 if(!mergedFileInput->IsOpen())
328 Printf(
"Error! Input file not found, abort");
339 cout<<
". . .Continue process by . . . . . . . . . . . ."<<endl;
345 cout<<
"o o o Flag dead cells o o o"<<endl;
355 cout<<
"o o o Flag bad cells o o o"<<endl;
362 if(
fPrint==1)cout<<
"o o o Write .txt for each period analyis with bad cells o o o"<<endl;
374 if(
fPrint==1)cout<<
"o o o Create summary documents for the entire analysis o o o"<<endl;
386 Int_t binHeightOne = hRefDistr->FindLastBinAbove(1.0/totalevents);
387 Double_t binCentreHeightOne = hRefDistr->GetBinCenter(binHeightOne);
388 cout<<
". . .Recomendation:"<<endl;
389 cout<<
". . .With the current statistic on average a cell has 1 hit at "<<binCentreHeightOne<<
" GeV"<<endl;
390 cout<<
". . .so it makes no sense to select energy ranges >"<<binCentreHeightOne<<
"GeV as cells will be"<<endl;
391 cout<<
". . .marked bad just due to the lack of statistic"<<endl;
392 cout<<
". . .your selected lower bond is "<<
fEndLowerBound<<
" GeV"<<endl;
393 if(binCentreHeightOne>=
fEndLowerBound) cout<<
". . .This means you are OK!"<<endl;
394 if(binCentreHeightOne<
fEndLowerBound) cout<<
". . .#!#!#!#! CAREFUL THIS COULD CAUSE TROUBLE AND THROW OUT MORE CELLS THAN NECESSARY #!#!#!#! "<<endl;
395 cout<<
". . .End of process . . . . . . . . . . . . . . . . . . . . ."<<endl;
396 cout<<
". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ."<<endl;
407 cout<<
"o o o Start conversion process o o o"<<endl;
411 TH1F *hNEventsProcessedPerRun=
new TH1F(
"hNEvents",
"Number of processed events in analyzed runs",1,0,1);
412 TH2F *hCellAmplitude;
416 cout<<
"o o o Open .txt file with run indices. Name = " <<
fRunList << endl;
417 FILE *pFile = fopen(
fRunList.Data(),
"r");
420 cout<<
"couldn't open file!"<<endl;
431 ncols = fscanf(pFile,
" %d ",&q);
440 const Int_t nRun = nlines ;
445 cout<<
"o o o Start merging process of " << nRun <<
" files"<< endl;
448 for(
Int_t i = 0 ; i < nRun ; i++)
452 infile = Form(
"%s.root",base.Data()) ;
454 cout<<
" o Open .root file with name: "<<infile<<endl;
455 TFile *f = TFile::Open(infile);
460 cout<<
"Couldn't open/find .root file: "<<infile<<endl;
463 TDirectoryFile *
dir = (TDirectoryFile *)f->Get(
fQADirect);
466 cout<<
"Couln't open directory file in .root file: "<<infile<<
", directory: "<<
fQADirect<<endl;
472 cout <<
"Couln't get TList from directory file: "<<
fQADirect<<endl;
480 hAmpId =(
TH2F*)outputList->FindObject(
"EMCAL_hAmpId");
483 Printf(
"hAmpId not found");
489 hAmpId->SetName(
"hCellAmplitude");
490 hAmpId->SetTitle(
"Cell Amplitude");
493 hTimeId =(
TH2F*)outputList->FindObject(
"EMCAL_hTimeId");
496 Printf(
"hTimeId not found");
502 hTimeId->SetName(
"hCellTime");
503 hTimeId->SetTitle(
"Cell Time");
509 hCellAmplitude=(
TH2F*)hAmpId->Clone(
"DummyName1");
510 hCellAmplitude->Reset();
511 hCellAmplitude->SetDirectory(0);
513 hCellTime=(
TH2F*)hTimeId->Clone(
"DummyName2");
515 hCellTime->SetDirectory(0);
518 hNEvents =(TH1F *)outputList->FindObject(
"hNEvents");
521 Printf(
"hNEvents not found");
525 nEntr = (
Int_t)hNEvents->GetEntries();
530 cout <<
" o File to small to be merged. Only N entries " << nEntr << endl;
533 cout <<
" o File with N entries " << nEntr<<
" will be merged"<< endl;
535 hCellAmplitude->Add(hAmpId);
536 hCellTime->Add(hTimeId);
537 hNEventsProcessedPerRun->Add(hNEvents);
542 TFile *singleRunFile = TFile::Open(singleRunFileName,
"recreate");
549 singleRunFile->Close();
551 outputList->Delete();
560 cout<<
"o o o Save the merged histogramms to .root file with name: "<<
fMergedFileName<<endl;
561 cout<<
"o o o "<<nEntrTot<<
" events were merged"<<endl;
565 hNEventsProcessedPerRun->Write();
566 hCellAmplitude->SetName(
"hCellAmplitude");
567 hCellAmplitude->SetTitle(
"Cell Amplitude");
568 hCellAmplitude->Write();
569 hCellTime->SetName(
"hCellTime");
570 hCellTime->SetTitle(
"Cell Time");
573 cout<<
"o o o End conversion process o o o"<<endl;
574 if(hNEventsProcessedPerRun)
delete hNEventsProcessedPerRun;
579 if(hNEventsProcessedPerRun)
delete hNEventsProcessedPerRun;
595 TFile* outputRoot = TFile::Open(extRootFileName.Data());
597 TH1F* hFlags =(TH1F*)outputRoot->Get(
"fhCellFlag");
603 Double_t extFlag = hFlags->GetBinContent(cell+1);
606 fFlag[cell] =extFlag;
627 PeriodAnalysis(periodArray.At(0),periodArray.At(1),periodArray.At(2),periodArray.At(3));
632 cout<<
"o o o End of bad channel analysis o o o"<<endl;
642 cout<<
"o o o Manually mask SM "<<iSM<<
" o o o"<<endl;
660 for(
Int_t iSM=0; iSM<NoSMmask; iSM++)
682 periodArray.AddAt((
Double_t)criteria,0);
683 periodArray.AddAt(nsigma,1);
684 periodArray.AddAt(emin,2);
685 periodArray.AddAt(emax,3);
707 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;
708 if(
fPrint==1)cout<<
"o o o PeriodAnalysis for flag "<<criterion<<
" o o o"<<endl;
710 if(
fPrint==1 && criterion != 3)cout<<
"o o o Done in the energy range E "<<emin<<
" - "<<emax<<endl;
711 if(
fPrint==1 && criterion == 3)cout<<
"o o o Done in the time range t "<<emin<<
" - "<<emax<<endl;
724 if(
fPrint==1)cout<<
"o o o Analyze average cell distributions o o o"<<endl;
728 if(criterion == 3) histogram =
BuildTimeMean(criterion, emin, emax);
730 if(criterion==1 || criterion == 4)
734 else FlagAsBad(criterion, histogram, nsigma, 200);
736 if(criterion==2 || criterion == 5)
740 else FlagAsBad(criterion, histogram, nsigma, 601);
758 if(
fPrint==1)cout<<
" o Calculate average cell hit per event and average cell energy per hit "<<endl;
760 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);
761 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);
762 histogram->SetXTitle(
"Abs. Cell Id");
763 if(crit==1)histogram->SetYTitle(
"Energy per hit");
764 if(crit==2)histogram->SetYTitle(
"Number of hits in cell");
765 histogram->GetXaxis()->SetNdivisions(510);
768 TH1F* pojection = (TH1F*)
fCellAmplitude->ProjectionX(
"Intermediate");
769 fnEventsInRange = pojection->Integral(pojection->GetBinContent(emin),pojection->GetBinContent(emax));
783 if (E < emin || E > emax ||
fFlag[cell]!=0)
continue;
790 if(crit==2) histogram->SetBinContent(cell+1, Nsum);
791 if(Nsum > 0. && crit==1)histogram->SetBinContent(cell+1, Esum/(Nsum));
813 if(
fPrint==1)cout<<
" o Calculate average cell hit per event and average cell energy per hit "<<endl;
814 TH1F *histogram = NULL;
815 if(crit==4)histogram =
new TH1F(Form(
"hCellEtoN_E%.2f-%.2f",emin,emax),Form(
"Energy per hit, %.2f < E < %.2f GeV",emin,emax),
fNoOfCells,0,
fNoOfCells);
816 if(crit==5)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);
817 histogram->SetXTitle(
"Abs. Cell Id");
818 if(crit==4)histogram->SetYTitle(
"Energy per hit");
819 if(crit==5)histogram->SetYTitle(
"Number of hits in cell");
820 histogram->GetXaxis()->SetNdivisions(510);
825 TH1F *hEnergyCol =
new TH1F(
"hEnergyCol",
"hEnergyCol", 100,0.,100.);
826 TH1F *hEnergyRow =
new TH1F(
"hEnergyRow",
"hEnergyRow", 250,0.,250.);
830 Int_t cellCol, cellRow, trash, col, row;
837 for(
int iCell = 1; iCell <=
fNoOfCells; iCell++){
839 if(
fFlag[iCell -1] == 0){
840 for(
int k = hEnergyScaled->GetXaxis()->FindBin(emin); k <= hEnergyScaled->GetXaxis()->FindBin(emax); k++){
841 NoOfHits += hEnergyScaled->GetBinContent(k, iCell);
844 arrHits[iCell - 1] = NoOfHits;
853 TH1D *hHitDistrib_forScaling =
new TH1D(
"hHitDistrib_forScaling",
"hHitDistrib_forScaling",1000,0.,TMath::Median(
fNoOfCells,arrHits)*4);
854 TF1 *fgausForScaling =
new TF1(
"fgausForScaling",
"gaus", 0.,TMath::Median(
fNoOfCells,arrHits)*4);
855 TVectorD fFlagForScaling;
861 for(
int k = hEnergyScaled->GetXaxis()->FindBin(emin); k <= hEnergyScaled->GetXaxis()->FindBin(emax); k++){
862 if(crit==5){dhits += hEnergyScaled->GetBinContent(k, i);}
864 dhits += hEnergyScaled->GetBinContent(k, i + 1)*hEnergyScaled->GetXaxis()->GetBinCenter(k);
865 dNumOfHits += hEnergyScaled->GetBinContent(k, i + 1);
868 if(crit==4 && dNumOfHits > 0){dhits = dhits / dNumOfHits;}
870 hHitDistrib_forScaling->Fill(dhits);
875 fgausForScaling->SetParameter(1, hHitDistrib_forScaling->GetBinCenter(hHitDistrib_forScaling-> GetMaximumBin()));
876 hHitDistrib_forScaling->Fit(fgausForScaling,
"MQ0");
877 hHitDistrib_forScaling->Fit(fgausForScaling,
"MQ0");
879 for(
int iCell = 1; iCell <=
fNoOfCells; iCell++){
882 for(
int k = hEnergyScaled->GetXaxis()->FindBin(emin); k <= hEnergyScaled->GetXaxis()->FindBin(emax); k++){
883 if(crit==5){dhits += hEnergyScaled->GetBinContent(k, iCell);}
885 dhits += hEnergyScaled->GetBinContent(k, iCell + 1)*hEnergyScaled->GetXaxis()->GetBinCenter(k);
886 dNumOfHits += hEnergyScaled->GetBinContent(k, iCell + 1);
889 if(crit==4 && dNumOfHits > 0){dhits = dhits / dNumOfHits;}
890 if(dhits > fgausForScaling->GetParameter(1) + 5* fgausForScaling->GetParameter(2) || dhits < fgausForScaling->GetParameter(1) - 5* fgausForScaling->GetParameter(2)){
891 fFlagForScaling[iCell - 1] = 1;
895 delete hHitDistrib_forScaling;
896 delete fgausForScaling;
904 for(
int iter = 0; iter < 5; iter++){
906 std::vector<Double_t> vecCol[100];
907 std::vector<Double_t> vecRow[250];
931 for(
int iCell = 0; iCell <
fNoOfCells; iCell++){
932 if(
fFlag[iCell] == 0 && fFlagForScaling[iCell] == 0){
936 for (
int EBin = hEnergyScaled->GetXaxis()->FindBin(emin); EBin < hEnergyScaled->GetXaxis()->FindBin(emax); EBin++) {
937 if(crit==5){dCellEnergy += hEnergyScaled->GetBinContent(EBin, iCell + 1);}
939 dCellEnergy += hEnergyScaled->GetBinContent(EBin, iCell + 1)*hEnergyScaled->GetXaxis()->GetBinCenter(EBin);
940 dNumOfHits += hEnergyScaled->GetBinContent(EBin, iCell + 1);
944 if(crit==4 && dNumOfHits > 0){dCellEnergy = dCellEnergy / dNumOfHits;}
946 if( dCellEnergy > 0.){
947 hEnergyCol->Fill(col + 0.5, dCellEnergy);
948 hEnergyRow->Fill(row + 0.5, dCellEnergy);
949 vecCol[col].push_back(dCellEnergy);
950 vecRow[row].push_back(dCellEnergy);
956 for(
int iCol = 1; iCol <= hEnergyCol->GetNbinsX() ; iCol++){
957 if(vecCol[iCol -1].size() > 0.){
958 hEnergyCol->SetBinContent(hEnergyCol->FindBin(iCol - 0.5), hEnergyCol->GetBinContent(hEnergyCol->FindBin(iCol - 0.5))/vecCol[iCol-1].size() );
963 for(
int iRow = 1; iRow <= hEnergyRow->GetNbinsX() ; iRow++){
964 if(vecRow[iRow -1].size() > 0.){
965 hEnergyRow->SetBinContent(hEnergyRow->FindBin(iRow - 0.5), hEnergyRow->GetBinContent(hEnergyRow->FindBin(iRow - 0.5))/vecRow[iRow-1].size() );
970 fFitRow =
new TF1(
"fFitRow",
"[0]",0.,250.);
971 fFitRow->SetParameter(0, hEnergyRow->GetBinContent(10));
972 Double_t MeanRow = hEnergyRow->GetBinContent(10);
975 fFitCol =
new TF1(
"fFitCol",
"[0]",0.,100.);
976 fFitCol->SetParameter(0, hEnergyCol->GetBinContent(10));
977 Double_t MeanCol = hEnergyCol->GetBinContent(10);
981 for(
int iCell = 0; iCell <
fNoOfCells; iCell++){
983 if (hEnergyCol->GetBinContent(col + 1) > 0.) {
984 for(
int EBin = 1; EBin < hEnergyScaled->GetNbinsX(); EBin++) {
985 hEnergyScaled->SetBinContent(EBin, iCell + 1, hEnergyScaled->GetBinContent(EBin, iCell + 1) * (MeanCol / hEnergyCol->GetBinContent(col + 1)));
991 for(
int iCell = 0; iCell <
fNoOfCells; iCell++){
993 if (hEnergyRow->GetBinContent(row + 1) > 0.) {
994 for(
int EBin = 1; EBin < hEnergyScaled->GetNbinsX(); EBin++) {
995 hEnergyScaled->SetBinContent(EBin, iCell + 1, hEnergyScaled->GetBinContent(EBin, iCell + 1) * (MeanRow / hEnergyRow->GetBinContent(row + 1)));
1012 for (
Int_t j = 1; j <= hEnergyScaled->GetNbinsX(); j++)
1015 Double_t E = hEnergyScaled->GetXaxis()->GetBinCenter(j);
1016 Double_t N = hEnergyScaled->GetBinContent(j, cell+1);
1018 if (E < emin || E > emax ||
fFlag[cell]!=0)
continue;
1025 if(crit==5) histogram->SetBinContent(cell+1, Nsum);
1026 if(Nsum > 0. && crit==4)histogram->SetBinContent(cell+1, Esum/(Nsum));
1029 delete hEnergyScaled;
1047 if(
fPrint==1)cout<<
" o Calculate maximum of cell time distribution "<<endl;
1049 TH1F *histogram = NULL;
1050 histogram =
new TH1F(Form(
"timeMax_t%.2f-%.2f",tmin,tmax),Form(
"Maximum of time distr., %.2f < t < %.2f ns",tmin,tmax),
fNoOfCells,0,
fNoOfCells);
1051 histogram->SetXTitle(
"Abs. Cell Id");
1052 histogram->SetYTitle(Form(
"N_{cells}^{%.0f<t<%.0f}/N_{cells}^{all}",tmin,tmax));
1053 histogram->GetXaxis()->SetNdivisions(510);
1059 for(
int iCell = 1; iCell <=
fNoOfCells; iCell ++)
1061 if(
fFlag[iCell - 1] != 0) {
continue; }
1064 for(
int iTime = 1; iTime <=
fCellTime->GetNbinsX(); iTime++)
1066 dHits =
fCellTime->GetBinContent(iTime, iCell);
1067 if(
fCellTime->GetXaxis()->GetBinCenter(iTime) > tmin &&
fCellTime->GetXaxis()->GetBinCenter(iTime) < tmax)
1075 histogram->SetBinContent(iCell, dAll/dIn);
1079 histogram->SetBinContent(iCell, 0.);
1093 Int_t manualMaskCounter=0;
1110 if(nSum == 0 &&
fFlag[cell]==0)
1121 manualMaskCounter++;
1124 if(
fPrint==1)cout<<
" o Number of dead cells: "<<sumOfExcl<<endl;
1125 if(
fPrint==1)cout<<
" ("<<sumOfExcl<<
")"<<endl;
1145 gStyle->SetOptStat(0);
1146 gStyle->SetOptFit(0);
1147 if(
fPrint==1 && crit==1)cout<<
" o Fit average energy per hit distribution"<<endl;
1148 if(
fPrint==1 && crit==2)cout<<
" o Fit average hit per event distribution"<<endl;
1149 if(
fPrint==1 && crit==3)cout<<
" o Fit average hit maximum distribution"<<endl;
1151 Int_t cellColumn=0,cellRow=0;
1152 Int_t cellColumnAbs=0,cellRowAbs=0;
1155 TString histoName=inhisto->GetName();
1160 Double_t dminVal = inhisto->GetMinimum(0);
1161 Double_t dmaxVal = inhisto->GetMaximum();
1172 Int_t numBins = inhisto->GetXaxis()->GetNbins();
1177 for (
int i = 0; i < numBins; i++)
1181 if(x[i]==0)y[i] = 0;
1183 medianOfHisto = TMath::Median(numBins,x,y);
1188 if(medianOfHisto*10<dmaxVal)
1190 if(medianOfHisto*100<dmaxVal)
1192 dmaxVal=medianOfHisto+0.02*(dmaxVal-medianOfHisto);
1196 dmaxVal=medianOfHisto+0.2*(dmaxVal-medianOfHisto);
1206 if(crit==2 || crit == 5)
1208 dnbins=dmaxVal-dminVal;
1211 if(dnbins>2000)dnbins=0.01*(dmaxVal-dminVal);
1212 if(dnbins>2000)dnbins=0.001*(dmaxVal-dminVal);
1213 if(dnbins<100) dnbins=0.02*(dmaxVal-dminVal);
1216 if(crit==1 || crit == 4)
1220 dnbins=(dmaxVal-dminVal)*150;
1221 if(dnbins>500)dnbins=(dmaxVal-dminVal)*50;
1223 if(dnbins<25)dnbins=dnbins*3;
1224 if(dnbins<25)dnbins=dnbins*2;
1229 dnbins=(dmaxVal-dminVal)*40;
1230 if(dnbins>500)dnbins=(dmaxVal-dminVal)*15;
1231 if(dnbins<25)dnbins=dnbins*3;
1232 if(dnbins<25)dnbins=dnbins*2;
1242 dnbins =
fCellTime->GetXaxis()->GetNbins();
1243 dminVal=
fCellTime->GetXaxis()->GetBinCenter(1)-(binWidth*1.0)/2.0;
1244 dmaxVal=
fCellTime->GetXaxis()->GetBinCenter(dnbins)+(binWidth*1.0)/2.0;
1245 cout<<
"set the new histo with following settings- bins: "<<dnbins<<
", min val = "<<dminVal<<
", max val:"<<dmaxVal<<endl;
1248 if(dmaxVal<dminVal || dnbins<1)
1250 cout<<
"###############################"<<endl;
1251 cout<<
"Big problem: min:"<<dminVal<<
", dmaxVal"<<dmaxVal<<endl;
1252 cout<<
"dnbins:"<<dnbins<<endl;
1253 cout<<
"###############################"<<endl;
1256 TH1F *distrib =
new TH1F(Form(
"%sDistr",(
const char*)histoName),
"", dnbins, dminVal, dmaxVal);
1257 distrib->SetXTitle(inhisto->GetYaxis()->GetTitle());
1258 distrib->SetYTitle(
"Entries");
1259 TH1F *distrib_wTRDStruc =
new TH1F(Form(
"%sDistr_wTRD",(
const char*)histoName),
"", dnbins, dminVal, dmaxVal);
1260 TH1F *distrib_woTRDStruc=
new TH1F(Form(
"%sDistr_woTRD",(
const char*)histoName),
"", dnbins, dminVal, dmaxVal);
1264 plot2D->GetXaxis()->SetTitle(
"cell column (#eta direction)");
1265 plot2D->GetYaxis()->SetTitle(
"cell row (#phi direction)");
1279 distrib->Fill(inhisto->GetBinContent(cell+1));
1286 cout<<
"Problem! wrong calculated number of max col and max rows"<<endl;
1287 cout<<
"current col: "<<cellColumnAbs<<
", max col"<<
fNMaxColsAbs<<endl;
1288 cout<<
"current row: "<<cellRowAbs<<
", max row"<<
fNMaxRowsAbs<<endl;
1290 plot2D->SetBinContent(cellColumnAbs,cellRowAbs,inhisto->GetBinContent(cell+1));
1294 distrib_wTRDStruc->Fill(inhisto->GetBinContent(cell+1));
1298 distrib_woTRDStruc ->Fill(inhisto->GetBinContent(cell+1));
1306 TCanvas *c1 =
new TCanvas(histoName,histoName,900,900);
1307 c1->ToggleEventStatus();
1308 TPad* upperPad =
new TPad(
"upperPad",
"upperPad",.005, .5, .995, .995);
1309 TPad* lowerPadLeft =
new TPad(
"lowerPadL",
"lowerPadL",.005, .005, .5, .5);
1310 TPad* lowerPadRight =
new TPad(
"lowerPadR",
"lowerPadR",.5, .005, .995, .5);
1312 lowerPadLeft->Draw();
1313 lowerPadRight->Draw();
1316 upperPad->SetLeftMargin(0.05);
1317 upperPad->SetRightMargin(0.05);
1318 if(crit!=3)upperPad->SetLogy();
1319 inhisto->SetTitleOffset(0.6,
"Y");
1320 inhisto->GetXaxis()->SetRangeUser(0,fNoOfCells+1);
1321 inhisto->GetYaxis()->SetTitleOffset(0.7);
1322 inhisto->SetLineColor(kBlue+1);
1323 inhisto->DrawCopy();
1325 lowerPadRight->cd();
1326 lowerPadRight->SetLeftMargin(0.09);
1327 lowerPadRight->SetRightMargin(0.12);
1328 plot2D->GetYaxis()->SetTitleOffset(1.3);
1329 plot2D->DrawCopy(
"colz");
1332 lowerPadLeft->SetLeftMargin(0.09);
1333 lowerPadLeft->SetRightMargin(0.07);
1334 lowerPadLeft->SetLogy();
1335 distrib->SetLineColor(kBlue+1);
1336 distrib->GetYaxis()->SetTitleOffset(1.3);
1341 distrib->DrawCopy(
"");
1342 distrib_wTRDStruc->SetLineColor(kGreen+1);
1343 distrib_wTRDStruc->DrawCopy(
"same");
1344 distrib_woTRDStruc->SetLineColor(kMagenta+1);
1345 distrib_woTRDStruc->DrawCopy(
"same");
1354 Double_t maxDistr = distrib->GetMaximum();
1355 Int_t maxBin = distrib->GetMaximumBin();
1356 Double_t maxCenter = distrib->GetBinCenter(maxBin);
1360 for(
Int_t i = maxBin ; i<=dnbins ; i++)
1362 if(distrib->GetBinContent(i)<2)
break ;
1363 goodmax = distrib->GetBinCenter(i);
1365 for(
Int_t i = maxBin ; i>2 ; i--)
1367 if(distrib->GetBinContent(i)<2)
break ;
1368 goodmin = distrib->GetBinLowEdge(i);
1378 if(crit==3)minFitRange=-20;
1379 if(crit==3)maxFitRange=20;
1384 TF1 *fit2 =
new TF1(
"fit2",
"gaus",minFitRange,maxFitRange);
1386 fit2->SetParLimits(0,0,maxDistr);
1387 fit2->SetParameter(1,maxCenter);
1388 fit2->SetParLimits(1,0,dmaxVal);
1391 distrib->Fit(fit2,
"0LQEM",
"", minFitRange, maxFitRange);
1393 mean = fit2->GetParameter(1);
1394 sig = fit2->GetParameter(2);
1399 goodmin = mean - nsigma*sig ;
1400 goodmax = mean + nsigma*sig ;
1405 if(inputBins==-1) goodmin=-1;
1406 if(goodmin <=0.) goodmin = -100;
1407 if(
fPrint==1)cout<<
" o Result of fit: "<<endl;
1408 if(
fPrint==1)cout<<
" o "<<endl;
1409 if(
fPrint==1)cout<<
" o Mean: "<<mean <<
" sigma: "<<sig<<endl;
1410 if(
fPrint==1)cout<<
" o good range : "<<goodmin <<
" - "<<goodmax<<endl;
1415 TLine *lline =
new TLine(goodmin, 0, goodmin, distrib->GetMaximum());
1416 lline->SetLineColor(kGreen+2);
1417 lline->SetLineStyle(7);
1420 TLine *rline =
new TLine(goodmax, 0, goodmax, distrib->GetMaximum());
1421 rline->SetLineColor(kGreen+2);
1422 rline->SetLineStyle(7);
1425 TLegend *leg =
new TLegend(0.60,0.70,0.9,0.85);
1426 leg->AddEntry(lline,
"Good region boundary",
"l");
1427 leg->AddEntry(distrib_wTRDStruc,
"Covered by TRD",
"l");
1428 leg->AddEntry(distrib_woTRDStruc,
"wo TRD structure",
"l");
1429 leg->SetBorderSize(0);
1432 fit2->SetLineColor(kOrange-3);
1433 fit2->SetLineStyle(1);
1438 if(crit==1 || crit==4) text =
new TLatex(0.12,0.85,Form(
"Good range: %.2f-%.2f",goodmin,goodmax));
1439 if(crit==2 || crit==5) text =
new TLatex(0.12,0.85,Form(
"Good range: %.2f-%.2f",goodmin,goodmax));
1440 if(crit==3) text =
new TLatex(0.12,0.85,Form(
"Good range: %.2f-%.2f",goodmin,goodmax));
1441 text->SetTextSize(0.06);
1443 text->SetTextColor(1);
1447 TLine *uline =
new TLine(0, goodmax,fNoOfCells,goodmax);
1448 uline->SetLineColor(kGreen+2);
1449 uline->SetLineStyle(7);
1451 TLine *lowline =
new TLine(0, goodmin,fNoOfCells,goodmin);
1452 lowline->SetLineColor(kGreen+2);
1453 lowline->SetLineStyle(7);
1460 if(crit==1)name=Form(
"%s/%s/AverageEperHit_%s.gif",
fWorkdir.Data(),
fAnalysisOutput.Data(), (
const char*)histoName);
1461 if(crit==2)name=Form(
"%s/%s/AverageHitperEvent_%s.gif",
fWorkdir.Data(),
fAnalysisOutput.Data(), (
const char*)histoName);
1462 if(crit==3)name=Form(
"%s/%s/AverageTimeMax_%s.gif",
fWorkdir.Data(),
fAnalysisOutput.Data(), (
const char*)histoName);
1463 if(crit==4)name=Form(
"%s/%s/AverageEperHit_scaled_%s.gif",
fWorkdir.Data(),
fAnalysisOutput.Data(), (
const char*)histoName);
1464 if(crit==5)name=Form(
"%s/%s/AverageHitperEvent_scaled_%s.gif",
fWorkdir.Data(),
fAnalysisOutput.Data(), (
const char*)histoName);
1467 fRootFile->WriteObject(c1,c1->GetName());
1468 fRootFile->WriteObject(plot2D,plot2D->GetName());
1469 fRootFile->WriteObject(distrib,distrib->GetName());
1470 fRootFile->WriteObject(inhisto,inhisto->GetName());
1477 if(
fPrint==1)cout<<
" o Flag bad cells that are outside the good range "<<endl;
1482 if(inhisto->GetBinContent(cell+1) <= goodmin &&
fFlag[cell]==0)
1486 if(inhisto->GetBinContent(cell+1) > goodmax && fFlag[cell]==0)
1491 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;
1523 Int_t cellColumn=0,cellRow=0;
1524 Int_t cellColumnAbs=0,cellRowAbs=0;
1529 Double_t dminVal = inhisto->GetMinimum(0);
1530 Double_t dmaxVal = inhisto->GetMaximum();
1539 Int_t numBins = inhisto->GetXaxis()->GetNbins();
1544 for (
int i = 0; i < numBins; i++)
1548 if(x[i]==0)y[i] = 0;
1550 medianOfHisto = TMath::Median(numBins,x,y);
1554 cout<<
"max value: "<<dmaxVal<<
", min: "<<dminVal<<
" median of histogram: "<<medianOfHisto<<endl;
1555 if(medianOfHisto*10<dmaxVal)
1557 if(medianOfHisto*100<dmaxVal)
1559 dmaxVal=medianOfHisto+0.002*(dmaxVal-medianOfHisto);
1563 dmaxVal=medianOfHisto+0.02*(dmaxVal-medianOfHisto);
1568 cout<<
"max value: "<<dmaxVal<<
", min: "<<dminVal<<
" median of histogram: "<<medianOfHisto<<endl;
1571 cout<<
"###############################"<<endl;
1572 cout<<
"Big problem: min:"<<dminVal<<
", dmaxVal"<<dmaxVal<<endl;
1573 cout<<
"###############################"<<endl;
1576 TString histoName=inhisto->GetName();
1577 TH1F *distrib =
new TH1F(Form(
"%sDistr",(
const char*)histoName),
"", 300, dminVal, dmaxVal);
1578 distrib->SetXTitle(inhisto->GetYaxis()->GetTitle());
1579 distrib->SetYTitle(
"Entries");
1580 TH1F *distrib_wTRDStruc =
new TH1F(Form(
"%sDistrWtrd",(
const char*)histoName),
"", 300, dminVal, dmaxVal);
1581 TH1F *distrib_woTRDStruc =
new TH1F(Form(
"%sDistrWoTRD",(
const char*)histoName),
"", 300, dminVal, dmaxVal);
1584 plot2D->GetXaxis()->SetTitle(
"cell column (#eta direction)");
1585 plot2D->GetYaxis()->SetTitle(
"cell row (#phi direction)");
1601 distrib->Fill(inhisto->GetBinContent(cell+1));
1608 cout<<
"Problem! wrong calculated number of max col and max rows"<<endl;
1609 cout<<
"current col: "<<cellColumnAbs<<
", max col"<<
fNMaxColsAbs<<endl;
1610 cout<<
"current row: "<<cellRowAbs<<
", max row"<<
fNMaxRowsAbs<<endl;
1612 plot2D->SetBinContent(cellColumnAbs,cellRowAbs,inhisto->GetBinContent(cell+1));
1616 distrib_wTRDStruc->Fill(inhisto->GetBinContent(cell+1));
1620 distrib_woTRDStruc ->Fill(inhisto->GetBinContent(cell+1));
1626 TCanvas *c1 =
new TCanvas(histoName,histoName,900,900);
1627 c1->ToggleEventStatus();
1628 TPad* upperPad =
new TPad(
"upperPad",
"upperPad",.005, .5, .995, .995);
1629 TPad* lowerPadLeft =
new TPad(
"lowerPadL",
"lowerPadL",.005, .005, .5, .5);
1630 TPad* lowerPadRight =
new TPad(
"lowerPadR",
"lowerPadR",.5, .005, .995, .5);
1632 lowerPadLeft->Draw();
1633 lowerPadRight->Draw();
1636 upperPad->SetLeftMargin(0.05);
1637 upperPad->SetRightMargin(0.05);
1638 upperPad->SetLogy();
1639 inhisto->SetTitleOffset(0.6,
"Y");
1640 inhisto->GetXaxis()->SetRangeUser(0,fNoOfCells+1);
1641 inhisto->GetYaxis()->SetTitleOffset(0.7);
1642 inhisto->SetLineColor(kBlue+1);
1646 lowerPadRight->cd();
1647 lowerPadRight->SetLeftMargin(0.09);
1648 lowerPadRight->SetRightMargin(0.12);
1649 plot2D->GetYaxis()->SetTitleOffset(1.3);
1650 plot2D->Draw(
"colz");
1654 lowerPadLeft->SetLeftMargin(0.09);
1655 lowerPadLeft->SetRightMargin(0.07);
1656 lowerPadLeft->SetLogy();
1657 distrib->SetLineColor(kBlue+1);
1658 distrib->GetYaxis()->SetTitleOffset(1.3);
1660 distrib_wTRDStruc->SetLineColor(kGreen+1);
1661 distrib_wTRDStruc->DrawCopy(
"same");
1662 distrib_woTRDStruc->SetLineColor(kMagenta+1);
1663 distrib_woTRDStruc->DrawCopy(
"same");
1667 Double_t maxDistr = distrib->GetMaximum();
1668 Int_t maxBin = distrib->GetMaximumBin();
1669 Double_t maxCenter = distrib->GetBinCenter(maxBin);
1679 TF1 *fitTime =
new TF1(
"fitTime",
"gaus",minFitRange,maxFitRange);
1681 fitTime->SetParLimits(0,maxDistr*0.5,maxDistr*1.2);
1682 fitTime->SetParameter(1,maxCenter);
1683 fitTime->SetParLimits(1,dminVal,dmaxVal);
1685 distrib->Fit(fitTime,
"0LEM",
"", minFitRange, maxFitRange);
1686 mean = fitTime->GetParameter(1);
1687 sig = fitTime->GetParameter(2);
1696 cout<<
"Determined time cut: "<<tCutMin<<
" - "<<tCutMax<<endl;
1700 TLine *line =
new TLine(tCutMax, 0, tCutMax, distrib->GetMaximum());
1701 line->SetLineColor(kGreen+2);
1702 line->SetLineStyle(7);
1704 TLine *line2 =
new TLine(tCutMin, 0, tCutMin, distrib->GetMaximum());
1705 line2->SetLineColor(kGreen+2);
1706 line2->SetLineStyle(7);
1709 fitTime->SetLineColor(kOrange-3);
1710 fitTime->SetLineStyle(1);
1711 fitTime->Draw(
"same");
1713 TLegend *leg =
new TLegend(0.60,0.70,0.9,0.85);
1714 leg->AddEntry(line,
"upper limit",
"l");
1715 leg->AddEntry(distrib_wTRDStruc,
"Covered by TRD",
"l");
1716 leg->AddEntry(distrib_woTRDStruc,
"wo TRD structure",
"l");
1717 leg->SetBorderSize(0);
1721 text =
new TLatex(0.12,0.85,Form(
"Good range: %.3f-%.3f",tCutMin,tCutMax));
1722 text->SetTextSize(0.06);
1724 text->SetTextColor(1);
1729 TLine *uline =
new TLine(0, tCutMax,fNoOfCells,tCutMax);
1730 uline->SetLineColor(kGreen+2);
1731 uline->SetLineStyle(7);
1734 TLine *lline =
new TLine(0, tCutMin,fNoOfCells,tCutMin);
1735 lline->SetLineColor(kGreen+2);
1736 lline->SetLineStyle(7);
1745 fRootFile->WriteObject(c1,c1->GetName());
1746 fRootFile->WriteObject(plot2D,plot2D->GetName());
1747 fRootFile->WriteObject(distrib,distrib->GetName());
1748 fRootFile->WriteObject(inhisto,inhisto->GetName());
1755 if(
fPrint==1)cout<<
" o Flag bad cells that are outside the good range "<<endl;
1760 if(inhisto->GetBinContent(cell+1) > tCutMax &&
fFlag[cell]==0)
1765 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;
1804 ofstream file2(aliceTwikiTable, ios::out | ios::trunc);
1807 file2<<
"|*Criterium* | *E_min !GeV* | *E_max !GeV* | *sigma* | *Excluded Cells* |"<<endl;
1814 criterion =periodArray.At(0);
1815 emin =periodArray.At(2);
1816 emax =periodArray.At(3);
1817 sig =periodArray.At(1);
1821 output.Form(
"%s/%s/Criterion%d_Emin-%.2f_Emax-%.2f.txt",
fWorkdir.Data(),
fAnalysisOutput.Data(), criterion,emin,emax);
1822 ofstream
file(output, ios::out | ios::trunc);
1825 cout<<
"#### Major Error. Check the textfile!"<<endl;
1827 file<<
"fFlag="<<i+2<<
"means Criterion : "<<criterion<<
", emin = "<<emin<<
" GeV"<<
", emax = "<<emax<<
" GeV"<<endl;
1828 if(
fPrint==1)cout<<
" o Criterion : "<<criterion<<
", emin = "<<emin<<
" GeV"<<
", emax = "<<emax<<
" GeV"<<
" (Method "<<i<<
")"<<endl;
1833 if(
fFlag[cellID]==(i+2))
1839 file<<
"Total number of bad cells with fFlag=="<<i+2<<endl;
1840 file<<
"("<<nb1<<
")"<<endl;
1842 if(
fPrint==1)cout<<
" o Total number of bad cells ("<<nb1<<
")"<<endl;
1847 ofstream file2(aliceTwikiTable, ios::out | ios::app);
1850 file2<<
"| "<<criterion<<
" | "<<emin<<
" | "<<emax<<
" | "<<sig<<
" | "<<nb1<<
" |"<<endl;
1864 Int_t cellID, nDeadDCalCells = 0, nDeadEMCalCells = 0, nDCalCells = 0, nEMCalCells = 0;
1865 Double_t perDeadEMCal,perDeadDCal,perBadEMCal,perBadDCal,perWarmEMCal,perWarmDCal;
1866 TString aliceTwikiTable, cellSummaryFile, deadPdfName, badPdfName, ratioOfBad,goodCells,goodCellsRatio,cellProp;
1867 TString OADBFile_bad, OADBFile_dead, OADBFile_warm;
1868 TString OADBFile_badRbR, OADBFile_deadRbR, OADBFile_warmRbR;
1887 cout<<
" o Final results o "<<endl;
1899 cellAmp_masked->SetBinContent(amp,cell+1,0);
1908 cellTime_masked->SetBinContent(time,cell+1,0);
1915 TCanvas *c1 =
new TCanvas(
"CellProp",
"I summary of cell properties",1000,1000);
1916 c1->ToggleEventStatus();
1918 c1->cd(1)->SetLogz();
1925 c1->cd(2)->SetLogz();
1928 fCellTime->GetYaxis()->SetTitleOffset(1.6);
1930 c1->cd(3)->SetLogz();
1933 cellAmp_masked->SetTitle(
"Masked Cell Amplitude");
1934 cellAmp_masked->SetXTitle(
"Cell Energy [GeV]");
1935 cellAmp_masked->SetYTitle(
"Abs. Cell Id");
1936 cellAmp_masked->GetYaxis()->SetTitleOffset(1.6);
1937 cellAmp_masked->Draw(
"colz");
1938 c1->cd(4)->SetLogz();
1939 cellTime_masked->SetTitle(
"Masked Cell Time");
1940 cellTime_masked->SetXTitle(
"Cell Time [ns]");
1941 cellTime_masked->SetYTitle(
"Abs. Cell Id");
1942 cellTime_masked->GetYaxis()->SetTitleOffset(1.6);
1943 cellTime_masked->Draw(
"colz");
1946 TCanvas *c1_ratio =
new TCanvas(
"CellPropRatio",
"II summary of cell properties ratio",1000,500);
1947 c1_ratio->ToggleEventStatus();
1948 c1_ratio->Divide(2);
1949 c1_ratio->cd(1)->SetLogz();
1950 cellAmp_masked->SetTitle(
"Masked Cell Amplitude");
1951 cellAmp_masked->GetZaxis()->SetRangeUser(0.0001,10e7);
1952 cellAmp_masked->Draw(
"colz");
1953 c1_ratio->cd(2)->SetLogz();
1956 TH2F* ratio2DAmp =(
TH2F*)cellAmp_masked->Clone(
"ratio2DAmp");
1957 TH2F* Sum2DIdeal =(
TH2F*)cellAmp_masked->Clone(
"Sum2DIdeal");
1958 Sum2DIdeal->Reset();
1962 for(
Int_t eBin=0;eBin<Sum2DIdeal->GetNbinsX();eBin++)
1964 Double_t binVal=hRefDistr->GetBinContent(eBin+1);
1965 for(
Int_t icell=0;icell<Sum2DIdeal->GetNbinsY();icell++)
1967 Sum2DIdeal->SetBinContent(eBin+1,icell+1,binVal);
1970 ratio2DAmp->SetTitle(
"Ratio of cell Amplitude to mean cell ampl.");
1971 ratio2DAmp->Divide(Sum2DIdeal);
1972 ratio2DAmp->GetZaxis()->UnZoom();
1973 ratio2DAmp->DrawCopy(
"colz");
1976 TLatex* textSM =
new TLatex(0.1,0.1,
"*test*");
1977 textSM->SetTextSize(0.06);
1978 textSM->SetTextColor(1);
1981 TCanvas *c1_proj =
new TCanvas(
"CellPropPProj",
"III summary of cell properties",1000,500);
1982 c1_proj->ToggleEventStatus();
1984 c1_proj->cd(1)->SetLogy();
1985 TH1D* projEnergyMask = cellAmp_masked->ProjectionX(Form(
"%sMask_Proj",cellAmp_masked->GetName()),
fStartCell,fNoOfCells);
1986 projEnergyMask->SetXTitle(
"Cell Energy [GeV]");
1987 projEnergyMask->GetYaxis()->SetTitleOffset(1.6);
1988 projEnergyMask->SetLineColor(kGreen+1);
1989 projEnergyMask->DrawCopy(
" hist");
1991 projEnergy->DrawCopy(
"same hist");
1992 TLegend *leg =
new TLegend(0.50,0.75,0.7,0.87);
1993 leg->AddEntry(projEnergy,
"all cells",
"l");
1994 leg->AddEntry(projEnergyMask,
"good cells",
"l");
1995 leg->SetTextSize(0.05);
1996 leg->SetBorderSize(0);
1997 leg->SetFillColorAlpha(10, 0);
1999 TLegend *legBig = (TLegend*)leg->Clone(
"legBig");
2000 legBig->SetTextSize(0.08);
2001 legBig->SetX1NDC(0.2);
2003 c1_proj->cd(2)->SetLogy();
2004 TH1* projTimeMask = cellTime_masked->ProjectionX(Form(
"%s_Proj",cellTime_masked->GetName()),
fStartCell,fNoOfCells);
2005 projTimeMask->SetXTitle(
"Cell Time [ns]");
2006 projTimeMask->GetYaxis()->SetTitleOffset(1.6);
2007 projTimeMask->GetYaxis()->SetRangeUser(1,projTimeMask->GetMaximum()*20);
2008 projTimeMask->SetLineColor(kGreen+1);
2009 projTimeMask->DrawCopy(
"hist");
2011 projTime->DrawCopy(
"same hist");
2015 TCanvas *c1_projSM =
new TCanvas(
"CellPropPProjSM",
"III summary of cell Energy per SM",1200,900);
2016 c1_projSM->Divide(5,4,0.001,0.001);
2017 TH1* projEnergyMaskSM[20];
2018 TH1* projEnergySM[20];
2019 for(
Int_t iSM=0;iSM<20;iSM++)
2021 c1_projSM->cd(iSM+1)->SetLogy();
2022 gPad->SetTopMargin(0.03);
2023 gPad->SetBottomMargin(0.11);
2024 projEnergyMaskSM[iSM] = cellAmp_masked->ProjectionX(Form(
"%sMask_ProjSM%i",cellAmp_masked->GetName(),iSM),
fStartCellSM[iSM]+1,
fStartCellSM[iSM+1]);
2025 projEnergyMaskSM[iSM]->SetTitle(
"");
2026 projEnergyMaskSM[iSM]->SetXTitle(Form(
"Cell Energy [GeV], SM%i",iSM));
2027 projEnergyMaskSM[iSM]->GetYaxis()->SetTitleOffset(1.6);
2028 projEnergyMaskSM[iSM]->GetYaxis()->SetLabelSize(0.06);
2029 projEnergyMaskSM[iSM]->GetXaxis()->SetLabelSize(0.06);
2030 projEnergyMaskSM[iSM]->GetXaxis()->SetRangeUser(0,20);
2031 projEnergyMaskSM[iSM]->GetXaxis()->SetTitleSize(0.06);
2032 projEnergyMaskSM[iSM]->SetLineColor(kGreen+1);
2033 projEnergyMaskSM[iSM]->DrawCopy(
" hist");
2036 projEnergySM[iSM]->DrawCopy(
"same hist");
2037 if(iSM==0)legBig->Draw(
"same");
2042 c1_projSM->Update();
2044 TCanvas *c1_projRSM =
new TCanvas(
"CellPropPProjRSM",
"III summary of cell Energy Ratio per SM",1200,900);
2045 c1_projRSM->Divide(5,4,0.001,0.001);
2046 for(
Int_t iSM=0;iSM<20;iSM++)
2048 c1_projRSM->cd(iSM+1)->SetLogy();
2049 gPad->SetTopMargin(0.03);
2050 gPad->SetBottomMargin(0.11);
2052 projEnergyMaskSM[iSM]->SetLineColor(kGray+1);
2053 projEnergyMaskSM[iSM]->Divide(hRefDistr);
2054 projEnergyMaskSM[iSM]->DrawCopy(
"hist");
2056 c1_projRSM->Update();
2058 TCanvas *c1_projTimeSM =
new TCanvas(
"CellPropPProjTimeSM",
"III summary of cell Time per SM",1200,900);
2059 c1_projTimeSM->Divide(5,4,0.001,0.001);
2060 TH1* projTimeMaskSM[20];
2061 TH1* projTimeSM[20];
2062 for(
Int_t iSM=0;iSM<20;iSM++)
2064 c1_projTimeSM->cd(iSM+1)->SetLogy();
2065 gPad->SetTopMargin(0.03);
2066 gPad->SetBottomMargin(0.11);
2067 projTimeMaskSM[iSM] = cellTime_masked->ProjectionX(Form(
"%sMask_ProjSMTime%i",cellAmp_masked->GetName(),iSM),
fStartCellSM[iSM]+1,
fStartCellSM[iSM+1]);
2068 projTimeMaskSM[iSM]->SetTitle(
"");
2069 projTimeMaskSM[iSM]->SetXTitle(Form(
"Cell Time [ns], SM%i",iSM));
2070 projTimeMaskSM[iSM]->GetYaxis()->SetTitleOffset(1.6);
2071 projTimeMaskSM[iSM]->GetYaxis()->SetLabelSize(0.06);
2072 projTimeMaskSM[iSM]->GetXaxis()->SetLabelSize(0.06);
2074 projTimeMaskSM[iSM]->GetXaxis()->SetTitleSize(0.06);
2075 projTimeMaskSM[iSM]->SetLineColor(kGreen+1);
2076 projTimeMaskSM[iSM]->DrawCopy(
" hist");
2078 if(iSM==0)legBig->Draw(
"same");
2080 projTimeSM[iSM]->DrawCopy(
"same hist");
2099 cellAmp_masked ->Scale(1.0/totalevents);
2105 ofstream
file(cellSummaryFile, ios::out | ios::trunc);
2106 ofstream fileBad(OADBFile_bad, ios::out | ios::trunc);
2107 ofstream fileDead(OADBFile_dead, ios::out | ios::trunc);
2108 ofstream fileWarm(OADBFile_warm, ios::out | ios::trunc);
2114 ofstream fileBadRbR(OADBFile_badRbR, ios::out | ios::trunc);
2115 ofstream fileDeadRbR(OADBFile_deadRbR, ios::out | ios::trunc);
2116 ofstream fileWarmRbR(OADBFile_warmRbR, ios::out | ios::trunc);
2120 file<<
"Dead cells : "<<endl;
2121 cout<<
" o Dead cells : "<<endl;
2126 file<<
"In EMCal: "<<endl;
2131 file<<
"In DCal: "<<endl;
2133 if(
fFlag[cellID]==1)
2137 else nDeadDCalCells++;
2139 if(
fFlag[cellID]==1)fileDead<<cellID<<endl;
2140 if(
fFlag[cellID]>1)fileBad<<cellID<<endl;
2147 file<<
"EMCal ("<<nDeadEMCalCells<<
" ="<<perDeadEMCal<<
"%), DCal ("<<nDeadDCalCells<<
" ="<<perDeadDCal<<
"%)"<<endl;
2148 cout<<
" o EMCal ("<<nDeadEMCalCells<<
" ="<<perDeadEMCal<<
"%), DCal ("<<nDeadDCalCells<<
" ="<<perDeadDCal<<
"%)"<<endl;
2150 file<<
"Bad cells: "<<endl;
2151 cout<<
" o Bad cells: "<<endl;
2156 file<<
"In EMCal: "<<endl;
2161 file<<
"In DCal: "<<endl;
2173 file<<
"EMCal ("<<nEMCalCells<<
" ="<<perBadEMCal<<
"%), DCal ("<<nDCalCells<<
" ="<<perBadDCal<<
"%)"<<endl;
2174 cout<<
" o EMCal ("<<nEMCalCells<<
" ="<<perBadEMCal<<
"%), DCal ("<<nDCalCells<<
" ="<<perBadDCal<<
"%)"<<endl;
2177 cout<<
" o Total: "<<endl;
2178 cout<<
" o Bad+Dead cells: "<<nDeadEMCalCells+nEMCalCells+nDeadDCalCells+nDCalCells<<
", this is "<<(nDeadEMCalCells+nEMCalCells+nDeadDCalCells+nDCalCells)*100/(1.0*fNoOfCells)<<
"% of the whole detector"<<endl;
2183 if(
fPrint==1)cout<<
" o Save the bad channel spectra to a .pdf file"<<endl;
2196 if(
fWarmCell[cell]==1)fileWarm<<cell<<endl;
2199 TCanvas *c2 =
new TCanvas(
"CellFlag",
"summary of cell flags",1200,800);
2200 c2->ToggleEventStatus();
2205 fhCellFlag->SetYTitle(
"flag by which cell was excluded");
2225 TString name1,name2,name3,name4,name5,name6;
2227 c1_ratio->SaveAs(name1);
2231 c1_proj->SaveAs(name3);
2233 c1_projSM->SaveAs(name4);
2235 c1_projRSM->SaveAs(name5);
2237 c1_projTimeSM->SaveAs(name6);
2239 fRootFile->WriteObject(c1_ratio,c1_ratio->GetName());
2240 fRootFile->WriteObject(c1,c1->GetName());
2241 fRootFile->WriteObject(c1_proj,c1_proj->GetName());
2242 fRootFile->WriteObject(c1_projSM,c1_projSM->GetName());
2243 fRootFile->WriteObject(c1_projRSM,c1_projRSM->GetName());
2244 fRootFile->WriteObject(c1_projTimeSM,c1_projTimeSM->GetName());
2246 fRootFile->WriteObject(c2,c2->GetName());
2248 fRootFile->WriteObject(cellAmp_masked,cellAmp_masked->GetName());
2249 fRootFile->WriteObject(ratio2DAmp,ratio2DAmp->GetName());
2254 fRootFile->WriteObject(projEnergyMask,projEnergyMask->GetName());
2255 fRootFile->WriteObject(projEnergy,projEnergy->GetName());
2262 Int_t nWEMCalCells =0;
2263 Int_t nWDCalCells =0;
2264 file.open(cellSummaryFile, ios::out | ios::app);
2267 file<<
"Warm cells : "<<endl;
2268 if(
fPrint==1)cout<<
" o Warm cells : "<<endl;
2273 file<<
"In EMCal: "<<endl;
2278 file<<
"In DCal: "<<endl;
2290 file<<
"EMCal ("<<nWEMCalCells<<
" ="<<perWarmEMCal<<
"%), DCal ("<<nWDCalCells<<
" ="<<perWarmDCal<<
"%)"<<endl;
2291 if(
fPrint==1)cout<<
" o EMCal ("<<nWEMCalCells<<
" ="<<perWarmEMCal<<
"%), DCal ("<<nWDCalCells<<
" ="<<perWarmDCal<<
"%)"<<endl;
2297 ofstream file2(aliceTwikiTable, ios::out | ios::app);
2300 file2<<
"1=energy/hit, 2= hit/event"<<endl;
2302 file2<<
"| *Detector* | *No of cells* | *percentage* |"<<endl;
2303 file2<<
"| Dead EMCal | "<<nDeadEMCalCells<<
" | "<<perDeadEMCal<<
"% |"<<endl;
2304 file2<<
"| Bad EMCal | "<<nEMCalCells<<
" | "<<perBadEMCal<<
"% |"<<endl;
2305 file2<<
"| - Warm EMCal | "<<nWEMCalCells<<
" | "<<perWarmEMCal<<
"% |"<<endl;
2306 file2<<
"| Dead DCal | "<<nDeadDCalCells<<
" | "<<perDeadDCal<<
"% |"<<endl;
2307 file2<<
"| Bad DCal | "<<nDCalCells<<
" | "<<perBadDCal<<
"% |"<<endl;
2308 file2<<
"| - Warm DCal | "<<nWDCalCells<<
" | "<<perWarmDCal<<
"% |"<<endl;
2309 file2<<
"| Summ D+B | "<<nDeadEMCalCells+nEMCalCells+nDeadDCalCells+nDCalCells<<
" | "<<(nDeadEMCalCells+nEMCalCells+nDeadDCalCells+nDCalCells)*100/(1.0*fNoOfCells)<<
"% |"<<endl;
2346 gROOT->SetStyle(
"Plain");
2347 gStyle->SetOptStat(0);
2348 gStyle->SetFillColor(kWhite);
2349 gStyle->SetTitleFillColor(kWhite);
2350 gStyle->SetPalette(91);
2356 fRootFile->WriteObject(hRefDistr,hRefDistr->GetName());
2357 Int_t firstCanvas=0;
2359 TLatex*
text =
new TLatex(0.2,0.8,
"*Candidate*");
2360 text->SetTextSize(0.07);
2361 text->SetTextColor(kOrange-3);
2364 TLatex* text2 =
new TLatex(0.2,0.8,
"*Not a Candidate*");
2365 text2->SetTextSize(0.08);
2366 text2->SetTextColor(8);
2369 TLatex* textA =
new TLatex(0.65,0.62,
"*test*");
2370 textA->SetTextSize(0.04);
2371 textA->SetTextColor(1);
2377 std::vector<Int_t> channelVector;
2378 channelVector.clear();
2379 cout<<
" o Start printing into .pdf for version: "<<version<<endl;
2382 if(
fFlag[cell]==1 && version==0)channelVector.push_back(cell);
2383 if(
fFlag[cell]>1 && version==1)channelVector.push_back(cell);
2384 if(
fFlag[cell]==0 && version==2)channelVector.push_back(cell);
2385 if(
fFlag[cell]>1 && version==10)channelVector.push_back(cell);
2386 if(
fFlag[cell]==0 && version==20)channelVector.push_back(cell);
2388 if(cell%2000==0)cout<<
"...cell No."<<cell<<endl;
2390 if(channelVector.size()==9 || cell == fNoOfCells-1)
2395 TCanvas *c1 =
new TCanvas(
"badcells",
"badcells",1000,750);
2396 if(channelVector.size() > 6) c1->Divide(3,3);
2397 else if (channelVector.size() > 3) c1->Divide(3,2);
2398 else c1->Divide(3,1);
2400 TLegend *leg =
new TLegend(0.7, 0.7, 0.9, 0.9);
2401 for(
Int_t i=0; i< (
Int_t)channelVector.size() ; i++)
2403 if(channelVector.size() >=
fNoOfCells) cout<<
"Massive problem"<<endl;
2404 sprintf(name,
"Cell %d",channelVector.at(i)) ;
2405 TH1 *hCell =
fCellAmplitude->ProjectionX(name,channelVector.at(i)+1,channelVector.at(i)+1);
2406 sprintf(title,
"Cell No: %d Entries: %d",channelVector.at(i), (
Int_t)hCell->GetEntries()) ;
2409 c1->cd(i%9 + 1)->SetLogy();
2412 leg->AddEntry(hRefDistr,
"mean of good",
"l");
2413 leg->AddEntry(hCell,
"current",
"l");
2417 if(candidate==1)
fWarmCell[channelVector.at(i)]=candidate;
2420 hCell->Divide(hRefDistr);
2430 hCell->SetLineColor(kBlue+1);
2431 hCell->GetXaxis()->SetTitle(
"E (GeV)");
2432 hCell->GetYaxis()->SetTitle(
"N Entries");
2433 hCell->GetXaxis()->SetRangeUser(0.,10.);
2434 hCell->SetLineWidth(1) ;
2435 hCell->SetTitle(title);
2436 hRefDistr->SetLineColor(kGray+2);
2437 hRefDistr->SetLineWidth(1);
2439 hCell->Draw(
"hist");
2441 if(version==1 || version==2)hRefDistr->Draw(
"same hist") ;
2444 if(candidate==1 && (version==1 || version==10))
2446 gPad->SetFrameFillColor(kYellow-10);
2451 textA->SetTitle(Form(
"Excluded by No. %d",
fFlag[channelVector.at(i)]));
2452 textA->DrawLatex(0.65,0.62,Form(
"Excluded by No. %d",
fFlag[channelVector.at(i)]));
2454 if(candidate==0 && (version==2 || version==20))
2456 gPad->SetFrameFillColor(kYellow-10);
2460 if(version<2)leg->Draw();
2463 if(channelVector.size()<9 || cell == fNoOfCells-1)
2465 internal_pdfName +=
")";
2466 c1->Print(internal_pdfName.Data());
2468 else if(firstCanvas==0)
2470 internal_pdfName +=
"(";
2471 c1->Print(internal_pdfName.Data());
2476 c1->Print(internal_pdfName.Data());
2480 channelVector.clear();
2509 if(warmIn==0 &&
fFlag[cell]!=0 )
continue;
2511 if(warmIn==2 &&
fWarmCell[cell]==0)
continue;
2515 hgoodMean->Add(hGoodAmp);
2517 hgoodMean->Scale(1.0/NrGood);
2534 TString Name = Form(
"%s_ratio",histogram->GetName());
2535 TH1* ratio=(
TH1*)histogram->Clone(Name);
2536 ratio->Divide(reference);
2549 Int_t binHeightOne = reference->FindLastBinAbove(1.0/totalevents);
2550 Double_t binCentreHeightOne = reference->GetBinCenter(binHeightOne);
2551 Double_t thirdBinCentre = reference->GetBinCenter(3);
2560 if(ratio->FindLastBinAbove(0)<ratio->FindBin(binCentreHeightOne*percentageOfLast))
2569 ratio->GetXaxis()->SetRangeUser(thirdBinCentre,10);
2570 if(ratio->GetMaximum()>highestRatio)
2580 Int_t nullEntries=0;
2581 for(
Int_t i=2;i<binHeightOne;i++)
2583 if(ratio->GetBinContent(i)!=0)mean+=ratio->GetBinContent(i);
2586 mean*=1.0/(binHeightOne-1-nullEntries);
2587 if(mean>maxMean || mean<minMean)
2599 ratio->GetXaxis()->SetRangeUser(0,binCentreHeightOne);
2600 Double_t localMaxBin=ratio->GetMaximumBin();
2602 for(
Int_t i=2;i<binHeightOne;i++)
2605 if(ratio->GetBinContent(i)<=0)
continue;
2606 if(i>localMaxBin-3 && i<localMaxBin+3)
continue;
2607 mean+=ratio->GetBinContent(i);
2609 mean*=1.0/(binHeightOne-1);
2610 ratio->GetXaxis()->SetRangeUser(thirdBinCentre,binCentreHeightOne);
2612 if(ratio->GetMaximum()>mean*higherThanMean)
2624 Int_t cliffBin = ratio->FindBin(4);
2625 for(
Int_t i=cliffBin-10;i<cliffBin+11;i++)
2628 if(ratio->GetBinContent(i)<=0)
continue;
2629 if(i<=cliffBin) binsBefore++;
2630 if(i>cliffBin) binsAfter++;
2631 if(i<=cliffBin) beforeCliff+=ratio->GetBinContent(i);
2632 if(i>cliffBin) afterCliff+=ratio->GetBinContent(i);
2633 beforeCliff*=1.0/binsBefore;
2634 afterCliff*=1.0/binsAfter;
2636 if((beforeCliff-afterCliff)>cliffSize*afterCliff)
2638 if(beforeCliff!=0 && afterCliff!=0)candidate=0;
2639 if(beforeCliff!=0 && afterCliff!=0)cout<<
"5"<<endl;
2670 Bool_t coveredByTRDSupportStruc=0;
2672 if((collumn>3 && collumn<9) || (collumn>32 && collumn<37) || (collumn>57 && collumn<61) || (collumn>84 && collumn<90) ||
2673 (row==1) ||(row>20 && row<25) || (row>44 && row<49) || (row>68 && row<73) || (row>91 && row<96) ||
2674 (row>116 && row<120)|| row==127 || (row>148 && row<152) || (row>172 && row<177) || (row>197 && row<201)
2677 coveredByTRDSupportStruc=1;
2679 return coveredByTRDSupportStruc;
2692 gStyle->SetPalette(55);
2693 gStyle->SetPalette(91);
2696 histoName = Form(
"2DChannelMap_Flag%d_V%i",flagBegin,
fTrial);
2697 if(flagBegin==0 && flagEnd==0)histoName = Form(
"2DChannelMap_Flag100_V%i",
fTrial);
2700 plot2D->GetXaxis()->SetTitle(
"cell column (#eta direction)");
2701 plot2D->GetYaxis()->SetTitle(
"cell row (#phi direction)");
2703 Int_t cellColumn=0,cellRow=0;
2704 Int_t cellColumnAbs=0,cellRowAbs=0;
2716 cout<<
"Problem! wrong calculated number of max col and max rows"<<endl;
2717 cout<<
"current col: "<<cellColumnAbs<<
", max col"<<
fNMaxColsAbs<<endl;
2718 cout<<
"current row: "<<cellRowAbs<<
", max row"<<
fNMaxRowsAbs<<endl;
2720 if(flagEnd==-1 &&
fFlag[cell]==flagBegin) plot2D->SetBinContent(cellColumnAbs,cellRowAbs,1);
2721 if(flagEnd!=0 && flagEnd!=-1 &&
fFlag[cell]>=flagBegin &&
fFlag[cell]<=flagEnd)plot2D->SetBinContent(cellColumnAbs,cellRowAbs,1);
2722 if(flagBegin==0 && flagEnd==0 &&
fWarmCell[cell]==1) plot2D->SetBinContent(cellColumnAbs,cellRowAbs,1);
2726 TCanvas *c1 =
new TCanvas(histoName,histoName,500,500);
2727 c1->ToggleEventStatus();
2731 plot2D->Draw(
"colz");
2734 if(flagBegin==0 && flagEnd==-1) text =
new TLatex(0.2,0.8,
"Good Cells");
2735 if(flagBegin==1) text =
new TLatex(0.2,0.8,
"Dead Cells");
2736 if(flagBegin>1) text =
new TLatex(0.2,0.8,
"Bad Cells");
2737 if(flagBegin==0 && flagEnd==0) text =
new TLatex(0.2,0.8,
"Warm Cells");
2738 text->SetTextSize(0.06);
2740 text->SetTextColor(1);
2747 fRootFile->WriteObject(plot2D,plot2D->GetName());
2764 sprintf(name,
"Cell %d",cell) ;
2783 cout<<
"******* Debug No "<<number<<
" ********"<<endl;
2785 cout<<
"*** number of period analyses: "<<
fAnalysisVector.size()<<endl;
2786 cout<<
"*** number of man mask cells: "<<
fManualMask.size()<<endl;
2787 cout<<
"*** Bad+Dead(!0) fFlag elements: "<<
fFlag.size()-zeroFlag<<endl;
2788 cout<<
"*** Warm(!0) fWarmCell elements: "<<
fWarmCell.size()-zeroWarm<<endl;
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
void FlagAsBad_Time(Int_t crit, TH1F *inhisto, Double_t nSig=3)
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.
std::vector< Int_t > fFlag
! fFlag[CellID] = 0 (ok),1 (dead),2 and higher (bad certain criteria) start at 0 (cellID 0 = histobin...
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
Double_t fEndLowerBound
Lower bound.
TLatex * text[5]
option to what and if export to output file
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 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.
Int_t fStartCellSM[21]
CellIDs of first cell in the 20SMs plus last cell ID.
Bool_t fRunBRunMap
Produce truely run-by-run maps in a separate folder.
TList * fOutputListGoodRatio
! list with good channel amplitude ratios, stored in fRootFile
TString fExternalBadMapName
Load an external bad map to test the effect on block or a given run.
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.
std::vector< Bool_t > fWarmCell
! fWarmCell[CellID] = 0 (really bad), fWarmCell[CellID] = 1 (candidate for warm), ...
void LoadExternalBadMap()
TH1F * fhCellWarm
! histogram that stores whether the cell was marked as warm
std::vector< Int_t > fSMMask
! fSMMask is filled with SM numbers that need to be masked by hand.
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)
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...
void AddMaskSM(Int_t iSM)
TString fAnalysisOutputRbR
For a compact summary of true run-by-run BC maps.
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.)
Bool_t fTrackCellRecord
Track the non-zero elements in the flags throughout the routine.
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...
TH1F * BuildHitAndEnergyMeanScaled(Int_t crit, Double_t emin=0.1, Double_t emax=2.)
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)
void PrintCellInfo(Int_t number)
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