AliPhysics  608b256 (608b256)
AliAnalysisTaskEMCALTimeCalib.cxx
Go to the documentation of this file.
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  * *
4  * Author: The ALICE Off-line Project. *
5  * Contributors are mentioned in the code where appropriate. *
6  * *
7  * Permission to use, copy, modify and distribute this software and its *
8  * documentation strictly for non-commercial purposes hereby granted *
9  * without fee, provided that the above copyright notice appears in all *
10  * copies and that both the copyright notice and this permission notice *
11  * appear in the supporting documentation. The authors make no claims *
12  * about the suitability of this software for any purpose. It is *
13  * provided "as is" without express or implied warranty. *
14  **************************************************************************/
15 
16 #include <TChain.h>
17 #include <TTree.h>
18 #include <TFile.h>
19 #include <TF1.h>
20 #include <TH1F.h>
21 #include <TH1D.h>
22 #include <TH2D.h>
23 #include <TH2F.h>
24 #include <TH1C.h>
25 #include <TList.h>
26 #include <TCanvas.h>
27 #include <TGeoManager.h>
28 #include <TRefArray.h>
29 #include <TKey.h>
30 
31 #include "AliLog.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"
39 //#include "AliESDpid.h"
40 //#include "AliTOFcalib.h"
41 #include "AliCDBManager.h"
42 #include "AliRunTag.h"
43 
44 //#include "AliTOFT0maker.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"
54 
56 
60 
61 //using std::cout;
62 //using std::endl;
63 
64 //________________________________________________________________________
67 : AliAnalysisTaskSE(name),
68  fPARvec(),
69  fCurrentPARs(),
70  fCurrentPARIndex(0),
71  fIsPARRun(0),
72  fRunNumber(-1),
73  fOutputList(0x0),
74  fgeom(0),
75  fGeometryName(0),
76  fMinClusterEnergy(0),
77  fMaxClusterEnergy(0),
78  fMinNcells(0),
79  fMaxNcells(0),
80  fMinLambda0(0),
81  fMaxLambda0(0),
82  fMinLambda0LG(0),
83  fMaxLambda0LG(0),
84  fMaxRtrack(0),
85  fMinCellEnergy(0),
86  fReferenceFileName(0),
87  fReferenceRunByRunFileName(0),
88  fPileupFromSPD(kFALSE),
89  fMinTime(0),
90  fMaxTime(0),
91  fMostEneCellOnly(kFALSE),
92  fRawTimeNbins (0),
93  fRawTimeMin (0),
94  fRawTimeMax (0),
95  fPassTimeNbins(0),
96  fPassTimeMin (0),
97  fPassTimeMax (0),
98  fEnergyNbins (0),
99  fEnergyMin(0),
100  fEnergyMax(0),
101  fEnergyLGNbins (0),
102  fEnergyLGMin(0),
103  fEnergyLGMax(0),
104  fFineNbins(0),
105  fFineTmin(0),
106  fFineTmax(0),
107  fL1PhaseList(0),
108  fBadReco(kFALSE),
109  fFillHeavyHisto(kFALSE),
110  fBadChannelMapArray(0),
111  fBadChannelMapSet(kFALSE),
112  fSetBadChannelMapSource(0),
113  fBadChannelFileName(0),
114  fhcalcEvtTime(0),
115  fhEvtTimeHeader(0),
116  fhEvtTimeDiff(0),
117  fhEventType(0),
118  fhTOFT0vsEventNumber(0),
119  fhTcellvsTOFT0(0),
120  fhTcellvsTOFT0HD(0),
121  fhTcellvsSM(0),
122  fhEneVsAbsIdHG(0),
123  fhEneVsAbsIdLG(0),
124  fhTimeVsBC(0),
125  fhTimeSumSq(),
126  fhTimeEnt(),
127  fhTimeSum(),
128  fhTimeLGSumSq(),
129  fhTimeLGEnt(),
130  fhTimeLGSum(),
131  fhAllAverageBC(),
132  fhAllAverageLGBC(),
133  fhRefRuns(0),
134  fhTimeDsup(),
135  fhTimeDsupBC(),
136  fhTimeDsupLG(),
137  fhTimeDsupLGBC(),
138  fhRawTimeVsIdBC(),
139  fhRawTimeSumBC(),
140  fhRawTimeEntriesBC(),
141  fhRawTimeSumSqBC(),
142  fhRawTimeVsIdLGBC(),
143  fhRawTimeSumLGBC(),
144  fhRawTimeEntriesLGBC(),
145  fhRawTimeSumSqLGBC(),
146  fhRawTimePARs(),
147  fhRawTimeLGPARs(),
148  fhRawCorrTimeVsIdBC(),
149  fhRawCorrTimeVsIdLGBC(),
150  fhTimeVsIdBC(),
151  fhTimeVsIdLGBC()
152 {
153  for(Int_t i = 0; i < kNBCmask; i++)
154  {
155  fhAllAverageBC[i]=0;
156  fhAllAverageLGBC[i]=0;
157 
158  fhTimeSumSq[i]=0;
159  fhTimeEnt[i]=0;
160  fhTimeSum[i]=0;
161 
162  fhTimeLGSumSq[i]=0;
163  fhTimeLGEnt[i]=0;
164  fhTimeLGSum[i]=0;
165 
166  fhRawTimeVsIdBC[i]=0;
167  fhRawTimeSumBC[i]=0;
168  fhRawTimeEntriesBC[i]=0;
169  fhRawTimeSumSqBC[i]=0;
170 
171  fhRawTimeVsIdLGBC[i]=0;
172  fhRawTimeSumLGBC[i]=0;
174  fhRawTimeSumSqLGBC[i]=0;
175  fhRawCorrTimeVsIdBC[i]=0;
177  fhTimeVsIdBC[i]=0;
178  fhTimeVsIdLGBC[i]=0;
179  }
180 
181  //set default cuts for calibration and geometry name
182  SetDefaultCuts();
183 
184  //T0 TOF time
186 
187  // Define input and output slots here
188  // Input slot #0 works with a TChain
189  DefineInput(0, TChain::Class());
190 
191  // Output slot #0 id reserved by the base class for AOD
192  // Output slot #1 writes into a TH1 container
193  DefineOutput(1, TList::Class());
194 
195 } // End ctor
196 
197 //_____________________________________________________________________
203 //void AliAnalysisTaskEMCALTimeCalib::LocalInit()
204 //{
205 // AliDebug(1,"AliAnalysisTaskEMCALTimeCalib::LocalInit()");
206 //}
207 
209 //_____________________________________________________________________
211 {
212  if(fReferenceFileName.Length()!=0){
213  TFile *myFile = TFile::Open(fReferenceFileName.Data());
214  AliInfo(Form("Reference file: %s, pointer %p",fReferenceFileName.Data(),myFile));
215  if(myFile==0x0) {
216  AliFatal("*** NO REFERENCE FILE");
217  } else {
218  AliDebug(1,"*** OK TFILE");
219  // connect ref run here
220  for(Int_t i = 0; i < kNBCmask; i++)
221  {
222  fhAllAverageBC[i]=(TH1F*) myFile->Get(Form("hAllTimeAvBC%d",i));
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));
225  fhAllAverageLGBC[i]=(TH1F*) myFile->Get(Form("hAllTimeAvLGBC%d",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));
228  }
229 
230  AliDebug(1,Form("hAllAverage entries BC0 %d", (Int_t)fhAllAverageBC[0]->GetEntries() ));
231  AliDebug(1,Form("hAllAverage entries BC2 %d",(Int_t)fhAllAverageBC[2]->GetEntries() ));
232  AliDebug(1,Form("hAllAverageLG entries BC0 %d", (Int_t)fhAllAverageLGBC[0]->GetEntries() ));
233  AliDebug(1,Form("hAllAverageLG entries BC2 %d",(Int_t)fhAllAverageLGBC[2]->GetEntries() ));
234 
235  }
236  } else { //end of reference file is provided
237  AliFatal("You require to load reference histos from file but FILENAME is not provided");
238  }
239 } // End of AliAnalysisTaskEMCALTimeCalib::LoadReferenceHistos()
240 
243 //_____________________________________________________________________
245 {
246  // connect ref run here
247  if(fReferenceRunByRunFileName.Length()!=0){
248  TFile *referenceFile = TFile::Open(fReferenceRunByRunFileName.Data());
249  if(referenceFile==0x0) {
250  AliFatal("*** NO REFERENCE R-B-R FILE");
251  return;
252  } else {
253  AliInfo(Form("Reference R-b-R file: %s, pointer %p",fReferenceRunByRunFileName.Data(),referenceFile));
254 
255  //load L1 phases to memory
256  fL1PhaseList=new TObjArray(referenceFile->GetNkeys());
257  TIter next(referenceFile->GetListOfKeys());
258  TKey *key;
259  while ((key=(TKey*)next())) {
260  fL1PhaseList->AddLast((TH1F*)referenceFile->Get(key->GetName()) );
261  //printf("key: %s points to an object of class: %s at %dn",key->GetName(),key->GetClassName(),key->GetSeekKey());
262  }
263  }
264  } else { //reference file is not provided
265  AliFatal("You require to load reference run-by-run histos from file but FILENAME is not provided");
266  return;
267  }
268 } // End of AliAnalysisTaskEMCALTimeCalib::LoadReferenceRunByRunHistos()
269 
274 {
275  fhRefRuns=NULL;
276  if(!fL1PhaseList) {
277  AliFatal("Array with reference L1 phase histograms do not exist in memory");
278  return;
279  }
280  if(fRunNumber<0) {
281  AliFatal("Negative run number");
282  return;
283  }
284 
285  fhRefRuns=(TH1C*)fL1PhaseList->FindObject(Form("h%d",fRunNumber));
286  if(fhRefRuns==0x0){
287  AliError(Form("Reference histogram for run %d does not exist. Use Default",fRunNumber));
288  fhRefRuns=(TH1C*)fL1PhaseList->FindObject("h0");
289  }
290  if(fhRefRuns==0x0) {
291  AliFatal(Form("No default histogram with L1 phases! Add default histogram to file %s!!!",fReferenceRunByRunFileName.Data()));
292  return;
293  }
294 
295  AliDebug(1,Form("Reference R-b-R histo %p, list %p, run number %d",fhRefRuns,fL1PhaseList,fRunNumber));
296  if(fhRefRuns->GetEntries()==0)AliWarning("fhRefRuns->GetEntries() = 0");
297  AliDebug(1,Form("hRefRuns entries %d", (Int_t)fhRefRuns->GetEntries() ));
298 }
299 
300 //_____________________________________________________________________
301 // Function for Setting L1 Phase reference in case of multiple phases for PAR
302 
304  if(fCurrentPARs.runNumber == 0){
305  AliFatal("fCurrentPARs not properly set! Unable to get PAR information.");
306  return;
307  }
308 
309  //if Reference is set, check if it is for correct PAR region
310  if(fhRefRuns!=0x0){
311  TString refName(fhRefRuns->GetName());
312  TString correctName;
314  correctName = Form("h%d_%llu", fRunNumber, fCurrentPARs.PARGlobalBCs[fCurrentPARIndex]);
315  }else{
316  correctName = Form("h%d", fRunNumber);
317  }
318  if(refName.CompareTo(correctName)==0) return;
319  }
320 
321  fhRefRuns=NULL;
322  if(!fL1PhaseList) {
323  AliFatal("Array with reference L1 phase histograms do not exist in memory");
324  return;
325  }
326  if(fRunNumber<0) {
327  AliFatal("Negative run number");
328  return;
329  }
331  fhRefRuns=(TH1C*)fL1PhaseList->FindObject(Form("h%d_%llu", fRunNumber, fCurrentPARs.PARGlobalBCs[fCurrentPARIndex]));
332  }else{
333  fhRefRuns=(TH1C*)fL1PhaseList->FindObject(Form("h%d", fRunNumber));
334  }
335 
336  if(fhRefRuns==0x0){
337  AliFatal(Form("No Reference R-b-R histo found for run %d PAR %d!", fRunNumber, fCurrentPARIndex));
338  return;
339  }
340  if(fhRefRuns->GetEntries()==0)AliWarning("fhRefRuns->GetEntries() = 0");
341  AliDebug(1,Form("hRefRuns entries %d", (Int_t)fhRefRuns->GetEntries() ));
342 
343 }
344 
345 //_____________________________________________________________________
349 {
350  AliDebug(1,"AnalysisTaskEMCalTimeCalib::NotifyRun()");
351  AliDebug(2,Form("Notify(): EMCal geometry: fgeom = %p, fGeometryName=%s\n ",fgeom,fGeometryName.Data()));
352 
353  if (!InputEvent())
354  {
355  AliFatal("ERROR: InputEvent not set");
356  return;
357  }
358  else AliDebug(1,"Good, InputEvent set");
359 
360  // AliInfo(Form("NotifyRun, fCurrentRunnumber %d",fCurrentRunNumber));
361  fRunNumber = InputEvent()->GetRunNumber();
362  AliDebug(1,Form("RunNumber %d", fRunNumber));
363 
364  // Init EMCAL geometry
365  if (!fgeom) SetEMCalGeometry();
366  //Init EMCAL geometry done
367 
369 
370  //set L1 phases for current run
371  if(fReferenceRunByRunFileName.Length()!=0){
372  if(fIsPARRun){
374  }else{
376  }
377  }
378 
379  // set bad channel map
381 
382  return;
383 }
384 
385 //_____________________________________________________________________
388 {
389  AliDebug(1,"AliAnalysisTaskEMCALTimeCalib::SetEMCalGeometry()");
390  if(fGeometryName.Length()==0){
391  fgeom=AliEMCALGeometry::GetInstanceFromRunNumber(fRunNumber);
392  AliInfo(Form("Get EMCAL geometry name <%s> for run %d",fgeom->GetName(),fRunNumber));
393  } else {
394  fgeom = AliEMCALGeometry::GetInstance(fGeometryName.Data());
395  AliInfo(Form("Set EMCAL geometry name to <%s>",fGeometryName.Data()));
396  }
397 
398  if (!fgeom){
399  AliWarning("Make sure the EMCal geometry is set properly !");
400  } else {
401  AliDebug(1,Form("EMCal geometry properly set: fGeom = %p, fGeometryName=%s",fgeom,fGeometryName.Data()));
402  }
403 
404  return kTRUE;
405 }
406 
407 //_____________________________________________________________________
410 {
411  //method under development
412  AliInfo(Form("<D> -- Run # = %d", fRunNumber));
413  AliInfo("prepare TOFT0maker!!");
414  //cout<<"Run "<< fRunNumber<<" in TOFT0maker"<<endl;
415 
416 
417  AliCDBManager * cdb = AliCDBManager::Instance();
418  cdb->SetDefaultStorage("raw://");
419  cdb->SetRun(fRunNumber);
420 
421 // AliESDpid *extPID=new AliESDpid();
422 //
423 // // Wonder if some have to be declared as private variables??
424 // // AliESDpid *extPID = new AliESDpid();
425 // // AliTOFcalib * tofCalib = new AliTOFcalib();
426 // // tofCalib->SetCalibrateTOFsignal(kTRUE);
427 // // tofCalib->Init();
428 //
429 // fTOFmaker = new AliTOFT0maker(extPID);
430 // fTOFmaker->SetTimeResolution(115.0); // if you want set the TOF res
431 // // fTOFmaker = new AliTOFT0maker(extPID,tofCalib);
432 // // fTOFmaker->SetTimeResolution(130.0);
433 //
434 // //cout<<"extPID "<<extPID<<" fTOFmaker "<<fTOFmaker<<endl;
435 
436 }// End PrepareTOFT0maker
437 
438 //________________________________________________________________________
442 {
443  AliDebug(1,"AliAnalysisTaskEMCALTimeCalib::UserCreateOutputObjects()");
444 
445  const Int_t nChannels = 17664;
446  //book histograms
447  if(fFillHeavyHisto){
448  fhcalcEvtTime = new TH1F("fhcalcEvtTime","calculated event time from T0",fFineNbins, fFineNbins,fFineTmax);
449  fhcalcEvtTime->GetXaxis()->SetTitle("T ");
450  fhcalcEvtTime->GetYaxis()->SetTitle("Counts (a.u.)");
451 
452  fhEvtTimeHeader = new TH1F("fhEvtTimeHeader","event time from header",fFineNbins, fFineNbins,fFineTmax);
453  fhEvtTimeHeader->GetXaxis()->SetTitle("T ");
454  fhEvtTimeHeader->GetYaxis()->SetTitle("Counts (a.u.)");
455 
456  fhEvtTimeDiff = new TH1F("fhEvtTimeDiff","event time difference",fFineNbins, fFineNbins,fFineTmax);
457  fhEvtTimeDiff->GetXaxis()->SetTitle("#Delta T ");
458  fhEvtTimeDiff->GetYaxis()->SetTitle("Counts (a.u.)");
459  }
460 
461  fhEventType = new TH1F("fhEventType","event type",10, 0.,10.);
462  //fhEventType ->GetXaxis()->SetTitle("Type ");
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");
472 
473 
474  fhEventType ->GetYaxis()->SetTitle("Counts (a.u.)");
475  if(fFillHeavyHisto){
476  fhTcellvsTOFT0 = new TH2F("hTcellvsTOFT0", " T_cell vs TOFT0", 500,-600.0,+400.0,fRawTimeNbins,fRawTimeMin,fRawTimeMax);
477  fhTcellvsTOFT0HD = new TH2F("hTcellvsTOFT0HD", " T_cell vs TOFT0,HighEnergy", 500,-600.0,+400.0,4*fRawTimeNbins,fRawTimeMin,fRawTimeMax);
478  }
479  fhTcellvsSM = new TH2F("hTcellvsSM", " T_cell vs SM", (Int_t)kNSM,0,(Double_t)kNSM,(Int_t)(fRawTimeNbins/2),fRawTimeMin,fRawTimeMax);
480 
481  if(fFillHeavyHisto){
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);
484  }
485 
486  //Set-up Info for PAR histograms
487  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
488  if(!mgr) AliFatal("No Analysis Manager available...\n");
489  Int_t runNum = mgr->GetRunFromPath();
490  if(runNum == 0){
491  runNum = TString(gSystem->Getenv("RUNNO")).Atoi();
492  if(runNum < 200000){
493  AliFatal("Run Number not correctly set in UserCreateOutputObjects()!");
494  }
495  }
496  GetPARInfoForRunNumber(runNum);
497 
498  if(fIsPARRun){
499  for (Int_t iPAR = 0; iPAR <= fCurrentPARs.numPARs; iPAR++){
500  TH2F* fRawTimeSinglePAR;
501  TH2F* fRawTimeLGSinglePAR;
502  std::vector<TH2F*> vecRawTimePAR;
503  std::vector<TH2F*> vecRawTimeLGPAR;
504  for(Int_t iBC = 0; iBC < kNBCmask; iBC++){
505  fRawTimeSinglePAR = new TH2F(Form("RawTimeBeforePAR%dBC%d",iPAR+1, iBC),
506  Form("cell raw time vs ID for high gain BC %d ", iBC),
507  nChannels,0.,(Double_t)nChannels,fRawTimeNbins,fRawTimeMin,fRawTimeMax);
508  fRawTimeLGSinglePAR = new TH2F(Form("RawTimeLGBeforePAR%dBC%d",iPAR+1, iBC),
509  Form("cell raw time vs ID for low gain BC %d ", iBC),
510  nChannels,0.,(Double_t)nChannels,fRawTimeNbins,fRawTimeMin,fRawTimeMax);
511  vecRawTimePAR.push_back(fRawTimeSinglePAR);
512  vecRawTimeLGPAR.push_back(fRawTimeLGSinglePAR);
513  }
514  fhRawTimePARs.push_back(vecRawTimePAR);
515  fhRawTimeLGPARs.push_back(vecRawTimeLGPAR);
516  }
517  }
518 
519  for (Int_t i = 0; i < kNBCmask ; i++)
520  {
521  //already after correction
522  //high gain
523  fhTimeSumSq[i] = new TH1F(Form("hTimeSumSq%d", i),
524  Form("cell Sum Square time HG, BC %d ", i),
525  nChannels,0.,(Double_t)nChannels);
526  fhTimeSumSq[i]->SetYTitle("Sum Sq Time ");
527  fhTimeSumSq[i]->SetXTitle("AbsId");
528 
529  fhTimeSum[i] = new TH1F(Form("hTimeSum%d", i),
530  Form("cell Sum time HG, BC %d ", i),
531  nChannels,0.,(Double_t)nChannels);
532  fhTimeSum[i]->SetYTitle("Sum Time ");
533  fhTimeSum[i]->SetXTitle("AbsId");
534 
535  fhTimeEnt[i] = new TH1F(Form("hTimeEnt%d", i),
536  Form("cell Entries HG, BC %d ", i),
537  nChannels,0.,(Double_t)nChannels);
538  fhTimeEnt[i]->SetYTitle("Entries for Time ");
539  fhTimeEnt[i]->SetXTitle("AbsId");
540 
541  //low gain
542  fhTimeLGSumSq[i] = new TH1F(Form("hTimeLGSumSq%d", i),
543  Form("cell Sum Square time LG, BC %d ", i),
544  nChannels,0.,(Double_t)nChannels);
545  fhTimeLGSumSq[i]->SetYTitle("Sum Sq Time ");
546  fhTimeLGSumSq[i]->SetXTitle("AbsId");
547 
548  fhTimeLGSum[i] = new TH1F(Form("hTimeLGSum%d", i),
549  Form("cell Sum time LG, BC %d ", i),
550  nChannels,0.,(Double_t)nChannels);
551  fhTimeLGSum[i]->SetYTitle("Sum Time ");
552  fhTimeLGSum[i]->SetXTitle("AbsId");
553 
554  fhTimeLGEnt[i] = new TH1F(Form("hTimeLGEnt%d", i),
555  Form("cell Entries LG, BC %d ", i),
556  nChannels,0.,(Double_t)nChannels);
557  fhTimeLGEnt[i]->SetYTitle("Entries for Time ");
558  fhTimeLGEnt[i]->SetXTitle("AbsId");
559 
560  //raw time histograms
561  //high gain
562  if(fFillHeavyHisto){
563  fhRawTimeVsIdBC[i] = new TH2F(Form("RawTimeVsIdBC%d", i),
564  Form("cell raw time vs ID for high gain BC %d ", i),
565  nChannels,0.,(Double_t)nChannels,fRawTimeNbins,fRawTimeMin,fRawTimeMax);
566  fhRawTimeVsIdBC[i]->SetXTitle("AbsId");
567  fhRawTimeVsIdBC[i]->SetYTitle("Time");
568  }
569 
570  fhRawTimeSumBC[i] = new TH1F(Form("RawTimeSumBC%d", i),
571  Form("sum of cell raw time for high gain BC %d ", i),
572  nChannels,0.,(Double_t)nChannels);
573  fhRawTimeSumBC[i]->SetXTitle("AbsId");
574  fhRawTimeSumBC[i]->SetYTitle("Sum Time");
575 
576  fhRawTimeEntriesBC[i] = new TH1F(Form("RawTimeEntriesBC%d", i),
577  Form("No. entries of cells raw time for high gain BC %d ", i),
578  nChannels,0.,(Double_t)nChannels);
579  fhRawTimeEntriesBC[i]->SetXTitle("AbsId");
580  fhRawTimeEntriesBC[i]->SetYTitle("Entries for Time ");
581 
582  fhRawTimeSumSqBC[i] = new TH1F(Form("RawTimeSumSqBC%d", i),
583  Form("sum of (cell raw time)^2 for high gain BC %d ", i),
584  nChannels,0.,(Double_t)nChannels);
585  fhRawTimeSumSqBC[i]->SetXTitle("AbsId");
586  fhRawTimeSumSqBC[i]->SetYTitle("Sum Sq Time");
587 
588  //low gain
589  if(fFillHeavyHisto){
590  fhRawTimeVsIdLGBC[i] = new TH2F(Form("RawTimeVsIdLGBC%d", i),
591  Form("cell raw time vs ID for low gain BC %d ", i),
592  nChannels,0.,(Double_t)nChannels,fRawTimeNbins,fRawTimeMin,fRawTimeMax);
593  fhRawTimeVsIdLGBC[i]->SetXTitle("AbsId");
594  fhRawTimeVsIdLGBC[i]->SetYTitle("Time");
595  }
596 
597  fhRawTimeSumLGBC[i] = new TH1F(Form("RawTimeSumLGBC%d", i),
598  Form("sum of cell raw time for low gain BC %d ", i),
599  nChannels,0.,(Double_t)nChannels);
600  fhRawTimeSumLGBC[i]->SetXTitle("AbsId");
601  fhRawTimeSumLGBC[i]->SetYTitle("Sum Time");
602 
603  fhRawTimeEntriesLGBC[i] = new TH1F(Form("RawTimeEntriesLGBC%d", i),
604  Form("No. entries of cells raw time for low gain BC %d ", i),
605  nChannels,0.,(Double_t)nChannels);
606  fhRawTimeEntriesLGBC[i]->SetXTitle("AbsId");
607  fhRawTimeEntriesLGBC[i]->SetYTitle("Entries for Time ");
608 
609  fhRawTimeSumSqLGBC[i] = new TH1F(Form("RawTimeSumSqLGBC%d", i),
610  Form("sum of (cell raw time)^2 for low gain BC %d ", i),
611  nChannels,0.,(Double_t)nChannels);
612  fhRawTimeSumSqLGBC[i]->SetXTitle("AbsId");
613  fhRawTimeSumSqLGBC[i]->SetYTitle("Sum Sq Time");
614 
615  //histograms with corrected raw time for L1 shift and 100ns
616  if(fBadReco && fFillHeavyHisto){
617  fhRawCorrTimeVsIdBC[i] = new TH2F(Form("RawCorrTimeVsIdBC%d", i),
618  Form("cell L1 shift and 100ns corrected raw time vs ID for high gain BC %d ", i),
619  nChannels,0.,(Double_t)nChannels,fPassTimeNbins,fPassTimeMin,fPassTimeMax);
620  fhRawCorrTimeVsIdBC[i]->SetXTitle("AbsId");
621  fhRawCorrTimeVsIdBC[i]->SetYTitle("Time");
622 
623  fhRawCorrTimeVsIdLGBC[i] = new TH2F(Form("RawCorrTimeVsIdLGBC%d", i),
624  Form("cell L1 shift and 100ns corrected raw time vs ID for low gain BC %d ", i),
625  nChannels,0.,(Double_t)nChannels,fPassTimeNbins,fPassTimeMin,fPassTimeMax);
626  fhRawCorrTimeVsIdLGBC[i]->SetXTitle("AbsId");
627  fhRawCorrTimeVsIdLGBC[i]->SetYTitle("Time");
628  }
629 
630  //histograms with corrected raw time for L1 shift and 100ns + new L1 phase
631  if(fReferenceRunByRunFileName.Length()!=0 && fFillHeavyHisto){
632  fhTimeVsIdBC[i] = new TH2F(Form("TimeVsIdBC%d", i),
633  Form("cell time corrected for L1 shift, 100ns and L1 phase vs ID for high gain BC %d ", i),
634  nChannels,0.,(Double_t)nChannels,fPassTimeNbins,fPassTimeMin,fPassTimeMax);
635  fhTimeVsIdBC[i]->SetXTitle("AbsId");
636  fhTimeVsIdBC[i]->SetYTitle("Time");
637 
638  fhTimeVsIdLGBC[i] = new TH2F(Form("TimeVsIdLGBC%d", i),
639  Form("cell time corrected for L1 shift, 100ns and L1 phase vs ID for low gain BC %d ", i),
640  nChannels,0.,(Double_t)nChannels,fPassTimeNbins,fPassTimeMin,fPassTimeMax);
641  fhTimeVsIdLGBC[i]->SetXTitle("AbsId");
642  fhTimeVsIdLGBC[i]->SetYTitle("Time");
643  }
644 
645  for (Int_t j = 0; j < kNSM ; j++)
646  {
647  //High gain
648  //fhTimeDsupBC[j][i]= new TH2F(Form("SupMod%dBC%d",j,i), Form("SupMod %d time_vs_E BC %d",j,i),500,0.0,20.0,2200,-350.0,750.0);
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);
650  fhTimeDsupBC[j][i]->SetYTitle(" Time (ns) ");
651  fhTimeDsupBC[j][i]->SetXTitle(" E (GeV) ");
652 
653  //low gain
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);
655  fhTimeDsupLGBC[j][i]->SetYTitle(" Time (ns) ");
656  fhTimeDsupLGBC[j][i]->SetXTitle(" E (GeV) ");
657  }
658  }
659 
660  for (Int_t jj = 0; jj < kNSM ; jj++)
661  {
662  //high gain
663  fhTimeDsup[jj] = new TH2F(Form("SupMod%d",jj), Form("SupMod %d time_vs_E, high gain",jj),fEnergyNbins,fEnergyMin,fEnergyMax,fPassTimeNbins,fPassTimeMin,fPassTimeMax);
664  fhTimeDsup[jj]->SetYTitle(" Time (ns) ");
665  fhTimeDsup[jj]->SetXTitle(" E (GeV) ");
666 
667  //low gain
668  fhTimeDsupLG[jj] = new TH2F(Form("SupMod%dLG",jj), Form("SupMod %d time_vs_E, low gain ",jj),fEnergyLGNbins,fEnergyLGMin,fEnergyLGMax,fPassTimeNbins,fPassTimeMin,fPassTimeMax);
669  fhTimeDsupLG[jj]->SetYTitle(" Time (ns) ");
670  fhTimeDsupLG[jj]->SetXTitle(" E (GeV) ");
671  }
672 
673  fhTimeVsBC = new TH2F("TimeVsBC"," SupMod time_vs_BC ", 4001,-0.5,4000.5,(Int_t)(fRawTimeNbins/2.),fRawTimeMin,fRawTimeMax);
674 
675 
676  //add histos to list
677  fOutputList = new TList();
678  fOutputList->Add(fhEventType);
679  if(fFillHeavyHisto){
683 
688  }
689  fOutputList->Add(fhTcellvsSM);
690 
691  if(fIsPARRun && fFillHeavyHisto){
692  for (Int_t iPAR = 0; iPAR <= fCurrentPARs.numPARs; iPAR++){
693  for(Int_t iBC = 0; iBC < kNBCmask; iBC++){
694  fOutputList->Add(fhRawTimePARs[iPAR][iBC]);
695  fOutputList->Add(fhRawTimeLGPARs[iPAR][iBC]);
696  }
697  }
698  }
699 
700  for (Int_t i = 0; i < kNBCmask ; i++)
701  {
702  fOutputList->Add(fhTimeSumSq[i]);
703  fOutputList->Add(fhTimeEnt[i]);
704  fOutputList->Add(fhTimeSum[i]);
705 
706  fOutputList->Add(fhTimeLGSumSq[i]);
707  fOutputList->Add(fhTimeLGEnt[i]);
708  fOutputList->Add(fhTimeLGSum[i]);
709 
710  if(fFillHeavyHisto) {
711  fOutputList->Add(fhRawTimeVsIdBC[i]);
713  }
714  fOutputList->Add(fhRawTimeSumBC[i]);
716  fOutputList->Add(fhRawTimeSumSqBC[i]);
717 
718  fOutputList->Add(fhRawTimeSumLGBC[i]);
721 
722  if(fBadReco && fFillHeavyHisto) {
725  }
726  if(fReferenceRunByRunFileName.Length()!=0 && fFillHeavyHisto) {
727  fOutputList->Add(fhTimeVsIdBC[i]);
728  fOutputList->Add(fhTimeVsIdLGBC[i]);
729  }
730 
731  for (Int_t j = 0; j < kNSM ; j++){
732  fOutputList->Add(fhTimeDsupBC[j][i]);
733  fOutputList->Add(fhTimeDsupLGBC[j][i]);
734  }
735  }
736 
737  for (Int_t j = 0; j < kNSM ; j++)
738  {
739  fOutputList->Add(fhTimeDsup[j]);
740  fOutputList->Add(fhTimeDsupLG[j]);
741  }
742 
743  fOutputList->Add(fhTimeVsBC);
744 
745  fOutputList->SetOwner(kTRUE);
746  PostData(1,fOutputList);
747 
748 
749 } // End of AliAnalysisTaskEMCALTimeCalib::UserCreateOuputObjects()
750 
751 //________________________________________________________________________
754 {
755  // Called for each event
756  AliDebug(2,Form("UserExec: EMCal geometry: fgeom = %p fGeometryName %s",fgeom,fGeometryName.Data()));
757  AliVEvent *event = InputEvent();
758  //cout<<"T0TOF "<<event->GetT0TOF()<<endl;//bad idea
759  //cout<< fEvent->GetTOFHeader()->GetDefaultEventTimeVal()<<endl;
760  AliDebug(2,Form("TOF time from header %f ps",event->GetTOFHeader()->GetDefaultEventTimeVal()));
761  if(fFillHeavyHisto) fhEvtTimeHeader->Fill(event->GetTOFHeader()->GetDefaultEventTimeVal());
762 
763  //fEvent = dynamic_cast<AliESDEvent*>(event);
764  if (!event) {
765  AliError("ESD not available, exit");
766  fhEventType->Fill(0.5);
767  return;
768  }
769 
770  if(fPileupFromSPD==kTRUE){
771  if(event->IsPileupFromSPD(3,0.8,3.,2.,5.)){
772  AliDebug(1,"Event: PileUp skip.");
773  fhEventType->Fill(1.5);
774  return;
775  }
776  }
777 
778  TString triggerclasses = event->GetFiredTriggerClasses();
779  if(triggerclasses=="") {
780  fhEventType->Fill(2.5);
781  return;
782  }
783 
784  Int_t eventType = ((AliVHeader*)event->GetHeader())->GetEventType();
785  // physics events eventType=7, select only those
786  AliDebug(1,Form("Triggerclasses %s, eventType %d",triggerclasses.Data(),eventType));
787  if(eventType != 7) {
788  fhEventType->Fill(3.5);
789  return;
790  }
791 
792  // Check trigger
793  Bool_t bMB = kFALSE;
794  Bool_t bL0 = kFALSE;
795  Bool_t bL1G = kFALSE;
796  Bool_t bL1J = kFALSE;
797  Bool_t bDL0 = kFALSE;
798  Bool_t bDL1G = kFALSE;
799  Bool_t bDL1J = kFALSE;
800 
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;
808 
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;
814 
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;
820 
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;
829 
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;
838 
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;
847 
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;
856 
857  if( bMB ){ fhEventType->Fill(4.5);}//INT7,8
858  if( bL0 ){ fhEventType->Fill(5.5);}//EMC7,EMC8
859  if( bL1G || bL1J ){ fhEventType->Fill(6.5);}//L1 EMCal
860  if( bDL0 ){ fhEventType->Fill(7.5);}//DMC7,DMC8
861  if( bDL1G || bDL1J ){ fhEventType->Fill(8.5);}//L1 DCal
862 
863  // if(bL1G || bL1J || bL0){
864 
865 // Prepare TOFT0 maker at the beginning of a run
866 // if (event->GetRunNumber() != fRunNumber){
867 // AliInfo(Form("Runno per event %d",event->GetRunNumber()));
868 // fRunNumber = event->GetRunNumber();
869 // // PrepareTOFT0maker();
870 // // cout<<"tofT0maker per run"<<fRunNumber<<endl;
871 // }// fi Check if run number has changed
872 
873 // // --- Use of AliTOFT0maker
874 // Double_t calcolot0=0.0;
875 // if(!AODEvent()){
876 // Double_t* timeTOFtable;
877 // timeTOFtable=fTOFmaker->ComputeT0TOF(dynamic_cast<AliESDEvent*>(event));
878 // AliDebug(2,Form("TOF time %f ps, resolution %f ps, tracks at TOF %f/used %f",timeTOFtable[0],timeTOFtable[1],timeTOFtable[3],timeTOFtable[7]));
879 // //cout<<"event time "<<timeTOFtable[0]<<" resolution "<<timeTOFtable[1]<<"ps av. ev. time "<<timeTOFtable[2]<<" trks at TOF "<<timeTOFtable[3]<<" calc evnt time "<<timeTOFtable[4]<<" resolution "<<timeTOFtable[5]<<" tracks used "<<timeTOFtable[7]<<endl;
880 // calcolot0=timeTOFtable[0];
881 // }
882 
883 // if(fFillHeavyHisto) {
884 // fhcalcEvtTime->Fill(calcolot0);
885 // if(calcolot0 != 0 && event->GetTOFHeader()->GetDefaultEventTimeVal() != 0 )
886 // fhEvtTimeDiff->Fill(calcolot0-event->GetTOFHeader()->GetDefaultEventTimeVal());
887 // }
888 
889  TRefArray* caloClusters = new TRefArray();
890  event->GetEMCALClusters(caloClusters);
891  // cout << " ###########Bunch Cross nb = " << event->GetBunchCrossNumber() << endl;
892 
893  Int_t BunchCrossNumber =event->GetBunchCrossNumber();
894 
895  Float_t offset=0.;
896  Float_t offsetPerSM=0.;
897  Int_t L1phaseshift=0;
898  Int_t L1phase=0;
899  Int_t L1shiftOffset=0;
900 
901  Int_t nBC = 0;
902  nBC = BunchCrossNumber%4;
903  //Int_t nTriggerMask =event->GetTriggerMask();
904  // cout << " nBC " << nBC << " nTriggerMask " << nTriggerMask<< endl;
905  Float_t timeBCoffset = 0.; //manual offset
906  // if( nBC%4 ==0 || nBC%4==1) timeBCoffset = 100.; // correction was for LHC11 when BC was not corrected
907 
908  Int_t nclus = caloClusters->GetEntries();
909  AliDebug(1,Form("###########Bunch Cross nb = %d nclus = %d",nBC,nclus ));
910  //cout << " ###########Bunch Cross nb = " << nBC <<" nclus= "<< nclus<< endl;
911  //Int_t ntracks = event-> GetNumberOfTracks() ;
912 
913  AliVCaloCells &cells= *(event->GetEMCALCells());//it is cluster independent
914  //Variables used plenty in loops
915  Int_t nSupMod=-1, nModule=-1;
916  Int_t iphi=-1, ieta=-1, nIphi=-1, nIeta=-1;
917  Int_t absId=-1;
918  Float_t hkdtime=0.0;
919  Float_t amp=0.0;
920  Bool_t isHighGain=kTRUE;
921  Int_t mostEneId=-1;
922  Float_t mostEneEn=0.;
923 
924  fCurrentPARIndex = 0;
925  if(fIsPARRun){
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()));
929  //ULong64_t globalBC = event->GetBunchCrossNumber() + 3564*event->GetOrbitNumber() + 59793994260*event->GetPeriodNumber();
930  ULong64_t globalBC = eventBC + eventOrbit + eventPeriod;
931  for(int ipar = 0; ipar < fCurrentPARs.numPARs; ipar++){
932  if(globalBC >= fCurrentPARs.PARGlobalBCs[ipar]){
933  fCurrentPARIndex ++;
934  }
935  }
936  }
937  if(fReferenceRunByRunFileName.Length()!=0 && fIsPARRun){
939  }
940  for (Int_t icl = 0; icl < nclus; icl++) {
941  //ESD and AOD CaloCells carries the same information
942  AliVCluster* clus = (AliVCluster*)caloClusters->At(icl);
943  if(!AcceptCluster(clus)) continue;
944 
945  //cout<<"nCells="<< clus->GetNCells();<<endl;
946 
947  UShort_t * index = clus->GetCellsAbsId() ;
948 
949  // find index of the most energetic cell in cluster
950  mostEneEn=0.;
951  mostEneId=-1;
952  if(fMostEneCellOnly) {
953  for(Int_t i = 0; i < clus->GetNCells() ; i++) {
954  absId = index[i];
955  amp = cells.GetCellAmplitude(absId) ;
956  if(amp > mostEneEn){
957  mostEneEn = amp;
958  mostEneId = absId;
959  }
960  }
961  }//works only for fMostEneCellOnly=kTRUE
962 
963  for(Int_t i = 0; i < clus->GetNCells() ; i++) {
964  absId = index[i]; // or clus->GetCellNumber(i) ;
965  if(fMostEneCellOnly && absId != mostEneId) {
966  //printf("tr.%s.cl.%d.cell.%d.rejected\n",triggerclasses.Data(),icl,i);
967  continue;
968  }
969  //printf("tr.%s.cl.%d.cell.%d.accepted\n",triggerclasses.Data(),icl,i);
970  hkdtime = cells.GetCellTime(absId) * 1.0e09; // to get ns
971  amp = cells.GetCellAmplitude(absId) ;
972  isHighGain = cells.GetCellHighGain(absId);
973  //cout<<"cell absID: "<<absId<<" cellTime: "<<hkdtime<<" cellaplit: "<< amp<<endl;
974  // GEOMETRY tranformations
975  fgeom->GetCellIndex(absId, nSupMod, nModule, nIphi, nIeta);
976  fgeom->GetCellPhiEtaIndexInSModule(nSupMod,nModule,nIphi,nIeta, iphi,ieta);
977 
978  //bad channel check. 0: good channel, 1-5: bad channel
980  if(GetEMCALChannelStatus(nSupMod,ieta,iphi)) continue;//printf("bad\n");
981  } else if(fSetBadChannelMapSource==2){
982  if(GetEMCALChannelStatus(absId)) continue;//printf("bad\n");
983  }
984 
985  //main histograms with raw time information
986  if(amp>fMinCellEnergy){
987 
988  if(isHighGain){
989  if(fFillHeavyHisto){
990  fhRawTimeVsIdBC[nBC]->Fill(absId,hkdtime);
991  if(fIsPARRun){
992  if(fhRawTimePARs[fCurrentPARIndex][nBC]==0x0)AliFatal(Form("No Histogram for PAR number %d! Problem with Create Output Objects", fCurrentPARIndex));
993  fhRawTimePARs[fCurrentPARIndex][nBC]->Fill(absId, hkdtime);
994  }
995  }
996  fhRawTimeSumBC[nBC]->Fill(absId,hkdtime);
997  fhRawTimeEntriesBC[nBC]->Fill(absId,1.);
998  fhRawTimeSumSqBC[nBC]->Fill(absId,hkdtime*hkdtime);
999  }else{
1000  if(fFillHeavyHisto){
1001  fhRawTimeVsIdLGBC[nBC]->Fill(absId,hkdtime);
1002  if(fIsPARRun){
1003  fhRawTimeLGPARs[fCurrentPARIndex][nBC]->Fill(absId, hkdtime);
1004  }
1005  }
1006  fhRawTimeSumLGBC[nBC]->Fill(absId,hkdtime);
1007  fhRawTimeEntriesLGBC[nBC]->Fill(absId,1.);
1008  fhRawTimeSumSqLGBC[nBC]->Fill(absId,hkdtime*hkdtime);
1009  }
1010  }
1011  //fgeom->PrintCellIndexes(absId);
1012  //fgeom->PrintCellIndexes(absId,1);
1013 
1014  // other histograms for cross-check
1015  CheckCellRCU(nSupMod,ieta,iphi);//SM, column, row
1016 
1017  fhTcellvsSM->Fill(nSupMod,hkdtime);
1018  if(fFillHeavyHisto) {
1019  if(isHighGain==kTRUE) {fhEneVsAbsIdHG->Fill(absId,amp);}
1020  else {fhEneVsAbsIdLG->Fill(absId,amp);}
1021  }
1022  fhTimeVsBC->Fill(1.*BunchCrossNumber,hkdtime-timeBCoffset);
1023  //important remark: We use 'Underflow bin' for absid=0 in OADB for time calibration
1024  if(isHighGain==kTRUE){
1025  if(fhAllAverageBC[nBC]!=0) {//comming from file after the first iteration
1026  offset = (Float_t)(fhAllAverageBC[nBC]->GetBinContent(absId));//channel absId=0 has histogram bin=0
1027  } else if(fReferenceFileName.Length()!=0){//protection against missing reference histogram
1028  AliFatal(Form("Reference histogram for BC%d not properly loaded",nBC));
1029  }
1030  } else {
1031  if(fhAllAverageLGBC[nBC]!=0) {//comming from file after the first iteration
1032  offset = (Float_t)(fhAllAverageLGBC[nBC]->GetBinContent(absId));//channel absId=0 has histogram bin=0
1033  } else if(fReferenceFileName.Length()!=0){//protection against missing reference histogram
1034  AliFatal(Form("Reference LG histogram for BC%d not properly loaded",nBC));
1035  }
1036  }
1037  //if(offset==0)cout<<"offset 0 in SM "<<nSupMod<<endl;
1038 
1039  // Solution for 2015 data where L1 phase and L1 shift is not correct in data. We need to calibrate run by run.
1040  // The shift and phase are done per SM (0-19).
1041  // L1 phase is necessary in run 2.
1042  // L1 shift is necessary only for bad reconstructed runs (muon_calo_pass1 lhc15f-m)
1043  if(fhRefRuns!=0) {//comming from file after the first iteration
1044  L1phaseshift = (Int_t)(fhRefRuns->GetBinContent(nSupMod));//SM0 = bin0
1045 
1046  // to correct for L1 phase
1047  // this part works for both: muon_calo_pass1 of LHC15n (pp@2.76) and later reconstructions
1048  // wrong reconstruction done before in run2
1049  L1phase = L1phaseshift & 3; //bit operation
1050  if(nBC >= L1phase)
1051  offsetPerSM = (nBC - L1phase)*25;
1052  else
1053  offsetPerSM = (nBC - L1phase + 4)*25;
1054 
1055  // to correct for L1 shift
1056  // this part is only for wrongly reconstructed runs before LHC15n in run2
1057  if(fBadReco){
1058  L1shiftOffset = L1phaseshift>>2; //bit operation
1059  L1shiftOffset*=25;
1060  //(we subtract it here because we subtract the whole wrong offset later --=+)
1061  if(nBC==0 || nBC==1) L1shiftOffset-=100.;//additional shift for muon_calo_pass1 up to lhc15f-m
1062  }
1063  } else if(fReferenceRunByRunFileName.Length()!=0){//protection against missing reference histogram
1064  AliFatal("Reference histogram run-by-run not properly loaded");
1065  }
1066  //end of load additional offset
1067 
1068  //fill the raw time with L1 shift correction and 100ns
1069  if(fBadReco && fFillHeavyHisto && amp>fMinCellEnergy){
1070  if(isHighGain){
1071  fhRawCorrTimeVsIdBC[nBC]->Fill(absId,hkdtime-L1shiftOffset);
1072  }else{
1073  fhRawCorrTimeVsIdLGBC[nBC]->Fill(absId,hkdtime-L1shiftOffset);
1074  }
1075  }
1076 
1077  //fill time after L1 shift correction and 100ns and new L1 phase
1078  if(fReferenceRunByRunFileName.Length()!=0 && fFillHeavyHisto && amp>fMinCellEnergy){
1079  if(isHighGain){
1080  fhTimeVsIdBC[nBC]->Fill(absId,hkdtime-L1shiftOffset-offsetPerSM);
1081  }else{
1082  fhTimeVsIdLGBC[nBC]->Fill(absId,hkdtime-L1shiftOffset-offsetPerSM);
1083  }
1084  }
1085 
1086  //other control histograms
1087  if(amp>0.5) {
1088  if(isHighGain){
1089  fhTimeDsup[nSupMod]->Fill(amp,hkdtime-offset-offsetPerSM-L1shiftOffset);
1090  fhTimeDsupBC[nSupMod][nBC]->Fill(amp,hkdtime-offset-offsetPerSM-L1shiftOffset);
1091  }else{
1092  fhTimeDsupLG[nSupMod]->Fill(amp,hkdtime-offset-offsetPerSM-L1shiftOffset);
1093  fhTimeDsupLGBC[nSupMod][nBC]->Fill(amp,hkdtime-offset-offsetPerSM-L1shiftOffset);
1094  }
1095  }
1096 
1097 // if(fFillHeavyHisto) {
1098 // if(amp>0.9) {
1099 // fhTcellvsTOFT0HD->Fill(calcolot0, hkdtime);
1100 // }
1101 // fhTcellvsTOFT0->Fill(calcolot0, hkdtime-offset-offsetPerSM-L1shiftOffset);
1102 // }
1103 
1104  hkdtime = hkdtime-timeBCoffset;//time corrected by manual offset (default=0)
1105  Float_t hkdtimecorr;
1106  hkdtimecorr= hkdtime-offset-offsetPerSM-L1shiftOffset;//time after first iteration
1107 
1108  //main histograms after the first itereation for calibration constants
1109  //if(hkdtimecorr>=-20. && hkdtimecorr<=20. && amp>0.9 ) {
1110  if(hkdtimecorr>=fMinTime && hkdtimecorr<=fMaxTime && amp>fMinCellEnergy ) {
1111  // per cell
1112 // Float_t entriesTime=fhTimeEnt[nBC]->GetBinContent(absId)+1;
1113 // Float_t sumTimeSq=(fhTimeSumSq[nBC]->GetBinContent(absId)+(hkdtime*hkdtime));
1114 // Float_t sumTime=(fhTimeSum[nBC]->GetBinContent(absId)+hkdtime);
1115 //
1116 // fhTimeEnt[nBC]->SetBinContent(absId,entriesTime);
1117 // fhTimeSumSq[nBC]->SetBinContent(absId,sumTimeSq);
1118 // fhTimeSum[nBC]->SetBinContent(absId,sumTime);
1119 
1120  //correction in 2015 for wrong L1 phase and L1 shift
1121  hkdtime = hkdtime - offsetPerSM - L1shiftOffset;
1122 
1123  if(isHighGain){
1124  fhTimeEnt[nBC]->Fill(absId,1.);
1125  fhTimeSumSq[nBC]->Fill(absId,hkdtime*hkdtime);
1126  fhTimeSum[nBC]->Fill(absId,hkdtime);
1127  }else{
1128  fhTimeLGEnt[nBC]->Fill(absId,1.);
1129  fhTimeLGSumSq[nBC]->Fill(absId,hkdtime*hkdtime);
1130  fhTimeLGSum[nBC]->Fill(absId,hkdtime);
1131  }
1132 
1133 
1134  } // hkdtime:[-20;20]
1135  } // end icell
1136  } //end cluster
1137 
1138 
1139  // Post output data.
1140  //cout<<"Post data and delete caloClusters"<<endl;
1141  caloClusters->Delete();
1142  delete caloClusters;
1143 // } // end if trigger type
1144 
1145  PostData(1, fOutputList);
1146 } // End of AliAnalysisTaskEMCALTimeCalib::UserExec()
1147 
1148 //________________________________________________________________________
1152 {
1153  fOutputList = dynamic_cast<TList*> (GetOutputData(1));
1154 
1155  // if(fTOFmaker) delete fTOFmaker;
1156 
1157  if(fL1PhaseList) {
1158  fL1PhaseList->SetOwner();
1159  fL1PhaseList->Clear();
1160  delete fL1PhaseList;
1161  }
1162 
1163  if (fBadChannelMapArray) {
1164  fBadChannelMapArray->Clear();
1165  delete fBadChannelMapArray;
1166  }
1167 
1168  if (!fOutputList)
1169  {
1170  AliDebug(1,"ERROR: Output list not available");
1171  return;
1172  }
1173 } // End of AliAnalysisTaskEMCALTimeCalib::Terminate
1174 
1175 //________________________________________________________________________
1178 {
1179  //fix with noisy EMCAL fee card
1180  Int_t nCells = clus->GetNCells();
1181 
1182  if(clus->IsEMCAL())
1183  {
1184  if ((clus->E() > fMaxClusterEnergy && nCells > fMaxNcells ) || nCells > fMaxNcells){
1185  AliDebug(1,"very big cluster with enormous energy - cluster rejected");
1186  return kFALSE;
1187  }
1188  }
1189 
1190  // remove other than photonlike
1191  Double_t lambda0=clus->GetM02();
1192  if (lambda0>fMaxLambda0LG || lambda0<fMinLambda0LG){
1193  AliDebug(1,"lambda0 loose cut failed - cluster rejected");
1194  return kFALSE;
1195  }
1196 
1197  // remove matched clusters
1198  Double_t Dx=clus->GetTrackDx();
1199  Double_t Dz=clus->GetTrackDz();
1200  Double_t Rtrack = TMath::Sqrt(Dx*Dx+Dz*Dz);
1201  if (Rtrack <fMaxRtrack)
1202  {
1203  AliDebug(1,"track matched - cluster rejected");
1204  return kFALSE;
1205  }
1206 
1207  if (nCells<fMinNcells)
1208  {
1209  AliDebug(1,"single cell cluster - cluster rejected");
1210  return kFALSE;
1211  }
1212 
1213  if(clus->E()<fMinClusterEnergy)
1214  {
1215  AliDebug(1,"cluster energy < 1 GeV- cluster rejected");
1216  return kFALSE;
1217  }
1218 
1219 
1220  if(!IsLowGainCellInCluster(clus)) {//no low gain cell in cluster
1221  //apply more strict lambda0^2 cut
1222  if (lambda0>fMaxLambda0 || lambda0<fMinLambda0){
1223  AliDebug(1,"lambda0 strict cut failed - cluster rejected");
1224  return kFALSE;
1225  }
1226  }
1227 
1228 
1229 
1230 
1231  return kTRUE;
1232 }//End AliAnalysisTaskEMCALTimeCalib::AcceptCluster
1233 
1234 //________________________________________________________________________
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;//low gain cell
1241  }
1242  return kFALSE;
1243 
1244 }
1245 
1246 //________________________________________________________________________
1249 {
1250  Int_t iRCU;
1251  if(nSupMod < 10 || (nSupMod >= 12 && nSupMod <18) )
1252  {
1253  if (0<=irow&&irow<8) iRCU=0; // first cable row
1254  else if (8<=irow&&irow<16 && 0<=icol&&icol<24) iRCU=0; // first half;
1255  //second cable row
1256  //RCU1
1257  else if (8<=irow&&irow<16 && 24<=icol&&icol<48) iRCU=1; // second half;
1258  //second cable row
1259  else if (16<=irow&&irow<24) iRCU=1; // third cable row
1260 
1261  if (nSupMod%2==1) iRCU = 1 - iRCU; // swap for odd=C side, to allow us to cable both sides the same
1262  }
1263  else
1264  {
1265  // Last 2 SM have one single SRU, just assign RCU 0
1266  iRCU = 0 ;
1267  }
1268 
1269  //cout<<"RCU:"<<iRCU<<endl;
1270  if (iRCU<0)
1271  AliFatal(Form("Wrong EMCAL/DCAL RCU number = %d\n", iRCU));
1272 
1273  return kTRUE;
1274 }//End AliAnalysisTaskEMCALTimeCalib::CheckCellRCU
1275 
1276 //________________________________________________________________________
1279 {
1280  fMinClusterEnergy=1.0;//0.5//0.7
1281  fMaxClusterEnergy=500;
1282  fMinNcells=2;
1283  fMaxNcells=200;
1284  fMinLambda0=0.1;
1285  fMaxLambda0=0.4;
1286  fMinLambda0LG=0.1;
1287  fMaxLambda0LG=4.0;
1288  fMaxRtrack=0.025;
1289  fMinCellEnergy=0.4;//0.1//0.4
1290  fReferenceFileName="";//Reference.root
1292  fBadReco=kFALSE;
1293  fFillHeavyHisto=kFALSE;
1294  fGeometryName="";//EMCAL_COMPLETE12SMV1_DCAL_8SM
1295  fPileupFromSPD=kFALSE;
1296  fMinTime=-20.;
1297  fMaxTime=20.;
1298  fMostEneCellOnly=kFALSE;
1299 
1300  fBadChannelMapSet=kFALSE;
1303 
1304  //histograms
1305  fRawTimeNbins = 400; // Raw time settings should be like that all the time
1306  fRawTimeMin = 400.; // importent in pass1
1307  fRawTimeMax = 800.;
1308  fPassTimeNbins = 1000; // in pass2 should be (400,400,800)
1309  fPassTimeMin = -250.;// in pass3 should be (1000,-250,250)
1310  fPassTimeMax = 250.;
1311  fEnergyNbins = 100; // default settings was 500
1312  fEnergyMin = 0.;
1313  fEnergyMax = 20.;
1314  fEnergyLGNbins = 200; // default settings
1315  fEnergyLGMin = 0.;
1316  fEnergyLGMax = 100.;
1317  fFineNbins = 90; //was 4500 for T0 time studies
1318  fFineTmin = -500;
1319  fFineTmax = 400;
1320 }
1321 
1322 //________________________________________________________________________
1328 {
1329  TFile *file =new TFile(inputFile.Data());
1330  if(file==0x0) {
1331  //AliWarning("Input file does not exist!");
1332  return;
1333  }
1334 
1335  TList *list=(TList*)file->Get("chistolist");
1336  if(list==0x0)
1337  {
1338  //AliWarning("List chistolist does not exist in file!");
1339  return;
1340  }
1341 
1342  Int_t numPARs = 0;
1343  Int_t counter = 0;
1344  if(isPAR){
1345  TIter next(list);
1346  TObject* obj;
1347  while((obj = next())){
1348  TString name(obj->GetName());
1349  if(name.BeginsWith("RawTimeBeforePAR")) counter++;
1350  }
1351  }
1352  numPARs = Int_t(counter/4) - 1;
1353  printf("number of PARs found to be %d!\n", numPARs);
1354 
1355  if(numPARs == -1) isPAR = kFALSE;
1356 
1357  //high gain
1358  TH1F *h1[4];
1359  TH1F *h2[4];
1360  TH1F *h3[4];
1361  TH1F *hAllTimeAvBC[4];
1362  TH1F *hAllTimeRMSBC[4];
1363 
1364  //low gain
1365  TH1F *h4[4];
1366  TH1F *h5[4];
1367  TH1F *h6[4];
1368  TH1F *hAllTimeAvLGBC[4];
1369  TH1F *hAllTimeRMSLGBC[4];
1370 
1371  //PAR histos
1372  TH1F *h1PAR[numPARs+1][4];
1373  TH1F *h2PAR[numPARs+1][4];
1374  //TH1F *h3PAR[numPARs+1][4];
1375  TH1F *hAllTimeAvBCPAR[numPARs+1][4];
1376  //TH1F *hAllTimeRMSBCPAR[numPARs+1][4];
1377 
1378  TH1F *h4PAR[numPARs+1][4];
1379  TH1F *h5PAR[numPARs+1][4];
1380  //TH1F *h6PAR[numPARs+1][4];
1381  TH1F *hAllTimeAvLGBCPAR[numPARs+1][4];
1382  //TH1F *hAllTimeRMSLGBCPAR[numPARs+1][4];
1383 
1384  TH2D* raw2D[4];
1385  TH2D* rawLG2D[4];
1386 
1387  if(isFinal==kFALSE){//first itereation
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));
1392 
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));
1396 
1397  if(isPAR){ //set-up histograms for different PAR time regions
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());
1404 
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);
1414  }
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);
1419  }else{
1420  hAllTimeAvBCPAR[iPAR][i]->SetBinContent(ixbin, h1PAR[iPAR][i]->GetBinContent(ixbin)/h2PAR[iPAR][i]->GetBinContent(ixbin));
1421  }
1422 
1423  if(h5PAR[iPAR][i]->GetBinContent(ixbin) ==0){
1424  hAllTimeAvLGBCPAR[iPAR][i]->SetBinContent(ixbin, 0);
1425  }else{
1426  hAllTimeAvLGBCPAR[iPAR][i]->SetBinContent(ixbin, h4PAR[iPAR][i]->GetBinContent(ixbin)/h5PAR[iPAR][i]->GetBinContent(ixbin));
1427  }
1428  }
1429 
1430  }
1431  }
1432  }
1433  } else {//final iteration
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));
1438 
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));
1442  }
1443  }
1444  //AliWarning("Input histograms read.");
1445 
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());
1449 
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());
1452  }
1453 
1454  //AliWarning("New histograms booked.");
1455 
1456  //important remark: we use 'underflow bin' for absid=0 in OADB . That's why there is j-1 below.
1457  for(Int_t i=0;i<4;i++){
1458  for(Int_t j=1;j<=h1[i]->GetNbinsX();j++){
1459  //high gain
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)) );
1463  } else {
1464  hAllTimeAvBC[i]->SetBinContent(j-1,0.);
1465  hAllTimeRMSBC[i]->SetBinContent(j-1,0.);
1466  }
1467  //low gain
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)) );
1471  } else {
1472  hAllTimeAvLGBC[i]->SetBinContent(j-1,0.);
1473  hAllTimeRMSLGBC[i]->SetBinContent(j-1,0.);
1474  }
1475 
1476  }
1477  }
1478 
1479  //AliWarning("Average and rms calculated.");
1480  TFile *fileNew=new TFile(outputFile.Data(),"recreate");
1481  for(Int_t i=0;i<4;i++){
1482  if(isPAR){
1483  for(Int_t iPAR = 0; iPAR <= numPARs; iPAR++){
1484  hAllTimeAvBCPAR[iPAR][i]->Write();
1485  //hAllTimeRMSBCPAR[iPAR][i]->Write();
1486  hAllTimeAvLGBCPAR[iPAR][i]->Write();
1487  //hAllTimeRMSLGBCPAR[iPAR][i]->Write();
1488  }
1489  }else{
1490  hAllTimeAvBC[i]->Write();
1491  hAllTimeRMSBC[i]->Write();
1492  hAllTimeAvLGBC[i]->Write();
1493  hAllTimeRMSLGBC[i]->Write();
1494  }
1495  }
1496 
1497  //AliWarning(Form("Histograms saved in %s file.",outputFile.Data()));
1498 
1499  fileNew->Close();
1500  delete fileNew;
1501 
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];
1507 
1508  if(isPAR){ //set-up histograms for different PAR time regions
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];
1516  }
1517  }
1518  }
1519  list->SetOwner(1);
1520  delete list;
1521  file->Close();
1522  delete file;
1523 
1524  //AliWarning("Pointers deleted. Memory cleaned.");
1525 }
1526 
1527 //________________________________________________________________________
1531 void AliAnalysisTaskEMCALTimeCalib::ProduceOffsetForSMsV2(Int_t runNumber,TString inputFile,TString outputFile, Bool_t offset100, Bool_t justL1phase, TString PARFilename){
1532 
1533 const Double_t lowerLimit[]={
1534  0,
1535  1152,
1536  2304,
1537  3456,
1538  4608,
1539  5760,
1540  6912,
1541  8064,
1542  9216,
1543  10368,
1544  11520,
1545  11904,
1546  12288,
1547  13056,
1548  13824,
1549  14592,
1550  15360,
1551  16128,
1552  16896,
1553  17280};
1554 
1555 const Double_t upperLimit[]={
1556  1151 ,
1557  2303 ,
1558  3455 ,
1559  4607 ,
1560  5759 ,
1561  6911 ,
1562  8063 ,
1563  9215 ,
1564  10367,
1565  11519,
1566  11903,
1567  12287,
1568  13055,
1569  13823,
1570  14591,
1571  15359,
1572  16127,
1573  16895,
1574  17279,
1575  17663};
1576 
1577  PARInfo info;
1578  info.numPARs = 0;
1579  Bool_t isPAR = kFALSE;
1580  if(PARFilename.Length() != 0){
1581  std::ifstream input;
1582  int inputrunnumber = 0, numPARs = 0;
1583  ULong64_t PAR = 0;
1584  input.open(PARFilename.Data());
1585  if(!input.good()){
1586  printf("PAR info file not accessable: %s\n", PARFilename.Data());
1587  return;
1588  }
1589  while(input.good()){
1590  input >> inputrunnumber >> numPARs;
1591  if(!input.good()) break;
1592  info.runNumber = inputrunnumber;
1593  info.numPARs = numPARs;
1594  //printf("\n\n!!!!\n\n from file: runnumber = %d, numPars = %d\n\n", info.runNumber, info.numPARs);
1595  if(numPARs <= 0 || numPARs > 10){
1596  printf("Number of PARS incorrectly found to be %d!\n", numPARs);
1597  return;
1598  }
1599  for(int iPAR = 0; iPAR < numPARs; iPAR++){
1600  input >> PAR;
1601  if(info.runNumber == runNumber){
1602  info.PARGlobalBCs.push_back(PAR);
1603  }
1604  }
1605  if(info.runNumber == runNumber) break;
1606  }
1607  input.close();
1608 
1609  if(info.runNumber != runNumber){
1610  isPAR = kFALSE;
1611  info.numPARs = 0;
1612  }else{
1613  isPAR = kTRUE;
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]);
1618  }
1619  }
1620  }
1621 
1622  TFile *file =new TFile(inputFile.Data());
1623  if(file==0x0) return;
1624 
1625  TH1F *ccBC[4];
1626  Bool_t shouldBeEmpty[4];
1627  TH1F *ccBCPAR[info.numPARs+1][4];
1628  Int_t emptyCounter;
1629  Bool_t shouldBeEmptyPAR[info.numPARs+1][4];
1630 
1631  for(Int_t i = 0; i < kNBCmask; i++){
1632  if(isPAR){
1633  for(Int_t iPAR = 0; iPAR <= info.numPARs; iPAR++){
1634  ccBCPAR[iPAR][i] = (TH1F*)file->Get(Form("hAllTimeAvPAR%dBC%d", iPAR, i));
1635  shouldBeEmptyPAR[iPAR][i]=kFALSE;
1636  emptyCounter=0;
1637  for(Int_t j=0;j<upperLimit[19];j++){
1638  if(ccBCPAR[iPAR][i]->GetBinContent(j)>0.) emptyCounter++;
1639  }
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]);
1642 
1643  }
1644  }else{
1645  ccBC[i]=(TH1F*) file->Get(Form("hAllTimeAvBC%d",i));
1646  shouldBeEmpty[i]=kFALSE;
1647  emptyCounter=0;
1648  for(Int_t j=0;j<upperLimit[19];j++){
1649  if(ccBC[i]->GetBinContent(j)>0.) emptyCounter++;
1650  }
1651  if(emptyCounter<1500) shouldBeEmpty[i]=kTRUE;
1652  printf("Non-zero channels %d BC %d should be empty: %d \n",emptyCounter,i,shouldBeEmpty[i]);
1653  }
1654  }
1655 
1656  TH1C *hRun=new TH1C(Form("h%d",runNumber),Form("h%d",runNumber),19,0,19);
1657  TH1C *hPARRun[info.numPARs+1];
1658  Int_t fitResult=0;
1659  Double_t minimumValue=10000.;
1660  Int_t minimumIndex=-1;
1661  Double_t meanBC[4];
1662 
1663  Double_t fitParameter=0;
1664  TF1 *f1=new TF1("f1","pol0",0,17664);
1665  Bool_t orderTest=kTRUE;
1666  Int_t iorder=0;//order index
1667  Int_t j=0;//BC index
1668  Int_t L1shift=0;
1669  Int_t totalValue=0;
1670 
1671  for(Int_t iPAR = 0; iPAR <= info.numPARs; iPAR++){
1672  if(iPAR != info.numPARs){
1673  hPARRun[iPAR] =new TH1C(Form("h%d_%llu", runNumber, info.PARGlobalBCs[iPAR]), Form("h%d_%llu", runNumber, info.PARGlobalBCs[iPAR]),19,0,19);
1674  }else{
1675  hPARRun[iPAR] =new TH1C(Form("h%dp%d", runNumber,iPAR), Form("h%d", runNumber),19,0,19);
1676  }
1677  for(Int_t i=0;i<20;i++){
1678  minimumValue=10000;
1679  for(j=0;j<kNBCmask;j++){
1680  if(isPAR){
1681  if(shouldBeEmptyPAR[iPAR][j]){
1682  meanBC[j]=-1;
1683  continue;
1684  }
1685  }else{
1686  if(shouldBeEmpty[j]) {
1687  meanBC[j]=-1;
1688  continue;
1689  }
1690  }
1691  if(isPAR){
1692  fitResult=ccBCPAR[iPAR][j]->Fit("f1", "CQN", "", lowerLimit[i],upperLimit[i]);
1693  }else{
1694  fitResult=ccBC[j]->Fit("f1","CQN","",lowerLimit[i],upperLimit[i]);
1695  }
1696  if(fitResult<0){
1697  //hRun->SetBinContent(i,0);//correct it please
1698  meanBC[j]=-1;
1699  if(isPAR){
1700  printf("Fit failed for SM %d BC%d, integral %f\n",i,j,ccBCPAR[iPAR][j]->Integral(lowerLimit[i],upperLimit[i]));
1701  }else{
1702  printf("Fit failed for SM %d BC%d, integral %f\n",i,j,ccBC[j]->Integral(lowerLimit[i],upperLimit[i]));
1703  }
1704  continue;
1705  } else {
1706  fitParameter = f1->GetParameter(0);
1707  }
1708  if(offset100 && (j==0 || j==1)) {
1709  //the 100 ns offset was removed in LHC15n muon_calo_pass1 and further reconstructions
1710  fitParameter+=100;
1711  }
1712  meanBC[j]=fitParameter;
1713 
1714  if(fitParameter>0 && fitParameter<minimumValue){
1715  minimumValue = fitParameter;
1716  minimumIndex = j;
1717  }
1718  }
1719 
1720  if( minimumValue/25-(Int_t)(minimumValue/25)>0.5 ) {
1721  L1shift=(Int_t)(minimumValue/25.)+1;
1722  } else {
1723  L1shift=(Int_t)(minimumValue/25.);
1724  }
1725 
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);
1728 
1729  if(justL1phase) totalValue = minimumIndex;
1730  else totalValue = L1shift<<2 | minimumIndex ;
1731  //printf("L1 phase %d, L1 shift %d *25ns= %d, L1p+L1s %d, total %d, L1pback %d, L1sback %d\n",minimumIndex,L1shift,L1shift*25,minimumIndex+L1shift,totalValue,totalValue&3,totalValue>>2);
1732 
1733  if(isPAR){
1734  hPARRun[iPAR]->SetBinContent(i,totalValue);
1735  }else{
1736  hRun->SetBinContent(i,totalValue);
1737  }
1738  orderTest=kTRUE;
1739  for(iorder=minimumIndex;iorder<minimumIndex+4-1;iorder++){
1740  if( meanBC[(iorder+1)%4] <= meanBC[iorder%4] ) orderTest=kFALSE;
1741  }
1742  if(!orderTest)
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);
1744 
1745  //patch for runs with not filled one, two or three BCs
1746  //manual patch for LHC16q - pPb@5TeV - only BC0 is filled and phase rotate
1747  if(shouldBeEmpty[0] || shouldBeEmpty[1] || shouldBeEmpty[2] || shouldBeEmpty[3]){
1748  Double_t newMean = meanBC[minimumIndex]-600;
1749  if(newMean<=12.5){
1750  if(isPAR){
1751  hPARRun[iPAR]->SetBinContent(i,minimumIndex);
1752  }else{
1753  hRun->SetBinContent(i,minimumIndex);
1754  }
1755  } else {
1756  Int_t minIndexTmp=-1;
1757  if(newMean/25. - (Int_t)(newMean/25.) <0.5)
1758  minIndexTmp = (Int_t)(newMean/25.);
1759  else
1760  minIndexTmp = 1+(Int_t)(newMean/25.);
1761 
1762  if(isPAR){
1763  hPARRun[iPAR]->SetBinContent(i,(4-minIndexTmp+minimumIndex)%4);
1764  }else{
1765  hRun->SetBinContent(i,(4-minIndexTmp+minimumIndex)%4);
1766  }
1767  //cout<<newMean/25.<<" int "<<(Int_t)(newMean/25.)<<" dif "<< newMean/25.-(Int_t)(newMean/25.)<<endl;
1768  }
1769  if(isPAR){
1770  printf("run with missing BC; new L1 phase set to %d\n",(Int_t)hPARRun[iPAR]->GetBinContent(i));
1771  }else{
1772  printf("run with missing BC; new L1 phase set to %d\n",(Int_t)hRun->GetBinContent(i));
1773  }
1774  }//end of patch for LHC16q and other runs with not filled BCs
1775  }//end of loop over SM
1776  }//end of loop over PARs
1777 
1778  delete f1;
1779  TFile *fileNew=new TFile(outputFile.Data(),"update");
1780  if(isPAR){
1781  for(Int_t iPAR = 0; iPAR <= info.numPARs; iPAR++){
1782  hPARRun[iPAR]->Write();
1783  delete hPARRun[iPAR];
1784  }
1785  }else{
1786  hRun->Write();
1787  delete hRun;
1788  }
1789  fileNew->Close();
1790  delete fileNew;
1791 
1792  file->Close();
1793  delete file;
1794 }
1795 
1796 //____________________________________________________
1798 {
1799  if(fBadChannelMapSet) return;
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());
1803  TObjArray *arrayBC=(TObjArray*)contBC->GetObject(fRunNumber);
1804  if(arrayBC) {
1805  AliInfo("Remove EMCAL bad cells");
1807  for (Int_t i=0; i<kNSM; ++i) {
1808  TH2I *hbm = (TH2I*)arrayBC->FindObject(Form("EMCALBadChannelMap_Mod%d",i));
1809  if (!hbm) {
1810  AliError(Form("Can not get EMCALBadChannelMap_Mod%d",i));
1811  continue;
1812  }
1813  hbm->SetDirectory(0);
1814  fBadChannelMapArray->AddAt(hbm,i);
1815 
1816  } // loop over SMs
1817  } else AliInfo("Do NOT remove EMCAL bad channels\n"); // run array
1818 
1819  delete contBC;
1820  fBadChannelMapSet = kFALSE;//BC map is not fixed at the beginning but can change r-by-r
1821 } // Bad channel map loaded
1822 
1823 //____________________________________________________
1825 {
1826  if(fBadChannelMapSet) return;
1827 
1828  TFile *referenceFile = TFile::Open(fBadChannelFileName.Data());
1829  if(referenceFile==0x0) {
1830  AliFatal("*** NO bad channel map FILE");
1831  }
1832 
1833  TH1F *hbm = (TH1F*)referenceFile->Get("h1");
1834  if (!hbm) {
1835  AliError("Can not get EMCALBadChannelMap");
1836  }
1837  fBadChannelMapArray = new TObjArray(1);
1838  fBadChannelMapArray->AddAt(hbm,0);
1839  fBadChannelMapSet=kTRUE;//BC map is fixed at the beginning for whole dataset
1840 } // Bad channel map loaded
1841 
1842 
1843 //_____________________________________________________________________
1848 }
1849 
1850 //_____________________________________________________________________
1851 // Load PAR info from text file
1853  std::ifstream input;
1854  int runnumber = 0, numPARs = 0, numRuns=0;
1855  ULong64_t PAR = 0;
1856  gSystem->ExpandPathName(PARFileName);
1857  //handle case of PAR file in Alien location, needs to be copied to working directory before ifstream can open.
1858  if(PARFileName.Contains("alien://")){
1859  TString localFileName(gSystem->BaseName(PARFileName.Data()));
1860  TFile::Cp(PARFileName.Data(), localFileName.Data());
1861  PARFileName = localFileName;
1862  }
1863  input.open(PARFileName.Data());
1864  if(!input.good()){
1865  AliFatal(Form("PAR info file not accessable: %s", PARFileName.Data()));
1866  }
1867  while(input.good()){
1868  input >> runnumber >> numPARs;
1869  if(!input.good()) break;
1870  PARInfo info;
1871  info.runNumber = runnumber;
1872  info.numPARs = numPARs;
1873  //printf("\n\n!!!!\n\n from file: runnumber = %d, numPars = %d\n\n", info.runNumber, info.numPARs);
1874  if(numPARs <= 0 || numPARs > 10){
1875  AliFatal(Form("Number of PARS incorrectly found to be %d!", numPARs));
1876  }
1877  for(int iPAR = 0; iPAR < numPARs; iPAR++){
1878  input >> PAR;
1879  info.PARGlobalBCs.push_back(PAR);
1880  }
1881  fPARvec.push_back(info);
1882  numRuns++;
1883  }
1884  printf("number of runs processed in PAR file: %d\n", numRuns);
1885  input.close();
1886 }
1887 
1888 //_______________________________________________________________________
1889 // Get Par info for the current run number, set-up PAR info variables
1891  if(runnum < 200000) AliFatal(Form("Bad Run Number %d passed to GetPARInfo!", runnum));
1892  if(fRunNumber!=runnum) fRunNumber = runnum;
1893  fIsPARRun = kFALSE;
1895  for(unsigned int iPARrun = 0; iPARrun < fPARvec.size(); iPARrun++){
1896  //printf("from stored vectors: %d %d", fPARvec[iPARrun].runNumber, fPARvec[iPARrun].numPARs);
1897  //for(int i = 0; i < fPARvec[iPARrun].numPARs; i++){
1898  // printf(" %llu", fPARvec[iPARrun].PARGlobalBCs[i]);
1899  //}
1900  //printf("\n");
1901  if (fRunNumber==fPARvec[iPARrun].runNumber){
1902  //set PAR flag & setup copy of specific PAR info
1903  fIsPARRun = kTRUE;
1905  fCurrentPARs.numPARs = fPARvec[iPARrun].numPARs;
1906  for(int ipar = 0; ipar < fPARvec[iPARrun].numPARs; ipar++){
1907  fCurrentPARs.PARGlobalBCs.push_back(fPARvec[iPARrun].PARGlobalBCs[ipar]);
1908  }
1909  }
1910  }
1911 }
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
Bool_t AcceptCluster(AliVCluster *clus)
Selection criteria of good cluster are set here.
TH2F * fhRawTimeVsIdBC[kNBCmask]
! 4 BCmask HG
double Double_t
Definition: External.C:58
Int_t fFineNbins
number of bins of histo with T0 time
Definition: External.C:236
TH1F * fhRawTimeSumSqBC[kNBCmask]
! 4 BCmask HG
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
!
TSystem * gSystem
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
void LoadBadChannelMap()
Load Bad Channel Map from different source.
Double_t fRawTimeMin
lower range of histo with raw time
TH2F * fhTimeDsupLG[kNSM]
! 20 SM low gain
TH1F * fhRawTimeSumSqLGBC[kNBCmask]
! 4 BCmask LG
Double_t fMaxRtrack
maximum cluster track distance
Double_t fMaxLambda0
maximum cluster lambda0
AliEMCALGeometry * fgeom
pointer to EMCal geometry
Double_t fRawTimeMax
upper range of histo with raw time
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
int Int_t
Definition: External.C:63
std::vector< std::vector< TH2F * > > fhRawTimePARs
!
Double_t fEnergyMax
upper range of histo with energy HG
Double_t fMinClusterEnergy
minimum cluster energy
float Float_t
Definition: External.C:68
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
Definition: External.C:228
virtual void UserExec(Option_t *option)
Main loop executed for each event.
virtual void PrepareTOFT0maker()
Get T0 time from TOF.
Bool_t fPileupFromSPD
flag to set PileupFromSPD
TH1F * fhRawTimeSumBC[kNBCmask]
! 4 BCmask HG
Double_t fMinCellEnergy
minimum cell energy
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
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
TFile * file
TList with histograms for a given trigger.
TH2F * fhTimeVsIdLGBC[kNBCmask]
! 4 BCmask LG
unsigned short UShort_t
Definition: External.C:28
const char Option_t
Definition: External.C:48
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.
bool Bool_t
Definition: External.C:53
TString fBadChannelFileName
name of file with bad channels
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 fRawTimeNbins
number of bins of histo with raw time
TH2F * fhTimeDsup[kNSM]
! 20 SM high gain
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