20 #include <Riostream.h> 30 #include <AliEMCALGeometry.h> 32 #include <AliAODEvent.h> 51 fCurrentRunNumber(-1),
56 fCellStartDCal(12288),
67 fExternalFileName(
""),
68 fExternalBadMapName(
""),
156 gROOT->ProcessLine(
"gErrorIgnoreLevel = kWarning;");
182 fRootFile =
new TFile(fileName,
"recreate");
197 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};
202 cout<<
"Number of supermod: "<<nModules<<endl;
266 cout<<
". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ."<<endl;
267 cout<<
". . .Start process by converting files. . . . . . . . . . . ."<<endl;
272 Printf(
"File not produced, exit");
280 cout<<
". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ."<<endl;
281 cout<<
". . .Start process by loading external file. . . . . . . . . . ."<<endl;
287 cout<<
". . .Load inputfile with name: "<<
fMergedFileName<<
" . . . . . . . ."<<endl;
292 if(!mergedFileInput->IsOpen())
294 Printf(
"Error! Input file not found, abort");
305 cout<<
". . .Continue process by . . . . . . . . . . . ."<<endl;
311 cout<<
"o o o Flag dead cells o o o"<<endl;
320 cout<<
"o o o Flag bad cells o o o"<<endl;
327 if(
fPrint==1)cout<<
"o o o Write .txt for each period analyis with bad cells o o o"<<endl;
338 if(
fPrint==1)cout<<
"o o o Create summary documents for the entire analysis o o o"<<endl;
349 Int_t binHeightOne = hRefDistr->FindLastBinAbove(1.0/totalevents);
350 Double_t binCentreHeightOne = hRefDistr->GetBinCenter(binHeightOne);
351 cout<<
". . .Recomendation:"<<endl;
352 cout<<
". . .With the current statistic on average a cell has 1 hit at "<<binCentreHeightOne<<
" GeV"<<endl;
353 cout<<
". . .so it makes no sense to select energy ranges >"<<binCentreHeightOne<<
"GeV as cells will be"<<endl;
354 cout<<
". . .marked bad just due to the lack of statistic"<<endl;
355 cout<<
". . .your selected lower bond is "<<
fEndLowerBound<<
" GeV"<<endl;
356 if(binCentreHeightOne>=
fEndLowerBound) cout<<
". . .This means you are OK!"<<endl;
357 if(binCentreHeightOne<
fEndLowerBound) cout<<
". . .#!#!#!#! CAREFUL THIS COULD CAUSE TROUBLE AND THROW OUT MORE CELLS THAN NECESSARY #!#!#!#! "<<endl;
358 cout<<
". . .End of process . . . . . . . . . . . . . . . . . . . . ."<<endl;
359 cout<<
". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ."<<endl;
370 cout<<
"o o o Start conversion process o o o"<<endl;
374 TH1F *hNEventsProcessedPerRun=
new TH1F(
"hNEvents",
"Number of processed events in analyzed runs",1,0,1);
375 TH2F *hCellAmplitude;
379 cout<<
"o o o Open .txt file with run indices. Name = " <<
fRunList << endl;
380 FILE *pFile = fopen(
fRunList.Data(),
"r");
383 cout<<
"couldn't open file!"<<endl;
394 ncols = fscanf(pFile,
" %d ",&q);
403 const Int_t nRun = nlines ;
408 cout<<
"o o o Start merging process of " << nRun <<
" files"<< endl;
411 for(
Int_t i = 0 ; i < nRun ; i++)
415 infile = Form(
"%s.root",base.Data()) ;
417 cout<<
" o Open .root file with name: "<<infile<<endl;
418 TFile *f = TFile::Open(infile);
423 cout<<
"Couldn't open/find .root file: "<<infile<<endl;
426 TDirectoryFile *
dir = (TDirectoryFile *)f->Get(
fQADirect);
429 cout<<
"Couln't open directory file in .root file: "<<infile<<
", directory: "<<
fQADirect<<endl;
435 cout <<
"Couln't get TList from directory file: "<<
fQADirect<<endl;
443 hAmpId =(
TH2F*)outputList->FindObject(
"EMCAL_hAmpId");
446 Printf(
"hAmpId not found");
452 hAmpId->SetName(
"hCellAmplitude");
453 hAmpId->SetTitle(
"Cell Amplitude");
456 hTimeId =(
TH2F*)outputList->FindObject(
"EMCAL_hTimeId");
459 Printf(
"hTimeId not found");
465 hTimeId->SetName(
"hCellTime");
466 hTimeId->SetTitle(
"Cell Time");
472 hCellAmplitude=(
TH2F*)hAmpId->Clone(
"DummyName1");
473 hCellAmplitude->Reset();
474 hCellAmplitude->SetDirectory(0);
476 hCellTime=(
TH2F*)hTimeId->Clone(
"DummyName2");
478 hCellTime->SetDirectory(0);
481 hNEvents =(TH1F *)outputList->FindObject(
"hNEvents");
484 Printf(
"hNEvents not found");
488 nEntr = (
Int_t)hNEvents->GetEntries();
493 cout <<
" o File to small to be merged. Only N entries " << nEntr << endl;
496 cout <<
" o File with N entries " << nEntr<<
" will be merged"<< endl;
498 hCellAmplitude->Add(hAmpId);
499 hCellTime->Add(hTimeId);
500 hNEventsProcessedPerRun->Add(hNEvents);
505 TFile *singleRunFile = TFile::Open(singleRunFileName,
"recreate");
512 singleRunFile->Close();
514 outputList->Delete();
523 cout<<
"o o o Save the merged histogramms to .root file with name: "<<
fMergedFileName<<endl;
524 cout<<
"o o o "<<nEntrTot<<
" events were merged"<<endl;
528 hNEventsProcessedPerRun->Write();
529 hCellAmplitude->SetName(
"hCellAmplitude");
530 hCellAmplitude->SetTitle(
"Cell Amplitude");
531 hCellAmplitude->Write();
532 hCellTime->SetName(
"hCellTime");
533 hCellTime->SetTitle(
"Cell Time");
536 cout<<
"o o o End conversion process o o o"<<endl;
555 TFile* outputRoot = TFile::Open(extRootFileName.Data());
557 TH1F* hFlags =(TH1F*)outputRoot->Get(
"fhCellFlag");
563 Double_t extFlag = hFlags->GetBinContent(cell+1);
566 fFlag[cell] =extFlag;
586 PeriodAnalysis(periodArray.At(0),periodArray.At(1),periodArray.At(2),periodArray.At(3));
591 cout<<
"o o o End of bad channel analysis o o o"<<endl;
601 cout<<
"o o o Manually mask SM "<<iSM<<
" o o o"<<endl;
625 periodArray.AddAt((
Double_t)criteria,0);
626 periodArray.AddAt(nsigma,1);
627 periodArray.AddAt(emin,2);
628 periodArray.AddAt(emax,3);
650 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;
651 if(
fPrint==1)cout<<
"o o o PeriodAnalysis for flag "<<criterion<<
" o o o"<<endl;
652 if(
fPrint==1 && criterion != 3)cout<<
"o o o Done in the energy range E "<<emin<<
" - "<<emax<<endl;
653 if(
fPrint==1 && criterion == 3)cout<<
"o o o Done in the time range t "<<emin<<
" - "<<emax<<endl;
666 if(
fPrint==1)cout<<
"o o o Analyze average cell distributions o o o"<<endl;
668 if(
fPrint==1)cout<<
"o o o Analyze average cell distributions o o o"<<endl;
671 if(criterion == 3) histogram =
BuildTimeMean(criterion, emin, emax);
673 if(criterion==1 || criterion == 4)
677 else FlagAsBad(criterion, histogram, nsigma, 200);
679 if(criterion==2 || criterion == 5)
683 else FlagAsBad(criterion, histogram, nsigma, 601);
699 if(
fPrint==1)cout<<
" o Calculate average cell hit per event and average cell energy per hit "<<endl;
701 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);
702 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);
703 histogram->SetXTitle(
"Abs. Cell Id");
704 if(crit==1)histogram->SetYTitle(
"Energy per hit");
705 if(crit==2)histogram->SetYTitle(
"Number of hits in cell");
706 histogram->GetXaxis()->SetNdivisions(510);
709 TH1F* pojection = (TH1F*)
fCellAmplitude->ProjectionX(
"Intermediate");
710 fnEventsInRange = pojection->Integral(pojection->GetBinContent(emin),pojection->GetBinContent(emax));
724 if (E < emin || E > emax ||
fFlag[cell]!=0)
continue;
731 if(crit==2) histogram->SetBinContent(cell+1, Nsum);
732 if(Nsum > 0. && crit==1)histogram->SetBinContent(cell+1, Esum/(Nsum));
756 if(
fPrint==1)cout<<
" o Calculate average cell hit per event and average cell energy per hit "<<endl;
757 TH1F *histogram = NULL;
758 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);
759 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);
760 histogram->SetXTitle(
"Abs. Cell Id");
761 if(crit==4)histogram->SetYTitle(
"Energy per hit");
762 if(crit==5)histogram->SetYTitle(
"Number of hits in cell");
763 histogram->GetXaxis()->SetNdivisions(510);
768 TH1F *hEnergyCol =
new TH1F(
"hEnergyCol",
"hEnergyCol", 100,0.,100.);
769 TH1F *hEnergyRow =
new TH1F(
"hEnergyRow",
"hEnergyRow", 250,0.,250.);
773 Int_t cellCol, cellRow, trash, col, row;
780 for(
int iCell = 1; iCell <=
fNoOfCells; iCell++){
782 if(
fFlag[iCell -1] == 0){
783 for(
int k = hEnergyScaled->GetXaxis()->FindBin(emin); k <= hEnergyScaled->GetXaxis()->FindBin(emax); k++){
784 NoOfHits += hEnergyScaled->GetBinContent(k, iCell);
787 arrHits[iCell - 1] = NoOfHits;
796 TH1D *hHitDistrib_forScaling =
new TH1D(
"hHitDistrib_forScaling",
"hHitDistrib_forScaling",1000,0.,TMath::Median(
fNoOfCells,arrHits)*4);
797 TF1 *fgausForScaling =
new TF1(
"fgausForScaling",
"gaus", 0.,TMath::Median(
fNoOfCells,arrHits)*4);
798 TVectorD fFlagForScaling;
804 for(
int k = hEnergyScaled->GetXaxis()->FindBin(emin); k <= hEnergyScaled->GetXaxis()->FindBin(emax); k++){
805 if(crit==5){dhits += hEnergyScaled->GetBinContent(k, i);}
807 dhits += hEnergyScaled->GetBinContent(k, i + 1)*hEnergyScaled->GetXaxis()->GetBinCenter(k);
808 dNumOfHits += hEnergyScaled->GetBinContent(k, i + 1);
811 if(crit==4 && dNumOfHits > 0){dhits = dhits / dNumOfHits;}
813 hHitDistrib_forScaling->Fill(dhits);
819 fgausForScaling->SetParameter(1, hHitDistrib_forScaling->GetBinCenter(hHitDistrib_forScaling-> GetMaximumBin()));
820 hHitDistrib_forScaling->Fit(fgausForScaling,
"MQ0");
821 hHitDistrib_forScaling->Fit(fgausForScaling,
"MQ0");
823 for(
int iCell = 1; iCell <=
fNoOfCells; iCell++){
826 for(
int k = hEnergyScaled->GetXaxis()->FindBin(emin); k <= hEnergyScaled->GetXaxis()->FindBin(emax); k++){
827 if(crit==5){dhits += hEnergyScaled->GetBinContent(k, iCell);}
829 dhits += hEnergyScaled->GetBinContent(k, iCell + 1)*hEnergyScaled->GetXaxis()->GetBinCenter(k);
830 dNumOfHits += hEnergyScaled->GetBinContent(k, iCell + 1);
833 if(crit==4 && dNumOfHits > 0){dhits = dhits / dNumOfHits;}
834 if(dhits > fgausForScaling->GetParameter(1) + 5* fgausForScaling->GetParameter(2) || dhits < fgausForScaling->GetParameter(1) - 5* fgausForScaling->GetParameter(2)){
835 fFlagForScaling[iCell - 1] = 1;
841 delete hHitDistrib_forScaling;
842 delete fgausForScaling;
853 for(
int iter = 0; iter < 5; iter++){
855 std::vector<Double_t> vecCol[100];
856 std::vector<Double_t> vecRow[250];
880 for(
int iCell = 0; iCell <
fNoOfCells; iCell++){
881 if(
fFlag[iCell] == 0 && fFlagForScaling[iCell] == 0){
885 for (
int EBin = hEnergyScaled->GetXaxis()->FindBin(emin); EBin < hEnergyScaled->GetXaxis()->FindBin(emax); EBin++) {
886 if(crit==5){dCellEnergy += hEnergyScaled->GetBinContent(EBin, iCell + 1);}
888 dCellEnergy += hEnergyScaled->GetBinContent(EBin, iCell + 1)*hEnergyScaled->GetXaxis()->GetBinCenter(EBin);
889 dNumOfHits += hEnergyScaled->GetBinContent(EBin, iCell + 1);
893 if(crit==4 && dNumOfHits > 0){dCellEnergy = dCellEnergy / dNumOfHits;}
895 if( dCellEnergy > 0.){
896 hEnergyCol->Fill(col + 0.5, dCellEnergy);
897 hEnergyRow->Fill(row + 0.5, dCellEnergy);
898 vecCol[col].push_back(dCellEnergy);
899 vecRow[row].push_back(dCellEnergy);
905 for(
int iCol = 1; iCol <= hEnergyCol->GetNbinsX() ; iCol++){
906 if(vecCol[iCol -1].size() > 0.){
907 hEnergyCol->SetBinContent(hEnergyCol->FindBin(iCol - 0.5), hEnergyCol->GetBinContent(hEnergyCol->FindBin(iCol - 0.5))/vecCol[iCol-1].size() );
912 for(
int iRow = 1; iRow <= hEnergyRow->GetNbinsX() ; iRow++){
913 if(vecRow[iRow -1].size() > 0.){
914 hEnergyRow->SetBinContent(hEnergyRow->FindBin(iRow - 0.5), hEnergyRow->GetBinContent(hEnergyRow->FindBin(iRow - 0.5))/vecRow[iRow-1].size() );
919 fFitRow =
new TF1(
"fFitRow",
"[0]",0.,250.);
920 fFitRow->SetParameter(0, hEnergyRow->GetBinContent(10));
921 Double_t MeanRow = hEnergyRow->GetBinContent(10);
924 fFitCol =
new TF1(
"fFitCol",
"[0]",0.,100.);
925 fFitCol->SetParameter(0, hEnergyCol->GetBinContent(10));
926 Double_t MeanCol = hEnergyCol->GetBinContent(10);
930 for(
int iCell = 0; iCell <
fNoOfCells; iCell++){
932 if (hEnergyCol->GetBinContent(col + 1) > 0.) {
933 for(
int EBin = 1; EBin < hEnergyScaled->GetNbinsX(); EBin++) {
934 hEnergyScaled->SetBinContent(EBin, iCell + 1, hEnergyScaled->GetBinContent(EBin, iCell + 1) * (MeanCol / hEnergyCol->GetBinContent(col + 1)));
940 for(
int iCell = 0; iCell <
fNoOfCells; iCell++){
942 if (hEnergyRow->GetBinContent(row + 1) > 0.) {
943 for(
int EBin = 1; EBin < hEnergyScaled->GetNbinsX(); EBin++) {
944 hEnergyScaled->SetBinContent(EBin, iCell + 1, hEnergyScaled->GetBinContent(EBin, iCell + 1) * (MeanRow / hEnergyRow->GetBinContent(row + 1)));
962 for (
Int_t j = 1; j <= hEnergyScaled->GetNbinsX(); j++)
965 Double_t E = hEnergyScaled->GetXaxis()->GetBinCenter(j);
966 Double_t N = hEnergyScaled->GetBinContent(j, cell+1);
968 if (E < emin || E > emax ||
fFlag[cell]!=0)
continue;
975 if(crit==5) histogram->SetBinContent(cell+1, Nsum);
976 if(Nsum > 0. && crit==4)histogram->SetBinContent(cell+1, Esum/(Nsum));
980 delete hEnergyScaled;
1001 if(
fPrint==1)cout<<
" o Calculate maximum of cell time distribution "<<endl;
1003 TH1F *histogram = NULL;
1004 histogram =
new TH1F(Form(
"timeMax_t%.2f-%.2f",tmin,tmax),Form(
"Maximum of time distr., %.2f < t < %.2f ns",tmin,tmax),
fNoOfCells,0,
fNoOfCells);
1005 histogram->SetXTitle(
"Abs. Cell Id");
1006 histogram->SetYTitle(
"time max");
1007 histogram->GetXaxis()->SetNdivisions(510);
1013 for(
int iCell = 1; iCell <=
fNoOfCells; iCell ++){
1014 if(
fFlag[iCell - 1] != 0) {
continue; }
1017 for(
int iTime = 1; iTime <=
fCellTime->GetNbinsX(); iTime++){
1018 dHits =
fCellTime->GetBinContent(iTime, iCell);
1019 if(
fCellTime->GetXaxis()->GetBinCenter(iTime) > tmin &&
fCellTime->GetXaxis()->GetBinCenter(iTime) < tmax){
1025 histogram->SetBinContent(iCell, dAll/dIn);
1027 histogram->SetBinContent(iCell, 0.);
1041 Int_t manualMaskCounter=0;
1058 if(nSum == 0 &&
fFlag[cell]==0)
1069 manualMaskCounter++;
1072 if(
fPrint==1)cout<<
" o Number of dead cells: "<<sumOfExcl<<endl;
1073 if(
fPrint==1)cout<<
" ("<<sumOfExcl<<
")"<<endl;
1093 gStyle->SetOptStat(0);
1094 gStyle->SetOptFit(0);
1095 if(
fPrint==1 && crit==1)cout<<
" o Fit average energy per hit distribution"<<endl;
1096 if(
fPrint==1 && crit==2)cout<<
" o Fit average hit per event distribution"<<endl;
1097 if(
fPrint==1 && crit==3)cout<<
" o Fit average hit maximum distribution"<<endl;
1099 Int_t cellColumn=0,cellRow=0;
1100 Int_t cellColumnAbs=0,cellRowAbs=0;
1103 TString histoName=inhisto->GetName();
1108 Double_t dminVal = inhisto->GetMinimum(0);
1109 Double_t dmaxVal = inhisto->GetMaximum();
1117 if((crit==2 || crit == 5) && inputBins==-1) dnbins=dmaxVal-dminVal;
1118 if((crit==1 || crit == 4) && inputBins==-1) dnbins=200;
1125 Int_t numBins = inhisto->GetXaxis()->GetNbins();
1130 for (
int i = 0; i < numBins; i++)
1134 if(x[i]==0)y[i] = 0;
1136 medianOfHisto = TMath::Median(numBins,x,y);
1141 if(medianOfHisto*10<dmaxVal)
1144 dmaxVal=medianOfHisto+0.2*(dmaxVal-medianOfHisto);
1147 if(crit==2 || crit == 5)
1149 dnbins=dmaxVal-dminVal;
1152 if(dnbins>2000)dnbins=0.01*(dmaxVal-dminVal);
1153 if(dnbins>2000)dnbins=0.001*(dmaxVal-dminVal);
1154 if(dnbins<100) dnbins=0.02*(dmaxVal-dminVal);
1157 if(crit==1 || crit == 4)
1159 dnbins=(dmaxVal-dminVal)*500;
1168 dnbins =
fCellTime->GetXaxis()->GetNbins();
1169 dminVal=
fCellTime->GetXaxis()->GetBinCenter(1)-(binWidth*1.0)/2.0;
1170 dmaxVal=
fCellTime->GetXaxis()->GetBinCenter(dnbins)+(binWidth*1.0)/2.0;
1171 cout<<
"set the new histo with following settings- bins: "<<dnbins<<
", min val = "<<dminVal<<
", max val:"<<dmaxVal<<endl;
1174 TH1F *distrib =
new TH1F(Form(
"%sDistr",(
const char*)histoName),
"", dnbins, dminVal, dmaxVal);
1175 distrib->SetXTitle(inhisto->GetYaxis()->GetTitle());
1176 distrib->SetYTitle(
"Entries");
1177 TH1F *distrib_wTRDStruc =
new TH1F(Form(
"%sDistr_wTRD",(
const char*)histoName),
"", dnbins, dminVal, dmaxVal);
1178 TH1F *distrib_woTRDStruc=
new TH1F(Form(
"%sDistr_woTRD",(
const char*)histoName),
"", dnbins, dminVal, dmaxVal);
1182 plot2D->GetXaxis()->SetTitle(
"cell column (#eta direction)");
1183 plot2D->GetYaxis()->SetTitle(
"cell row (#phi direction)");
1197 distrib->Fill(inhisto->GetBinContent(cell+1));
1204 cout<<
"Problem! wrong calculated number of max col and max rows"<<endl;
1205 cout<<
"current col: "<<cellColumnAbs<<
", max col"<<
fNMaxColsAbs<<endl;
1206 cout<<
"current row: "<<cellRowAbs<<
", max row"<<
fNMaxRowsAbs<<endl;
1208 plot2D->SetBinContent(cellColumnAbs,cellRowAbs,inhisto->GetBinContent(cell+1));
1212 distrib_wTRDStruc->Fill(inhisto->GetBinContent(cell+1));
1216 distrib_woTRDStruc ->Fill(inhisto->GetBinContent(cell+1));
1224 TCanvas *c1 =
new TCanvas(histoName,histoName,900,900);
1225 c1->ToggleEventStatus();
1226 TPad* upperPad =
new TPad(
"upperPad",
"upperPad",.005, .5, .995, .995);
1227 TPad* lowerPadLeft =
new TPad(
"lowerPadL",
"lowerPadL",.005, .005, .5, .5);
1228 TPad* lowerPadRight =
new TPad(
"lowerPadR",
"lowerPadR",.5, .005, .995, .5);
1230 lowerPadLeft->Draw();
1231 lowerPadRight->Draw();
1234 upperPad->SetLeftMargin(0.05);
1235 upperPad->SetRightMargin(0.05);
1236 if(crit!=3)upperPad->SetLogy();
1237 inhisto->SetTitleOffset(0.6,
"Y");
1238 inhisto->GetXaxis()->SetRangeUser(0,fNoOfCells+1);
1239 inhisto->GetYaxis()->SetTitleOffset(0.7);
1240 inhisto->SetLineColor(kBlue+1);
1243 lowerPadRight->cd();
1244 lowerPadRight->SetLeftMargin(0.09);
1245 lowerPadRight->SetRightMargin(0.12);
1246 plot2D->GetYaxis()->SetTitleOffset(1.3);
1247 plot2D->Draw(
"colz");
1250 lowerPadLeft->SetLeftMargin(0.09);
1251 lowerPadLeft->SetRightMargin(0.07);
1252 lowerPadLeft->SetLogy();
1253 distrib->SetLineColor(kBlue+1);
1254 distrib->GetYaxis()->SetTitleOffset(1.3);
1255 cout<<medianOfHisto<<endl;
1260 distrib_wTRDStruc->SetLineColor(kGreen+1);
1261 distrib_wTRDStruc->DrawCopy(
"same");
1262 distrib_woTRDStruc->SetLineColor(kMagenta+1);
1263 distrib_woTRDStruc->DrawCopy(
"same");
1273 Double_t maxDistr = distrib->GetMaximum();
1274 Int_t maxBin = distrib->GetMaximumBin();
1275 Double_t maxCenter = distrib->GetBinCenter(maxBin);
1279 for(
Int_t i = maxBin ; i<=dnbins ; i++)
1281 if(distrib->GetBinContent(i)<2)
break ;
1282 goodmax = distrib->GetBinCenter(i);
1284 for(
Int_t i = maxBin ; i>2 ; i--)
1286 if(distrib->GetBinContent(i)<2)
break ;
1287 goodmin = distrib->GetBinLowEdge(i);
1297 if(crit==3)minFitRange=-20;
1298 if(crit==3)maxFitRange=20;
1303 TF1 *fit2 =
new TF1(
"fit2",
"gaus",minFitRange,maxFitRange);
1305 fit2->SetParLimits(0,0,maxDistr);
1306 fit2->SetParameter(1,maxCenter);
1307 fit2->SetParLimits(1,0,dmaxVal);
1310 distrib->Fit(fit2,
"0LQEM",
"", minFitRange, maxFitRange);
1312 mean = fit2->GetParameter(1);
1313 sig = fit2->GetParameter(2);
1318 goodmin = mean - nsigma*sig ;
1319 goodmax = mean + nsigma*sig ;
1324 if(inputBins==-1) goodmin=-1;
1325 if(goodmin <=0.) goodmin = -100;
1326 if(
fPrint==1)cout<<
" o Result of fit: "<<endl;
1327 if(
fPrint==1)cout<<
" o "<<endl;
1328 if(
fPrint==1)cout<<
" o Mean: "<<mean <<
" sigma: "<<sig<<endl;
1329 if(
fPrint==1)cout<<
" o good range : "<<goodmin <<
" - "<<goodmax<<endl;
1334 TLine *lline =
new TLine(goodmin, 0, goodmin, distrib->GetMaximum());
1335 lline->SetLineColor(kGreen+2);
1336 lline->SetLineStyle(7);
1339 TLine *rline =
new TLine(goodmax, 0, goodmax, distrib->GetMaximum());
1340 rline->SetLineColor(kGreen+2);
1341 rline->SetLineStyle(7);
1344 TLegend *leg =
new TLegend(0.60,0.70,0.9,0.85);
1345 leg->AddEntry(lline,
"Good region boundary",
"l");
1346 leg->AddEntry(distrib_wTRDStruc,
"Covered by TRD",
"l");
1347 leg->AddEntry(distrib_woTRDStruc,
"wo TRD structure",
"l");
1348 leg->SetBorderSize(0);
1352 fit2->SetLineColor(kOrange-3);
1353 fit2->SetLineStyle(1);
1358 if(crit==1 || crit==4) text =
new TLatex(0.12,0.85,Form(
"Good range: %.2f-%.2f",goodmin,goodmax));
1359 if(crit==2 || crit==5) text =
new TLatex(0.12,0.85,Form(
"Good range: %.2f-%.2f",goodmin,goodmax));
1360 if(crit==3) text =
new TLatex(0.12,0.85,Form(
"Good range: %.2f-%.2f",goodmin,goodmax));
1361 text->SetTextSize(0.06);
1363 text->SetTextColor(1);
1367 TLine *uline =
new TLine(0, goodmax,fNoOfCells,goodmax);
1368 uline->SetLineColor(kGreen+2);
1369 uline->SetLineStyle(7);
1371 TLine *lowline =
new TLine(0, goodmin,fNoOfCells,goodmin);
1372 lowline->SetLineColor(kGreen+2);
1373 lowline->SetLineStyle(7);
1380 if(crit==1)name=Form(
"%s/%s/AverageEperHit_%s.gif",
fWorkdir.Data(),
fAnalysisOutput.Data(), (
const char*)histoName);
1381 if(crit==2)name=Form(
"%s/%s/AverageHitperEvent_%s.gif",
fWorkdir.Data(),
fAnalysisOutput.Data(), (
const char*)histoName);
1382 if(crit==3)name=Form(
"%s/%s/AverageTimeMax_%s.gif",
fWorkdir.Data(),
fAnalysisOutput.Data(), (
const char*)histoName);
1383 if(crit==4)name=Form(
"%s/%s/AverageEperHit_scaled_%s.gif",
fWorkdir.Data(),
fAnalysisOutput.Data(), (
const char*)histoName);
1384 if(crit==5)name=Form(
"%s/%s/AverageHitperEvent_scaled_%s.gif",
fWorkdir.Data(),
fAnalysisOutput.Data(), (
const char*)histoName);
1387 fRootFile->WriteObject(c1,c1->GetName());
1388 fRootFile->WriteObject(plot2D,plot2D->GetName());
1389 fRootFile->WriteObject(distrib,distrib->GetName());
1390 fRootFile->WriteObject(inhisto,inhisto->GetName());
1397 if(
fPrint==1)cout<<
" o Flag bad cells that are outside the good range "<<endl;
1402 if(inhisto->GetBinContent(cell+1) <= goodmin &&
fFlag[cell]==0)
1406 if(inhisto->GetBinContent(cell+1) > goodmax && fFlag[cell]==0)
1411 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;
1427 Int_t cellColumn=0,cellRow=0;
1428 Int_t cellColumnAbs=0,cellRowAbs=0;
1431 TString histoName=inhisto->GetName();
1434 TH1F *distrib =
new TH1F(Form(
"%sDistr",(
const char*)histoName),
"", 100, 1., 3.);
1435 TH1F *distrib_wTRDStruc =
new TH1F(Form(
"%sDistr",(
const char*)histoName),
"", 100, 1., 3.);
1436 TH1F *distrib_woTRDStruc =
new TH1F(Form(
"%sDistr",(
const char*)histoName),
"", 100, 1., 3.);
1439 plot2D->GetXaxis()->SetTitle(
"cell column (#eta direction)");
1440 plot2D->GetYaxis()->SetTitle(
"cell row (#phi direction)");
1454 distrib->Fill(inhisto->GetBinContent(cell+1));
1461 cout<<
"Problem! wrong calculated number of max col and max rows"<<endl;
1462 cout<<
"current col: "<<cellColumnAbs<<
", max col"<<
fNMaxColsAbs<<endl;
1463 cout<<
"current row: "<<cellRowAbs<<
", max row"<<
fNMaxRowsAbs<<endl;
1465 plot2D->SetBinContent(cellColumnAbs,cellRowAbs,inhisto->GetBinContent(cell+1));
1469 distrib_wTRDStruc->Fill(inhisto->GetBinContent(cell+1));
1473 distrib_woTRDStruc ->Fill(inhisto->GetBinContent(cell+1));
1479 TCanvas *c1 =
new TCanvas(histoName,histoName,900,900);
1480 c1->ToggleEventStatus();
1481 TPad* upperPad =
new TPad(
"upperPad",
"upperPad",.005, .5, .995, .995);
1482 TPad* lowerPadLeft =
new TPad(
"lowerPadL",
"lowerPadL",.005, .005, .5, .5);
1483 TPad* lowerPadRight =
new TPad(
"lowerPadR",
"lowerPadR",.5, .005, .995, .5);
1485 lowerPadLeft->Draw();
1486 lowerPadRight->Draw();
1489 upperPad->SetLeftMargin(0.05);
1490 upperPad->SetRightMargin(0.05);
1491 upperPad->SetLogy();
1492 inhisto->SetTitleOffset(0.6,
"Y");
1493 inhisto->GetXaxis()->SetRangeUser(0,fNoOfCells+1);
1494 inhisto->GetYaxis()->SetTitleOffset(0.7);
1495 inhisto->SetLineColor(kBlue+1);
1498 lowerPadRight->cd();
1499 lowerPadRight->SetLeftMargin(0.09);
1500 lowerPadRight->SetRightMargin(0.12);
1501 plot2D->GetYaxis()->SetTitleOffset(1.3);
1502 plot2D->Draw(
"colz");
1505 lowerPadLeft->SetLeftMargin(0.09);
1506 lowerPadLeft->SetRightMargin(0.07);
1507 lowerPadLeft->SetLogy();
1508 distrib->SetLineColor(kBlue+1);
1509 distrib->GetYaxis()->SetTitleOffset(1.3);
1511 distrib_wTRDStruc->SetLineColor(kGreen+1);
1512 distrib_wTRDStruc->DrawCopy(
"same");
1513 distrib_woTRDStruc->SetLineColor(kMagenta+1);
1514 distrib_woTRDStruc->DrawCopy(
"same");
1520 TLine *line =
new TLine(tCut, 0, tCut, distrib->GetMaximum());
1521 line->SetLineColor(kGreen+2);
1522 line->SetLineStyle(7);
1526 TLegend *leg =
new TLegend(0.60,0.70,0.9,0.85);
1527 leg->AddEntry(line,
"upper limit",
"l");
1528 leg->AddEntry(distrib_wTRDStruc,
"Covered by TRD",
"l");
1529 leg->AddEntry(distrib_woTRDStruc,
"wo TRD structure",
"l");
1530 leg->SetBorderSize(0);
1536 text =
new TLatex(0.12,0.85,Form(
"Good range: %.2f-%.2f",0.,tCut));
1537 text->SetTextSize(0.06);
1539 text->SetTextColor(1);
1543 TLine *uline =
new TLine(0, tCut,fNoOfCells,tCut);
1544 uline->SetLineColor(kGreen+2);
1545 uline->SetLineStyle(7);
1555 fRootFile->WriteObject(c1,c1->GetName());
1556 fRootFile->WriteObject(plot2D,plot2D->GetName());
1557 fRootFile->WriteObject(distrib,distrib->GetName());
1558 fRootFile->WriteObject(inhisto,inhisto->GetName());
1565 if(
fPrint==1)cout<<
" o Flag bad cells that are outside the good range "<<endl;
1570 if(inhisto->GetBinContent(cell+1) > tCut &&
fFlag[cell]==0)
1575 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;
1578 delete distrib_wTRDStruc;
1579 delete distrib_woTRDStruc;
1609 ofstream file2(aliceTwikiTable, ios::out | ios::trunc);
1612 file2<<
"|*Criterium* | *E_min !GeV* | *E_max !GeV* | *sigma* | *Excluded Cells* |"<<endl;
1619 criterion =periodArray.At(0);
1620 emin =periodArray.At(2);
1621 emax =periodArray.At(3);
1622 sig =periodArray.At(1);
1626 output.Form(
"%s/%s/Criterion%d_Emin-%.2f_Emax-%.2f.txt",
fWorkdir.Data(),
fAnalysisOutput.Data(), criterion,emin,emax);
1627 ofstream
file(output, ios::out | ios::trunc);
1630 cout<<
"#### Major Error. Check the textfile!"<<endl;
1632 file<<
"fFlag="<<i+2<<
"means Criterion : "<<criterion<<
", emin = "<<emin<<
" GeV"<<
", emax = "<<emax<<
" GeV"<<endl;
1633 if(
fPrint==1)cout<<
" o Criterion : "<<criterion<<
", emin = "<<emin<<
" GeV"<<
", emax = "<<emax<<
" GeV"<<
" (Method "<<i<<
")"<<endl;
1638 if(
fFlag[cellID]==(i+2))
1644 file<<
"Total number of bad cells with fFlag=="<<i+2<<endl;
1645 file<<
"("<<nb1<<
")"<<endl;
1647 if(
fPrint==1)cout<<
" o Total number of bad cells ("<<nb1<<
")"<<endl;
1652 ofstream file2(aliceTwikiTable, ios::out | ios::app);
1655 file2<<
"| "<<criterion<<
" | "<<emin<<
" | "<<emax<<
" | "<<sig<<
" | "<<nb1<<
" |"<<endl;
1669 Int_t cellID, nDeadDCalCells = 0, nDeadEMCalCells = 0, nDCalCells = 0, nEMCalCells = 0;
1670 Double_t perDeadEMCal,perDeadDCal,perBadEMCal,perBadDCal,perWarmEMCal,perWarmDCal;
1671 TString aliceTwikiTable, cellSummaryFile, deadPdfName, badPdfName, ratioOfBad,goodCells,goodCellsRatio,cellProp;
1672 TString OADBFile_bad, OADBFile_dead, OADBFile_warm;
1688 cout<<
" o Final results o "<<endl;
1700 cellAmp_masked->SetBinContent(amp,cell+1,0);
1709 cellTime_masked->SetBinContent(time,cell+1,0);
1716 TCanvas *c1 =
new TCanvas(
"CellProp",
"I summary of cell properties",1000,1000);
1717 c1->ToggleEventStatus();
1719 c1->cd(1)->SetLogz();
1726 c1->cd(2)->SetLogz();
1729 fCellTime->GetYaxis()->SetTitleOffset(1.6);
1731 c1->cd(3)->SetLogz();
1734 cellAmp_masked->SetTitle(
"Masked Cell Amplitude");
1735 cellAmp_masked->SetXTitle(
"Cell Energy [GeV]");
1736 cellAmp_masked->SetYTitle(
"Abs. Cell Id");
1737 cellAmp_masked->GetYaxis()->SetTitleOffset(1.6);
1738 cellAmp_masked->Draw(
"colz");
1739 c1->cd(4)->SetLogz();
1740 cellTime_masked->SetTitle(
"Masked Cell Time");
1741 cellTime_masked->SetXTitle(
"Cell Time [ns]");
1742 cellTime_masked->SetYTitle(
"Abs. Cell Id");
1743 cellTime_masked->GetYaxis()->SetTitleOffset(1.6);
1744 cellTime_masked->Draw(
"colz");
1747 TCanvas *c1_ratio =
new TCanvas(
"CellPropRatio",
"II summary of cell properties ratio",1000,500);
1748 c1_ratio->ToggleEventStatus();
1749 c1_ratio->Divide(2);
1750 c1_ratio->cd(1)->SetLogz();
1751 cellAmp_masked->SetTitle(
"Masked Cell Amplitude");
1752 cellAmp_masked->GetZaxis()->SetRangeUser(0.0001,10e7);
1753 cellAmp_masked->Draw(
"colz");
1754 c1_ratio->cd(2)->SetLogz();
1757 TH2F* ratio2DAmp =(
TH2F*)cellAmp_masked->Clone(
"ratio2DAmp");
1758 TH2F* Sum2DIdeal =(
TH2F*)cellAmp_masked->Clone(
"Sum2DIdeal");
1759 Sum2DIdeal->Reset();
1763 for(
Int_t eBin=0;eBin<Sum2DIdeal->GetNbinsX();eBin++)
1765 Double_t binVal=hRefDistr->GetBinContent(eBin+1);
1766 for(
Int_t icell=0;icell<Sum2DIdeal->GetNbinsY();icell++)
1768 Sum2DIdeal->SetBinContent(eBin+1,icell+1,binVal);
1771 ratio2DAmp->SetTitle(
"Ratio of cell Amplitude to mean cell ampl.");
1772 ratio2DAmp->Divide(Sum2DIdeal);
1773 ratio2DAmp->GetZaxis()->UnZoom();
1774 ratio2DAmp->Draw(
"colz");
1776 TLatex* textSM =
new TLatex(0.1,0.1,
"*test*");
1777 textSM->SetTextSize(0.06);
1778 textSM->SetTextColor(1);
1781 TCanvas *c1_proj =
new TCanvas(
"CellPropPProj",
"III summary of cell properties",1000,500);
1782 c1_proj->ToggleEventStatus();
1784 c1_proj->cd(1)->SetLogy();
1785 TH1* projEnergyMask = cellAmp_masked->ProjectionX(Form(
"%sMask_Proj",cellAmp_masked->GetName()),
fStartCell,fNoOfCells);
1786 projEnergyMask->SetXTitle(
"Cell Energy [GeV]");
1787 projEnergyMask->GetYaxis()->SetTitleOffset(1.6);
1788 projEnergyMask->SetLineColor(kGreen+1);
1789 projEnergyMask->DrawCopy(
" hist");
1791 projEnergy->DrawCopy(
"same hist");
1792 TLegend *leg =
new TLegend(0.50,0.75,0.7,0.87);
1793 leg->AddEntry(projEnergy,
"all cells",
"l");
1794 leg->AddEntry(projEnergyMask,
"good cells",
"l");
1795 leg->SetTextSize(0.05);
1796 leg->SetBorderSize(0);
1797 leg->SetFillColorAlpha(10, 0);
1799 TLegend *legBig = (TLegend*)leg->Clone(
"legBig");
1800 legBig->SetTextSize(0.08);
1801 legBig->SetX1NDC(0.2);
1803 c1_proj->cd(2)->SetLogy();
1804 TH1* projTimeMask = cellTime_masked->ProjectionX(Form(
"%s_Proj",cellTime_masked->GetName()),
fStartCell,fNoOfCells);
1805 projTimeMask->SetXTitle(
"Cell Time [ns]");
1806 projTimeMask->GetYaxis()->SetTitleOffset(1.6);
1807 projTimeMask->GetYaxis()->SetRangeUser(1,projTimeMask->GetMaximum()*20);
1808 projTimeMask->SetLineColor(kGreen+1);
1809 projTimeMask->DrawCopy(
"hist");
1811 projTime->DrawCopy(
"same hist");
1815 TCanvas *c1_projSM =
new TCanvas(
"CellPropPProjSM",
"III summary of cell Energy per SM",1200,900);
1816 c1_projSM->Divide(5,4,0.001,0.001);
1817 TH1* projEnergyMaskSM[20];
1818 TH1* projEnergySM[20];
1819 for(
Int_t iSM=0;iSM<20;iSM++)
1821 c1_projSM->cd(iSM+1)->SetLogy();
1822 gPad->SetTopMargin(0.03);
1823 gPad->SetBottomMargin(0.11);
1824 projEnergyMaskSM[iSM] = cellAmp_masked->ProjectionX(Form(
"%sMask_ProjSM%i",cellAmp_masked->GetName(),iSM),
fStartCellSM[iSM]+1,
fStartCellSM[iSM+1]);
1825 projEnergyMaskSM[iSM]->SetTitle(
"");
1826 projEnergyMaskSM[iSM]->SetXTitle(Form(
"Cell Energy [GeV], SM%i",iSM));
1827 projEnergyMaskSM[iSM]->GetYaxis()->SetTitleOffset(1.6);
1828 projEnergyMaskSM[iSM]->GetYaxis()->SetLabelSize(0.06);
1829 projEnergyMaskSM[iSM]->GetXaxis()->SetLabelSize(0.06);
1830 projEnergyMaskSM[iSM]->GetXaxis()->SetRangeUser(0,20);
1831 projEnergyMaskSM[iSM]->GetXaxis()->SetTitleSize(0.06);
1832 projEnergyMaskSM[iSM]->SetLineColor(kGreen+1);
1833 projEnergyMaskSM[iSM]->DrawCopy(
" hist");
1836 projEnergySM[iSM]->DrawCopy(
"same hist");
1837 if(iSM==0)legBig->Draw(
"same");
1843 TCanvas *c1_projRSM =
new TCanvas(
"CellPropPProjRSM",
"III summary of cell Energy Ratio per SM",1200,900);
1844 c1_projRSM->Divide(5,4,0.001,0.001);
1845 for(
Int_t iSM=0;iSM<20;iSM++)
1847 c1_projRSM->cd(iSM+1)->SetLogy();
1848 gPad->SetTopMargin(0.03);
1849 gPad->SetBottomMargin(0.11);
1851 projEnergyMaskSM[iSM]->SetLineColor(kGray+1);
1852 projEnergyMaskSM[iSM]->Divide(hRefDistr);
1853 projEnergyMaskSM[iSM]->DrawCopy(
"hist");
1856 TCanvas *c1_projTimeSM =
new TCanvas(
"CellPropPProjTimeSM",
"III summary of cell Time per SM",1200,900);
1857 c1_projTimeSM->Divide(5,4,0.001,0.001);
1858 TH1* projTimeMaskSM[20];
1859 TH1* projTimeSM[20];
1860 for(
Int_t iSM=0;iSM<20;iSM++)
1862 c1_projTimeSM->cd(iSM+1)->SetLogy();
1863 gPad->SetTopMargin(0.03);
1864 gPad->SetBottomMargin(0.11);
1865 projTimeMaskSM[iSM] = cellTime_masked->ProjectionX(Form(
"%sMask_ProjSMTime%i",cellAmp_masked->GetName(),iSM),
fStartCellSM[iSM]+1,
fStartCellSM[iSM+1]);
1866 projTimeMaskSM[iSM]->SetTitle(
"");
1867 projTimeMaskSM[iSM]->SetXTitle(Form(
"Cell Time [ns], SM%i",iSM));
1868 projTimeMaskSM[iSM]->GetYaxis()->SetTitleOffset(1.6);
1869 projTimeMaskSM[iSM]->GetYaxis()->SetLabelSize(0.06);
1870 projTimeMaskSM[iSM]->GetXaxis()->SetLabelSize(0.06);
1872 projTimeMaskSM[iSM]->GetXaxis()->SetTitleSize(0.06);
1873 projTimeMaskSM[iSM]->SetLineColor(kGreen+1);
1874 projTimeMaskSM[iSM]->DrawCopy(
" hist");
1876 if(iSM==0)legBig->Draw(
"same");
1878 projTimeSM[iSM]->DrawCopy(
"same hist");
1882 c1 ->Print(Form(
"%s(",cellProp.Data()));
1883 c1_ratio ->Print(Form(
"%s",cellProp.Data()));
1884 c1_proj ->Print(Form(
"%s",cellProp.Data()));
1885 c1_projSM ->Print(Form(
"%s",cellProp.Data()));
1886 c1_projRSM ->Print(Form(
"%s",cellProp.Data()));
1887 c1_projTimeSM->Print(Form(
"%s)",cellProp.Data()));
1894 cellAmp_masked ->Scale(1.0/totalevents);
1900 ofstream
file(cellSummaryFile, ios::out | ios::trunc);
1901 ofstream fileBad(OADBFile_bad, ios::out | ios::trunc);
1902 ofstream fileDead(OADBFile_dead, ios::out | ios::trunc);
1903 ofstream fileWarm(OADBFile_warm, ios::out | ios::trunc);
1906 file<<
"Dead cells : "<<endl;
1907 cout<<
" o Dead cells : "<<endl;
1912 file<<
"In EMCal: "<<endl;
1917 file<<
"In DCal: "<<endl;
1919 if(
fFlag[cellID]==1)
1923 else nDeadDCalCells++;
1925 if(
fFlag[cellID]==1)fileDead<<cellID<<endl;
1926 if(
fFlag[cellID]>1)fileBad<<cellID<<endl;
1931 file<<
"EMCal ("<<nDeadEMCalCells<<
" ="<<perDeadEMCal<<
"%), DCal ("<<nDeadDCalCells<<
" ="<<perDeadDCal<<
"%)"<<endl;
1932 cout<<
" o EMCal ("<<nDeadEMCalCells<<
" ="<<perDeadEMCal<<
"%), DCal ("<<nDeadDCalCells<<
" ="<<perDeadDCal<<
"%)"<<endl;
1934 file<<
"Bad cells: "<<endl;
1935 cout<<
" o Bad cells: "<<endl;
1940 file<<
"In EMCal: "<<endl;
1945 file<<
"In DCal: "<<endl;
1957 file<<
"EMCal ("<<nEMCalCells<<
" ="<<perBadEMCal<<
"%), DCal ("<<nDCalCells<<
" ="<<perBadDCal<<
"%)"<<endl;
1958 cout<<
" o EMCal ("<<nEMCalCells<<
" ="<<perBadEMCal<<
"%), DCal ("<<nDCalCells<<
" ="<<perBadDCal<<
"%)"<<endl;
1961 cout<<
" o Total: "<<endl;
1962 cout<<
" o Bad+Dead cells: "<<nDeadEMCalCells+nEMCalCells+nDeadDCalCells+nDCalCells<<
", this is "<<(nDeadEMCalCells+nEMCalCells+nDeadDCalCells+nDCalCells)*100/(1.0*fNoOfCells)<<
"% of the whole detector"<<endl;
1967 if(
fPrint==1)cout<<
" o Save the bad channel spectra to a .pdf file"<<endl;
1980 if(
fWarmCell[cell]==1)fileWarm<<cell<<endl;
1982 TCanvas *c2 =
new TCanvas(
"CellFlag",
"summary of cell flags",1200,800);
1983 c2->ToggleEventStatus();
1988 fhCellFlag->SetYTitle(
"flag by which cell was excluded");
2008 TString name1,name2,name3,name4,name5,name6;
2010 c1_ratio->SaveAs(name1);
2014 c1_proj->SaveAs(name3);
2016 c1_projSM->SaveAs(name4);
2018 c1_projRSM->SaveAs(name5);
2020 c1_projTimeSM->SaveAs(name6);
2022 fRootFile->WriteObject(c1,c1->GetName());
2023 fRootFile->WriteObject(c1_ratio,c1_ratio->GetName());
2024 fRootFile->WriteObject(c1_proj,c1_proj->GetName());
2025 fRootFile->WriteObject(c1_projSM,c1_projSM->GetName());
2026 fRootFile->WriteObject(c1_projRSM,c1_projRSM->GetName());
2027 fRootFile->WriteObject(c1_projTimeSM,c1_projTimeSM->GetName());
2028 fRootFile->WriteObject(c2,c2->GetName());
2030 fRootFile->WriteObject(cellAmp_masked,cellAmp_masked->GetName());
2031 fRootFile->WriteObject(ratio2DAmp,ratio2DAmp->GetName());
2036 fRootFile->WriteObject(projEnergyMask,projEnergyMask->GetName());
2037 fRootFile->WriteObject(projEnergy,projEnergy->GetName());
2044 Int_t nWEMCalCells =0;
2045 Int_t nWDCalCells =0;
2046 file.open(cellSummaryFile, ios::out | ios::app);
2049 file<<
"Warm cells : "<<endl;
2050 if(
fPrint==1)cout<<
" o Warm cells : "<<endl;
2055 file<<
"In EMCal: "<<endl;
2060 file<<
"In DCal: "<<endl;
2072 file<<
"EMCal ("<<nWEMCalCells<<
" ="<<perWarmEMCal<<
"%), DCal ("<<nWDCalCells<<
" ="<<perWarmDCal<<
"%)"<<endl;
2073 if(
fPrint==1)cout<<
" o EMCal ("<<nWEMCalCells<<
" ="<<perWarmEMCal<<
"%), DCal ("<<nWDCalCells<<
" ="<<perWarmDCal<<
"%)"<<endl;
2079 ofstream file2(aliceTwikiTable, ios::out | ios::app);
2082 file2<<
"1=energy/hit, 2= hit/event"<<endl;
2084 file2<<
"| *Detector* | *No of cells* | *percentage* |"<<endl;
2085 file2<<
"| Dead EMCal | "<<nDeadEMCalCells<<
" | "<<perDeadEMCal<<
"% |"<<endl;
2086 file2<<
"| Bad EMCal | "<<nEMCalCells<<
" | "<<perBadEMCal<<
"% |"<<endl;
2087 file2<<
"| - Warm EMCal | "<<nWEMCalCells<<
" | "<<perWarmEMCal<<
"% |"<<endl;
2088 file2<<
"| Dead DCal | "<<nDeadDCalCells<<
" | "<<perDeadDCal<<
"% |"<<endl;
2089 file2<<
"| Bad DCal | "<<nDCalCells<<
" | "<<perBadDCal<<
"% |"<<endl;
2090 file2<<
"| - Warm DCal | "<<nWDCalCells<<
" | "<<perWarmDCal<<
"% |"<<endl;
2091 file2<<
"| Summ D+B | "<<nDeadEMCalCells+nEMCalCells+nDeadDCalCells+nDCalCells<<
" | "<<(nDeadEMCalCells+nEMCalCells+nDeadDCalCells+nDCalCells)*100/(1.0*fNoOfCells)<<
"% |"<<endl;
2116 gROOT->SetStyle(
"Plain");
2117 gStyle->SetOptStat(0);
2118 gStyle->SetFillColor(kWhite);
2119 gStyle->SetTitleFillColor(kWhite);
2120 gStyle->SetPalette(1);
2126 fRootFile->WriteObject(hRefDistr,hRefDistr->GetName());
2127 Int_t firstCanvas=0;
2129 TLatex*
text =
new TLatex(0.2,0.8,
"*Candidate*");
2130 text->SetTextSize(0.07);
2131 text->SetTextColor(kOrange-3);
2134 TLatex* text2 =
new TLatex(0.2,0.8,
"*Not a Candidate*");
2135 text2->SetTextSize(0.08);
2136 text2->SetTextColor(8);
2139 TLatex* textA =
new TLatex(0.65,0.62,
"*test*");
2140 textA->SetTextSize(0.04);
2141 textA->SetTextColor(1);
2147 std::vector<Int_t> channelVector;
2148 channelVector.clear();
2149 cout<<
" o Start printing into .pdf for version: "<<version<<endl;
2152 if(
fFlag[cell]==1 && version==0)channelVector.push_back(cell);
2153 if(
fFlag[cell]>1 && version==1)channelVector.push_back(cell);
2154 if(
fFlag[cell]==0 && version==2)channelVector.push_back(cell);
2155 if(
fFlag[cell]>1 && version==10)channelVector.push_back(cell);
2156 if(
fFlag[cell]==0 && version==20)channelVector.push_back(cell);
2158 if(cell%2000==0)cout<<
"...cell No."<<cell<<endl;
2160 if(channelVector.size()==9 || cell == fNoOfCells-1)
2165 TCanvas *c1 =
new TCanvas(
"badcells",
"badcells",1000,750);
2166 if(channelVector.size() > 6) c1->Divide(3,3);
2167 else if (channelVector.size() > 3) c1->Divide(3,2);
2168 else c1->Divide(3,1);
2170 TLegend *leg =
new TLegend(0.7, 0.7, 0.9, 0.9);
2171 for(
Int_t i=0; i< (
Int_t)channelVector.size() ; i++)
2173 sprintf(name,
"Cell %d",channelVector.at(i)) ;
2174 TH1 *hCell =
fCellAmplitude->ProjectionX(name,channelVector.at(i)+1,channelVector.at(i)+1);
2175 sprintf(title,
"Cell No: %d Entries: %d",channelVector.at(i), (
Int_t)hCell->GetEntries()) ;
2178 c1->cd(i%9 + 1)->SetLogy();
2181 leg->AddEntry(hRefDistr,
"mean of good",
"l");
2182 leg->AddEntry(hCell,
"current",
"l");
2186 if(candidate==1)
fWarmCell[channelVector.at(i)]=candidate;
2189 hCell->Divide(hRefDistr);
2197 hCell->SetLineColor(kBlue+1);
2198 hCell->GetXaxis()->SetTitle(
"E (GeV)");
2199 hCell->GetYaxis()->SetTitle(
"N Entries");
2200 hCell->GetXaxis()->SetRangeUser(0.,10.);
2201 hCell->SetLineWidth(1) ;
2202 hCell->SetTitle(title);
2203 hRefDistr->SetLineColor(kGray+2);
2204 hRefDistr->SetLineWidth(1);
2206 hCell->Draw(
"hist");
2208 if(version==1 || version==2)hRefDistr->Draw(
"same") ;
2211 if(candidate==1 && (version==1 || version==10))
2213 gPad->SetFrameFillColor(kYellow-10);
2218 textA->SetTitle(Form(
"Excluded by No. %d",
fFlag[channelVector.at(i)]));
2219 textA->DrawLatex(0.65,0.62,Form(
"Excluded by No. %d",
fFlag[channelVector.at(i)]));
2221 if(candidate==0 && (version==2 || version==20))
2223 gPad->SetFrameFillColor(kYellow-10);
2227 if(version<2)leg->Draw();
2230 if(channelVector.size()<9 || cell == fNoOfCells-1)
2232 internal_pdfName +=
")";
2233 c1->Print(internal_pdfName.Data());
2235 else if(firstCanvas==0)
2237 internal_pdfName +=
"(";
2238 c1->Print(internal_pdfName.Data());
2243 c1->Print(internal_pdfName.Data());
2247 channelVector.clear();
2273 if(warmIn==0 &&
fFlag[cell]!=0 )
continue;
2275 if(warmIn==2 &&
fWarmCell[cell]==0)
continue;
2279 hgoodMean->Add(hGoodAmp);
2281 hgoodMean->Scale(1.0/NrGood);
2298 TString Name = Form(
"%s_ratio",histogram->GetName());
2299 TH1* ratio=(
TH1*)histogram->Clone(Name);
2300 ratio->Divide(reference);
2313 Int_t binHeightOne = reference->FindLastBinAbove(1.0/totalevents);
2314 Double_t binCentreHeightOne = reference->GetBinCenter(binHeightOne);
2315 Double_t thirdBinCentre = reference->GetBinCenter(3);
2324 if(ratio->FindLastBinAbove(0)<ratio->FindBin(binCentreHeightOne*percentageOfLast))
2333 ratio->GetXaxis()->SetRangeUser(thirdBinCentre,10);
2334 if(ratio->GetMaximum()>highestRatio)
2344 Int_t nullEntries=0;
2345 for(
Int_t i=2;i<binHeightOne;i++)
2347 if(ratio->GetBinContent(i)!=0)mean+=ratio->GetBinContent(i);
2350 mean*=1.0/(binHeightOne-1-nullEntries);
2351 if(mean>maxMean || mean<minMean)
2363 ratio->GetXaxis()->SetRangeUser(0,binCentreHeightOne);
2364 Double_t localMaxBin=ratio->GetMaximumBin();
2366 for(
Int_t i=2;i<binHeightOne;i++)
2369 if(ratio->GetBinContent(i)<=0)
continue;
2370 if(i>localMaxBin-3 && i<localMaxBin+3)
continue;
2371 mean+=ratio->GetBinContent(i);
2373 mean*=1.0/(binHeightOne-1);
2374 ratio->GetXaxis()->SetRangeUser(thirdBinCentre,binCentreHeightOne);
2376 if(ratio->GetMaximum()>mean*higherThanMean)
2388 Int_t cliffBin = ratio->FindBin(4);
2389 for(
Int_t i=cliffBin-10;i<cliffBin+11;i++)
2392 if(ratio->GetBinContent(i)<=0)
continue;
2393 if(i<=cliffBin) binsBefore++;
2394 if(i>cliffBin) binsAfter++;
2395 if(i<=cliffBin) beforeCliff+=ratio->GetBinContent(i);
2396 if(i>cliffBin) afterCliff+=ratio->GetBinContent(i);
2397 beforeCliff*=1.0/binsBefore;
2398 afterCliff*=1.0/binsAfter;
2400 if((beforeCliff-afterCliff)>cliffSize*afterCliff)
2402 if(beforeCliff!=0 && afterCliff!=0)candidate=0;
2403 if(beforeCliff!=0 && afterCliff!=0)cout<<
"5"<<endl;
2434 Bool_t coveredByTRDSupportStruc=0;
2436 if((collumn>3 && collumn<9) || (collumn>32 && collumn<37) || (collumn>57 && collumn<61) || (collumn>84 && collumn<90) ||
2437 (row==1) ||(row>20 && row<25) || (row>44 && row<49) || (row>68 && row<73) || (row>91 && row<96) ||
2438 (row>116 && row<120)|| row==127 || (row>148 && row<152) || (row>172 && row<177) || (row>197 && row<201)
2441 coveredByTRDSupportStruc=1;
2443 return coveredByTRDSupportStruc;
2458 histoName = Form(
"2DChannelMap_Flag%d_V%i",flagBegin,
fTrial);
2459 if(flagBegin==0 && flagEnd==0)histoName = Form(
"2DChannelMap_Flag100_V%i",
fTrial);
2462 plot2D->GetXaxis()->SetTitle(
"cell column (#eta direction)");
2463 plot2D->GetYaxis()->SetTitle(
"cell row (#phi direction)");
2465 Int_t cellColumn=0,cellRow=0;
2466 Int_t cellColumnAbs=0,cellRowAbs=0;
2478 cout<<
"Problem! wrong calculated number of max col and max rows"<<endl;
2479 cout<<
"current col: "<<cellColumnAbs<<
", max col"<<
fNMaxColsAbs<<endl;
2480 cout<<
"current row: "<<cellRowAbs<<
", max row"<<
fNMaxRowsAbs<<endl;
2482 if(flagEnd==-1 &&
fFlag[cell]==flagBegin) plot2D->SetBinContent(cellColumnAbs,cellRowAbs,1);
2483 if(flagEnd!=0 && flagEnd!=-1 &&
fFlag[cell]>=flagBegin &&
fFlag[cell]<=flagEnd)plot2D->SetBinContent(cellColumnAbs,cellRowAbs,1);
2484 if(flagBegin==0 && flagEnd==0 &&
fWarmCell[cell]==1) plot2D->SetBinContent(cellColumnAbs,cellRowAbs,1);
2488 TCanvas *c1 =
new TCanvas(histoName,histoName,500,500);
2489 c1->ToggleEventStatus();
2493 plot2D->Draw(
"colz");
2496 if(flagBegin==0 && flagEnd==-1) text =
new TLatex(0.2,0.8,
"Good Cells");
2497 if(flagBegin==1) text =
new TLatex(0.2,0.8,
"Dead Cells");
2498 if(flagBegin>1) text =
new TLatex(0.2,0.8,
"Bad Cells");
2499 if(flagBegin==0 && flagEnd==0) text =
new TLatex(0.2,0.8,
"Warm Cells");
2500 text->SetTextSize(0.06);
2502 text->SetTextColor(1);
2509 fRootFile->WriteObject(plot2D,plot2D->GetName());
2521 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
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 * 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.
Int_t fStartCellSM[21]
CellIDs of first cell in the 20SMs plus last cell ID.
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.
void LoadExternalBadMap()
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)
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 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...
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)
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.
void FlagAsBad_Time(Int_t crit, TH1F *inhisto, Double_t tCut=1.5)
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