prevent running if CDB snapshot setting failed
[u/mrichter/AliRoot.git] / STEER / STEER / AliLHCData.h
CommitLineData
a65a7e70 1#ifndef ALILHCDATA_H
2#define ALILHCDATA_H
3
4/********************************************************************************
5* *
6* AliLHCData: summary of the LHC related information from LHC DIP. *
7* Created from the TMap provided by the AliLHCReader with optional beginning *
8* *
9* The data are (wrapped in the AliLHCDipValT): *
10* made of TimeStamp (double) and array of values *
11* *
12* Multiple entries for each type of data are possible. To obtaine number of *
13* records (with distinct timestamp) for give type od records use: *
14* int GetNBunchConfigMeasured(int beam) (with beam=0,1) etc. *
15* *
16* To get i-th entry, use brec= AliLHCDipValI* GetBunchConfigMeasured(bm,i); *
17* Note: exact type of templated AliLHCDipValT pointer depends on the record *
18* type, concult getters to know it. *
19* *
20* Then, once the pointer is obtained, details can be accessed: *
21* int nBunches = brec->GetSize(); *
22* for (int i=0;i<nBunches;i++) printf("Bunch#%d: %d\n",i,(*brec)[i]); *
23* *
24* ATTENTION: Bunch RFBucked is NEGATIVE for bunches interacting at IR2 *
25* *
26* *
27* *
28* Author: ruben.shahoyan@cern.ch *
29* *
30********************************************************************************/
31
32#include "AliLHCDipValT.h"
33#include "TObject.h"
34class TObjArray;
35//class AliLHCDipValT;
36
37class AliDCSArray;
38class TString;
39class TMap;
40class AliLHCReader;
41class TGraph;
42
43class AliLHCData : public TObject
44{
45 public:
46 enum {kStart,kNStor};
47 enum BeamID_t {kBeam1,kBeam2};
a5d01fb6 48 enum BgID_t {kBg1,kBg2,kBg3,kNBGs};
a65a7e70 49 enum Proj_t {kX,kY};
50 enum Side_t {kLeft,kRight};
51 enum Collim_t {kTCTVB4L2, kTCTVB4R2, kTCLIA4R2, kNCollimators};
52 enum ColJaw_t {kGapDn,kGapUp,kLeftDn,kLeftUp,kRightDn,kRightUp,kNJaws};
53 enum {kMaxBSlots = 3564, kOffsBeam1=346, kOffsBeam2 = 3019};
54 enum {kMarginSOR = 60*60*24*30, // use margin of 30 days for SOR, when looking for the 1st record
55 kMarginEOR = 60*15}; // use margin of 15 min for EOR, when looking for the last record
56 //
57 enum {kIntTot,kIntTotAv,kIntBunchAv,
58 kLumAcqMode,kLumTot,kLumTotErr,kLumBunch,kLumBunchErr,kLumCrossAng,kLumCrossAngErr,
59 kBunchConf,kFillNum,kBunchLgtNB,kBunchLgt,kBunchLgtFillB,
60 kRCInjSch,kRCBeta,kRCCrossAng,kRCVang,
61 kBeamSzAcqMode,kBeamSzSigH,kBeamSzSigV,kBeamSzEmittH,kBeamSzEmittV,kBeamSzSigHErr,kBeamSzSigVErr,
a5d01fb6 62 kCollPos,
63 kBPTXdeltaTB1B2,
64 kBPTXdeltaTRMSB1B2,
65 kBPTXPhase,
66 kBPTXPhaseRMS,
67 kBPTXPhaseShift,
68 //
69 kALILumiTotalInst,
70 kALILumiTotalDeliveredStabBeam,
71 kALILumiBunchInst,
72 kALIBackground,
73 kNRecordTypes};
a65a7e70 74 //
75 //le
76 public:
77 //
78 AliLHCData() : fTMin(0),fTMax(1e10),fFillNumber(0),fData(0),fkFile2Process(0),fkMap2Process(0) {Clear();}
79 AliLHCData(const TMap* dcsMap, double tmin=0, double tmax=1.e10);
80 AliLHCData(const Char_t* dcsFile, double tmin=0, double tmax=1.e10);
81 virtual ~AliLHCData() {}
82 //
83 Bool_t FillData(const TMap* dcsMap, double tmin=0, double tmax=1.e20);
84 Bool_t FillData(const Char_t* dcsFile, double tmin=0, double tmax=1.e20);
85 Double_t GetTMin() const {return fTMin;}
86 Double_t GetTMax() const {return fTMax;}
87 Int_t GetFillNumber() const {return fFillNumber;}
88 void SetFillNumber(Int_t fill) {fFillNumber = fill;}
89 void SetTMin(Double_t t) {fTMin = t<0?0:(t>1e10?1e10:t);}
90 void SetTMax(Double_t t) {fTMax = t<0?0:(t>1e10?1e10:t);}
91 //
92 virtual void Print(const Option_t *opt="") const;
93 TGraph* ExportGraph(Int_t *coord, Int_t elID=0) const;
94 //
95 Int_t GetNBunchConfigMeasured(int bm) const {return GoodPairID(bm)?fBunchConfMeas[bm][kNStor]:-1;}
96 Int_t GetNBunchConfigDeclared(int bm) const {return GoodPairID(bm)?fBunchConfDecl[bm][kNStor]:-1;}
97 Int_t GetNBunchLengths(int bm) const {return GoodPairID(bm)?fBunchLengths[bm][kNStor]:-1;}
98 Int_t GetNTotalIntensity(int bm) const {return GoodPairID(bm)?fIntensTotal[bm][kNStor]:-1;}
99 Int_t GetNTotalIntensityAv(int bm) const {return GoodPairID(bm)?fIntensTotalAv[bm][kNStor]:-1;}
100 Int_t GetNIntensityPerBunch(int bm) const {return GoodPairID(bm)?fIntensPerBunch[bm][kNStor]:-1;}
101 Int_t GetNEmittanceH(int bm) const {return GoodPairID(bm)?fEmittanceH[bm][kNStor]:-1;}
102 Int_t GetNEmittanceV(int bm) const {return GoodPairID(bm)?fEmittanceV[bm][kNStor]:-1;}
103 Int_t GetNBeamSigmaH(int bm) const {return GoodPairID(bm)?fBeamSigmaH[bm][kNStor]:-1;}
104 Int_t GetNBeamSigmaV(int bm) const {return GoodPairID(bm)?fBeamSigmaV[bm][kNStor]:-1;}
105 //
106 Int_t GetNLuminosityTotal(int lr) const {return GoodPairID(lr)?fLuminTotal[lr][kNStor]:-1;}
107 Int_t GetNLuminosityPerBunch(int lr) const {return GoodPairID(lr)?fLuminPerBC[lr][kNStor]:-1;}
108 Int_t GetNLuminosityAcqMode(int lr) const {return GoodPairID(lr)?fLuminAcqMode[lr][kNStor]:-1;}
109 Int_t GetNCrossingAngle(int lr) const {return GoodPairID(lr)?fCrossAngle[lr][kNStor]:-1;}
110 //
111 Int_t GetNInjectionScheme() const {return fRCInjScheme[kNStor];}
112 Int_t GetNRCBetaStar() const {return fRCBeta[kNStor];}
113 Int_t GetNRCAngleH() const {return fRCAngH[kNStor];}
114 Int_t GetNRCAngleV() const {return fRCAngV[kNStor];}
115 //
116 Int_t GetNLumiAlice() const {return fLumiAlice[kNStor];}
a5d01fb6 117 Int_t GetNLumiAliceSBDelivered() const {return fLumiAliceStB[kNStor];}
118 Int_t GetNLumiAliceBunch() const {return fLumiAliceBbB[kNStor];}
119 //
120 Int_t GetNBckgAlice(int bg) const {return (bg>-1&&bg<kNBGs) ? fBckgAlice[bg][kNStor] : -1;}
121 //
122 Int_t GetNBPTXdeltaTB1B2() const {return fBPTXdTB1B2[kNStor];}
123 Int_t GetNBPTXdeltaTRMSB1B2() const {return fBPTXdTRMSB1B2[kNStor];}
124 Int_t GetNBPTXPhase(int bm) const {return GoodPairID(bm)?fBPTXPhase[bm][kNStor]:-1;}
125 Int_t GetNBPTXPhaseRMS(int bm) const {return GoodPairID(bm)?fBPTXPhaseRMS[bm][kNStor]:-1;}
126 Int_t GetNBPTXPhaseShift(int bm) const {return GoodPairID(bm)?fBPTXPhaseShift[bm][kNStor]:-1;}
127 //
a65a7e70 128 //
129 Int_t GetNCollimatorJawPos(int coll,int jaw) const;
130 //
131 AliLHCDipValI* GetBunchConfigMeasured(int bm, int i=0) const;
132 AliLHCDipValF* GetBunchLengths(int bm, int i=0) const;
133 AliLHCDipValI* GetBunchConfigDeclared(int bm, int i=0) const;
134 AliLHCDipValF* GetTotalIntensity(int bm, int i=0) const;
135 AliLHCDipValF* GetTotalIntensityAv(int bm, int i=0) const;
136 AliLHCDipValF* GetIntensityPerBunch(int bm, int i=0) const;
137 AliLHCDipValF* GetEmittanceH(int bm, int i=0) const;
138 AliLHCDipValF* GetEmittanceV(int bm, int i=0) const;
139 AliLHCDipValF* GetBeamSigmaH(int bm, int i=0) const;
140 AliLHCDipValF* GetBeamSigmaV(int bm, int i=0) const;
141 AliLHCDipValF* GetLuminosityTotal(int lr, int i=0) const;
142 AliLHCDipValF* GetLuminosityPerBunch(int lr, int i=0) const;
143 AliLHCDipValI* GetLuminosityAcqMode(int lr, int i=0) const;
144 AliLHCDipValF* GetCrossAngle(int lr, int i=0) const;
145 AliLHCDipValC* GetInjectionScheme(int i=0) const;
146 AliLHCDipValF* GetRCBetaStar(int i=0) const;
147 AliLHCDipValF* GetRCAngleH(int i=0) const;
148 AliLHCDipValF* GetRCAngleV(int i=0) const;
149 AliLHCDipValF* GetCollimJawPos(int coll, int jaw, int i=0) const;
150 //
a5d01fb6 151 AliLHCDipValF* GetLumiAlice(int i=0) const;
152 AliLHCDipValF* GetLumiAliceSBDelivered(int i=0) const;
153 AliLHCDipValF* GetLumiAliceBunch(int i=0) const;
154 AliLHCDipValF* GetBckgAlice(int bg, int i=0) const;
155 //
156 AliLHCDipValF* GetBPTXdeltaTB1B2(int i=0) const;
157 AliLHCDipValF* GetBPTXdeltaTRMSB1B2(int i=0) const;
158 AliLHCDipValF* GetBPTXPhase(int bm, int i=0) const;
159 AliLHCDipValF* GetBPTXPhaseRMS(int bm, int i=0) const;
160 AliLHCDipValF* GetBPTXPhaseShift(int bm, int i=0) const;
a65a7e70 161 //
162 Float_t GetLumiAlice(Double_t tstamp) const;
a5d01fb6 163 Float_t GetLumiAliceSBDelivered(Double_t tstamp) const;
164 Float_t GetBckgAlice(Int_t bg,Double_t tstamp) const;
a65a7e70 165 //
a5d01fb6 166 // Float_t GetLumiInstAlice(Double_t tstamp) const;
167 // Float_t GetBckgInstAlice(Double_t tstamp) const;
a65a7e70 168 //
169 void FlagInteractingBunches(const Int_t beam1[2],const Int_t beam2[2]);
170 TObject* FindRecValidFor(int start,int nrec, double tstamp) const;
171 Int_t FindEntryValidFor(int start,int nrec, double tstamp) const;
172 AliLHCDipValI* GetBunchConfigMeasured(int beam,double tstamp) const;
173 AliLHCDipValI* GetBunchConfigDeclared(int beam,double tstamp) const;
174 Int_t GetNInteractingBunchesMeasured(int i=0) const;
175 Int_t GetNInteractingBunchesDeclared(int i=0) const;
176 Int_t IsPilotPresent(int i=0) const;
177 //
178 // return array with beginning [0] and number of records for corresponding info (in the fData)
179 const Int_t* GetOffsBunchConfigMeasured(int bm) const {return GoodPairID(bm)?fBunchConfMeas[bm]:0;}
180 const Int_t* GetOffsBunchConfigDeclared(int bm) const {return GoodPairID(bm)?fBunchConfDecl[bm]:0;}
181 const Int_t* GetOffsBunchLengths(int bm) const {return GoodPairID(bm)?fBunchLengths[bm]:0;}
182 const Int_t* GetOffsTotalIntensity(int bm) const {return GoodPairID(bm)?fIntensTotal[bm]:0;}
183 const Int_t* GetOffsTotalIntensityAv(int bm) const {return GoodPairID(bm)?fIntensTotalAv[bm]:0;}
184 const Int_t* GetOffsIntensityPerBunch(int bm) const {return GoodPairID(bm)?fIntensPerBunch[bm]:0;}
185 const Int_t* GetOffsEmittanceH(int bm) const {return GoodPairID(bm)?fEmittanceH[bm]:0;}
186 const Int_t* GetOffsEmittanceV(int bm) const {return GoodPairID(bm)?fEmittanceV[bm]:0;}
187 const Int_t* GetOffsBeamSigmaH(int bm) const {return GoodPairID(bm)?fBeamSigmaH[bm]:0;}
188 const Int_t* GetOffsBeamSigmaV(int bm) const {return GoodPairID(bm)?fBeamSigmaV[bm]:0;}
189 //
190 const Int_t* GetOffsLuminosityTotal(int lr) const {return GoodPairID(lr)?fLuminTotal[lr]:0;}
191 const Int_t* GetOffsLuminosityPerBunch(int lr) const {return GoodPairID(lr)?fLuminPerBC[lr]:0;}
192 const Int_t* GetOffsLuminosityAcqMode(int lr) const {return GoodPairID(lr)?fLuminAcqMode[lr]:0;}
193 const Int_t* GetOffsCrossingAngle(int lr) const {return GoodPairID(lr)?fCrossAngle[lr]:0;}
194 //
195 const Int_t* GetOffsInjectionScheme() const {return fRCInjScheme;}
196 const Int_t* GetOffsRCBetaStar() const {return fRCBeta;}
197 const Int_t* GetOffsRCAngleH() const {return fRCAngH;}
198 const Int_t* GetOffsRCAngleV() const {return fRCAngV;}
a5d01fb6 199 //
a65a7e70 200 const Int_t* GetOffsLumiAlice() const {return fLumiAlice;}
a5d01fb6 201 const Int_t* GetOffsLumiAliceSBDelivered() const {return fLumiAliceStB;}
202 const Int_t* GetOffsLumiAliceBunch() const {return fLumiAliceBbB;}
203 const Int_t* GetOffsBckgAlice(int bg) const {return (bg>-1&&bg<kNBGs) ? fBckgAlice[bg] : 0;}
204 //
205 const Int_t* GetOffsBPTXdeltaTB1B2() const {return fBPTXdTB1B2;}
206 const Int_t* GetOffsBPTXdeltaTRMSB1B2() const {return fBPTXdTRMSB1B2;}
207 const Int_t* GetOffsBPTXPhase(int bm) const {return GoodPairID(bm)?fBPTXPhase[bm]:0;}
208 const Int_t* GetOffsBPTXPhaseRMS(int bm) const {return GoodPairID(bm)?fBPTXPhaseRMS[bm]:0;}
209 const Int_t* GetOffsBPTXPhaseShift(int bm) const {return GoodPairID(bm)?fBPTXPhaseShift[bm]:0;}
a65a7e70 210 //
211 const Int_t* GetOffsCollimatorJawPos(int coll,int jaw) const;
212 //
213 const TObjArray& GetData() const {return fData;}
214 //
215 // analysis methods
216 Int_t GetMeanIntensity(int beamID, Double_t &colliding, Double_t &noncolliding, const TObjArray* bcmasks=0) const;
217 static Int_t GetBCId(int bucket, int beamID) {return (TMath::Abs(bucket)/10 + (beamID==0 ? kOffsBeam1:kOffsBeam2))%kMaxBSlots;}
218 //
219 // for retrofitting, these methods has to be public
a5d01fb6 220 // void FillLumiAliceOFL(Int_t nrec, Int_t* time, Double_t* val);
221 // void FillBckgAliceOFL(Int_t nrec, Int_t* time, Double_t* val);
a65a7e70 222
223 protected:
224 //
225 Bool_t FillData(double tmin=0, double tmax=1.e20);
226 virtual void Clear(const Option_t *opt="");
227 void PrintAux(Bool_t full,const Int_t refs[2],const Option_t *opt="") const;
228 TObjArray* GetDCSEntry(const char* key,int &entry,int &last,double tmin,double tmax) const;
229 Int_t FillScalarRecord( int refs[2], const char* rec, const char* recErr=0, Double_t maxAbsVal=1.e30);
230 Int_t FillBunchConfig( int refs[2], const char* rec);
231 Int_t FillStringRecord( int refs[2], const char* rec);
232 Int_t FillAcqMode( int refs[2], const char* rec);
233 Int_t FillBunchInfo( int refs[2], const char* rec,int ibm, Bool_t inRealSlots, Double_t maxAbsVal=1.e30);
234 Int_t FillBCLuminosities(int refs[2], const char* rec, const char* recErr, Int_t useBeam, Double_t maxAbsVal=1.e30);
235 //
236 Int_t ExtractInt(AliDCSArray* dcsArray,Int_t el) const;
237 Double_t ExtractDouble(AliDCSArray* dcsArray,Int_t el) const;
238 TString& ExtractString(AliDCSArray* dcsArray) const;
239 AliLHCData(const AliLHCData& src) : TObject(src),fTMin(0),fTMax(0),fFillNumber(0),fData(0),fkFile2Process(0),fkMap2Process(0) { /*dummy*/ }
240 AliLHCData& operator=(const AliLHCData& ) { /*dummy*/ return *this;}
241 Int_t TimeDifference(double v1,double v2,double tol=0.9) const;
242 Bool_t IzZero(double val, double tol=1e-16) const {return TMath::Abs(val)<tol;}
243 Bool_t GoodPairID(int beam) const;
244 //
245 protected:
246 //
247 Double_t fTMin; // selection timeMin
248 Double_t fTMax; // selection timeMax
249 Int_t fFillNumber; // fill number : kFillNum
250 //
251 //---------------- Last index gives: 0 - beginning of the records in fData, 1 - number of records
252 //
253 // infrormation from RunControl
254 Int_t fRCInjScheme[2]; // active injection scheme : String |kRCInjScheme
255 Int_t fRCBeta[2]; // target beta : Float |kRCBeta
256 Int_t fRCAngH[2]; // horisontal angle : Float |kRCCrossAng
257 Int_t fRCAngV[2]; // vertical angle : Float |kRCVang
258 Int_t fBunchConfDecl[2][2]; // declared beam configuration : Float |kBunchConf
259 //
260 // measured information
261 Int_t fBunchConfMeas[2][2]; // measured beam configuration : Int |kBunchLgtFillB
262 Int_t fBunchLengths[2][2]; // measured beam lenghts : Float |kBunchLgt
263 Int_t fIntensTotal[2][2]; // total beam intensities : Float |kIntTot
264 Int_t fIntensTotalAv[2][2]; // total beam intensities from bunch averages : Float |kIntTotAv
265 Int_t fIntensPerBunch[2][2]; // bunch-by-bunch intensities : Float |kIntBunchAv
266 //
267 Int_t fCrossAngle[2][2]; // crossing angle at IP2 and its error : Float |kLimCrossAng, kLumCrossAngErr
268 Int_t fEmittanceH[2][2]; // beam H emittances : Float |kBeamSzEmittH
269 Int_t fEmittanceV[2][2]; // beam V emittances : Float |kBeamSzEmittV
270 Int_t fBeamSigmaH[2][2]; // beam H sigma and error : Float |kBeamSzSigH,kBeamSzSigHErr
271 Int_t fBeamSigmaV[2][2]; // beam V sigma and error : Float |kBeamSzSigV,kBeamSzSigVErr
272 //
273 Int_t fLuminTotal[2][2]; // total luminosity at IP2 and its error : Float |kLumTot, kLumTotErr
274 Int_t fLuminPerBC[2][2]; // luminosity at IP2 for each BC and its error : Float |kLumBunch,kLumBunchErr
275 Int_t fLuminAcqMode[2][2]; // luminosity acquisition mode : Int |kLumAcqMode
276 //
277 // here we will store the luminosity and the background measured by Alice. We store the value integrated from the start of fill.
278 // the inst. value can be obtained as its derivative
a5d01fb6 279 Int_t fLumiAlice[2]; // luminosity measured by Alice, Total_Inst : Float |kALILumiTotalInst
280 Int_t fLumiAliceStB[2]; // luminosity measured by Alice, Deli.StabBeam : Float |kALILumiTotalDeliveredStabBeam
281 Int_t fLumiAliceBbB[2]; // luminosity measured by Alice, B-by-B : Float |kALILumiBunchInst
282 //
283 Int_t fBckgAlice[kNBGs][2]; // backgrounds measured by Alice : Float |kALIBackground1,2,3
284 //
285 Int_t fBPTXdTB1B2[2]; // BPTX_deltaT_B1_B2 : Float |kBPTXdeltaTB1B2,
286 Int_t fBPTXdTRMSB1B2[2]; // BPTX_deltaTRMS_B1_B2 : Float |kBPTXdeltaTRMSB1B2,
287 Int_t fBPTXPhase[2][2]; // BPTX_Phase_B1, and BPTX_Phase_B2 : Float |kBPTXPhase
288 Int_t fBPTXPhaseRMS[2][2]; // BPTX_PhaseRMS_B1, and BPTX_PhaseRMS_B2 : Float |kBPTXPhaseRMS
289 Int_t fBPTXPhaseShift[2][2]; // BPTX_Phase_Shift_B1 and BPTX_Phase_Shift_B2 : Float |kBPTXPhaseShift
a65a7e70 290 //
291 Int_t fCollimators[kNCollimators][kNJaws][2];// collimator jaws positions : Float |kCollPos
292 //
293 TObjArray fData; // single storage for various records
294 //
295 static const Char_t *fgkDCSNames[]; // beam related DCS names to extract
296 static const Char_t *fgkDCSColNames[]; // collimators to extract
297 static const Char_t *fgkDCSColJaws[]; // names of collimator pieces
298 //
299 private:
300 // non-persistent objects used at the filling time
301 const Char_t* fkFile2Process; //! name of DCS file
302 const TMap* fkMap2Process; //! DCS map to process
303
a5d01fb6 304 ClassDef(AliLHCData,4)
a65a7e70 305};
306
307
308//_____________________________________________________________________________
309inline Int_t AliLHCData::GetNCollimatorJawPos(int coll,int jaw) const {// get n records
310 return (coll>=0&&coll<kNCollimators&&jaw>=0&&jaw<kNJaws)? fCollimators[coll][jaw][kNStor]:0;
311}
312
313inline const Int_t* AliLHCData::GetOffsCollimatorJawPos(int coll,int jaw) const { // offset array
314 return (coll>=0&&coll<kNCollimators&&jaw>=0&&jaw<kNJaws)? fCollimators[coll][jaw]:0;
315}
316
317inline AliLHCDipValI* AliLHCData::GetBunchConfigMeasured(int bm, int i) const { // get record
318 return (GoodPairID(bm) && i>=0 && i<fBunchConfMeas[bm][kNStor]) ? (AliLHCDipValI*)fData[fBunchConfMeas[bm][kStart]+i]:0;
319}
320
321inline AliLHCDipValF* AliLHCData::GetBunchLengths(int bm, int i) const { // get record
322 return (GoodPairID(bm) && i>=0 && i<fBunchLengths[bm][kNStor]) ? (AliLHCDipValF*)fData[fBunchLengths[bm][kStart]+i]:0;
323}
324
325inline AliLHCDipValI* AliLHCData::GetBunchConfigDeclared(int bm, int i) const { // get record
326 return (GoodPairID(bm) && i>=0 && i<fBunchConfDecl[bm][kNStor]) ? (AliLHCDipValI*)fData[fBunchConfDecl[bm][kStart]+i]:0;
327}
328
329inline AliLHCDipValF* AliLHCData::GetTotalIntensity(int bm, int i) const { // get record
330 return (GoodPairID(bm) && i>=0 && i<fIntensTotal[bm][kNStor]) ? (AliLHCDipValF*)fData[fIntensTotal[bm][kStart]+i]:0;
331}
332
333inline AliLHCDipValF* AliLHCData::GetTotalIntensityAv(int bm, int i) const { // get record
334 return (GoodPairID(bm) && i>=0 && i<fIntensTotalAv[bm][kNStor]) ? (AliLHCDipValF*)fData[fIntensTotalAv[bm][kStart]+i]:0;
335}
336
337inline AliLHCDipValF* AliLHCData::GetIntensityPerBunch(int bm, int i) const { // get record
338 return (GoodPairID(bm) && i>=0 && i<fIntensPerBunch[bm][kNStor]) ? (AliLHCDipValF*)fData[fIntensPerBunch[bm][kStart]+i]:0;
339}
340
341inline AliLHCDipValF* AliLHCData::GetEmittanceH(int bm, int i) const { // get record
342 return (GoodPairID(bm) && i>=0 && i<fEmittanceH[bm][kNStor]) ? (AliLHCDipValF*)fData[fEmittanceH[bm][kStart]+i]:0;
343}
344
345inline AliLHCDipValF* AliLHCData::GetEmittanceV(int bm, int i) const { // get record
346 return (GoodPairID(bm) && i>=0 && i<fEmittanceV[bm][kNStor]) ? (AliLHCDipValF*)fData[fEmittanceV[bm][kStart]+i]:0;
347}
348
349inline AliLHCDipValF* AliLHCData::GetBeamSigmaH(int bm, int i) const { // get record
350 return (GoodPairID(bm) && i>=0 && i<fBeamSigmaH[bm][kNStor]) ? (AliLHCDipValF*)fData[fBeamSigmaH[bm][kStart]+i]:0;
351}
352
353inline AliLHCDipValF* AliLHCData::GetBeamSigmaV(int bm, int i) const { // get record
354 return (GoodPairID(bm) && i>=0 && i<fBeamSigmaV[bm][kNStor]) ? (AliLHCDipValF*)fData[fBeamSigmaV[bm][kStart]+i]:0;
355}
356
357inline AliLHCDipValF* AliLHCData::GetLuminosityTotal(int lr, int i) const { // get record
358 return (GoodPairID(lr) && i>=0 && i<fLuminTotal[lr][kNStor]) ? (AliLHCDipValF*)fData[fLuminTotal[lr][kStart]+i]:0;
359}
360
361inline AliLHCDipValF* AliLHCData::GetLuminosityPerBunch(int lr, int i) const { // get record
362 return (GoodPairID(lr) && i>=0 && i<fLuminPerBC[lr][kNStor]) ? (AliLHCDipValF*)fData[fLuminPerBC[lr][kStart]+i]:0;
363}
364
365inline AliLHCDipValI* AliLHCData::GetLuminosityAcqMode(int lr, int i) const { // get record
366 return (GoodPairID(lr) && i>=0 && i<fLuminAcqMode[lr][kNStor]) ? (AliLHCDipValI*)fData[fLuminAcqMode[lr][kStart]+i]:0;
367}
368
369inline AliLHCDipValF* AliLHCData::GetCrossAngle(int lr, int i) const { // get record
370 return (GoodPairID(lr) && i>=0 && i<fCrossAngle[lr][kNStor]) ? (AliLHCDipValF*)fData[fCrossAngle[lr][kStart]+i]:0;
371}
372
373inline AliLHCDipValC* AliLHCData::GetInjectionScheme(int i) const { // get record
374 return (i>=0 && i<fRCInjScheme[kNStor]) ? (AliLHCDipValC*)fData[fRCInjScheme[kStart]+i]:0;
375}
376
377inline AliLHCDipValF* AliLHCData::GetRCBetaStar(int i) const { // get record
378 return (i>=0 && i<fRCBeta[kNStor]) ? (AliLHCDipValF*)fData[fRCBeta[kStart]+i]:0;
379}
380
381inline AliLHCDipValF* AliLHCData::GetRCAngleH(int i) const { // get record
382 return (i>=0 && i<fRCAngH[kNStor]) ? (AliLHCDipValF*)fData[fRCAngH[kStart]+i]:0;
383}
384
385inline AliLHCDipValF* AliLHCData::GetRCAngleV(int i) const { // get record
386 return (i>=0 && i<fRCAngV[kNStor]) ? (AliLHCDipValF*)fData[fRCAngV[kStart]+i]:0;
387}
388
389inline AliLHCDipValF* AliLHCData::GetCollimJawPos(int coll, int jaw, int i) const { // get record
390 return (coll>=0 && coll<kNCollimators && jaw>=0 && jaw<kNJaws &&
391 i>=0 && i<fCollimators[coll][jaw][kNStor]) ? (AliLHCDipValF*)fData[fCollimators[coll][jaw][kStart]+i]:0;
392}
393
a5d01fb6 394inline AliLHCDipValF* AliLHCData::GetLumiAlice(int i) const { // get record on integrated luminosity
a65a7e70 395 return (i>=0 && i<fLumiAlice[kNStor]) ? (AliLHCDipValF*)fData[fLumiAlice[kStart]+i]:0;
396}
397
a5d01fb6 398inline AliLHCDipValF* AliLHCData::GetLumiAliceSBDelivered(int i) const { // get record on st.beam delivered luminosity
399 return (i>=0 && i<fLumiAliceStB[kNStor]) ? (AliLHCDipValF*)fData[fLumiAliceStB[kStart]+i]:0;
400}
401
402inline AliLHCDipValF* AliLHCData::GetLumiAliceBunch(int i) const { // get record on b-by-b luminosity
403 return (i>=0 && i<fLumiAliceBbB[kNStor]) ? (AliLHCDipValF*)fData[fLumiAliceBbB[kStart]+i]:0;
404}
405
406inline AliLHCDipValF* AliLHCData::GetBckgAlice(int bg, int i) const { // get record on integrated background
407 return (bg>=0&&bg<kNBGs&&i>=0&&i<fBckgAlice[bg][kNStor]) ? (AliLHCDipValF*)fData[fBckgAlice[bg][kStart]+i]:0;
408}
409
410inline AliLHCDipValF* AliLHCData::GetBPTXdeltaTB1B2(int i) const { // get record
411 return (i>=0 && i<fBPTXdTB1B2[kNStor]) ? (AliLHCDipValF*)fData[fBPTXdTB1B2[kStart]+i]:0;
412}
413
414inline AliLHCDipValF* AliLHCData::GetBPTXdeltaTRMSB1B2(int i) const { // get record
415 return (i>=0 && i<fBPTXdTRMSB1B2[kNStor]) ? (AliLHCDipValF*)fData[fBPTXdTRMSB1B2[kStart]+i]:0;
416}
417
418inline AliLHCDipValF* AliLHCData::GetBPTXPhase(int bm, int i) const { // get record
419 return (GoodPairID(bm) && i>=0 && i<fBPTXPhase[bm][kNStor]) ? (AliLHCDipValF*)fData[fBPTXPhase[bm][kStart]+i]:0;
420}
421
422inline AliLHCDipValF* AliLHCData::GetBPTXPhaseRMS(int bm, int i) const { // get record
423 return (GoodPairID(bm) && i>=0 && i<fBPTXPhaseRMS[bm][kNStor]) ? (AliLHCDipValF*)fData[fBPTXPhaseRMS[bm][kStart]+i]:0;
424}
425
426inline AliLHCDipValF* AliLHCData::GetBPTXPhaseShift(int bm, int i) const { // get record
427 return (GoodPairID(bm) && i>=0 && i<fBPTXPhaseShift[bm][kNStor]) ? (AliLHCDipValF*)fData[fBPTXPhaseShift[bm][kStart]+i]:0;
a65a7e70 428}
429
430inline Float_t AliLHCData::GetLumiAlice(Double_t tStamp) const { // get closest in time value on integrated luminosity
431 int idx = FindEntryValidFor(fLumiAlice[kStart],fLumiAlice[kNStor],tStamp);
432 return idx<0 ? -1 : ((AliLHCDipValF*)fData[fLumiAlice[kStart]+idx])->GetValue();
433}
434
a5d01fb6 435inline Float_t AliLHCData::GetLumiAliceSBDelivered(Double_t tStamp) const { // get closest in time value on delivered luminosity
436 int idx = FindEntryValidFor(fLumiAliceStB[kStart],fLumiAliceStB[kNStor],tStamp);
437 return idx<0 ? -1 : ((AliLHCDipValF*)fData[fLumiAliceStB[kStart]+idx])->GetValue();
438}
439
440inline Float_t AliLHCData::GetBckgAlice(int bg,Double_t tStamp) const { // get closest in time value on integrated bckg
4792ea97 441 if (bg<0||bg>=kNBGs) return 0;
a5d01fb6 442 int idx = FindEntryValidFor(fBckgAlice[bg][kStart],fBckgAlice[bg][kNStor],tStamp);
443 return idx<0 ? -1 : ((AliLHCDipValF*)fData[fBckgAlice[bg][kStart]+idx])->GetValue();
a65a7e70 444}
445
a5d01fb6 446
447
a65a7e70 448inline Int_t AliLHCData::FindEntryValidFor(int start,int nrec, double tstamp) const
449{
450 // find index of record within this limits valid for given tstamp (i.e. the last one before or equal to tstamp)
451 int idx;
452 for (idx=0;idx<nrec;idx++) {
453 if (TimeDifference(tstamp,((AliLHCDipValI*)fData[start+idx])->GetTimeStamp())<=0) break;
454 }
455 return (idx<nrec) ? idx : nrec-1;
456}
457
458#endif