1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
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 //-----------------------------------------------------------------
25 #include "AliRunTag.h"
26 #include "AliDetectorTag.h"
27 #include "AliEventTag.h"
31 //___________________________________________________________________________
32 AliRunTag::AliRunTag() :
35 fAliceMagneticField(0.0),
36 fAliceDipoleField(0.0),
37 fAliceRunStartTime(0),
45 fAliceRunValidated(0),
46 fAliceRunGlobalQuality(0),
47 fAliceBeamEnergy(0.0),
49 fAliceCalibrationVersion(0),
54 fCollisionTriggers(0),
67 fActiveTriggerClasses(""),
77 //___________________________________________________________________________
78 AliRunTag::~AliRunTag() {
80 // fEventTag.Delete();
84 delete [] fEventSpecies ;
88 //___________________________________________________________________________
89 AliRunTag::AliRunTag(const AliRunTag& tag):
91 fAliceRunId(tag.fAliceRunId),
92 fAliceMagneticField(tag.fAliceMagneticField),
93 fAliceDipoleField(tag.fAliceDipoleField),
94 fAliceRunStartTime(tag.fAliceRunStartTime),
95 fAliceRunStopTime(tag.fAliceRunStopTime),
96 fAlirootVersion(tag.fAlirootVersion),
97 fRootVersion(tag.fRootVersion),
98 fGeant3Version(tag.fGeant3Version),
99 fLHCPeriod(tag.fLHCPeriod),
100 fRecPass(tag.fRecPass),
101 fProductionName(tag.fProductionName),
102 fAliceRunValidated(tag.fAliceRunValidated),
103 fAliceRunGlobalQuality(tag.fAliceRunGlobalQuality),
104 fAliceBeamEnergy(tag.fAliceBeamEnergy),
105 fAliceBeamType(tag.fAliceBeamType),
106 fAliceCalibrationVersion(tag.fAliceCalibrationVersion),
107 fAliceDataType(tag.fAliceDataType),
108 //fNumEvents(tag.fNumEvents),
110 fBeamTriggers(tag.fBeamTriggers),
111 fCollisionTriggers(tag.fCollisionTriggers),
112 fEmptyTriggers(tag.fEmptyTriggers),
113 fASideTriggers(tag.fASideTriggers),
114 fCSideTriggers(tag.fCSideTriggers),
115 fHMTriggers(tag.fHMTriggers),
116 fMuonTriggers(tag.fMuonTriggers),
117 fCollisionRate(tag.fCollisionRate),
118 fMeanVertex(tag.fMeanVertex),
119 fVertexQuality(tag.fVertexQuality),
120 fNumDetectors(tag.fNumDetectors),
122 fDetectorTag(tag.fDetectorTag),
123 fLHCTag(tag.fLHCTag),
124 fActiveTriggerClasses(tag.fActiveTriggerClasses),
126 fQALength(tag.fQALength),
128 fESLength(tag.fESLength),
135 fQAArray = new ULong_t[fQALength] ;
136 memcpy(fQAArray, tag.fQAArray, fQALength*sizeof(ULong_t)) ;
139 fEventSpecies = NULL ;
141 fEventSpecies = new Bool_t[fESLength] ;
142 memcpy(fEventSpecies, tag.fEventSpecies, fESLength*sizeof(Bool_t)) ;
144 for (int ifl=0; ifl<tag.fNumFiles; ifl++) {
145 AddFileTag(new AliFileTag(*tag.GetFileTag(ifl)));
151 //___________________________________________________________________________
152 AliRunTag& AliRunTag::operator = (const AliRunTag& tag) {
153 //assignment operator
155 fAliceRunId = tag.fAliceRunId ;
156 fAliceMagneticField = tag.fAliceMagneticField ;
157 fAliceDipoleField = tag.fAliceDipoleField ;
158 fAliceRunStartTime = tag.fAliceRunStartTime ;
159 fAliceRunStopTime = tag.fAliceRunStopTime ;
160 fAlirootVersion = tag.fAlirootVersion ;
161 fRootVersion = tag.fRootVersion ;
162 fGeant3Version = tag.fGeant3Version ;
163 fLHCPeriod = tag.fLHCPeriod ;
164 fRecPass = tag.fRecPass ;
165 fProductionName = tag.fProductionName ;
166 fAliceRunValidated = tag.fAliceRunValidated ;
167 fAliceRunGlobalQuality = tag.fAliceRunGlobalQuality ;
168 fAliceBeamEnergy = tag.fAliceBeamEnergy ;
169 fAliceBeamType = tag.fAliceBeamType ;
170 fAliceCalibrationVersion = tag.fAliceCalibrationVersion ;
171 fAliceDataType = tag.fAliceDataType ;
172 // fNumEvents = tag.fNumEvents ;
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;
183 fNumDetectors = tag.fNumDetectors ;
184 fDetectorTag = tag.fDetectorTag ;
185 fLHCTag = tag.fLHCTag ;
186 fActiveTriggerClasses = tag.fActiveTriggerClasses;
188 fQALength = tag.fQALength ;
194 fQAArray = new ULong_t[fQALength] ;
195 memcpy(fQAArray, tag.fQAArray, fQALength*sizeof(ULong_t)) ;
197 fESLength = tag.fESLength ;
199 delete [] fEventSpecies ;
201 fEventSpecies = NULL ;
203 fEventSpecies = new Bool_t[fESLength] ;
204 memcpy(fEventSpecies, tag.fEventSpecies, fESLength*sizeof(Bool_t)) ;
206 for (int ifl=0; ifl<tag.fNumFiles; ifl++) {
207 AddFileTag(new AliFileTag(*tag.GetFileTag(ifl)));
209 // for (int ifile=0; ifile<tag.GetFileTags()->GetEntries(); ifile++)
210 // AddFileTag(*((AliFileTag *) tag.GetFileTags()->At(ifile)));
215 //___________________________________________________________________________
216 Bool_t AliRunTag::Add(const AliRunTag* tag)
219 if (fAliceRunId==-1) { // empty
223 if (fAliceRunId != tag->fAliceRunId) {
224 AliWarning(Form("Run IDs are different: %d %d",fAliceRunId,tag->fAliceRunId));
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;
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);
241 eftag = new AliFileTag();
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);
257 //___________________________________________________________________________
258 void AliRunTag::CopyStandardContent(AliRunTag *oldtag) {
259 //function that copies the run, lhc and detector levels
260 SetRunId(oldtag->GetRunId());
261 SetMagneticField(oldtag->GetMagneticField());
262 SetDipoleField(oldtag->GetDipoleField());
263 SetRunStartTime(oldtag->GetRunStartTime());
264 SetRunStopTime(oldtag->GetRunStopTime());
265 SetAlirootVersion(oldtag->GetAlirootVersion());
266 SetRootVersion(oldtag->GetRootVersion());
267 SetGeant3Version(oldtag->GetGeant3Version());
268 SetLHCPeriod(oldtag->GetLHCPeriod());
269 SetReconstructionPass(oldtag->GetReconstructionPass());
270 SetProductionName(oldtag->GetProductionName());
271 SetRunValidation(oldtag->GetRunValidation());
272 SetRunQuality(oldtag->GetRunQuality());
273 SetBeamEnergy(oldtag->GetBeamEnergy());
274 SetBeamType(oldtag->GetBeamType());
275 SetCalibVersion(oldtag->GetCalibVersion());
276 SetDataType(oldtag->GetDataType());
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());
287 SetLHCTag(oldtag->GetLHCTag()->GetLuminosity(),oldtag->GetLHCTag()->GetLHCState());
288 SetDetectorTag(oldtag->GetDetectorTags()->GetIntDetectorMaskDAQ(), oldtag->GetDetectorTags()->GetIntDetectorMaskReco());
289 SetActiveTriggerClasses(oldtag->GetActiveTriggerClasses());
290 SetQA(*(oldtag->GetQA())) ;
291 SetQAArray(oldtag->GetQAArray(), oldtag->GetQALength()) ;
292 SetEventSpecies(oldtag->GetEventSpecies(), oldtag->GetESLength()) ;
293 for (int ifile=0; ifile<oldtag->GetNFiles(); ifile++) {
294 AliFileTag *ntag = new AliFileTag();
295 ntag->CopyFileInfo((const AliFileTag &) *(oldtag->GetFileTag(ifile)));
300 void AliRunTag::UpdateFromRunTable(AliRunTag *tabtag)
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());
317 //___________________________________________________________________________
318 void AliRunTag::SetQAArray(ULong_t * qa, Int_t qalength) {
319 //Setter for the qa bits
320 if (qa && qalength > 0) {
321 fQALength = qalength ;
324 fQAArray = new ULong_t[qalength] ;
325 memcpy(fQAArray, qa, qalength*sizeof(ULong_t)) ;
329 //___________________________________________________________________________
330 void AliRunTag::SetEventSpecies(Bool_t * es, Int_t eslength) {
331 //setter for the eventspecices
332 if (es && eslength >0 ) {
333 fESLength = eslength ;
335 delete [] fEventSpecies ;
336 fEventSpecies = new Bool_t[eslength] ;
337 memcpy(fEventSpecies, es, eslength*sizeof(Bool_t)) ;
342 //___________________________________________________________________________
343 void AliRunTag::SetLHCTag(Float_t lumin, TString type) {
344 //Setter for the LHC tags
345 fLHCTag.SetLuminosity(lumin);
346 fLHCTag.SetLHCState(type);
349 //___________________________________________________________________________
350 void AliRunTag::SetDetectorTag(UInt_t mask, UInt_t maskReco) {
351 //Setter for the detector tags
352 fDetectorTag.SetDetectorMaskDAQ(mask);
354 fDetectorTag.SetDetectorMaskReco(mask);
356 fDetectorTag.SetDetectorMaskReco(maskReco);
359 for (int iter=0; iter<32; iter++)
360 ndet += (mask & (1 << iter)) > 0;
362 fNumDetectors = ndet;
365 //___________________________________________________________________________
366 void AliRunTag::AddEventTag(const AliEventTag & EvTag) {
367 //Adds an entry to the event tag TClonesArray
368 ((AliFileTag *) fFileTags[fNumFiles-1])->AddEventTag(EvTag);
369 // new(fEventTag[fNumEvents++]) AliEventTag(EvTag);
372 void AliRunTag::AddFileTag(AliFileTag *t) {
373 //Adds an entry for each file tag
374 if (fNumFiles == fFileTags.GetSize()-1) fFileTags.Expand(fFileTags.GetSize()*2);
375 // new(fFileTags[fNumFiles++]) AliFileTag(t);
376 fFileTags[fNumFiles++] = t;
379 //___________________________________________________________________________
380 void AliRunTag::Clear(const char *) {
381 //Resets the number of events and detectors
382 // fEventTag.Delete();
391 if ( fEventSpecies ) {
392 delete [] fEventSpecies ;
398 const AliEventTag* AliRunTag::GetEventTag(int evt) const
403 if (evt >= GetNEvents()) return 0;
405 while (curev >= ((AliFileTag *) fFileTags[curf])->GetNEvents()) {
406 curev -= ((AliFileTag *) fFileTags[curf])->GetNEvents();
409 return ((AliFileTag *) fFileTags[curf])->GetEventTag(curev);
412 AliFileTag *AliRunTag::GetFileTagForEvent(int evt)
414 // Returns FileTag in which the given event is
418 if (evt >= GetNEvents()) return 0;
420 while (curev >= ((AliFileTag *) fFileTags[curf])->GetNEvents()) {
421 curev -= ((AliFileTag *) fFileTags[curf])->GetNEvents();
424 return (AliFileTag *) fFileTags[curf];
427 Int_t AliRunTag::GetNEvents() const
430 for (int iter=0; iter<fNumFiles; iter++)
431 evtot += ((AliFileTag *) fFileTags[iter])->GetNEvents();
436 Int_t AliRunTag::GetFileId(const char *guid)
438 for (int iter=0; iter<fNumFiles; iter++) {
439 if (!strcmp(((AliFileTag *) fFileTags[iter])->GetGUID(), guid))