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>
40 #include "AliVZEROTenderSupply.h"
42 ClassImp(AliVZEROTenderSupply)
44 AliVZEROTenderSupply::AliVZEROTenderSupply() :
56 //_____________________________________________________
57 AliVZEROTenderSupply::AliVZEROTenderSupply(const char *name, const AliTender *tender) :
58 AliTenderSupply(name,tender),
69 //_____________________________________________________
70 void AliVZEROTenderSupply::Init()
73 // Initialise VZERO tender
77 //_____________________________________________________
78 void AliVZEROTenderSupply::ProcessEvent()
81 // Reapply the LHC-clock phase drift
84 AliESDEvent *event=fTender->GetEvent();
87 //load gain correction if run has changed
88 if (fTender->RunChanged()){
89 if (fDebug) printf("AliVZEROTenderSupply::ProcessEvent - Run Changed (%d)\n",fTender->GetRun());
92 AliCDBEntry *entryCal = fTender->GetCDBManager()->Get("VZERO/Calib/Data",fTender->GetRun());
94 AliError("No VZERO calibration entry is found");
98 fCalibData = (AliVZEROCalibData*)entryCal->GetObject();
99 if (fDebug) printf("AliVZEROTenderSupply::Used VZERO calibration entry: %s\n",entryCal->GetId().ToString().Data());
102 AliCDBEntry *entrySlew = fTender->GetCDBManager()->Get("VZERO/Calib/TimeSlewing",fTender->GetRun());
104 AliError("VZERO time slewing function is not found in OCDB !");
108 fTimeSlewing = (TF1*)entrySlew->GetObject();
109 if (fDebug) printf("AliVZEROTenderSupply::Used VZERO time slewing entry: %s\n",entrySlew->GetId().ToString().Data());
113 if (!fCalibData || !fTimeSlewing) return;
116 // correct VZERO time signals and decision
118 AliESDVZERO *esdVZERO = event->GetVZEROData();
120 AliError("No VZERO object is found inside ESD!");
123 if (!esdVZERO->TestBit(AliESDVZERO::kDecisionFilled)) {
124 AliWarning("VZERO offline trigger decisions were not filled in ESD, the tender supply is disabled");
129 for(Int_t i = 0; i < 64; ++i) {
130 time[i] = esdVZERO->GetTime(i);
131 time[i] += fLHCClockPhase;
133 esdVZERO->SetTime(time);
136 AliVZEROTriggerMask triggerMask;
137 triggerMask.FillMasks(esdVZERO, fCalibData, fTimeSlewing);
142 //_____________________________________________________
143 void AliVZEROTenderSupply::GetPhaseCorrection()
146 // Get Gain splines from OCDB
149 AliInfo("Get LHC-clock phase correction");
152 //find previous entry from the UserInfo
154 TTree *tree=((TChain*)fTender->GetInputData(0))->GetTree();
156 AliError("Tree not found in ESDhandler");
160 TList *userInfo=(TList*)tree->GetUserInfo();
162 AliError("No UserInfo found in tree");
166 TList *cdbList=(TList*)userInfo->FindObject("cdbList");
168 AliError("No cdbList found in UserInfo");
169 if (AliLog::GetGlobalLogLevel()>=AliLog::kError) userInfo->Print();
173 Float_t oldPhase = 0;
175 TIter nextCDB(cdbList);
177 while ( (os=(TObjString*)nextCDB()) ){
178 if (!(os->GetString().Contains("GRP/Calib/LHCClockPhase"))) continue;
179 AliCDBId *id=AliCDBId::MakeFromString(os->GetString());
181 AliCDBEntry *entry=fTender->GetCDBManager()->Get(*id);
183 AliError("The previous LHC-clock phase entry is not found");
188 if (fDebug) printf("AliVZEROTenderSupply::Used old LHC-clock phase entry: %s\n",entry->GetId().ToString().Data());
190 AliLHCClockPhase *phase = (AliLHCClockPhase*)entry->GetObject();
192 AliError("Phase object is not found in the calibration entry");
197 oldPhase = phase->GetMeanPhase();
204 //new LHC-clock phase entry
206 Float_t newPhase = 0;
207 AliCDBEntry *entryNew=fTender->GetCDBManager()->Get("GRP/Calib/LHCClockPhase",fTender->GetRun());
209 AliError("No new LHC-clock phase calibration entry is found");
212 if (fDebug) printf("AliVZEROTenderSupply::Used new LHC-clock phase entry: %s\n",entryNew->GetId().ToString().Data());
214 AliLHCClockPhase *phase2 = (AliLHCClockPhase*)entryNew->GetObject();
216 AliError("Phase object is not found in the calibration entry");
220 newPhase = phase2->GetMeanPhase();
222 fLHCClockPhase = newPhase - oldPhase;