Update master to aliroot
[u/mrichter/AliRoot.git] / STEER / STEERBase / AliProdInfo.cxx
CommitLineData
4cf1e5f2 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
30ClassImp(AliProdInfo);
31
32AliProdInfo::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
47AliProdInfo::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
63AliProdInfo::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//-------------------------------------------------------------------------------------------------
80AliProdInfo::~AliProdInfo() {
81
82}
83
84//-------------------------------------------------------------------------------------------------
85void 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//-------------------------------------------------------------------------------------------------
102void 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);
08395d25 113 fAlirootVersion="";
114 if (tos) {
115 TObjArray *tali2 = (TObjArray *)tos->GetString().Tokenize(" ");
116 TObjString *av = (TObjString *)tali2->At(1);
117 if (av) fAlirootVersion=av->GetString().Data();
118 else AliWarning("Cannot extract AliROOT version string. Might be git related.");
119 delete tali2;
120 }
121
122 TObjString *ts = (TObjString*)tali->At(1);
123 if (ts){
124 if (ts->GetString().IsDigit()){
125 fAlirootSvnVersion = ts->GetString().Atoi();
126 } else {
127 AliWarning("Version number not numeric, might be on git. Using last svn rev number (65263) instead.");
128 fAlirootSvnVersion=65263;
129 }
130 }
4cf1e5f2 131 delete tali;
4cf1e5f2 132 }
133 else if (stObj->GetString().Contains("root") && (i==1) ) { // root version
134 TObjArray *tali = (TObjArray *)stObj->GetString().Tokenize(":");
135 TObjString *tos = (TObjString *)tali->At(0);
136 TObjArray *tali2 = (TObjArray *)tos->GetString().Tokenize(" ");
137 TObjString *av = (TObjString *)tali2->At(1);
138 fRootVersion=av->GetString().Data();
139 TObjString *ts = (TObjString*)tali->At(1);
140 fRootSvnVersion = ts->GetString().Atoi();
141 delete tali;
142 delete tali2;
143 }
144 else if (stObj->GetString().Contains("OutputDir")) {
145 if (stObj->GetString().Contains("pass1") ) {
146 fRecoPass=1;
147 } else if (stObj->GetString().Contains("pass2") ) {
148 fRecoPass=2;
149 } else if (stObj->GetString().Contains("pass3") ) {
150 fRecoPass=3;
151 } else if (stObj->GetString().Contains("pass4") ) {
152 fRecoPass=4;
153 } else if (stObj->GetString().Contains("pass5") ) {
154 fRecoPass=5;
155 }
156 if (stObj->GetString().Contains("/alice/sim") ) fMcFlag = kTRUE;
157 else {
158 TObjArray *tit = (TObjArray *)stObj->GetString().Tokenize("=");
159 TObjString *tos = (TObjString*)tit->At(1);
160 tit=(TObjArray *)tos->GetString().Tokenize("/");
161 tos=(TObjString*)tit->At(3);
162 if (tos) {
163 if (tos->GetString().Contains("_")) {
164 tit=(TObjArray *)tos->GetString().Tokenize("_");
165 tos=(TObjString*)tit->At(0);
166 }
167 if (tos) fPeriod=tos->GetString().Data();
168 }
169 delete tit;
170 }
171 }
172 // else if (stObj->GetString().Contains("LPMProductionType=MC") ) {
173 // fMcFlag = kTRUE;
174 // }
175 else if (stObj->GetString().Contains("LPMAnchorProduction") ) {
176 TObjArray *tit = (TObjArray *)stObj->GetString().Tokenize("=");
177 TObjString *tos = (TObjString *)tit->At(1);
178 fPeriod=tos->GetString().Data();
179 delete tit;
180 }
181 else if (stObj->GetString().Contains("LPMProductionTag")) {
182 // for the moment we don't parse the tag, given unsafe standards...
183 /*
184 TObjArray *tit = (TObjArray *)stObj->GetString().Tokenize(" ");
185 if (tit->GetLast()>1) {
186 TObjString *tos = (TObjString *)tit->At(2);
187 if (tos) fPeriod=tos->GetString().Data();
188 }
189 */
190 }
191 }
09d5920f 192 delete tokens;
4cf1e5f2 193}
194
195//-------------------------------------------------------------------------------------------------
196void AliProdInfo::List() const {
197
198 if (fAlirootSvnVersion > 0) {
199 AliInfo("ALICE Production Info found in UserInfo: ");
200 AliInfo(Form(" ALIROOT Version: %s [SVN #: %d]",fAlirootVersion.Data(),fAlirootSvnVersion));
201 AliInfo(Form(" ROOT Version: %s [SVN #: %d]",fRootVersion.Data(),fRootSvnVersion));
202 if (!fMcFlag) AliInfo(Form(" Reconstruction Pass: %d",fRecoPass));
203 AliInfo(Form(" LHC Period: %s",fPeriod.Data()));
204 AliInfo(Form(" MC Flag: %d",fMcFlag));
205 } else {
206 AliInfo("ALICE Production Info not available in UserInfo");
207 }
208}