LCOV - code coverage report
Current view: top level - STEER/STEERBase - AliRunTag.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 140 295 47.5 %
Date: 2016-06-14 17:26:59 Functions: 17 23 73.9 %

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

Generated by: LCOV version 1.11