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 **************************************************************************/
17 ///////////////////////////////////////////////////////////////////////////////
19 // Recalculate VZERO timing and decision using the tender //
20 // (in case the LHC phase drift is updated in OCDB) //
22 ///////////////////////////////////////////////////////////////////////////////
25 #include <TObjString.h>
30 #include <AliESDEvent.h>
31 #include <AliESDVZERO.h>
33 #include <AliCDBManager.h>
34 #include <AliCDBEntry.h>
35 #include <AliTender.h>
36 #include <AliLHCClockPhase.h>
37 #include <AliVZEROCalibData.h>
38 #include <AliVZEROTriggerMask.h>
39 #include <AliVZEROReconstructor.h>
41 #include "AliVZEROTenderSupply.h"
43 ClassImp(AliVZEROTenderSupply)
45 AliVZEROTenderSupply::AliVZEROTenderSupply() :
57 //_____________________________________________________
58 AliVZEROTenderSupply::AliVZEROTenderSupply(const char *name, const AliTender *tender) :
59 AliTenderSupply(name,tender),
70 //_____________________________________________________
71 void AliVZEROTenderSupply::Init()
74 // Initialise VZERO tender
78 //_____________________________________________________
79 void AliVZEROTenderSupply::ProcessEvent()
82 // Reapply the LHC-clock phase drift
85 AliESDEvent *event=fTender->GetEvent();
88 //load gain correction if run has changed
89 if (fTender->RunChanged()){
90 if (fDebug) printf("AliVZEROTenderSupply::ProcessEvent - Run Changed (%d)\n",fTender->GetRun());
93 AliCDBEntry *entryGeom = fTender->GetCDBManager()->Get("GRP/Geometry/Data",fTender->GetRun());
95 AliError("No geometry entry is found");
98 if (fDebug) printf("AliVZEROTenderSupply::Used geometry entry: %s\n",entryGeom->GetId().ToString().Data());
101 AliCDBEntry *entryCal = fTender->GetCDBManager()->Get("VZERO/Calib/Data",fTender->GetRun());
103 AliError("No VZERO calibration entry is found");
107 fCalibData = (AliVZEROCalibData*)entryCal->GetObject();
108 if (fDebug) printf("AliVZEROTenderSupply::Used VZERO calibration entry: %s\n",entryCal->GetId().ToString().Data());
111 AliCDBEntry *entrySlew = fTender->GetCDBManager()->Get("VZERO/Calib/TimeSlewing",fTender->GetRun());
113 AliError("VZERO time slewing function is not found in OCDB !");
117 fTimeSlewing = (TF1*)entrySlew->GetObject();
118 if (fDebug) printf("AliVZEROTenderSupply::Used VZERO time slewing entry: %s\n",entrySlew->GetId().ToString().Data());
122 if (!fCalibData || !fTimeSlewing) {
123 AliWarning("VZERO calibration objects not found!");
127 // correct VZERO time signals and decision
129 AliESDVZERO *esdVZERO = event->GetVZEROData();
131 AliError("No VZERO object is found inside ESD!");
134 if (!esdVZERO->TestBit(AliESDVZERO::kDecisionFilled)) {
135 AliWarning("VZERO offline trigger decisions were not filled in ESD, the tender supply is disabled");
139 if (fDebug) printf("LHC-clock phase correction: %f\n",fLHCClockPhase);
141 if (fDebug) printf("Original VZERO decision %d (%f ns) and %d (%f ns)\n",
142 esdVZERO->GetV0ADecision(),esdVZERO->GetV0ATime(),
143 esdVZERO->GetV0CDecision(),esdVZERO->GetV0CTime());
145 for(Int_t i = 0; i < 64; ++i) {
146 time[i] = esdVZERO->GetTime(i);
147 if (time[i] > (AliVZEROReconstructor::kInvalidTime + 1e-6))
148 time[i] += fLHCClockPhase;
150 esdVZERO->SetTime(time);
153 AliVZEROTriggerMask triggerMask;
154 triggerMask.FillMasks(esdVZERO, fCalibData, fTimeSlewing);
156 if (fDebug) printf("Modified VZERO decision %d (%f ns) and %d (%f ns)\n",
157 esdVZERO->GetV0ADecision(),esdVZERO->GetV0ATime(),
158 esdVZERO->GetV0CDecision(),esdVZERO->GetV0CTime());
162 //_____________________________________________________
163 void AliVZEROTenderSupply::GetPhaseCorrection()
166 // Get Gain splines from OCDB
169 AliInfo("Get LHC-clock phase correction");
172 //find previous entry from the UserInfo
174 TTree *tree=((TChain*)fTender->GetInputData(0))->GetTree();
176 AliError("Tree not found in ESDhandler");
180 TList *userInfo=(TList*)tree->GetUserInfo();
182 AliError("No UserInfo found in tree");
186 TList *cdbList=(TList*)userInfo->FindObject("cdbList");
188 AliError("No cdbList found in UserInfo");
189 if (AliLog::GetGlobalLogLevel()>=AliLog::kError) userInfo->Print();
193 Float_t oldPhase = 0;
195 TIter nextCDB(cdbList);
197 while ( (os=(TObjString*)nextCDB()) ){
198 if (!(os->GetString().Contains("GRP/Calib/LHCClockPhase"))) continue;
199 AliCDBId *id=AliCDBId::MakeFromString(os->GetString());
201 AliCDBEntry *entry=fTender->GetCDBManager()->Get(*id);
203 AliError("The previous LHC-clock phase entry is not found");
208 if (fDebug) printf("AliVZEROTenderSupply::Used old LHC-clock phase entry: %s\n",entry->GetId().ToString().Data());
210 AliLHCClockPhase *phase = (AliLHCClockPhase*)entry->GetObject();
212 AliError("Phase object is not found in the calibration entry");
217 oldPhase = phase->GetMeanPhase();
224 //new LHC-clock phase entry
226 Float_t newPhase = 0;
227 AliCDBEntry *entryNew=fTender->GetCDBManager()->Get("GRP/Calib/LHCClockPhase",fTender->GetRun());
229 AliError("No new LHC-clock phase calibration entry is found");
232 if (fDebug) printf("AliVZEROTenderSupply::Used new LHC-clock phase entry: %s\n",entryNew->GetId().ToString().Data());
234 AliLHCClockPhase *phase2 = (AliLHCClockPhase*)entryNew->GetObject();
236 AliError("Phase object is not found in the calibration entry");
240 newPhase = phase2->GetMeanPhase();
242 fLHCClockPhase = newPhase - oldPhase;