]>
Commit | Line | Data |
---|---|---|
799c6677 | 1 | /**************************************************************************\r |
2 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *\r | |
3 | * *\r | |
4 | * Author: The ALICE Off-line Project. *\r | |
5 | * Contributors are mentioned in the code where appropriate. *\r | |
6 | * *\r | |
7 | * Permission to use, copy, modify and distribute this software and its *\r | |
8 | * documentation strictly for non-commercial purposes is hereby granted *\r | |
9 | * without fee, provided that the above copyright notice appears in all *\r | |
10 | * copies and that both the copyright notice and this permission notice *\r | |
11 | * appear in the supporting documentation. The authors make no claims *\r | |
12 | * about the suitability of this software for any purpose. It is *\r | |
13 | * provided "as is" without express or implied warranty. *\r | |
14 | * *\r | |
15 | **************************************************************************/\r | |
16 | \r | |
17 | /********************************************************************************\r | |
18 | * *\r | |
19 | * AliLHCData: summary of the LHC related information from LHC DIP. *\r | |
20 | * Created from the TMap provided by the AliLHCReader with optional beginning *\r | |
21 | * *\r | |
22 | * The data are (wrapped in the AliLHCDipValT): *\r | |
23 | * made of TimeStamp (double) and array of values *\r | |
24 | * *\r | |
25 | * Multiple entries for each type of data are possible. To obtaine number of *\r | |
26 | * records (with distinct timestamp) for give type od records use: *\r | |
27 | * int GetNBunchConfigMeasured(int beam) (with beam=0,1) etc. *\r | |
28 | * *\r | |
29 | * To get i-th entry, use brec= AliLHCDipValI* GetBunchConfigMeasured(bm,i); *\r | |
30 | * Note: exact type of templated AliLHCDipValT pointer depends on the record *\r | |
31 | * type, concult getters to know it. *\r | |
32 | * *\r | |
33 | * Then, once the pointer is obtained, details can be accessed: *\r | |
34 | * int nBunches = brec->GetSize(); *\r | |
35 | * for (int i=0;i<nBunches;i++) printf("Bunch#%d: %d\n",i,(*brec)[i]); *\r | |
36 | * *\r | |
37 | * *\r | |
38 | * Author: ruben.shahoyan@cern.ch *\r | |
39 | * *\r | |
40 | ********************************************************************************/\r | |
41 | \r | |
42 | #include "AliLHCData.h"\r | |
43 | #include "TMap.h"\r | |
44 | #include "AliDCSArray.h"\r | |
bab62329 | 45 | #include "AliLHCReader.h"\r |
2af04ffd | 46 | #include "AliTriggerBCMask.h"\r |
799c6677 | 47 | #include <TString.h>\r |
48 | #include <TObjArray.h>\r | |
49 | \r | |
50 | ClassImp(AliLHCData)\r | |
51 | \r | |
52 | const Char_t* AliLHCData::fgkDCSNames[] = {\r | |
d97d27ff | 53 | "LHC_IntensityBeam%1d_totalIntensity",\r |
54 | "LHC_BeamIntensityPerBunchBeam%1d_averageBeamIntensity",\r | |
55 | "LHC_BeamIntensityPerBunchBeam%1d_Average_BunchIntensities",\r | |
799c6677 | 56 | //\r |
57 | "LHC_LumAverageBRANB_4%c2_acqMode",\r | |
58 | "LHC_LumAverageBRANB_4%c2_meanLuminosity",\r | |
59 | "LHC_LumAverageBRANB_4%c2_meanLuminosityError",\r | |
60 | "LHC_BeamLuminosityPerBunchBRANB_4%c2_Average_BunchLuminosity",\r | |
61 | "LHC_BeamLuminosityPerBunchBRANB_4%c2_BunchLuminosityError",\r | |
62 | "LHC_LumAverageBRANB_4%c2_meanCrossingAngle",\r | |
63 | "LHC_LumAverageBRANB_4%c2_meanCrossingAngleError",\r | |
64 | "LHC_CirculatingBunchConfig_Beam%d",\r | |
65 | "LHC_FillNumber",\r | |
66 | //\r | |
d97d27ff | 67 | "LHC_BunchLengthBeam%1d_nBunches",\r |
68 | "LHC_BunchLengthBeam%1d_bunchesLenghts",\r | |
69 | "LHC_BunchLengthBeam%1d_filledBuckets",\r | |
799c6677 | 70 | //\r |
71 | "LHC_RunControl_ActiveInjectionScheme",\r | |
72 | "LHC_RunControl_BetaStar",\r | |
73 | "LHC_RunControl_IP2_Xing_Murad",\r | |
74 | "LHC_RunControl_IP2_ALICE_Murad",\r | |
75 | \r | |
d97d27ff | 76 | "LHC_BeamSizeBeam%1d_acqMode",\r |
77 | "LHC_BeamSizeBeam%1d_sigmaH",\r | |
78 | "LHC_BeamSizeBeam%1d_sigmaV",\r | |
79 | "LHC_BeamSizeBeam%1d_emittanceH",\r | |
80 | "LHC_BeamSizeBeam%1d_emittanceV",\r | |
81 | "LHC_BeamSizeBeam%1d_errorSigmaH",\r | |
82 | "LHC_BeamSizeBeam%1d_errorSigmaV",\r | |
799c6677 | 83 | //\r |
84 | "LHC_CollimatorPos_%s_lvdt_%s"\r | |
85 | };\r | |
86 | \r | |
87 | const Char_t* AliLHCData::fgkDCSColNames[] = {\r | |
88 | "TCTVB_4L2",\r | |
89 | "TCTVB_4R2",\r | |
90 | "TCLIA_4R2"\r | |
91 | };\r | |
92 | \r | |
93 | const Char_t* AliLHCData::fgkDCSColJaws[] = {\r | |
94 | "gap_downstream","gap_upstream","left_downstream",\r | |
95 | "left_upstream","right_downstream","right_upstream"};\r | |
96 | \r | |
97 | //___________________________________________________________________\r | |
0e9ab7ce | 98 | AliLHCData::AliLHCData(const TMap* dcsMap, double tmin, double tmax)\r |
bab62329 | 99 | : fTMin(0),fTMax(0),fFillNumber(0),fData(0),fFile2Process(0),fMap2Process(0)\r |
799c6677 | 100 | {\r |
bab62329 | 101 | FillData(dcsMap,tmin,tmax);\r |
102 | }\r | |
103 | \r | |
104 | //___________________________________________________________________\r | |
0e9ab7ce | 105 | AliLHCData::AliLHCData(const Char_t* dcsFile, double tmin, double tmax)\r |
bab62329 | 106 | : fTMin(0),fTMax(0),fFillNumber(0),fData(0),fFile2Process(dcsFile),fMap2Process(0)\r |
107 | {\r | |
108 | FillData(dcsFile,tmin,tmax);\r | |
109 | }\r | |
110 | \r | |
111 | //___________________________________________________________________\r | |
112 | Bool_t AliLHCData::FillData(const TMap* dcsMap,double tmin, double tmax)\r | |
113 | {\r | |
114 | // process DCS map and fill all fields. \r | |
799c6677 | 115 | Clear();\r |
bab62329 | 116 | fMap2Process = dcsMap;\r |
117 | FillData(tmin,tmax);\r | |
94179526 | 118 | return kTRUE;\r |
799c6677 | 119 | }\r |
120 | \r | |
121 | //___________________________________________________________________\r | |
bab62329 | 122 | Bool_t AliLHCData::FillData(const Char_t* dcsFile,double tmin, double tmax)\r |
123 | {\r | |
124 | // process DCS file and fill all fields. \r | |
125 | Clear();\r | |
126 | fFile2Process = dcsFile;\r | |
127 | FillData(tmin,tmax);\r | |
94179526 | 128 | return kTRUE;\r |
bab62329 | 129 | }\r |
130 | \r | |
131 | //___________________________________________________________________\r | |
132 | Bool_t AliLHCData::FillData(double tmin, double tmax)\r | |
799c6677 | 133 | {\r |
134 | // process DCS map and fill all fields. \r | |
135 | // Accept only entries with timestamp between tmin and tmax\r | |
136 | //\r | |
137 | char buff[100],buff1[100];\r | |
138 | //\r | |
139 | SetTMin(tmin);\r | |
140 | SetTMax(tmax);\r | |
141 | //\r | |
142 | // -------------------------- extract Fill Number\r | |
0e9ab7ce | 143 | int iFirst=0,iLast=0;\r |
144 | TObjArray* arr = GetDCSEntry(fgkDCSNames[kFillNum],iFirst,iLast,fTMin,fTMax);\r | |
145 | if (arr) SetFillNumber( ExtractInt( (AliDCSArray*)arr->At(iFirst), 0) );\r | |
bab62329 | 146 | if (fFile2Process) delete arr; // array was created on demand\r |
799c6677 | 147 | //\r |
148 | for (int ibm=0;ibm<2;ibm++) {\r | |
149 | //\r | |
d97d27ff | 150 | snprintf(buff,99,fgkDCSNames[kBunchConf],ibm+1); // ----- declared bunch configuration\r |
bab62329 | 151 | FillBunchConfig(fBunchConfDecl[ibm], buff);\r |
799c6677 | 152 | //\r |
d97d27ff | 153 | snprintf(buff,99,fgkDCSNames[kBunchLgtFillB],ibm+1); // ----- measured bunch configuration\r |
bab62329 | 154 | FillBunchConfig(fBunchConfMeas[ibm], buff);\r |
799c6677 | 155 | //\r |
d97d27ff | 156 | snprintf(buff,99,fgkDCSNames[kBunchLgt],ibm+1); // ----- measured bunch lenghts\r |
bab62329 | 157 | FillBunchInfo(fBunchLengths[ibm],buff,ibm,kFALSE); \r |
799c6677 | 158 | //\r |
d97d27ff | 159 | snprintf(buff,99,fgkDCSNames[kIntBunchAv],ibm+1); // ----- B-by-B intensities\r |
bab62329 | 160 | FillBunchInfo(fIntensPerBunch[ibm],buff,ibm,kTRUE);\r |
799c6677 | 161 | //\r |
162 | //\r | |
d97d27ff | 163 | snprintf(buff,99,fgkDCSNames[kIntTot],ibm+1); // ----- total intensities for beam 1 and 2\r |
bab62329 | 164 | FillScalarRecord(fIntensTotal[ibm], buff);\r |
799c6677 | 165 | //\r |
d97d27ff | 166 | snprintf(buff,99,fgkDCSNames[kIntTotAv],ibm+1); // ----- total intensities for beam 1 and 2 from B-by-B average\r |
bab62329 | 167 | FillScalarRecord(fIntensTotalAv[ibm], buff);\r |
799c6677 | 168 | //\r |
d97d27ff | 169 | snprintf(buff,99,fgkDCSNames[kBeamSzEmittH],ibm+1); // ----- H emittance for beam 1 and 2 \r |
bab62329 | 170 | FillScalarRecord(fEmittanceH[ibm], buff);\r |
799c6677 | 171 | //\r |
d97d27ff | 172 | snprintf(buff,99,fgkDCSNames[kBeamSzEmittV],ibm+1); // ----- V emittance for beam 1 and 2 \r |
bab62329 | 173 | FillScalarRecord(fEmittanceV[ibm], buff);\r |
799c6677 | 174 | //\r |
d97d27ff | 175 | snprintf(buff,99 ,fgkDCSNames[kBeamSzSigH], ibm+1); // ----- H sigmas and errors for beam 1 and 2 \r |
176 | snprintf(buff1,99,fgkDCSNames[kBeamSzSigHErr],ibm+1);\r | |
bab62329 | 177 | FillScalarRecord(fBeamSigmaH[ibm], buff, buff1);\r |
799c6677 | 178 | //\r |
d97d27ff | 179 | snprintf(buff,99 ,fgkDCSNames[kBeamSzSigV], ibm+1); // ----- V sigmas and errors for beam 1 and 2 \r |
180 | snprintf(buff1,99,fgkDCSNames[kBeamSzSigVErr],ibm+1);\r | |
bab62329 | 181 | FillScalarRecord(fBeamSigmaV[ibm], buff, buff1);\r |
799c6677 | 182 | //\r |
183 | }\r | |
184 | //\r | |
3760aa6b | 185 | FlagInteractingBunches(fBunchConfMeas[0],fBunchConfMeas[1]);\r |
186 | FlagInteractingBunches(fBunchConfDecl[0],fBunchConfDecl[1]);\r | |
187 | //\r | |
799c6677 | 188 | for (int ilr=0;ilr<2;ilr++) {\r |
189 | //\r | |
d97d27ff | 190 | snprintf(buff,99 ,fgkDCSNames[kLumBunch], ilr ? 'R':'L'); // ---- BC-by-BC luminosity at IP2 and its error\r |
191 | snprintf(buff1,99,fgkDCSNames[kLumBunchErr], ilr ? 'R':'L');\r | |
bab62329 | 192 | FillBCLuminosities(fLuminPerBC[ilr], buff, buff1, 0); // BRAN L uses beam2 as a reference, BRAN R - beam1\r |
799c6677 | 193 | //\r |
d97d27ff | 194 | snprintf(buff,99 ,fgkDCSNames[kLumTot] , ilr ? 'R':'L'); // ---- total luminosity at IP2 and its error\r |
195 | snprintf(buff1,99,fgkDCSNames[kLumTotErr], ilr ? 'R':'L');\r | |
bab62329 | 196 | FillScalarRecord(fLuminTotal[ilr], buff, buff1);\r |
799c6677 | 197 | //\r |
d97d27ff | 198 | snprintf(buff,99 ,fgkDCSNames[kLumAcqMode], ilr ? 'R':'L'); // ---- luminosity acquisition mode\r |
bab62329 | 199 | FillAcqMode(fLuminAcqMode[ilr], buff);\r |
799c6677 | 200 | //\r |
d97d27ff | 201 | snprintf(buff,99, fgkDCSNames[kLumCrossAng] , ilr ? 'R':'L'); //----- crossing angle at IP2 and its error\r |
202 | snprintf(buff1,99,fgkDCSNames[kLumCrossAngErr], ilr ? 'R':'L');\r | |
bab62329 | 203 | FillScalarRecord(fCrossAngle[ilr], buff, buff1);\r |
799c6677 | 204 | // \r |
205 | }\r | |
206 | //\r | |
207 | for (int icl=0;icl<kNCollimators;icl++) { // ----- collimators positions\r | |
208 | for (int jaw=0;jaw<kNJaws;jaw++) {\r | |
d97d27ff | 209 | snprintf(buff,99,fgkDCSNames[kCollPos], fgkDCSColNames[icl],fgkDCSColJaws[jaw]); \r |
bab62329 | 210 | FillScalarRecord(fCollimators[icl][jaw], buff);\r |
799c6677 | 211 | } // jaws\r |
212 | } // collimators\r | |
213 | //\r | |
214 | //\r | |
215 | // RunControl info\r | |
bab62329 | 216 | FillStringRecord(fRCInjScheme, fgkDCSNames[kRCInjSch]); // ---- active injection scheme\r |
217 | FillScalarRecord(fRCBeta, fgkDCSNames[kRCBeta]); // ---- target beta \r | |
218 | FillScalarRecord(fRCAngH, fgkDCSNames[kRCCrossAng]); // ---- horisontal angle\r | |
219 | FillScalarRecord(fRCAngV,fgkDCSNames[kRCVang] ); // ---- vertical angle\r | |
799c6677 | 220 | //\r |
221 | return kTRUE;\r | |
222 | }\r | |
223 | \r | |
224 | //___________________________________________________________________\r | |
0e9ab7ce | 225 | TObjArray* AliLHCData::GetDCSEntry(const char* key,int &entry,int &last,double tmin,double tmax) const\r |
799c6677 | 226 | {\r |
bab62329 | 227 | // extract array from the DCS map or file and find the first entry within the time limits\r |
799c6677 | 228 | entry = -1;\r |
0e9ab7ce | 229 | last = -2;\r |
bab62329 | 230 | TObjArray* arr;\r |
231 | if (fMap2Process) arr = (TObjArray*)fMap2Process->GetValue(key);\r | |
232 | else if (fFile2Process) {\r | |
233 | AliLHCReader rd;\r | |
234 | arr = rd.ReadSingleLHCDP(fFile2Process,key);\r | |
235 | }\r | |
236 | else {\r | |
237 | AliError("Neither DCS map nor DCS filename are set");\r | |
238 | return 0; \r | |
239 | }\r | |
240 | //\r | |
799c6677 | 241 | if (!arr || !arr->GetEntriesFast()) { \r |
242 | AliWarning(Form("No data for %s",key)); \r | |
bab62329 | 243 | if (fMap2Process) delete arr; // created on demand\r |
799c6677 | 244 | return 0;\r |
245 | }\r | |
246 | int ntot = arr->GetEntriesFast();\r | |
0e9ab7ce | 247 | //\r |
248 | // search 1st entry before or at tmin\r | |
249 | AliDCSArray* ent = 0;\r | |
250 | Bool_t found = kFALSE;\r | |
799c6677 | 251 | for (entry=0;entry<ntot;entry++) {\r |
0e9ab7ce | 252 | ent = (AliDCSArray*)arr->At(entry);\r |
253 | if (ent->GetTimeStamp()>=tmin-kMarginSOR && ent->GetTimeStamp()<=tmax+kMarginEOR) {\r | |
254 | found = kTRUE;\r | |
255 | if (ent->GetTimeStamp()>tmin) break;\r | |
256 | }\r | |
799c6677 | 257 | }\r |
0e9ab7ce | 258 | if (!found) {\r |
799c6677 | 259 | entry = -1;\r |
260 | TString str;\r | |
261 | str += AliLHCDipValD::TimeAsString(tmin);\r | |
262 | str += " : ";\r | |
263 | str += AliLHCDipValD::TimeAsString(tmax);\r | |
264 | AliWarning(Form("All entries for %s are outside the requested range:\n%s",key,str.Data()));\r | |
bab62329 | 265 | if (fMap2Process) delete arr; // created on demand\r |
266 | return 0;\r | |
799c6677 | 267 | }\r |
0e9ab7ce | 268 | if (entry>0) entry--;\r |
269 | //\r | |
270 | // search last entry at or after tmin\r | |
271 | ent = 0;\r | |
272 | for (last=entry;last<ntot;last++) {\r | |
273 | ent = (AliDCSArray*)arr->At(last);\r | |
274 | if (ent->GetTimeStamp()>tmax) break;\r | |
275 | }\r | |
276 | if (last == ntot) last--;\r | |
277 | else if (ent->GetTimeStamp()>tmax+kMarginEOR) last--;\r | |
278 | //\r | |
799c6677 | 279 | return arr;\r |
280 | }\r | |
281 | \r | |
282 | //___________________________________________________________________\r | |
283 | Int_t AliLHCData::TimeDifference(double v1,double v2,double tol) const\r | |
284 | {\r | |
285 | // return 0 if the times are the same within the tolerance\r | |
286 | // 1 if v1>v2\r | |
287 | // -1 if v1<v2\r | |
288 | v1-=v2;\r | |
289 | if (v1>tol) return 1;\r | |
290 | if (v1<-tol) return -1;\r | |
291 | return 0;\r | |
292 | }\r | |
293 | \r | |
294 | //___________________________________________________________________\r | |
295 | Bool_t AliLHCData::GoodPairID(int beam) const\r | |
296 | {\r | |
297 | // check for correct beam identifier \r | |
298 | if (beam>kBeam2||beam<0) {AliError(Form("BeamID can be 0 or 1, %d requested",beam)); return kFALSE;}\r | |
299 | return kTRUE;\r | |
300 | }\r | |
301 | \r | |
302 | //___________________________________________________________________\r | |
303 | AliLHCDipValI* AliLHCData::GetBunchConfigMeasured(int beam,double tstamp) const\r | |
304 | {\r | |
305 | // find measured bunch configuration valid for given tstamp\r | |
306 | if (!GoodPairID(beam)) return 0;\r | |
307 | return (AliLHCDipValI*)FindRecValidFor(fBunchConfMeas[beam][kStart],fBunchConfMeas[beam][kNStor],tstamp);\r | |
308 | }\r | |
309 | \r | |
310 | //___________________________________________________________________\r | |
311 | AliLHCDipValI* AliLHCData::GetBunchConfigDeclared(int beam,double tstamp) const\r | |
312 | {\r | |
313 | // find declared bunch configuration valid for given tstamp\r | |
314 | if (!GoodPairID(beam)) return 0;\r | |
315 | return (AliLHCDipValI*)FindRecValidFor(fBunchConfDecl[beam][kStart],fBunchConfDecl[beam][kNStor],tstamp);\r | |
316 | }\r | |
317 | \r | |
318 | //___________________________________________________________________\r | |
319 | TObject* AliLHCData::FindRecValidFor(int start,int nrec, double tstamp) const\r | |
320 | {\r | |
321 | // find record within this limits valid for given tstamp (i.e. the last one before or equal to tstamp)\r | |
322 | AliLHCDipValI *prevObj = 0;\r | |
323 | for (int i=0;i<nrec;i++) {\r | |
324 | AliLHCDipValI* curObj = (AliLHCDipValI*)fData[start+i];\r | |
3760aa6b | 325 | if (TimeDifference(tstamp,curObj->GetTimeStamp())<0) break;\r |
799c6677 | 326 | prevObj = curObj;\r |
327 | }\r | |
328 | if (!prevObj && nrec>0) prevObj = (AliLHCDipValI*)fData[start]; // if no exact match, return the 1st one\r | |
329 | return prevObj;\r | |
330 | }\r | |
331 | \r | |
332 | //___________________________________________________________________\r | |
bab62329 | 333 | Int_t AliLHCData::FillScalarRecord(int refs[2], const char* rec, const char* recErr)\r |
799c6677 | 334 | {\r |
335 | // fill record for scalar value, optionally accompanied by measurement error \r | |
336 | //\r | |
337 | AliInfo(Form("Acquiring record: %s",rec));\r | |
338 | //\r | |
e08ebb54 | 339 | TObjArray *arr=0,*arrE=0;\r |
0e9ab7ce | 340 | Int_t iLast=0,iLastE=0,iFirst=0,iFirstE=0;\r |
799c6677 | 341 | //\r |
342 | refs[kStart] = fData.GetEntriesFast();\r | |
343 | refs[kNStor] = 0;\r | |
344 | //\r | |
0e9ab7ce | 345 | if ( !(arr=GetDCSEntry(rec,iFirst,iLast,fTMin,fTMax)) ) return -1;\r |
799c6677 | 346 | //\r |
347 | int dim = 1;\r | |
348 | if (recErr) {\r | |
0e9ab7ce | 349 | arrE = GetDCSEntry(recErr,iFirstE,iLastE,fTMin,fTMax);\r |
799c6677 | 350 | dim += 1;\r |
351 | }\r | |
352 | //\r | |
f8b1c575 | 353 | // Bool_t last = kFALSE;\r |
0e9ab7ce | 354 | while (iFirst<=iLast) {\r |
355 | AliDCSArray *dcsVal = (AliDCSArray*) arr->At(iFirst++);\r | |
799c6677 | 356 | double tstamp = dcsVal->GetTimeStamp();\r |
799c6677 | 357 | //\r |
358 | AliLHCDipValF* curValF = new AliLHCDipValF(dim,tstamp); // start new period\r | |
359 | (*curValF)[0] = ExtractDouble(dcsVal,0); // value\r | |
360 | //\r | |
361 | if (recErr) {\r | |
362 | double errVal = -1;\r | |
0e9ab7ce | 363 | while (iFirstE<=iLastE) { // try to find corresponding error\r |
364 | AliDCSArray *dcsValE = (AliDCSArray*) arrE->At(iFirstE);\r | |
799c6677 | 365 | double tstampE = dcsValE->GetTimeStamp();\r |
799c6677 | 366 | int tdif = TimeDifference(tstamp,tstampE);\r |
367 | if (!tdif) { // error matches to value\r | |
368 | errVal = ExtractDouble(dcsValE,0);\r | |
0e9ab7ce | 369 | iFirstE++; \r |
799c6677 | 370 | break;\r |
371 | }\r | |
0e9ab7ce | 372 | else if (tdif>0) iFirstE++; // error time lags behind, read the next one\r |
799c6677 | 373 | else break; // error time is ahead of value, no error associated\r |
374 | }\r | |
375 | (*curValF)[dim-1] = errVal; // error\r | |
376 | curValF->SetLastSpecial(); // lable the last entry as an error\r | |
377 | }\r | |
378 | //\r | |
379 | fData.Add(curValF);\r | |
380 | refs[kNStor]++;\r | |
f8b1c575 | 381 | // if (last) break;\r |
799c6677 | 382 | }\r |
383 | //\r | |
bab62329 | 384 | if (fFile2Process) {\r |
385 | delete arr;\r | |
386 | delete arrE;\r | |
387 | }\r | |
799c6677 | 388 | return refs[kNStor];\r |
389 | }\r | |
390 | \r | |
391 | //___________________________________________________________________\r | |
bab62329 | 392 | Int_t AliLHCData::FillBunchConfig(int refs[2],const char* rec)\r |
799c6677 | 393 | {\r |
394 | // fill record for bunch configuration\r | |
395 | //\r | |
396 | AliInfo(Form("Acquiring record: %s",rec));\r | |
397 | TObjArray *arr;\r | |
0e9ab7ce | 398 | Int_t iLast,iFirst;\r |
799c6677 | 399 | //\r |
400 | refs[kStart] = fData.GetEntriesFast();\r | |
401 | refs[kNStor] = 0;\r | |
402 | //\r | |
0e9ab7ce | 403 | if ( !(arr=GetDCSEntry(rec,iFirst,iLast,fTMin,fTMax)) ) return -1;\r |
799c6677 | 404 | //\r |
405 | AliLHCDipValI* prevRecI=0;\r | |
0e9ab7ce | 406 | // \r |
407 | while (iFirst<=iLast) {\r | |
408 | AliDCSArray *dcsVal = (AliDCSArray*) arr->At(iFirst++);\r | |
799c6677 | 409 | double tstamp = dcsVal->GetTimeStamp();\r |
799c6677 | 410 | //\r |
411 | int bucket=0, nbunch=0, ndiff=0;\r | |
412 | int nSlots = dcsVal->GetNEntries(); // count number of actual bunches (non-zeros)\r | |
413 | int* dcsArr = dcsVal->GetInt();\r | |
414 | while(nbunch<nSlots && (bucket=dcsArr[nbunch])) {\r | |
415 | if (prevRecI && prevRecI->GetSize()>nbunch && bucket!=prevRecI->GetValue(nbunch)) ndiff++;\r | |
416 | nbunch++;\r | |
417 | }\r | |
418 | if (!nbunch) AliWarning(Form("%s record is present but empty: no beam?",rec));\r | |
419 | if (prevRecI && !ndiff && nbunch==prevRecI->GetSize()) continue; // record similar to previous one\r | |
420 | AliLHCDipValI* curValI = new AliLHCDipValI(nbunch,tstamp); \r | |
421 | for (int i=nbunch;i--;) (*curValI)[i] = dcsArr[i];\r | |
422 | fData.Add(curValI);\r | |
423 | refs[kNStor]++;\r | |
424 | prevRecI = curValI;\r | |
425 | }\r | |
426 | //\r | |
bab62329 | 427 | if (fFile2Process) delete arr;\r |
799c6677 | 428 | return refs[kNStor];\r |
429 | }\r | |
430 | \r | |
431 | //___________________________________________________________________\r | |
bab62329 | 432 | Int_t AliLHCData::FillAcqMode(int refs[2],const char* rec)\r |
799c6677 | 433 | {\r |
434 | // fill acquisition mode\r | |
435 | //\r | |
436 | AliInfo(Form("Acquiring record: %s",rec));\r | |
437 | TObjArray *arr;\r | |
0e9ab7ce | 438 | Int_t iLast,iFirst;\r |
799c6677 | 439 | //\r |
440 | refs[kStart] = fData.GetEntriesFast();\r | |
441 | refs[kNStor] = 0;\r | |
442 | //\r | |
0e9ab7ce | 443 | if ( !(arr=GetDCSEntry(rec,iFirst,iLast,fTMin,fTMax)) ) return -1;\r |
799c6677 | 444 | //\r |
445 | AliLHCDipValI* prevRecI=0;\r | |
0e9ab7ce | 446 | while (iFirst<=iLast) {\r |
447 | AliDCSArray *dcsVal = (AliDCSArray*) arr->At(iFirst++);\r | |
799c6677 | 448 | double tstamp = dcsVal->GetTimeStamp();\r |
799c6677 | 449 | //\r |
450 | int nSlots = dcsVal->GetNEntries();\r | |
451 | if (nSlots<1) continue;\r | |
452 | int acqMode = dcsVal->GetInt()[0];\r | |
453 | if (prevRecI && (*prevRecI)[0] == acqMode) continue; // record similar to previous one\r | |
454 | AliLHCDipValI* curValI = new AliLHCDipValI(1,tstamp); \r | |
455 | (*curValI)[0] = acqMode;\r | |
456 | fData.Add(curValI);\r | |
457 | refs[kNStor]++;\r | |
458 | prevRecI = curValI;\r | |
459 | }\r | |
460 | //\r | |
bab62329 | 461 | if (fFile2Process) delete arr;\r |
799c6677 | 462 | return refs[kNStor];\r |
463 | }\r | |
464 | \r | |
465 | //___________________________________________________________________\r | |
bab62329 | 466 | Int_t AliLHCData::FillStringRecord(int refs[2],const char* rec)\r |
799c6677 | 467 | {\r |
468 | // fill record with string value\r | |
469 | //\r | |
470 | AliInfo(Form("Acquiring record: %s",rec));\r | |
471 | TString prevRec;\r | |
472 | TObjArray *arr;\r | |
0e9ab7ce | 473 | Int_t iLast,iFirst;\r |
799c6677 | 474 | //\r |
475 | refs[kStart] = fData.GetEntriesFast();\r | |
476 | refs[kNStor] = 0;\r | |
477 | //\r | |
0e9ab7ce | 478 | if ( !(arr=GetDCSEntry(rec,iFirst,iLast,fTMin,fTMax)) ) return -1;\r |
799c6677 | 479 | //\r |
0e9ab7ce | 480 | while (iFirst<=iLast) {\r |
481 | AliDCSArray *dcsVal = (AliDCSArray*) arr->At(iFirst++);\r | |
799c6677 | 482 | double tstamp = dcsVal->GetTimeStamp();\r |
799c6677 | 483 | //\r |
484 | TString &str = ExtractString(dcsVal);\r | |
485 | if (!prevRec.IsNull()) {if (str == prevRec) continue;} // skip similar record\r | |
486 | else prevRec = str;\r | |
487 | //\r | |
488 | AliLHCDipValC* curValS = new AliLHCDipValC(1,tstamp); \r | |
489 | curValS->SetValues(str.Data(),str.Length()+1);\r | |
490 | //\r | |
491 | fData.Add(curValS);\r | |
492 | refs[kNStor]++;\r | |
493 | }\r | |
bab62329 | 494 | if (fFile2Process) delete arr;\r |
799c6677 | 495 | return refs[kNStor];\r |
496 | }\r | |
497 | \r | |
498 | //___________________________________________________________________\r | |
bab62329 | 499 | Int_t AliLHCData::FillBunchInfo(int refs[2],const char* rec, int ibm, Bool_t inRealSlots)\r |
799c6677 | 500 | {\r |
501 | // fill bunch properties for beam ibm\r | |
502 | // if inRealSlots = true, then the value is taken from bunchRFbucket/10, otherwise, the value \r | |
503 | // for the i-th bunch is taken from the i-th element\r | |
504 | //\r | |
505 | AliInfo(Form("Acquiring record: %s",rec));\r | |
506 | TObjArray *arr;\r | |
0e9ab7ce | 507 | Int_t iLast,iFirst;\r |
799c6677 | 508 | //\r |
509 | refs[kStart] = fData.GetEntriesFast();\r | |
510 | refs[kNStor] = 0;\r | |
511 | //\r | |
0e9ab7ce | 512 | if ( !(arr=GetDCSEntry(rec,iFirst,iLast,fTMin,fTMax)) ) return -1;\r |
41ff94a3 | 513 | //\r |
0e9ab7ce | 514 | while (iFirst<=iLast) {\r |
515 | AliDCSArray *dcsVal = (AliDCSArray*) arr->At(iFirst++);\r | |
799c6677 | 516 | double tstamp = dcsVal->GetTimeStamp();\r |
799c6677 | 517 | //\r |
518 | AliLHCDipValI *bconf = GetBunchConfigMeasured(ibm,tstamp);\r | |
519 | if (!bconf) {\r | |
520 | AliWarning(Form("Mearured bunch configuration for beam %d at t=%.1f is not available, trying declared one",ibm+1,tstamp));\r | |
521 | bconf = GetBunchConfigDeclared(ibm,tstamp);\r | |
522 | }\r | |
523 | if (!bconf) {\r | |
524 | AliWarning(Form("Declared bunch configuration for beam %d at t=%.1f is not available, skip this record",ibm+1,tstamp));\r | |
525 | return -1;\r | |
526 | }\r | |
527 | int nSlots = dcsVal->GetNEntries(); // count number of actual bunches (non-zeros)\r | |
528 | int nbunch = bconf->GetSize();\r | |
529 | if (nbunch>nSlots) {\r | |
530 | AliWarning(Form("More N bunches than slots in %s at time %.1f",rec,tstamp));\r | |
531 | continue;\r | |
532 | }\r | |
533 | double* dcsArr = dcsVal->GetDouble();\r | |
534 | AliLHCDipValF* curValF = new AliLHCDipValF(nbunch,tstamp);\r | |
535 | for (int i=nbunch;i--;) {\r | |
536 | int ind = inRealSlots ? (*bconf)[i]/10 : i;\r | |
537 | if (ind>nSlots) {\r | |
538 | AliError(Form("Bunch %d refers to wrong slot %d, set to -1",i,(*bconf)[i]));\r | |
539 | (*curValF)[i] = -1;\r | |
540 | }\r | |
541 | else (*curValF)[i] = dcsArr[ind];\r | |
542 | }\r | |
543 | fData.Add(curValF);\r | |
544 | refs[kNStor]++;\r | |
545 | }\r | |
bab62329 | 546 | if (fFile2Process) delete arr;\r |
799c6677 | 547 | return refs[kNStor];\r |
548 | //\r | |
549 | }\r | |
550 | \r | |
551 | //___________________________________________________________________\r | |
bab62329 | 552 | Int_t AliLHCData::FillBCLuminosities(int refs[2],const char* rec, const char* recErr, int useBeam)\r |
799c6677 | 553 | {\r |
554 | // fill luminosities per bunch crossing\r | |
555 | //\r | |
556 | AliInfo(Form("Acquiring record: %s",rec));\r | |
e08ebb54 | 557 | TObjArray *arr,*arrE=0;\r |
0e9ab7ce | 558 | Int_t iLast=0,iLastE=0,iFirst=0,iFirstE=0;\r |
799c6677 | 559 | //\r |
560 | refs[kStart] = fData.GetEntriesFast();\r | |
561 | refs[kNStor] = 0;\r | |
562 | //\r | |
0e9ab7ce | 563 | if ( !(arr=GetDCSEntry(rec,iFirst,iLast,fTMin,fTMax)) ) return -1;\r |
799c6677 | 564 | //\r |
0e9ab7ce | 565 | while (iFirst<=iLast) {\r |
566 | AliDCSArray *dcsVal = (AliDCSArray*) arr->At(iFirst++);\r | |
799c6677 | 567 | double tstamp = dcsVal->GetTimeStamp();\r |
799c6677 | 568 | //\r |
3760aa6b | 569 | AliLHCDipValI *bconf;\r |
570 | bconf = GetBunchConfigMeasured(useBeam,tstamp); // luminosities are stored according to beam bunches\r | |
799c6677 | 571 | if (!bconf) {\r |
3760aa6b | 572 | AliWarning(Form("Mearured bunch configuration for beam%d at t=%.1f is not available, trying declared one",useBeam,tstamp));\r |
573 | bconf = GetBunchConfigDeclared(useBeam,tstamp);\r | |
799c6677 | 574 | }\r |
575 | if (!bconf) {\r | |
3760aa6b | 576 | AliWarning(Form("Declared bunch configuration for beam%i at t=%.1f is not available, skip this record",useBeam,tstamp));\r |
799c6677 | 577 | return -1;\r |
578 | }\r | |
579 | int nSlots = dcsVal->GetNEntries(); // count number of actual bunches (non-zeros)\r | |
580 | int nbunch = bconf->GetSize();\r | |
581 | double* dcsArr = dcsVal->GetDouble();\r | |
582 | //\r | |
799c6677 | 583 | if (nbunch>nSlots) {\r |
584 | AliWarning(Form("More N bunches than slots in %s at time %.1f",rec,tstamp));\r | |
585 | continue;\r | |
586 | }\r | |
3760aa6b | 587 | int dim = 0;\r |
588 | if (!bconf->IsProcessed1()) {\r | |
589 | AliWarning(Form("Bunch conf. for beam%d has no marked interacting bunches, store all luminosity for all filled bunches",useBeam));\r | |
590 | dim = nbunch;\r | |
591 | }\r | |
592 | else { // count number of interacting bunches\r | |
593 | for (int i=nbunch;i--;) if ((*bconf)[i]<0) dim++;\r | |
594 | }\r | |
595 | //\r | |
799c6677 | 596 | if (recErr) {\r |
0e9ab7ce | 597 | arrE=GetDCSEntry(recErr,iFirstE,iLastE,fTMin,fTMax);\r |
799c6677 | 598 | dim += 1;\r |
599 | }\r | |
600 | AliLHCDipValF* curValF = new AliLHCDipValF(dim,tstamp);\r | |
3760aa6b | 601 | int cnt = 0;\r |
602 | for (int i=0;i<nbunch;i++) {\r | |
603 | int slot = (*bconf)[i];\r | |
604 | if (bconf->IsProcessed1() && slot>0) continue;\r | |
605 | //\r | |
606 | int ind = TMath::Abs(slot)/10;\r | |
799c6677 | 607 | if (ind>nSlots) {\r |
3760aa6b | 608 | AliError(Form("Bunch %d refers to wrong slot %d, set to -1",cnt,slot));\r |
609 | (*curValF)[cnt] = -1;\r | |
799c6677 | 610 | }\r |
3760aa6b | 611 | else (*curValF)[cnt] = dcsArr[ind];\r |
612 | cnt++;\r | |
799c6677 | 613 | }\r |
614 | //\r | |
615 | if (recErr) {\r | |
616 | double errVal = -1;\r | |
0e9ab7ce | 617 | while (iFirstE<=iLastE) { // try to find corresponding error\r |
618 | AliDCSArray *dcsValE = (AliDCSArray*) arrE->At(iFirstE);\r | |
799c6677 | 619 | double tstamp1 = dcsValE->GetTimeStamp();\r |
799c6677 | 620 | int tdif = TimeDifference(tstamp,tstamp1);\r |
621 | if (!tdif) { // error matches to value\r | |
622 | errVal = dcsValE->GetDouble()[0];\r | |
0e9ab7ce | 623 | iFirstE++; \r |
799c6677 | 624 | break;\r |
625 | }\r | |
0e9ab7ce | 626 | else if (tdif>0) iFirstE++; // error time lags behind, read the next one\r |
799c6677 | 627 | else break; // error time is ahead of value, no error associated\r |
628 | }\r | |
629 | (*curValF)[dim-1] = errVal; // error\r | |
630 | curValF->SetLastSpecial(); // lable the last entry as an error\r | |
631 | }\r | |
632 | //\r | |
633 | fData.Add(curValF);\r | |
634 | refs[kNStor]++;\r | |
635 | }\r | |
bab62329 | 636 | if (fFile2Process) {\r |
637 | delete arr;\r | |
638 | delete arrE;\r | |
639 | }\r | |
799c6677 | 640 | return refs[kNStor];\r |
641 | //\r | |
642 | }\r | |
643 | \r | |
644 | //___________________________________________________________________\r | |
645 | Int_t AliLHCData::ExtractInt(AliDCSArray* dcsArray,Int_t el) const\r | |
646 | {\r | |
647 | // extract integer from the dcsArray\r | |
648 | int val = -1;\r | |
649 | //\r | |
650 | int sz = dcsArray->GetNEntries();\r | |
651 | if (sz<=el) return val;\r | |
652 | //\r | |
653 | if (dcsArray->GetType()==AliDCSArray::kInt) val = dcsArray->GetInt(el);\r | |
654 | else if (dcsArray->GetType()==AliDCSArray::kString) {\r | |
655 | TObjString *stro = dcsArray->GetStringArray(el);\r | |
656 | if (stro) val = stro->GetString().Atoi();\r | |
657 | else AliError(Form("DCSArray TObjString for element %d is missing",el));\r | |
658 | }\r | |
659 | else if (dcsArray->GetType()==AliDCSArray::kUInt) val = dcsArray->GetUInt(el);\r | |
660 | else AliError(Form("Integer requested from DCSArray of type %d",dcsArray->GetType()));\r | |
661 | return val;\r | |
662 | }\r | |
663 | \r | |
664 | //___________________________________________________________________\r | |
665 | Double_t AliLHCData::ExtractDouble(AliDCSArray* dcsArray,Int_t el) const\r | |
666 | {\r | |
667 | // extract double from the dcsArray\r | |
668 | double val = 0;\r | |
669 | //\r | |
670 | int sz = dcsArray->GetNEntries();\r | |
671 | if (sz<=el) return val;\r | |
672 | //\r | |
673 | if (dcsArray->GetType()==AliDCSArray::kDouble) val = dcsArray->GetDouble(el);\r | |
674 | else if (dcsArray->GetType()==AliDCSArray::kFloat) val = dcsArray->GetFloat(el);\r | |
675 | else if (dcsArray->GetType()==AliDCSArray::kString) {\r | |
676 | TObjString *stro = dcsArray->GetStringArray(el);\r | |
677 | if (stro) val = stro->GetString().Atof();\r | |
678 | else AliError(Form("DCSArray has TObjString for element %d is missing",el));\r | |
679 | }\r | |
680 | else if (dcsArray->GetType()==AliDCSArray::kChar) val = dcsArray->GetChar(el);\r | |
681 | else if (dcsArray->GetType()==AliDCSArray::kInt) val = dcsArray->GetInt(el);\r | |
682 | else if (dcsArray->GetType()==AliDCSArray::kUInt) val = dcsArray->GetUInt(el);\r | |
683 | else AliError(Form("Double requested from DCSArray of type %d",dcsArray->GetType()));\r | |
684 | return val;\r | |
685 | }\r | |
686 | \r | |
687 | //___________________________________________________________________\r | |
688 | TString& AliLHCData::ExtractString(AliDCSArray* dcsArray) const\r | |
689 | {\r | |
690 | // extract string from the dcsArray\r | |
691 | static TString str;\r | |
692 | str = "";\r | |
693 | //\r | |
694 | int sz = dcsArray->GetNEntries();\r | |
695 | if (dcsArray->GetType()!=AliDCSArray::kString) {\r | |
696 | AliError(Form("String requested from DCSArray of type %d",dcsArray->GetType()));\r | |
697 | return str;\r | |
698 | }\r | |
699 | //\r | |
700 | for (int i=0;i<sz;i++) {\r | |
701 | str += dcsArray->GetStringArray(i)->GetString();\r | |
702 | if (i<sz-1) str += " ";\r | |
703 | }\r | |
704 | return str;\r | |
705 | }\r | |
706 | \r | |
707 | //___________________________________________________________________\r | |
708 | void AliLHCData::Print(const Option_t* opt) const\r | |
709 | {\r | |
710 | // print full info\r | |
711 | TString opts = opt;\r | |
712 | opts.ToLower();\r | |
41ff94a3 | 713 | Bool_t utcTime = opts.Contains("loc") ? kFALSE:kTRUE;\r |
799c6677 | 714 | Bool_t full = kTRUE;\r |
715 | if (!opts.Contains("f")) {\r | |
716 | printf("Use Print(\"f\") to print full info\n");\r | |
717 | printf("Printing short info:\n<RecordType>(number of records): <TimeStamp, value> for 1st record only\n");\r | |
718 | full = kFALSE;\r | |
719 | }\r | |
41ff94a3 | 720 | TString sdtmn = AliLHCDipValI::TimeAsString(fTMin,utcTime);\r |
721 | TString sdtmx = AliLHCDipValI::TimeAsString(fTMax,utcTime);\r | |
722 | printf("Fill#%6d Validity: %s - %s (%s)\n",fFillNumber,sdtmn.Data(),sdtmx.Data(),utcTime ? "UTC":"LOC");\r | |
799c6677 | 723 | //\r |
724 | printf("********** SETTINGS FROM RUN CONTROL **********\n");\r | |
725 | //\r | |
3760aa6b | 726 | printf("* %-38s","Injection Scheme");\r |
41ff94a3 | 727 | PrintAux(full,fRCInjScheme,opts);\r |
799c6677 | 728 | //\r |
3760aa6b | 729 | printf("* %-38s","Beta Star");\r |
41ff94a3 | 730 | PrintAux(full,fRCBeta,opts);\r |
799c6677 | 731 | //\r |
3760aa6b | 732 | printf("* %-38s","Horisontal Crossing Angle");\r |
41ff94a3 | 733 | PrintAux(full,fRCAngH,opts);\r |
799c6677 | 734 | //\r |
3760aa6b | 735 | printf("* %-38s","Vertical Crossing Angle");\r |
41ff94a3 | 736 | PrintAux(full,fRCAngV,opts);\r |
799c6677 | 737 | //\r |
738 | for (int ib=0;ib<2;ib++) {\r | |
3760aa6b | 739 | printf("* Beam%d filling [- interacts at IR2!] ",ib+1);\r |
41ff94a3 | 740 | PrintAux(full,fBunchConfDecl[ib],opts);\r |
799c6677 | 741 | }\r |
742 | //\r | |
743 | printf("\n********** MEASURED DATA **********\n");\r | |
744 | //\r | |
745 | for (int ib=0;ib<2;ib++) {\r | |
3760aa6b | 746 | printf("* Beam%d filling [- interacts at IR2!] ",ib+1);\r |
41ff94a3 | 747 | PrintAux(full,fBunchConfMeas[ib],opts);\r |
799c6677 | 748 | } \r |
749 | //\r | |
750 | for (int ib=0;ib<2;ib++) {\r | |
3760aa6b | 751 | printf("* Beam%d total intensity ",ib+1);\r |
41ff94a3 | 752 | PrintAux(full,fIntensTotal[ib],opts);\r |
799c6677 | 753 | } \r |
754 | //\r | |
755 | for (int ib=0;ib<2;ib++) {\r | |
3760aa6b | 756 | printf("* Beam%d total intensity (bunch average) ",ib+1);\r |
41ff94a3 | 757 | PrintAux(full,fIntensTotalAv[ib],opts);\r |
799c6677 | 758 | } \r |
759 | //\r | |
760 | for (int ib=0;ib<2;ib++) {\r | |
3760aa6b | 761 | printf("* Beam%d intensity per bunch ",ib+1);\r |
41ff94a3 | 762 | PrintAux(full,fIntensPerBunch[ib],opts);\r |
799c6677 | 763 | }\r |
764 | //\r | |
765 | for (int ib=0;ib<2;ib++) {\r | |
3760aa6b | 766 | printf("* Beam%d bunch lengths ",ib+1);\r |
41ff94a3 | 767 | PrintAux(full,fBunchLengths[ib],opts);\r |
799c6677 | 768 | } \r |
769 | //\r | |
770 | for (int ib=0;ib<2;ib++) {\r | |
3760aa6b | 771 | printf("* Beam%d Horisontal emittance ",ib+1);\r |
41ff94a3 | 772 | PrintAux(full,fEmittanceH[ib],opts);\r |
799c6677 | 773 | }\r |
774 | //\r | |
775 | for (int ib=0;ib<2;ib++) {\r | |
3760aa6b | 776 | printf("* Beam%d Vertical emittance ",ib+1);\r |
41ff94a3 | 777 | PrintAux(full,fEmittanceV[ib],opts);\r |
799c6677 | 778 | }\r |
779 | //\r | |
780 | for (int ib=0;ib<2;ib++) {\r | |
3760aa6b | 781 | printf("* Beam%d Horisontal sigma ",ib+1);\r |
41ff94a3 | 782 | PrintAux(full,fBeamSigmaH[ib],opts);\r |
799c6677 | 783 | }\r |
784 | //\r | |
785 | for (int ib=0;ib<2;ib++) {\r | |
3760aa6b | 786 | printf("* Beam%d Vertical sigma ",ib+1);\r |
41ff94a3 | 787 | PrintAux(full,fBeamSigmaV[ib],opts);\r |
799c6677 | 788 | }\r |
789 | //\r | |
790 | for (int lr=0;lr<2;lr++) {\r | |
3760aa6b | 791 | printf("* Total luminosity from BRANB_4%c2 ",lr ? 'R':'L');\r |
41ff94a3 | 792 | PrintAux(full,fLuminTotal[lr],opts);\r |
799c6677 | 793 | } \r |
794 | //\r | |
795 | for (int lr=0;lr<2;lr++) {\r | |
3760aa6b | 796 | printf("* Luminosity acq.mode, BRANB_4%c2 ",lr ? 'R':'L');\r |
41ff94a3 | 797 | PrintAux(full,fLuminAcqMode[lr],opts+"bit");\r |
799c6677 | 798 | } \r |
799 | //\r | |
800 | for (int lr=0;lr<2;lr++) {\r | |
3760aa6b | 801 | printf("* Luminosity per BC from BRANB_4%c2 ",lr ? 'R':'L');\r |
41ff94a3 | 802 | PrintAux(full,fLuminPerBC[lr],opts);\r |
799c6677 | 803 | }\r |
804 | //\r | |
805 | for (int lr=0;lr<2;lr++) {\r | |
3760aa6b | 806 | printf("* Crossing angle, side %c ",lr ? 'R':'L');\r |
41ff94a3 | 807 | PrintAux(full,fCrossAngle[lr],opts);\r |
799c6677 | 808 | }\r |
809 | //\r | |
810 | for (int coll=0;coll<kNCollimators;coll++)\r | |
811 | for (int jaw=0;jaw<kNJaws;jaw++) {\r | |
3760aa6b | 812 | printf("* Collimator %10s:%16s",fgkDCSColNames[coll],fgkDCSColJaws[jaw]);\r |
41ff94a3 | 813 | PrintAux(full,fCollimators[coll][jaw],opts);\r |
799c6677 | 814 | }\r |
815 | //\r | |
816 | }\r | |
817 | \r | |
818 | //___________________________________________________________________\r | |
bab62329 | 819 | void AliLHCData::PrintAux(Bool_t full, const Int_t refs[2], const Option_t *opt) const\r |
799c6677 | 820 | {\r |
821 | // aux method to print the reocrds of the same type\r | |
822 | int nrec = refs[kNStor];\r | |
823 | if (nrec<1) {\r | |
824 | printf(": N/A\n"); \r | |
825 | return;\r | |
826 | }\r | |
3760aa6b | 827 | printf(": (%3d):\t",nrec); // number of records\r |
799c6677 | 828 | if (!full) nrec = 1;\r |
829 | int sz = ((AliLHCDipValI*)fData[refs[kStart]])->GetSizeTotal(); // dimension of the record\r | |
830 | Bool_t isStr = ((AliLHCDipValI*)fData[refs[kStart]])->IsTypeC();\r | |
831 | if ((!isStr && sz>2) || nrec>1) printf("\n"); // long record, open new line\r | |
bab62329 | 832 | for (int i=0;i<nrec;i++) fData[refs[kStart]+i]->Print(opt);\r |
799c6677 | 833 | //\r |
834 | }\r | |
835 | \r | |
836 | //___________________________________________________________________\r | |
837 | void AliLHCData::Clear(const Option_t *)\r | |
838 | {\r | |
839 | // clear all info\r | |
840 | fData.Delete();\r | |
841 | fFillNumber = 0;\r | |
842 | fTMin = 0;\r | |
843 | fTMax = 1e10;\r | |
bab62329 | 844 | fFile2Process = 0;\r |
845 | fMap2Process = 0;\r | |
846 | //\r | |
799c6677 | 847 | for (int i=2;i--;) {\r |
848 | fRCInjScheme[i] = 0;\r | |
849 | fRCBeta[i] = 0;\r | |
850 | fRCAngH[i] = 0;\r | |
851 | fRCAngV[i] = 0;\r | |
852 | //\r | |
853 | for (int icl=kNCollimators;icl--;) for (int jaw=kNJaws;jaw--;) fCollimators[icl][jaw][i]=0;\r | |
854 | //\r | |
855 | for (int j=2;j--;) {\r | |
856 | fBunchConfDecl[j][i] = 0;\r | |
857 | fBunchConfMeas[j][i] = 0;\r | |
858 | fBunchLengths[j][i] = 0;\r | |
859 | fIntensTotal[j][i] = 0;\r | |
860 | fIntensTotalAv[j][i] = 0;\r | |
861 | fIntensPerBunch[j][i] = 0; \r | |
862 | fCrossAngle[j][i] = 0;\r | |
863 | fEmittanceH[j][i] = 0;\r | |
864 | fEmittanceV[j][i] = 0;\r | |
865 | fBeamSigmaH[j][i] = 0;\r | |
866 | fBeamSigmaV[j][i] = 0;\r | |
867 | fLuminTotal[j][i] = 0;\r | |
868 | fLuminPerBC[j][i] = 0;\r | |
869 | fLuminAcqMode[j][i] = 0;\r | |
870 | }\r | |
871 | }\r | |
872 | }\r | |
873 | \r | |
874 | //___________________________________________________________________\r | |
875 | Int_t AliLHCData::GetNInteractingBunchesMeasured(int i) const\r | |
876 | {\r | |
877 | // get number of interacting bunches at IR2\r | |
878 | AliLHCDipValI* rec = GetBunchConfigMeasured(kBeam1,i);\r | |
879 | if (!rec) {AliInfo(Form("No record %d found",i)); return -1;}\r | |
880 | if (!rec->IsProcessed1()) { AliInfo("Interacting bunches were not marked"); return -1;}\r | |
881 | int n = 0;\r | |
e08ebb54 | 882 | for (int j=rec->GetSize();j--;) if ( (*rec)[j]<0 ) n++;\r |
799c6677 | 883 | return n;\r |
884 | }\r | |
885 | \r | |
886 | //___________________________________________________________________\r | |
887 | Int_t AliLHCData::GetNInteractingBunchesDeclared(int i) const\r | |
888 | {\r | |
889 | // get number of interacting bunches at IR2\r | |
890 | AliLHCDipValI* rec = GetBunchConfigMeasured(kBeam1,i);\r | |
891 | if (!rec) {AliInfo(Form("No record %d found",i)); return -1;}\r | |
892 | if (!rec->IsProcessed1()) { AliInfo("Interacting bunches were not marked"); return -1; }\r | |
893 | int n = 0;\r | |
e08ebb54 | 894 | for (int j=rec->GetSize();j--;) if ( (*rec)[j]<0 ) n++;\r |
799c6677 | 895 | return n;\r |
896 | }\r | |
897 | \r | |
898 | //___________________________________________________________________\r | |
899 | Int_t AliLHCData::IsPilotPresent(int i) const\r | |
900 | {\r | |
901 | // check in the filling scheme is the pilot bunch is present\r | |
902 | AliLHCDipValC* rec = GetInjectionScheme();\r | |
903 | if (!rec) {AliInfo(Form("No record %d found",i)); return -1;}\r | |
904 | TString scheme = rec->GetValues();\r | |
905 | return scheme.Contains("wp",TString::kIgnoreCase);\r | |
906 | }\r | |
3760aa6b | 907 | \r |
908 | //___________________________________________________________________\r | |
909 | void AliLHCData::FlagInteractingBunches(const Int_t beam1[2],const Int_t beam2[2])\r | |
910 | {\r | |
911 | // assign - sign to interacting bunches\r | |
3760aa6b | 912 | //\r |
913 | for (int ib1=0;ib1<beam1[kNStor];ib1++) {\r | |
914 | AliLHCDipValI *bm1 = (AliLHCDipValI*)fData[ beam1[kStart] + ib1];\r | |
915 | if (!bm1) continue;\r | |
916 | AliLHCDipValI *bm2 = (AliLHCDipValI*)FindRecValidFor(beam2[kStart],beam2[kNStor], bm1->GetTimeStamp());\r | |
917 | if (!bm2) continue;\r | |
918 | //\r | |
919 | int nb1 = bm1->GetSize();\r | |
920 | int nb2 = bm2->GetSize();\r | |
921 | int i1,i2;\r | |
922 | for (i1=0;i1<nb1;i1++) {\r | |
923 | int bunch2=-1, bunch1 = TMath::Abs((*bm1)[i1]);\r | |
2af04ffd | 924 | int slot2 =-1, slot1 = GetBCId(bunch1,0);\r |
3760aa6b | 925 | for (i2=0;i2<nb2;i2++) {\r |
926 | bunch2 = TMath::Abs((*bm2)[i2]);\r | |
2af04ffd | 927 | slot2 = GetBCId(bunch2,1);\r |
3760aa6b | 928 | if (slot1==slot2) break;\r |
929 | }\r | |
930 | if (slot1!=slot2) continue;\r | |
931 | (*bm1)[i1] = -bunch1;\r | |
932 | (*bm2)[i2] = -bunch2;\r | |
933 | bm1->SetProcessed1();\r | |
934 | bm2->SetProcessed1();\r | |
935 | }\r | |
936 | }\r | |
937 | }\r | |
3d84ad67 | 938 | \r |
939 | //___________________________________________________________________\r | |
2af04ffd | 940 | Int_t AliLHCData::GetMeanIntensity(int beamID, Double_t &colliding, Double_t &noncolliding, const TObjArray* bcmasks) const\r |
3d84ad67 | 941 | {\r |
942 | // get average intensity for all, colliding and non-colliding bunches\r | |
943 | // on success returns number of intensity records used (1 per ~10 min)\r | |
2af04ffd | 944 | // If triggered BC masks are provided, calculation is done for Triggered BC only\r |
3d84ad67 | 945 | colliding = noncolliding = -1.;\r |
946 | if (beamID<0||beamID>1) {\r | |
947 | AliError(Form("BeamID must be either 0 or 1, %d requested",beamID));\r | |
948 | return -10;\r | |
949 | }\r | |
950 | //\r | |
2af04ffd | 951 | AliTriggerBCMask *bcMaskBoth=0,*bcMaskSingle=0;\r |
952 | int nbcm = 0;\r | |
953 | if (bcmasks && (nbcm=bcmasks->GetEntries())) {\r | |
954 | if (nbcm>1) bcMaskBoth = (AliTriggerBCMask*)bcmasks->At(1);\r | |
955 | if (nbcm>0 && beamID==kBeam1) bcMaskSingle = (AliTriggerBCMask*)bcmasks->At(0);\r | |
956 | else if (nbcm>2 && beamID==kBeam2) bcMaskSingle = (AliTriggerBCMask*)bcmasks->At(2);\r | |
957 | //\r | |
958 | if (!bcMaskSingle) AliError(Form("Only triggered BSs are requested but %c mask is not provided",beamID ? 'C':'A'));\r | |
959 | if (!bcMaskBoth) AliError("Only triggered BSs are requested but B mask is not provided");\r | |
960 | }\r | |
961 | else {\r | |
962 | AliWarning("No BC masks are provided");\r | |
963 | }\r | |
964 | //\r | |
3d84ad67 | 965 | int nrec = GetNIntensityPerBunch(beamID);\r |
966 | if (nrec<1) return -1;\r | |
967 | AliLHCDipValI *conf = GetBunchConfigMeasured(beamID);\r | |
968 | if (!conf) conf = GetBunchConfigDeclared(beamID);\r | |
969 | if (!conf) return -2;\r | |
970 | int nb = conf->GetSize();\r | |
971 | //\r | |
972 | for (int irec=0;irec<nrec;irec++) {\r | |
2af04ffd | 973 | //\r |
3d84ad67 | 974 | AliLHCDipValF* rInt = GetIntensityPerBunch(beamID,irec);\r |
975 | for (int ib=0;ib<nb;ib++) {\r | |
976 | double val = rInt->GetValue(ib);\r | |
977 | if (val<0) continue;\r | |
978 | int bID = conf->GetValue(ib);\r | |
2af04ffd | 979 | // check if this is a triggered bunch\r |
980 | int bcID = GetBCId(bID, beamID);\r | |
981 | if (bID<0) { // interacting\r | |
982 | if (bcMaskBoth && bcMaskBoth->GetMask(bcID)) continue; // masked\r | |
983 | colliding += val;\r | |
984 | }\r | |
985 | else {\r | |
986 | if (bcMaskSingle && bcMaskSingle->GetMask(bcID)) continue; // masked \r | |
987 | noncolliding += val;\r | |
988 | }\r | |
3d84ad67 | 989 | }\r |
990 | }\r | |
991 | colliding /= nrec;\r | |
992 | noncolliding /= nrec;\r | |
993 | return nrec;\r | |
994 | }\r |