27 #include <TGeoManager.h> 28 #include <TRefArray.h> 32 #include "AliAnalysisTask.h" 33 #include "AliAnalysisManager.h" 34 #include "AliESDEvent.h" 35 #include "AliAODEvent.h" 36 #include "AliVEvent.h" 37 #include "AliESDInputHandler.h" 38 #include "AliAODInputHandler.h" 41 #include "AliCDBManager.h" 42 #include "AliRunTag.h" 45 #include "AliVCluster.h" 46 #include "AliESDCaloCluster.h" 47 #include "AliVCaloCells.h" 48 #include "AliESDCaloCells.h" 49 #include "AliAODCaloCluster.h" 50 #include "AliAODCaloCells.h" 51 #include "AliEMCALGeometry.h" 52 #include "AliOADBContainer.h" 53 #include "AliDataFile.h" 86 fReferenceFileName(0),
87 fReferenceRunByRunFileName(0),
88 fPileupFromSPD(kFALSE),
91 fMostEneCellOnly(kFALSE),
109 fFillHeavyHisto(kFALSE),
110 fBadChannelMapArray(0),
111 fBadChannelMapSet(kFALSE),
112 fSetBadChannelMapSource(0),
113 fBadChannelFileName(0),
118 fhTOFT0vsEventNumber(0),
140 fhRawTimeEntriesBC(),
144 fhRawTimeEntriesLGBC(),
145 fhRawTimeSumSqLGBC(),
148 fhRawCorrTimeVsIdBC(),
149 fhRawCorrTimeVsIdLGBC(),
189 DefineInput(0, TChain::Class());
193 DefineOutput(1, TList::Class());
216 AliFatal(
"*** NO REFERENCE FILE");
218 AliDebug(1,
"*** OK TFILE");
223 if(
fhAllAverageBC[i]==0x0) AliFatal(Form(
"Reference histogram for BC%d does not exist",i));
224 if(
fhAllAverageBC[i]->GetEntries()==0)AliWarning(Form(
"fhAllAverageLGBC[%d]->GetEntries() = 0",i));
226 if(
fhAllAverageLGBC[i]==0x0) AliFatal(Form(
"Reference LG histogram for BC%d does not exist",i));
227 if(
fhAllAverageLGBC[i]->GetEntries()==0)AliFatal(Form(
"fhAllAverageLGBC[%d]->GetEntries() = 0",i));
237 AliFatal(
"You require to load reference histos from file but FILENAME is not provided");
249 if(referenceFile==0x0) {
250 AliFatal(
"*** NO REFERENCE R-B-R FILE");
257 TIter next(referenceFile->GetListOfKeys());
259 while ((key=(TKey*)next())) {
260 fL1PhaseList->AddLast((TH1F*)referenceFile->Get(key->GetName()) );
265 AliFatal(
"You require to load reference run-by-run histos from file but FILENAME is not provided");
277 AliFatal(
"Array with reference L1 phase histograms do not exist in memory");
281 AliFatal(
"Negative run number");
287 AliError(Form(
"Reference histogram for run %d does not exist. Use Default",
fRunNumber));
296 if(
fhRefRuns->GetEntries()==0)AliWarning(
"fhRefRuns->GetEntries() = 0");
297 AliDebug(1,Form(
"hRefRuns entries %d", (
Int_t)
fhRefRuns->GetEntries() ));
305 AliFatal(
"fCurrentPARs not properly set! Unable to get PAR information.");
318 if(refName.CompareTo(correctName)==0)
return;
323 AliFatal(
"Array with reference L1 phase histograms do not exist in memory");
327 AliFatal(
"Negative run number");
340 if(
fhRefRuns->GetEntries()==0)AliWarning(
"fhRefRuns->GetEntries() = 0");
341 AliDebug(1,Form(
"hRefRuns entries %d", (
Int_t)
fhRefRuns->GetEntries() ));
350 AliDebug(1,
"AnalysisTaskEMCalTimeCalib::NotifyRun()");
351 AliDebug(2,Form(
"Notify(): EMCal geometry: fgeom = %p, fGeometryName=%s\n ",
fgeom,
fGeometryName.Data()));
355 AliFatal(
"ERROR: InputEvent not set");
358 else AliDebug(1,
"Good, InputEvent set");
389 AliDebug(1,
"AliAnalysisTaskEMCALTimeCalib::SetEMCalGeometry()");
392 AliInfo(Form(
"Get EMCAL geometry name <%s> for run %d",
fgeom->GetName(),
fRunNumber));
395 AliInfo(Form(
"Set EMCAL geometry name to <%s>",
fGeometryName.Data()));
399 AliWarning(
"Make sure the EMCal geometry is set properly !");
401 AliDebug(1,Form(
"EMCal geometry properly set: fGeom = %p, fGeometryName=%s",
fgeom,
fGeometryName.Data()));
412 AliInfo(Form(
"<D> -- Run # = %d",
fRunNumber));
413 AliInfo(
"prepare TOFT0maker!!");
417 AliCDBManager * cdb = AliCDBManager::Instance();
418 cdb->SetDefaultStorage(
"raw://");
443 AliDebug(1,
"AliAnalysisTaskEMCALTimeCalib::UserCreateOutputObjects()");
445 const Int_t nChannels = 17664;
461 fhEventType =
new TH1F(
"fhEventType",
"event type",10, 0.,10.);
463 fhEventType->GetXaxis()->SetBinLabel(1 ,
"1=No ESD");
464 fhEventType->GetXaxis()->SetBinLabel(2 ,
"2=Pileup");
465 fhEventType->GetXaxis()->SetBinLabel(3 ,
"3=No Trigger");
466 fhEventType->GetXaxis()->SetBinLabel(4 ,
"4=Evt Type != 7");
467 fhEventType->GetXaxis()->SetBinLabel(5 ,
"5=INT7,8");
468 fhEventType->GetXaxis()->SetBinLabel(6 ,
"6=EMC7,8");
469 fhEventType->GetXaxis()->SetBinLabel(7 ,
"7=L1 EMCal");
470 fhEventType->GetXaxis()->SetBinLabel(8 ,
"8=DMC7,8");
471 fhEventType->GetXaxis()->SetBinLabel(9 ,
"9=L1 DCal");
474 fhEventType ->GetYaxis()->SetTitle(
"Counts (a.u.)");
482 fhEneVsAbsIdHG =
new TH2F(
"fhEneVsAbsIdHG",
"energy vs ID for HG",1000,0,18000,200,0,10);
483 fhEneVsAbsIdLG =
new TH2F(
"fhEneVsAbsIdLG",
"energy vs ID for LG",1000,0,18000,200,0,40);
488 if(!mgr) AliFatal(
"No Analysis Manager available...\n");
489 Int_t runNum = mgr->GetRunFromPath();
493 AliFatal(
"Run Number not correctly set in UserCreateOutputObjects()!");
500 TH2F* fRawTimeSinglePAR;
501 TH2F* fRawTimeLGSinglePAR;
502 std::vector<TH2F*> vecRawTimePAR;
503 std::vector<TH2F*> vecRawTimeLGPAR;
505 fRawTimeSinglePAR =
new TH2F(Form(
"RawTimeBeforePAR%dBC%d",iPAR+1, iBC),
506 Form(
"cell raw time vs ID for high gain BC %d ", iBC),
508 fRawTimeLGSinglePAR =
new TH2F(Form(
"RawTimeLGBeforePAR%dBC%d",iPAR+1, iBC),
509 Form(
"cell raw time vs ID for low gain BC %d ", iBC),
511 vecRawTimePAR.push_back(fRawTimeSinglePAR);
512 vecRawTimeLGPAR.push_back(fRawTimeLGSinglePAR);
524 Form(
"cell Sum Square time HG, BC %d ", i),
529 fhTimeSum[i] =
new TH1F(Form(
"hTimeSum%d", i),
530 Form(
"cell Sum time HG, BC %d ", i),
535 fhTimeEnt[i] =
new TH1F(Form(
"hTimeEnt%d", i),
536 Form(
"cell Entries HG, BC %d ", i),
538 fhTimeEnt[i]->SetYTitle(
"Entries for Time ");
543 Form(
"cell Sum Square time LG, BC %d ", i),
549 Form(
"cell Sum time LG, BC %d ", i),
555 Form(
"cell Entries LG, BC %d ", i),
564 Form(
"cell raw time vs ID for high gain BC %d ", i),
571 Form(
"sum of cell raw time for high gain BC %d ", i),
577 Form(
"No. entries of cells raw time for high gain BC %d ", i),
583 Form(
"sum of (cell raw time)^2 for high gain BC %d ", i),
591 Form(
"cell raw time vs ID for low gain BC %d ", i),
598 Form(
"sum of cell raw time for low gain BC %d ", i),
604 Form(
"No. entries of cells raw time for low gain BC %d ", i),
610 Form(
"sum of (cell raw time)^2 for low gain BC %d ", i),
618 Form(
"cell L1 shift and 100ns corrected raw time vs ID for high gain BC %d ", i),
624 Form(
"cell L1 shift and 100ns corrected raw time vs ID for low gain BC %d ", i),
633 Form(
"cell time corrected for L1 shift, 100ns and L1 phase vs ID for high gain BC %d ", i),
639 Form(
"cell time corrected for L1 shift, 100ns and L1 phase vs ID for low gain BC %d ", i),
649 fhTimeDsupBC[j][i]=
new TH2F(Form(
"SupMod%dBC%d",j,i), Form(
"SupMod %d time_vs_E, high gain, BC %d",j,i),
fEnergyNbins,
fEnergyMin,
fEnergyMax,
fPassTimeNbins,
fPassTimeMin,
fPassTimeMax);
654 fhTimeDsupLGBC[j][i]=
new TH2F(Form(
"SupMod%dBC%dLG",j,i), Form(
"SupMod %d time_vs_E, low gain, BC %d",j,i),
fEnergyLGNbins,
fEnergyLGMin,
fEnergyLGMax,
fPassTimeNbins,
fPassTimeMin,
fPassTimeMax);
663 fhTimeDsup[jj] =
new TH2F(Form(
"SupMod%d",jj), Form(
"SupMod %d time_vs_E, high gain",jj),
fEnergyNbins,
fEnergyMin,
fEnergyMax,
fPassTimeNbins,
fPassTimeMin,
fPassTimeMax);
668 fhTimeDsupLG[jj] =
new TH2F(Form(
"SupMod%dLG",jj), Form(
"SupMod %d time_vs_E, low gain ",jj),
fEnergyLGNbins,
fEnergyLGMin,
fEnergyLGMax,
fPassTimeNbins,
fPassTimeMin,
fPassTimeMax);
756 AliDebug(2,Form(
"UserExec: EMCal geometry: fgeom = %p fGeometryName %s",
fgeom,
fGeometryName.Data()));
757 AliVEvent *
event = InputEvent();
760 AliDebug(2,Form(
"TOF time from header %f ps",event->GetTOFHeader()->GetDefaultEventTimeVal()));
765 AliError(
"ESD not available, exit");
771 if(event->IsPileupFromSPD(3,0.8,3.,2.,5.)){
772 AliDebug(1,
"Event: PileUp skip.");
778 TString triggerclasses =
event->GetFiredTriggerClasses();
779 if(triggerclasses==
"") {
784 Int_t eventType = ((AliVHeader*)event->GetHeader())->GetEventType();
786 AliDebug(1,Form(
"Triggerclasses %s, eventType %d",triggerclasses.Data(),eventType));
801 if(triggerclasses.Contains(
"CINT7-B-NOPF-ALLNOTRD") ||
802 triggerclasses.Contains(
"CINT7-I-NOPF-ALLNOTRD") ||
803 triggerclasses.Contains(
"CINT1-I-NOPF-ALLNOTRD") ||
804 triggerclasses.Contains(
"CINT1-B-NOPF-ALLNOTRD") ||
805 triggerclasses.Contains(
"CINT8") ||
806 triggerclasses.Contains(
"CINT7") ||
807 triggerclasses.Contains(
"CPBI2_B1-B-NOPF-ALLNOTRD") ) bMB = kTRUE;
809 if(triggerclasses.Contains(
"CEMC7-B-NOPF-CENTNOTRD") ||
810 triggerclasses.Contains(
"CEMC1-B-NOPF-CENTNOTRD") ||
811 triggerclasses.Contains(
"CEMC7") ||
812 triggerclasses.Contains(
"CEMC8") ||
813 triggerclasses.Contains(
"CEMC8-B-NOPF-CENTNOTRD") ) bL0 = kTRUE;
815 if(triggerclasses.Contains(
"CDMC7-B-NOPF-CENTNOTRD") ||
816 triggerclasses.Contains(
"CDMC1-B-NOPF-CENTNOTRD") ||
817 triggerclasses.Contains(
"CDMC7") ||
818 triggerclasses.Contains(
"CDMC8") ||
819 triggerclasses.Contains(
"CDMC8-B-NOPF-CENTNOTRD") ) bDL0 = kTRUE;
821 if(triggerclasses.Contains(
"CEMC7EG1-B-NOPF-CENTNOTRD") ||
822 triggerclasses.Contains(
"CEMC7EG2-B-NOPF-CENTNOTRD") ||
823 triggerclasses.Contains(
"CEMC8EG1-B-NOPF-CENTNOTRD") ||
824 triggerclasses.Contains(
"CEMC8EGA") ||
825 triggerclasses.Contains(
"CEMC7EGA") ||
826 triggerclasses.Contains(
"CEMC7EG1-B") ||
827 triggerclasses.Contains(
"CEMC7EG2-B") ||
828 triggerclasses.Contains(
"CPBI2EGA") ) bL1G = kTRUE;
830 if(triggerclasses.Contains(
"CDMC7DG1-B-NOPF-CENTNOTRD") ||
831 triggerclasses.Contains(
"CDMC7DG2-B-NOPF-CENTNOTRD") ||
832 triggerclasses.Contains(
"CDMC8DG1-B-NOPF-CENTNOTRD") ||
833 triggerclasses.Contains(
"CDMC8DGA") ||
834 triggerclasses.Contains(
"CDMC7DGA") ||
835 triggerclasses.Contains(
"CDMC7DG1-B") ||
836 triggerclasses.Contains(
"CDMC7DG2-B") ||
837 triggerclasses.Contains(
"CPBI2DGA") ) bDL1G = kTRUE;
839 if(triggerclasses.Contains(
"CEMC7EJ1-B-NOPF-CENTNOTRD") ||
840 triggerclasses.Contains(
"CEMC7EJ2-B-NOPF-CENTNOTRD") ||
841 triggerclasses.Contains(
"CEMC8EJ1-B-NOPF-CENTNOTRD") ||
842 triggerclasses.Contains(
"CEMC7EJE") ||
843 triggerclasses.Contains(
"CEMC8EJE") ||
844 triggerclasses.Contains(
"CEMC7EJ1-B") ||
845 triggerclasses.Contains(
"CEMC7EJ2-B") ||
846 triggerclasses.Contains(
"CPBI2EJE") ) bL1J = kTRUE;
848 if(triggerclasses.Contains(
"CDMC7DJ1-B-NOPF-CENTNOTRD") ||
849 triggerclasses.Contains(
"CDMC7DJ2-B-NOPF-CENTNOTRD") ||
850 triggerclasses.Contains(
"CDMC8DJ1-B-NOPF-CENTNOTRD") ||
851 triggerclasses.Contains(
"CDMC7DJE") ||
852 triggerclasses.Contains(
"CDMC8DJE") ||
853 triggerclasses.Contains(
"CDMC7DJ1-B") ||
854 triggerclasses.Contains(
"CDMC7DJ2-B") ||
855 triggerclasses.Contains(
"CPBI2DJE") ) bDL1J = kTRUE;
889 TRefArray* caloClusters =
new TRefArray();
890 event->GetEMCALClusters(caloClusters);
893 Int_t BunchCrossNumber =
event->GetBunchCrossNumber();
897 Int_t L1phaseshift=0;
899 Int_t L1shiftOffset=0;
902 nBC = BunchCrossNumber%4;
908 Int_t nclus = caloClusters->GetEntries();
909 AliDebug(1,Form(
"###########Bunch Cross nb = %d nclus = %d",nBC,nclus ));
913 AliVCaloCells &cells= *(
event->GetEMCALCells());
915 Int_t nSupMod=-1, nModule=-1;
916 Int_t iphi=-1, ieta=-1, nIphi=-1, nIeta=-1;
926 ULong64_t eventBC = (ULong64_t)event->GetBunchCrossNumber();
927 ULong64_t eventOrbit = ((ULong64_t)(3564))*((ULong64_t)
event->GetOrbitNumber());
928 ULong64_t eventPeriod = ((ULong64_t)(59793994260))*((ULong64_t)(
event->GetPeriodNumber()));
930 ULong64_t globalBC = eventBC + eventOrbit + eventPeriod;
940 for (
Int_t icl = 0; icl < nclus; icl++) {
942 AliVCluster* clus = (AliVCluster*)caloClusters->At(icl);
947 UShort_t * index = clus->GetCellsAbsId() ;
953 for(
Int_t i = 0; i < clus->GetNCells() ; i++) {
955 amp = cells.GetCellAmplitude(absId) ;
963 for(
Int_t i = 0; i < clus->GetNCells() ; i++) {
970 hkdtime = cells.GetCellTime(absId) * 1.0e09;
971 amp = cells.GetCellAmplitude(absId) ;
972 isHighGain = cells.GetCellHighGain(absId);
975 fgeom->GetCellIndex(absId, nSupMod, nModule, nIphi, nIeta);
976 fgeom->GetCellPhiEtaIndexInSModule(nSupMod,nModule,nIphi,nIeta, iphi,ieta);
1022 fhTimeVsBC->Fill(1.*BunchCrossNumber,hkdtime-timeBCoffset);
1024 if(isHighGain==kTRUE){
1028 AliFatal(Form(
"Reference histogram for BC%d not properly loaded",nBC));
1034 AliFatal(Form(
"Reference LG histogram for BC%d not properly loaded",nBC));
1049 L1phase = L1phaseshift & 3;
1051 offsetPerSM = (nBC - L1phase)*25;
1053 offsetPerSM = (nBC - L1phase + 4)*25;
1058 L1shiftOffset = L1phaseshift>>2;
1061 if(nBC==0 || nBC==1) L1shiftOffset-=100.;
1064 AliFatal(
"Reference histogram run-by-run not properly loaded");
1080 fhTimeVsIdBC[nBC]->Fill(absId,hkdtime-L1shiftOffset-offsetPerSM);
1082 fhTimeVsIdLGBC[nBC]->Fill(absId,hkdtime-L1shiftOffset-offsetPerSM);
1089 fhTimeDsup[nSupMod]->Fill(amp,hkdtime-offset-offsetPerSM-L1shiftOffset);
1090 fhTimeDsupBC[nSupMod][nBC]->Fill(amp,hkdtime-offset-offsetPerSM-L1shiftOffset);
1092 fhTimeDsupLG[nSupMod]->Fill(amp,hkdtime-offset-offsetPerSM-L1shiftOffset);
1093 fhTimeDsupLGBC[nSupMod][nBC]->Fill(amp,hkdtime-offset-offsetPerSM-L1shiftOffset);
1104 hkdtime = hkdtime-timeBCoffset;
1106 hkdtimecorr= hkdtime-offset-offsetPerSM-L1shiftOffset;
1121 hkdtime = hkdtime - offsetPerSM - L1shiftOffset;
1141 caloClusters->Delete();
1142 delete caloClusters;
1170 AliDebug(1,
"ERROR: Output list not available");
1180 Int_t nCells = clus->GetNCells();
1185 AliDebug(1,
"very big cluster with enormous energy - cluster rejected");
1193 AliDebug(1,
"lambda0 loose cut failed - cluster rejected");
1200 Double_t Rtrack = TMath::Sqrt(Dx*Dx+Dz*Dz);
1203 AliDebug(1,
"track matched - cluster rejected");
1209 AliDebug(1,
"single cell cluster - cluster rejected");
1215 AliDebug(1,
"cluster energy < 1 GeV- cluster rejected");
1223 AliDebug(1,
"lambda0 strict cut failed - cluster rejected");
1237 UShort_t * index = clus->GetCellsAbsId() ;
1238 AliVCaloCells &cells= *(InputEvent()->GetEMCALCells());
1239 for(
Int_t i = 0; i < clus->GetNCells() ; i++) {
1240 if(cells.GetCellHighGain(index[i])==kFALSE)
return kTRUE;
1251 if(nSupMod < 10 || (nSupMod >= 12 && nSupMod <18) )
1253 if (0<=irow&&irow<8) iRCU=0;
1254 else if (8<=irow&&irow<16 && 0<=icol&&icol<24) iRCU=0;
1257 else if (8<=irow&&irow<16 && 24<=icol&&icol<48) iRCU=1;
1259 else if (16<=irow&&irow<24) iRCU=1;
1261 if (nSupMod%2==1) iRCU = 1 - iRCU;
1271 AliFatal(Form(
"Wrong EMCAL/DCAL RCU number = %d\n", iRCU));
1329 TFile *
file =
new TFile(inputFile.Data());
1347 while((obj = next())){
1349 if(name.BeginsWith(
"RawTimeBeforePAR")) counter++;
1352 numPARs =
Int_t(counter/4) - 1;
1353 printf(
"number of PARs found to be %d!\n", numPARs);
1355 if(numPARs == -1) isPAR = kFALSE;
1361 TH1F *hAllTimeAvBC[4];
1362 TH1F *hAllTimeRMSBC[4];
1368 TH1F *hAllTimeAvLGBC[4];
1369 TH1F *hAllTimeRMSLGBC[4];
1372 TH1F *h1PAR[numPARs+1][4];
1373 TH1F *h2PAR[numPARs+1][4];
1375 TH1F *hAllTimeAvBCPAR[numPARs+1][4];
1378 TH1F *h4PAR[numPARs+1][4];
1379 TH1F *h5PAR[numPARs+1][4];
1381 TH1F *hAllTimeAvLGBCPAR[numPARs+1][4];
1387 if(isFinal==kFALSE){
1388 for(
Int_t i=0;i<4;i++){
1389 h1[i]=(TH1F *)list->FindObject(Form(
"RawTimeSumBC%d",i));
1390 h2[i]=(TH1F *)list->FindObject(Form(
"RawTimeEntriesBC%d",i));
1391 h3[i]=(TH1F *)list->FindObject(Form(
"RawTimeSumSqBC%d",i));
1393 h4[i]=(TH1F *)list->FindObject(Form(
"RawTimeSumLGBC%d",i));
1394 h5[i]=(TH1F *)list->FindObject(Form(
"RawTimeEntriesLGBC%d",i));
1395 h6[i]=(TH1F *)list->FindObject(Form(
"RawTimeSumSqLGBC%d",i));
1398 for(
Int_t iPAR = 0; iPAR <= numPARs; iPAR++){
1399 raw2D[i] = (
TH2D*)list->FindObject(Form(
"RawTimeBeforePAR%dBC%d", iPAR+1, i));
1400 rawLG2D[i] = (
TH2D*)list->FindObject(Form(
"RawTimeLGBeforePAR%dBC%d", iPAR+1, i));
1401 h1PAR[iPAR][i] =
new TH1F(Form(
"hAllTimeSumPAR%dBC%d",iPAR, i), Form(
"hAlltimeSumPAR%dBC%d",iPAR, i), raw2D[i]->GetXaxis()->GetNbins(), raw2D[i]->GetXaxis()->GetXmin(), raw2D[i]->GetXaxis()->GetXmax());
1402 hAllTimeAvBCPAR[iPAR][i] =
new TH1F(Form(
"hAllTimeAvPAR%dBC%d",iPAR, i), Form(
"hAlltimeAvPAR%dBC%d",iPAR, i), raw2D[i]->GetXaxis()->GetNbins(), raw2D[i]->GetXaxis()->GetXmin(), raw2D[i]->GetXaxis()->GetXmax());
1403 h2PAR[iPAR][i] = (TH1F*)raw2D[i]->ProjectionX(Form(
"hAllTimeEntriesPAR%dBC%d",iPAR, i), 0, raw2D[i]->GetYaxis()->GetNbins());
1405 h4PAR[iPAR][i] =
new TH1F(Form(
"hAllTimeSumLGPAR%dBC%d",iPAR, i), Form(
"hAllTimeSumLGPAR%dBC%d",iPAR, i), raw2D[i]->GetXaxis()->GetNbins(), raw2D[i]->GetXaxis()->GetXmin(), raw2D[i]->GetXaxis()->GetXmax());
1406 hAllTimeAvLGBCPAR[iPAR][i] =
new TH1F(Form(
"hAllTimeAvLGPAR%dBC%d",iPAR, i), Form(
"hAlltimeAvLGPAR%dBC%d",iPAR, i), raw2D[i]->GetXaxis()->GetNbins(), raw2D[i]->GetXaxis()->GetXmin(), raw2D[i]->GetXaxis()->GetXmax());
1407 h5PAR[iPAR][i] = (TH1F*)raw2D[i]->ProjectionX(Form(
"hAllTimeEntriesPAR%dLGBC%d",iPAR, i), 0, raw2D[i]->GetYaxis()->GetNbins());
1408 for(
int ixbin = 0; ixbin < raw2D[i]->GetXaxis()->GetNbins(); ixbin++){
1409 float sumtime = 0.0;
1410 float sumLGtime = 0.0;
1411 for(
int iybin = 0; iybin < raw2D[i]->GetYaxis()->GetNbins(); iybin++){
1412 sumtime += raw2D[i]->GetBinContent(ixbin, iybin)*raw2D[i]->GetYaxis()->GetBinCenter(iybin);
1413 sumLGtime += rawLG2D[i]->GetBinContent(ixbin, iybin)*rawLG2D[i]->GetYaxis()->GetBinCenter(iybin);
1415 h1PAR[iPAR][i]->SetBinContent(ixbin, sumtime);
1416 h4PAR[iPAR][i]->SetBinContent(ixbin, sumLGtime);
1417 if(h2PAR[iPAR][i]->GetBinContent(ixbin) ==0){
1418 hAllTimeAvBCPAR[iPAR][i]->SetBinContent(ixbin, 0);
1420 hAllTimeAvBCPAR[iPAR][i]->SetBinContent(ixbin, h1PAR[iPAR][i]->GetBinContent(ixbin)/h2PAR[iPAR][i]->GetBinContent(ixbin));
1423 if(h5PAR[iPAR][i]->GetBinContent(ixbin) ==0){
1424 hAllTimeAvLGBCPAR[iPAR][i]->SetBinContent(ixbin, 0);
1426 hAllTimeAvLGBCPAR[iPAR][i]->SetBinContent(ixbin, h4PAR[iPAR][i]->GetBinContent(ixbin)/h5PAR[iPAR][i]->GetBinContent(ixbin));
1434 for(
Int_t i=0;i<4;i++){
1435 h1[i]=(TH1F *)list->FindObject(Form(
"hTimeSum%d",i));
1436 h2[i]=(TH1F *)list->FindObject(Form(
"hTimeEnt%d",i));
1437 h3[i]=(TH1F *)list->FindObject(Form(
"hTimeSumSq%d",i));
1439 h4[i]=(TH1F *)list->FindObject(Form(
"hTimeLGSum%d",i));
1440 h5[i]=(TH1F *)list->FindObject(Form(
"hTimeLGEnt%d",i));
1441 h6[i]=(TH1F *)list->FindObject(Form(
"hTimeLGSumSq%d",i));
1446 for(
Int_t i=0;i<4;i++){
1447 hAllTimeAvBC[i]=
new TH1F(Form(
"hAllTimeAvBC%d",i),Form(
"hAllTimeAvBC%d",i),h1[i]->GetNbinsX(),h1[i]->GetXaxis()->GetXmin(),h1[i]->GetXaxis()->GetXmax());
1448 hAllTimeRMSBC[i]=
new TH1F(Form(
"hAllTimeRMSBC%d",i),Form(
"hAllTimeRMSBC%d",i),h3[i]->GetNbinsX(),h3[i]->GetXaxis()->GetXmin(),h3[i]->GetXaxis()->GetXmax());
1450 hAllTimeAvLGBC[i]=
new TH1F(Form(
"hAllTimeAvLGBC%d",i),Form(
"hAllTimeAvLGBC%d",i),h4[i]->GetNbinsX(),h4[i]->GetXaxis()->GetXmin(),h4[i]->GetXaxis()->GetXmax());
1451 hAllTimeRMSLGBC[i]=
new TH1F(Form(
"hAllTimeRMSLGBC%d",i),Form(
"hAllTimeRMSLGBC%d",i),h6[i]->GetNbinsX(),h6[i]->GetXaxis()->GetXmin(),h6[i]->GetXaxis()->GetXmax());
1457 for(
Int_t i=0;i<4;i++){
1458 for(
Int_t j=1;j<=h1[i]->GetNbinsX();j++){
1460 if(h2[i]->GetBinContent(j)!=0){
1461 hAllTimeAvBC[i]->SetBinContent(j-1,h1[i]->GetBinContent(j)/h2[i]->GetBinContent(j));
1462 hAllTimeRMSBC[i]->SetBinContent(j-1,TMath::Sqrt(h3[i]->GetBinContent(j)/h2[i]->GetBinContent(j)) );
1464 hAllTimeAvBC[i]->SetBinContent(j-1,0.);
1465 hAllTimeRMSBC[i]->SetBinContent(j-1,0.);
1468 if(h5[i]->GetBinContent(j)!=0){
1469 hAllTimeAvLGBC[i]->SetBinContent(j-1,h4[i]->GetBinContent(j)/h5[i]->GetBinContent(j));
1470 hAllTimeRMSLGBC[i]->SetBinContent(j-1,TMath::Sqrt(h6[i]->GetBinContent(j)/h5[i]->GetBinContent(j)) );
1472 hAllTimeAvLGBC[i]->SetBinContent(j-1,0.);
1473 hAllTimeRMSLGBC[i]->SetBinContent(j-1,0.);
1480 TFile *fileNew=
new TFile(outputFile.Data(),
"recreate");
1481 for(
Int_t i=0;i<4;i++){
1483 for(
Int_t iPAR = 0; iPAR <= numPARs; iPAR++){
1484 hAllTimeAvBCPAR[iPAR][i]->Write();
1486 hAllTimeAvLGBCPAR[iPAR][i]->Write();
1490 hAllTimeAvBC[i]->Write();
1491 hAllTimeRMSBC[i]->Write();
1492 hAllTimeAvLGBC[i]->Write();
1493 hAllTimeRMSLGBC[i]->Write();
1502 for(
Int_t i=0;i<4;i++){
1503 delete hAllTimeAvBC[i];
1504 delete hAllTimeRMSBC[i];
1505 delete hAllTimeAvLGBC[i];
1506 delete hAllTimeRMSLGBC[i];
1509 for(
Int_t iPAR = 0; iPAR <= numPARs; iPAR++){
1510 delete h1PAR[iPAR][i];
1511 delete hAllTimeAvBCPAR[iPAR][i];
1512 delete h2PAR[iPAR][i];
1513 delete h4PAR[iPAR][i];
1514 delete hAllTimeAvLGBCPAR[iPAR][i];
1515 delete h5PAR[iPAR][i];
1580 if(PARFilename.Length() != 0){
1581 std::ifstream input;
1582 int inputrunnumber = 0, numPARs = 0;
1584 input.open(PARFilename.Data());
1586 printf(
"PAR info file not accessable: %s\n", PARFilename.Data());
1589 while(input.good()){
1590 input >> inputrunnumber >> numPARs;
1591 if(!input.good())
break;
1595 if(numPARs <= 0 || numPARs > 10){
1596 printf(
"Number of PARS incorrectly found to be %d!\n", numPARs);
1599 for(
int iPAR = 0; iPAR < numPARs; iPAR++){
1614 printf(
"info.runNumber = %d\n", info.
runNumber);
1615 printf(
"info.numPARs = %d\n", info.
numPARs);
1616 for(
int i = 0; i < info.
numPARs; i++){
1617 printf(
"info.PARGlobalBCs[%d] = %llu\n", i, info.
PARGlobalBCs[i]);
1622 TFile *
file =
new TFile(inputFile.Data());
1623 if(file==0x0)
return;
1627 TH1F *ccBCPAR[info.
numPARs+1][4];
1634 ccBCPAR[iPAR][i] = (TH1F*)file->Get(Form(
"hAllTimeAvPAR%dBC%d", iPAR, i));
1635 shouldBeEmptyPAR[iPAR][i]=kFALSE;
1637 for(
Int_t j=0;j<upperLimit[19];j++){
1638 if(ccBCPAR[iPAR][i]->GetBinContent(j)>0.) emptyCounter++;
1640 if(emptyCounter<1500) shouldBeEmptyPAR[iPAR][i]=kTRUE;
1641 printf(
"Non-zero channels %d BC %d should be empty: %d \n",emptyCounter,i,shouldBeEmptyPAR[iPAR][i]);
1645 ccBC[i]=(TH1F*) file->Get(Form(
"hAllTimeAvBC%d",i));
1646 shouldBeEmpty[i]=kFALSE;
1648 for(
Int_t j=0;j<upperLimit[19];j++){
1649 if(ccBC[i]->GetBinContent(j)>0.) emptyCounter++;
1651 if(emptyCounter<1500) shouldBeEmpty[i]=kTRUE;
1652 printf(
"Non-zero channels %d BC %d should be empty: %d \n",emptyCounter,i,shouldBeEmpty[i]);
1656 TH1C *hRun=
new TH1C(Form(
"h%d",runNumber),Form(
"h%d",runNumber),19,0,19);
1657 TH1C *hPARRun[info.
numPARs+1];
1660 Int_t minimumIndex=-1;
1664 TF1 *f1=
new TF1(
"f1",
"pol0",0,17664);
1673 hPARRun[iPAR] =
new TH1C(Form(
"h%d_%llu", runNumber, info.
PARGlobalBCs[iPAR]), Form(
"h%d_%llu", runNumber, info.
PARGlobalBCs[iPAR]),19,0,19);
1675 hPARRun[iPAR] =
new TH1C(Form(
"h%dp%d", runNumber,iPAR), Form(
"h%d", runNumber),19,0,19);
1677 for(
Int_t i=0;i<20;i++){
1681 if(shouldBeEmptyPAR[iPAR][j]){
1686 if(shouldBeEmpty[j]) {
1692 fitResult=ccBCPAR[iPAR][j]->Fit(
"f1",
"CQN",
"", lowerLimit[i],upperLimit[i]);
1694 fitResult=ccBC[j]->Fit(
"f1",
"CQN",
"",lowerLimit[i],upperLimit[i]);
1700 printf(
"Fit failed for SM %d BC%d, integral %f\n",i,j,ccBCPAR[iPAR][j]->Integral(lowerLimit[i],upperLimit[i]));
1702 printf(
"Fit failed for SM %d BC%d, integral %f\n",i,j,ccBC[j]->Integral(lowerLimit[i],upperLimit[i]));
1706 fitParameter = f1->GetParameter(0);
1708 if(offset100 && (j==0 || j==1)) {
1712 meanBC[j]=fitParameter;
1714 if(fitParameter>0 && fitParameter<minimumValue){
1715 minimumValue = fitParameter;
1720 if( minimumValue/25-(
Int_t)(minimumValue/25)>0.5 ) {
1721 L1shift=(
Int_t)(minimumValue/25.)+1;
1723 L1shift=(
Int_t)(minimumValue/25.);
1726 if(TMath::Abs(minimumValue/25-(
Int_t)(minimumValue/25)-0.5)<0.05)
1727 printf(
"Run %d, SM %d, min %f, next_min %f, next+1_min %f, next+2_min %f, min/25 %f, min%%25 %d, next_min/25 %f, next+1_min/25 %f, next+2_min/25 %f, SMmin %d\n",runNumber,i,minimumValue,meanBC[(minimumIndex+1)%4],meanBC[(minimumIndex+2)%4],meanBC[(minimumIndex+3)%4],minimumValue/25., (
Int_t)((
Int_t)minimumValue%25), meanBC[(minimumIndex+1)%4]/25., meanBC[(minimumIndex+2)%4]/25., meanBC[(minimumIndex+3)%4]/25., L1shift*25);
1729 if(justL1phase) totalValue = minimumIndex;
1730 else totalValue = L1shift<<2 | minimumIndex ;
1734 hPARRun[iPAR]->SetBinContent(i,totalValue);
1736 hRun->SetBinContent(i,totalValue);
1739 for(iorder=minimumIndex;iorder<minimumIndex+4-1;iorder++){
1740 if( meanBC[(iorder+1)%4] <= meanBC[iorder%4] ) orderTest=kFALSE;
1743 printf(
"run %d, SM %d, min index %d meanBC %f %f %f %f, order ok? %d\n",runNumber,i,minimumIndex,meanBC[0],meanBC[1],meanBC[2],meanBC[3],orderTest);
1747 if(shouldBeEmpty[0] || shouldBeEmpty[1] || shouldBeEmpty[2] || shouldBeEmpty[3]){
1748 Double_t newMean = meanBC[minimumIndex]-600;
1751 hPARRun[iPAR]->SetBinContent(i,minimumIndex);
1753 hRun->SetBinContent(i,minimumIndex);
1756 Int_t minIndexTmp=-1;
1757 if(newMean/25. - (
Int_t)(newMean/25.) <0.5)
1758 minIndexTmp = (
Int_t)(newMean/25.);
1760 minIndexTmp = 1+(
Int_t)(newMean/25.);
1763 hPARRun[iPAR]->SetBinContent(i,(4-minIndexTmp+minimumIndex)%4);
1765 hRun->SetBinContent(i,(4-minIndexTmp+minimumIndex)%4);
1770 printf(
"run with missing BC; new L1 phase set to %d\n",(
Int_t)hPARRun[iPAR]->GetBinContent(i));
1772 printf(
"run with missing BC; new L1 phase set to %d\n",(
Int_t)hRun->GetBinContent(i));
1779 TFile *fileNew=
new TFile(outputFile.Data(),
"update");
1782 hPARRun[iPAR]->Write();
1783 delete hPARRun[iPAR];
1800 AliOADBContainer *contBC=
new AliOADBContainer(
"");
1801 contBC->InitFromFile(AliDataFile::GetFileNameOADB(
"EMCAL/EMCALBadChannels.root").data(),
"AliEMCALBadChannels");
1802 printf(
"contBC %p, ent %d\n",contBC,contBC->GetNumberOfEntries());
1805 AliInfo(
"Remove EMCAL bad cells");
1808 TH2I *hbm = (TH2I*)arrayBC->FindObject(Form(
"EMCALBadChannelMap_Mod%d",i));
1810 AliError(Form(
"Can not get EMCALBadChannelMap_Mod%d",i));
1813 hbm->SetDirectory(0);
1817 }
else AliInfo(
"Do NOT remove EMCAL bad channels\n");
1829 if(referenceFile==0x0) {
1830 AliFatal(
"*** NO bad channel map FILE");
1833 TH1F *hbm = (TH1F*)referenceFile->Get(
"h1");
1835 AliError(
"Can not get EMCALBadChannelMap");
1853 std::ifstream input;
1854 int runnumber = 0, numPARs = 0, numRuns=0;
1856 gSystem->ExpandPathName(PARFileName);
1858 if(PARFileName.Contains(
"alien://")){
1860 TFile::Cp(PARFileName.Data(), localFileName.Data());
1861 PARFileName = localFileName;
1863 input.open(PARFileName.Data());
1865 AliFatal(Form(
"PAR info file not accessable: %s", PARFileName.Data()));
1867 while(input.good()){
1868 input >> runnumber >> numPARs;
1869 if(!input.good())
break;
1874 if(numPARs <= 0 || numPARs > 10){
1875 AliFatal(Form(
"Number of PARS incorrectly found to be %d!", numPARs));
1877 for(
int iPAR = 0; iPAR < numPARs; iPAR++){
1884 printf(
"number of runs processed in PAR file: %d\n", numRuns);
1891 if(runnum < 200000) AliFatal(Form(
"Bad Run Number %d passed to GetPARInfo!", runnum));
1895 for(
unsigned int iPARrun = 0; iPARrun <
fPARvec.size(); iPARrun++){
1906 for(
int ipar = 0; ipar <
fPARvec[iPARrun].numPARs; ipar++){
Bool_t SetEMCalGeometry()
Set the EMCal Geometry.
TH1F * fhRawTimeEntriesLGBC[kNBCmask]
! 4 BCmask LG
Double_t fPassTimeMax
upper range of histo with time in passX
TH2F * fhEneVsAbsIdHG
! energy of each cell for high gain cells with strange time
TH1F * fhRawTimeSumLGBC[kNBCmask]
! 4 BCmask LG
virtual void UserCreateOutputObjects()
Bool_t AcceptCluster(AliVCluster *clus)
Selection criteria of good cluster are set here.
TH2F * fhRawTimeVsIdBC[kNBCmask]
! 4 BCmask HG
Int_t fFineNbins
number of bins of histo with T0 time
TH1F * fhRawTimeSumSqBC[kNBCmask]
! 4 BCmask HG
TString fGeometryName
geometry name
TH1F * fhTimeEnt[kNBCmask]
! 4
Double_t fMinLambda0
minimum cluster lambda0
Int_t fCurrentPARIndex
Par Info for current Run Number.
Int_t fEnergyLGNbins
number of bins of histo with energy LG
Int_t GetEMCALChannelStatus(Int_t iSM, Int_t iCol, Int_t iRow) const
TH1F * fhcalcEvtTime
! spectrum calcolot0[0]
Bool_t fBadReco
flag to apply 100ns shift and L1 shift
Double_t fEnergyMin
lower range of histo with energy HG
TString fReferenceRunByRunFileName
name of reference file (run-by-run)
TObjArray * fL1PhaseList
array with phases for set of runs
std::vector< std::vector< TH2F * > > fhRawTimeLGPARs
!
TH2F * fhTimeVsBC
!cell time vs BC
Double_t fMinTime
minimum cluster time after correction
Double_t fFineTmax
upper range of histo with T0 time
void SetDefaultCuts()
Set default cuts for calibration.
Int_t fSetBadChannelMapSource
switch to load BC map 0-no BC,1-OADB,2-file
AliAnalysisTaskEMCALTimeCalib()
void LoadBadChannelMap()
Load Bad Channel Map from different source.
Double_t fRawTimeMin
lower range of histo with raw time
TH2F * fhTcellvsSM
! cell time vs SM
TH2F * fhTimeDsupLG[kNSM]
! 20 SM low gain
TH1F * fhRawTimeSumSqLGBC[kNBCmask]
! 4 BCmask LG
Double_t fMaxRtrack
maximum cluster track distance
void LoadBadChannelMapOADB()
Double_t fMaxLambda0
maximum cluster lambda0
AliEMCALGeometry * fgeom
pointer to EMCal geometry
Double_t fRawTimeMax
upper range of histo with raw time
void SetL1PhaseReferencePAR()
TH2F * fhTcellvsTOFT0HD
! time of cell vs TOF T0 time for higher energy threshold
TH2F * fhRawCorrTimeVsIdBC[kNBCmask]
! 4 BCmask HG
Bool_t fMostEneCellOnly
flag to use calibration on most energetic cell in cluster only
TH2F * fhRawCorrTimeVsIdLGBC[kNBCmask]
! 4 BCmask LG
Bool_t IsLowGainCellInCluster(AliVCluster *clus)
Check if low gain cell is in a cluster.
Double_t fMaxTime
maximum cluster time after correction
std::vector< std::vector< TH2F * > > fhRawTimePARs
!
Double_t fEnergyMax
upper range of histo with energy HG
Double_t fMinClusterEnergy
minimum cluster energy
void LoadReferenceRunByRunHistos()
TH1F * fhTimeLGEnt[kNBCmask]
! 4
TObjArray * fBadChannelMapArray
bad channel map array
static void ProduceCalibConsts(TString inputFile="time186319testWOL0.root", TString outputFile="Reference.root", Bool_t isFinal=kFALSE, Bool_t isPAR=kFALSE)
Double_t fEnergyLGMax
upper range of histo with energy LG
Double_t fFineTmin
lower range of histo with T0 time
TString fReferenceFileName
! name of reference file (for one period)
Int_t fMaxNcells
maximum number of cells in cluster
std::vector< PARInfo > fPARvec
vector of PAR info for all runs
void SetPARInfo(TString PARfilename)
virtual void UserExec(Option_t *option)
Main loop executed for each event.
virtual void PrepareTOFT0maker()
Get T0 time from TOF.
TH1F * fhTimeSumSq[kNBCmask]
! 4
Bool_t fPileupFromSPD
flag to set PileupFromSPD
TH1F * fhTimeLGSumSq[kNBCmask]
! 4
TH1F * fhRawTimeSumBC[kNBCmask]
! 4 BCmask HG
Double_t fMinCellEnergy
minimum cell energy
void LoadBadChannelMapFile()
Int_t fMinNcells
minimum number of cells in cluster
Double_t fEnergyLGMin
lower range of histo with energy LG
Task to work on Time Calibration for EMCal/DCal.
Double_t fMinLambda0LG
minimum cluster lambda0 Low Gain
Double_t fMaxClusterEnergy
maximum cluster energy
Bool_t fBadChannelMapSet
flag whether bad channel map is set
TH1F * fhEvtTimeHeader
! spectrum time from header
TH1F * fhEvtTimeDiff
! spectrum time difference
TH1F * fhAllAverageBC[kNBCmask]
TH2F * fhTcellvsTOFT0
! time of cell vs TOF T0 time
Double_t fPassTimeMin
lower range of histo with time in passX
Double_t fMaxLambda0LG
maximum cluster lambda0 Low Gain
static void ProduceOffsetForSMsV2(Int_t runNumber, TString inputFile="Reference.root", TString outputFile="ReferenceSM.root", Bool_t offset100=kTRUE, Bool_t justL1phase=kTRUE, TString PARfilename="")
TH2F * fhEneVsAbsIdLG
! energy of each cell for low gain cells with strange time
Int_t fPassTimeNbins
number of bins of histo with time in passX
TList * fOutputList
pointer to output list
TH1F * fhRawTimeEntriesBC[kNBCmask]
! 4 BCmask HG
Bool_t fIsPARRun
Which PAR the currnt event is after.
TH2F * fhTimeVsIdBC[kNBCmask]
! 4 BCmask HG
TH1C * fhRefRuns
4 BCmask Low gain
TFile * file
TList with histograms for a given trigger.
TH2F * fhTimeVsIdLGBC[kNBCmask]
! 4 BCmask LG
TH1F * fhEventType
! event type
void SetL1PhaseReferenceForGivenRun()
Bool_t CheckCellRCU(Int_t nSupMod, Int_t icol, Int_t irow)
Check RCU for cell given by Super Module, column index, row index.
TH2F * fhRawTimeVsIdLGBC[kNBCmask]
! 4 BCmask LG
void LoadReferenceHistos()
Load reference Histograms (for one period) from file.
TH1F * fhTimeSum[kNBCmask]
! 4
TString fBadChannelFileName
name of file with bad channels
std::vector< ULong64_t > PARGlobalBCs
virtual void Terminate(Option_t *)
TH1F * fhAllAverageLGBC[kNBCmask]
4 BCmask High gain
Bool_t fFillHeavyHisto
flag to fill heavy histograms
Int_t fEnergyNbins
number of bins of histo with energy HG
Int_t fRunNumber
! run number
Int_t fRawTimeNbins
number of bins of histo with raw time
TH2F * fhTimeDsup[kNSM]
! 20 SM high gain
TH1F * fhTimeLGSum[kNBCmask]
! 4
void GetPARInfoForRunNumber(Int_t runnum)
Does current run have PAR info?
TH2F * fhTimeDsupBC[kNSM][kNBCmask]
! 20 x 4 high gain
TH2F * fhTimeDsupLGBC[kNSM][kNBCmask]
! 20 x 4 low gain