20 #include <Riostream.h> 30 #include <AliEMCALGeometry.h> 32 #include <AliAODEvent.h> 51 fCurrentRunNumber(-1),
56 fCellStartDCal(12288),
67 fExternalFileName(
""),
68 fExternalBadMapName(
""),
76 fCriterionCounter(0x0),
158 gROOT->ProcessLine(
"gErrorIgnoreLevel = kWarning;");
184 fRootFile =
new TFile(fileName,
"recreate");
199 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};
204 cout<<
"Number of supermod: "<<nModules<<endl;
291 cout<<
". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ."<<endl;
292 cout<<
". . .Start process by converting files. . . . . . . . . . . ."<<endl;
297 Printf(
"File not produced, exit");
305 cout<<
". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ."<<endl;
306 cout<<
". . .Start process by loading external file. . . . . . . . . . ."<<endl;
313 cout<<
". . .Load inputfile with name: "<<
fMergedFileName<<
" . . . . . . . ."<<endl;
318 if(!mergedFileInput->IsOpen())
320 Printf(
"Error! Input file not found, abort");
331 cout<<
". . .Continue process by . . . . . . . . . . . ."<<endl;
337 cout<<
"o o o Flag dead cells o o o"<<endl;
347 cout<<
"o o o Flag bad cells o o o"<<endl;
354 if(
fPrint==1)cout<<
"o o o Write .txt for each period analyis with bad cells o o o"<<endl;
366 if(
fPrint==1)cout<<
"o o o Create summary documents for the entire analysis o o o"<<endl;
378 Int_t binHeightOne = hRefDistr->FindLastBinAbove(1.0/totalevents);
379 Double_t binCentreHeightOne = hRefDistr->GetBinCenter(binHeightOne);
380 cout<<
". . .Recomendation:"<<endl;
381 cout<<
". . .With the current statistic on average a cell has 1 hit at "<<binCentreHeightOne<<
" GeV"<<endl;
382 cout<<
". . .so it makes no sense to select energy ranges >"<<binCentreHeightOne<<
"GeV as cells will be"<<endl;
383 cout<<
". . .marked bad just due to the lack of statistic"<<endl;
384 cout<<
". . .your selected lower bond is "<<
fEndLowerBound<<
" GeV"<<endl;
385 if(binCentreHeightOne>=
fEndLowerBound) cout<<
". . .This means you are OK!"<<endl;
386 if(binCentreHeightOne<
fEndLowerBound) cout<<
". . .#!#!#!#! CAREFUL THIS COULD CAUSE TROUBLE AND THROW OUT MORE CELLS THAN NECESSARY #!#!#!#! "<<endl;
387 cout<<
". . .End of process . . . . . . . . . . . . . . . . . . . . ."<<endl;
388 cout<<
". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ."<<endl;
399 cout<<
"o o o Start conversion process o o o"<<endl;
403 TH1F *hNEventsProcessedPerRun=
new TH1F(
"hNEvents",
"Number of processed events in analyzed runs",1,0,1);
404 TH2F *hCellAmplitude;
408 cout<<
"o o o Open .txt file with run indices. Name = " <<
fRunList << endl;
409 FILE *pFile = fopen(
fRunList.Data(),
"r");
412 cout<<
"couldn't open file!"<<endl;
423 ncols = fscanf(pFile,
" %d ",&q);
432 const Int_t nRun = nlines ;
437 cout<<
"o o o Start merging process of " << nRun <<
" files"<< endl;
440 for(
Int_t i = 0 ; i < nRun ; i++)
444 infile = Form(
"%s.root",base.Data()) ;
446 cout<<
" o Open .root file with name: "<<infile<<endl;
447 TFile *f = TFile::Open(infile);
452 cout<<
"Couldn't open/find .root file: "<<infile<<endl;
455 TDirectoryFile *
dir = (TDirectoryFile *)f->Get(
fQADirect);
458 cout<<
"Couln't open directory file in .root file: "<<infile<<
", directory: "<<
fQADirect<<endl;
464 cout <<
"Couln't get TList from directory file: "<<
fQADirect<<endl;
472 hAmpId =(
TH2F*)outputList->FindObject(
"EMCAL_hAmpId");
475 Printf(
"hAmpId not found");
481 hAmpId->SetName(
"hCellAmplitude");
482 hAmpId->SetTitle(
"Cell Amplitude");
485 hTimeId =(
TH2F*)outputList->FindObject(
"EMCAL_hTimeId");
488 Printf(
"hTimeId not found");
494 hTimeId->SetName(
"hCellTime");
495 hTimeId->SetTitle(
"Cell Time");
501 hCellAmplitude=(
TH2F*)hAmpId->Clone(
"DummyName1");
502 hCellAmplitude->Reset();
503 hCellAmplitude->SetDirectory(0);
505 hCellTime=(
TH2F*)hTimeId->Clone(
"DummyName2");
507 hCellTime->SetDirectory(0);
510 hNEvents =(TH1F *)outputList->FindObject(
"hNEvents");
513 Printf(
"hNEvents not found");
517 nEntr = (
Int_t)hNEvents->GetEntries();
522 cout <<
" o File to small to be merged. Only N entries " << nEntr << endl;
525 cout <<
" o File with N entries " << nEntr<<
" will be merged"<< endl;
527 hCellAmplitude->Add(hAmpId);
528 hCellTime->Add(hTimeId);
529 hNEventsProcessedPerRun->Add(hNEvents);
534 TFile *singleRunFile = TFile::Open(singleRunFileName,
"recreate");
541 singleRunFile->Close();
543 outputList->Delete();
552 cout<<
"o o o Save the merged histogramms to .root file with name: "<<
fMergedFileName<<endl;
553 cout<<
"o o o "<<nEntrTot<<
" events were merged"<<endl;
557 hNEventsProcessedPerRun->Write();
558 hCellAmplitude->SetName(
"hCellAmplitude");
559 hCellAmplitude->SetTitle(
"Cell Amplitude");
560 hCellAmplitude->Write();
561 hCellTime->SetName(
"hCellTime");
562 hCellTime->SetTitle(
"Cell Time");
565 cout<<
"o o o End conversion process o o o"<<endl;
566 if(hNEventsProcessedPerRun)
delete hNEventsProcessedPerRun;
571 if(hNEventsProcessedPerRun)
delete hNEventsProcessedPerRun;
586 TFile* outputRoot = TFile::Open(extRootFileName.Data());
588 TH1F* hFlags =(TH1F*)outputRoot->Get(
"fhCellFlag");
594 Double_t extFlag = hFlags->GetBinContent(cell+1);
597 fFlag[cell] =extFlag;
617 PeriodAnalysis(periodArray.At(0),periodArray.At(1),periodArray.At(2),periodArray.At(3));
622 cout<<
"o o o End of bad channel analysis o o o"<<endl;
632 cout<<
"o o o Manually mask SM "<<iSM<<
" o o o"<<endl;
656 periodArray.AddAt((
Double_t)criteria,0);
657 periodArray.AddAt(nsigma,1);
658 periodArray.AddAt(emin,2);
659 periodArray.AddAt(emax,3);
681 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;
682 if(
fPrint==1)cout<<
"o o o PeriodAnalysis for flag "<<criterion<<
" o o o"<<endl;
684 if(
fPrint==1 && criterion != 3)cout<<
"o o o Done in the energy range E "<<emin<<
" - "<<emax<<endl;
685 if(
fPrint==1 && criterion == 3)cout<<
"o o o Done in the time range t "<<emin<<
" - "<<emax<<endl;
698 if(
fPrint==1)cout<<
"o o o Analyze average cell distributions o o o"<<endl;
702 if(criterion == 3) histogram =
BuildTimeMean(criterion, emin, emax);
704 if(criterion==1 || criterion == 4)
708 else FlagAsBad(criterion, histogram, nsigma, 200);
710 if(criterion==2 || criterion == 5)
714 else FlagAsBad(criterion, histogram, nsigma, 601);
732 if(
fPrint==1)cout<<
" o Calculate average cell hit per event and average cell energy per hit "<<endl;
734 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);
735 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);
736 histogram->SetXTitle(
"Abs. Cell Id");
737 if(crit==1)histogram->SetYTitle(
"Energy per hit");
738 if(crit==2)histogram->SetYTitle(
"Number of hits in cell");
739 histogram->GetXaxis()->SetNdivisions(510);
742 TH1F* pojection = (TH1F*)
fCellAmplitude->ProjectionX(
"Intermediate");
743 fnEventsInRange = pojection->Integral(pojection->GetBinContent(emin),pojection->GetBinContent(emax));
757 if (E < emin || E > emax ||
fFlag[cell]!=0)
continue;
764 if(crit==2) histogram->SetBinContent(cell+1, Nsum);
765 if(Nsum > 0. && crit==1)histogram->SetBinContent(cell+1, Esum/(Nsum));
787 if(
fPrint==1)cout<<
" o Calculate average cell hit per event and average cell energy per hit "<<endl;
788 TH1F *histogram = NULL;
789 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);
790 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);
791 histogram->SetXTitle(
"Abs. Cell Id");
792 if(crit==4)histogram->SetYTitle(
"Energy per hit");
793 if(crit==5)histogram->SetYTitle(
"Number of hits in cell");
794 histogram->GetXaxis()->SetNdivisions(510);
799 TH1F *hEnergyCol =
new TH1F(
"hEnergyCol",
"hEnergyCol", 100,0.,100.);
800 TH1F *hEnergyRow =
new TH1F(
"hEnergyRow",
"hEnergyRow", 250,0.,250.);
804 Int_t cellCol, cellRow, trash, col, row;
811 for(
int iCell = 1; iCell <=
fNoOfCells; iCell++){
813 if(
fFlag[iCell -1] == 0){
814 for(
int k = hEnergyScaled->GetXaxis()->FindBin(emin); k <= hEnergyScaled->GetXaxis()->FindBin(emax); k++){
815 NoOfHits += hEnergyScaled->GetBinContent(k, iCell);
818 arrHits[iCell - 1] = NoOfHits;
827 TH1D *hHitDistrib_forScaling =
new TH1D(
"hHitDistrib_forScaling",
"hHitDistrib_forScaling",1000,0.,TMath::Median(
fNoOfCells,arrHits)*4);
828 TF1 *fgausForScaling =
new TF1(
"fgausForScaling",
"gaus", 0.,TMath::Median(
fNoOfCells,arrHits)*4);
829 TVectorD fFlagForScaling;
835 for(
int k = hEnergyScaled->GetXaxis()->FindBin(emin); k <= hEnergyScaled->GetXaxis()->FindBin(emax); k++){
836 if(crit==5){dhits += hEnergyScaled->GetBinContent(k, i);}
838 dhits += hEnergyScaled->GetBinContent(k, i + 1)*hEnergyScaled->GetXaxis()->GetBinCenter(k);
839 dNumOfHits += hEnergyScaled->GetBinContent(k, i + 1);
842 if(crit==4 && dNumOfHits > 0){dhits = dhits / dNumOfHits;}
844 hHitDistrib_forScaling->Fill(dhits);
849 fgausForScaling->SetParameter(1, hHitDistrib_forScaling->GetBinCenter(hHitDistrib_forScaling-> GetMaximumBin()));
850 hHitDistrib_forScaling->Fit(fgausForScaling,
"MQ0");
851 hHitDistrib_forScaling->Fit(fgausForScaling,
"MQ0");
853 for(
int iCell = 1; iCell <=
fNoOfCells; iCell++){
856 for(
int k = hEnergyScaled->GetXaxis()->FindBin(emin); k <= hEnergyScaled->GetXaxis()->FindBin(emax); k++){
857 if(crit==5){dhits += hEnergyScaled->GetBinContent(k, iCell);}
859 dhits += hEnergyScaled->GetBinContent(k, iCell + 1)*hEnergyScaled->GetXaxis()->GetBinCenter(k);
860 dNumOfHits += hEnergyScaled->GetBinContent(k, iCell + 1);
863 if(crit==4 && dNumOfHits > 0){dhits = dhits / dNumOfHits;}
864 if(dhits > fgausForScaling->GetParameter(1) + 5* fgausForScaling->GetParameter(2) || dhits < fgausForScaling->GetParameter(1) - 5* fgausForScaling->GetParameter(2)){
865 fFlagForScaling[iCell - 1] = 1;
869 delete hHitDistrib_forScaling;
870 delete fgausForScaling;
878 for(
int iter = 0; iter < 5; iter++){
880 std::vector<Double_t> vecCol[100];
881 std::vector<Double_t> vecRow[250];
905 for(
int iCell = 0; iCell <
fNoOfCells; iCell++){
906 if(
fFlag[iCell] == 0 && fFlagForScaling[iCell] == 0){
910 for (
int EBin = hEnergyScaled->GetXaxis()->FindBin(emin); EBin < hEnergyScaled->GetXaxis()->FindBin(emax); EBin++) {
911 if(crit==5){dCellEnergy += hEnergyScaled->GetBinContent(EBin, iCell + 1);}
913 dCellEnergy += hEnergyScaled->GetBinContent(EBin, iCell + 1)*hEnergyScaled->GetXaxis()->GetBinCenter(EBin);
914 dNumOfHits += hEnergyScaled->GetBinContent(EBin, iCell + 1);
918 if(crit==4 && dNumOfHits > 0){dCellEnergy = dCellEnergy / dNumOfHits;}
920 if( dCellEnergy > 0.){
921 hEnergyCol->Fill(col + 0.5, dCellEnergy);
922 hEnergyRow->Fill(row + 0.5, dCellEnergy);
923 vecCol[col].push_back(dCellEnergy);
924 vecRow[row].push_back(dCellEnergy);
930 for(
int iCol = 1; iCol <= hEnergyCol->GetNbinsX() ; iCol++){
931 if(vecCol[iCol -1].size() > 0.){
932 hEnergyCol->SetBinContent(hEnergyCol->FindBin(iCol - 0.5), hEnergyCol->GetBinContent(hEnergyCol->FindBin(iCol - 0.5))/vecCol[iCol-1].size() );
937 for(
int iRow = 1; iRow <= hEnergyRow->GetNbinsX() ; iRow++){
938 if(vecRow[iRow -1].size() > 0.){
939 hEnergyRow->SetBinContent(hEnergyRow->FindBin(iRow - 0.5), hEnergyRow->GetBinContent(hEnergyRow->FindBin(iRow - 0.5))/vecRow[iRow-1].size() );
944 fFitRow =
new TF1(
"fFitRow",
"[0]",0.,250.);
945 fFitRow->SetParameter(0, hEnergyRow->GetBinContent(10));
946 Double_t MeanRow = hEnergyRow->GetBinContent(10);
949 fFitCol =
new TF1(
"fFitCol",
"[0]",0.,100.);
950 fFitCol->SetParameter(0, hEnergyCol->GetBinContent(10));
951 Double_t MeanCol = hEnergyCol->GetBinContent(10);
955 for(
int iCell = 0; iCell <
fNoOfCells; iCell++){
957 if (hEnergyCol->GetBinContent(col + 1) > 0.) {
958 for(
int EBin = 1; EBin < hEnergyScaled->GetNbinsX(); EBin++) {
959 hEnergyScaled->SetBinContent(EBin, iCell + 1, hEnergyScaled->GetBinContent(EBin, iCell + 1) * (MeanCol / hEnergyCol->GetBinContent(col + 1)));
965 for(
int iCell = 0; iCell <
fNoOfCells; iCell++){
967 if (hEnergyRow->GetBinContent(row + 1) > 0.) {
968 for(
int EBin = 1; EBin < hEnergyScaled->GetNbinsX(); EBin++) {
969 hEnergyScaled->SetBinContent(EBin, iCell + 1, hEnergyScaled->GetBinContent(EBin, iCell + 1) * (MeanRow / hEnergyRow->GetBinContent(row + 1)));
986 for (
Int_t j = 1; j <= hEnergyScaled->GetNbinsX(); j++)
989 Double_t E = hEnergyScaled->GetXaxis()->GetBinCenter(j);
990 Double_t N = hEnergyScaled->GetBinContent(j, cell+1);
992 if (E < emin || E > emax ||
fFlag[cell]!=0)
continue;
999 if(crit==5) histogram->SetBinContent(cell+1, Nsum);
1000 if(Nsum > 0. && crit==4)histogram->SetBinContent(cell+1, Esum/(Nsum));
1003 delete hEnergyScaled;
1021 if(
fPrint==1)cout<<
" o Calculate maximum of cell time distribution "<<endl;
1023 TH1F *histogram = NULL;
1024 histogram =
new TH1F(Form(
"timeMax_t%.2f-%.2f",tmin,tmax),Form(
"Maximum of time distr., %.2f < t < %.2f ns",tmin,tmax),
fNoOfCells,0,
fNoOfCells);
1025 histogram->SetXTitle(
"Abs. Cell Id");
1026 histogram->SetYTitle(
"time max");
1027 histogram->GetXaxis()->SetNdivisions(510);
1033 for(
int iCell = 1; iCell <=
fNoOfCells; iCell ++){
1034 if(
fFlag[iCell - 1] != 0) {
continue; }
1037 for(
int iTime = 1; iTime <=
fCellTime->GetNbinsX(); iTime++){
1038 dHits =
fCellTime->GetBinContent(iTime, iCell);
1039 if(
fCellTime->GetXaxis()->GetBinCenter(iTime) > tmin &&
fCellTime->GetXaxis()->GetBinCenter(iTime) < tmax){
1045 histogram->SetBinContent(iCell, dAll/dIn);
1047 histogram->SetBinContent(iCell, 0.);
1061 Int_t manualMaskCounter=0;
1078 if(nSum == 0 &&
fFlag[cell]==0)
1089 manualMaskCounter++;
1092 if(
fPrint==1)cout<<
" o Number of dead cells: "<<sumOfExcl<<endl;
1093 if(
fPrint==1)cout<<
" ("<<sumOfExcl<<
")"<<endl;
1113 gStyle->SetOptStat(0);
1114 gStyle->SetOptFit(0);
1115 if(
fPrint==1 && crit==1)cout<<
" o Fit average energy per hit distribution"<<endl;
1116 if(
fPrint==1 && crit==2)cout<<
" o Fit average hit per event distribution"<<endl;
1117 if(
fPrint==1 && crit==3)cout<<
" o Fit average hit maximum distribution"<<endl;
1119 Int_t cellColumn=0,cellRow=0;
1120 Int_t cellColumnAbs=0,cellRowAbs=0;
1123 TString histoName=inhisto->GetName();
1128 Double_t dminVal = inhisto->GetMinimum(0);
1129 Double_t dmaxVal = inhisto->GetMaximum();
1137 if((crit==2 || crit == 5) && inputBins==-1) dnbins=dmaxVal-dminVal;
1138 if((crit==1 || crit == 4) && inputBins==-1) dnbins=200;
1145 Int_t numBins = inhisto->GetXaxis()->GetNbins();
1150 for (
int i = 0; i < numBins; i++)
1154 if(x[i]==0)y[i] = 0;
1156 medianOfHisto = TMath::Median(numBins,x,y);
1161 if(medianOfHisto*10<dmaxVal)
1164 dmaxVal=medianOfHisto+0.2*(dmaxVal-medianOfHisto);
1167 if(crit==2 || crit == 5)
1169 dnbins=dmaxVal-dminVal;
1172 if(dnbins>2000)dnbins=0.01*(dmaxVal-dminVal);
1173 if(dnbins>2000)dnbins=0.001*(dmaxVal-dminVal);
1174 if(dnbins<100) dnbins=0.02*(dmaxVal-dminVal);
1177 if(crit==1 || crit == 4)
1179 dnbins=(dmaxVal-dminVal)*500;
1190 dnbins =
fCellTime->GetXaxis()->GetNbins();
1191 dminVal=
fCellTime->GetXaxis()->GetBinCenter(1)-(binWidth*1.0)/2.0;
1192 dmaxVal=
fCellTime->GetXaxis()->GetBinCenter(dnbins)+(binWidth*1.0)/2.0;
1193 cout<<
"set the new histo with following settings- bins: "<<dnbins<<
", min val = "<<dminVal<<
", max val:"<<dmaxVal<<endl;
1196 TH1F *distrib =
new TH1F(Form(
"%sDistr",(
const char*)histoName),
"", dnbins, dminVal, dmaxVal);
1197 distrib->SetXTitle(inhisto->GetYaxis()->GetTitle());
1198 distrib->SetYTitle(
"Entries");
1199 TH1F *distrib_wTRDStruc =
new TH1F(Form(
"%sDistr_wTRD",(
const char*)histoName),
"", dnbins, dminVal, dmaxVal);
1200 TH1F *distrib_woTRDStruc=
new TH1F(Form(
"%sDistr_woTRD",(
const char*)histoName),
"", dnbins, dminVal, dmaxVal);
1204 plot2D->GetXaxis()->SetTitle(
"cell column (#eta direction)");
1205 plot2D->GetYaxis()->SetTitle(
"cell row (#phi direction)");
1219 distrib->Fill(inhisto->GetBinContent(cell+1));
1226 cout<<
"Problem! wrong calculated number of max col and max rows"<<endl;
1227 cout<<
"current col: "<<cellColumnAbs<<
", max col"<<
fNMaxColsAbs<<endl;
1228 cout<<
"current row: "<<cellRowAbs<<
", max row"<<
fNMaxRowsAbs<<endl;
1230 plot2D->SetBinContent(cellColumnAbs,cellRowAbs,inhisto->GetBinContent(cell+1));
1234 distrib_wTRDStruc->Fill(inhisto->GetBinContent(cell+1));
1238 distrib_woTRDStruc ->Fill(inhisto->GetBinContent(cell+1));
1246 TCanvas *c1 =
new TCanvas(histoName,histoName,900,900);
1247 c1->ToggleEventStatus();
1248 TPad* upperPad =
new TPad(
"upperPad",
"upperPad",.005, .5, .995, .995);
1249 TPad* lowerPadLeft =
new TPad(
"lowerPadL",
"lowerPadL",.005, .005, .5, .5);
1250 TPad* lowerPadRight =
new TPad(
"lowerPadR",
"lowerPadR",.5, .005, .995, .5);
1252 lowerPadLeft->Draw();
1253 lowerPadRight->Draw();
1256 upperPad->SetLeftMargin(0.05);
1257 upperPad->SetRightMargin(0.05);
1258 if(crit!=3)upperPad->SetLogy();
1259 inhisto->SetTitleOffset(0.6,
"Y");
1260 inhisto->GetXaxis()->SetRangeUser(0,fNoOfCells+1);
1261 inhisto->GetYaxis()->SetTitleOffset(0.7);
1262 inhisto->SetLineColor(kBlue+1);
1263 inhisto->DrawCopy();
1265 lowerPadRight->cd();
1266 lowerPadRight->SetLeftMargin(0.09);
1267 lowerPadRight->SetRightMargin(0.12);
1268 plot2D->GetYaxis()->SetTitleOffset(1.3);
1269 plot2D->DrawCopy(
"colz");
1272 lowerPadLeft->SetLeftMargin(0.09);
1273 lowerPadLeft->SetRightMargin(0.07);
1274 lowerPadLeft->SetLogy();
1275 distrib->SetLineColor(kBlue+1);
1276 distrib->GetYaxis()->SetTitleOffset(1.3);
1281 distrib->DrawCopy(
"");
1282 distrib_wTRDStruc->SetLineColor(kGreen+1);
1283 distrib_wTRDStruc->DrawCopy(
"same");
1284 distrib_woTRDStruc->SetLineColor(kMagenta+1);
1285 distrib_woTRDStruc->DrawCopy(
"same");
1294 Double_t maxDistr = distrib->GetMaximum();
1295 Int_t maxBin = distrib->GetMaximumBin();
1296 Double_t maxCenter = distrib->GetBinCenter(maxBin);
1300 for(
Int_t i = maxBin ; i<=dnbins ; i++)
1302 if(distrib->GetBinContent(i)<2)
break ;
1303 goodmax = distrib->GetBinCenter(i);
1305 for(
Int_t i = maxBin ; i>2 ; i--)
1307 if(distrib->GetBinContent(i)<2)
break ;
1308 goodmin = distrib->GetBinLowEdge(i);
1318 if(crit==3)minFitRange=-20;
1319 if(crit==3)maxFitRange=20;
1324 TF1 *fit2 =
new TF1(
"fit2",
"gaus",minFitRange,maxFitRange);
1326 fit2->SetParLimits(0,0,maxDistr);
1327 fit2->SetParameter(1,maxCenter);
1328 fit2->SetParLimits(1,0,dmaxVal);
1331 distrib->Fit(fit2,
"0LQEM",
"", minFitRange, maxFitRange);
1333 mean = fit2->GetParameter(1);
1334 sig = fit2->GetParameter(2);
1339 goodmin = mean - nsigma*sig ;
1340 goodmax = mean + nsigma*sig ;
1345 if(inputBins==-1) goodmin=-1;
1346 if(goodmin <=0.) goodmin = -100;
1347 if(
fPrint==1)cout<<
" o Result of fit: "<<endl;
1348 if(
fPrint==1)cout<<
" o "<<endl;
1349 if(
fPrint==1)cout<<
" o Mean: "<<mean <<
" sigma: "<<sig<<endl;
1350 if(
fPrint==1)cout<<
" o good range : "<<goodmin <<
" - "<<goodmax<<endl;
1355 TLine *lline =
new TLine(goodmin, 0, goodmin, distrib->GetMaximum());
1356 lline->SetLineColor(kGreen+2);
1357 lline->SetLineStyle(7);
1360 TLine *rline =
new TLine(goodmax, 0, goodmax, distrib->GetMaximum());
1361 rline->SetLineColor(kGreen+2);
1362 rline->SetLineStyle(7);
1365 TLegend *leg =
new TLegend(0.60,0.70,0.9,0.85);
1366 leg->AddEntry(lline,
"Good region boundary",
"l");
1367 leg->AddEntry(distrib_wTRDStruc,
"Covered by TRD",
"l");
1368 leg->AddEntry(distrib_woTRDStruc,
"wo TRD structure",
"l");
1369 leg->SetBorderSize(0);
1372 fit2->SetLineColor(kOrange-3);
1373 fit2->SetLineStyle(1);
1378 if(crit==1 || crit==4) text =
new TLatex(0.12,0.85,Form(
"Good range: %.2f-%.2f",goodmin,goodmax));
1379 if(crit==2 || crit==5) text =
new TLatex(0.12,0.85,Form(
"Good range: %.2f-%.2f",goodmin,goodmax));
1380 if(crit==3) text =
new TLatex(0.12,0.85,Form(
"Good range: %.2f-%.2f",goodmin,goodmax));
1381 text->SetTextSize(0.06);
1383 text->SetTextColor(1);
1387 TLine *uline =
new TLine(0, goodmax,fNoOfCells,goodmax);
1388 uline->SetLineColor(kGreen+2);
1389 uline->SetLineStyle(7);
1391 TLine *lowline =
new TLine(0, goodmin,fNoOfCells,goodmin);
1392 lowline->SetLineColor(kGreen+2);
1393 lowline->SetLineStyle(7);
1400 if(crit==1)name=Form(
"%s/%s/AverageEperHit_%s.gif",
fWorkdir.Data(),
fAnalysisOutput.Data(), (
const char*)histoName);
1401 if(crit==2)name=Form(
"%s/%s/AverageHitperEvent_%s.gif",
fWorkdir.Data(),
fAnalysisOutput.Data(), (
const char*)histoName);
1402 if(crit==3)name=Form(
"%s/%s/AverageTimeMax_%s.gif",
fWorkdir.Data(),
fAnalysisOutput.Data(), (
const char*)histoName);
1403 if(crit==4)name=Form(
"%s/%s/AverageEperHit_scaled_%s.gif",
fWorkdir.Data(),
fAnalysisOutput.Data(), (
const char*)histoName);
1404 if(crit==5)name=Form(
"%s/%s/AverageHitperEvent_scaled_%s.gif",
fWorkdir.Data(),
fAnalysisOutput.Data(), (
const char*)histoName);
1407 fRootFile->WriteObject(c1,c1->GetName());
1408 fRootFile->WriteObject(plot2D,plot2D->GetName());
1409 fRootFile->WriteObject(distrib,distrib->GetName());
1410 fRootFile->WriteObject(inhisto,inhisto->GetName());
1417 if(
fPrint==1)cout<<
" o Flag bad cells that are outside the good range "<<endl;
1422 if(inhisto->GetBinContent(cell+1) <= goodmin &&
fFlag[cell]==0)
1426 if(inhisto->GetBinContent(cell+1) > goodmax && fFlag[cell]==0)
1431 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;
1463 Int_t cellColumn=0,cellRow=0;
1464 Int_t cellColumnAbs=0,cellRowAbs=0;
1467 TString histoName=inhisto->GetName();
1470 TH1F *distrib =
new TH1F(Form(
"%sDistr",(
const char*)histoName),
"", 100, 1., 3.);
1471 TH1F *distrib_wTRDStruc =
new TH1F(Form(
"%sDistr",(
const char*)histoName),
"", 100, 1., 3.);
1472 TH1F *distrib_woTRDStruc =
new TH1F(Form(
"%sDistr",(
const char*)histoName),
"", 100, 1., 3.);
1475 plot2D->GetXaxis()->SetTitle(
"cell column (#eta direction)");
1476 plot2D->GetYaxis()->SetTitle(
"cell row (#phi direction)");
1490 distrib->Fill(inhisto->GetBinContent(cell+1));
1497 cout<<
"Problem! wrong calculated number of max col and max rows"<<endl;
1498 cout<<
"current col: "<<cellColumnAbs<<
", max col"<<
fNMaxColsAbs<<endl;
1499 cout<<
"current row: "<<cellRowAbs<<
", max row"<<
fNMaxRowsAbs<<endl;
1501 plot2D->SetBinContent(cellColumnAbs,cellRowAbs,inhisto->GetBinContent(cell+1));
1505 distrib_wTRDStruc->Fill(inhisto->GetBinContent(cell+1));
1509 distrib_woTRDStruc ->Fill(inhisto->GetBinContent(cell+1));
1515 TCanvas *c1 =
new TCanvas(histoName,histoName,900,900);
1516 c1->ToggleEventStatus();
1517 TPad* upperPad =
new TPad(
"upperPad",
"upperPad",.005, .5, .995, .995);
1518 TPad* lowerPadLeft =
new TPad(
"lowerPadL",
"lowerPadL",.005, .005, .5, .5);
1519 TPad* lowerPadRight =
new TPad(
"lowerPadR",
"lowerPadR",.5, .005, .995, .5);
1521 lowerPadLeft->Draw();
1522 lowerPadRight->Draw();
1525 upperPad->SetLeftMargin(0.05);
1526 upperPad->SetRightMargin(0.05);
1527 upperPad->SetLogy();
1528 inhisto->SetTitleOffset(0.6,
"Y");
1529 inhisto->GetXaxis()->SetRangeUser(0,fNoOfCells+1);
1530 inhisto->GetYaxis()->SetTitleOffset(0.7);
1531 inhisto->SetLineColor(kBlue+1);
1534 lowerPadRight->cd();
1535 lowerPadRight->SetLeftMargin(0.09);
1536 lowerPadRight->SetRightMargin(0.12);
1537 plot2D->GetYaxis()->SetTitleOffset(1.3);
1538 plot2D->Draw(
"colz");
1541 lowerPadLeft->SetLeftMargin(0.09);
1542 lowerPadLeft->SetRightMargin(0.07);
1543 lowerPadLeft->SetLogy();
1544 distrib->SetLineColor(kBlue+1);
1545 distrib->GetYaxis()->SetTitleOffset(1.3);
1547 distrib_wTRDStruc->SetLineColor(kGreen+1);
1548 distrib_wTRDStruc->DrawCopy(
"same");
1549 distrib_woTRDStruc->SetLineColor(kMagenta+1);
1550 distrib_woTRDStruc->DrawCopy(
"same");
1556 TLine *line =
new TLine(tCut, 0, tCut, distrib->GetMaximum());
1557 line->SetLineColor(kGreen+2);
1558 line->SetLineStyle(7);
1562 TLegend *leg =
new TLegend(0.60,0.70,0.9,0.85);
1563 leg->AddEntry(line,
"upper limit",
"l");
1564 leg->AddEntry(distrib_wTRDStruc,
"Covered by TRD",
"l");
1565 leg->AddEntry(distrib_woTRDStruc,
"wo TRD structure",
"l");
1566 leg->SetBorderSize(0);
1572 text =
new TLatex(0.12,0.85,Form(
"Good range: %.2f-%.2f",0.,tCut));
1573 text->SetTextSize(0.06);
1575 text->SetTextColor(1);
1579 TLine *uline =
new TLine(0, tCut,fNoOfCells,tCut);
1580 uline->SetLineColor(kGreen+2);
1581 uline->SetLineStyle(7);
1591 fRootFile->WriteObject(c1,c1->GetName());
1592 fRootFile->WriteObject(plot2D,plot2D->GetName());
1593 fRootFile->WriteObject(distrib,distrib->GetName());
1594 fRootFile->WriteObject(inhisto,inhisto->GetName());
1601 if(
fPrint==1)cout<<
" o Flag bad cells that are outside the good range "<<endl;
1606 if(inhisto->GetBinContent(cell+1) > tCut &&
fFlag[cell]==0)
1611 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;
1614 delete distrib_wTRDStruc;
1615 delete distrib_woTRDStruc;
1648 ofstream file2(aliceTwikiTable, ios::out | ios::trunc);
1651 file2<<
"|*Criterium* | *E_min !GeV* | *E_max !GeV* | *sigma* | *Excluded Cells* |"<<endl;
1658 criterion =periodArray.At(0);
1659 emin =periodArray.At(2);
1660 emax =periodArray.At(3);
1661 sig =periodArray.At(1);
1665 output.Form(
"%s/%s/Criterion%d_Emin-%.2f_Emax-%.2f.txt",
fWorkdir.Data(),
fAnalysisOutput.Data(), criterion,emin,emax);
1666 ofstream
file(output, ios::out | ios::trunc);
1669 cout<<
"#### Major Error. Check the textfile!"<<endl;
1671 file<<
"fFlag="<<i+2<<
"means Criterion : "<<criterion<<
", emin = "<<emin<<
" GeV"<<
", emax = "<<emax<<
" GeV"<<endl;
1672 if(
fPrint==1)cout<<
" o Criterion : "<<criterion<<
", emin = "<<emin<<
" GeV"<<
", emax = "<<emax<<
" GeV"<<
" (Method "<<i<<
")"<<endl;
1677 if(
fFlag[cellID]==(i+2))
1683 file<<
"Total number of bad cells with fFlag=="<<i+2<<endl;
1684 file<<
"("<<nb1<<
")"<<endl;
1686 if(
fPrint==1)cout<<
" o Total number of bad cells ("<<nb1<<
")"<<endl;
1691 ofstream file2(aliceTwikiTable, ios::out | ios::app);
1694 file2<<
"| "<<criterion<<
" | "<<emin<<
" | "<<emax<<
" | "<<sig<<
" | "<<nb1<<
" |"<<endl;
1708 Int_t cellID, nDeadDCalCells = 0, nDeadEMCalCells = 0, nDCalCells = 0, nEMCalCells = 0;
1709 Double_t perDeadEMCal,perDeadDCal,perBadEMCal,perBadDCal,perWarmEMCal,perWarmDCal;
1710 TString aliceTwikiTable, cellSummaryFile, deadPdfName, badPdfName, ratioOfBad,goodCells,goodCellsRatio,cellProp;
1711 TString OADBFile_bad, OADBFile_dead, OADBFile_warm;
1727 cout<<
" o Final results o "<<endl;
1739 cellAmp_masked->SetBinContent(amp,cell+1,0);
1748 cellTime_masked->SetBinContent(time,cell+1,0);
1755 TCanvas *c1 =
new TCanvas(
"CellProp",
"I summary of cell properties",1000,1000);
1756 c1->ToggleEventStatus();
1758 c1->cd(1)->SetLogz();
1765 c1->cd(2)->SetLogz();
1768 fCellTime->GetYaxis()->SetTitleOffset(1.6);
1770 c1->cd(3)->SetLogz();
1773 cellAmp_masked->SetTitle(
"Masked Cell Amplitude");
1774 cellAmp_masked->SetXTitle(
"Cell Energy [GeV]");
1775 cellAmp_masked->SetYTitle(
"Abs. Cell Id");
1776 cellAmp_masked->GetYaxis()->SetTitleOffset(1.6);
1777 cellAmp_masked->Draw(
"colz");
1778 c1->cd(4)->SetLogz();
1779 cellTime_masked->SetTitle(
"Masked Cell Time");
1780 cellTime_masked->SetXTitle(
"Cell Time [ns]");
1781 cellTime_masked->SetYTitle(
"Abs. Cell Id");
1782 cellTime_masked->GetYaxis()->SetTitleOffset(1.6);
1783 cellTime_masked->Draw(
"colz");
1786 TCanvas *c1_ratio =
new TCanvas(
"CellPropRatio",
"II summary of cell properties ratio",1000,500);
1787 c1_ratio->ToggleEventStatus();
1788 c1_ratio->Divide(2);
1789 c1_ratio->cd(1)->SetLogz();
1790 cellAmp_masked->SetTitle(
"Masked Cell Amplitude");
1791 cellAmp_masked->GetZaxis()->SetRangeUser(0.0001,10e7);
1792 cellAmp_masked->Draw(
"colz");
1793 c1_ratio->cd(2)->SetLogz();
1796 TH2F* ratio2DAmp =(
TH2F*)cellAmp_masked->Clone(
"ratio2DAmp");
1797 TH2F* Sum2DIdeal =(
TH2F*)cellAmp_masked->Clone(
"Sum2DIdeal");
1798 Sum2DIdeal->Reset();
1802 for(
Int_t eBin=0;eBin<Sum2DIdeal->GetNbinsX();eBin++)
1804 Double_t binVal=hRefDistr->GetBinContent(eBin+1);
1805 for(
Int_t icell=0;icell<Sum2DIdeal->GetNbinsY();icell++)
1807 Sum2DIdeal->SetBinContent(eBin+1,icell+1,binVal);
1810 ratio2DAmp->SetTitle(
"Ratio of cell Amplitude to mean cell ampl.");
1811 ratio2DAmp->Divide(Sum2DIdeal);
1812 ratio2DAmp->GetZaxis()->UnZoom();
1813 ratio2DAmp->DrawCopy(
"colz");
1816 TLatex* textSM =
new TLatex(0.1,0.1,
"*test*");
1817 textSM->SetTextSize(0.06);
1818 textSM->SetTextColor(1);
1821 TCanvas *c1_proj =
new TCanvas(
"CellPropPProj",
"III summary of cell properties",1000,500);
1822 c1_proj->ToggleEventStatus();
1824 c1_proj->cd(1)->SetLogy();
1825 TH1D* projEnergyMask = cellAmp_masked->ProjectionX(Form(
"%sMask_Proj",cellAmp_masked->GetName()),
fStartCell,fNoOfCells);
1826 projEnergyMask->SetXTitle(
"Cell Energy [GeV]");
1827 projEnergyMask->GetYaxis()->SetTitleOffset(1.6);
1828 projEnergyMask->SetLineColor(kGreen+1);
1829 projEnergyMask->DrawCopy(
" hist");
1831 projEnergy->DrawCopy(
"same hist");
1832 TLegend *leg =
new TLegend(0.50,0.75,0.7,0.87);
1833 leg->AddEntry(projEnergy,
"all cells",
"l");
1834 leg->AddEntry(projEnergyMask,
"good cells",
"l");
1835 leg->SetTextSize(0.05);
1836 leg->SetBorderSize(0);
1837 leg->SetFillColorAlpha(10, 0);
1839 TLegend *legBig = (TLegend*)leg->Clone(
"legBig");
1840 legBig->SetTextSize(0.08);
1841 legBig->SetX1NDC(0.2);
1843 c1_proj->cd(2)->SetLogy();
1844 TH1* projTimeMask = cellTime_masked->ProjectionX(Form(
"%s_Proj",cellTime_masked->GetName()),
fStartCell,fNoOfCells);
1845 projTimeMask->SetXTitle(
"Cell Time [ns]");
1846 projTimeMask->GetYaxis()->SetTitleOffset(1.6);
1847 projTimeMask->GetYaxis()->SetRangeUser(1,projTimeMask->GetMaximum()*20);
1848 projTimeMask->SetLineColor(kGreen+1);
1849 projTimeMask->DrawCopy(
"hist");
1851 projTime->DrawCopy(
"same hist");
1855 TCanvas *c1_projSM =
new TCanvas(
"CellPropPProjSM",
"III summary of cell Energy per SM",1200,900);
1856 c1_projSM->Divide(5,4,0.001,0.001);
1857 TH1* projEnergyMaskSM[20];
1858 TH1* projEnergySM[20];
1859 for(
Int_t iSM=0;iSM<20;iSM++)
1861 c1_projSM->cd(iSM+1)->SetLogy();
1862 gPad->SetTopMargin(0.03);
1863 gPad->SetBottomMargin(0.11);
1864 projEnergyMaskSM[iSM] = cellAmp_masked->ProjectionX(Form(
"%sMask_ProjSM%i",cellAmp_masked->GetName(),iSM),
fStartCellSM[iSM]+1,
fStartCellSM[iSM+1]);
1865 projEnergyMaskSM[iSM]->SetTitle(
"");
1866 projEnergyMaskSM[iSM]->SetXTitle(Form(
"Cell Energy [GeV], SM%i",iSM));
1867 projEnergyMaskSM[iSM]->GetYaxis()->SetTitleOffset(1.6);
1868 projEnergyMaskSM[iSM]->GetYaxis()->SetLabelSize(0.06);
1869 projEnergyMaskSM[iSM]->GetXaxis()->SetLabelSize(0.06);
1870 projEnergyMaskSM[iSM]->GetXaxis()->SetRangeUser(0,20);
1871 projEnergyMaskSM[iSM]->GetXaxis()->SetTitleSize(0.06);
1872 projEnergyMaskSM[iSM]->SetLineColor(kGreen+1);
1873 projEnergyMaskSM[iSM]->DrawCopy(
" hist");
1876 projEnergySM[iSM]->DrawCopy(
"same hist");
1877 if(iSM==0)legBig->Draw(
"same");
1882 c1_projSM->Update();
1884 TCanvas *c1_projRSM =
new TCanvas(
"CellPropPProjRSM",
"III summary of cell Energy Ratio per SM",1200,900);
1885 c1_projRSM->Divide(5,4,0.001,0.001);
1886 for(
Int_t iSM=0;iSM<20;iSM++)
1888 c1_projRSM->cd(iSM+1)->SetLogy();
1889 gPad->SetTopMargin(0.03);
1890 gPad->SetBottomMargin(0.11);
1892 projEnergyMaskSM[iSM]->SetLineColor(kGray+1);
1893 projEnergyMaskSM[iSM]->Divide(hRefDistr);
1894 projEnergyMaskSM[iSM]->DrawCopy(
"hist");
1896 c1_projRSM->Update();
1898 TCanvas *c1_projTimeSM =
new TCanvas(
"CellPropPProjTimeSM",
"III summary of cell Time per SM",1200,900);
1899 c1_projTimeSM->Divide(5,4,0.001,0.001);
1900 TH1* projTimeMaskSM[20];
1901 TH1* projTimeSM[20];
1902 for(
Int_t iSM=0;iSM<20;iSM++)
1904 c1_projTimeSM->cd(iSM+1)->SetLogy();
1905 gPad->SetTopMargin(0.03);
1906 gPad->SetBottomMargin(0.11);
1907 projTimeMaskSM[iSM] = cellTime_masked->ProjectionX(Form(
"%sMask_ProjSMTime%i",cellAmp_masked->GetName(),iSM),
fStartCellSM[iSM]+1,
fStartCellSM[iSM+1]);
1908 projTimeMaskSM[iSM]->SetTitle(
"");
1909 projTimeMaskSM[iSM]->SetXTitle(Form(
"Cell Time [ns], SM%i",iSM));
1910 projTimeMaskSM[iSM]->GetYaxis()->SetTitleOffset(1.6);
1911 projTimeMaskSM[iSM]->GetYaxis()->SetLabelSize(0.06);
1912 projTimeMaskSM[iSM]->GetXaxis()->SetLabelSize(0.06);
1914 projTimeMaskSM[iSM]->GetXaxis()->SetTitleSize(0.06);
1915 projTimeMaskSM[iSM]->SetLineColor(kGreen+1);
1916 projTimeMaskSM[iSM]->DrawCopy(
" hist");
1918 if(iSM==0)legBig->Draw(
"same");
1920 projTimeSM[iSM]->DrawCopy(
"same hist");
1939 cellAmp_masked ->Scale(1.0/totalevents);
1945 ofstream
file(cellSummaryFile, ios::out | ios::trunc);
1946 ofstream fileBad(OADBFile_bad, ios::out | ios::trunc);
1947 ofstream fileDead(OADBFile_dead, ios::out | ios::trunc);
1948 ofstream fileWarm(OADBFile_warm, ios::out | ios::trunc);
1951 file<<
"Dead cells : "<<endl;
1952 cout<<
" o Dead cells : "<<endl;
1957 file<<
"In EMCal: "<<endl;
1962 file<<
"In DCal: "<<endl;
1964 if(
fFlag[cellID]==1)
1968 else nDeadDCalCells++;
1970 if(
fFlag[cellID]==1)fileDead<<cellID<<endl;
1971 if(
fFlag[cellID]>1)fileBad<<cellID<<endl;
1976 file<<
"EMCal ("<<nDeadEMCalCells<<
" ="<<perDeadEMCal<<
"%), DCal ("<<nDeadDCalCells<<
" ="<<perDeadDCal<<
"%)"<<endl;
1977 cout<<
" o EMCal ("<<nDeadEMCalCells<<
" ="<<perDeadEMCal<<
"%), DCal ("<<nDeadDCalCells<<
" ="<<perDeadDCal<<
"%)"<<endl;
1979 file<<
"Bad cells: "<<endl;
1980 cout<<
" o Bad cells: "<<endl;
1985 file<<
"In EMCal: "<<endl;
1990 file<<
"In DCal: "<<endl;
2002 file<<
"EMCal ("<<nEMCalCells<<
" ="<<perBadEMCal<<
"%), DCal ("<<nDCalCells<<
" ="<<perBadDCal<<
"%)"<<endl;
2003 cout<<
" o EMCal ("<<nEMCalCells<<
" ="<<perBadEMCal<<
"%), DCal ("<<nDCalCells<<
" ="<<perBadDCal<<
"%)"<<endl;
2006 cout<<
" o Total: "<<endl;
2007 cout<<
" o Bad+Dead cells: "<<nDeadEMCalCells+nEMCalCells+nDeadDCalCells+nDCalCells<<
", this is "<<(nDeadEMCalCells+nEMCalCells+nDeadDCalCells+nDCalCells)*100/(1.0*fNoOfCells)<<
"% of the whole detector"<<endl;
2012 if(
fPrint==1)cout<<
" o Save the bad channel spectra to a .pdf file"<<endl;
2025 if(
fWarmCell[cell]==1)fileWarm<<cell<<endl;
2027 TCanvas *c2 =
new TCanvas(
"CellFlag",
"summary of cell flags",1200,800);
2028 c2->ToggleEventStatus();
2033 fhCellFlag->SetYTitle(
"flag by which cell was excluded");
2053 TString name1,name2,name3,name4,name5,name6;
2055 c1_ratio->SaveAs(name1);
2059 c1_proj->SaveAs(name3);
2061 c1_projSM->SaveAs(name4);
2063 c1_projRSM->SaveAs(name5);
2065 c1_projTimeSM->SaveAs(name6);
2067 fRootFile->WriteObject(c1_ratio,c1_ratio->GetName());
2068 fRootFile->WriteObject(c1,c1->GetName());
2069 fRootFile->WriteObject(c1_proj,c1_proj->GetName());
2070 fRootFile->WriteObject(c1_projSM,c1_projSM->GetName());
2071 fRootFile->WriteObject(c1_projRSM,c1_projRSM->GetName());
2072 fRootFile->WriteObject(c1_projTimeSM,c1_projTimeSM->GetName());
2074 fRootFile->WriteObject(c2,c2->GetName());
2076 fRootFile->WriteObject(cellAmp_masked,cellAmp_masked->GetName());
2077 fRootFile->WriteObject(ratio2DAmp,ratio2DAmp->GetName());
2082 fRootFile->WriteObject(projEnergyMask,projEnergyMask->GetName());
2083 fRootFile->WriteObject(projEnergy,projEnergy->GetName());
2090 Int_t nWEMCalCells =0;
2091 Int_t nWDCalCells =0;
2092 file.open(cellSummaryFile, ios::out | ios::app);
2095 file<<
"Warm cells : "<<endl;
2096 if(
fPrint==1)cout<<
" o Warm cells : "<<endl;
2101 file<<
"In EMCal: "<<endl;
2106 file<<
"In DCal: "<<endl;
2118 file<<
"EMCal ("<<nWEMCalCells<<
" ="<<perWarmEMCal<<
"%), DCal ("<<nWDCalCells<<
" ="<<perWarmDCal<<
"%)"<<endl;
2119 if(
fPrint==1)cout<<
" o EMCal ("<<nWEMCalCells<<
" ="<<perWarmEMCal<<
"%), DCal ("<<nWDCalCells<<
" ="<<perWarmDCal<<
"%)"<<endl;
2125 ofstream file2(aliceTwikiTable, ios::out | ios::app);
2128 file2<<
"1=energy/hit, 2= hit/event"<<endl;
2130 file2<<
"| *Detector* | *No of cells* | *percentage* |"<<endl;
2131 file2<<
"| Dead EMCal | "<<nDeadEMCalCells<<
" | "<<perDeadEMCal<<
"% |"<<endl;
2132 file2<<
"| Bad EMCal | "<<nEMCalCells<<
" | "<<perBadEMCal<<
"% |"<<endl;
2133 file2<<
"| - Warm EMCal | "<<nWEMCalCells<<
" | "<<perWarmEMCal<<
"% |"<<endl;
2134 file2<<
"| Dead DCal | "<<nDeadDCalCells<<
" | "<<perDeadDCal<<
"% |"<<endl;
2135 file2<<
"| Bad DCal | "<<nDCalCells<<
" | "<<perBadDCal<<
"% |"<<endl;
2136 file2<<
"| - Warm DCal | "<<nWDCalCells<<
" | "<<perWarmDCal<<
"% |"<<endl;
2137 file2<<
"| Summ D+B | "<<nDeadEMCalCells+nEMCalCells+nDeadDCalCells+nDCalCells<<
" | "<<(nDeadEMCalCells+nEMCalCells+nDeadDCalCells+nDCalCells)*100/(1.0*fNoOfCells)<<
"% |"<<endl;
2174 gROOT->SetStyle(
"Plain");
2175 gStyle->SetOptStat(0);
2176 gStyle->SetFillColor(kWhite);
2177 gStyle->SetTitleFillColor(kWhite);
2178 gStyle->SetPalette(1);
2184 fRootFile->WriteObject(hRefDistr,hRefDistr->GetName());
2185 Int_t firstCanvas=0;
2187 TLatex*
text =
new TLatex(0.2,0.8,
"*Candidate*");
2188 text->SetTextSize(0.07);
2189 text->SetTextColor(kOrange-3);
2192 TLatex* text2 =
new TLatex(0.2,0.8,
"*Not a Candidate*");
2193 text2->SetTextSize(0.08);
2194 text2->SetTextColor(8);
2197 TLatex* textA =
new TLatex(0.65,0.62,
"*test*");
2198 textA->SetTextSize(0.04);
2199 textA->SetTextColor(1);
2205 std::vector<Int_t> channelVector;
2206 channelVector.clear();
2207 cout<<
" o Start printing into .pdf for version: "<<version<<endl;
2210 if(
fFlag[cell]==1 && version==0)channelVector.push_back(cell);
2211 if(
fFlag[cell]>1 && version==1)channelVector.push_back(cell);
2212 if(
fFlag[cell]==0 && version==2)channelVector.push_back(cell);
2213 if(
fFlag[cell]>1 && version==10)channelVector.push_back(cell);
2214 if(
fFlag[cell]==0 && version==20)channelVector.push_back(cell);
2216 if(cell%2000==0)cout<<
"...cell No."<<cell<<endl;
2218 if(channelVector.size()==9 || cell == fNoOfCells-1)
2223 TCanvas *c1 =
new TCanvas(
"badcells",
"badcells",1000,750);
2224 if(channelVector.size() > 6) c1->Divide(3,3);
2225 else if (channelVector.size() > 3) c1->Divide(3,2);
2226 else c1->Divide(3,1);
2228 TLegend *leg =
new TLegend(0.7, 0.7, 0.9, 0.9);
2229 for(
Int_t i=0; i< (
Int_t)channelVector.size() ; i++)
2231 if(channelVector.size() >=
fNoOfCells) cout<<
"Massive problem"<<endl;
2232 sprintf(name,
"Cell %d",channelVector.at(i)) ;
2233 TH1 *hCell =
fCellAmplitude->ProjectionX(name,channelVector.at(i)+1,channelVector.at(i)+1);
2234 sprintf(title,
"Cell No: %d Entries: %d",channelVector.at(i), (
Int_t)hCell->GetEntries()) ;
2237 c1->cd(i%9 + 1)->SetLogy();
2240 leg->AddEntry(hRefDistr,
"mean of good",
"l");
2241 leg->AddEntry(hCell,
"current",
"l");
2245 if(candidate==1)
fWarmCell[channelVector.at(i)]=candidate;
2248 hCell->Divide(hRefDistr);
2258 hCell->SetLineColor(kBlue+1);
2259 hCell->GetXaxis()->SetTitle(
"E (GeV)");
2260 hCell->GetYaxis()->SetTitle(
"N Entries");
2261 hCell->GetXaxis()->SetRangeUser(0.,10.);
2262 hCell->SetLineWidth(1) ;
2263 hCell->SetTitle(title);
2264 hRefDistr->SetLineColor(kGray+2);
2265 hRefDistr->SetLineWidth(1);
2267 hCell->Draw(
"hist");
2269 if(version==1 || version==2)hRefDistr->Draw(
"same hist") ;
2272 if(candidate==1 && (version==1 || version==10))
2274 gPad->SetFrameFillColor(kYellow-10);
2279 textA->SetTitle(Form(
"Excluded by No. %d",
fFlag[channelVector.at(i)]));
2280 textA->DrawLatex(0.65,0.62,Form(
"Excluded by No. %d",
fFlag[channelVector.at(i)]));
2282 if(candidate==0 && (version==2 || version==20))
2284 gPad->SetFrameFillColor(kYellow-10);
2288 if(version<2)leg->Draw();
2291 if(channelVector.size()<9 || cell == fNoOfCells-1)
2293 internal_pdfName +=
")";
2294 c1->Print(internal_pdfName.Data());
2296 else if(firstCanvas==0)
2298 internal_pdfName +=
"(";
2299 c1->Print(internal_pdfName.Data());
2304 c1->Print(internal_pdfName.Data());
2308 channelVector.clear();
2337 if(warmIn==0 &&
fFlag[cell]!=0 )
continue;
2339 if(warmIn==2 &&
fWarmCell[cell]==0)
continue;
2343 hgoodMean->Add(hGoodAmp);
2345 hgoodMean->Scale(1.0/NrGood);
2362 TString Name = Form(
"%s_ratio",histogram->GetName());
2363 TH1* ratio=(
TH1*)histogram->Clone(Name);
2364 ratio->Divide(reference);
2377 Int_t binHeightOne = reference->FindLastBinAbove(1.0/totalevents);
2378 Double_t binCentreHeightOne = reference->GetBinCenter(binHeightOne);
2379 Double_t thirdBinCentre = reference->GetBinCenter(3);
2388 if(ratio->FindLastBinAbove(0)<ratio->FindBin(binCentreHeightOne*percentageOfLast))
2397 ratio->GetXaxis()->SetRangeUser(thirdBinCentre,10);
2398 if(ratio->GetMaximum()>highestRatio)
2408 Int_t nullEntries=0;
2409 for(
Int_t i=2;i<binHeightOne;i++)
2411 if(ratio->GetBinContent(i)!=0)mean+=ratio->GetBinContent(i);
2414 mean*=1.0/(binHeightOne-1-nullEntries);
2415 if(mean>maxMean || mean<minMean)
2427 ratio->GetXaxis()->SetRangeUser(0,binCentreHeightOne);
2428 Double_t localMaxBin=ratio->GetMaximumBin();
2430 for(
Int_t i=2;i<binHeightOne;i++)
2433 if(ratio->GetBinContent(i)<=0)
continue;
2434 if(i>localMaxBin-3 && i<localMaxBin+3)
continue;
2435 mean+=ratio->GetBinContent(i);
2437 mean*=1.0/(binHeightOne-1);
2438 ratio->GetXaxis()->SetRangeUser(thirdBinCentre,binCentreHeightOne);
2440 if(ratio->GetMaximum()>mean*higherThanMean)
2452 Int_t cliffBin = ratio->FindBin(4);
2453 for(
Int_t i=cliffBin-10;i<cliffBin+11;i++)
2456 if(ratio->GetBinContent(i)<=0)
continue;
2457 if(i<=cliffBin) binsBefore++;
2458 if(i>cliffBin) binsAfter++;
2459 if(i<=cliffBin) beforeCliff+=ratio->GetBinContent(i);
2460 if(i>cliffBin) afterCliff+=ratio->GetBinContent(i);
2461 beforeCliff*=1.0/binsBefore;
2462 afterCliff*=1.0/binsAfter;
2464 if((beforeCliff-afterCliff)>cliffSize*afterCliff)
2466 if(beforeCliff!=0 && afterCliff!=0)candidate=0;
2467 if(beforeCliff!=0 && afterCliff!=0)cout<<
"5"<<endl;
2498 Bool_t coveredByTRDSupportStruc=0;
2500 if((collumn>3 && collumn<9) || (collumn>32 && collumn<37) || (collumn>57 && collumn<61) || (collumn>84 && collumn<90) ||
2501 (row==1) ||(row>20 && row<25) || (row>44 && row<49) || (row>68 && row<73) || (row>91 && row<96) ||
2502 (row>116 && row<120)|| row==127 || (row>148 && row<152) || (row>172 && row<177) || (row>197 && row<201)
2505 coveredByTRDSupportStruc=1;
2507 return coveredByTRDSupportStruc;
2522 histoName = Form(
"2DChannelMap_Flag%d_V%i",flagBegin,
fTrial);
2523 if(flagBegin==0 && flagEnd==0)histoName = Form(
"2DChannelMap_Flag100_V%i",
fTrial);
2526 plot2D->GetXaxis()->SetTitle(
"cell column (#eta direction)");
2527 plot2D->GetYaxis()->SetTitle(
"cell row (#phi direction)");
2529 Int_t cellColumn=0,cellRow=0;
2530 Int_t cellColumnAbs=0,cellRowAbs=0;
2542 cout<<
"Problem! wrong calculated number of max col and max rows"<<endl;
2543 cout<<
"current col: "<<cellColumnAbs<<
", max col"<<
fNMaxColsAbs<<endl;
2544 cout<<
"current row: "<<cellRowAbs<<
", max row"<<
fNMaxRowsAbs<<endl;
2546 if(flagEnd==-1 &&
fFlag[cell]==flagBegin) plot2D->SetBinContent(cellColumnAbs,cellRowAbs,1);
2547 if(flagEnd!=0 && flagEnd!=-1 &&
fFlag[cell]>=flagBegin &&
fFlag[cell]<=flagEnd)plot2D->SetBinContent(cellColumnAbs,cellRowAbs,1);
2548 if(flagBegin==0 && flagEnd==0 &&
fWarmCell[cell]==1) plot2D->SetBinContent(cellColumnAbs,cellRowAbs,1);
2552 TCanvas *c1 =
new TCanvas(histoName,histoName,500,500);
2553 c1->ToggleEventStatus();
2557 plot2D->Draw(
"colz");
2560 if(flagBegin==0 && flagEnd==-1) text =
new TLatex(0.2,0.8,
"Good Cells");
2561 if(flagBegin==1) text =
new TLatex(0.2,0.8,
"Dead Cells");
2562 if(flagBegin>1) text =
new TLatex(0.2,0.8,
"Bad Cells");
2563 if(flagBegin==0 && flagEnd==0) text =
new TLatex(0.2,0.8,
"Warm Cells");
2564 text->SetTextSize(0.06);
2566 text->SetTextColor(1);
2573 fRootFile->WriteObject(plot2D,plot2D->GetName());
2590 sprintf(name,
"Cell %d",cell) ;
2609 cout<<
"******* Debug No "<<number<<
" ********"<<endl;
2611 cout<<
"*** number of period analyses: "<<
fAnalysisVector.size()<<endl;
2612 cout<<
"*** number of man mask cells: "<<
fManualMask.size()<<endl;
2613 cout<<
"*** Bad+Dead(!0) fFlag elements: "<<
fFlag.size()-zeroFlag<<endl;
2614 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