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),
160 gROOT->ProcessLine(
"gErrorIgnoreLevel = kWarning;");
186 fRootFile =
new TFile(fileName,
"recreate");
201 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};
206 cout<<
"Number of supermod: "<<nModules<<endl;
293 cout<<
". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ."<<endl;
294 cout<<
". . .Start process by converting files. . . . . . . . . . . ."<<endl;
299 Printf(
"File not produced, exit");
307 cout<<
". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ."<<endl;
308 cout<<
". . .Start process by loading external file. . . . . . . . . . ."<<endl;
315 cout<<
". . .Load inputfile with name: "<<
fMergedFileName<<
" . . . . . . . ."<<endl;
320 if(!mergedFileInput->IsOpen())
322 Printf(
"Error! Input file not found, abort");
333 cout<<
". . .Continue process by . . . . . . . . . . . ."<<endl;
339 cout<<
"o o o Flag dead cells o o o"<<endl;
349 cout<<
"o o o Flag bad cells o o o"<<endl;
356 if(
fPrint==1)cout<<
"o o o Write .txt for each period analyis with bad cells o o o"<<endl;
368 if(
fPrint==1)cout<<
"o o o Create summary documents for the entire analysis o o o"<<endl;
380 Int_t binHeightOne = hRefDistr->FindLastBinAbove(1.0/totalevents);
381 Double_t binCentreHeightOne = hRefDistr->GetBinCenter(binHeightOne);
382 cout<<
". . .Recomendation:"<<endl;
383 cout<<
". . .With the current statistic on average a cell has 1 hit at "<<binCentreHeightOne<<
" GeV"<<endl;
384 cout<<
". . .so it makes no sense to select energy ranges >"<<binCentreHeightOne<<
"GeV as cells will be"<<endl;
385 cout<<
". . .marked bad just due to the lack of statistic"<<endl;
386 cout<<
". . .your selected lower bond is "<<
fEndLowerBound<<
" GeV"<<endl;
387 if(binCentreHeightOne>=
fEndLowerBound) cout<<
". . .This means you are OK!"<<endl;
388 if(binCentreHeightOne<
fEndLowerBound) cout<<
". . .#!#!#!#! CAREFUL THIS COULD CAUSE TROUBLE AND THROW OUT MORE CELLS THAN NECESSARY #!#!#!#! "<<endl;
389 cout<<
". . .End of process . . . . . . . . . . . . . . . . . . . . ."<<endl;
390 cout<<
". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ."<<endl;
401 cout<<
"o o o Start conversion process o o o"<<endl;
405 TH1F *hNEventsProcessedPerRun=
new TH1F(
"hNEvents",
"Number of processed events in analyzed runs",1,0,1);
406 TH2F *hCellAmplitude;
410 cout<<
"o o o Open .txt file with run indices. Name = " <<
fRunList << endl;
411 FILE *pFile = fopen(
fRunList.Data(),
"r");
414 cout<<
"couldn't open file!"<<endl;
425 ncols = fscanf(pFile,
" %d ",&q);
434 const Int_t nRun = nlines ;
439 cout<<
"o o o Start merging process of " << nRun <<
" files"<< endl;
442 for(
Int_t i = 0 ; i < nRun ; i++)
446 infile = Form(
"%s.root",base.Data()) ;
448 cout<<
" o Open .root file with name: "<<infile<<endl;
449 TFile *f = TFile::Open(infile);
454 cout<<
"Couldn't open/find .root file: "<<infile<<endl;
457 TDirectoryFile *
dir = (TDirectoryFile *)f->Get(
fQADirect);
460 cout<<
"Couln't open directory file in .root file: "<<infile<<
", directory: "<<
fQADirect<<endl;
466 cout <<
"Couln't get TList from directory file: "<<
fQADirect<<endl;
474 hAmpId =(
TH2F*)outputList->FindObject(
"EMCAL_hAmpId");
477 Printf(
"hAmpId not found");
483 hAmpId->SetName(
"hCellAmplitude");
484 hAmpId->SetTitle(
"Cell Amplitude");
487 hTimeId =(
TH2F*)outputList->FindObject(
"EMCAL_hTimeId");
490 Printf(
"hTimeId not found");
496 hTimeId->SetName(
"hCellTime");
497 hTimeId->SetTitle(
"Cell Time");
503 hCellAmplitude=(
TH2F*)hAmpId->Clone(
"DummyName1");
504 hCellAmplitude->Reset();
505 hCellAmplitude->SetDirectory(0);
507 hCellTime=(
TH2F*)hTimeId->Clone(
"DummyName2");
509 hCellTime->SetDirectory(0);
512 hNEvents =(TH1F *)outputList->FindObject(
"hNEvents");
515 Printf(
"hNEvents not found");
519 nEntr = (
Int_t)hNEvents->GetEntries();
524 cout <<
" o File to small to be merged. Only N entries " << nEntr << endl;
527 cout <<
" o File with N entries " << nEntr<<
" will be merged"<< endl;
529 hCellAmplitude->Add(hAmpId);
530 hCellTime->Add(hTimeId);
531 hNEventsProcessedPerRun->Add(hNEvents);
536 TFile *singleRunFile = TFile::Open(singleRunFileName,
"recreate");
543 singleRunFile->Close();
545 outputList->Delete();
554 cout<<
"o o o Save the merged histogramms to .root file with name: "<<
fMergedFileName<<endl;
555 cout<<
"o o o "<<nEntrTot<<
" events were merged"<<endl;
559 hNEventsProcessedPerRun->Write();
560 hCellAmplitude->SetName(
"hCellAmplitude");
561 hCellAmplitude->SetTitle(
"Cell Amplitude");
562 hCellAmplitude->Write();
563 hCellTime->SetName(
"hCellTime");
564 hCellTime->SetTitle(
"Cell Time");
567 cout<<
"o o o End conversion process o o o"<<endl;
568 if(hNEventsProcessedPerRun)
delete hNEventsProcessedPerRun;
573 if(hNEventsProcessedPerRun)
delete hNEventsProcessedPerRun;
588 TFile* outputRoot = TFile::Open(extRootFileName.Data());
590 TH1F* hFlags =(TH1F*)outputRoot->Get(
"fhCellFlag");
596 Double_t extFlag = hFlags->GetBinContent(cell+1);
599 fFlag[cell] =extFlag;
619 PeriodAnalysis(periodArray.At(0),periodArray.At(1),periodArray.At(2),periodArray.At(3));
624 cout<<
"o o o End of bad channel analysis o o o"<<endl;
634 cout<<
"o o o Manually mask SM "<<iSM<<
" o o o"<<endl;
658 periodArray.AddAt((
Double_t)criteria,0);
659 periodArray.AddAt(nsigma,1);
660 periodArray.AddAt(emin,2);
661 periodArray.AddAt(emax,3);
683 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;
684 if(
fPrint==1)cout<<
"o o o PeriodAnalysis for flag "<<criterion<<
" o o o"<<endl;
686 if(
fPrint==1 && criterion != 3)cout<<
"o o o Done in the energy range E "<<emin<<
" - "<<emax<<endl;
687 if(
fPrint==1 && criterion == 3)cout<<
"o o o Done in the time range t "<<emin<<
" - "<<emax<<endl;
700 if(
fPrint==1)cout<<
"o o o Analyze average cell distributions o o o"<<endl;
704 if(criterion == 3) histogram =
BuildTimeMean(criterion, emin, emax);
706 if(criterion==1 || criterion == 4)
710 else FlagAsBad(criterion, histogram, nsigma, 200);
712 if(criterion==2 || criterion == 5)
716 else FlagAsBad(criterion, histogram, nsigma, 601);
734 if(
fPrint==1)cout<<
" o Calculate average cell hit per event and average cell energy per hit "<<endl;
736 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);
737 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);
738 histogram->SetXTitle(
"Abs. Cell Id");
739 if(crit==1)histogram->SetYTitle(
"Energy per hit");
740 if(crit==2)histogram->SetYTitle(
"Number of hits in cell");
741 histogram->GetXaxis()->SetNdivisions(510);
744 TH1F* pojection = (TH1F*)
fCellAmplitude->ProjectionX(
"Intermediate");
745 fnEventsInRange = pojection->Integral(pojection->GetBinContent(emin),pojection->GetBinContent(emax));
759 if (E < emin || E > emax ||
fFlag[cell]!=0)
continue;
766 if(crit==2) histogram->SetBinContent(cell+1, Nsum);
767 if(Nsum > 0. && crit==1)histogram->SetBinContent(cell+1, Esum/(Nsum));
789 if(
fPrint==1)cout<<
" o Calculate average cell hit per event and average cell energy per hit "<<endl;
790 TH1F *histogram = NULL;
791 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);
792 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);
793 histogram->SetXTitle(
"Abs. Cell Id");
794 if(crit==4)histogram->SetYTitle(
"Energy per hit");
795 if(crit==5)histogram->SetYTitle(
"Number of hits in cell");
796 histogram->GetXaxis()->SetNdivisions(510);
801 TH1F *hEnergyCol =
new TH1F(
"hEnergyCol",
"hEnergyCol", 100,0.,100.);
802 TH1F *hEnergyRow =
new TH1F(
"hEnergyRow",
"hEnergyRow", 250,0.,250.);
806 Int_t cellCol, cellRow, trash, col, row;
813 for(
int iCell = 1; iCell <=
fNoOfCells; iCell++){
815 if(
fFlag[iCell -1] == 0){
816 for(
int k = hEnergyScaled->GetXaxis()->FindBin(emin); k <= hEnergyScaled->GetXaxis()->FindBin(emax); k++){
817 NoOfHits += hEnergyScaled->GetBinContent(k, iCell);
820 arrHits[iCell - 1] = NoOfHits;
829 TH1D *hHitDistrib_forScaling =
new TH1D(
"hHitDistrib_forScaling",
"hHitDistrib_forScaling",1000,0.,TMath::Median(
fNoOfCells,arrHits)*4);
830 TF1 *fgausForScaling =
new TF1(
"fgausForScaling",
"gaus", 0.,TMath::Median(
fNoOfCells,arrHits)*4);
831 TVectorD fFlagForScaling;
837 for(
int k = hEnergyScaled->GetXaxis()->FindBin(emin); k <= hEnergyScaled->GetXaxis()->FindBin(emax); k++){
838 if(crit==5){dhits += hEnergyScaled->GetBinContent(k, i);}
840 dhits += hEnergyScaled->GetBinContent(k, i + 1)*hEnergyScaled->GetXaxis()->GetBinCenter(k);
841 dNumOfHits += hEnergyScaled->GetBinContent(k, i + 1);
844 if(crit==4 && dNumOfHits > 0){dhits = dhits / dNumOfHits;}
846 hHitDistrib_forScaling->Fill(dhits);
851 fgausForScaling->SetParameter(1, hHitDistrib_forScaling->GetBinCenter(hHitDistrib_forScaling-> GetMaximumBin()));
852 hHitDistrib_forScaling->Fit(fgausForScaling,
"MQ0");
853 hHitDistrib_forScaling->Fit(fgausForScaling,
"MQ0");
855 for(
int iCell = 1; iCell <=
fNoOfCells; iCell++){
858 for(
int k = hEnergyScaled->GetXaxis()->FindBin(emin); k <= hEnergyScaled->GetXaxis()->FindBin(emax); k++){
859 if(crit==5){dhits += hEnergyScaled->GetBinContent(k, iCell);}
861 dhits += hEnergyScaled->GetBinContent(k, iCell + 1)*hEnergyScaled->GetXaxis()->GetBinCenter(k);
862 dNumOfHits += hEnergyScaled->GetBinContent(k, iCell + 1);
865 if(crit==4 && dNumOfHits > 0){dhits = dhits / dNumOfHits;}
866 if(dhits > fgausForScaling->GetParameter(1) + 5* fgausForScaling->GetParameter(2) || dhits < fgausForScaling->GetParameter(1) - 5* fgausForScaling->GetParameter(2)){
867 fFlagForScaling[iCell - 1] = 1;
871 delete hHitDistrib_forScaling;
872 delete fgausForScaling;
880 for(
int iter = 0; iter < 5; iter++){
882 std::vector<Double_t> vecCol[100];
883 std::vector<Double_t> vecRow[250];
907 for(
int iCell = 0; iCell <
fNoOfCells; iCell++){
908 if(
fFlag[iCell] == 0 && fFlagForScaling[iCell] == 0){
912 for (
int EBin = hEnergyScaled->GetXaxis()->FindBin(emin); EBin < hEnergyScaled->GetXaxis()->FindBin(emax); EBin++) {
913 if(crit==5){dCellEnergy += hEnergyScaled->GetBinContent(EBin, iCell + 1);}
915 dCellEnergy += hEnergyScaled->GetBinContent(EBin, iCell + 1)*hEnergyScaled->GetXaxis()->GetBinCenter(EBin);
916 dNumOfHits += hEnergyScaled->GetBinContent(EBin, iCell + 1);
920 if(crit==4 && dNumOfHits > 0){dCellEnergy = dCellEnergy / dNumOfHits;}
922 if( dCellEnergy > 0.){
923 hEnergyCol->Fill(col + 0.5, dCellEnergy);
924 hEnergyRow->Fill(row + 0.5, dCellEnergy);
925 vecCol[col].push_back(dCellEnergy);
926 vecRow[row].push_back(dCellEnergy);
932 for(
int iCol = 1; iCol <= hEnergyCol->GetNbinsX() ; iCol++){
933 if(vecCol[iCol -1].size() > 0.){
934 hEnergyCol->SetBinContent(hEnergyCol->FindBin(iCol - 0.5), hEnergyCol->GetBinContent(hEnergyCol->FindBin(iCol - 0.5))/vecCol[iCol-1].size() );
939 for(
int iRow = 1; iRow <= hEnergyRow->GetNbinsX() ; iRow++){
940 if(vecRow[iRow -1].size() > 0.){
941 hEnergyRow->SetBinContent(hEnergyRow->FindBin(iRow - 0.5), hEnergyRow->GetBinContent(hEnergyRow->FindBin(iRow - 0.5))/vecRow[iRow-1].size() );
946 fFitRow =
new TF1(
"fFitRow",
"[0]",0.,250.);
947 fFitRow->SetParameter(0, hEnergyRow->GetBinContent(10));
948 Double_t MeanRow = hEnergyRow->GetBinContent(10);
951 fFitCol =
new TF1(
"fFitCol",
"[0]",0.,100.);
952 fFitCol->SetParameter(0, hEnergyCol->GetBinContent(10));
953 Double_t MeanCol = hEnergyCol->GetBinContent(10);
957 for(
int iCell = 0; iCell <
fNoOfCells; iCell++){
959 if (hEnergyCol->GetBinContent(col + 1) > 0.) {
960 for(
int EBin = 1; EBin < hEnergyScaled->GetNbinsX(); EBin++) {
961 hEnergyScaled->SetBinContent(EBin, iCell + 1, hEnergyScaled->GetBinContent(EBin, iCell + 1) * (MeanCol / hEnergyCol->GetBinContent(col + 1)));
967 for(
int iCell = 0; iCell <
fNoOfCells; iCell++){
969 if (hEnergyRow->GetBinContent(row + 1) > 0.) {
970 for(
int EBin = 1; EBin < hEnergyScaled->GetNbinsX(); EBin++) {
971 hEnergyScaled->SetBinContent(EBin, iCell + 1, hEnergyScaled->GetBinContent(EBin, iCell + 1) * (MeanRow / hEnergyRow->GetBinContent(row + 1)));
988 for (
Int_t j = 1; j <= hEnergyScaled->GetNbinsX(); j++)
991 Double_t E = hEnergyScaled->GetXaxis()->GetBinCenter(j);
992 Double_t N = hEnergyScaled->GetBinContent(j, cell+1);
994 if (E < emin || E > emax ||
fFlag[cell]!=0)
continue;
1001 if(crit==5) histogram->SetBinContent(cell+1, Nsum);
1002 if(Nsum > 0. && crit==4)histogram->SetBinContent(cell+1, Esum/(Nsum));
1005 delete hEnergyScaled;
1023 if(
fPrint==1)cout<<
" o Calculate maximum of cell time distribution "<<endl;
1025 TH1F *histogram = NULL;
1026 histogram =
new TH1F(Form(
"timeMax_t%.2f-%.2f",tmin,tmax),Form(
"Maximum of time distr., %.2f < t < %.2f ns",tmin,tmax),
fNoOfCells,0,
fNoOfCells);
1027 histogram->SetXTitle(
"Abs. Cell Id");
1028 histogram->SetYTitle(
"time max");
1029 histogram->GetXaxis()->SetNdivisions(510);
1035 for(
int iCell = 1; iCell <=
fNoOfCells; iCell ++){
1036 if(
fFlag[iCell - 1] != 0) {
continue; }
1039 for(
int iTime = 1; iTime <=
fCellTime->GetNbinsX(); iTime++){
1040 dHits =
fCellTime->GetBinContent(iTime, iCell);
1041 if(
fCellTime->GetXaxis()->GetBinCenter(iTime) > tmin &&
fCellTime->GetXaxis()->GetBinCenter(iTime) < tmax){
1047 histogram->SetBinContent(iCell, dAll/dIn);
1049 histogram->SetBinContent(iCell, 0.);
1063 Int_t manualMaskCounter=0;
1080 if(nSum == 0 &&
fFlag[cell]==0)
1091 manualMaskCounter++;
1094 if(
fPrint==1)cout<<
" o Number of dead cells: "<<sumOfExcl<<endl;
1095 if(
fPrint==1)cout<<
" ("<<sumOfExcl<<
")"<<endl;
1115 gStyle->SetOptStat(0);
1116 gStyle->SetOptFit(0);
1117 if(
fPrint==1 && crit==1)cout<<
" o Fit average energy per hit distribution"<<endl;
1118 if(
fPrint==1 && crit==2)cout<<
" o Fit average hit per event distribution"<<endl;
1119 if(
fPrint==1 && crit==3)cout<<
" o Fit average hit maximum distribution"<<endl;
1121 Int_t cellColumn=0,cellRow=0;
1122 Int_t cellColumnAbs=0,cellRowAbs=0;
1125 TString histoName=inhisto->GetName();
1130 Double_t dminVal = inhisto->GetMinimum(0);
1131 Double_t dmaxVal = inhisto->GetMaximum();
1139 if((crit==2 || crit == 5) && inputBins==-1) dnbins=dmaxVal-dminVal;
1140 if((crit==1 || crit == 4) && inputBins==-1) dnbins=200;
1147 Int_t numBins = inhisto->GetXaxis()->GetNbins();
1152 for (
int i = 0; i < numBins; i++)
1156 if(x[i]==0)y[i] = 0;
1158 medianOfHisto = TMath::Median(numBins,x,y);
1163 if(medianOfHisto*10<dmaxVal)
1166 dmaxVal=medianOfHisto+0.2*(dmaxVal-medianOfHisto);
1169 if(crit==2 || crit == 5)
1171 dnbins=dmaxVal-dminVal;
1174 if(dnbins>2000)dnbins=0.01*(dmaxVal-dminVal);
1175 if(dnbins>2000)dnbins=0.001*(dmaxVal-dminVal);
1176 if(dnbins<100) dnbins=0.02*(dmaxVal-dminVal);
1179 if(crit==1 || crit == 4)
1181 dnbins=(dmaxVal-dminVal)*500;
1192 dnbins =
fCellTime->GetXaxis()->GetNbins();
1193 dminVal=
fCellTime->GetXaxis()->GetBinCenter(1)-(binWidth*1.0)/2.0;
1194 dmaxVal=
fCellTime->GetXaxis()->GetBinCenter(dnbins)+(binWidth*1.0)/2.0;
1195 cout<<
"set the new histo with following settings- bins: "<<dnbins<<
", min val = "<<dminVal<<
", max val:"<<dmaxVal<<endl;
1198 TH1F *distrib =
new TH1F(Form(
"%sDistr",(
const char*)histoName),
"", dnbins, dminVal, dmaxVal);
1199 distrib->SetXTitle(inhisto->GetYaxis()->GetTitle());
1200 distrib->SetYTitle(
"Entries");
1201 TH1F *distrib_wTRDStruc =
new TH1F(Form(
"%sDistr_wTRD",(
const char*)histoName),
"", dnbins, dminVal, dmaxVal);
1202 TH1F *distrib_woTRDStruc=
new TH1F(Form(
"%sDistr_woTRD",(
const char*)histoName),
"", dnbins, dminVal, dmaxVal);
1206 plot2D->GetXaxis()->SetTitle(
"cell column (#eta direction)");
1207 plot2D->GetYaxis()->SetTitle(
"cell row (#phi direction)");
1221 distrib->Fill(inhisto->GetBinContent(cell+1));
1228 cout<<
"Problem! wrong calculated number of max col and max rows"<<endl;
1229 cout<<
"current col: "<<cellColumnAbs<<
", max col"<<
fNMaxColsAbs<<endl;
1230 cout<<
"current row: "<<cellRowAbs<<
", max row"<<
fNMaxRowsAbs<<endl;
1232 plot2D->SetBinContent(cellColumnAbs,cellRowAbs,inhisto->GetBinContent(cell+1));
1236 distrib_wTRDStruc->Fill(inhisto->GetBinContent(cell+1));
1240 distrib_woTRDStruc ->Fill(inhisto->GetBinContent(cell+1));
1248 TCanvas *c1 =
new TCanvas(histoName,histoName,900,900);
1249 c1->ToggleEventStatus();
1250 TPad* upperPad =
new TPad(
"upperPad",
"upperPad",.005, .5, .995, .995);
1251 TPad* lowerPadLeft =
new TPad(
"lowerPadL",
"lowerPadL",.005, .005, .5, .5);
1252 TPad* lowerPadRight =
new TPad(
"lowerPadR",
"lowerPadR",.5, .005, .995, .5);
1254 lowerPadLeft->Draw();
1255 lowerPadRight->Draw();
1258 upperPad->SetLeftMargin(0.05);
1259 upperPad->SetRightMargin(0.05);
1260 if(crit!=3)upperPad->SetLogy();
1261 inhisto->SetTitleOffset(0.6,
"Y");
1262 inhisto->GetXaxis()->SetRangeUser(0,fNoOfCells+1);
1263 inhisto->GetYaxis()->SetTitleOffset(0.7);
1264 inhisto->SetLineColor(kBlue+1);
1265 inhisto->DrawCopy();
1267 lowerPadRight->cd();
1268 lowerPadRight->SetLeftMargin(0.09);
1269 lowerPadRight->SetRightMargin(0.12);
1270 plot2D->GetYaxis()->SetTitleOffset(1.3);
1271 plot2D->DrawCopy(
"colz");
1274 lowerPadLeft->SetLeftMargin(0.09);
1275 lowerPadLeft->SetRightMargin(0.07);
1276 lowerPadLeft->SetLogy();
1277 distrib->SetLineColor(kBlue+1);
1278 distrib->GetYaxis()->SetTitleOffset(1.3);
1283 distrib->DrawCopy(
"");
1284 distrib_wTRDStruc->SetLineColor(kGreen+1);
1285 distrib_wTRDStruc->DrawCopy(
"same");
1286 distrib_woTRDStruc->SetLineColor(kMagenta+1);
1287 distrib_woTRDStruc->DrawCopy(
"same");
1296 Double_t maxDistr = distrib->GetMaximum();
1297 Int_t maxBin = distrib->GetMaximumBin();
1298 Double_t maxCenter = distrib->GetBinCenter(maxBin);
1302 for(
Int_t i = maxBin ; i<=dnbins ; i++)
1304 if(distrib->GetBinContent(i)<2)
break ;
1305 goodmax = distrib->GetBinCenter(i);
1307 for(
Int_t i = maxBin ; i>2 ; i--)
1309 if(distrib->GetBinContent(i)<2)
break ;
1310 goodmin = distrib->GetBinLowEdge(i);
1320 if(crit==3)minFitRange=-20;
1321 if(crit==3)maxFitRange=20;
1326 TF1 *fit2 =
new TF1(
"fit2",
"gaus",minFitRange,maxFitRange);
1328 fit2->SetParLimits(0,0,maxDistr);
1329 fit2->SetParameter(1,maxCenter);
1330 fit2->SetParLimits(1,0,dmaxVal);
1333 distrib->Fit(fit2,
"0LQEM",
"", minFitRange, maxFitRange);
1335 mean = fit2->GetParameter(1);
1336 sig = fit2->GetParameter(2);
1341 goodmin = mean - nsigma*sig ;
1342 goodmax = mean + nsigma*sig ;
1347 if(inputBins==-1) goodmin=-1;
1348 if(goodmin <=0.) goodmin = -100;
1349 if(
fPrint==1)cout<<
" o Result of fit: "<<endl;
1350 if(
fPrint==1)cout<<
" o "<<endl;
1351 if(
fPrint==1)cout<<
" o Mean: "<<mean <<
" sigma: "<<sig<<endl;
1352 if(
fPrint==1)cout<<
" o good range : "<<goodmin <<
" - "<<goodmax<<endl;
1357 TLine *lline =
new TLine(goodmin, 0, goodmin, distrib->GetMaximum());
1358 lline->SetLineColor(kGreen+2);
1359 lline->SetLineStyle(7);
1362 TLine *rline =
new TLine(goodmax, 0, goodmax, distrib->GetMaximum());
1363 rline->SetLineColor(kGreen+2);
1364 rline->SetLineStyle(7);
1367 TLegend *leg =
new TLegend(0.60,0.70,0.9,0.85);
1368 leg->AddEntry(lline,
"Good region boundary",
"l");
1369 leg->AddEntry(distrib_wTRDStruc,
"Covered by TRD",
"l");
1370 leg->AddEntry(distrib_woTRDStruc,
"wo TRD structure",
"l");
1371 leg->SetBorderSize(0);
1374 fit2->SetLineColor(kOrange-3);
1375 fit2->SetLineStyle(1);
1380 if(crit==1 || crit==4) text =
new TLatex(0.12,0.85,Form(
"Good range: %.2f-%.2f",goodmin,goodmax));
1381 if(crit==2 || crit==5) text =
new TLatex(0.12,0.85,Form(
"Good range: %.2f-%.2f",goodmin,goodmax));
1382 if(crit==3) text =
new TLatex(0.12,0.85,Form(
"Good range: %.2f-%.2f",goodmin,goodmax));
1383 text->SetTextSize(0.06);
1385 text->SetTextColor(1);
1389 TLine *uline =
new TLine(0, goodmax,fNoOfCells,goodmax);
1390 uline->SetLineColor(kGreen+2);
1391 uline->SetLineStyle(7);
1393 TLine *lowline =
new TLine(0, goodmin,fNoOfCells,goodmin);
1394 lowline->SetLineColor(kGreen+2);
1395 lowline->SetLineStyle(7);
1402 if(crit==1)name=Form(
"%s/%s/AverageEperHit_%s.gif",
fWorkdir.Data(),
fAnalysisOutput.Data(), (
const char*)histoName);
1403 if(crit==2)name=Form(
"%s/%s/AverageHitperEvent_%s.gif",
fWorkdir.Data(),
fAnalysisOutput.Data(), (
const char*)histoName);
1404 if(crit==3)name=Form(
"%s/%s/AverageTimeMax_%s.gif",
fWorkdir.Data(),
fAnalysisOutput.Data(), (
const char*)histoName);
1405 if(crit==4)name=Form(
"%s/%s/AverageEperHit_scaled_%s.gif",
fWorkdir.Data(),
fAnalysisOutput.Data(), (
const char*)histoName);
1406 if(crit==5)name=Form(
"%s/%s/AverageHitperEvent_scaled_%s.gif",
fWorkdir.Data(),
fAnalysisOutput.Data(), (
const char*)histoName);
1409 fRootFile->WriteObject(c1,c1->GetName());
1410 fRootFile->WriteObject(plot2D,plot2D->GetName());
1411 fRootFile->WriteObject(distrib,distrib->GetName());
1412 fRootFile->WriteObject(inhisto,inhisto->GetName());
1419 if(
fPrint==1)cout<<
" o Flag bad cells that are outside the good range "<<endl;
1424 if(inhisto->GetBinContent(cell+1) <= goodmin &&
fFlag[cell]==0)
1428 if(inhisto->GetBinContent(cell+1) > goodmax && fFlag[cell]==0)
1433 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;
1465 Int_t cellColumn=0,cellRow=0;
1466 Int_t cellColumnAbs=0,cellRowAbs=0;
1469 TString histoName=inhisto->GetName();
1472 TH1F *distrib =
new TH1F(Form(
"%sDistr",(
const char*)histoName),
"", 100, 1., 3.);
1473 TH1F *distrib_wTRDStruc =
new TH1F(Form(
"%sDistr",(
const char*)histoName),
"", 100, 1., 3.);
1474 TH1F *distrib_woTRDStruc =
new TH1F(Form(
"%sDistr",(
const char*)histoName),
"", 100, 1., 3.);
1477 plot2D->GetXaxis()->SetTitle(
"cell column (#eta direction)");
1478 plot2D->GetYaxis()->SetTitle(
"cell row (#phi direction)");
1492 distrib->Fill(inhisto->GetBinContent(cell+1));
1499 cout<<
"Problem! wrong calculated number of max col and max rows"<<endl;
1500 cout<<
"current col: "<<cellColumnAbs<<
", max col"<<
fNMaxColsAbs<<endl;
1501 cout<<
"current row: "<<cellRowAbs<<
", max row"<<
fNMaxRowsAbs<<endl;
1503 plot2D->SetBinContent(cellColumnAbs,cellRowAbs,inhisto->GetBinContent(cell+1));
1507 distrib_wTRDStruc->Fill(inhisto->GetBinContent(cell+1));
1511 distrib_woTRDStruc ->Fill(inhisto->GetBinContent(cell+1));
1517 TCanvas *c1 =
new TCanvas(histoName,histoName,900,900);
1518 c1->ToggleEventStatus();
1519 TPad* upperPad =
new TPad(
"upperPad",
"upperPad",.005, .5, .995, .995);
1520 TPad* lowerPadLeft =
new TPad(
"lowerPadL",
"lowerPadL",.005, .005, .5, .5);
1521 TPad* lowerPadRight =
new TPad(
"lowerPadR",
"lowerPadR",.5, .005, .995, .5);
1523 lowerPadLeft->Draw();
1524 lowerPadRight->Draw();
1527 upperPad->SetLeftMargin(0.05);
1528 upperPad->SetRightMargin(0.05);
1529 upperPad->SetLogy();
1530 inhisto->SetTitleOffset(0.6,
"Y");
1531 inhisto->GetXaxis()->SetRangeUser(0,fNoOfCells+1);
1532 inhisto->GetYaxis()->SetTitleOffset(0.7);
1533 inhisto->SetLineColor(kBlue+1);
1536 lowerPadRight->cd();
1537 lowerPadRight->SetLeftMargin(0.09);
1538 lowerPadRight->SetRightMargin(0.12);
1539 plot2D->GetYaxis()->SetTitleOffset(1.3);
1540 plot2D->Draw(
"colz");
1543 lowerPadLeft->SetLeftMargin(0.09);
1544 lowerPadLeft->SetRightMargin(0.07);
1545 lowerPadLeft->SetLogy();
1546 distrib->SetLineColor(kBlue+1);
1547 distrib->GetYaxis()->SetTitleOffset(1.3);
1549 distrib_wTRDStruc->SetLineColor(kGreen+1);
1550 distrib_wTRDStruc->DrawCopy(
"same");
1551 distrib_woTRDStruc->SetLineColor(kMagenta+1);
1552 distrib_woTRDStruc->DrawCopy(
"same");
1558 TLine *line =
new TLine(tCut, 0, tCut, distrib->GetMaximum());
1559 line->SetLineColor(kGreen+2);
1560 line->SetLineStyle(7);
1564 TLegend *leg =
new TLegend(0.60,0.70,0.9,0.85);
1565 leg->AddEntry(line,
"upper limit",
"l");
1566 leg->AddEntry(distrib_wTRDStruc,
"Covered by TRD",
"l");
1567 leg->AddEntry(distrib_woTRDStruc,
"wo TRD structure",
"l");
1568 leg->SetBorderSize(0);
1574 text =
new TLatex(0.12,0.85,Form(
"Good range: %.2f-%.2f",0.,tCut));
1575 text->SetTextSize(0.06);
1577 text->SetTextColor(1);
1581 TLine *uline =
new TLine(0, tCut,fNoOfCells,tCut);
1582 uline->SetLineColor(kGreen+2);
1583 uline->SetLineStyle(7);
1593 fRootFile->WriteObject(c1,c1->GetName());
1594 fRootFile->WriteObject(plot2D,plot2D->GetName());
1595 fRootFile->WriteObject(distrib,distrib->GetName());
1596 fRootFile->WriteObject(inhisto,inhisto->GetName());
1603 if(
fPrint==1)cout<<
" o Flag bad cells that are outside the good range "<<endl;
1608 if(inhisto->GetBinContent(cell+1) > tCut &&
fFlag[cell]==0)
1613 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;
1616 delete distrib_wTRDStruc;
1617 delete distrib_woTRDStruc;
1650 ofstream file2(aliceTwikiTable, ios::out | ios::trunc);
1653 file2<<
"|*Criterium* | *E_min !GeV* | *E_max !GeV* | *sigma* | *Excluded Cells* |"<<endl;
1660 criterion =periodArray.At(0);
1661 emin =periodArray.At(2);
1662 emax =periodArray.At(3);
1663 sig =periodArray.At(1);
1667 output.Form(
"%s/%s/Criterion%d_Emin-%.2f_Emax-%.2f.txt",
fWorkdir.Data(),
fAnalysisOutput.Data(), criterion,emin,emax);
1668 ofstream
file(output, ios::out | ios::trunc);
1671 cout<<
"#### Major Error. Check the textfile!"<<endl;
1673 file<<
"fFlag="<<i+2<<
"means Criterion : "<<criterion<<
", emin = "<<emin<<
" GeV"<<
", emax = "<<emax<<
" GeV"<<endl;
1674 if(
fPrint==1)cout<<
" o Criterion : "<<criterion<<
", emin = "<<emin<<
" GeV"<<
", emax = "<<emax<<
" GeV"<<
" (Method "<<i<<
")"<<endl;
1679 if(
fFlag[cellID]==(i+2))
1685 file<<
"Total number of bad cells with fFlag=="<<i+2<<endl;
1686 file<<
"("<<nb1<<
")"<<endl;
1688 if(
fPrint==1)cout<<
" o Total number of bad cells ("<<nb1<<
")"<<endl;
1693 ofstream file2(aliceTwikiTable, ios::out | ios::app);
1696 file2<<
"| "<<criterion<<
" | "<<emin<<
" | "<<emax<<
" | "<<sig<<
" | "<<nb1<<
" |"<<endl;
1710 Int_t cellID, nDeadDCalCells = 0, nDeadEMCalCells = 0, nDCalCells = 0, nEMCalCells = 0;
1711 Double_t perDeadEMCal,perDeadDCal,perBadEMCal,perBadDCal,perWarmEMCal,perWarmDCal;
1712 TString aliceTwikiTable, cellSummaryFile, deadPdfName, badPdfName, ratioOfBad,goodCells,goodCellsRatio,cellProp;
1713 TString OADBFile_bad, OADBFile_dead, OADBFile_warm;
1729 cout<<
" o Final results o "<<endl;
1741 cellAmp_masked->SetBinContent(amp,cell+1,0);
1750 cellTime_masked->SetBinContent(time,cell+1,0);
1757 TCanvas *c1 =
new TCanvas(
"CellProp",
"I summary of cell properties",1000,1000);
1758 c1->ToggleEventStatus();
1760 c1->cd(1)->SetLogz();
1767 c1->cd(2)->SetLogz();
1770 fCellTime->GetYaxis()->SetTitleOffset(1.6);
1772 c1->cd(3)->SetLogz();
1775 cellAmp_masked->SetTitle(
"Masked Cell Amplitude");
1776 cellAmp_masked->SetXTitle(
"Cell Energy [GeV]");
1777 cellAmp_masked->SetYTitle(
"Abs. Cell Id");
1778 cellAmp_masked->GetYaxis()->SetTitleOffset(1.6);
1779 cellAmp_masked->Draw(
"colz");
1780 c1->cd(4)->SetLogz();
1781 cellTime_masked->SetTitle(
"Masked Cell Time");
1782 cellTime_masked->SetXTitle(
"Cell Time [ns]");
1783 cellTime_masked->SetYTitle(
"Abs. Cell Id");
1784 cellTime_masked->GetYaxis()->SetTitleOffset(1.6);
1785 cellTime_masked->Draw(
"colz");
1788 TCanvas *c1_ratio =
new TCanvas(
"CellPropRatio",
"II summary of cell properties ratio",1000,500);
1789 c1_ratio->ToggleEventStatus();
1790 c1_ratio->Divide(2);
1791 c1_ratio->cd(1)->SetLogz();
1792 cellAmp_masked->SetTitle(
"Masked Cell Amplitude");
1793 cellAmp_masked->GetZaxis()->SetRangeUser(0.0001,10e7);
1794 cellAmp_masked->Draw(
"colz");
1795 c1_ratio->cd(2)->SetLogz();
1798 TH2F* ratio2DAmp =(
TH2F*)cellAmp_masked->Clone(
"ratio2DAmp");
1799 TH2F* Sum2DIdeal =(
TH2F*)cellAmp_masked->Clone(
"Sum2DIdeal");
1800 Sum2DIdeal->Reset();
1804 for(
Int_t eBin=0;eBin<Sum2DIdeal->GetNbinsX();eBin++)
1806 Double_t binVal=hRefDistr->GetBinContent(eBin+1);
1807 for(
Int_t icell=0;icell<Sum2DIdeal->GetNbinsY();icell++)
1809 Sum2DIdeal->SetBinContent(eBin+1,icell+1,binVal);
1812 ratio2DAmp->SetTitle(
"Ratio of cell Amplitude to mean cell ampl.");
1813 ratio2DAmp->Divide(Sum2DIdeal);
1814 ratio2DAmp->GetZaxis()->UnZoom();
1815 ratio2DAmp->DrawCopy(
"colz");
1818 TLatex* textSM =
new TLatex(0.1,0.1,
"*test*");
1819 textSM->SetTextSize(0.06);
1820 textSM->SetTextColor(1);
1823 TCanvas *c1_proj =
new TCanvas(
"CellPropPProj",
"III summary of cell properties",1000,500);
1824 c1_proj->ToggleEventStatus();
1826 c1_proj->cd(1)->SetLogy();
1827 TH1D* projEnergyMask = cellAmp_masked->ProjectionX(Form(
"%sMask_Proj",cellAmp_masked->GetName()),
fStartCell,fNoOfCells);
1828 projEnergyMask->SetXTitle(
"Cell Energy [GeV]");
1829 projEnergyMask->GetYaxis()->SetTitleOffset(1.6);
1830 projEnergyMask->SetLineColor(kGreen+1);
1831 projEnergyMask->DrawCopy(
" hist");
1833 projEnergy->DrawCopy(
"same hist");
1834 TLegend *leg =
new TLegend(0.50,0.75,0.7,0.87);
1835 leg->AddEntry(projEnergy,
"all cells",
"l");
1836 leg->AddEntry(projEnergyMask,
"good cells",
"l");
1837 leg->SetTextSize(0.05);
1838 leg->SetBorderSize(0);
1839 leg->SetFillColorAlpha(10, 0);
1841 TLegend *legBig = (TLegend*)leg->Clone(
"legBig");
1842 legBig->SetTextSize(0.08);
1843 legBig->SetX1NDC(0.2);
1845 c1_proj->cd(2)->SetLogy();
1846 TH1* projTimeMask = cellTime_masked->ProjectionX(Form(
"%s_Proj",cellTime_masked->GetName()),
fStartCell,fNoOfCells);
1847 projTimeMask->SetXTitle(
"Cell Time [ns]");
1848 projTimeMask->GetYaxis()->SetTitleOffset(1.6);
1849 projTimeMask->GetYaxis()->SetRangeUser(1,projTimeMask->GetMaximum()*20);
1850 projTimeMask->SetLineColor(kGreen+1);
1851 projTimeMask->DrawCopy(
"hist");
1853 projTime->DrawCopy(
"same hist");
1857 TCanvas *c1_projSM =
new TCanvas(
"CellPropPProjSM",
"III summary of cell Energy per SM",1200,900);
1858 c1_projSM->Divide(5,4,0.001,0.001);
1859 TH1* projEnergyMaskSM[20];
1860 TH1* projEnergySM[20];
1861 for(
Int_t iSM=0;iSM<20;iSM++)
1863 c1_projSM->cd(iSM+1)->SetLogy();
1864 gPad->SetTopMargin(0.03);
1865 gPad->SetBottomMargin(0.11);
1866 projEnergyMaskSM[iSM] = cellAmp_masked->ProjectionX(Form(
"%sMask_ProjSM%i",cellAmp_masked->GetName(),iSM),
fStartCellSM[iSM]+1,
fStartCellSM[iSM+1]);
1867 projEnergyMaskSM[iSM]->SetTitle(
"");
1868 projEnergyMaskSM[iSM]->SetXTitle(Form(
"Cell Energy [GeV], SM%i",iSM));
1869 projEnergyMaskSM[iSM]->GetYaxis()->SetTitleOffset(1.6);
1870 projEnergyMaskSM[iSM]->GetYaxis()->SetLabelSize(0.06);
1871 projEnergyMaskSM[iSM]->GetXaxis()->SetLabelSize(0.06);
1872 projEnergyMaskSM[iSM]->GetXaxis()->SetRangeUser(0,20);
1873 projEnergyMaskSM[iSM]->GetXaxis()->SetTitleSize(0.06);
1874 projEnergyMaskSM[iSM]->SetLineColor(kGreen+1);
1875 projEnergyMaskSM[iSM]->DrawCopy(
" hist");
1878 projEnergySM[iSM]->DrawCopy(
"same hist");
1879 if(iSM==0)legBig->Draw(
"same");
1884 c1_projSM->Update();
1886 TCanvas *c1_projRSM =
new TCanvas(
"CellPropPProjRSM",
"III summary of cell Energy Ratio per SM",1200,900);
1887 c1_projRSM->Divide(5,4,0.001,0.001);
1888 for(
Int_t iSM=0;iSM<20;iSM++)
1890 c1_projRSM->cd(iSM+1)->SetLogy();
1891 gPad->SetTopMargin(0.03);
1892 gPad->SetBottomMargin(0.11);
1894 projEnergyMaskSM[iSM]->SetLineColor(kGray+1);
1895 projEnergyMaskSM[iSM]->Divide(hRefDistr);
1896 projEnergyMaskSM[iSM]->DrawCopy(
"hist");
1898 c1_projRSM->Update();
1900 TCanvas *c1_projTimeSM =
new TCanvas(
"CellPropPProjTimeSM",
"III summary of cell Time per SM",1200,900);
1901 c1_projTimeSM->Divide(5,4,0.001,0.001);
1902 TH1* projTimeMaskSM[20];
1903 TH1* projTimeSM[20];
1904 for(
Int_t iSM=0;iSM<20;iSM++)
1906 c1_projTimeSM->cd(iSM+1)->SetLogy();
1907 gPad->SetTopMargin(0.03);
1908 gPad->SetBottomMargin(0.11);
1909 projTimeMaskSM[iSM] = cellTime_masked->ProjectionX(Form(
"%sMask_ProjSMTime%i",cellAmp_masked->GetName(),iSM),
fStartCellSM[iSM]+1,
fStartCellSM[iSM+1]);
1910 projTimeMaskSM[iSM]->SetTitle(
"");
1911 projTimeMaskSM[iSM]->SetXTitle(Form(
"Cell Time [ns], SM%i",iSM));
1912 projTimeMaskSM[iSM]->GetYaxis()->SetTitleOffset(1.6);
1913 projTimeMaskSM[iSM]->GetYaxis()->SetLabelSize(0.06);
1914 projTimeMaskSM[iSM]->GetXaxis()->SetLabelSize(0.06);
1916 projTimeMaskSM[iSM]->GetXaxis()->SetTitleSize(0.06);
1917 projTimeMaskSM[iSM]->SetLineColor(kGreen+1);
1918 projTimeMaskSM[iSM]->DrawCopy(
" hist");
1920 if(iSM==0)legBig->Draw(
"same");
1922 projTimeSM[iSM]->DrawCopy(
"same hist");
1941 cellAmp_masked ->Scale(1.0/totalevents);
1947 ofstream
file(cellSummaryFile, ios::out | ios::trunc);
1948 ofstream fileBad(OADBFile_bad, ios::out | ios::trunc);
1949 ofstream fileDead(OADBFile_dead, ios::out | ios::trunc);
1950 ofstream fileWarm(OADBFile_warm, ios::out | ios::trunc);
1953 file<<
"Dead cells : "<<endl;
1954 cout<<
" o Dead cells : "<<endl;
1959 file<<
"In EMCal: "<<endl;
1964 file<<
"In DCal: "<<endl;
1966 if(
fFlag[cellID]==1)
1970 else nDeadDCalCells++;
1972 if(
fFlag[cellID]==1)fileDead<<cellID<<endl;
1973 if(
fFlag[cellID]>1)fileBad<<cellID<<endl;
1978 file<<
"EMCal ("<<nDeadEMCalCells<<
" ="<<perDeadEMCal<<
"%), DCal ("<<nDeadDCalCells<<
" ="<<perDeadDCal<<
"%)"<<endl;
1979 cout<<
" o EMCal ("<<nDeadEMCalCells<<
" ="<<perDeadEMCal<<
"%), DCal ("<<nDeadDCalCells<<
" ="<<perDeadDCal<<
"%)"<<endl;
1981 file<<
"Bad cells: "<<endl;
1982 cout<<
" o Bad cells: "<<endl;
1987 file<<
"In EMCal: "<<endl;
1992 file<<
"In DCal: "<<endl;
2004 file<<
"EMCal ("<<nEMCalCells<<
" ="<<perBadEMCal<<
"%), DCal ("<<nDCalCells<<
" ="<<perBadDCal<<
"%)"<<endl;
2005 cout<<
" o EMCal ("<<nEMCalCells<<
" ="<<perBadEMCal<<
"%), DCal ("<<nDCalCells<<
" ="<<perBadDCal<<
"%)"<<endl;
2008 cout<<
" o Total: "<<endl;
2009 cout<<
" o Bad+Dead cells: "<<nDeadEMCalCells+nEMCalCells+nDeadDCalCells+nDCalCells<<
", this is "<<(nDeadEMCalCells+nEMCalCells+nDeadDCalCells+nDCalCells)*100/(1.0*fNoOfCells)<<
"% of the whole detector"<<endl;
2014 if(
fPrint==1)cout<<
" o Save the bad channel spectra to a .pdf file"<<endl;
2027 if(
fWarmCell[cell]==1)fileWarm<<cell<<endl;
2029 TCanvas *c2 =
new TCanvas(
"CellFlag",
"summary of cell flags",1200,800);
2030 c2->ToggleEventStatus();
2035 fhCellFlag->SetYTitle(
"flag by which cell was excluded");
2055 TString name1,name2,name3,name4,name5,name6;
2057 c1_ratio->SaveAs(name1);
2061 c1_proj->SaveAs(name3);
2063 c1_projSM->SaveAs(name4);
2065 c1_projRSM->SaveAs(name5);
2067 c1_projTimeSM->SaveAs(name6);
2069 fRootFile->WriteObject(c1_ratio,c1_ratio->GetName());
2070 fRootFile->WriteObject(c1,c1->GetName());
2071 fRootFile->WriteObject(c1_proj,c1_proj->GetName());
2072 fRootFile->WriteObject(c1_projSM,c1_projSM->GetName());
2073 fRootFile->WriteObject(c1_projRSM,c1_projRSM->GetName());
2074 fRootFile->WriteObject(c1_projTimeSM,c1_projTimeSM->GetName());
2076 fRootFile->WriteObject(c2,c2->GetName());
2078 fRootFile->WriteObject(cellAmp_masked,cellAmp_masked->GetName());
2079 fRootFile->WriteObject(ratio2DAmp,ratio2DAmp->GetName());
2084 fRootFile->WriteObject(projEnergyMask,projEnergyMask->GetName());
2085 fRootFile->WriteObject(projEnergy,projEnergy->GetName());
2092 Int_t nWEMCalCells =0;
2093 Int_t nWDCalCells =0;
2094 file.open(cellSummaryFile, ios::out | ios::app);
2097 file<<
"Warm cells : "<<endl;
2098 if(
fPrint==1)cout<<
" o Warm cells : "<<endl;
2103 file<<
"In EMCal: "<<endl;
2108 file<<
"In DCal: "<<endl;
2120 file<<
"EMCal ("<<nWEMCalCells<<
" ="<<perWarmEMCal<<
"%), DCal ("<<nWDCalCells<<
" ="<<perWarmDCal<<
"%)"<<endl;
2121 if(
fPrint==1)cout<<
" o EMCal ("<<nWEMCalCells<<
" ="<<perWarmEMCal<<
"%), DCal ("<<nWDCalCells<<
" ="<<perWarmDCal<<
"%)"<<endl;
2127 ofstream file2(aliceTwikiTable, ios::out | ios::app);
2130 file2<<
"1=energy/hit, 2= hit/event"<<endl;
2132 file2<<
"| *Detector* | *No of cells* | *percentage* |"<<endl;
2133 file2<<
"| Dead EMCal | "<<nDeadEMCalCells<<
" | "<<perDeadEMCal<<
"% |"<<endl;
2134 file2<<
"| Bad EMCal | "<<nEMCalCells<<
" | "<<perBadEMCal<<
"% |"<<endl;
2135 file2<<
"| - Warm EMCal | "<<nWEMCalCells<<
" | "<<perWarmEMCal<<
"% |"<<endl;
2136 file2<<
"| Dead DCal | "<<nDeadDCalCells<<
" | "<<perDeadDCal<<
"% |"<<endl;
2137 file2<<
"| Bad DCal | "<<nDCalCells<<
" | "<<perBadDCal<<
"% |"<<endl;
2138 file2<<
"| - Warm DCal | "<<nWDCalCells<<
" | "<<perWarmDCal<<
"% |"<<endl;
2139 file2<<
"| Summ D+B | "<<nDeadEMCalCells+nEMCalCells+nDeadDCalCells+nDCalCells<<
" | "<<(nDeadEMCalCells+nEMCalCells+nDeadDCalCells+nDCalCells)*100/(1.0*fNoOfCells)<<
"% |"<<endl;
2176 gROOT->SetStyle(
"Plain");
2177 gStyle->SetOptStat(0);
2178 gStyle->SetFillColor(kWhite);
2179 gStyle->SetTitleFillColor(kWhite);
2180 gStyle->SetPalette(1);
2186 fRootFile->WriteObject(hRefDistr,hRefDistr->GetName());
2187 Int_t firstCanvas=0;
2189 TLatex*
text =
new TLatex(0.2,0.8,
"*Candidate*");
2190 text->SetTextSize(0.07);
2191 text->SetTextColor(kOrange-3);
2194 TLatex* text2 =
new TLatex(0.2,0.8,
"*Not a Candidate*");
2195 text2->SetTextSize(0.08);
2196 text2->SetTextColor(8);
2199 TLatex* textA =
new TLatex(0.65,0.62,
"*test*");
2200 textA->SetTextSize(0.04);
2201 textA->SetTextColor(1);
2207 std::vector<Int_t> channelVector;
2208 channelVector.clear();
2209 cout<<
" o Start printing into .pdf for version: "<<version<<endl;
2212 if(
fFlag[cell]==1 && version==0)channelVector.push_back(cell);
2213 if(
fFlag[cell]>1 && version==1)channelVector.push_back(cell);
2214 if(
fFlag[cell]==0 && version==2)channelVector.push_back(cell);
2215 if(
fFlag[cell]>1 && version==10)channelVector.push_back(cell);
2216 if(
fFlag[cell]==0 && version==20)channelVector.push_back(cell);
2218 if(cell%2000==0)cout<<
"...cell No."<<cell<<endl;
2220 if(channelVector.size()==9 || cell == fNoOfCells-1)
2225 TCanvas *c1 =
new TCanvas(
"badcells",
"badcells",1000,750);
2226 if(channelVector.size() > 6) c1->Divide(3,3);
2227 else if (channelVector.size() > 3) c1->Divide(3,2);
2228 else c1->Divide(3,1);
2230 TLegend *leg =
new TLegend(0.7, 0.7, 0.9, 0.9);
2231 for(
Int_t i=0; i< (
Int_t)channelVector.size() ; i++)
2233 if(channelVector.size() >=
fNoOfCells) cout<<
"Massive problem"<<endl;
2234 sprintf(name,
"Cell %d",channelVector.at(i)) ;
2235 TH1 *hCell =
fCellAmplitude->ProjectionX(name,channelVector.at(i)+1,channelVector.at(i)+1);
2236 sprintf(title,
"Cell No: %d Entries: %d",channelVector.at(i), (
Int_t)hCell->GetEntries()) ;
2239 c1->cd(i%9 + 1)->SetLogy();
2242 leg->AddEntry(hRefDistr,
"mean of good",
"l");
2243 leg->AddEntry(hCell,
"current",
"l");
2247 if(candidate==1)
fWarmCell[channelVector.at(i)]=candidate;
2250 hCell->Divide(hRefDistr);
2260 hCell->SetLineColor(kBlue+1);
2261 hCell->GetXaxis()->SetTitle(
"E (GeV)");
2262 hCell->GetYaxis()->SetTitle(
"N Entries");
2263 hCell->GetXaxis()->SetRangeUser(0.,10.);
2264 hCell->SetLineWidth(1) ;
2265 hCell->SetTitle(title);
2266 hRefDistr->SetLineColor(kGray+2);
2267 hRefDistr->SetLineWidth(1);
2269 hCell->Draw(
"hist");
2271 if(version==1 || version==2)hRefDistr->Draw(
"same hist") ;
2274 if(candidate==1 && (version==1 || version==10))
2276 gPad->SetFrameFillColor(kYellow-10);
2281 textA->SetTitle(Form(
"Excluded by No. %d",
fFlag[channelVector.at(i)]));
2282 textA->DrawLatex(0.65,0.62,Form(
"Excluded by No. %d",
fFlag[channelVector.at(i)]));
2284 if(candidate==0 && (version==2 || version==20))
2286 gPad->SetFrameFillColor(kYellow-10);
2290 if(version<2)leg->Draw();
2293 if(channelVector.size()<9 || cell == fNoOfCells-1)
2295 internal_pdfName +=
")";
2296 c1->Print(internal_pdfName.Data());
2298 else if(firstCanvas==0)
2300 internal_pdfName +=
"(";
2301 c1->Print(internal_pdfName.Data());
2306 c1->Print(internal_pdfName.Data());
2310 channelVector.clear();
2339 if(warmIn==0 &&
fFlag[cell]!=0 )
continue;
2341 if(warmIn==2 &&
fWarmCell[cell]==0)
continue;
2345 hgoodMean->Add(hGoodAmp);
2347 hgoodMean->Scale(1.0/NrGood);
2364 TString Name = Form(
"%s_ratio",histogram->GetName());
2365 TH1* ratio=(
TH1*)histogram->Clone(Name);
2366 ratio->Divide(reference);
2379 Int_t binHeightOne = reference->FindLastBinAbove(1.0/totalevents);
2380 Double_t binCentreHeightOne = reference->GetBinCenter(binHeightOne);
2381 Double_t thirdBinCentre = reference->GetBinCenter(3);
2390 if(ratio->FindLastBinAbove(0)<ratio->FindBin(binCentreHeightOne*percentageOfLast))
2399 ratio->GetXaxis()->SetRangeUser(thirdBinCentre,10);
2400 if(ratio->GetMaximum()>highestRatio)
2410 Int_t nullEntries=0;
2411 for(
Int_t i=2;i<binHeightOne;i++)
2413 if(ratio->GetBinContent(i)!=0)mean+=ratio->GetBinContent(i);
2416 mean*=1.0/(binHeightOne-1-nullEntries);
2417 if(mean>maxMean || mean<minMean)
2429 ratio->GetXaxis()->SetRangeUser(0,binCentreHeightOne);
2430 Double_t localMaxBin=ratio->GetMaximumBin();
2432 for(
Int_t i=2;i<binHeightOne;i++)
2435 if(ratio->GetBinContent(i)<=0)
continue;
2436 if(i>localMaxBin-3 && i<localMaxBin+3)
continue;
2437 mean+=ratio->GetBinContent(i);
2439 mean*=1.0/(binHeightOne-1);
2440 ratio->GetXaxis()->SetRangeUser(thirdBinCentre,binCentreHeightOne);
2442 if(ratio->GetMaximum()>mean*higherThanMean)
2454 Int_t cliffBin = ratio->FindBin(4);
2455 for(
Int_t i=cliffBin-10;i<cliffBin+11;i++)
2458 if(ratio->GetBinContent(i)<=0)
continue;
2459 if(i<=cliffBin) binsBefore++;
2460 if(i>cliffBin) binsAfter++;
2461 if(i<=cliffBin) beforeCliff+=ratio->GetBinContent(i);
2462 if(i>cliffBin) afterCliff+=ratio->GetBinContent(i);
2463 beforeCliff*=1.0/binsBefore;
2464 afterCliff*=1.0/binsAfter;
2466 if((beforeCliff-afterCliff)>cliffSize*afterCliff)
2468 if(beforeCliff!=0 && afterCliff!=0)candidate=0;
2469 if(beforeCliff!=0 && afterCliff!=0)cout<<
"5"<<endl;
2500 Bool_t coveredByTRDSupportStruc=0;
2502 if((collumn>3 && collumn<9) || (collumn>32 && collumn<37) || (collumn>57 && collumn<61) || (collumn>84 && collumn<90) ||
2503 (row==1) ||(row>20 && row<25) || (row>44 && row<49) || (row>68 && row<73) || (row>91 && row<96) ||
2504 (row>116 && row<120)|| row==127 || (row>148 && row<152) || (row>172 && row<177) || (row>197 && row<201)
2507 coveredByTRDSupportStruc=1;
2509 return coveredByTRDSupportStruc;
2524 histoName = Form(
"2DChannelMap_Flag%d_V%i",flagBegin,
fTrial);
2525 if(flagBegin==0 && flagEnd==0)histoName = Form(
"2DChannelMap_Flag100_V%i",
fTrial);
2528 plot2D->GetXaxis()->SetTitle(
"cell column (#eta direction)");
2529 plot2D->GetYaxis()->SetTitle(
"cell row (#phi direction)");
2531 Int_t cellColumn=0,cellRow=0;
2532 Int_t cellColumnAbs=0,cellRowAbs=0;
2544 cout<<
"Problem! wrong calculated number of max col and max rows"<<endl;
2545 cout<<
"current col: "<<cellColumnAbs<<
", max col"<<
fNMaxColsAbs<<endl;
2546 cout<<
"current row: "<<cellRowAbs<<
", max row"<<
fNMaxRowsAbs<<endl;
2548 if(flagEnd==-1 &&
fFlag[cell]==flagBegin) plot2D->SetBinContent(cellColumnAbs,cellRowAbs,1);
2549 if(flagEnd!=0 && flagEnd!=-1 &&
fFlag[cell]>=flagBegin &&
fFlag[cell]<=flagEnd)plot2D->SetBinContent(cellColumnAbs,cellRowAbs,1);
2550 if(flagBegin==0 && flagEnd==0 &&
fWarmCell[cell]==1) plot2D->SetBinContent(cellColumnAbs,cellRowAbs,1);
2554 TCanvas *c1 =
new TCanvas(histoName,histoName,500,500);
2555 c1->ToggleEventStatus();
2559 plot2D->Draw(
"colz");
2562 if(flagBegin==0 && flagEnd==-1) text =
new TLatex(0.2,0.8,
"Good Cells");
2563 if(flagBegin==1) text =
new TLatex(0.2,0.8,
"Dead Cells");
2564 if(flagBegin>1) text =
new TLatex(0.2,0.8,
"Bad Cells");
2565 if(flagBegin==0 && flagEnd==0) text =
new TLatex(0.2,0.8,
"Warm Cells");
2566 text->SetTextSize(0.06);
2568 text->SetTextColor(1);
2575 fRootFile->WriteObject(plot2D,plot2D->GetName());
2592 sprintf(name,
"Cell %d",cell) ;
2611 cout<<
"******* Debug No "<<number<<
" ********"<<endl;
2613 cout<<
"*** number of period analyses: "<<
fAnalysisVector.size()<<endl;
2614 cout<<
"*** number of man mask cells: "<<
fManualMask.size()<<endl;
2615 cout<<
"*** Bad+Dead(!0) fFlag elements: "<<
fFlag.size()-zeroFlag<<endl;
2616 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
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.
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
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.)
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.
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