]> git.uio.no Git - u/mrichter/AliRoot.git/blob - STEER/STEER/AliLHCData.h
3d802221e31842f23c8874d4744a431577150484
[u/mrichter/AliRoot.git] / STEER / STEER / AliLHCData.h
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"
34 class TObjArray;
35 //class AliLHCDipValT;
36
37 class AliDCSArray;
38 class TString;
39 class TMap;
40 class AliLHCReader;
41 class TGraph;
42
43 class AliLHCData : public TObject
44 {
45  public:
46   enum          {kStart,kNStor};
47   enum BeamID_t {kBeam1,kBeam2};
48   enum Proj_t   {kX,kY};
49   enum Side_t   {kLeft,kRight};
50   enum Collim_t {kTCTVB4L2, kTCTVB4R2, kTCLIA4R2, kNCollimators};
51   enum ColJaw_t {kGapDn,kGapUp,kLeftDn,kLeftUp,kRightDn,kRightUp,kNJaws};
52   enum          {kMaxBSlots = 3564, kOffsBeam1=346, kOffsBeam2 = 3019};
53   enum          {kMarginSOR = 60*60*24*30, // use margin of 30 days for SOR, when looking for the 1st record
54                  kMarginEOR = 60*15};      // use margin of 15 min for EOR, when looking for the last record
55   //
56   enum {kIntTot,kIntTotAv,kIntBunchAv,
57         kLumAcqMode,kLumTot,kLumTotErr,kLumBunch,kLumBunchErr,kLumCrossAng,kLumCrossAngErr,
58         kBunchConf,kFillNum,kBunchLgtNB,kBunchLgt,kBunchLgtFillB,
59         kRCInjSch,kRCBeta,kRCCrossAng,kRCVang,
60         kBeamSzAcqMode,kBeamSzSigH,kBeamSzSigV,kBeamSzEmittH,kBeamSzEmittV,kBeamSzSigHErr,kBeamSzSigVErr,
61         kCollPos,kLumiAlice,kBckgAlice
62         ,kNRecordTypes};
63   //
64   //le
65  public:
66   //
67  AliLHCData() : fTMin(0),fTMax(1e10),fFillNumber(0),fData(0),fkFile2Process(0),fkMap2Process(0) {Clear();}
68   AliLHCData(const TMap*   dcsMap,  double tmin=0, double tmax=1.e10);
69   AliLHCData(const Char_t* dcsFile, double tmin=0, double tmax=1.e10);
70   virtual ~AliLHCData() {}
71   //
72   Bool_t                FillData(const TMap*   dcsMap,  double tmin=0, double tmax=1.e20);
73   Bool_t                FillData(const Char_t* dcsFile, double tmin=0, double tmax=1.e20);
74   Double_t              GetTMin()                                    const {return fTMin;}
75   Double_t              GetTMax()                                    const {return fTMax;}
76   Int_t                 GetFillNumber()                              const {return fFillNumber;}
77   void                  SetFillNumber(Int_t fill)                          {fFillNumber = fill;}
78   void                  SetTMin(Double_t t)                                {fTMin = t<0?0:(t>1e10?1e10:t);}
79   void                  SetTMax(Double_t t)                                {fTMax = t<0?0:(t>1e10?1e10:t);}
80   //
81   virtual void          Print(const Option_t *opt="")                const;
82   TGraph*               ExportGraph(Int_t *coord, Int_t elID=0)      const;
83   //
84   Int_t GetNBunchConfigMeasured(int bm)           const {return GoodPairID(bm)?fBunchConfMeas[bm][kNStor]:-1;}
85   Int_t GetNBunchConfigDeclared(int bm)           const {return GoodPairID(bm)?fBunchConfDecl[bm][kNStor]:-1;}
86   Int_t GetNBunchLengths(int bm)                  const {return GoodPairID(bm)?fBunchLengths[bm][kNStor]:-1;}
87   Int_t GetNTotalIntensity(int bm)                const {return GoodPairID(bm)?fIntensTotal[bm][kNStor]:-1;}
88   Int_t GetNTotalIntensityAv(int bm)              const {return GoodPairID(bm)?fIntensTotalAv[bm][kNStor]:-1;}
89   Int_t GetNIntensityPerBunch(int bm)             const {return GoodPairID(bm)?fIntensPerBunch[bm][kNStor]:-1;}
90   Int_t GetNEmittanceH(int bm)                    const {return GoodPairID(bm)?fEmittanceH[bm][kNStor]:-1;}
91   Int_t GetNEmittanceV(int bm)                    const {return GoodPairID(bm)?fEmittanceV[bm][kNStor]:-1;}
92   Int_t GetNBeamSigmaH(int bm)                    const {return GoodPairID(bm)?fBeamSigmaH[bm][kNStor]:-1;}
93   Int_t GetNBeamSigmaV(int bm)                    const {return GoodPairID(bm)?fBeamSigmaV[bm][kNStor]:-1;}
94   //
95   Int_t GetNLuminosityTotal(int lr)               const {return GoodPairID(lr)?fLuminTotal[lr][kNStor]:-1;}
96   Int_t GetNLuminosityPerBunch(int lr)            const {return GoodPairID(lr)?fLuminPerBC[lr][kNStor]:-1;}
97   Int_t GetNLuminosityAcqMode(int lr)             const {return GoodPairID(lr)?fLuminAcqMode[lr][kNStor]:-1;}
98   Int_t GetNCrossingAngle(int lr)                 const {return GoodPairID(lr)?fCrossAngle[lr][kNStor]:-1;}
99   //
100   Int_t GetNInjectionScheme()                     const {return fRCInjScheme[kNStor];}
101   Int_t GetNRCBetaStar()                          const {return fRCBeta[kNStor];}
102   Int_t GetNRCAngleH()                            const {return fRCAngH[kNStor];}
103   Int_t GetNRCAngleV()                            const {return fRCAngV[kNStor];}
104   //
105   Int_t GetNLumiAlice()                           const {return fLumiAlice[kNStor];}
106   Int_t GetNBckgAlice()                           const {return fBckgAlice[kNStor];}
107   //
108   Int_t GetNCollimatorJawPos(int coll,int jaw)    const;
109   //
110   AliLHCDipValI* GetBunchConfigMeasured(int bm, int i=0)  const;
111   AliLHCDipValF* GetBunchLengths(int bm, int i=0)         const;
112   AliLHCDipValI* GetBunchConfigDeclared(int bm, int i=0)  const;
113   AliLHCDipValF* GetTotalIntensity(int bm, int i=0)       const;
114   AliLHCDipValF* GetTotalIntensityAv(int bm, int i=0)     const;
115   AliLHCDipValF* GetIntensityPerBunch(int bm, int i=0)    const;
116   AliLHCDipValF* GetEmittanceH(int bm, int i=0)           const;
117   AliLHCDipValF* GetEmittanceV(int bm, int i=0)           const;
118   AliLHCDipValF* GetBeamSigmaH(int bm, int i=0)           const;
119   AliLHCDipValF* GetBeamSigmaV(int bm, int i=0)           const;
120   AliLHCDipValF* GetLuminosityTotal(int lr, int i=0)      const;
121   AliLHCDipValF* GetLuminosityPerBunch(int lr, int i=0)   const;
122   AliLHCDipValI* GetLuminosityAcqMode(int lr, int i=0)    const;
123   AliLHCDipValF* GetCrossAngle(int lr, int i=0)           const;
124   AliLHCDipValC* GetInjectionScheme(int i=0)              const;
125   AliLHCDipValF* GetRCBetaStar(int i=0)                   const;
126   AliLHCDipValF* GetRCAngleH(int i=0)                     const; 
127   AliLHCDipValF* GetRCAngleV(int i=0)                     const; 
128   AliLHCDipValF* GetCollimJawPos(int coll, int jaw, int i=0) const;
129   //
130   AliLHCDipValF* GetLumiAliceRecord(int i=0)              const; 
131   AliLHCDipValF* GetBckgAliceRecord(int i=0)              const; 
132   //
133   Float_t        GetLumiAlice(Double_t tstamp)            const;
134   Float_t        GetBckgAlice(Double_t tstamp)            const;
135   //
136   Float_t        GetLumiInstAlice(Double_t tstamp)        const;
137   Float_t        GetBckgInstAlice(Double_t tstamp)        const;
138   //
139   void           FlagInteractingBunches(const Int_t beam1[2],const Int_t beam2[2]);
140   TObject*       FindRecValidFor(int start,int nrec, double tstamp) const;
141   Int_t          FindEntryValidFor(int start,int nrec, double tstamp) const;
142   AliLHCDipValI* GetBunchConfigMeasured(int beam,double tstamp)  const;
143   AliLHCDipValI* GetBunchConfigDeclared(int beam,double tstamp)  const;
144   Int_t          GetNInteractingBunchesMeasured(int i=0)         const;
145   Int_t          GetNInteractingBunchesDeclared(int i=0)         const;
146   Int_t          IsPilotPresent(int i=0)                         const;
147   //
148   // return array with beginning [0] and number of records for corresponding info (in the fData)
149   const Int_t* GetOffsBunchConfigMeasured(int bm)         const {return GoodPairID(bm)?fBunchConfMeas[bm]:0;}
150   const Int_t* GetOffsBunchConfigDeclared(int bm)         const {return GoodPairID(bm)?fBunchConfDecl[bm]:0;}
151   const Int_t* GetOffsBunchLengths(int bm)                const {return GoodPairID(bm)?fBunchLengths[bm]:0;}
152   const Int_t* GetOffsTotalIntensity(int bm)              const {return GoodPairID(bm)?fIntensTotal[bm]:0;}
153   const Int_t* GetOffsTotalIntensityAv(int bm)            const {return GoodPairID(bm)?fIntensTotalAv[bm]:0;}
154   const Int_t* GetOffsIntensityPerBunch(int bm)           const {return GoodPairID(bm)?fIntensPerBunch[bm]:0;}
155   const Int_t* GetOffsEmittanceH(int bm)                  const {return GoodPairID(bm)?fEmittanceH[bm]:0;}
156   const Int_t* GetOffsEmittanceV(int bm)                  const {return GoodPairID(bm)?fEmittanceV[bm]:0;}
157   const Int_t* GetOffsBeamSigmaH(int bm)                  const {return GoodPairID(bm)?fBeamSigmaH[bm]:0;}
158   const Int_t* GetOffsBeamSigmaV(int bm)                  const {return GoodPairID(bm)?fBeamSigmaV[bm]:0;}
159   //
160   const Int_t* GetOffsLuminosityTotal(int lr)             const {return GoodPairID(lr)?fLuminTotal[lr]:0;}
161   const Int_t* GetOffsLuminosityPerBunch(int lr)          const {return GoodPairID(lr)?fLuminPerBC[lr]:0;}
162   const Int_t* GetOffsLuminosityAcqMode(int lr)           const {return GoodPairID(lr)?fLuminAcqMode[lr]:0;}
163   const Int_t* GetOffsCrossingAngle(int lr)               const {return GoodPairID(lr)?fCrossAngle[lr]:0;}
164   //
165   const Int_t* GetOffsInjectionScheme()                   const {return fRCInjScheme;}
166   const Int_t* GetOffsRCBetaStar()                        const {return fRCBeta;}
167   const Int_t* GetOffsRCAngleH()                          const {return fRCAngH;}
168   const Int_t* GetOffsRCAngleV()                          const {return fRCAngV;}
169   const Int_t* GetOffsLumiAlice()                         const {return fLumiAlice;}
170   const Int_t* GetOffsBckgAlice()                         const {return fBckgAlice;}
171   //
172   const Int_t* GetOffsCollimatorJawPos(int coll,int jaw)  const;
173   //
174   const TObjArray&  GetData()                             const {return fData;}
175   //
176   // analysis methods
177   Int_t GetMeanIntensity(int beamID, Double_t &colliding, Double_t &noncolliding, const TObjArray* bcmasks=0) const;
178   static Int_t GetBCId(int bucket, int beamID)                  {return (TMath::Abs(bucket)/10 + (beamID==0 ? kOffsBeam1:kOffsBeam2))%kMaxBSlots;}
179   //
180   // for retrofitting, these methods has to be public
181   void                  FillLumiAlice(Int_t nrec, Int_t* time, Double_t* val);
182   void                  FillBckgAlice(Int_t nrec, Int_t* time, Double_t* val);
183
184
185  protected:
186   //
187   Bool_t                FillData(double tmin=0, double tmax=1.e20);
188   virtual void          Clear(const Option_t *opt="");
189   void                  PrintAux(Bool_t full,const Int_t refs[2],const Option_t *opt="") const;
190   TObjArray*            GetDCSEntry(const char* key,int &entry,int &last,double tmin,double tmax) const;
191   Int_t                 FillScalarRecord(  int refs[2], const char* rec, const char* recErr=0, Double_t maxAbsVal=1.e30);
192   Int_t                 FillBunchConfig(   int refs[2], const char* rec);
193   Int_t                 FillStringRecord(  int refs[2], const char* rec);
194   Int_t                 FillAcqMode(       int refs[2], const char* rec);
195   Int_t                 FillBunchInfo(     int refs[2], const char* rec,int ibm, Bool_t inRealSlots, Double_t maxAbsVal=1.e30);
196   Int_t                 FillBCLuminosities(int refs[2], const char* rec, const char* recErr, Int_t useBeam, Double_t maxAbsVal=1.e30);
197   //
198   Int_t                 ExtractInt(AliDCSArray* dcsArray,Int_t el)    const;
199   Double_t              ExtractDouble(AliDCSArray* dcsArray,Int_t el) const;
200   TString&              ExtractString(AliDCSArray* dcsArray)          const;
201   AliLHCData(const AliLHCData& src) : TObject(src),fTMin(0),fTMax(0),fFillNumber(0),fData(0),fkFile2Process(0),fkMap2Process(0) { /*dummy*/ }
202   AliLHCData& operator=(const AliLHCData& ) { /*dummy*/ return *this;}
203   Int_t                 TimeDifference(double v1,double v2,double tol=0.9) const;
204   Bool_t                IzZero(double val, double tol=1e-16)         const {return TMath::Abs(val)<tol;}
205   Bool_t                GoodPairID(int beam)                         const;
206   //
207  protected:
208   //
209   Double_t        fTMin;                              // selection timeMin
210   Double_t        fTMax;                              // selection timeMax
211   Int_t           fFillNumber;                        // fill number           : kFillNum
212   //
213   //---------------- Last index gives: 0 - beginning of the records in fData, 1 - number of records
214   //
215   //              infrormation from RunControl
216   Int_t           fRCInjScheme[2];                    // active injection scheme                       : String |kRCInjScheme
217   Int_t           fRCBeta[2];                         // target beta                                   : Float  |kRCBeta
218   Int_t           fRCAngH[2];                         // horisontal angle                              : Float  |kRCCrossAng
219   Int_t           fRCAngV[2];                         // vertical angle                                : Float  |kRCVang
220   Int_t           fBunchConfDecl[2][2];               // declared beam configuration                   : Float  |kBunchConf                
221   //
222   //              measured information
223   Int_t           fBunchConfMeas[2][2];               // measured beam configuration                   : Int    |kBunchLgtFillB
224   Int_t           fBunchLengths[2][2];                // measured beam lenghts                         : Float  |kBunchLgt
225   Int_t           fIntensTotal[2][2];                 // total beam intensities                        : Float  |kIntTot
226   Int_t           fIntensTotalAv[2][2];               // total beam intensities from bunch averages    : Float  |kIntTotAv
227   Int_t           fIntensPerBunch[2][2];              // bunch-by-bunch intensities                    : Float  |kIntBunchAv
228   //
229   Int_t           fCrossAngle[2][2];                  // crossing angle   at IP2 and its error         : Float  |kLimCrossAng, kLumCrossAngErr
230   Int_t           fEmittanceH[2][2];                  // beam H emittances                             : Float  |kBeamSzEmittH
231   Int_t           fEmittanceV[2][2];                  // beam V emittances                             : Float  |kBeamSzEmittV
232   Int_t           fBeamSigmaH[2][2];                  // beam H sigma and error                        : Float  |kBeamSzSigH,kBeamSzSigHErr
233   Int_t           fBeamSigmaV[2][2];                  // beam V sigma and error                        : Float  |kBeamSzSigV,kBeamSzSigVErr
234   //
235   Int_t           fLuminTotal[2][2];                  // total luminosity at IP2 and its error         : Float  |kLumTot, kLumTotErr
236   Int_t           fLuminPerBC[2][2];                  // luminosity at IP2 for each BC and its error   : Float  |kLumBunch,kLumBunchErr
237   Int_t           fLuminAcqMode[2][2];                // luminosity acquisition mode                   : Int    |kLumAcqMode
238   //
239   // here we will store the luminosity and the background measured by Alice. We store the value integrated from the start of fill.
240   // the inst. value can be obtained as its derivative
241   Int_t           fLumiAlice[2];                      // luminosity measured by Alice                  : Float  |kLumiAlice
242   Int_t           fBckgAlice[2];                      // background measured by Alice                  : Float  |kLumiAlice
243   //
244   Int_t           fCollimators[kNCollimators][kNJaws][2];// collimator jaws positions                  : Float  |kCollPos
245   //
246   TObjArray       fData;                              // single storage for various records
247   //
248   static const Char_t *fgkDCSNames[];                 // beam related DCS names to extract
249   static const Char_t *fgkDCSColNames[];              // collimators to extract
250   static const Char_t *fgkDCSColJaws[];               // names of collimator pieces
251   //
252  private:
253   // non-persistent objects used at the filling time
254   const Char_t*   fkFile2Process;                      //! name of DCS file
255   const TMap*     fkMap2Process;                       //! DCS map to process 
256
257   ClassDef(AliLHCData,3)
258 };
259
260
261 //_____________________________________________________________________________
262 inline Int_t AliLHCData::GetNCollimatorJawPos(int coll,int jaw) const {// get n records
263   return (coll>=0&&coll<kNCollimators&&jaw>=0&&jaw<kNJaws)? fCollimators[coll][jaw][kNStor]:0;
264 }
265
266 inline const Int_t* AliLHCData::GetOffsCollimatorJawPos(int coll,int jaw)  const { // offset array
267   return (coll>=0&&coll<kNCollimators&&jaw>=0&&jaw<kNJaws)? fCollimators[coll][jaw]:0;
268 }
269
270 inline AliLHCDipValI* AliLHCData::GetBunchConfigMeasured(int bm, int i) const { // get record
271   return (GoodPairID(bm) && i>=0 && i<fBunchConfMeas[bm][kNStor]) ? (AliLHCDipValI*)fData[fBunchConfMeas[bm][kStart]+i]:0;
272 }
273
274 inline AliLHCDipValF* AliLHCData::GetBunchLengths(int bm, int i) const { // get record
275   return (GoodPairID(bm) && i>=0 && i<fBunchLengths[bm][kNStor]) ? (AliLHCDipValF*)fData[fBunchLengths[bm][kStart]+i]:0;
276 }
277
278 inline AliLHCDipValI* AliLHCData::GetBunchConfigDeclared(int bm, int i) const { // get record
279   return (GoodPairID(bm) && i>=0 && i<fBunchConfDecl[bm][kNStor]) ? (AliLHCDipValI*)fData[fBunchConfDecl[bm][kStart]+i]:0;
280 }
281
282 inline AliLHCDipValF* AliLHCData::GetTotalIntensity(int bm, int i) const { // get record
283   return (GoodPairID(bm) && i>=0 && i<fIntensTotal[bm][kNStor]) ? (AliLHCDipValF*)fData[fIntensTotal[bm][kStart]+i]:0;
284 }
285
286 inline AliLHCDipValF* AliLHCData::GetTotalIntensityAv(int bm, int i) const { // get record
287   return (GoodPairID(bm) && i>=0 && i<fIntensTotalAv[bm][kNStor]) ? (AliLHCDipValF*)fData[fIntensTotalAv[bm][kStart]+i]:0;
288 }
289
290 inline AliLHCDipValF* AliLHCData::GetIntensityPerBunch(int bm, int i) const { // get record
291   return (GoodPairID(bm) && i>=0 && i<fIntensPerBunch[bm][kNStor]) ? (AliLHCDipValF*)fData[fIntensPerBunch[bm][kStart]+i]:0;
292 }
293
294 inline AliLHCDipValF* AliLHCData::GetEmittanceH(int bm, int i) const { // get record
295   return (GoodPairID(bm) && i>=0 && i<fEmittanceH[bm][kNStor]) ? (AliLHCDipValF*)fData[fEmittanceH[bm][kStart]+i]:0;
296 }
297
298 inline AliLHCDipValF* AliLHCData::GetEmittanceV(int bm, int i) const { // get record
299   return (GoodPairID(bm) && i>=0 && i<fEmittanceV[bm][kNStor]) ? (AliLHCDipValF*)fData[fEmittanceV[bm][kStart]+i]:0;
300 }
301
302 inline AliLHCDipValF* AliLHCData::GetBeamSigmaH(int bm, int i) const { // get record
303   return (GoodPairID(bm) && i>=0 && i<fBeamSigmaH[bm][kNStor]) ? (AliLHCDipValF*)fData[fBeamSigmaH[bm][kStart]+i]:0;
304 }
305
306 inline AliLHCDipValF* AliLHCData::GetBeamSigmaV(int bm, int i) const { // get record
307   return (GoodPairID(bm) && i>=0 && i<fBeamSigmaV[bm][kNStor]) ? (AliLHCDipValF*)fData[fBeamSigmaV[bm][kStart]+i]:0;
308 }
309
310 inline AliLHCDipValF* AliLHCData::GetLuminosityTotal(int lr, int i) const { // get record
311   return (GoodPairID(lr) && i>=0 && i<fLuminTotal[lr][kNStor]) ? (AliLHCDipValF*)fData[fLuminTotal[lr][kStart]+i]:0;
312 }
313
314 inline AliLHCDipValF* AliLHCData::GetLuminosityPerBunch(int lr, int i) const { // get record
315   return (GoodPairID(lr) && i>=0 && i<fLuminPerBC[lr][kNStor]) ? (AliLHCDipValF*)fData[fLuminPerBC[lr][kStart]+i]:0;
316 }
317
318 inline AliLHCDipValI* AliLHCData::GetLuminosityAcqMode(int lr, int i) const { // get record
319   return (GoodPairID(lr) && i>=0 && i<fLuminAcqMode[lr][kNStor]) ? (AliLHCDipValI*)fData[fLuminAcqMode[lr][kStart]+i]:0;
320 }
321
322 inline AliLHCDipValF* AliLHCData::GetCrossAngle(int lr, int i) const { // get record
323   return (GoodPairID(lr) && i>=0 && i<fCrossAngle[lr][kNStor]) ? (AliLHCDipValF*)fData[fCrossAngle[lr][kStart]+i]:0;
324 }
325
326 inline AliLHCDipValC* AliLHCData::GetInjectionScheme(int i) const { // get record
327   return (i>=0 && i<fRCInjScheme[kNStor]) ? (AliLHCDipValC*)fData[fRCInjScheme[kStart]+i]:0;
328 }
329
330 inline AliLHCDipValF* AliLHCData::GetRCBetaStar(int i) const { // get record
331   return (i>=0 && i<fRCBeta[kNStor]) ? (AliLHCDipValF*)fData[fRCBeta[kStart]+i]:0;
332 }
333
334 inline AliLHCDipValF* AliLHCData::GetRCAngleH(int i) const { // get record
335   return (i>=0 && i<fRCAngH[kNStor]) ? (AliLHCDipValF*)fData[fRCAngH[kStart]+i]:0;
336 }
337
338 inline AliLHCDipValF* AliLHCData::GetRCAngleV(int i) const { // get record
339   return (i>=0 && i<fRCAngV[kNStor]) ? (AliLHCDipValF*)fData[fRCAngV[kStart]+i]:0;
340 }
341
342 inline AliLHCDipValF* AliLHCData::GetCollimJawPos(int coll, int jaw, int i) const { // get record
343   return (coll>=0 && coll<kNCollimators && jaw>=0 && jaw<kNJaws && 
344           i>=0 && i<fCollimators[coll][jaw][kNStor]) ? (AliLHCDipValF*)fData[fCollimators[coll][jaw][kStart]+i]:0;
345 }
346
347 inline AliLHCDipValF* AliLHCData::GetLumiAliceRecord(int i) const { // get record on integrated luminosity
348   return (i>=0 && i<fLumiAlice[kNStor]) ? (AliLHCDipValF*)fData[fLumiAlice[kStart]+i]:0;
349 }
350
351 inline AliLHCDipValF* AliLHCData::GetBckgAliceRecord(int i) const { // get record on integrated background
352   return (i>=0 && i<fBckgAlice[kNStor]) ? (AliLHCDipValF*)fData[fBckgAlice[kStart]+i]:0;
353 }
354
355 inline Float_t AliLHCData::GetLumiAlice(Double_t tStamp) const { // get closest in time value on integrated luminosity
356   int idx = FindEntryValidFor(fLumiAlice[kStart],fLumiAlice[kNStor],tStamp);
357   return idx<0 ? -1 : ((AliLHCDipValF*)fData[fLumiAlice[kStart]+idx])->GetValue();
358 }
359
360 inline Float_t AliLHCData::GetBckgAlice(Double_t tStamp) const { // get closest in time value on integrated bckg
361   int idx = FindEntryValidFor(fBckgAlice[kStart],fBckgAlice[kNStor],tStamp);
362   return idx<0 ? -1 : ((AliLHCDipValF*)fData[fBckgAlice[kStart]+idx])->GetValue();
363 }
364
365 inline Int_t AliLHCData::FindEntryValidFor(int start,int nrec, double tstamp) const
366 {
367   // find index of record within this limits valid for given tstamp (i.e. the last one before or equal to tstamp)
368   int idx;
369   for (idx=0;idx<nrec;idx++) {
370     if (TimeDifference(tstamp,((AliLHCDipValI*)fData[start+idx])->GetTimeStamp())<=0) break;
371   }
372   return (idx<nrec) ? idx : nrec-1;
373 }
374
375 #endif