]> git.uio.no Git - u/mrichter/AliRoot.git/blob - STEER/STEERBase/AliProdInfo.cxx
New generator to perform a dedicated simulation
[u/mrichter/AliRoot.git] / STEER / STEERBase / AliProdInfo.cxx
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 ClassImp(AliProdInfo);
31
32 AliProdInfo::AliProdInfo():
33   fPeriod(""),
34   fAlirootVersion(""),
35   fAlirootSvnVersion(0),
36   fRootVersion(""),
37   fRootSvnVersion(0),
38   fMcFlag(kFALSE),
39   fRecoPass(-1)
40 {       
41   //
42   // default constructor
43   //    
44   AliLog::SetClassDebugLevel("AliProdInfo",10);
45 }
46
47 AliProdInfo::AliProdInfo(const TString& name,const TString& title):
48   TNamed(name,title),
49   fPeriod(""),
50   fAlirootVersion(""),
51   fAlirootSvnVersion(0),
52   fRootVersion(""),
53   fRootSvnVersion(0),
54   fMcFlag(kFALSE),
55   fRecoPass(-1)
56 {       
57   //
58   // default constructor
59   //    
60   AliLog::SetClassDebugLevel("AliProdInfo",10);
61 }
62
63 AliProdInfo::AliProdInfo(TList *userInfoList):
64   fPeriod(""),
65   fAlirootVersion(""),
66   fAlirootSvnVersion(0),
67   fRootVersion(""),
68   fRootSvnVersion(0),
69   fMcFlag(kFALSE),
70   fRecoPass(-1)
71 {       
72   //
73   // default constructor & init
74   //    
75   AliLog::SetClassDebugLevel("AliProdInfo",10);
76   Init(userInfoList);
77 }
78
79 //-------------------------------------------------------------------------------------------------     
80 AliProdInfo::~AliProdInfo() {
81
82 }
83
84 //-------------------------------------------------------------------------------------------------     
85 void AliProdInfo::Init(TList *userInfoList) {
86   fPeriod="";
87   fAlirootVersion="";
88   fAlirootSvnVersion=0;
89   fRootVersion="";
90   fRootSvnVersion=0;
91   fMcFlag=kFALSE;
92   fRecoPass=-1;
93   TNamed *prodInfo = (TNamed *)userInfoList->FindObject("alirootVersion");
94   if (!prodInfo) {
95     AliError("No alirootVersion named object found in user info");
96     return;
97   }
98   ParseProdInfo(prodInfo);
99  }
100
101 //-------------------------------------------------------------------------------------------------     
102 void AliProdInfo::ParseProdInfo(TNamed *prodInfoData) {
103
104   TString str(prodInfoData->GetTitle());
105   TObjArray *tokens = str.Tokenize(";");
106
107   for (Int_t i=0;i<=tokens->GetLast();i++) {
108     TObjString *stObj = (TObjString *)tokens->At(i);
109     
110     if (stObj->GetString().Contains("aliroot") && (i==0) ) {  // aliroot version
111       TObjArray *tali = (TObjArray *)stObj->GetString().Tokenize(":");
112       TObjString *tos = (TObjString *)tali->At(0);
113       TObjArray *tali2 = (TObjArray *)tos->GetString().Tokenize(" ");
114       TObjString *av = (TObjString *)tali2->At(1);
115       fAlirootVersion=av->GetString().Data();
116       TObjString *ts = (TObjString*)tali->At(1); 
117       fAlirootSvnVersion = ts->GetString().Atoi();
118       delete tali;
119       delete tali2;
120     }
121     else if (stObj->GetString().Contains("root") && (i==1) ) {  // root version
122       TObjArray *tali = (TObjArray *)stObj->GetString().Tokenize(":");
123       TObjString *tos = (TObjString *)tali->At(0);
124       TObjArray *tali2 = (TObjArray *)tos->GetString().Tokenize(" ");
125       TObjString *av = (TObjString *)tali2->At(1);
126       fRootVersion=av->GetString().Data();
127       TObjString *ts = (TObjString*)tali->At(1); 
128       fRootSvnVersion = ts->GetString().Atoi();
129       delete tali;
130       delete tali2;
131     }
132     else if (stObj->GetString().Contains("OutputDir")) {
133           if (stObj->GetString().Contains("pass1") ) {
134             fRecoPass=1;
135           } else if (stObj->GetString().Contains("pass2") ) {
136             fRecoPass=2;
137           } else if (stObj->GetString().Contains("pass3") ) {
138             fRecoPass=3;
139           } else if (stObj->GetString().Contains("pass4") ) {
140             fRecoPass=4;
141           } else if (stObj->GetString().Contains("pass5") ) {
142             fRecoPass=5;
143           }
144           if (stObj->GetString().Contains("/alice/sim") ) fMcFlag = kTRUE;
145           else {
146             TObjArray *tit = (TObjArray *)stObj->GetString().Tokenize("=");
147             TObjString *tos = (TObjString*)tit->At(1);
148             tit=(TObjArray *)tos->GetString().Tokenize("/");
149             tos=(TObjString*)tit->At(3);
150             if (tos) {
151               if (tos->GetString().Contains("_")) {
152                 tit=(TObjArray *)tos->GetString().Tokenize("_");
153                 tos=(TObjString*)tit->At(0);
154               }
155               if (tos) fPeriod=tos->GetString().Data();
156             }
157             delete tit;
158           }
159     }
160     //    else if (stObj->GetString().Contains("LPMProductionType=MC") ) {
161     //      fMcFlag = kTRUE;
162     //    }
163     else if (stObj->GetString().Contains("LPMAnchorProduction") ) {
164       TObjArray *tit = (TObjArray *)stObj->GetString().Tokenize("=");
165       TObjString *tos = (TObjString *)tit->At(1);
166       fPeriod=tos->GetString().Data();
167       delete tit;
168     }
169     else if (stObj->GetString().Contains("LPMProductionTag")) {
170       // for the moment we don't parse the tag, given unsafe standards...
171       /*
172       TObjArray *tit = (TObjArray *)stObj->GetString().Tokenize(" ");
173       if (tit->GetLast()>1) {
174         TObjString *tos = (TObjString *)tit->At(2);
175         if (tos) fPeriod=tos->GetString().Data();
176       }
177       */
178     }
179   }
180   delete tokens;
181 }
182
183 //-------------------------------------------------------------------------------------------------     
184 void AliProdInfo::List() const {
185
186   if (fAlirootSvnVersion > 0) {
187     AliInfo("ALICE Production Info found in UserInfo: ");
188     AliInfo(Form("  ALIROOT Version: %s [SVN #: %d]",fAlirootVersion.Data(),fAlirootSvnVersion));
189     AliInfo(Form("  ROOT Version: %s [SVN #: %d]",fRootVersion.Data(),fRootSvnVersion));
190     if (!fMcFlag) AliInfo(Form("  Reconstruction Pass: %d",fRecoPass));
191     AliInfo(Form("  LHC Period: %s",fPeriod.Data()));
192     AliInfo(Form("  MC Flag: %d",fMcFlag));
193   } else {
194     AliInfo("ALICE Production Info not available in UserInfo");
195   }
196 }