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