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 TObjArray *recoParamArr = (TObjArray*)entryRecoParam->GetObject();
130 if (fDebug) printf("AliVZEROTenderSupply::Used VZERO reco-param entry: %s\n",entryRecoParam->GetId().ToString().Data());
132 for(Int_t i = 0; i < recoParamArr->GetEntriesFast(); i++) {
133 AliVZERORecoParam *par = (AliVZERORecoParam*)recoParamArr->At(i);
135 if (par->IsDefault()) fRecoParam = par;
137 if (!fRecoParam) AliError("No default VZERO reco-param object is found in OCDB !");
141 if (!fCalibData || !fTimeSlewing || !fRecoParam) {
142 AliWarning("VZERO calibration objects not found!");
146 // correct VZERO time signals and decision
148 AliESDVZERO *esdVZERO = event->GetVZEROData();
150 AliError("No VZERO object is found inside ESD!");
153 if (!esdVZERO->TestBit(AliESDVZERO::kDecisionFilled)) {
154 AliWarning("VZERO offline trigger decisions were not filled in ESD, the tender supply is disabled");
158 if (fDebug) printf("LHC-clock phase correction: %f\n",fLHCClockPhase);
160 if (fDebug) printf("Original VZERO decision %d (%f ns) and %d (%f ns)\n",
161 esdVZERO->GetV0ADecision(),esdVZERO->GetV0ATime(),
162 esdVZERO->GetV0CDecision(),esdVZERO->GetV0CTime());
164 for(Int_t i = 0; i < 64; ++i) {
165 time[i] = esdVZERO->GetTime(i);
166 if (time[i] > (AliVZEROReconstructor::kInvalidTime + 1e-6))
167 time[i] += fLHCClockPhase;
169 esdVZERO->SetTime(time);
172 AliVZEROTriggerMask triggerMask;
173 triggerMask.SetRecoParam(fRecoParam);
174 triggerMask.FillMasks(esdVZERO, fCalibData, fTimeSlewing);
176 if (fDebug) printf("Modified VZERO decision %d (%f ns) and %d (%f ns)\n",
177 esdVZERO->GetV0ADecision(),esdVZERO->GetV0ATime(),
178 esdVZERO->GetV0CDecision(),esdVZERO->GetV0CTime());
182 //_____________________________________________________
183 void AliVZEROTenderSupply::GetPhaseCorrection()
186 // Get Gain splines from OCDB
189 AliInfo("Get LHC-clock phase correction");
192 //find previous entry from the UserInfo
194 TTree *tree=((TChain*)fTender->GetInputData(0))->GetTree();
196 AliError("Tree not found in ESDhandler");
200 TList *userInfo=(TList*)tree->GetUserInfo();
202 AliError("No UserInfo found in tree");
206 TList *cdbList=(TList*)userInfo->FindObject("cdbList");
208 AliError("No cdbList found in UserInfo");
209 if (AliLog::GetGlobalLogLevel()>=AliLog::kError) userInfo->Print();
213 Float_t oldPhase = 0;
215 TIter nextCDB(cdbList);
217 while ( (os=(TObjString*)nextCDB()) ){
218 if (!(os->GetString().Contains("GRP/Calib/LHCClockPhase"))) continue;
219 AliCDBId *id=AliCDBId::MakeFromString(os->GetString());
221 AliCDBEntry *entry=fTender->GetCDBManager()->Get(*id);
223 AliError("The previous LHC-clock phase entry is not found");
228 if (fDebug) printf("AliVZEROTenderSupply::Used old LHC-clock phase entry: %s\n",entry->GetId().ToString().Data());
230 AliLHCClockPhase *phase = (AliLHCClockPhase*)entry->GetObject();
232 AliError("Phase object is not found in the calibration entry");
237 oldPhase = phase->GetMeanPhase();
244 //new LHC-clock phase entry
246 Float_t newPhase = 0;
247 AliCDBEntry *entryNew=fTender->GetCDBManager()->Get("GRP/Calib/LHCClockPhase",fTender->GetRun());
249 AliError("No new LHC-clock phase calibration entry is found");
252 if (fDebug) printf("AliVZEROTenderSupply::Used new LHC-clock phase entry: %s\n",entryNew->GetId().ToString().Data());
254 AliLHCClockPhase *phase2 = (AliLHCClockPhase*)entryNew->GetObject();
256 AliError("Phase object is not found in the calibration entry");
260 newPhase = phase2->GetMeanPhase();
262 fLHCClockPhase = newPhase - oldPhase;