]> git.uio.no Git - u/mrichter/AliRoot.git/blame - STEER/STEERBase/AliRunTag.cxx
o fix treatment for dedicated splines LHC13D1
[u/mrichter/AliRoot.git] / STEER / STEERBase / AliRunTag.cxx
CommitLineData
f3a97c86 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
15
16/* $Id$ */
17
18//-----------------------------------------------------------------
19// Implementation of the RunTag class
20// This is the class to deal with the tags in the run level
21// Origin: Panos Christakoglou, UOA-CERN, Panos.Christakoglou@cern.ch
22//-----------------------------------------------------------------
23
04cb11d4 24#include <stdlib.h>
f3a97c86 25#include "AliRunTag.h"
f3a97c86 26#include "AliDetectorTag.h"
27#include "AliEventTag.h"
28
29ClassImp(AliRunTag)
30
bec9a2e7 31//___________________________________________________________________________
17a9d008 32 AliRunTag::AliRunTag() :
33 TObject(),
34 fAliceRunId(-1),
35 fAliceMagneticField(0.0),
850d5792 36 fAliceDipoleField(0.0),
17a9d008 37 fAliceRunStartTime(0),
38 fAliceRunStopTime(0),
bec9a2e7 39 fAlirootVersion(0),
40 fRootVersion(0),
41 fGeant3Version(0),
850d5792 42 fLHCPeriod(0),
43 fRecPass(0),
44 fProductionName(0),
04cb11d4 45 fAliceRunValidated(0),
46 fAliceRunGlobalQuality(0),
17a9d008 47 fAliceBeamEnergy(0.0),
bec9a2e7 48 fAliceBeamType(0),
17a9d008 49 fAliceCalibrationVersion(0),
50 fAliceDataType(0),
04cb11d4 51 // fNumEvents(0),
52 fNumFiles(0),
53 fBeamTriggers(0),
54 fCollisionTriggers(0),
55 fEmptyTriggers(0),
56 fASideTriggers(0),
57 fCSideTriggers(0),
58 fHMTriggers(0),
59 fMuonTriggers(0),
60 fCollisionRate(0.0),
61 fMeanVertex(0.0),
62 fVertexQuality(0.0),
17a9d008 63 fNumDetectors(0),
04cb11d4 64 fFileTags(100),
c5caed45 65 fDetectorTag(),
46af88be 66 fLHCTag(),
04cb11d4 67 fActiveTriggerClasses(""),
9ee5d033 68 fQA(),
27293674 69 fQALength(0),
9ee5d033 70 fQAArray(NULL),
27293674 71 fESLength(0),
72 fEventSpecies(NULL)
f3a97c86 73{
e16601cf 74 //Default constructor
f3a97c86 75}
76
bec9a2e7 77//___________________________________________________________________________
78AliRunTag::~AliRunTag() {
17a9d008 79 //Destructor
04cb11d4 80 // fEventTag.Delete();
9ee5d033 81 if ( fQAArray )
82 delete [] fQAArray ;
27293674 83 if ( fEventSpecies )
84 delete [] fEventSpecies ;
04cb11d4 85 fFileTags.Delete();
27293674 86}
87
88//___________________________________________________________________________
89AliRunTag::AliRunTag(const AliRunTag& tag):
90TObject(),
91fAliceRunId(tag.fAliceRunId),
92fAliceMagneticField(tag.fAliceMagneticField),
850d5792 93fAliceDipoleField(tag.fAliceDipoleField),
27293674 94fAliceRunStartTime(tag.fAliceRunStartTime),
b28939aa 95fAliceRunStopTime(tag.fAliceRunStopTime),
27293674 96fAlirootVersion(tag.fAlirootVersion),
97fRootVersion(tag.fRootVersion),
98fGeant3Version(tag.fGeant3Version),
850d5792 99fLHCPeriod(tag.fLHCPeriod),
100fRecPass(tag.fRecPass),
101fProductionName(tag.fProductionName),
04cb11d4 102fAliceRunValidated(tag.fAliceRunValidated),
103fAliceRunGlobalQuality(tag.fAliceRunGlobalQuality),
27293674 104fAliceBeamEnergy(tag.fAliceBeamEnergy),
105fAliceBeamType(tag.fAliceBeamType),
106fAliceCalibrationVersion(tag.fAliceCalibrationVersion),
107fAliceDataType(tag.fAliceDataType),
04cb11d4 108//fNumEvents(tag.fNumEvents),
bfc9ff63 109fNumFiles(0),
04cb11d4 110fBeamTriggers(tag.fBeamTriggers),
111fCollisionTriggers(tag.fCollisionTriggers),
112fEmptyTriggers(tag.fEmptyTriggers),
113fASideTriggers(tag.fASideTriggers),
114fCSideTriggers(tag.fCSideTriggers),
115fHMTriggers(tag.fHMTriggers),
116fMuonTriggers(tag.fMuonTriggers),
117fCollisionRate(tag.fCollisionRate),
118fMeanVertex(tag.fMeanVertex),
119fVertexQuality(tag.fVertexQuality),
27293674 120fNumDetectors(tag.fNumDetectors),
04cb11d4 121fFileTags(100),
27293674 122fDetectorTag(tag.fDetectorTag),
123fLHCTag(tag.fLHCTag),
04cb11d4 124fActiveTriggerClasses(tag.fActiveTriggerClasses),
9ee5d033 125fQA(tag.fQA),
27293674 126fQALength(tag.fQALength),
9ee5d033 127fQAArray(NULL),
27293674 128fESLength(tag.fESLength),
129fEventSpecies(NULL)
130{
131 //copy constructor
132 if (fQALength == 0 )
9ee5d033 133 fQAArray = NULL ;
27293674 134 else {
9ee5d033 135 fQAArray = new ULong_t[fQALength] ;
136 memcpy(fQAArray, tag.fQAArray, fQALength*sizeof(ULong_t)) ;
27293674 137 }
138 if (fESLength == 0 )
139 fEventSpecies = NULL ;
140 else {
e1ffd6bc 141 fEventSpecies = new Bool_t[fESLength] ;
27293674 142 memcpy(fEventSpecies, tag.fEventSpecies, fESLength*sizeof(Bool_t)) ;
143 }
bfc9ff63 144 for (int ifl=0; ifl<tag.fNumFiles; ifl++) {
145 AddFileTag(new AliFileTag(*tag.GetFileTag(ifl)));
04cb11d4 146 }
147
148
27293674 149}
150
151//___________________________________________________________________________
152AliRunTag& AliRunTag::operator = (const AliRunTag& tag) {
153//assignment operator
154 if(&tag != this) {
155 fAliceRunId = tag.fAliceRunId ;
156 fAliceMagneticField = tag.fAliceMagneticField ;
850d5792 157 fAliceDipoleField = tag.fAliceDipoleField ;
27293674 158 fAliceRunStartTime = tag.fAliceRunStartTime ;
159 fAliceRunStopTime = tag.fAliceRunStopTime ;
160 fAlirootVersion = tag.fAlirootVersion ;
161 fRootVersion = tag.fRootVersion ;
162 fGeant3Version = tag.fGeant3Version ;
850d5792 163 fLHCPeriod = tag.fLHCPeriod ;
164 fRecPass = tag.fRecPass ;
165 fProductionName = tag.fProductionName ;
04cb11d4 166 fAliceRunValidated = tag.fAliceRunValidated ;
167 fAliceRunGlobalQuality = tag.fAliceRunGlobalQuality ;
27293674 168 fAliceBeamEnergy = tag.fAliceBeamEnergy ;
169 fAliceBeamType = tag.fAliceBeamType ;
170 fAliceCalibrationVersion = tag.fAliceCalibrationVersion ;
171 fAliceDataType = tag.fAliceDataType ;
04cb11d4 172 // fNumEvents = tag.fNumEvents ;
04cb11d4 173 fBeamTriggers = tag.fBeamTriggers;
174 fCollisionTriggers = tag.fCollisionTriggers;
175 fEmptyTriggers = tag.fEmptyTriggers;
176 fASideTriggers = tag.fASideTriggers;
177 fCSideTriggers = tag.fCSideTriggers;
178 fHMTriggers = tag.fHMTriggers;
179 fMuonTriggers = tag.fMuonTriggers;
180 fCollisionRate = tag.fCollisionRate;
181 fMeanVertex = tag.fMeanVertex;
182 fVertexQuality = tag.fVertexQuality;
27293674 183 fNumDetectors = tag.fNumDetectors ;
27293674 184 fDetectorTag = tag.fDetectorTag ;
185 fLHCTag = tag.fLHCTag ;
04cb11d4 186 fActiveTriggerClasses = tag.fActiveTriggerClasses;
9ee5d033 187 fQA = tag.fQA ;
27293674 188 fQALength = tag.fQALength ;
9ee5d033 189 if (fQAArray)
190 delete [] fQAArray ;
27293674 191 if (fQALength == 0 )
9ee5d033 192 fQAArray = NULL ;
27293674 193 else {
9ee5d033 194 fQAArray = new ULong_t[fQALength] ;
195 memcpy(fQAArray, tag.fQAArray, fQALength*sizeof(ULong_t)) ;
27293674 196 }
197 fESLength = tag.fESLength ;
198 if (fEventSpecies)
199 delete [] fEventSpecies ;
200 if (fESLength == 0 )
201 fEventSpecies = NULL ;
202 else {
e1ffd6bc 203 fEventSpecies = new Bool_t[fESLength] ;
27293674 204 memcpy(fEventSpecies, tag.fEventSpecies, fESLength*sizeof(Bool_t)) ;
205 }
0f8cecc4 206 for (int ifl=0; ifl<tag.fNumFiles; ifl++) {
bfc9ff63 207 AddFileTag(new AliFileTag(*tag.GetFileTag(ifl)));
04cb11d4 208 }
209// for (int ifile=0; ifile<tag.GetFileTags()->GetEntries(); ifile++)
210// AddFileTag(*((AliFileTag *) tag.GetFileTags()->At(ifile)));
27293674 211 }
212 return *this ;
f3a97c86 213}
214
0f8cecc4 215//___________________________________________________________________________
216Bool_t AliRunTag::Add(const AliRunTag* tag)
217{
218 // merge two pieces
219 if (fAliceRunId==-1) { // empty
220 *this = *tag;
221 return kTRUE;
222 }
223 if (fAliceRunId != tag->fAliceRunId) {
224 AliWarning(Form("Run IDs are different: %d %d",fAliceRunId,tag->fAliceRunId));
225 return kFALSE;
226 }
227 // real merging
228 fBeamTriggers += tag->fBeamTriggers;
229 fCollisionTriggers += tag->fCollisionTriggers;
230 fEmptyTriggers += tag->fEmptyTriggers;
231 fASideTriggers += tag->fASideTriggers;
232 fCSideTriggers += tag->fCSideTriggers;
233 fHMTriggers += tag->fHMTriggers;
234 fMuonTriggers += tag->fMuonTriggers;
235 AliFileTag* eftag = 0;
236 //
237 for (int i=0;i<tag->fNumFiles;i++) {
238 AliFileTag* tftag = (AliFileTag*)tag->GetFileTag(i);
239 if (fNumFiles>0) eftag = (AliFileTag*)GetFileTag(fNumFiles-1);
240 else {
241 eftag = new AliFileTag();
242 eftag->SetMD5("");
243 eftag->SetTURL("");
244 eftag->SetSize(0);
245 AddFileTag(eftag);
246 }
247 int nev = tftag->GetNEvents();
248 for (int j=0;j<nev;j++) {
249 AliEventTag* tge = (AliEventTag*)tftag->GetEventTag(j);
250 if (tge) eftag->AddEventTag(*tge);
251 }
252 }
253
254 return kTRUE;
255}
256
4c117ffd 257//___________________________________________________________________________
258void AliRunTag::CopyStandardContent(AliRunTag *oldtag) {
259 //function that copies the run, lhc and detector levels
260 SetRunId(oldtag->GetRunId());
261 SetMagneticField(oldtag->GetMagneticField());
850d5792 262 SetDipoleField(oldtag->GetDipoleField());
4c117ffd 263 SetRunStartTime(oldtag->GetRunStartTime());
264 SetRunStopTime(oldtag->GetRunStopTime());
265 SetAlirootVersion(oldtag->GetAlirootVersion());
266 SetRootVersion(oldtag->GetRootVersion());
267 SetGeant3Version(oldtag->GetGeant3Version());
850d5792 268 SetLHCPeriod(oldtag->GetLHCPeriod());
269 SetReconstructionPass(oldtag->GetReconstructionPass());
270 SetProductionName(oldtag->GetProductionName());
04cb11d4 271 SetRunValidation(oldtag->GetRunValidation());
4c117ffd 272 SetRunQuality(oldtag->GetRunQuality());
273 SetBeamEnergy(oldtag->GetBeamEnergy());
274 SetBeamType(oldtag->GetBeamType());
275 SetCalibVersion(oldtag->GetCalibVersion());
276 SetDataType(oldtag->GetDataType());
04cb11d4 277 SetBeamTriggers(oldtag->GetBeamTriggers());
278 SetCollisionTriggers(oldtag->GetCollisionTriggers());
279 SetEmptyTriggers(oldtag->GetEmptyTriggers());
280 SetASideTriggers(oldtag->GetASideTriggers());
281 SetCSideTriggers(oldtag->GetCSideTriggers());
282 SetHMTriggers(oldtag->GetHMTriggers());
283 SetMuonTriggers(oldtag->GetMuonTriggers());
284 SetCollisionRate(oldtag->GetCollisionRate());
285 SetMeanVertex(oldtag->GetMeanVertex());
286 SetVertexQuality(oldtag->GetVertexQuality());
4c117ffd 287 SetLHCTag(oldtag->GetLHCTag()->GetLuminosity(),oldtag->GetLHCTag()->GetLHCState());
3ace8f92 288 SetDetectorTag(oldtag->GetDetectorTags()->GetIntDetectorMaskDAQ(), oldtag->GetDetectorTags()->GetIntDetectorMaskReco());
04cb11d4 289 SetActiveTriggerClasses(oldtag->GetActiveTriggerClasses());
9ee5d033 290 SetQA(*(oldtag->GetQA())) ;
291 SetQAArray(oldtag->GetQAArray(), oldtag->GetQALength()) ;
850d5792 292 SetEventSpecies(oldtag->GetEventSpecies(), oldtag->GetESLength()) ;
04cb11d4 293 for (int ifile=0; ifile<oldtag->GetNFiles(); ifile++) {
294 AliFileTag *ntag = new AliFileTag();
295 ntag->CopyFileInfo((const AliFileTag &) *(oldtag->GetFileTag(ifile)));
296 AddFileTag(ntag);
297 }
298}
299
300void AliRunTag::UpdateFromRunTable(AliRunTag *tabtag)
301{
302 SetBeamTriggers(tabtag->GetBeamTriggers());
303 SetCollisionTriggers(tabtag->GetCollisionTriggers());
304 SetEmptyTriggers(tabtag->GetEmptyTriggers());
305 SetASideTriggers(tabtag->GetASideTriggers());
306 SetCSideTriggers(tabtag->GetCSideTriggers());
307 SetHMTriggers(tabtag->GetHMTriggers());
308 SetMuonTriggers(tabtag->GetMuonTriggers());
309 SetCollisionRate(tabtag->GetCollisionRate());
310 SetMeanVertex(tabtag->GetMeanVertex());
311 SetVertexQuality(tabtag->GetVertexQuality());
312 SetRunQuality(tabtag->GetRunQuality());
313 fLHCTag.UpdateFromRunTable(*tabtag->GetLHCTag());
314 fDetectorTag.UpdateFromRunTable(*tabtag->GetDetectorTags());
4c117ffd 315}
316
27293674 317//___________________________________________________________________________
9ee5d033 318void AliRunTag::SetQAArray(ULong_t * qa, Int_t qalength) {
27293674 319 //Setter for the qa bits
e1ffd6bc 320 if (qa && qalength > 0) {
321 fQALength = qalength ;
9ee5d033 322 if (fQAArray)
323 delete [] fQAArray ;
324 fQAArray = new ULong_t[qalength] ;
325 memcpy(fQAArray, qa, qalength*sizeof(ULong_t)) ;
e1ffd6bc 326 }
27293674 327}
328
329//___________________________________________________________________________
330void AliRunTag::SetEventSpecies(Bool_t * es, Int_t eslength) {
331 //setter for the eventspecices
e1ffd6bc 332 if (es && eslength >0 ) {
333 fESLength = eslength ;
334 if (fEventSpecies)
335 delete [] fEventSpecies ;
336 fEventSpecies = new Bool_t[eslength] ;
337 memcpy(fEventSpecies, es, eslength*sizeof(Bool_t)) ;
338 }
27293674 339}
340
341
bec9a2e7 342//___________________________________________________________________________
c5caed45 343void AliRunTag::SetLHCTag(Float_t lumin, TString type) {
e16601cf 344 //Setter for the LHC tags
04cb11d4 345 fLHCTag.SetLuminosity(lumin);
346 fLHCTag.SetLHCState(type);
f3a97c86 347}
348
bec9a2e7 349//___________________________________________________________________________
3ace8f92 350void AliRunTag::SetDetectorTag(UInt_t mask, UInt_t maskReco) {
e16601cf 351 //Setter for the detector tags
3ace8f92 352 fDetectorTag.SetDetectorMaskDAQ(mask);
353 if (maskReco == 0)
354 fDetectorTag.SetDetectorMaskReco(mask);
355 else
356 fDetectorTag.SetDetectorMaskReco(maskReco);
357
358 int ndet = 0;
359 for (int iter=0; iter<32; iter++)
360 ndet += (mask & (1 << iter)) > 0;
361
362 fNumDetectors = ndet;
f3a97c86 363}
364
bec9a2e7 365//___________________________________________________________________________
366void AliRunTag::AddEventTag(const AliEventTag & EvTag) {
e16601cf 367 //Adds an entry to the event tag TClonesArray
04cb11d4 368 ((AliFileTag *) fFileTags[fNumFiles-1])->AddEventTag(EvTag);
369 // new(fEventTag[fNumEvents++]) AliEventTag(EvTag);
370}
371
372void AliRunTag::AddFileTag(AliFileTag *t) {
373 //Adds an entry for each file tag
bfc9ff63 374 if (fNumFiles == fFileTags.GetSize()-1) fFileTags.Expand(fFileTags.GetSize()*2);
04cb11d4 375 // new(fFileTags[fNumFiles++]) AliFileTag(t);
bfc9ff63 376 fFileTags[fNumFiles++] = t;
f3a97c86 377}
378
bec9a2e7 379//___________________________________________________________________________
380void AliRunTag::Clear(const char *) {
e16601cf 381 //Resets the number of events and detectors
04cb11d4 382 // fEventTag.Delete();
383 // fNumEvents = 0;
384 fFileTags.Delete();
385 fNumFiles = 0;
a9d95c96 386 if ( fQAArray ) {
387 delete [] fQAArray ;
388 fQAArray = 0x0;
389 }
b9f60f9d 390 fQALength=0;
a9d95c96 391 if ( fEventSpecies ) {
392 delete [] fEventSpecies ;
393 fEventSpecies = 0x0;
394 }
b9f60f9d 395 fESLength=0;
f3a97c86 396}
04cb11d4 397
398const AliEventTag* AliRunTag::GetEventTag(int evt) const
399{
400 int curev = evt;
401 int curf = 0;
402
403 if (evt >= GetNEvents()) return 0;
404
ee6d9bb3 405 while (curev >= ((AliFileTag *) fFileTags[curf])->GetNEvents()) {
04cb11d4 406 curev -= ((AliFileTag *) fFileTags[curf])->GetNEvents();
ee6d9bb3 407 curf++;
04cb11d4 408 }
409 return ((AliFileTag *) fFileTags[curf])->GetEventTag(curev);
410}
411
412AliFileTag *AliRunTag::GetFileTagForEvent(int evt)
413{
414 // Returns FileTag in which the given event is
415 int curev = evt;
416 int curf = 0;
417
418 if (evt >= GetNEvents()) return 0;
419
ee6d9bb3 420 while (curev >= ((AliFileTag *) fFileTags[curf])->GetNEvents()) {
04cb11d4 421 curev -= ((AliFileTag *) fFileTags[curf])->GetNEvents();
ee6d9bb3 422 curf++;
04cb11d4 423 }
424 return (AliFileTag *) fFileTags[curf];
425}
426
427Int_t AliRunTag::GetNEvents() const
428{
429 Int_t evtot = 0;
430 for (int iter=0; iter<fNumFiles; iter++)
431 evtot += ((AliFileTag *) fFileTags[iter])->GetNEvents();
432
433 return evtot;
434}
435
436Int_t AliRunTag::GetFileId(const char *guid)
437{
438 for (int iter=0; iter<fNumFiles; iter++) {
c035cce6 439 if (!strcmp(((AliFileTag *) fFileTags[iter])->GetGUID(), guid))
04cb11d4 440 return iter;
441 }
442 return -1;
443}
444