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