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() :
58 //_____________________________________________________
59 AliVZEROTenderSupply::AliVZEROTenderSupply(const char *name, const AliTender *tender) :
60 AliTenderSupply(name,tender),
72 //_____________________________________________________
73 void AliVZEROTenderSupply::Init()
76 // Initialise VZERO tender
80 //_____________________________________________________
81 void AliVZEROTenderSupply::ProcessEvent()
84 // Reapply the LHC-clock phase drift
87 AliESDEvent *event=fTender->GetEvent();
90 //load gain correction if run has changed
91 if (fTender->RunChanged()){
92 if (fDebug) printf("AliVZEROTenderSupply::ProcessEvent - Run Changed (%d)\n",fTender->GetRun());
95 AliCDBEntry *entryGeom = fTender->GetCDBManager()->Get("GRP/Geometry/Data",fTender->GetRun());
97 AliError("No geometry entry is found");
100 if (fDebug) printf("AliVZEROTenderSupply::Used geometry entry: %s\n",entryGeom->GetId().ToString().Data());
103 AliCDBEntry *entryCal = fTender->GetCDBManager()->Get("VZERO/Calib/Data",fTender->GetRun());
105 AliError("No VZERO calibration entry is found");
109 fCalibData = (AliVZEROCalibData*)entryCal->GetObject();
110 if (fDebug) printf("AliVZEROTenderSupply::Used VZERO calibration entry: %s\n",entryCal->GetId().ToString().Data());
113 AliCDBEntry *entrySlew = fTender->GetCDBManager()->Get("VZERO/Calib/TimeSlewing",fTender->GetRun());
115 AliError("VZERO time slewing function is not found in OCDB !");
119 fTimeSlewing = (TF1*)entrySlew->GetObject();
120 if (fDebug) printf("AliVZEROTenderSupply::Used VZERO time slewing entry: %s\n",entrySlew->GetId().ToString().Data());
123 AliCDBEntry *entryRecoParam = fTender->GetCDBManager()->Get("VZERO/Calib/RecoParam",fTender->GetRun());
124 if (!entryRecoParam) {
125 AliError("VZERO reco-param object is not found in OCDB !");
129 fRecoParam = (AliVZERORecoParam*)entryRecoParam->GetObject();
130 if (fDebug) printf("AliVZEROTenderSupply::Used VZERO reco-param entry: %s\n",entryRecoParam->GetId().ToString().Data());
134 if (!fCalibData || !fTimeSlewing || !fRecoParam) {
135 AliWarning("VZERO calibration objects not found!");
139 // correct VZERO time signals and decision
141 AliESDVZERO *esdVZERO = event->GetVZEROData();
143 AliError("No VZERO object is found inside ESD!");
146 if (!esdVZERO->TestBit(AliESDVZERO::kDecisionFilled)) {
147 AliWarning("VZERO offline trigger decisions were not filled in ESD, the tender supply is disabled");
151 if (fDebug) printf("LHC-clock phase correction: %f\n",fLHCClockPhase);
153 if (fDebug) printf("Original VZERO decision %d (%f ns) and %d (%f ns)\n",
154 esdVZERO->GetV0ADecision(),esdVZERO->GetV0ATime(),
155 esdVZERO->GetV0CDecision(),esdVZERO->GetV0CTime());
157 for(Int_t i = 0; i < 64; ++i) {
158 time[i] = esdVZERO->GetTime(i);
159 if (time[i] > (AliVZEROReconstructor::kInvalidTime + 1e-6))
160 time[i] += fLHCClockPhase;
162 esdVZERO->SetTime(time);
165 AliVZEROTriggerMask triggerMask;
166 triggerMask.SetRecoParam(fRecoParam);
167 triggerMask.FillMasks(esdVZERO, fCalibData, fTimeSlewing);
169 if (fDebug) printf("Modified VZERO decision %d (%f ns) and %d (%f ns)\n",
170 esdVZERO->GetV0ADecision(),esdVZERO->GetV0ATime(),
171 esdVZERO->GetV0CDecision(),esdVZERO->GetV0CTime());
175 //_____________________________________________________
176 void AliVZEROTenderSupply::GetPhaseCorrection()
179 // Get Gain splines from OCDB
182 AliInfo("Get LHC-clock phase correction");
185 //find previous entry from the UserInfo
187 TTree *tree=((TChain*)fTender->GetInputData(0))->GetTree();
189 AliError("Tree not found in ESDhandler");
193 TList *userInfo=(TList*)tree->GetUserInfo();
195 AliError("No UserInfo found in tree");
199 TList *cdbList=(TList*)userInfo->FindObject("cdbList");
201 AliError("No cdbList found in UserInfo");
202 if (AliLog::GetGlobalLogLevel()>=AliLog::kError) userInfo->Print();
206 Float_t oldPhase = 0;
208 TIter nextCDB(cdbList);
210 while ( (os=(TObjString*)nextCDB()) ){
211 if (!(os->GetString().Contains("GRP/Calib/LHCClockPhase"))) continue;
212 AliCDBId *id=AliCDBId::MakeFromString(os->GetString());
214 AliCDBEntry *entry=fTender->GetCDBManager()->Get(*id);
216 AliError("The previous LHC-clock phase entry is not found");
221 if (fDebug) printf("AliVZEROTenderSupply::Used old LHC-clock phase entry: %s\n",entry->GetId().ToString().Data());
223 AliLHCClockPhase *phase = (AliLHCClockPhase*)entry->GetObject();
225 AliError("Phase object is not found in the calibration entry");
230 oldPhase = phase->GetMeanPhase();
237 //new LHC-clock phase entry
239 Float_t newPhase = 0;
240 AliCDBEntry *entryNew=fTender->GetCDBManager()->Get("GRP/Calib/LHCClockPhase",fTender->GetRun());
242 AliError("No new LHC-clock phase calibration entry is found");
245 if (fDebug) printf("AliVZEROTenderSupply::Used new LHC-clock phase entry: %s\n",entryNew->GetId().ToString().Data());
247 AliLHCClockPhase *phase2 = (AliLHCClockPhase*)entryNew->GetObject();
249 AliError("Phase object is not found in the calibration entry");
253 newPhase = phase2->GetMeanPhase();
255 fLHCClockPhase = newPhase - oldPhase;