]> git.uio.no Git - u/mrichter/AliRoot.git/blame - STEER/AliRunTag.cxx
1) corrections for Coverity reports
[u/mrichter/AliRoot.git] / STEER / 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),
95fAliceRunStopTime(fAliceRunStopTime),
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),
109fNumFiles(tag.fNumFiles),
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 }
04cb11d4 144 for (int ifl=0; ifl<fNumFiles; ifl++) {
145 AddFileTag(tag.GetFileTag(ifl));
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 ;
173 fNumFiles = tag.fNumFiles;
174 fBeamTriggers = tag.fBeamTriggers;
175 fCollisionTriggers = tag.fCollisionTriggers;
176 fEmptyTriggers = tag.fEmptyTriggers;
177 fASideTriggers = tag.fASideTriggers;
178 fCSideTriggers = tag.fCSideTriggers;
179 fHMTriggers = tag.fHMTriggers;
180 fMuonTriggers = tag.fMuonTriggers;
181 fCollisionRate = tag.fCollisionRate;
182 fMeanVertex = tag.fMeanVertex;
183 fVertexQuality = tag.fVertexQuality;
27293674 184 fNumDetectors = tag.fNumDetectors ;
27293674 185 fDetectorTag = tag.fDetectorTag ;
186 fLHCTag = tag.fLHCTag ;
04cb11d4 187 fActiveTriggerClasses = tag.fActiveTriggerClasses;
9ee5d033 188 fQA = tag.fQA ;
27293674 189 fQALength = tag.fQALength ;
9ee5d033 190 if (fQAArray)
191 delete [] fQAArray ;
27293674 192 if (fQALength == 0 )
9ee5d033 193 fQAArray = NULL ;
27293674 194 else {
9ee5d033 195 fQAArray = new ULong_t[fQALength] ;
196 memcpy(fQAArray, tag.fQAArray, fQALength*sizeof(ULong_t)) ;
27293674 197 }
198 fESLength = tag.fESLength ;
199 if (fEventSpecies)
200 delete [] fEventSpecies ;
201 if (fESLength == 0 )
202 fEventSpecies = NULL ;
203 else {
e1ffd6bc 204 fEventSpecies = new Bool_t[fESLength] ;
27293674 205 memcpy(fEventSpecies, tag.fEventSpecies, fESLength*sizeof(Bool_t)) ;
206 }
04cb11d4 207 for (int ifl=0; ifl<fNumFiles; ifl++) {
208 AddFileTag(tag.GetFileTag(ifl));
209 }
210// for (int ifile=0; ifile<tag.GetFileTags()->GetEntries(); ifile++)
211// AddFileTag(*((AliFileTag *) tag.GetFileTags()->At(ifile)));
27293674 212 }
213 return *this ;
f3a97c86 214}
215
4c117ffd 216//___________________________________________________________________________
217void AliRunTag::CopyStandardContent(AliRunTag *oldtag) {
218 //function that copies the run, lhc and detector levels
219 SetRunId(oldtag->GetRunId());
220 SetMagneticField(oldtag->GetMagneticField());
850d5792 221 SetDipoleField(oldtag->GetDipoleField());
4c117ffd 222 SetRunStartTime(oldtag->GetRunStartTime());
223 SetRunStopTime(oldtag->GetRunStopTime());
224 SetAlirootVersion(oldtag->GetAlirootVersion());
225 SetRootVersion(oldtag->GetRootVersion());
226 SetGeant3Version(oldtag->GetGeant3Version());
850d5792 227 SetLHCPeriod(oldtag->GetLHCPeriod());
228 SetReconstructionPass(oldtag->GetReconstructionPass());
229 SetProductionName(oldtag->GetProductionName());
04cb11d4 230 SetRunValidation(oldtag->GetRunValidation());
4c117ffd 231 SetRunQuality(oldtag->GetRunQuality());
232 SetBeamEnergy(oldtag->GetBeamEnergy());
233 SetBeamType(oldtag->GetBeamType());
234 SetCalibVersion(oldtag->GetCalibVersion());
235 SetDataType(oldtag->GetDataType());
04cb11d4 236 SetBeamTriggers(oldtag->GetBeamTriggers());
237 SetCollisionTriggers(oldtag->GetCollisionTriggers());
238 SetEmptyTriggers(oldtag->GetEmptyTriggers());
239 SetASideTriggers(oldtag->GetASideTriggers());
240 SetCSideTriggers(oldtag->GetCSideTriggers());
241 SetHMTriggers(oldtag->GetHMTriggers());
242 SetMuonTriggers(oldtag->GetMuonTriggers());
243 SetCollisionRate(oldtag->GetCollisionRate());
244 SetMeanVertex(oldtag->GetMeanVertex());
245 SetVertexQuality(oldtag->GetVertexQuality());
4c117ffd 246 SetLHCTag(oldtag->GetLHCTag()->GetLuminosity(),oldtag->GetLHCTag()->GetLHCState());
3ace8f92 247 SetDetectorTag(oldtag->GetDetectorTags()->GetIntDetectorMaskDAQ(), oldtag->GetDetectorTags()->GetIntDetectorMaskReco());
04cb11d4 248 SetActiveTriggerClasses(oldtag->GetActiveTriggerClasses());
9ee5d033 249 SetQA(*(oldtag->GetQA())) ;
250 SetQAArray(oldtag->GetQAArray(), oldtag->GetQALength()) ;
850d5792 251 SetEventSpecies(oldtag->GetEventSpecies(), oldtag->GetESLength()) ;
04cb11d4 252 for (int ifile=0; ifile<oldtag->GetNFiles(); ifile++) {
253 AliFileTag *ntag = new AliFileTag();
254 ntag->CopyFileInfo((const AliFileTag &) *(oldtag->GetFileTag(ifile)));
255 AddFileTag(ntag);
256 }
257}
258
259void AliRunTag::UpdateFromRunTable(AliRunTag *tabtag)
260{
261 SetBeamTriggers(tabtag->GetBeamTriggers());
262 SetCollisionTriggers(tabtag->GetCollisionTriggers());
263 SetEmptyTriggers(tabtag->GetEmptyTriggers());
264 SetASideTriggers(tabtag->GetASideTriggers());
265 SetCSideTriggers(tabtag->GetCSideTriggers());
266 SetHMTriggers(tabtag->GetHMTriggers());
267 SetMuonTriggers(tabtag->GetMuonTriggers());
268 SetCollisionRate(tabtag->GetCollisionRate());
269 SetMeanVertex(tabtag->GetMeanVertex());
270 SetVertexQuality(tabtag->GetVertexQuality());
271 SetRunQuality(tabtag->GetRunQuality());
272 fLHCTag.UpdateFromRunTable(*tabtag->GetLHCTag());
273 fDetectorTag.UpdateFromRunTable(*tabtag->GetDetectorTags());
4c117ffd 274}
275
27293674 276//___________________________________________________________________________
9ee5d033 277void AliRunTag::SetQAArray(ULong_t * qa, Int_t qalength) {
27293674 278 //Setter for the qa bits
e1ffd6bc 279 if (qa && qalength > 0) {
280 fQALength = qalength ;
9ee5d033 281 if (fQAArray)
282 delete [] fQAArray ;
283 fQAArray = new ULong_t[qalength] ;
284 memcpy(fQAArray, qa, qalength*sizeof(ULong_t)) ;
e1ffd6bc 285 }
27293674 286}
287
288//___________________________________________________________________________
289void AliRunTag::SetEventSpecies(Bool_t * es, Int_t eslength) {
290 //setter for the eventspecices
e1ffd6bc 291 if (es && eslength >0 ) {
292 fESLength = eslength ;
293 if (fEventSpecies)
294 delete [] fEventSpecies ;
295 fEventSpecies = new Bool_t[eslength] ;
296 memcpy(fEventSpecies, es, eslength*sizeof(Bool_t)) ;
297 }
27293674 298}
299
300
bec9a2e7 301//___________________________________________________________________________
c5caed45 302void AliRunTag::SetLHCTag(Float_t lumin, TString type) {
e16601cf 303 //Setter for the LHC tags
04cb11d4 304 fLHCTag.SetLuminosity(lumin);
305 fLHCTag.SetLHCState(type);
f3a97c86 306}
307
bec9a2e7 308//___________________________________________________________________________
3ace8f92 309void AliRunTag::SetDetectorTag(UInt_t mask, UInt_t maskReco) {
e16601cf 310 //Setter for the detector tags
3ace8f92 311 fDetectorTag.SetDetectorMaskDAQ(mask);
312 if (maskReco == 0)
313 fDetectorTag.SetDetectorMaskReco(mask);
314 else
315 fDetectorTag.SetDetectorMaskReco(maskReco);
316
317 int ndet = 0;
318 for (int iter=0; iter<32; iter++)
319 ndet += (mask & (1 << iter)) > 0;
320
321 fNumDetectors = ndet;
f3a97c86 322}
323
bec9a2e7 324//___________________________________________________________________________
325void AliRunTag::AddEventTag(const AliEventTag & EvTag) {
e16601cf 326 //Adds an entry to the event tag TClonesArray
04cb11d4 327 ((AliFileTag *) fFileTags[fNumFiles-1])->AddEventTag(EvTag);
328 // new(fEventTag[fNumEvents++]) AliEventTag(EvTag);
329}
330
331void AliRunTag::AddFileTag(AliFileTag *t) {
332 //Adds an entry for each file tag
333 // new(fFileTags[fNumFiles++]) AliFileTag(t);
334 fFileTags[fNumFiles++] = t;
f3a97c86 335}
336
bec9a2e7 337//___________________________________________________________________________
338void AliRunTag::Clear(const char *) {
e16601cf 339 //Resets the number of events and detectors
04cb11d4 340 // fEventTag.Delete();
341 // fNumEvents = 0;
342 fFileTags.Delete();
343 fNumFiles = 0;
a9d95c96 344 if ( fQAArray ) {
345 delete [] fQAArray ;
346 fQAArray = 0x0;
347 }
b9f60f9d 348 fQALength=0;
a9d95c96 349 if ( fEventSpecies ) {
350 delete [] fEventSpecies ;
351 fEventSpecies = 0x0;
352 }
b9f60f9d 353 fESLength=0;
f3a97c86 354}
04cb11d4 355
356const AliEventTag* AliRunTag::GetEventTag(int evt) const
357{
358 int curev = evt;
359 int curf = 0;
360
361 if (evt >= GetNEvents()) return 0;
362
363 while (curev > ((AliFileTag *) fFileTags[curf])->GetNEvents()) {
364 curf++;
365 curev -= ((AliFileTag *) fFileTags[curf])->GetNEvents();
366 }
367 return ((AliFileTag *) fFileTags[curf])->GetEventTag(curev);
368}
369
370AliFileTag *AliRunTag::GetFileTagForEvent(int evt)
371{
372 // Returns FileTag in which the given event is
373 int curev = evt;
374 int curf = 0;
375
376 if (evt >= GetNEvents()) return 0;
377
378 while (curev > ((AliFileTag *) fFileTags[curf])->GetNEvents()) {
379 curf++;
380 curev -= ((AliFileTag *) fFileTags[curf])->GetNEvents();
381 }
382 return (AliFileTag *) fFileTags[curf];
383}
384
385Int_t AliRunTag::GetNEvents() const
386{
387 Int_t evtot = 0;
388 for (int iter=0; iter<fNumFiles; iter++)
389 evtot += ((AliFileTag *) fFileTags[iter])->GetNEvents();
390
391 return evtot;
392}
393
394Int_t AliRunTag::GetFileId(const char *guid)
395{
396 for (int iter=0; iter<fNumFiles; iter++) {
397 if (strcmp(((AliFileTag *) fFileTags[iter])->GetGUID(), guid))
398 return iter;
399 }
400 return -1;
401}
402