AliPhysics  29d4213 (29d4213)
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Macros
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 <TList.h>
24 #include <TCanvas.h>
25 #include <TGeoManager.h>
26 #include <TRefArray.h>
27 
28 #include "AliLog.h"
29 #include "AliAnalysisTask.h"
30 #include "AliAnalysisManager.h"
31 #include "AliESDEvent.h"
32 #include "AliAODEvent.h"
33 #include "AliVEvent.h"
34 #include "AliESDInputHandler.h"
35 #include "AliAODInputHandler.h"
36 #include "AliESDpid.h"
37 #include "AliTOFcalib.h"
38 #include "AliCDBManager.h"
39 #include "AliRunTag.h"
40 
41 #include "AliTOFT0maker.h"
42 #include "AliVCluster.h"
43 #include "AliESDCaloCluster.h"
44 #include "AliVCaloCells.h"
45 #include "AliESDCaloCells.h"
46 #include "AliAODCaloCluster.h"
47 #include "AliAODCaloCells.h"
48 #include "AliEMCALGeometry.h"
49 
51 
55 
56 using std::cout;
57 using std::endl;
58 
59 //________________________________________________________________________
62 : AliAnalysisTaskSE(name),
63  fRunNumber(-1),
64  fTOFmaker(0),
65  fOutputList(0x0),
66  fgeom(0),
67  fGeometryName(),
68  fMinClusterEnergy(0),
69  fMaxClusterEnergy(0),
70  fMinNcells(0),
71  fMaxNcells(0),
72  fMinLambda0(0),
73  fMaxLambda0(0),
74  fMinLambda0LG(0),
75  fMaxLambda0LG(0),
76  fMaxRtrack(0),
77  fMinCellEnergy(0),
78  fReferenceFileName(),
79  fReferenceRunByRunFileName(),
80  fPileupFromSPD(kFALSE),
81  fMinTime(0),
82  fMaxTime(0),
83  fReferenceFile(0),
84  fhcalcEvtTime(0),
85  fhEvtTimeHeader(0),
86  fhEvtTimeDiff(0),
87  fhEventType(0),
88  fhTOFT0vsEventNumber(0),
89  fhTcellvsTOFT0(0),
90  fhTcellvsTOFT0HD(0),
91  fhTcellvsSM(0),
92  fhEneVsAbsIdHG(0),
93  fhEneVsAbsIdLG(0),
94  fhTimeVsBC(0),
95  fhTimeSumSq(),
96  fhTimeEnt(),
97  fhTimeSum(),
98  fhTimeLGSumSq(),
99  fhTimeLGEnt(),
100  fhTimeLGSum(),
101  fhAllAverageBC(),
102  fhAllAverageLGBC(),
103  fhRefRuns(0),
104  fhTimeDsup(),
105  fhTimeDsupBC(),
106  fhRawTimeVsIdBC(),
107  fhRawTimeSumBC(),
108  fhRawTimeEntriesBC(),
109  fhRawTimeSumSqBC(),
110  fhRawTimeVsIdLGBC(),
111  fhRawTimeSumLGBC(),
112  fhRawTimeEntriesLGBC(),
113  fhRawTimeSumSqLGBC()
114 
115 {
116  for(Int_t i = 0; i < kNBCmask; i++)
117  {
118  fhAllAverageBC[i]=0;
119  fhAllAverageLGBC[i]=0;
120 
121  fhTimeSumSq[i]=0;
122  fhTimeEnt[i]=0;
123  fhTimeSum[i]=0;
124 
125  fhTimeLGSumSq[i]=0;
126  fhTimeLGEnt[i]=0;
127  fhTimeLGSum[i]=0;
128 
129  fhRawTimeVsIdBC[i]=0;
130  fhRawTimeSumBC[i]=0;
131  fhRawTimeEntriesBC[i]=0;
132  fhRawTimeSumSqBC[i]=0;
133 
134  fhRawTimeVsIdLGBC[i]=0;
135  fhRawTimeSumLGBC[i]=0;
137  fhRawTimeSumSqLGBC[i]=0;
138  }
139 
140  //set default cuts for calibration and geometry name
141  SetDefaultCuts();
142 
143  //T0 TOF time
145 
146  // Define input and output slots here
147  // Input slot #0 works with a TChain
148  DefineInput(0, TChain::Class());
149 
150  // Output slot #0 id reserved by the base class for AOD
151  // Output slot #1 writes into a TH1 container
152  DefineOutput(1, TList::Class());
153 
154 } // End ctor
155 
156 //_____________________________________________________________________
162 //void AliAnalysisTaskEMCALTimeCalib::LocalInit()
163 //{
164 // AliDebug(1,"AliAnalysisTaskEMCALTimeCalib::LocalInit()");
165 //}
166 
168 //_____________________________________________________________________
170 {
171  if(fReferenceFileName.Length()!=0){
172  TFile *myFile = TFile::Open(fReferenceFileName.Data());
173  AliInfo(Form("Reference file: %s, pointer %p",fReferenceFileName.Data(),myFile));
174  if(myFile==0x0) {
175  AliFatal("*** NO REFERENCE FILE");
176  } else {
177  AliDebug(1,"*** OK TFILE");
178  // connect ref run here
179  for(Int_t i = 0; i < kNBCmask; i++)
180  {
181  fhAllAverageBC[i]=(TH1F*) myFile->Get(Form("hAllTimeAvBC%d",i));
182  if(fhAllAverageBC[i]==0x0) AliFatal(Form("Reference histogram for BC%d does not exist",i));
183  if(fhAllAverageBC[i]->GetEntries()==0)AliWarning(Form("fhAllAverageLGBC[%d]->GetEntries() = 0",i));
184  fhAllAverageLGBC[i]=(TH1F*) myFile->Get(Form("hAllTimeAvLGBC%d",i));
185  if(fhAllAverageLGBC[i]==0x0) AliFatal(Form("Reference LG histogram for BC%d does not exist",i));
186  if(fhAllAverageLGBC[i]->GetEntries()==0)AliFatal(Form("fhAllAverageLGBC[%d]->GetEntries() = 0",i));
187  }
188 
189  AliDebug(1,Form("hAllAverage entries BC0 %d", (Int_t)fhAllAverageBC[0]->GetEntries() ));
190  AliDebug(1,Form("hAllAverage entries BC2 %d",(Int_t)fhAllAverageBC[2]->GetEntries() ));
191  AliDebug(1,Form("hAllAverageLG entries BC0 %d", (Int_t)fhAllAverageLGBC[0]->GetEntries() ));
192  AliDebug(1,Form("hAllAverageLG entries BC2 %d",(Int_t)fhAllAverageLGBC[2]->GetEntries() ));
193 
194  }
195  } else { //end of reference file is provided
196  AliFatal("You require to load reference histos from file but FILENAME is not provided");
197  }
198 } // End of AliAnalysisTaskEMCALTimeCalib::LoadReferenceHistos()
199 
202 //_____________________________________________________________________
204 {
205  // connect ref run here
206 
207  if(fReferenceRunByRunFileName.Length()!=0){
208  TFile *fReferenceFile = TFile::Open(fReferenceRunByRunFileName.Data());
209  AliInfo(Form("Reference R-b-R file: %s, pointer %p",fReferenceRunByRunFileName.Data(),fReferenceFile));
210  if(fReferenceFile==0x0) {
211  AliFatal("*** NO REFERENCE R-B-R FILE");
212  } else {
213  AliDebug(1,"*** OK TFILE");
214 
215 
216  AliInfo(Form("runnumber in LoadReferenceRunByRunHistos() %d, %d, InputEvent %p",fRunNumber,InputEvent()->GetRunNumber(),InputEvent()));
217  AliInfo(Form("fReferenceFile in LoadReferenceRunByRunHistos() %p",fReferenceFile));
218  fReferenceFile->ls();
219  fhRefRuns=(TH1F*) fReferenceFile->Get(Form("h%d",fRunNumber));
220  AliInfo(Form("Pointer to reference histogram %p",fhRefRuns));
221  if(fhRefRuns==0x0) AliFatal(Form("Reference histogram for run %d does not exist",fRunNumber));
222  if(fhRefRuns->GetEntries()==0)AliWarning("fhRefRuns->GetEntries() = 0");
223  AliDebug(1,Form("hRefRuns entries %d", (Int_t)fhRefRuns->GetEntries() ));
224  }
225  } else { //end of reference file is provided
226  AliFatal("You require to load reference run-by-run histos from file but FILENAME is not provided");
227  }
228 
229 
230 
231 } // End of AliAnalysisTaskEMCALTimeCalib::LoadReferenceRunByRunHistos()
232 
233 //_____________________________________________________________________
237 {
238  AliDebug(1,"AnalysisTaskEMCalTimeCalib::NotifyRun()");
239  AliDebug(2,Form("Notify(): EMCal geometry: fgeom = %p, fGeometryName=%s\n ",fgeom,fGeometryName.Data()));
240 
241  if (!InputEvent())
242  {
243  AliFatal("ERROR: InputEvent not set");
244  return;
245  }
246  else AliDebug(1,"Good, InputEvent set");
247 
248  // AliInfo(Form("NotifyRun, fCurrentRunnumber %d",fCurrentRunNumber));
249  fRunNumber = InputEvent()->GetRunNumber();
250  AliDebug(1,Form("RunNumber %d", fRunNumber));
251 
252  // Init EMCAL geometry
253  if (!fgeom) SetEMCalGeometry();
254  //Init EMCAL geometry done
255 
256  if(fReferenceRunByRunFileName.Length()!=0)
258 
259  return;
260 }
261 
262 //_____________________________________________________________________
265 {
266  AliDebug(1,"AliAnalysisTaskEMCALTimeCalib::SetEMCalGeometry()");
267  if(fGeometryName.Length()==0){
268  fgeom=AliEMCALGeometry::GetInstanceFromRunNumber(fRunNumber);
269  AliInfo(Form("Get EMCAL geometry name <%s> for run %d",fgeom->GetName(),fRunNumber));
270  } else {
271  fgeom = AliEMCALGeometry::GetInstance(fGeometryName.Data());
272  AliInfo(Form("Set EMCAL geometry name to <%s>",fGeometryName.Data()));
273  }
274 
275  if (!fgeom){
276  AliWarning("Make sure the EMCal geometry is set properly !");
277  } else {
278  AliDebug(1,Form("EMCal geometry properly set: fGeom = %p, fGeometryName=%s",fgeom,fGeometryName.Data()));
279  }
280 
281  return kTRUE;
282 }
283 
284 //_____________________________________________________________________
287 {
288  //method under development
289  AliInfo(Form("<D> -- Run # = %d", fRunNumber));
290  AliInfo("prepare TOFT0maker!!");
291  //cout<<"Run "<< fRunNumber<<" in TOFT0maker"<<endl;
292 
293 
294  AliCDBManager * cdb = AliCDBManager::Instance();
295  cdb->SetDefaultStorage("raw://");
296  cdb->SetRun(fRunNumber);
297 
298  AliESDpid *extPID=new AliESDpid();
299 
300  // Wonder if some have to be declared as private variables??
301  // AliESDpid *extPID = new AliESDpid();
302  // AliTOFcalib * tofCalib = new AliTOFcalib();
303  // tofCalib->SetCalibrateTOFsignal(kTRUE);
304  // tofCalib->Init();
305 
306  fTOFmaker = new AliTOFT0maker(extPID);
307  fTOFmaker->SetTimeResolution(115.0); // if you want set the TOF res
308  // fTOFmaker = new AliTOFT0maker(extPID,tofCalib);
309  // fTOFmaker->SetTimeResolution(130.0);
310 
311  //cout<<"extPID "<<extPID<<" fTOFmaker "<<fTOFmaker<<endl;
312 
313 }// End PrepareTOFT0maker
314 
315 //________________________________________________________________________
319 {
320  AliDebug(1,"AliAnalysisTaskEMCALTimeCalib::UserCreateOutputObjects()");
321 
322  Double_t fineTmin = -500;
323  Double_t fineTmax = 400;
324  Double_t fineInterval = 0.20;
325  Int_t nfinebin = (fineTmax-fineTmin)/fineInterval;
326  //cout << "<D> nfinebin = " << nfinebin << endl;
327 
328  Int_t nChannels = 17664;
329  //book histograms
330  fhcalcEvtTime = new TH1F("fhcalcEvtTime","calculated event time from T0",nfinebin, fineTmin,fineTmax);
331  fhcalcEvtTime->GetXaxis()->SetTitle("T ");
332  fhcalcEvtTime->GetYaxis()->SetTitle("Counts (a.u.)");
333 
334  fhEvtTimeHeader = new TH1F("fhEvtTimeHeader","event time from header",nfinebin, fineTmin,fineTmax);
335  fhEvtTimeHeader->GetXaxis()->SetTitle("T ");
336  fhEvtTimeHeader->GetYaxis()->SetTitle("Counts (a.u.)");
337 
338  fhEvtTimeDiff = new TH1F("fhEvtTimeDiff","event time difference",nfinebin, fineTmin,fineTmax);
339  fhEvtTimeDiff->GetXaxis()->SetTitle("#Delta T ");
340  fhEvtTimeDiff->GetYaxis()->SetTitle("Counts (a.u.)");
341 
342  fhEventType = new TH1F("fhEventType","event type",10, 0.,10.);
343  fhEventType ->GetXaxis()->SetTitle("Type ");
344  fhEventType ->GetYaxis()->SetTitle("Counts (a.u.)");
345  fhTcellvsTOFT0 = new TH2F("hTcellvsTOFT0", " T_cell vs TOFT0", 500,-600.0,+400.0,1200,300.0,900.0);
346  fhTcellvsTOFT0HD = new TH2F("hTcellvsTOFT0HD", " T_cell vs TOFT0,HighEnergy", 500,-600.0,+400.0,4000,500.0,700.0);
347  fhTcellvsSM = new TH2F("hTcellvsSM", " T_cell vs SM", 20,0,20,300,300,900);
348  fhEneVsAbsIdHG = new TH2F("fhEneVsAbsIdHG", "energy vs ID for HG",1000,0,18000,200,0,10);
349  fhEneVsAbsIdLG = new TH2F("fhEneVsAbsIdLG", "energy vs ID for LG",1000,0,18000,100,0,20);
350 
351  for (Int_t i = 0; i < kNBCmask ; i++)
352  {
353  //already after correction
354  //high gain
355  fhTimeSumSq[i] = new TH1F(Form("hTimeSumSq%d", i),
356  Form("cell Sum Square time HG, BC %d ", i),
357  nChannels,0.,(Double_t)nChannels);
358  fhTimeSumSq[i]->SetYTitle("Sum Sq Time ");
359  fhTimeSumSq[i]->SetXTitle("AbsId");
360 
361  fhTimeSum[i] = new TH1F(Form("hTimeSum%d", i),
362  Form("cell Sum time HG, BC %d ", i),
363  nChannels,0.,(Double_t)nChannels);
364  fhTimeSum[i]->SetYTitle("Sum Time ");
365  fhTimeSum[i]->SetXTitle("AbsId");
366 
367  fhTimeEnt[i] = new TH1F(Form("hTimeEnt%d", i),
368  Form("cell Entries HG, BC %d ", i),
369  nChannels,0.,(Double_t)nChannels);
370  fhTimeEnt[i]->SetYTitle("Entries for Time ");
371  fhTimeEnt[i]->SetXTitle("AbsId");
372 
373  //low gain
374  fhTimeLGSumSq[i] = new TH1F(Form("hTimeLGSumSq%d", i),
375  Form("cell Sum Square time LG, BC %d ", i),
376  nChannels,0.,(Double_t)nChannels);
377  fhTimeLGSumSq[i]->SetYTitle("Sum Sq Time ");
378  fhTimeLGSumSq[i]->SetXTitle("AbsId");
379 
380  fhTimeLGSum[i] = new TH1F(Form("hTimeLGSum%d", i),
381  Form("cell Sum time LG, BC %d ", i),
382  nChannels,0.,(Double_t)nChannels);
383  fhTimeLGSum[i]->SetYTitle("Sum Time ");
384  fhTimeLGSum[i]->SetXTitle("AbsId");
385 
386  fhTimeLGEnt[i] = new TH1F(Form("hTimeLGEnt%d", i),
387  Form("cell Entries LG, BC %d ", i),
388  nChannels,0.,(Double_t)nChannels);
389  fhTimeLGEnt[i]->SetYTitle("Entries for Time ");
390  fhTimeLGEnt[i]->SetXTitle("AbsId");
391 
392  //raw time histograms
393  //high gain
394  fhRawTimeVsIdBC[i] = new TH2F(Form("RawTimeVsIdBC%d", i),
395  Form("cell raw time vs ID for high gain BC %d ", i),
396  nChannels,0.,(Double_t)nChannels,600,300,900);
397  fhRawTimeVsIdBC[i]->SetXTitle("AbsId");
398  fhRawTimeVsIdBC[i]->SetYTitle("Time");
399 
400  fhRawTimeSumBC[i] = new TH1F(Form("RawTimeSumBC%d", i),
401  Form("sum of cell raw time for high gain BC %d ", i),
402  nChannels,0.,(Double_t)nChannels);
403  fhRawTimeSumBC[i]->SetXTitle("AbsId");
404  fhRawTimeSumBC[i]->SetYTitle("Sum Time");
405 
406  fhRawTimeEntriesBC[i] = new TH1F(Form("RawTimeEntriesBC%d", i),
407  Form("No. entries of cells raw time for high gain BC %d ", i),
408  nChannels,0.,(Double_t)nChannels);
409  fhRawTimeEntriesBC[i]->SetXTitle("AbsId");
410  fhRawTimeEntriesBC[i]->SetYTitle("Entries for Time ");
411 
412  fhRawTimeSumSqBC[i] = new TH1F(Form("RawTimeSumSqBC%d", i),
413  Form("sum of (cell raw time)^2 for high gain BC %d ", i),
414  nChannels,0.,(Double_t)nChannels);
415  fhRawTimeSumSqBC[i]->SetXTitle("AbsId");
416  fhRawTimeSumSqBC[i]->SetYTitle("Sum Sq Time");
417 
418  //low gain
419  fhRawTimeVsIdLGBC[i] = new TH2F(Form("RawTimeVsIdLGBC%d", i),
420  Form("cell raw time vs ID for low gain BC %d ", i),
421  nChannels,0.,(Double_t)nChannels,600,300,900);
422  fhRawTimeVsIdLGBC[i]->SetXTitle("AbsId");
423  fhRawTimeVsIdLGBC[i]->SetYTitle("Time");
424 
425  fhRawTimeSumLGBC[i] = new TH1F(Form("RawTimeSumLGBC%d", i),
426  Form("sum of cell raw time for low gain BC %d ", i),
427  nChannels,0.,(Double_t)nChannels);
428  fhRawTimeSumLGBC[i]->SetXTitle("AbsId");
429  fhRawTimeSumLGBC[i]->SetYTitle("Sum Time");
430 
431  fhRawTimeEntriesLGBC[i] = new TH1F(Form("RawTimeEntriesLGBC%d", i),
432  Form("No. entries of cells raw time for low gain BC %d ", i),
433  nChannels,0.,(Double_t)nChannels);
434  fhRawTimeEntriesLGBC[i]->SetXTitle("AbsId");
435  fhRawTimeEntriesLGBC[i]->SetYTitle("Entries for Time ");
436 
437  fhRawTimeSumSqLGBC[i] = new TH1F(Form("RawTimeSumSqLGBC%d", i),
438  Form("sum of (cell raw time)^2 for low gain BC %d ", i),
439  nChannels,0.,(Double_t)nChannels);
440  fhRawTimeSumSqLGBC[i]->SetXTitle("AbsId");
441  fhRawTimeSumSqLGBC[i]->SetYTitle("Sum Sq Time");
442 
443 
444  for (Int_t j = 0; j < kNSM ; j++)
445  {
446  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);
447  fhTimeDsupBC[j][i]->SetYTitle(" Time (ns) ");
448  fhTimeDsupBC[j][i]->SetXTitle(" E (GeV) ");
449  }
450  }
451 
452  for (Int_t jj = 0; jj < kNSM ; jj++)
453  {
454  fhTimeDsup[jj] = new TH2F(Form("SupMod%d",jj), Form("SupMod %d time_vs_E ",jj),500,0.0,20.0,1400,-350.0,350.0);
455  fhTimeDsup[jj]->SetYTitle(" Time (ns) ");
456  fhTimeDsup[jj]->SetXTitle(" E (GeV) ");
457  }
458 
459  fhTimeVsBC = new TH2F("TimeVsBC"," SupMod time_vs_BC ", 4001,-0.5,4000.5,400,200.0,1000.0);
460 
461 
462  //add histos to list
463  fOutputList = new TList();
464 
468  fOutputList->Add(fhEventType);
471  fOutputList->Add(fhTcellvsSM);
474 
475  for (Int_t i = 0; i < kNBCmask ; i++)
476  {
477  fOutputList->Add(fhTimeSumSq[i]);
478  fOutputList->Add(fhTimeEnt[i]);
479  fOutputList->Add(fhTimeSum[i]);
480 
481  fOutputList->Add(fhTimeLGSumSq[i]);
482  fOutputList->Add(fhTimeLGEnt[i]);
483  fOutputList->Add(fhTimeLGSum[i]);
484 
485  fOutputList->Add(fhRawTimeVsIdBC[i]);
486  fOutputList->Add(fhRawTimeSumBC[i]);
488  fOutputList->Add(fhRawTimeSumSqBC[i]);
489 
491  fOutputList->Add(fhRawTimeSumLGBC[i]);
494 
495  for (Int_t j = 0; j < kNSM ; j++){
496  fOutputList->Add(fhTimeDsupBC[j][i]);
497  }
498  }
499 
500  for (Int_t j = 0; j < kNSM ; j++)
501  {
502  fOutputList->Add(fhTimeDsup[j]);
503  }
504 
505  fOutputList->Add(fhTimeVsBC);
506 
507  fOutputList->SetOwner(kTRUE);
508  PostData(1,fOutputList);
509 
510 
511 } // End of AliAnalysisTaskEMCALTimeCalib::UserCreateOuputObjects()
512 
513 //________________________________________________________________________
516 {
517  // Called for each event
518  AliDebug(2,Form("UserExec: EMCal geometry: fgeom = %p fGeometryName %s",fgeom,fGeometryName.Data()));
519  AliVEvent *event = InputEvent();
520  //cout<<"T0TOF "<<event->GetT0TOF()<<endl;//bad idea
521  //cout<< fEvent->GetTOFHeader()->GetDefaultEventTimeVal()<<endl;
522  AliDebug(2,Form("TOF time from header %f ps",event->GetTOFHeader()->GetDefaultEventTimeVal()));
523  fhEvtTimeHeader->Fill(event->GetTOFHeader()->GetDefaultEventTimeVal());
524 
525  //fEvent = dynamic_cast<AliESDEvent*>(event);
526  if (!event) {
527  AliError("ESD not available, exit");
528  fhEventType->Fill(0.5);
529  return;
530  }
531 
532  if(fPileupFromSPD==kTRUE){
533  if(event->IsPileupFromSPD(3,0.8,3.,2.,5.)){
534  AliDebug(1,"Event: PileUp skip.");
535  fhEventType->Fill(1.5);
536  return;
537  }
538  }
539 
540  TString triggerclasses = event->GetFiredTriggerClasses();
541  if(triggerclasses=="") {
542  fhEventType->Fill(2.5);
543  return;
544  }
545 
546  Int_t eventType = ((AliVHeader*)event->GetHeader())->GetEventType();
547  // physics events eventType=7, select only those
548  AliDebug(1,Form("Triggerclasses %s, eventType %d",triggerclasses.Data(),eventType));
549  if(eventType != 7) {
550  fhEventType->Fill(3.5);
551  return;
552  }
553 
554  // Check trigger
555  Bool_t bMB = kFALSE;
556  Bool_t bL0 = kFALSE;
557  Bool_t bL1G = kFALSE;
558  Bool_t bL1J = kFALSE;
559 
560  if(triggerclasses.Contains("CINT7-B-NOPF-ALLNOTRD") ||
561  triggerclasses.Contains("CINT7-I-NOPF-ALLNOTRD") ||
562  triggerclasses.Contains("CINT1-I-NOPF-ALLNOTRD") ||
563  triggerclasses.Contains("CINT1-B-NOPF-ALLNOTRD") ||
564  triggerclasses.Contains("CINT8") ||
565  triggerclasses.Contains("CINT7") ||
566  triggerclasses.Contains("CPBI2_B1-B-NOPF-ALLNOTRD") ) bMB = kTRUE;
567 
568  if(triggerclasses.Contains("CEMC7-B-NOPF-CENTNOTRD") ||
569  triggerclasses.Contains("CEMC1-B-NOPF-CENTNOTRD") ||
570  triggerclasses.Contains("CEMC7") ||
571  triggerclasses.Contains("CEMC8") ||
572  triggerclasses.Contains("CEMC8-B-NOPF-CENTNOTRD") ) bL0 = kTRUE;
573 
574  if(triggerclasses.Contains("CEMC7EG1-B-NOPF-CENTNOTRD") ||
575  triggerclasses.Contains("CEMC7EG2-B-NOPF-CENTNOTRD") ||
576  triggerclasses.Contains("CEMC8EG1-B-NOPF-CENTNOTRD") ||
577  triggerclasses.Contains("CEMC8EGA") ||
578  triggerclasses.Contains("CEMC7EGA") ||
579  triggerclasses.Contains("CPBI2EGA") ) bL1G = kTRUE;
580 
581 
582  if(triggerclasses.Contains("CEMC7EJ1-B-NOPF-CENTNOTRD") ||
583  triggerclasses.Contains("CEMC7EJ2-B-NOPF-CENTNOTRD") ||
584  triggerclasses.Contains("CEMC8EJ1-B-NOPF-CENTNOTRD") ||
585  triggerclasses.Contains("CEMC7EJE") ||
586  triggerclasses.Contains("CEMC8EJE") ||
587  triggerclasses.Contains("CPBI2EJE") ) bL1J = kTRUE;
588 
589  if( bL1G || bL1J || bL0 ){ fhEventType->Fill(4.5);}
590  if( bMB ){ fhEventType->Fill(5.5);}
591 
592 
593  // if(bL1G || bL1J || bL0){
594 
595 // Prepare TOFT0 maker at the beginning of a run
596 // if (event->GetRunNumber() != fRunNumber){
597 // AliInfo(Form("Runno per event %d",event->GetRunNumber()));
598 // fRunNumber = event->GetRunNumber();
599 // // PrepareTOFT0maker();
600 // // cout<<"tofT0maker per run"<<fRunNumber<<endl;
601 // }// fi Check if run number has changed
602 
603  // --- Use of AliTOFT0maker
604  Double_t calcolot0=0.0;
605  if(!AODEvent()){
606  Double_t* timeTOFtable;
607  timeTOFtable=fTOFmaker->ComputeT0TOF(dynamic_cast<AliESDEvent*>(event));
608  AliDebug(2,Form("TOF time %f ps, resolution %f ps, tracks at TOF %f/used %f",timeTOFtable[0],timeTOFtable[1],timeTOFtable[3],timeTOFtable[7]));
609  //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;
610  calcolot0=timeTOFtable[0];
611  }
612 
613  if (!fhcalcEvtTime) {
614  AliWarning("<E> fhcalcEvtTime not available");
615  return;
616  }// fi no simple histo present
617 
618  fhcalcEvtTime->Fill(calcolot0);
619  if(calcolot0 != 0 && event->GetTOFHeader()->GetDefaultEventTimeVal() != 0 )
620  fhEvtTimeDiff->Fill(calcolot0-event->GetTOFHeader()->GetDefaultEventTimeVal());
621 
622  TRefArray* caloClusters = new TRefArray();
623  event->GetEMCALClusters(caloClusters);
624  // cout << " ###########Bunch Cross nb = " << event->GetBunchCrossNumber() << endl;
625 
626  Int_t BunchCrossNumber =event->GetBunchCrossNumber();
627 
628  Float_t offset=0.;
629  Float_t offsetPerSM=0.;
630  Int_t L1phase=0;
631 
632  Int_t nBC = 0;
633  nBC = BunchCrossNumber%4;
634  //Int_t nTriggerMask =event->GetTriggerMask();
635  // cout << " nBC " << nBC << " nTriggerMask " << nTriggerMask<< endl;
636  Float_t timeBCoffset = 0.; //manual offest
637  // if( nBC%4 ==0 || nBC%4==1) timeBCoffset = 100.; // correction was for LHC11 when BC was not corrected
638 
639  Int_t nclus = caloClusters->GetEntries();
640  AliDebug(1,Form("###########Bunch Cross nb = %d nclus = %d",nBC,nclus ));
641  //cout << " ###########Bunch Cross nb = " << nBC <<" nclus= "<< nclus<< endl;
642  //Int_t ntracks = event-> GetNumberOfTracks() ;
643 
644  AliVCaloCells &cells= *(event->GetEMCALCells());//it is cluster independent
645  //Variables used plenty in loops
646  Int_t nSupMod=-1, nModule=-1;
647  Int_t iphi=-1, ieta=-1, nIphi=-1, nIeta=-1;
648  Int_t absId=-1;
649  Float_t hkdtime=0.0;
650  Float_t amp=0.0;
651  Bool_t isHighGain=kTRUE;
652 
653  for (Int_t icl = 0; icl < nclus; icl++) {
654  //ESD and AOD CaloCells carries the same information
655  AliVCluster* clus = (AliVCluster*)caloClusters->At(icl);
656  if(!AcceptCluster(clus)) continue;
657 
658  //cout<<"nCells="<< clus->GetNCells();<<endl;
659 
660  UShort_t * index = clus->GetCellsAbsId() ;
661 
662  for(Int_t i = 0; i < clus->GetNCells() ; i++) {
663  absId = index[i]; // or clus->GetCellNumber(i) ;
664  hkdtime = cells.GetCellTime(absId) * 1.0e09; // to get ns
665  amp = cells.GetCellAmplitude(absId) ;
666  isHighGain = cells.GetCellHighGain(absId);
667  //cout<<"cell absID: "<<absId<<" cellTime: "<<hkdtime<<" cellaplit: "<< amp<<endl;
668 
669  //main histograms with raw time information
670  if(amp>fMinCellEnergy){
671  if(isHighGain){
672  fhRawTimeVsIdBC[nBC]->Fill(absId,hkdtime);
673  fhRawTimeSumBC[nBC]->Fill(absId,hkdtime);
674  fhRawTimeEntriesBC[nBC]->Fill(absId,1.);
675  fhRawTimeSumSqBC[nBC]->Fill(absId,hkdtime*hkdtime);
676  }else{
677  fhRawTimeVsIdLGBC[nBC]->Fill(absId,hkdtime);
678  fhRawTimeSumLGBC[nBC]->Fill(absId,hkdtime);
679  fhRawTimeEntriesLGBC[nBC]->Fill(absId,1.);
680  fhRawTimeSumSqLGBC[nBC]->Fill(absId,hkdtime*hkdtime);
681  }
682  }
683  //fgeom->PrintCellIndexes(absId);
684  //fgeom->PrintCellIndexes(absId,1);
685 
686  // GEOMETRY tranformations
687  fgeom->GetCellIndex(absId, nSupMod, nModule, nIphi, nIeta);
688  fgeom->GetCellPhiEtaIndexInSModule(nSupMod,nModule,nIphi,nIeta, iphi,ieta);
689 
690  // other histograms for cross-check
691  CheckCellRCU(nSupMod,ieta,iphi);//SM, column, row
692 
693  fhTcellvsSM->Fill(nSupMod,hkdtime);
694  if(isHighGain==kTRUE) {fhEneVsAbsIdHG->Fill(absId,amp);}
695  else {fhEneVsAbsIdLG->Fill(absId,amp);}
696 
697  fhTimeVsBC->Fill(1.*BunchCrossNumber,hkdtime-timeBCoffset);
698  //important remark: We use 'Underflow bin' for absid=0 in OADB for time calibration
699  if(isHighGain==kTRUE){
700  if(fhAllAverageBC[nBC]!=0) {//comming from file after the first iteration
701  offset = (Float_t)(fhAllAverageBC[nBC]->GetBinContent(absId));//channel absId=0 has histogram bin=0
702  } else if(fReferenceFileName.Length()!=0){//protection against missing reference histogram
703  AliFatal(Form("Reference histogram for BC%d not properly loaded",nBC));
704  }
705  } else {
706  if(fhAllAverageLGBC[nBC]!=0) {//comming from file after the first iteration
707  offset = (Float_t)(fhAllAverageLGBC[nBC]->GetBinContent(absId));//channel absId=0 has histogram bin=0
708  } else if(fReferenceFileName.Length()!=0){//protection against missing reference histogram
709  AliFatal(Form("Reference LG histogram for BC%d not properly loaded",nBC));
710  }
711  }
712  //if(offset==0)cout<<"offset 0 in SM "<<nSupMod<<endl;
713 
714  // Solution for 2015 data where L1 phase is not correct in data. We need to calibrate run by run.
715  // The shift is done per SM (0-19).
716  if(fhRefRuns!=0) {//comming from file after the first iteration
717  //offsetPerSM = (Float_t)(fhRefRuns->GetBinContent(nBC*kNSM+nSupMod));//BC0SM0 = bin0
718  L1phase = (Int_t)(fhRefRuns->GetBinContent(nSupMod));//SM0 = bin0
719  if(nBC >= L1phase)
720  offsetPerSM = (nBC - L1phase)*25;
721  else
722  offsetPerSM = (nBC - L1phase + 4)*25;
723  } else if(fReferenceRunByRunFileName.Length()!=0){//protection against missing reference histogram
724  AliFatal("Reference histogram run-by-run not properly loaded");
725  }
726  //end of load additional offset
727 
728  if(amp>0.5) {
729  fhTimeDsup[nSupMod]->Fill(amp,hkdtime-offset-offsetPerSM);
730  fhTimeDsupBC[nSupMod][nBC]->Fill(amp,hkdtime-offset-offsetPerSM);
731  }
732 
733  if(amp>0.9) {
734  fhTcellvsTOFT0HD->Fill(calcolot0, hkdtime);
735  }
736 
737  fhTcellvsTOFT0->Fill(calcolot0, hkdtime-offset-offsetPerSM);
738 
739  hkdtime = hkdtime-timeBCoffset;//time corrected by manual offset (default=0)
740  Float_t hkdtimecorr;
741  hkdtimecorr= hkdtime-offset-offsetPerSM;//time after first iteration
742 
743  //main histograms after the first itereation for calibration constants
744  //if(hkdtimecorr>=-20. && hkdtimecorr<=20. && amp>0.9 ) {
745  if(hkdtimecorr>=fMinTime && hkdtimecorr<=fMaxTime && amp>fMinCellEnergy ) {
746  // per cell
747 // Float_t entriesTime=fhTimeEnt[nBC]->GetBinContent(absId)+1;
748 // Float_t sumTimeSq=(fhTimeSumSq[nBC]->GetBinContent(absId)+(hkdtime*hkdtime));
749 // Float_t sumTime=(fhTimeSum[nBC]->GetBinContent(absId)+hkdtime);
750 //
751 // fhTimeEnt[nBC]->SetBinContent(absId,entriesTime);
752 // fhTimeSumSq[nBC]->SetBinContent(absId,sumTimeSq);
753 // fhTimeSum[nBC]->SetBinContent(absId,sumTime);
754 
755  //correction in 2015 for wrong phase
756  if(offsetPerSM!=0) hkdtime=hkdtime-offsetPerSM;
757 
758  if(isHighGain){
759  fhTimeEnt[nBC]->Fill(absId,1.);
760  fhTimeSumSq[nBC]->Fill(absId,hkdtime*hkdtime);
761  fhTimeSum[nBC]->Fill(absId,hkdtime);
762  }else{
763  fhTimeLGEnt[nBC]->Fill(absId,1.);
764  fhTimeLGSumSq[nBC]->Fill(absId,hkdtime*hkdtime);
765  fhTimeLGSum[nBC]->Fill(absId,hkdtime);
766  }
767 
768 
769  } // hkdtime:[-20;20]
770  } // end icell
771  } //end cluster
772 
773 
774  // Post output data.
775  //cout<<"Post data and delete caloClusters"<<endl;
776  caloClusters->Delete();
777  delete caloClusters;
778 // } // end if trigger type
779 
780  PostData(1, fOutputList);
781 } // End of AliAnalysisTaskEMCALTimeCalib::UserExec()
782 
783 //________________________________________________________________________
787 {
788  fOutputList = dynamic_cast<TList*> (GetOutputData(1));
789 
790  if(fTOFmaker) delete fTOFmaker;
791 
792 
793  if (!fOutputList)
794  {
795  AliDebug(1,"ERROR: Output list not available");
796  return;
797  }
798 } // End of AliAnalysisTaskEMCALTimeCalib::Terminate
799 
800 //________________________________________________________________________
803 {
804  //fix with noisy EMCAL fee card
805  Int_t nCells = clus->GetNCells();
806 
807  if(clus->IsEMCAL())
808  {
809  if ((clus->E() > fMaxClusterEnergy && nCells > fMaxNcells ) || nCells > fMaxNcells){
810  AliDebug(1,"very big cluster with enormous energy - cluster rejected");
811  return kFALSE;
812  }
813  }
814 
815  // remove other than photonlike
816  Double_t lambda0=clus->GetM02();
817  if (lambda0>fMaxLambda0LG || lambda0<fMinLambda0LG){
818  AliDebug(1,"lambda0 loose cut failed - cluster rejected");
819  return kFALSE;
820  }
821 
822  // remove matched clusters
823  Double_t Dx=clus->GetTrackDx();
824  Double_t Dz=clus->GetTrackDz();
825  Double_t Rtrack = TMath::Sqrt(Dx*Dx+Dz*Dz);
826  if (Rtrack <fMaxRtrack)
827  {
828  AliDebug(1,"track matched - cluster rejected");
829  return kFALSE;
830  }
831 
832  if (nCells<fMinNcells)
833  {
834  AliDebug(1,"single cell cluster - cluster rejected");
835  return kFALSE;
836  }
837 
838  if(clus->E()<fMinClusterEnergy)
839  {
840  AliDebug(1,"cluster energy < 1 GeV- cluster rejected");
841  return kFALSE;
842  }
843 
844 
845  if(!IsLowGainCellInCluster(clus)) {//no low gain cell in cluster
846  //apply more strict lambda0^2 cut
847  if (lambda0>fMaxLambda0 || lambda0<fMinLambda0){
848  AliDebug(1,"lambda0 strict cut failed - cluster rejected");
849  return kFALSE;
850  }
851  }
852 
853 
854 
855 
856  return kTRUE;
857 }//End AliAnalysisTaskEMCALTimeCalib::AcceptCluster
858 
859 //________________________________________________________________________
862  UShort_t * index = clus->GetCellsAbsId() ;
863  AliVCaloCells &cells= *(InputEvent()->GetEMCALCells());
864  for(Int_t i = 0; i < clus->GetNCells() ; i++) {
865  if(cells.GetCellHighGain(index[i])==kFALSE) return kTRUE;//low gain cell
866  }
867  return kFALSE;
868 
869 }
870 
871 //________________________________________________________________________
873 Bool_t AliAnalysisTaskEMCALTimeCalib::CheckCellRCU(Int_t nSupMod,Int_t icol,Int_t irow)
874 {
875  Int_t iRCU;
876  if(nSupMod < 10 || (nSupMod >= 12 && nSupMod <18) )
877  {
878  if (0<=irow&&irow<8) iRCU=0; // first cable row
879  else if (8<=irow&&irow<16 && 0<=icol&&icol<24) iRCU=0; // first half;
880  //second cable row
881  //RCU1
882  else if (8<=irow&&irow<16 && 24<=icol&&icol<48) iRCU=1; // second half;
883  //second cable row
884  else if (16<=irow&&irow<24) iRCU=1; // third cable row
885 
886  if (nSupMod%2==1) iRCU = 1 - iRCU; // swap for odd=C side, to allow us to cable both sides the same
887  }
888  else
889  {
890  // Last 2 SM have one single SRU, just assign RCU 0
891  iRCU = 0 ;
892  }
893 
894  //cout<<"RCU:"<<iRCU<<endl;
895  if (iRCU<0)
896  AliFatal(Form("Wrong EMCAL/DCAL RCU number = %d\n", iRCU));
897 
898  return kTRUE;
899 }//End AliAnalysisTaskEMCALTimeCalib::CheckCellRCU
900 
901 //________________________________________________________________________
904 {
905  fMinClusterEnergy=1.0;//0.5//0.7
906  fMaxClusterEnergy=500;
907  fMinNcells=2;
908  fMaxNcells=200;
909  fMinLambda0=0.1;
910  fMaxLambda0=0.4;
911  fMinLambda0LG=0.1;
912  fMaxLambda0LG=4.0;
913  fMaxRtrack=0.025;
914  fMinCellEnergy=0.4;//0.1//0.4
915  fReferenceFileName="";//Reference.root
917  fGeometryName="";//EMCAL_COMPLETE12SMV1_DCAL_8SM
918  fPileupFromSPD=kFALSE;
919  fMinTime=-20.;
920  fMaxTime=20.;
921 }
922 
923 //________________________________________________________________________
928 void AliAnalysisTaskEMCALTimeCalib::ProduceCalibConsts(TString inputFile,TString outputFile,Bool_t isFinal)
929 {
930  TFile *file =new TFile(inputFile.Data());
931  if(file==0x0) {
932  //AliWarning("Input file does not exist!");
933  return;
934  }
935 
936  TList *list=(TList*)file->Get("chistolist");
937  if(list==0x0)
938  {
939  //AliWarning("List chistolist does not exist in file!");
940  return;
941  }
942 
943  //high gain
944  TH1F *h1[4];
945  TH1F *h2[4];
946  TH1F *h3[4];
947  TH1F *hAllTimeAvBC[4];
948  TH1F *hAllTimeRMSBC[4];
949 
950  //low gain
951  TH1F *h4[4];
952  TH1F *h5[4];
953  TH1F *h6[4];
954  TH1F *hAllTimeAvLGBC[4];
955  TH1F *hAllTimeRMSLGBC[4];
956 
957  if(isFinal==kFALSE){//first itereation
958  for(Int_t i=0;i<4;i++){
959  h1[i]=(TH1F *)list->FindObject(Form("RawTimeSumBC%d",i));
960  h2[i]=(TH1F *)list->FindObject(Form("RawTimeEntriesBC%d",i));
961  h3[i]=(TH1F *)list->FindObject(Form("RawTimeSumSqBC%d",i));
962 
963  h4[i]=(TH1F *)list->FindObject(Form("RawTimeSumLGBC%d",i));
964  h5[i]=(TH1F *)list->FindObject(Form("RawTimeEntriesLGBC%d",i));
965  h6[i]=(TH1F *)list->FindObject(Form("RawTimeSumSqLGBC%d",i));
966  }
967  } else {//final iteration
968  for(Int_t i=0;i<4;i++){
969  h1[i]=(TH1F *)list->FindObject(Form("hTimeSum%d",i));
970  h2[i]=(TH1F *)list->FindObject(Form("hTimeEnt%d",i));
971  h3[i]=(TH1F *)list->FindObject(Form("hTimeSumSq%d",i));
972 
973  h4[i]=(TH1F *)list->FindObject(Form("hTimeLGSum%d",i));
974  h5[i]=(TH1F *)list->FindObject(Form("hTimeLGEnt%d",i));
975  h6[i]=(TH1F *)list->FindObject(Form("hTimeLGSumSq%d",i));
976  }
977  }
978  //AliWarning("Input histograms read.");
979 
980  for(Int_t i=0;i<4;i++){
981  hAllTimeAvBC[i]=new TH1F(Form("hAllTimeAvBC%d",i),Form("hAllTimeAvBC%d",i),h1[i]->GetNbinsX(),h1[i]->GetXaxis()->GetXmin(),h1[i]->GetXaxis()->GetXmax());
982  hAllTimeRMSBC[i]=new TH1F(Form("hAllTimeRMSBC%d",i),Form("hAllTimeRMSBC%d",i),h3[i]->GetNbinsX(),h3[i]->GetXaxis()->GetXmin(),h3[i]->GetXaxis()->GetXmax());
983 
984  hAllTimeAvLGBC[i]=new TH1F(Form("hAllTimeAvLGBC%d",i),Form("hAllTimeAvLGBC%d",i),h4[i]->GetNbinsX(),h4[i]->GetXaxis()->GetXmin(),h4[i]->GetXaxis()->GetXmax());
985  hAllTimeRMSLGBC[i]=new TH1F(Form("hAllTimeRMSLGBC%d",i),Form("hAllTimeRMSLGBC%d",i),h6[i]->GetNbinsX(),h6[i]->GetXaxis()->GetXmin(),h6[i]->GetXaxis()->GetXmax());
986  }
987 
988  //AliWarning("New histograms booked.");
989 
990  //important remark: we use 'underflow bin' for absid=0 in OADB . That's why there is j-1 below.
991  for(Int_t i=0;i<4;i++){
992  for(Int_t j=1;j<=h1[i]->GetNbinsX();j++){
993  //high gain
994  if(h2[i]->GetBinContent(j)!=0){
995  hAllTimeAvBC[i]->SetBinContent(j-1,h1[i]->GetBinContent(j)/h2[i]->GetBinContent(j));
996  hAllTimeRMSBC[i]->SetBinContent(j-1,TMath::Sqrt(h3[i]->GetBinContent(j)/h2[i]->GetBinContent(j)) );
997  } else {
998  hAllTimeAvBC[i]->SetBinContent(j-1,0.);
999  hAllTimeRMSBC[i]->SetBinContent(j-1,0.);
1000  }
1001  //low gain
1002  if(h5[i]->GetBinContent(j)!=0){
1003  hAllTimeAvLGBC[i]->SetBinContent(j-1,h4[i]->GetBinContent(j)/h5[i]->GetBinContent(j));
1004  hAllTimeRMSLGBC[i]->SetBinContent(j-1,TMath::Sqrt(h6[i]->GetBinContent(j)/h5[i]->GetBinContent(j)) );
1005  } else {
1006  hAllTimeAvLGBC[i]->SetBinContent(j-1,0.);
1007  hAllTimeRMSLGBC[i]->SetBinContent(j-1,0.);
1008  }
1009 
1010  }
1011  }
1012 
1013  //AliWarning("Average and rms calculated.");
1014  TFile *fileNew=new TFile(outputFile.Data(),"recreate");
1015  for(Int_t i=0;i<4;i++){
1016  hAllTimeAvBC[i]->Write();
1017  hAllTimeRMSBC[i]->Write();
1018  hAllTimeAvLGBC[i]->Write();
1019  hAllTimeRMSLGBC[i]->Write();
1020  }
1021 
1022  //AliWarning(Form("Histograms saved in %s file.",outputFile.Data()));
1023 
1024  fileNew->Close();
1025  delete fileNew;
1026 
1027  for(Int_t i=0;i<4;i++){
1028  delete hAllTimeAvBC[i];
1029  delete hAllTimeRMSBC[i];
1030  delete hAllTimeAvLGBC[i];
1031  delete hAllTimeRMSLGBC[i];
1032  }
1033 
1034  file->Close();
1035  delete file;
1036 
1037  //AliWarning("Pointers deleted. Memory cleaned.");
1038 }
1039 
1040 //________________________________________________________________________
1044 void AliAnalysisTaskEMCALTimeCalib::ProduceOffsetForSMsV2(Int_t runNumber,TString inputFile,TString outputFile){
1045 
1046 const Double_t lowerLimit[]={
1047  0,
1048  1152,
1049  2304,
1050  3456,
1051  4608,
1052  5760,
1053  6912,
1054  8064,
1055  9216,
1056  10368,
1057  11520,
1058  11904,
1059  12288,
1060  13056,
1061  13824,
1062  14592,
1063  15360,
1064  16128,
1065  16896,
1066  17280};
1067 
1068 const Double_t upperLimit[]={
1069  1151 ,
1070  2303 ,
1071  3455 ,
1072  4607 ,
1073  5759 ,
1074  6911 ,
1075  8063 ,
1076  9215 ,
1077  10367,
1078  11519,
1079  11903,
1080  12287,
1081  13055,
1082  13823,
1083  14591,
1084  15359,
1085  16127,
1086  16895,
1087  17279,
1088  17663};
1089 
1090  TFile *file =new TFile(inputFile.Data());
1091  if(file==0x0) return;
1092 
1093  TH1F *ccBC[4];
1094  for(Int_t i = 0; i < kNBCmask; i++){
1095  ccBC[i]=(TH1F*) file->Get(Form("hAllTimeAvBC%d",i));
1096  }
1097 
1098  TH1F *hRun=new TH1F(Form("h%d",runNumber),Form("h%d",runNumber),19,0,19);
1099  Int_t fitResult=0;
1100  Double_t minimumValue=10000;
1101  Int_t minimumIndex=-1;
1102  Double_t meanBC[4];
1103 
1104  Double_t fitParameter=0;
1105  TF1 *f1=new TF1("f1","pol0",0,17664);
1106  for(Int_t i=0;i<20;i++){
1107  minimumValue=10000;
1108  for(Int_t j=0;j<kNBCmask;j++){
1109  fitResult=ccBC[j]->Fit("f1","CQ","",lowerLimit[i],upperLimit[i]);
1110  if(fitResult<0){
1111  hRun->SetBinContent(i,0);
1112  continue;
1113  }
1114  fitParameter = f1->GetParameter(0);
1115  if(j==0 || j==1) {
1116  fitParameter+=100;
1117  }
1118  meanBC[j]=fitParameter;
1119 
1120  if(fitParameter<minimumValue){
1121  minimumValue = fitParameter;
1122  minimumIndex = j;
1123  }
1124  }
1125  hRun->SetBinContent(i,minimumIndex);
1126  }
1127  delete f1;
1128  TFile *fileNew=new TFile(outputFile.Data(),"update");
1129  hRun->Write();
1130  fileNew->Close();
1131  delete fileNew;
1132 
1133  file->Close();
1134  delete file;
1135 }
Bool_t SetEMCalGeometry()
Set the EMCal Geometry.
TH1F * fhRawTimeEntriesLGBC[kNBCmask]
! 4 BCmask LG
TH2F * fhEneVsAbsIdHG
! energy of each cell for high gain cells with strange time
TH1F * fhRawTimeSumLGBC[kNBCmask]
! 4 BCmask LG
ClassImp(AliAnalysisTaskTriggerRates) AliAnalysisTaskTriggerRates
Bool_t AcceptCluster(AliVCluster *clus)
Selection criteria of good cluster are set here.
TH2F * fhRawTimeVsIdBC[kNBCmask]
! 4 BCmask HG
TH1F * fhRawTimeSumSqBC[kNBCmask]
! 4 BCmask HG
Double_t fMinLambda0
minimum cluster lambda0
TFile * fReferenceFile
file with reference for SM
TH1F * fhcalcEvtTime
! spectrum calcolot0[0]
TString fReferenceRunByRunFileName
! name of reference file (run-by-run)
Double_t fMinTime
minimum cluster time after correction
AliTOFT0maker * fTOFmaker
pointer to get T0 from TOF
TList * list
void SetDefaultCuts()
Set default cuts for calibration.
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
TH2F * fhTcellvsTOFT0HD
! time of cell vs TOF T0 time for higher energy threshold
Bool_t IsLowGainCellInCluster(AliVCluster *clus)
Check if low gain cell is in a cluster.
Double_t fMaxTime
maximum cluster time after correction
static void ProduceOffsetForSMsV2(Int_t runNumber, TString inputFile="Reference.root", TString outputFile="ReferenceSM.root")
Double_t fMinClusterEnergy
minimum cluster energy
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
Task to work on Time Calibration for EMCal/DCal.
Double_t fMinLambda0LG
minimum cluster lambda0 Low Gain
Double_t fMaxClusterEnergy
maximum cluster energy
TH1F * fhEvtTimeHeader
! spectrum time from header
TH1F * fhEvtTimeDiff
! spectrum time difference
TH2F * fhTcellvsTOFT0
! time of cell vs TOF T0 time
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
TList * fOutputList
pointer to output list
TH1F * fhRawTimeEntriesBC[kNBCmask]
! 4 BCmask HG
TFile * file
Int_t GetRunNumber(TString)
Definition: PlotMuonQA.C:2235
Bool_t CheckCellRCU(Int_t nSupMod, Int_t icol, Int_t irow)
Check RCU for cell given by Super Module, column index, row index.
TH2F * fhRawTimeVsIdLGBC[kNBCmask]
! 4 BCmask LG
void LoadReferenceHistos()
Load reference Histograms (for one period) from file.
TH1F * fhAllAverageLGBC[kNBCmask]
4 BCmask High gain
TH2F * fhTimeDsup[kNSM]
20 entries per run: nSM
TH2F * fhTimeDsupBC[kNSM][kNBCmask]
! 20 x 4