AliPhysics  eb0e5d9 (eb0e5d9)
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  fRunNumber(-1),
69  // fTOFmaker(0),
70  fOutputList(0x0),
71  fgeom(0),
72  fGeometryName(),
73  fMinClusterEnergy(0),
74  fMaxClusterEnergy(0),
75  fMinNcells(0),
76  fMaxNcells(0),
77  fMinLambda0(0),
78  fMaxLambda0(0),
79  fMinLambda0LG(0),
80  fMaxLambda0LG(0),
81  fMaxRtrack(0),
82  fMinCellEnergy(0),
83  fReferenceFileName(),
84  fReferenceRunByRunFileName(),
85  fPileupFromSPD(kFALSE),
86  fMinTime(0),
87  fMaxTime(0),
88  fMostEneCellOnly(kFALSE),
89  fRawTimeNbins (0),
90  fRawTimeMin (0),
91  fRawTimeMax (0),
92  fPassTimeNbins(0),
93  fPassTimeMin (0),
94  fPassTimeMax (0),
95  fEnergyNbins (0),
96  fEnergyMin(0),
97  fEnergyMax(0),
98  fEnergyLGNbins (0),
99  fEnergyLGMin(0),
100  fEnergyLGMax(0),
101  fFineNbins(0),
102  fFineTmin(0),
103  fFineTmax(0),
104  fL1PhaseList(0),
105  fBadReco(kFALSE),
106  fFillHeavyHisto(kFALSE),
107  fBadChannelMapArray(),
108  fBadChannelMapSet(kFALSE),
109  fSetBadChannelMapSource(0),
110  fBadChannelFileName(),
111  fhcalcEvtTime(0),
112  fhEvtTimeHeader(0),
113  fhEvtTimeDiff(0),
114  fhEventType(0),
115  fhTOFT0vsEventNumber(0),
116  fhTcellvsTOFT0(0),
117  fhTcellvsTOFT0HD(0),
118  fhTcellvsSM(0),
119  fhEneVsAbsIdHG(0),
120  fhEneVsAbsIdLG(0),
121  fhTimeVsBC(0),
122  fhTimeSumSq(),
123  fhTimeEnt(),
124  fhTimeSum(),
125  fhTimeLGSumSq(),
126  fhTimeLGEnt(),
127  fhTimeLGSum(),
128  fhAllAverageBC(),
129  fhAllAverageLGBC(),
130  fhRefRuns(0),
131  fhTimeDsup(),
132  fhTimeDsupBC(),
133  fhTimeDsupLG(),
134  fhTimeDsupLGBC(),
135  fhRawTimeVsIdBC(),
136  fhRawTimeSumBC(),
137  fhRawTimeEntriesBC(),
138  fhRawTimeSumSqBC(),
139  fhRawTimeVsIdLGBC(),
140  fhRawTimeSumLGBC(),
141  fhRawTimeEntriesLGBC(),
142  fhRawTimeSumSqLGBC(),
143  fhRawCorrTimeVsIdBC(),
144  fhRawCorrTimeVsIdLGBC(),
145  fhTimeVsIdBC(),
146  fhTimeVsIdLGBC()
147 {
148  for(Int_t i = 0; i < kNBCmask; i++)
149  {
150  fhAllAverageBC[i]=0;
151  fhAllAverageLGBC[i]=0;
152 
153  fhTimeSumSq[i]=0;
154  fhTimeEnt[i]=0;
155  fhTimeSum[i]=0;
156 
157  fhTimeLGSumSq[i]=0;
158  fhTimeLGEnt[i]=0;
159  fhTimeLGSum[i]=0;
160 
161  fhRawTimeVsIdBC[i]=0;
162  fhRawTimeSumBC[i]=0;
163  fhRawTimeEntriesBC[i]=0;
164  fhRawTimeSumSqBC[i]=0;
165 
166  fhRawTimeVsIdLGBC[i]=0;
167  fhRawTimeSumLGBC[i]=0;
169  fhRawTimeSumSqLGBC[i]=0;
170  fhRawCorrTimeVsIdBC[i]=0;
172  fhTimeVsIdBC[i]=0;
173  fhTimeVsIdLGBC[i]=0;
174 
175  }
176 
177  //set default cuts for calibration and geometry name
178  SetDefaultCuts();
179 
180  //T0 TOF time
182 
183  // Define input and output slots here
184  // Input slot #0 works with a TChain
185  DefineInput(0, TChain::Class());
186 
187  // Output slot #0 id reserved by the base class for AOD
188  // Output slot #1 writes into a TH1 container
189  DefineOutput(1, TList::Class());
190 
191 } // End ctor
192 
193 //_____________________________________________________________________
199 //void AliAnalysisTaskEMCALTimeCalib::LocalInit()
200 //{
201 // AliDebug(1,"AliAnalysisTaskEMCALTimeCalib::LocalInit()");
202 //}
203 
205 //_____________________________________________________________________
207 {
208  if(fReferenceFileName.Length()!=0){
209  TFile *myFile = TFile::Open(fReferenceFileName.Data());
210  AliInfo(Form("Reference file: %s, pointer %p",fReferenceFileName.Data(),myFile));
211  if(myFile==0x0) {
212  AliFatal("*** NO REFERENCE FILE");
213  } else {
214  AliDebug(1,"*** OK TFILE");
215  // connect ref run here
216  for(Int_t i = 0; i < kNBCmask; i++)
217  {
218  fhAllAverageBC[i]=(TH1F*) myFile->Get(Form("hAllTimeAvBC%d",i));
219  if(fhAllAverageBC[i]==0x0) AliFatal(Form("Reference histogram for BC%d does not exist",i));
220  if(fhAllAverageBC[i]->GetEntries()==0)AliWarning(Form("fhAllAverageLGBC[%d]->GetEntries() = 0",i));
221  fhAllAverageLGBC[i]=(TH1F*) myFile->Get(Form("hAllTimeAvLGBC%d",i));
222  if(fhAllAverageLGBC[i]==0x0) AliFatal(Form("Reference LG histogram for BC%d does not exist",i));
223  if(fhAllAverageLGBC[i]->GetEntries()==0)AliFatal(Form("fhAllAverageLGBC[%d]->GetEntries() = 0",i));
224  }
225 
226  AliDebug(1,Form("hAllAverage entries BC0 %d", (Int_t)fhAllAverageBC[0]->GetEntries() ));
227  AliDebug(1,Form("hAllAverage entries BC2 %d",(Int_t)fhAllAverageBC[2]->GetEntries() ));
228  AliDebug(1,Form("hAllAverageLG entries BC0 %d", (Int_t)fhAllAverageLGBC[0]->GetEntries() ));
229  AliDebug(1,Form("hAllAverageLG entries BC2 %d",(Int_t)fhAllAverageLGBC[2]->GetEntries() ));
230 
231  }
232  } else { //end of reference file is provided
233  AliFatal("You require to load reference histos from file but FILENAME is not provided");
234  }
235 } // End of AliAnalysisTaskEMCALTimeCalib::LoadReferenceHistos()
236 
239 //_____________________________________________________________________
241 {
242  // connect ref run here
243  if(fReferenceRunByRunFileName.Length()!=0){
244  TFile *referenceFile = TFile::Open(fReferenceRunByRunFileName.Data());
245  if(referenceFile==0x0) {
246  AliFatal("*** NO REFERENCE R-B-R FILE");
247  return;
248  } else {
249  AliInfo(Form("Reference R-b-R file: %s, pointer %p",fReferenceRunByRunFileName.Data(),referenceFile));
250 
251  //load L1 phases to memory
252  fL1PhaseList=new TObjArray(referenceFile->GetNkeys());
253  TIter next(referenceFile->GetListOfKeys());
254  TKey *key;
255  while ((key=(TKey*)next())) {
256  fL1PhaseList->AddLast((TH1F*)referenceFile->Get(key->GetName()) );
257  //printf("key: %s points to an object of class: %s at %dn",key->GetName(),key->GetClassName(),key->GetSeekKey());
258  }
259  }
260  } else { //reference file is not provided
261  AliFatal("You require to load reference run-by-run histos from file but FILENAME is not provided");
262  return;
263  }
264 } // End of AliAnalysisTaskEMCALTimeCalib::LoadReferenceRunByRunHistos()
265 
270 {
271  fhRefRuns=NULL;
272  if(!fL1PhaseList) {
273  AliFatal("Array with reference L1 phase histograms do not exist in memory");
274  return;
275  }
276  if(fRunNumber<0) {
277  AliFatal("Negative run number");
278  return;
279  }
280 
281  fhRefRuns=(TH1C*)fL1PhaseList->FindObject(Form("h%d",fRunNumber));
282  if(fhRefRuns==0x0){
283  AliError(Form("Reference histogram for run %d does not exist. Use Default",fRunNumber));
284  fhRefRuns=(TH1C*)fL1PhaseList->FindObject("h0");
285  }
286  if(fhRefRuns==0x0) {
287  AliFatal(Form("No default histogram with L1 phases! Add default histogram to file %s!!!",fReferenceRunByRunFileName.Data()));
288  return;
289  }
290 
291  AliDebug(1,Form("Reference R-b-R histo %p, list %p, run number %d",fhRefRuns,fL1PhaseList,fRunNumber));
292  if(fhRefRuns->GetEntries()==0)AliWarning("fhRefRuns->GetEntries() = 0");
293  AliDebug(1,Form("hRefRuns entries %d", (Int_t)fhRefRuns->GetEntries() ));
294 }
295 
296 //_____________________________________________________________________
300 {
301  AliDebug(1,"AnalysisTaskEMCalTimeCalib::NotifyRun()");
302  AliDebug(2,Form("Notify(): EMCal geometry: fgeom = %p, fGeometryName=%s\n ",fgeom,fGeometryName.Data()));
303 
304  if (!InputEvent())
305  {
306  AliFatal("ERROR: InputEvent not set");
307  return;
308  }
309  else AliDebug(1,"Good, InputEvent set");
310 
311  // AliInfo(Form("NotifyRun, fCurrentRunnumber %d",fCurrentRunNumber));
312  fRunNumber = InputEvent()->GetRunNumber();
313  AliDebug(1,Form("RunNumber %d", fRunNumber));
314 
315  // Init EMCAL geometry
316  if (!fgeom) SetEMCalGeometry();
317  //Init EMCAL geometry done
318 
319  //set L1 phases for current run
320  if(fReferenceRunByRunFileName.Length()!=0)
322 
323  // set bad channel map
325 
326  return;
327 }
328 
329 //_____________________________________________________________________
332 {
333  AliDebug(1,"AliAnalysisTaskEMCALTimeCalib::SetEMCalGeometry()");
334  if(fGeometryName.Length()==0){
335  fgeom=AliEMCALGeometry::GetInstanceFromRunNumber(fRunNumber);
336  AliInfo(Form("Get EMCAL geometry name <%s> for run %d",fgeom->GetName(),fRunNumber));
337  } else {
338  fgeom = AliEMCALGeometry::GetInstance(fGeometryName.Data());
339  AliInfo(Form("Set EMCAL geometry name to <%s>",fGeometryName.Data()));
340  }
341 
342  if (!fgeom){
343  AliWarning("Make sure the EMCal geometry is set properly !");
344  } else {
345  AliDebug(1,Form("EMCal geometry properly set: fGeom = %p, fGeometryName=%s",fgeom,fGeometryName.Data()));
346  }
347 
348  return kTRUE;
349 }
350 
351 //_____________________________________________________________________
354 {
355  //method under development
356  AliInfo(Form("<D> -- Run # = %d", fRunNumber));
357  AliInfo("prepare TOFT0maker!!");
358  //cout<<"Run "<< fRunNumber<<" in TOFT0maker"<<endl;
359 
360 
361  AliCDBManager * cdb = AliCDBManager::Instance();
362  cdb->SetDefaultStorage("raw://");
363  cdb->SetRun(fRunNumber);
364 
365 // AliESDpid *extPID=new AliESDpid();
366 //
367 // // Wonder if some have to be declared as private variables??
368 // // AliESDpid *extPID = new AliESDpid();
369 // // AliTOFcalib * tofCalib = new AliTOFcalib();
370 // // tofCalib->SetCalibrateTOFsignal(kTRUE);
371 // // tofCalib->Init();
372 //
373 // fTOFmaker = new AliTOFT0maker(extPID);
374 // fTOFmaker->SetTimeResolution(115.0); // if you want set the TOF res
375 // // fTOFmaker = new AliTOFT0maker(extPID,tofCalib);
376 // // fTOFmaker->SetTimeResolution(130.0);
377 //
378 // //cout<<"extPID "<<extPID<<" fTOFmaker "<<fTOFmaker<<endl;
379 
380 }// End PrepareTOFT0maker
381 
382 //________________________________________________________________________
386 {
387  AliDebug(1,"AliAnalysisTaskEMCALTimeCalib::UserCreateOutputObjects()");
388 
389  const Int_t nChannels = 17664;
390  //book histograms
391  if(fFillHeavyHisto){
392  fhcalcEvtTime = new TH1F("fhcalcEvtTime","calculated event time from T0",fFineNbins, fFineNbins,fFineTmax);
393  fhcalcEvtTime->GetXaxis()->SetTitle("T ");
394  fhcalcEvtTime->GetYaxis()->SetTitle("Counts (a.u.)");
395 
396  fhEvtTimeHeader = new TH1F("fhEvtTimeHeader","event time from header",fFineNbins, fFineNbins,fFineTmax);
397  fhEvtTimeHeader->GetXaxis()->SetTitle("T ");
398  fhEvtTimeHeader->GetYaxis()->SetTitle("Counts (a.u.)");
399 
400  fhEvtTimeDiff = new TH1F("fhEvtTimeDiff","event time difference",fFineNbins, fFineNbins,fFineTmax);
401  fhEvtTimeDiff->GetXaxis()->SetTitle("#Delta T ");
402  fhEvtTimeDiff->GetYaxis()->SetTitle("Counts (a.u.)");
403  }
404 
405  fhEventType = new TH1F("fhEventType","event type",10, 0.,10.);
406  //fhEventType ->GetXaxis()->SetTitle("Type ");
407  fhEventType->GetXaxis()->SetBinLabel(1 ,"1=No ESD");
408  fhEventType->GetXaxis()->SetBinLabel(2 ,"2=Pileup");
409  fhEventType->GetXaxis()->SetBinLabel(3 ,"3=No Trigger");
410  fhEventType->GetXaxis()->SetBinLabel(4 ,"4=Evt Type != 7");
411  fhEventType->GetXaxis()->SetBinLabel(5 ,"5=INT7,8");
412  fhEventType->GetXaxis()->SetBinLabel(6 ,"6=EMC7,8");
413  fhEventType->GetXaxis()->SetBinLabel(7 ,"7=L1 EMCal");
414  fhEventType->GetXaxis()->SetBinLabel(8 ,"8=DMC7,8");
415  fhEventType->GetXaxis()->SetBinLabel(9 ,"9=L1 DCal");
416 
417 
418  fhEventType ->GetYaxis()->SetTitle("Counts (a.u.)");
419  if(fFillHeavyHisto){
420  fhTcellvsTOFT0 = new TH2F("hTcellvsTOFT0", " T_cell vs TOFT0", 500,-600.0,+400.0,fRawTimeNbins,fRawTimeMin,fRawTimeMax);
421  fhTcellvsTOFT0HD = new TH2F("hTcellvsTOFT0HD", " T_cell vs TOFT0,HighEnergy", 500,-600.0,+400.0,4*fRawTimeNbins,fRawTimeMin,fRawTimeMax);
422  }
423  fhTcellvsSM = new TH2F("hTcellvsSM", " T_cell vs SM", (Int_t)kNSM,0,(Double_t)kNSM,(Int_t)(fRawTimeNbins/2),fRawTimeMin,fRawTimeMax);
424 
425  if(fFillHeavyHisto){
426  fhEneVsAbsIdHG = new TH2F("fhEneVsAbsIdHG", "energy vs ID for HG",1000,0,18000,200,0,10);
427  fhEneVsAbsIdLG = new TH2F("fhEneVsAbsIdLG", "energy vs ID for LG",1000,0,18000,200,0,40);
428  }
429 
430  for (Int_t i = 0; i < kNBCmask ; i++)
431  {
432  //already after correction
433  //high gain
434  fhTimeSumSq[i] = new TH1F(Form("hTimeSumSq%d", i),
435  Form("cell Sum Square time HG, BC %d ", i),
436  nChannels,0.,(Double_t)nChannels);
437  fhTimeSumSq[i]->SetYTitle("Sum Sq Time ");
438  fhTimeSumSq[i]->SetXTitle("AbsId");
439 
440  fhTimeSum[i] = new TH1F(Form("hTimeSum%d", i),
441  Form("cell Sum time HG, BC %d ", i),
442  nChannels,0.,(Double_t)nChannels);
443  fhTimeSum[i]->SetYTitle("Sum Time ");
444  fhTimeSum[i]->SetXTitle("AbsId");
445 
446  fhTimeEnt[i] = new TH1F(Form("hTimeEnt%d", i),
447  Form("cell Entries HG, BC %d ", i),
448  nChannels,0.,(Double_t)nChannels);
449  fhTimeEnt[i]->SetYTitle("Entries for Time ");
450  fhTimeEnt[i]->SetXTitle("AbsId");
451 
452  //low gain
453  fhTimeLGSumSq[i] = new TH1F(Form("hTimeLGSumSq%d", i),
454  Form("cell Sum Square time LG, BC %d ", i),
455  nChannels,0.,(Double_t)nChannels);
456  fhTimeLGSumSq[i]->SetYTitle("Sum Sq Time ");
457  fhTimeLGSumSq[i]->SetXTitle("AbsId");
458 
459  fhTimeLGSum[i] = new TH1F(Form("hTimeLGSum%d", i),
460  Form("cell Sum time LG, BC %d ", i),
461  nChannels,0.,(Double_t)nChannels);
462  fhTimeLGSum[i]->SetYTitle("Sum Time ");
463  fhTimeLGSum[i]->SetXTitle("AbsId");
464 
465  fhTimeLGEnt[i] = new TH1F(Form("hTimeLGEnt%d", i),
466  Form("cell Entries LG, BC %d ", i),
467  nChannels,0.,(Double_t)nChannels);
468  fhTimeLGEnt[i]->SetYTitle("Entries for Time ");
469  fhTimeLGEnt[i]->SetXTitle("AbsId");
470 
471  //raw time histograms
472  //high gain
473  if(fFillHeavyHisto){
474  fhRawTimeVsIdBC[i] = new TH2F(Form("RawTimeVsIdBC%d", i),
475  Form("cell raw time vs ID for high gain BC %d ", i),
476  nChannels,0.,(Double_t)nChannels,fRawTimeNbins,fRawTimeMin,fRawTimeMax);
477  fhRawTimeVsIdBC[i]->SetXTitle("AbsId");
478  fhRawTimeVsIdBC[i]->SetYTitle("Time");
479  }
480 
481  fhRawTimeSumBC[i] = new TH1F(Form("RawTimeSumBC%d", i),
482  Form("sum of cell raw time for high gain BC %d ", i),
483  nChannels,0.,(Double_t)nChannels);
484  fhRawTimeSumBC[i]->SetXTitle("AbsId");
485  fhRawTimeSumBC[i]->SetYTitle("Sum Time");
486 
487  fhRawTimeEntriesBC[i] = new TH1F(Form("RawTimeEntriesBC%d", i),
488  Form("No. entries of cells raw time for high gain BC %d ", i),
489  nChannels,0.,(Double_t)nChannels);
490  fhRawTimeEntriesBC[i]->SetXTitle("AbsId");
491  fhRawTimeEntriesBC[i]->SetYTitle("Entries for Time ");
492 
493  fhRawTimeSumSqBC[i] = new TH1F(Form("RawTimeSumSqBC%d", i),
494  Form("sum of (cell raw time)^2 for high gain BC %d ", i),
495  nChannels,0.,(Double_t)nChannels);
496  fhRawTimeSumSqBC[i]->SetXTitle("AbsId");
497  fhRawTimeSumSqBC[i]->SetYTitle("Sum Sq Time");
498 
499  //low gain
500  if(fFillHeavyHisto){
501  fhRawTimeVsIdLGBC[i] = new TH2F(Form("RawTimeVsIdLGBC%d", i),
502  Form("cell raw time vs ID for low gain BC %d ", i),
503  nChannels,0.,(Double_t)nChannels,fRawTimeNbins,fRawTimeMin,fRawTimeMax);
504  fhRawTimeVsIdLGBC[i]->SetXTitle("AbsId");
505  fhRawTimeVsIdLGBC[i]->SetYTitle("Time");
506  }
507 
508  fhRawTimeSumLGBC[i] = new TH1F(Form("RawTimeSumLGBC%d", i),
509  Form("sum of cell raw time for low gain BC %d ", i),
510  nChannels,0.,(Double_t)nChannels);
511  fhRawTimeSumLGBC[i]->SetXTitle("AbsId");
512  fhRawTimeSumLGBC[i]->SetYTitle("Sum Time");
513 
514  fhRawTimeEntriesLGBC[i] = new TH1F(Form("RawTimeEntriesLGBC%d", i),
515  Form("No. entries of cells raw time for low gain BC %d ", i),
516  nChannels,0.,(Double_t)nChannels);
517  fhRawTimeEntriesLGBC[i]->SetXTitle("AbsId");
518  fhRawTimeEntriesLGBC[i]->SetYTitle("Entries for Time ");
519 
520  fhRawTimeSumSqLGBC[i] = new TH1F(Form("RawTimeSumSqLGBC%d", i),
521  Form("sum of (cell raw time)^2 for low gain BC %d ", i),
522  nChannels,0.,(Double_t)nChannels);
523  fhRawTimeSumSqLGBC[i]->SetXTitle("AbsId");
524  fhRawTimeSumSqLGBC[i]->SetYTitle("Sum Sq Time");
525 
526  //histograms with corrected raw time for L1 shift and 100ns
527  if(fBadReco && fFillHeavyHisto){
528  fhRawCorrTimeVsIdBC[i] = new TH2F(Form("RawCorrTimeVsIdBC%d", i),
529  Form("cell L1 shift and 100ns corrected raw time vs ID for high gain BC %d ", i),
530  nChannels,0.,(Double_t)nChannels,fPassTimeNbins,fPassTimeMin,fPassTimeMax);
531  fhRawCorrTimeVsIdBC[i]->SetXTitle("AbsId");
532  fhRawCorrTimeVsIdBC[i]->SetYTitle("Time");
533 
534  fhRawCorrTimeVsIdLGBC[i] = new TH2F(Form("RawCorrTimeVsIdLGBC%d", i),
535  Form("cell L1 shift and 100ns corrected raw time vs ID for low gain BC %d ", i),
536  nChannels,0.,(Double_t)nChannels,fPassTimeNbins,fPassTimeMin,fPassTimeMax);
537  fhRawCorrTimeVsIdLGBC[i]->SetXTitle("AbsId");
538  fhRawCorrTimeVsIdLGBC[i]->SetYTitle("Time");
539  }
540 
541  //histograms with corrected raw time for L1 shift and 100ns + new L1 phase
542  if(fReferenceRunByRunFileName.Length()!=0 && fFillHeavyHisto){
543  fhTimeVsIdBC[i] = new TH2F(Form("TimeVsIdBC%d", i),
544  Form("cell time corrected for L1 shift, 100ns and L1 phase vs ID for high gain BC %d ", i),
545  nChannels,0.,(Double_t)nChannels,fPassTimeNbins,fPassTimeMin,fPassTimeMax);
546  fhTimeVsIdBC[i]->SetXTitle("AbsId");
547  fhTimeVsIdBC[i]->SetYTitle("Time");
548 
549  fhTimeVsIdLGBC[i] = new TH2F(Form("TimeVsIdLGBC%d", i),
550  Form("cell time corrected for L1 shift, 100ns and L1 phase vs ID for low gain BC %d ", i),
551  nChannels,0.,(Double_t)nChannels,fPassTimeNbins,fPassTimeMin,fPassTimeMax);
552  fhTimeVsIdLGBC[i]->SetXTitle("AbsId");
553  fhTimeVsIdLGBC[i]->SetYTitle("Time");
554  }
555 
556  for (Int_t j = 0; j < kNSM ; j++)
557  {
558  //High gain
559  //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);
560  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);
561  fhTimeDsupBC[j][i]->SetYTitle(" Time (ns) ");
562  fhTimeDsupBC[j][i]->SetXTitle(" E (GeV) ");
563 
564  //low gain
565  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);
566  fhTimeDsupLGBC[j][i]->SetYTitle(" Time (ns) ");
567  fhTimeDsupLGBC[j][i]->SetXTitle(" E (GeV) ");
568  }
569  }
570 
571  for (Int_t jj = 0; jj < kNSM ; jj++)
572  {
573  //high gain
574  fhTimeDsup[jj] = new TH2F(Form("SupMod%d",jj), Form("SupMod %d time_vs_E, high gain",jj),fEnergyNbins,fEnergyMin,fEnergyMax,fPassTimeNbins,fPassTimeMin,fPassTimeMax);
575  fhTimeDsup[jj]->SetYTitle(" Time (ns) ");
576  fhTimeDsup[jj]->SetXTitle(" E (GeV) ");
577 
578  //low gain
579  fhTimeDsupLG[jj] = new TH2F(Form("SupMod%dLG",jj), Form("SupMod %d time_vs_E, low gain ",jj),fEnergyLGNbins,fEnergyLGMin,fEnergyLGMax,fPassTimeNbins,fPassTimeMin,fPassTimeMax);
580  fhTimeDsupLG[jj]->SetYTitle(" Time (ns) ");
581  fhTimeDsupLG[jj]->SetXTitle(" E (GeV) ");
582  }
583 
584  fhTimeVsBC = new TH2F("TimeVsBC"," SupMod time_vs_BC ", 4001,-0.5,4000.5,(Int_t)(fRawTimeNbins/2.),fRawTimeMin,fRawTimeMax);
585 
586 
587  //add histos to list
588  fOutputList = new TList();
589  fOutputList->Add(fhEventType);
590  if(fFillHeavyHisto){
594 
599  }
600  fOutputList->Add(fhTcellvsSM);
601 
602  for (Int_t i = 0; i < kNBCmask ; i++)
603  {
604  fOutputList->Add(fhTimeSumSq[i]);
605  fOutputList->Add(fhTimeEnt[i]);
606  fOutputList->Add(fhTimeSum[i]);
607 
608  fOutputList->Add(fhTimeLGSumSq[i]);
609  fOutputList->Add(fhTimeLGEnt[i]);
610  fOutputList->Add(fhTimeLGSum[i]);
611 
612  if(fFillHeavyHisto) {
613  fOutputList->Add(fhRawTimeVsIdBC[i]);
615  }
616 
617  fOutputList->Add(fhRawTimeSumBC[i]);
619  fOutputList->Add(fhRawTimeSumSqBC[i]);
620 
621  fOutputList->Add(fhRawTimeSumLGBC[i]);
624 
625  if(fBadReco && fFillHeavyHisto) {
628  }
629  if(fReferenceRunByRunFileName.Length()!=0 && fFillHeavyHisto) {
630  fOutputList->Add(fhTimeVsIdBC[i]);
631  fOutputList->Add(fhTimeVsIdLGBC[i]);
632  }
633 
634  for (Int_t j = 0; j < kNSM ; j++){
635  fOutputList->Add(fhTimeDsupBC[j][i]);
636  fOutputList->Add(fhTimeDsupLGBC[j][i]);
637  }
638  }
639 
640  for (Int_t j = 0; j < kNSM ; j++)
641  {
642  fOutputList->Add(fhTimeDsup[j]);
643  fOutputList->Add(fhTimeDsupLG[j]);
644  }
645 
646  fOutputList->Add(fhTimeVsBC);
647 
648  fOutputList->SetOwner(kTRUE);
649  PostData(1,fOutputList);
650 
651 
652 } // End of AliAnalysisTaskEMCALTimeCalib::UserCreateOuputObjects()
653 
654 //________________________________________________________________________
657 {
658  // Called for each event
659  AliDebug(2,Form("UserExec: EMCal geometry: fgeom = %p fGeometryName %s",fgeom,fGeometryName.Data()));
660  AliVEvent *event = InputEvent();
661  //cout<<"T0TOF "<<event->GetT0TOF()<<endl;//bad idea
662  //cout<< fEvent->GetTOFHeader()->GetDefaultEventTimeVal()<<endl;
663  AliDebug(2,Form("TOF time from header %f ps",event->GetTOFHeader()->GetDefaultEventTimeVal()));
664  if(fFillHeavyHisto) fhEvtTimeHeader->Fill(event->GetTOFHeader()->GetDefaultEventTimeVal());
665 
666  //fEvent = dynamic_cast<AliESDEvent*>(event);
667  if (!event) {
668  AliError("ESD not available, exit");
669  fhEventType->Fill(0.5);
670  return;
671  }
672 
673  if(fPileupFromSPD==kTRUE){
674  if(event->IsPileupFromSPD(3,0.8,3.,2.,5.)){
675  AliDebug(1,"Event: PileUp skip.");
676  fhEventType->Fill(1.5);
677  return;
678  }
679  }
680 
681  TString triggerclasses = event->GetFiredTriggerClasses();
682  if(triggerclasses=="") {
683  fhEventType->Fill(2.5);
684  return;
685  }
686 
687  Int_t eventType = ((AliVHeader*)event->GetHeader())->GetEventType();
688  // physics events eventType=7, select only those
689  AliDebug(1,Form("Triggerclasses %s, eventType %d",triggerclasses.Data(),eventType));
690  if(eventType != 7) {
691  fhEventType->Fill(3.5);
692  return;
693  }
694 
695  // Check trigger
696  Bool_t bMB = kFALSE;
697  Bool_t bL0 = kFALSE;
698  Bool_t bL1G = kFALSE;
699  Bool_t bL1J = kFALSE;
700  Bool_t bDL0 = kFALSE;
701  Bool_t bDL1G = kFALSE;
702  Bool_t bDL1J = kFALSE;
703 
704  if(triggerclasses.Contains("CINT7-B-NOPF-ALLNOTRD") ||
705  triggerclasses.Contains("CINT7-I-NOPF-ALLNOTRD") ||
706  triggerclasses.Contains("CINT1-I-NOPF-ALLNOTRD") ||
707  triggerclasses.Contains("CINT1-B-NOPF-ALLNOTRD") ||
708  triggerclasses.Contains("CINT8") ||
709  triggerclasses.Contains("CINT7") ||
710  triggerclasses.Contains("CPBI2_B1-B-NOPF-ALLNOTRD") ) bMB = kTRUE;
711 
712  if(triggerclasses.Contains("CEMC7-B-NOPF-CENTNOTRD") ||
713  triggerclasses.Contains("CEMC1-B-NOPF-CENTNOTRD") ||
714  triggerclasses.Contains("CEMC7") ||
715  triggerclasses.Contains("CEMC8") ||
716  triggerclasses.Contains("CEMC8-B-NOPF-CENTNOTRD") ) bL0 = kTRUE;
717 
718  if(triggerclasses.Contains("CDMC7-B-NOPF-CENTNOTRD") ||
719  triggerclasses.Contains("CDMC1-B-NOPF-CENTNOTRD") ||
720  triggerclasses.Contains("CDMC7") ||
721  triggerclasses.Contains("CDMC8") ||
722  triggerclasses.Contains("CDMC8-B-NOPF-CENTNOTRD") ) bDL0 = kTRUE;
723 
724  if(triggerclasses.Contains("CEMC7EG1-B-NOPF-CENTNOTRD") ||
725  triggerclasses.Contains("CEMC7EG2-B-NOPF-CENTNOTRD") ||
726  triggerclasses.Contains("CEMC8EG1-B-NOPF-CENTNOTRD") ||
727  triggerclasses.Contains("CEMC8EGA") ||
728  triggerclasses.Contains("CEMC7EGA") ||
729  triggerclasses.Contains("CEMC7EG1-B") ||
730  triggerclasses.Contains("CEMC7EG2-B") ||
731  triggerclasses.Contains("CPBI2EGA") ) bL1G = kTRUE;
732 
733  if(triggerclasses.Contains("CDMC7DG1-B-NOPF-CENTNOTRD") ||
734  triggerclasses.Contains("CDMC7DG2-B-NOPF-CENTNOTRD") ||
735  triggerclasses.Contains("CDMC8DG1-B-NOPF-CENTNOTRD") ||
736  triggerclasses.Contains("CDMC8DGA") ||
737  triggerclasses.Contains("CDMC7DGA") ||
738  triggerclasses.Contains("CDMC7DG1-B") ||
739  triggerclasses.Contains("CDMC7DG2-B") ||
740  triggerclasses.Contains("CPBI2DGA") ) bDL1G = kTRUE;
741 
742  if(triggerclasses.Contains("CEMC7EJ1-B-NOPF-CENTNOTRD") ||
743  triggerclasses.Contains("CEMC7EJ2-B-NOPF-CENTNOTRD") ||
744  triggerclasses.Contains("CEMC8EJ1-B-NOPF-CENTNOTRD") ||
745  triggerclasses.Contains("CEMC7EJE") ||
746  triggerclasses.Contains("CEMC8EJE") ||
747  triggerclasses.Contains("CEMC7EJ1-B") ||
748  triggerclasses.Contains("CEMC7EJ2-B") ||
749  triggerclasses.Contains("CPBI2EJE") ) bL1J = kTRUE;
750 
751  if(triggerclasses.Contains("CDMC7DJ1-B-NOPF-CENTNOTRD") ||
752  triggerclasses.Contains("CDMC7DJ2-B-NOPF-CENTNOTRD") ||
753  triggerclasses.Contains("CDMC8DJ1-B-NOPF-CENTNOTRD") ||
754  triggerclasses.Contains("CDMC7DJE") ||
755  triggerclasses.Contains("CDMC8DJE") ||
756  triggerclasses.Contains("CDMC7DJ1-B") ||
757  triggerclasses.Contains("CDMC7DJ2-B") ||
758  triggerclasses.Contains("CPBI2DJE") ) bDL1J = kTRUE;
759 
760  if( bMB ){ fhEventType->Fill(4.5);}//INT7,8
761  if( bL0 ){ fhEventType->Fill(5.5);}//EMC7,EMC8
762  if( bL1G || bL1J ){ fhEventType->Fill(6.5);}//L1 EMCal
763  if( bDL0 ){ fhEventType->Fill(7.5);}//DMC7,DMC8
764  if( bDL1G || bDL1J ){ fhEventType->Fill(8.5);}//L1 DCal
765 
766  // if(bL1G || bL1J || bL0){
767 
768 // Prepare TOFT0 maker at the beginning of a run
769 // if (event->GetRunNumber() != fRunNumber){
770 // AliInfo(Form("Runno per event %d",event->GetRunNumber()));
771 // fRunNumber = event->GetRunNumber();
772 // // PrepareTOFT0maker();
773 // // cout<<"tofT0maker per run"<<fRunNumber<<endl;
774 // }// fi Check if run number has changed
775 
776 // // --- Use of AliTOFT0maker
777 // Double_t calcolot0=0.0;
778 // if(!AODEvent()){
779 // Double_t* timeTOFtable;
780 // timeTOFtable=fTOFmaker->ComputeT0TOF(dynamic_cast<AliESDEvent*>(event));
781 // AliDebug(2,Form("TOF time %f ps, resolution %f ps, tracks at TOF %f/used %f",timeTOFtable[0],timeTOFtable[1],timeTOFtable[3],timeTOFtable[7]));
782 // //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;
783 // calcolot0=timeTOFtable[0];
784 // }
785 
786 // if(fFillHeavyHisto) {
787 // fhcalcEvtTime->Fill(calcolot0);
788 // if(calcolot0 != 0 && event->GetTOFHeader()->GetDefaultEventTimeVal() != 0 )
789 // fhEvtTimeDiff->Fill(calcolot0-event->GetTOFHeader()->GetDefaultEventTimeVal());
790 // }
791 
792  TRefArray* caloClusters = new TRefArray();
793  event->GetEMCALClusters(caloClusters);
794  // cout << " ###########Bunch Cross nb = " << event->GetBunchCrossNumber() << endl;
795 
796  Int_t BunchCrossNumber =event->GetBunchCrossNumber();
797 
798  Float_t offset=0.;
799  Float_t offsetPerSM=0.;
800  Int_t L1phaseshift=0;
801  Int_t L1phase=0;
802  Int_t L1shiftOffset=0;
803 
804  Int_t nBC = 0;
805  nBC = BunchCrossNumber%4;
806  //Int_t nTriggerMask =event->GetTriggerMask();
807  // cout << " nBC " << nBC << " nTriggerMask " << nTriggerMask<< endl;
808  Float_t timeBCoffset = 0.; //manual offset
809  // if( nBC%4 ==0 || nBC%4==1) timeBCoffset = 100.; // correction was for LHC11 when BC was not corrected
810 
811  Int_t nclus = caloClusters->GetEntries();
812  AliDebug(1,Form("###########Bunch Cross nb = %d nclus = %d",nBC,nclus ));
813  //cout << " ###########Bunch Cross nb = " << nBC <<" nclus= "<< nclus<< endl;
814  //Int_t ntracks = event-> GetNumberOfTracks() ;
815 
816  AliVCaloCells &cells= *(event->GetEMCALCells());//it is cluster independent
817  //Variables used plenty in loops
818  Int_t nSupMod=-1, nModule=-1;
819  Int_t iphi=-1, ieta=-1, nIphi=-1, nIeta=-1;
820  Int_t absId=-1;
821  Float_t hkdtime=0.0;
822  Float_t amp=0.0;
823  Bool_t isHighGain=kTRUE;
824  Int_t mostEneId=-1;
825  Float_t mostEneEn=0.;
826 
827  for (Int_t icl = 0; icl < nclus; icl++) {
828  //ESD and AOD CaloCells carries the same information
829  AliVCluster* clus = (AliVCluster*)caloClusters->At(icl);
830  if(!AcceptCluster(clus)) continue;
831 
832  //cout<<"nCells="<< clus->GetNCells();<<endl;
833 
834  UShort_t * index = clus->GetCellsAbsId() ;
835 
836  // find index of the most energetic cell in cluster
837  mostEneEn=0.;
838  mostEneId=-1;
839  if(fMostEneCellOnly) {
840  for(Int_t i = 0; i < clus->GetNCells() ; i++) {
841  absId = index[i];
842  amp = cells.GetCellAmplitude(absId) ;
843  if(amp > mostEneEn){
844  mostEneEn = amp;
845  mostEneId = absId;
846  }
847  }
848  }//works only for fMostEneCellOnly=kTRUE
849 
850  for(Int_t i = 0; i < clus->GetNCells() ; i++) {
851  absId = index[i]; // or clus->GetCellNumber(i) ;
852  if(fMostEneCellOnly && absId != mostEneId) {
853  //printf("tr.%s.cl.%d.cell.%d.rejected\n",triggerclasses.Data(),icl,i);
854  continue;
855  }
856  //printf("tr.%s.cl.%d.cell.%d.accepted\n",triggerclasses.Data(),icl,i);
857  hkdtime = cells.GetCellTime(absId) * 1.0e09; // to get ns
858  amp = cells.GetCellAmplitude(absId) ;
859  isHighGain = cells.GetCellHighGain(absId);
860  //cout<<"cell absID: "<<absId<<" cellTime: "<<hkdtime<<" cellaplit: "<< amp<<endl;
861  // GEOMETRY tranformations
862  fgeom->GetCellIndex(absId, nSupMod, nModule, nIphi, nIeta);
863  fgeom->GetCellPhiEtaIndexInSModule(nSupMod,nModule,nIphi,nIeta, iphi,ieta);
864 
865  //bad channel check. 0: good channel, 1-5: bad channel
867  if(GetEMCALChannelStatus(nSupMod,ieta,iphi)) continue;//printf("bad\n");
868  } else if(fSetBadChannelMapSource==2){
869  if(GetEMCALChannelStatus(absId)) continue;//printf("bad\n");
870  }
871 
872  //main histograms with raw time information
873  if(amp>fMinCellEnergy){
874  if(isHighGain){
875  if(fFillHeavyHisto) fhRawTimeVsIdBC[nBC]->Fill(absId,hkdtime);
876  fhRawTimeSumBC[nBC]->Fill(absId,hkdtime);
877  fhRawTimeEntriesBC[nBC]->Fill(absId,1.);
878  fhRawTimeSumSqBC[nBC]->Fill(absId,hkdtime*hkdtime);
879  }else{
880  if(fFillHeavyHisto) fhRawTimeVsIdLGBC[nBC]->Fill(absId,hkdtime);
881  fhRawTimeSumLGBC[nBC]->Fill(absId,hkdtime);
882  fhRawTimeEntriesLGBC[nBC]->Fill(absId,1.);
883  fhRawTimeSumSqLGBC[nBC]->Fill(absId,hkdtime*hkdtime);
884  }
885  }
886  //fgeom->PrintCellIndexes(absId);
887  //fgeom->PrintCellIndexes(absId,1);
888 
889  // other histograms for cross-check
890  CheckCellRCU(nSupMod,ieta,iphi);//SM, column, row
891 
892  fhTcellvsSM->Fill(nSupMod,hkdtime);
893  if(fFillHeavyHisto) {
894  if(isHighGain==kTRUE) {fhEneVsAbsIdHG->Fill(absId,amp);}
895  else {fhEneVsAbsIdLG->Fill(absId,amp);}
896  }
897  fhTimeVsBC->Fill(1.*BunchCrossNumber,hkdtime-timeBCoffset);
898  //important remark: We use 'Underflow bin' for absid=0 in OADB for time calibration
899  if(isHighGain==kTRUE){
900  if(fhAllAverageBC[nBC]!=0) {//comming from file after the first iteration
901  offset = (Float_t)(fhAllAverageBC[nBC]->GetBinContent(absId));//channel absId=0 has histogram bin=0
902  } else if(fReferenceFileName.Length()!=0){//protection against missing reference histogram
903  AliFatal(Form("Reference histogram for BC%d not properly loaded",nBC));
904  }
905  } else {
906  if(fhAllAverageLGBC[nBC]!=0) {//comming from file after the first iteration
907  offset = (Float_t)(fhAllAverageLGBC[nBC]->GetBinContent(absId));//channel absId=0 has histogram bin=0
908  } else if(fReferenceFileName.Length()!=0){//protection against missing reference histogram
909  AliFatal(Form("Reference LG histogram for BC%d not properly loaded",nBC));
910  }
911  }
912  //if(offset==0)cout<<"offset 0 in SM "<<nSupMod<<endl;
913 
914  // Solution for 2015 data where L1 phase and L1 shift is not correct in data. We need to calibrate run by run.
915  // The shift and phase are done per SM (0-19).
916  // L1 phase is necessary in run 2.
917  // L1 shift is necessary only for bad reconstructed runs (muon_calo_pass1 lhc15f-m)
918  if(fhRefRuns!=0) {//comming from file after the first iteration
919  L1phaseshift = (Int_t)(fhRefRuns->GetBinContent(nSupMod));//SM0 = bin0
920 
921  // to correct for L1 phase
922  // this part works for both: muon_calo_pass1 of LHC15n (pp@2.76) and later reconstructions
923  // wrong reconstruction done before in run2
924  L1phase = L1phaseshift & 3; //bit operation
925  if(nBC >= L1phase)
926  offsetPerSM = (nBC - L1phase)*25;
927  else
928  offsetPerSM = (nBC - L1phase + 4)*25;
929 
930  // to correct for L1 shift
931  // this part is only for wrongly reconstructed runs before LHC15n in run2
932  if(fBadReco){
933  L1shiftOffset = L1phaseshift>>2; //bit operation
934  L1shiftOffset*=25;
935  //(we subtract it here because we subtract the whole wrong offset later --=+)
936  if(nBC==0 || nBC==1) L1shiftOffset-=100.;//additional shift for muon_calo_pass1 up to lhc15f-m
937  }
938  } else if(fReferenceRunByRunFileName.Length()!=0){//protection against missing reference histogram
939  AliFatal("Reference histogram run-by-run not properly loaded");
940  }
941  //end of load additional offset
942 
943  //fill the raw time with L1 shift correction and 100ns
945  if(isHighGain){
946  fhRawCorrTimeVsIdBC[nBC]->Fill(absId,hkdtime-L1shiftOffset);
947  }else{
948  fhRawCorrTimeVsIdLGBC[nBC]->Fill(absId,hkdtime-L1shiftOffset);
949  }
950  }
951 
952  //fill time after L1 shift correction and 100ns and new L1 phase
954  if(isHighGain){
955  fhTimeVsIdBC[nBC]->Fill(absId,hkdtime-L1shiftOffset-offsetPerSM);
956  }else{
957  fhTimeVsIdLGBC[nBC]->Fill(absId,hkdtime-L1shiftOffset-offsetPerSM);
958  }
959  }
960 
961  //other control histograms
962  if(amp>0.5) {
963  if(isHighGain){
964  fhTimeDsup[nSupMod]->Fill(amp,hkdtime-offset-offsetPerSM-L1shiftOffset);
965  fhTimeDsupBC[nSupMod][nBC]->Fill(amp,hkdtime-offset-offsetPerSM-L1shiftOffset);
966  }else{
967  fhTimeDsupLG[nSupMod]->Fill(amp,hkdtime-offset-offsetPerSM-L1shiftOffset);
968  fhTimeDsupLGBC[nSupMod][nBC]->Fill(amp,hkdtime-offset-offsetPerSM-L1shiftOffset);
969  }
970  }
971 
972 // if(fFillHeavyHisto) {
973 // if(amp>0.9) {
974 // fhTcellvsTOFT0HD->Fill(calcolot0, hkdtime);
975 // }
976 // fhTcellvsTOFT0->Fill(calcolot0, hkdtime-offset-offsetPerSM-L1shiftOffset);
977 // }
978 
979  hkdtime = hkdtime-timeBCoffset;//time corrected by manual offset (default=0)
980  Float_t hkdtimecorr;
981  hkdtimecorr= hkdtime-offset-offsetPerSM-L1shiftOffset;//time after first iteration
982 
983  //main histograms after the first itereation for calibration constants
984  //if(hkdtimecorr>=-20. && hkdtimecorr<=20. && amp>0.9 ) {
985  if(hkdtimecorr>=fMinTime && hkdtimecorr<=fMaxTime && amp>fMinCellEnergy ) {
986  // per cell
987 // Float_t entriesTime=fhTimeEnt[nBC]->GetBinContent(absId)+1;
988 // Float_t sumTimeSq=(fhTimeSumSq[nBC]->GetBinContent(absId)+(hkdtime*hkdtime));
989 // Float_t sumTime=(fhTimeSum[nBC]->GetBinContent(absId)+hkdtime);
990 //
991 // fhTimeEnt[nBC]->SetBinContent(absId,entriesTime);
992 // fhTimeSumSq[nBC]->SetBinContent(absId,sumTimeSq);
993 // fhTimeSum[nBC]->SetBinContent(absId,sumTime);
994 
995  //correction in 2015 for wrong L1 phase and L1 shift
996  hkdtime = hkdtime - offsetPerSM - L1shiftOffset;
997 
998  if(isHighGain){
999  fhTimeEnt[nBC]->Fill(absId,1.);
1000  fhTimeSumSq[nBC]->Fill(absId,hkdtime*hkdtime);
1001  fhTimeSum[nBC]->Fill(absId,hkdtime);
1002  }else{
1003  fhTimeLGEnt[nBC]->Fill(absId,1.);
1004  fhTimeLGSumSq[nBC]->Fill(absId,hkdtime*hkdtime);
1005  fhTimeLGSum[nBC]->Fill(absId,hkdtime);
1006  }
1007 
1008 
1009  } // hkdtime:[-20;20]
1010  } // end icell
1011  } //end cluster
1012 
1013 
1014  // Post output data.
1015  //cout<<"Post data and delete caloClusters"<<endl;
1016  caloClusters->Delete();
1017  delete caloClusters;
1018 // } // end if trigger type
1019 
1020  PostData(1, fOutputList);
1021 } // End of AliAnalysisTaskEMCALTimeCalib::UserExec()
1022 
1023 //________________________________________________________________________
1027 {
1028  fOutputList = dynamic_cast<TList*> (GetOutputData(1));
1029 
1030  // if(fTOFmaker) delete fTOFmaker;
1031 
1032  if(fL1PhaseList) {
1033  fL1PhaseList->SetOwner();
1034  fL1PhaseList->Clear();
1035  delete fL1PhaseList;
1036  }
1037 
1038  if (fBadChannelMapArray) {
1039  fBadChannelMapArray->Clear();
1040  delete fBadChannelMapArray;
1041  }
1042 
1043  if (!fOutputList)
1044  {
1045  AliDebug(1,"ERROR: Output list not available");
1046  return;
1047  }
1048 } // End of AliAnalysisTaskEMCALTimeCalib::Terminate
1049 
1050 //________________________________________________________________________
1053 {
1054  //fix with noisy EMCAL fee card
1055  Int_t nCells = clus->GetNCells();
1056 
1057  if(clus->IsEMCAL())
1058  {
1059  if ((clus->E() > fMaxClusterEnergy && nCells > fMaxNcells ) || nCells > fMaxNcells){
1060  AliDebug(1,"very big cluster with enormous energy - cluster rejected");
1061  return kFALSE;
1062  }
1063  }
1064 
1065  // remove other than photonlike
1066  Double_t lambda0=clus->GetM02();
1067  if (lambda0>fMaxLambda0LG || lambda0<fMinLambda0LG){
1068  AliDebug(1,"lambda0 loose cut failed - cluster rejected");
1069  return kFALSE;
1070  }
1071 
1072  // remove matched clusters
1073  Double_t Dx=clus->GetTrackDx();
1074  Double_t Dz=clus->GetTrackDz();
1075  Double_t Rtrack = TMath::Sqrt(Dx*Dx+Dz*Dz);
1076  if (Rtrack <fMaxRtrack)
1077  {
1078  AliDebug(1,"track matched - cluster rejected");
1079  return kFALSE;
1080  }
1081 
1082  if (nCells<fMinNcells)
1083  {
1084  AliDebug(1,"single cell cluster - cluster rejected");
1085  return kFALSE;
1086  }
1087 
1088  if(clus->E()<fMinClusterEnergy)
1089  {
1090  AliDebug(1,"cluster energy < 1 GeV- cluster rejected");
1091  return kFALSE;
1092  }
1093 
1094 
1095  if(!IsLowGainCellInCluster(clus)) {//no low gain cell in cluster
1096  //apply more strict lambda0^2 cut
1097  if (lambda0>fMaxLambda0 || lambda0<fMinLambda0){
1098  AliDebug(1,"lambda0 strict cut failed - cluster rejected");
1099  return kFALSE;
1100  }
1101  }
1102 
1103 
1104 
1105 
1106  return kTRUE;
1107 }//End AliAnalysisTaskEMCALTimeCalib::AcceptCluster
1108 
1109 //________________________________________________________________________
1112  UShort_t * index = clus->GetCellsAbsId() ;
1113  AliVCaloCells &cells= *(InputEvent()->GetEMCALCells());
1114  for(Int_t i = 0; i < clus->GetNCells() ; i++) {
1115  if(cells.GetCellHighGain(index[i])==kFALSE) return kTRUE;//low gain cell
1116  }
1117  return kFALSE;
1118 
1119 }
1120 
1121 //________________________________________________________________________
1124 {
1125  Int_t iRCU;
1126  if(nSupMod < 10 || (nSupMod >= 12 && nSupMod <18) )
1127  {
1128  if (0<=irow&&irow<8) iRCU=0; // first cable row
1129  else if (8<=irow&&irow<16 && 0<=icol&&icol<24) iRCU=0; // first half;
1130  //second cable row
1131  //RCU1
1132  else if (8<=irow&&irow<16 && 24<=icol&&icol<48) iRCU=1; // second half;
1133  //second cable row
1134  else if (16<=irow&&irow<24) iRCU=1; // third cable row
1135 
1136  if (nSupMod%2==1) iRCU = 1 - iRCU; // swap for odd=C side, to allow us to cable both sides the same
1137  }
1138  else
1139  {
1140  // Last 2 SM have one single SRU, just assign RCU 0
1141  iRCU = 0 ;
1142  }
1143 
1144  //cout<<"RCU:"<<iRCU<<endl;
1145  if (iRCU<0)
1146  AliFatal(Form("Wrong EMCAL/DCAL RCU number = %d\n", iRCU));
1147 
1148  return kTRUE;
1149 }//End AliAnalysisTaskEMCALTimeCalib::CheckCellRCU
1150 
1151 //________________________________________________________________________
1154 {
1155  fMinClusterEnergy=1.0;//0.5//0.7
1156  fMaxClusterEnergy=500;
1157  fMinNcells=2;
1158  fMaxNcells=200;
1159  fMinLambda0=0.1;
1160  fMaxLambda0=0.4;
1161  fMinLambda0LG=0.1;
1162  fMaxLambda0LG=4.0;
1163  fMaxRtrack=0.025;
1164  fMinCellEnergy=0.4;//0.1//0.4
1165  fReferenceFileName="";//Reference.root
1167  fBadReco=kFALSE;
1168  fFillHeavyHisto=kFALSE;
1169  fGeometryName="";//EMCAL_COMPLETE12SMV1_DCAL_8SM
1170  fPileupFromSPD=kFALSE;
1171  fMinTime=-20.;
1172  fMaxTime=20.;
1173  fMostEneCellOnly=kFALSE;
1174 
1175  fBadChannelMapSet=kFALSE;
1178 
1179  //histograms
1180  fRawTimeNbins = 400; // Raw time settings should be like that all the time
1181  fRawTimeMin = 400.; // importent in pass1
1182  fRawTimeMax = 800.;
1183  fPassTimeNbins = 1000; // in pass2 should be (400,400,800)
1184  fPassTimeMin = -250.;// in pass3 should be (1000,-250,250)
1185  fPassTimeMax = 250.;
1186  fEnergyNbins = 100; // default settings was 500
1187  fEnergyMin = 0.;
1188  fEnergyMax = 20.;
1189  fEnergyLGNbins = 200; // default settings
1190  fEnergyLGMin = 0.;
1191  fEnergyLGMax = 100.;
1192  fFineNbins = 90; //was 4500 for T0 time studies
1193  fFineTmin = -500;
1194  fFineTmax = 400;
1195 }
1196 
1197 //________________________________________________________________________
1203 {
1204  TFile *file =new TFile(inputFile.Data());
1205  if(file==0x0) {
1206  //AliWarning("Input file does not exist!");
1207  return;
1208  }
1209 
1210  TList *list=(TList*)file->Get("chistolist");
1211  if(list==0x0)
1212  {
1213  //AliWarning("List chistolist does not exist in file!");
1214  return;
1215  }
1216 
1217  //high gain
1218  TH1F *h1[4];
1219  TH1F *h2[4];
1220  TH1F *h3[4];
1221  TH1F *hAllTimeAvBC[4];
1222  TH1F *hAllTimeRMSBC[4];
1223 
1224  //low gain
1225  TH1F *h4[4];
1226  TH1F *h5[4];
1227  TH1F *h6[4];
1228  TH1F *hAllTimeAvLGBC[4];
1229  TH1F *hAllTimeRMSLGBC[4];
1230 
1231  if(isFinal==kFALSE){//first itereation
1232  for(Int_t i=0;i<4;i++){
1233  h1[i]=(TH1F *)list->FindObject(Form("RawTimeSumBC%d",i));
1234  h2[i]=(TH1F *)list->FindObject(Form("RawTimeEntriesBC%d",i));
1235  h3[i]=(TH1F *)list->FindObject(Form("RawTimeSumSqBC%d",i));
1236 
1237  h4[i]=(TH1F *)list->FindObject(Form("RawTimeSumLGBC%d",i));
1238  h5[i]=(TH1F *)list->FindObject(Form("RawTimeEntriesLGBC%d",i));
1239  h6[i]=(TH1F *)list->FindObject(Form("RawTimeSumSqLGBC%d",i));
1240  }
1241  } else {//final iteration
1242  for(Int_t i=0;i<4;i++){
1243  h1[i]=(TH1F *)list->FindObject(Form("hTimeSum%d",i));
1244  h2[i]=(TH1F *)list->FindObject(Form("hTimeEnt%d",i));
1245  h3[i]=(TH1F *)list->FindObject(Form("hTimeSumSq%d",i));
1246 
1247  h4[i]=(TH1F *)list->FindObject(Form("hTimeLGSum%d",i));
1248  h5[i]=(TH1F *)list->FindObject(Form("hTimeLGEnt%d",i));
1249  h6[i]=(TH1F *)list->FindObject(Form("hTimeLGSumSq%d",i));
1250  }
1251  }
1252  //AliWarning("Input histograms read.");
1253 
1254  for(Int_t i=0;i<4;i++){
1255  hAllTimeAvBC[i]=new TH1F(Form("hAllTimeAvBC%d",i),Form("hAllTimeAvBC%d",i),h1[i]->GetNbinsX(),h1[i]->GetXaxis()->GetXmin(),h1[i]->GetXaxis()->GetXmax());
1256  hAllTimeRMSBC[i]=new TH1F(Form("hAllTimeRMSBC%d",i),Form("hAllTimeRMSBC%d",i),h3[i]->GetNbinsX(),h3[i]->GetXaxis()->GetXmin(),h3[i]->GetXaxis()->GetXmax());
1257 
1258  hAllTimeAvLGBC[i]=new TH1F(Form("hAllTimeAvLGBC%d",i),Form("hAllTimeAvLGBC%d",i),h4[i]->GetNbinsX(),h4[i]->GetXaxis()->GetXmin(),h4[i]->GetXaxis()->GetXmax());
1259  hAllTimeRMSLGBC[i]=new TH1F(Form("hAllTimeRMSLGBC%d",i),Form("hAllTimeRMSLGBC%d",i),h6[i]->GetNbinsX(),h6[i]->GetXaxis()->GetXmin(),h6[i]->GetXaxis()->GetXmax());
1260  }
1261 
1262  //AliWarning("New histograms booked.");
1263 
1264  //important remark: we use 'underflow bin' for absid=0 in OADB . That's why there is j-1 below.
1265  for(Int_t i=0;i<4;i++){
1266  for(Int_t j=1;j<=h1[i]->GetNbinsX();j++){
1267  //high gain
1268  if(h2[i]->GetBinContent(j)!=0){
1269  hAllTimeAvBC[i]->SetBinContent(j-1,h1[i]->GetBinContent(j)/h2[i]->GetBinContent(j));
1270  hAllTimeRMSBC[i]->SetBinContent(j-1,TMath::Sqrt(h3[i]->GetBinContent(j)/h2[i]->GetBinContent(j)) );
1271  } else {
1272  hAllTimeAvBC[i]->SetBinContent(j-1,0.);
1273  hAllTimeRMSBC[i]->SetBinContent(j-1,0.);
1274  }
1275  //low gain
1276  if(h5[i]->GetBinContent(j)!=0){
1277  hAllTimeAvLGBC[i]->SetBinContent(j-1,h4[i]->GetBinContent(j)/h5[i]->GetBinContent(j));
1278  hAllTimeRMSLGBC[i]->SetBinContent(j-1,TMath::Sqrt(h6[i]->GetBinContent(j)/h5[i]->GetBinContent(j)) );
1279  } else {
1280  hAllTimeAvLGBC[i]->SetBinContent(j-1,0.);
1281  hAllTimeRMSLGBC[i]->SetBinContent(j-1,0.);
1282  }
1283 
1284  }
1285  }
1286 
1287  //AliWarning("Average and rms calculated.");
1288  TFile *fileNew=new TFile(outputFile.Data(),"recreate");
1289  for(Int_t i=0;i<4;i++){
1290  hAllTimeAvBC[i]->Write();
1291  hAllTimeRMSBC[i]->Write();
1292  hAllTimeAvLGBC[i]->Write();
1293  hAllTimeRMSLGBC[i]->Write();
1294  }
1295 
1296  //AliWarning(Form("Histograms saved in %s file.",outputFile.Data()));
1297 
1298  fileNew->Close();
1299  delete fileNew;
1300 
1301  for(Int_t i=0;i<4;i++){
1302  delete hAllTimeAvBC[i];
1303  delete hAllTimeRMSBC[i];
1304  delete hAllTimeAvLGBC[i];
1305  delete hAllTimeRMSLGBC[i];
1306 
1307  delete h1[i];
1308  delete h2[i];
1309  delete h3[i];
1310  delete h4[i];
1311  delete h5[i];
1312  delete h6[i];
1313  }
1314 
1315  file->Close();
1316  delete file;
1317 
1318  //AliWarning("Pointers deleted. Memory cleaned.");
1319 }
1320 
1321 //________________________________________________________________________
1325 void AliAnalysisTaskEMCALTimeCalib::ProduceOffsetForSMsV2(Int_t runNumber,TString inputFile,TString outputFile, Bool_t offset100, Bool_t justL1phase){
1326 
1327 const Double_t lowerLimit[]={
1328  0,
1329  1152,
1330  2304,
1331  3456,
1332  4608,
1333  5760,
1334  6912,
1335  8064,
1336  9216,
1337  10368,
1338  11520,
1339  11904,
1340  12288,
1341  13056,
1342  13824,
1343  14592,
1344  15360,
1345  16128,
1346  16896,
1347  17280};
1348 
1349 const Double_t upperLimit[]={
1350  1151 ,
1351  2303 ,
1352  3455 ,
1353  4607 ,
1354  5759 ,
1355  6911 ,
1356  8063 ,
1357  9215 ,
1358  10367,
1359  11519,
1360  11903,
1361  12287,
1362  13055,
1363  13823,
1364  14591,
1365  15359,
1366  16127,
1367  16895,
1368  17279,
1369  17663};
1370 
1371  TFile *file =new TFile(inputFile.Data());
1372  if(file==0x0) return;
1373 
1374  TH1F *ccBC[4];
1375  Bool_t shouldBeEmpty[4];
1376  Int_t emptyCounter;
1377  for(Int_t i = 0; i < kNBCmask; i++){
1378  ccBC[i]=(TH1F*) file->Get(Form("hAllTimeAvBC%d",i));
1379  shouldBeEmpty[i]=kFALSE;
1380  emptyCounter=0;
1381  for(Int_t j=0;j<upperLimit[19];j++){
1382  if(ccBC[i]->GetBinContent(j)>0.) emptyCounter++;
1383  }
1384  if(emptyCounter<1500) shouldBeEmpty[i]=kTRUE;
1385  printf("Non-zero channels %d BC %d should be empty: %d \n",emptyCounter,i,shouldBeEmpty[i]);
1386  }
1387 
1388  TH1C *hRun=new TH1C(Form("h%d",runNumber),Form("h%d",runNumber),19,0,19);
1389  Int_t fitResult=0;
1390  Double_t minimumValue=10000.;
1391  Int_t minimumIndex=-1;
1392  Double_t meanBC[4];
1393 
1394  Double_t fitParameter=0;
1395  TF1 *f1=new TF1("f1","pol0",0,17664);
1396  Bool_t orderTest=kTRUE;
1397  Int_t iorder=0;//order index
1398  Int_t j=0;//BC index
1399  Int_t L1shift=0;
1400  Int_t totalValue=0;
1401 
1402  for(Int_t i=0;i<20;i++){
1403  minimumValue=10000;
1404  for(j=0;j<kNBCmask;j++){
1405  if(shouldBeEmpty[j]) {
1406  meanBC[j]=-1;
1407  continue;
1408  }
1409  fitResult=ccBC[j]->Fit("f1","CQ","",lowerLimit[i],upperLimit[i]);
1410  if(fitResult<0){
1411  //hRun->SetBinContent(i,0);//correct it please
1412  meanBC[j]=-1;
1413  printf("Fit failed for SM %d BC%d, integral %f\n",i,j,ccBC[j]->Integral(lowerLimit[i],upperLimit[i]));
1414  continue;
1415  } else {
1416  fitParameter = f1->GetParameter(0);
1417  }
1418  if(offset100 && (j==0 || j==1)) {
1419  //the 100 ns offset was removed in LHC15n muon_calo_pass1 and further reconstructions
1420  fitParameter+=100;
1421  }
1422  meanBC[j]=fitParameter;
1423 
1424  if(fitParameter>0 && fitParameter<minimumValue){
1425  minimumValue = fitParameter;
1426  minimumIndex = j;
1427  }
1428  }
1429 
1430  if( minimumValue/25-(Int_t)(minimumValue/25)>0.5 ) {
1431  L1shift=(Int_t)(minimumValue/25.)+1;
1432  } else {
1433  L1shift=(Int_t)(minimumValue/25.);
1434  }
1435 
1436  if(TMath::Abs(minimumValue/25-(Int_t)(minimumValue/25)-0.5)<0.05)
1437  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);
1438 
1439  if(justL1phase) totalValue = minimumIndex;
1440  else totalValue = L1shift<<2 | minimumIndex ;
1441  //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);
1442 
1443  hRun->SetBinContent(i,totalValue);
1444  orderTest=kTRUE;
1445  for(iorder=minimumIndex;iorder<minimumIndex+4-1;iorder++){
1446  if( meanBC[(iorder+1)%4] <= meanBC[iorder%4] ) orderTest=kFALSE;
1447  }
1448  if(!orderTest)
1449  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);
1450 
1451  //patch for runs with not filled one, two or three BCs
1452  //manual patch for LHC16q - pPb@5TeV - only BC0 is filled and phase rotate
1453  if(shouldBeEmpty[0] || shouldBeEmpty[1] || shouldBeEmpty[2] || shouldBeEmpty[3]){
1454  Double_t newMean = meanBC[minimumIndex]-600;
1455  if(newMean<=12.5) hRun->SetBinContent(i,minimumIndex);
1456  else {
1457  Int_t minIndexTmp=-1;
1458  if(newMean/25. - (Int_t)(newMean/25.) <0.5)
1459  minIndexTmp = (Int_t)(newMean/25.);
1460  else
1461  minIndexTmp = 1+(Int_t)(newMean/25.);
1462 
1463  hRun->SetBinContent(i,(4-minIndexTmp+minimumIndex)%4);
1464  //cout<<newMean/25.<<" int "<<(Int_t)(newMean/25.)<<" dif "<< newMean/25.-(Int_t)(newMean/25.)<<endl;
1465  }
1466  printf("run with missing BC; new L1 phase set to %d\n",(Int_t)hRun->GetBinContent(i));
1467  }//end of patch for LHC16q and other runs with not filled BCs
1468  }//end of loop over SM
1469 
1470  delete f1;
1471  TFile *fileNew=new TFile(outputFile.Data(),"update");
1472  hRun->Write();
1473  fileNew->Close();
1474  delete fileNew;
1475 
1476  file->Close();
1477  delete file;
1478 }
1479 
1480 //____________________________________________________
1482 {
1483  if(fBadChannelMapSet) return;
1484  AliOADBContainer *contBC=new AliOADBContainer("");
1485  contBC->InitFromFile(AliDataFile::GetFileNameOADB("EMCAL/EMCALBadChannels.root").data(),"AliEMCALBadChannels");
1486  printf("contBC %p, ent %d\n",contBC,contBC->GetNumberOfEntries());
1487  TObjArray *arrayBC=(TObjArray*)contBC->GetObject(fRunNumber);
1488  if(arrayBC) {
1489  AliInfo("Remove EMCAL bad cells");
1491  for (Int_t i=0; i<kNSM; ++i) {
1492  TH2I *hbm = (TH2I*)arrayBC->FindObject(Form("EMCALBadChannelMap_Mod%d",i));
1493  if (!hbm) {
1494  AliError(Form("Can not get EMCALBadChannelMap_Mod%d",i));
1495  continue;
1496  }
1497  hbm->SetDirectory(0);
1498  fBadChannelMapArray->AddAt(hbm,i);
1499 
1500  } // loop over SMs
1501  } else AliInfo("Do NOT remove EMCAL bad channels\n"); // run array
1502 
1503  delete contBC;
1504  fBadChannelMapSet = kFALSE;//BC map is not fixed at the beginning but can change r-by-r
1505 } // Bad channel map loaded
1506 
1507 //____________________________________________________
1509 {
1510  if(fBadChannelMapSet) return;
1511 
1512  TFile *referenceFile = TFile::Open(fBadChannelFileName.Data());
1513  if(referenceFile==0x0) {
1514  AliFatal("*** NO bad channel map FILE");
1515  }
1516 
1517  TH1F *hbm = (TH1F*)referenceFile->Get("h1");
1518  if (!hbm) {
1519  AliError("Can not get EMCALBadChannelMap");
1520  }
1521  fBadChannelMapArray = new TObjArray(1);
1522  fBadChannelMapArray->AddAt(hbm,0);
1523  fBadChannelMapSet=kTRUE;//BC map is fixed at the beginning for whole dataset
1524 } // Bad channel map loaded
1525 
1526 
1527 //_____________________________________________________________________
1532 }
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 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
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
Double_t fEnergyMax
upper range of histo with energy HG
Double_t fMinClusterEnergy
minimum cluster energy
float Float_t
Definition: External.C:68
static void ProduceOffsetForSMsV2(Int_t runNumber, TString inputFile="Reference.root", TString outputFile="ReferenceSM.root", Bool_t offset100=kTRUE, Bool_t justL1phase=kTRUE)
TObjArray * fBadChannelMapArray
bad channel map array
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
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 ProduceCalibConsts(TString inputFile="time186319testWOL0.root", TString outputFile="Reference.root", Bool_t isFinal=kFALSE)
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
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
TH2F * fhTimeDsupBC[kNSM][kNBCmask]
! 20 x 4 high gain
TH2F * fhTimeDsupLGBC[kNSM][kNBCmask]
! 20 x 4 low gain