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