1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is 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 **************************************************************************/
16 ///////////////////////////////////////////////////////////////////////////
18 // T0 Tender supply //
21 ///////////////////////////////////////////////////////////////////////////
23 #include <AliESDEvent.h>
24 #include <AliESDtrack.h>
26 #include <AliTender.h>
27 #include <AliT0TenderSupply.h>
28 #include <AliCDBManager.h>
29 #include <AliCDBEntry.h>
30 #include <AliT0CalibSeasonTimeShift.h>
33 ClassImp(AliT0TenderSupply)
35 //________________________________________________________________________
36 AliT0TenderSupply::AliT0TenderSupply():
38 fCorrectMeanTime(kFALSE),
39 fCorrectStartTimeOnAmplSatur(kFALSE),
40 fAmplitudeThreshold(100),
41 fPass4LHC11aCorrection(kFALSE)
44 // default constructor
46 for(int i=0; i<4; i++) fTimeOffset[i]=0;
49 //________________________________________________________________________
50 AliT0TenderSupply::AliT0TenderSupply(const char *name, const AliTender *tender):
51 AliTenderSupply(name,tender),
52 fCorrectMeanTime(kFALSE),
53 fCorrectStartTimeOnAmplSatur(kFALSE),
54 fAmplitudeThreshold(100),
55 fPass4LHC11aCorrection(kFALSE)
60 for(int i=0; i<3; i++) fTimeOffset[i]=0;
63 //________________________________________________________________________
64 AliT0TenderSupply::~AliT0TenderSupply(){
71 //________________________________________________________________________
72 void AliT0TenderSupply::Init(){
76 Int_t run = fTender->GetRun();
77 if (run == 0) return; // to skip first init, when we don't have yet a run number
79 fCorrectMeanTime = kFALSE; //reset
80 for(int i=0; i<4; i++) fTimeOffset[i]=0;
83 fCorrectStartTimeOnAmplSatur = kFALSE;
84 fAmplitudeThreshold = 100; //in mips
86 if(167693<= run && run<=170593){ // LHC11h
87 fCorrectStartTimeOnAmplSatur = kTRUE;
88 fAmplitudeThreshold = 50; //in mips
93 //________________________________________________________________________
94 void AliT0TenderSupply::ProcessEvent(){
96 // loop over all online T0 candidates and flag
97 // selected daughter tracks using the status bis of the TObject
100 AliESDEvent *event=fTender->GetEvent();
103 //Do something when the run number changed, like loading OCDB entries etc.
104 if(fTender->RunChanged()){
108 if(fPass4LHC11aCorrection) {
109 const Double32_t* mean = event->GetT0TOF();
110 event->SetT0TOF(0, (mean[1]+mean[2])/2.);
113 if(fCorrectStartTimeOnAmplSatur){
114 //correct A side ORA on amplitude saturation
115 const Double32_t* time = event->GetT0time();
116 const Double32_t* amplitude = event->GetT0amplitude();
118 Int_t idxOfFirstPmtA = -1;
119 Double32_t timeOrA = 99999;
120 for(int ipmt=12; ipmt<24; ipmt++){ //loop over A side
121 if( amplitude[ipmt] < fAmplitudeThreshold){
122 if( time[ipmt] > -200 && time[ipmt]!=0 && time[ipmt] < timeOrA ){
123 timeOrA = time[ipmt];
124 idxOfFirstPmtA = ipmt;
129 if(idxOfFirstPmtA>-1){ //a hit in aside with less than 40 mips
130 const Double32_t* mean = event->GetT0TOF();
131 Double32_t timeOrC = mean[2];
132 Double32_t timeOrAplusOrC = (timeOrA+timeOrC)/2;
134 event->SetT0TOF(0, timeOrAplusOrC);
135 event->SetT0TOF(1, timeOrA);
139 //...........................................
140 Float_t *t0means=0x0;
141 if(fCorrectMeanTime){
142 AliCDBManager* ocdbMan = AliCDBManager::Instance();
143 ocdbMan->SetRun(fTender->GetRun());
144 AliCDBEntry *entry = ocdbMan->Get("T0/Calib/TimeAdjust/");
146 AliT0CalibSeasonTimeShift *clb = (AliT0CalibSeasonTimeShift*) entry->GetObject();
147 t0means= clb->GetT0Means();
149 for (Int_t i=0;i<4;i++) t0means[i]=0;
150 AliWarning("T0Tender no T0 entry found T0shift set to 0");
153 for (Int_t i=0;i<4;i++) t0means=0;
155 // correct mean time offsets
156 const Double32_t* mean = event->GetT0TOF();
157 for(int it0=0; it0<3; it0++){
158 if(-2000 < mean[it0]){
159 event->SetT0TOF(it0, mean[it0] - t0means[it0]);