LCOV - code coverage report
Current view: top level - STEER/STEERBase - AliProdInfo.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 1 150 0.7 %
Date: 2016-06-14 17:26:59 Functions: 1 13 7.7 %

          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             : 
      17             : //-----------------------------------------------------------------
      18             : //        Base class for parsing alirootVersion                  //
      19             : //        TNamed object stored in ESD/AOD data                   //
      20             : //        and setup easy getters for end user                    //
      21             : //                                                               //
      22             : //                                                               //
      23             : //   Origin: Pietro Antonioli, INFN-BO Pietro.Antonioli@cern.ch  //
      24             : //                                                               //
      25             : //-----------------------------------------------------------------
      26             : 
      27             : #include <AliLog.h>
      28             : #include "AliProdInfo.h"
      29             : 
      30         176 : ClassImp(AliProdInfo);
      31             : 
      32           0 : AliProdInfo::AliProdInfo()
      33           0 :   :fMcFlag(kFALSE)
      34           0 :   ,fAlirootSvnVersion(0)
      35           0 :   ,fRootSvnVersion(0)
      36           0 :   ,fRecoPass(-1)
      37           0 :   ,fPeriod("")
      38           0 :   ,fProductionTag("")
      39           0 :   ,fAlirootVersion("")
      40           0 :   ,fRootVersion("")
      41           0 : {       
      42             :   //
      43             :   // default constructor
      44             :   //    
      45           0 :   AliLog::SetClassDebugLevel("AliProdInfo",10);
      46           0 :   for (Int_t itag=0; itag<Int_t(kNTags); ++itag) fTags[itag]="";
      47           0 : }
      48             : 
      49           0 : AliProdInfo::AliProdInfo(const TString& name,const TString& title)
      50           0 :   :TNamed(name,title)
      51           0 :   ,fMcFlag(kFALSE)
      52           0 :   ,fAlirootSvnVersion(0)
      53           0 :   ,fRootSvnVersion(0)
      54           0 :   ,fRecoPass(-1)
      55           0 :   ,fPeriod("")
      56           0 :   ,fProductionTag("")
      57           0 :   ,fAlirootVersion("")
      58           0 :   ,fRootVersion("")
      59           0 : {       
      60             :   //
      61             :   // default constructor
      62             :   //    
      63           0 :   AliLog::SetClassDebugLevel("AliProdInfo",10);
      64           0 :   for (Int_t itag=0; itag<Int_t(kNTags); ++itag) fTags[itag]="";
      65           0 : }
      66             : 
      67           0 : AliProdInfo::AliProdInfo(TList *userInfoList)
      68           0 :   :fMcFlag(kFALSE)
      69           0 :   ,fAlirootSvnVersion(0)
      70           0 :   ,fRootSvnVersion(0)
      71           0 :   ,fRecoPass(-1)
      72           0 :   ,fPeriod("")
      73           0 :   ,fProductionTag("")
      74           0 :   ,fAlirootVersion("")
      75           0 :   ,fRootVersion("")
      76           0 : {       
      77             :   //
      78             :   // default constructor & init
      79             :   //    
      80           0 :   AliLog::SetClassDebugLevel("AliProdInfo",10);
      81           0 :   for (Int_t itag=0; itag<Int_t(kNTags); ++itag) fTags[itag]="";
      82           0 :   Init(userInfoList);
      83           0 : }
      84             : 
      85             : //-------------------------------------------------------------------------------------------------     
      86           0 : AliProdInfo::~AliProdInfo() {
      87             : 
      88           0 : }
      89             : 
      90             : //-------------------------------------------------------------------------------------------------     
      91             : void AliProdInfo::Init(TList *userInfoList) 
      92             : {
      93           0 :   fPeriod="";
      94           0 :   fAlirootVersion="";
      95           0 :   fAlirootSvnVersion=0;
      96           0 :   fRootVersion="";
      97           0 :   fRootSvnVersion=0;
      98           0 :   fMcFlag=kFALSE;
      99           0 :   fRecoPass=-1;
     100           0 :   for (Int_t itag=0; itag<Int_t(kNTags); ++itag) fTags[itag]="";
     101           0 :   TNamed *prodInfo = (TNamed *)userInfoList->FindObject("alirootVersion");
     102           0 :   if (!prodInfo) {
     103           0 :     AliError("No alirootVersion named object found in user info");
     104           0 :     return;
     105             :   }
     106           0 :   ParseProdInfo(prodInfo);
     107           0 :  }
     108             : 
     109             : //-------------------------------------------------------------------------------------------------     
     110             : void AliProdInfo::ParseProdInfo(TNamed *prodInfoData) 
     111             : {
     112             :   // parse information
     113           0 :   const char* key[] = {
     114             :     "aliroot"
     115             :     ,"root"
     116             :     ,"OutputDir="
     117             :     ,"LPMRawPass="
     118             :     ,"LPMProductionType="
     119             :     ,"LPMProductionTag="
     120             :     ,"LPMAnchorProduction="
     121             :   };
     122             : 
     123           0 :   TString tmpStr="";
     124             :   //
     125           0 :   TString str(prodInfoData->GetTitle());
     126           0 :   TObjArray *tokens = str.Tokenize(";");  
     127             :   //
     128           0 :   for (Int_t i=0;i<=tokens->GetLast();i++) {
     129           0 :     TObjString *stObj = (TObjString *)tokens->At(i);
     130           0 :     tmpStr = stObj->GetString().Strip(TString::kBoth,' '); // strip irrelevant spaces
     131             :     //
     132           0 :     for (Int_t itag=0; itag<Int_t(kNTags); ++itag) {
     133           0 :       if (tmpStr.BeginsWith( key[itag] )) {
     134           0 :         fTags[itag] = tmpStr.ReplaceAll( key[itag] ,"").Strip(TString::kBoth,' ');
     135           0 :         break;
     136             :       }
     137             :     }
     138             :   }
     139           0 :   delete tokens;
     140             :   // now interpret ...
     141             :   //
     142             :   // extract ALIROOT version
     143           0 :   if (!fTags[kAliroot].IsNull()) {
     144           0 :     TObjArray *tali = (TObjArray *)fTags[kAliroot].Tokenize(":");
     145           0 :     TObjString *tos = (TObjString *)tali->At(0);
     146           0 :     fAlirootVersion = "";
     147           0 :     if (tos) {
     148           0 :       fAlirootVersion = tos->GetString().Strip(TString::kBoth,' ');
     149           0 :       if (fAlirootVersion.IsNull()) AliWarning("Cannot extract AliROOT version string. Might be git related.");
     150             :     }
     151             :     //
     152           0 :     tos = (TObjString*)tali->At(1);
     153           0 :     if (tos){
     154           0 :       tmpStr = tos->GetString().Strip(TString::kBoth,' ');
     155           0 :       if (tmpStr.IsDigit()){
     156           0 :         fAlirootSvnVersion = tmpStr.Atoi();
     157           0 :       } 
     158           0 :       else if (tmpStr.IsHex()) {
     159           0 :         if (tmpStr.Length()>6) tmpStr.Resize(6);
     160           0 :         sscanf(tmpStr.Data(),"%x",&fAlirootSvnVersion);
     161           0 :         AliWarningF("ALIROOT SVN version number not decimal, might be on git. Reading as hex %s -> %d",tmpStr.Data(),fAlirootSvnVersion);
     162           0 :       }
     163             :       else {
     164           0 :         fAlirootSvnVersion=65263;
     165           0 :         AliWarningF("AliRoot SVN version is not extracted, setting to %d",fAlirootSvnVersion);
     166             :       }
     167             :     }
     168           0 :     delete tali;
     169           0 :   }
     170           0 :   else AliWarningF("Failed to extract %s version information",key[kAliroot]);
     171             :   //
     172             :   // extract ROOT version
     173           0 :   if (!fTags[kRoot].IsNull()) {
     174           0 :     TObjArray *tali = fTags[kRoot].Tokenize(":");
     175           0 :     TObjString *tos = (TObjString *)tali->At(0);
     176           0 :     fRootVersion = "";
     177           0 :     if (tos) {
     178           0 :       fRootVersion = tos->GetString().Strip(TString::kBoth,' ');
     179           0 :       if (fRootVersion.IsNull()) AliWarning("Cannot extract ROOT version string. Might be git related.");
     180             :     }
     181             :     //
     182           0 :     tos = (TObjString*)tali->At(1);
     183           0 :     if (tos){
     184           0 :       tmpStr = tos->GetString().Strip(TString::kBoth,' ');
     185           0 :       if (tmpStr.IsDigit()){
     186           0 :         fRootSvnVersion = tmpStr.Atoi();
     187           0 :       } 
     188           0 :       else if (tmpStr.IsHex()) {
     189           0 :         if (tmpStr.Length()>6) tmpStr.Resize(6);
     190           0 :         sscanf(tmpStr.Data(),"%x",&fRootSvnVersion);
     191           0 :         AliWarningF("ROOT SVN version number not decimal, might be on git. Reading as hex %s -> %d",
     192             :                     tmpStr.Data(),fRootSvnVersion);
     193           0 :       }
     194             :       else {
     195           0 :         fRootSvnVersion=0;
     196           0 :         AliWarningF("ROOT SVN version is not extracted, setting to %d",fRootSvnVersion);
     197             :       }
     198             :     }
     199           0 :     delete tali;
     200           0 :   }
     201           0 :   else AliWarningF("Failed to extract %s version information",key[kRoot]);
     202             :   //
     203             :   // extract PASS
     204           0 :   if (!fTags[kPass].IsNull() && fTags[kPass].IsDigit()) fRecoPass = fTags[kPass].Atoi();
     205             :   else {
     206           0 :     AliWarningF("No %s record found, attempting to extract pass from OutputDir",key[kPass]);
     207           0 :     tmpStr = "/pass";
     208           0 :     if (fTags[kOutDir].IsNull() || !fTags[kOutDir].Contains(tmpStr)
     209           0 :         || !sscanf(fTags[kOutDir].Data()+fTags[kOutDir].Index(tmpStr)+tmpStr.Length(),"%d",&fRecoPass))
     210           0 :       AliWarningF("Failed to extract pass number, set to %d",fRecoPass);
     211             :   }
     212             :   //
     213             :   // extract production type (RAW/MC)
     214           0 :   if (!fTags[kProdType].IsNull()) fMcFlag = (fTags[kProdType]=="MC") ? kTRUE:kFALSE;
     215             :   else {
     216           0 :     AliWarningF("No %s record found, attempting to extract production type from OutputDir",key[kProdType]);
     217           0 :     if (fTags[kOutDir].Contains("/alice/sim")) fMcFlag = kTRUE;
     218             :   }
     219             :   //
     220             :   // extract production tag
     221           0 :   if (!fTags[kProdTag].IsNull()) fProductionTag = fTags[kProdTag];
     222             :   else {
     223           0 :     AliWarningF("No %s record found, attempting to extract production tag from OutputDir",key[kProdTag]);
     224           0 :     tmpStr = "/LHC";
     225           0 :     if (!fTags[kOutDir].IsNull() && fTags[kOutDir].Contains(tmpStr)) {
     226           0 :       fProductionTag = fTags[kOutDir].Data()+fTags[kOutDir].Index(tmpStr)+1;
     227           0 :       if (fProductionTag.Contains("/")) fProductionTag.Resize(tmpStr.Index("/"));
     228             :     }
     229             :   }
     230             :   //
     231             :   // extract (anchored) period
     232           0 :   if (!fTags[kPeriod].IsNull()) fPeriod = fTags[kPeriod];
     233             :   else {
     234           0 :     AliWarningF("No %s record found, for raw data production tag %s will be assigned",key[kPeriod],fProductionTag.Data());
     235           0 :     if (!fMcFlag) fPeriod = fProductionTag;
     236             :   }
     237             :   //
     238           0 :   SetParsed(kTRUE);
     239           0 : }
     240             : 
     241             : //-------------------------------------------------------------------------------------------------     
     242             : void AliProdInfo::List() const {
     243             : 
     244           0 :   if (IsParsed()) {
     245           0 :     AliInfo("ALICE Production Info found in UserInfo: ");
     246           0 :     AliInfo(Form("  ALIROOT Version: %s [SVN #: %d]",fAlirootVersion.Data(),fAlirootSvnVersion));
     247           0 :     AliInfo(Form("  ROOT Version: %s [SVN #: %d]",fRootVersion.Data(),fRootSvnVersion));
     248           0 :     AliInfo(Form("  Reconstruction Pass: %d",fRecoPass));
     249           0 :     AliInfo(Form("  LHC Period: %s",fPeriod.Data()));
     250           0 :     AliInfo(Form("  ProductionTag: %s",fProductionTag.Data()));
     251           0 :     AliInfo(Form("  MC Flag: %d",fMcFlag));
     252           0 :     AliInfo("  - Buffered production tags:");
     253           0 :     for (Int_t itag=0; itag<Int_t(kNTags); ++itag) {
     254           0 :       AliInfo(Form("    %s",fTags[itag].Data()));
     255             :     }
     256           0 :   } else {
     257           0 :     AliInfo("ALICE Production Info not available in UserInfo");
     258             :   }
     259           0 : }

Generated by: LCOV version 1.11