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 // Options for the TPC Reconstruction in rec.C
21 // 4 options can be set to change the input for TPC reconstruction
22 // which overwrites the usage of fUseHLTClusters of the AliTPCRecoParam
24 // 1) useRAW - use RAW, if not present -> do nothing
25 // 2) useRAWorHLT - use RAW, if not present -> use HLT clusters
26 // 3) useHLT - use HLT clusters, if not present -> do nothing
27 // 4) useHLTorRAW - use HLT clusters, if not present -> use RAW
29 // -> The current default is useHLTorRAW
30 //--------------------------------------------------------------------
32 ///////////////////////////////////////////////////////////////////////////////
34 // class for TPC reconstruction //
36 ///////////////////////////////////////////////////////////////////////////////
40 #include <TObjString.h>
41 #include <TObjArray.h>
46 #include <AliESDpid.h>
47 #include <AliTPCPIDResponse.h>
48 #include "AliTPCReconstructor.h"
49 #include "AliRunLoader.h"
51 #include "AliRawReader.h"
52 #include "AliTPCclusterer.h"
53 #include "AliTPCtracker.h"
54 #include "AliTPCParam.h"
55 #include "AliTPCParamSR.h"
56 #include "AliTPCcalibDB.h"
57 #include "AliTracker.h"
60 ClassImp(AliTPCReconstructor)
63 Int_t AliTPCReconstructor::fgStreamLevel = 0; // stream (debug) level
64 AliTPCAltroEmulator * AliTPCReconstructor::fAltroEmulator=0; // ALTRO emulator
66 AliTPCReconstructor::AliTPCReconstructor():
72 // default constructor
76 AliTPCcalibDB * calib = AliTPCcalibDB::Instance();
77 const AliMagF * field = (AliMagF*)TGeoGlobalMagField::Instance()->GetField();
78 calib->SetExBField(field);
79 AliTPCParam* param = GetTPCParam();
81 AliWarning("Loading default TPC parameters !");
82 param = new AliTPCParamSR;
84 fClusterer = new AliTPCclusterer(param);
87 AliTPCReconstructor::AliTPCReconstructor(const AliTPCReconstructor& /*rec*/):
93 // Dummy copu constructor
97 AliTPCReconstructor& AliTPCReconstructor::operator=(const AliTPCReconstructor&){
104 //_____________________________________________________________________________
105 AliTPCReconstructor::~AliTPCReconstructor()
107 if (fClusterer) delete fClusterer;
109 delete AliTPCcalibDB::Instance();
112 //_____________________________________________________________________________
113 void AliTPCReconstructor::Reconstruct(TTree* digitsTree, TTree* clustersTree) const {
114 // single event local reconstruction
116 fClusterer->SetInput(digitsTree);
117 fClusterer->SetOutput(clustersTree);
118 fClusterer->Digits2Clusters();
121 //_____________________________________________________________________________
122 void AliTPCReconstructor::Reconstruct(AliRawReader* rawReader, TTree* clustersTree) const {
123 // single event local reconstruction
124 // of TPC data starting from raw data
126 fClusterer->SetOutput(clustersTree);
127 fClusterer->Digits2Clusters(rawReader);
130 //_____________________________________________________________________________
131 AliTracker* AliTPCReconstructor::CreateTracker() const
133 // create a TPC tracker
135 AliTPCParam* param = GetTPCParam();
137 AliWarning("Loading default TPC parameters !");
138 param = new AliTPCParamSR;
140 param->ReadGeoMatrices();
142 AliTPCtracker* tracker = new AliTPCtracker(param);
144 ParseOptions(tracker);
149 //_____________________________________________________________________________
150 void AliTPCReconstructor::FillESD(TTree */*digitsTree*/, TTree */*clustersTree*/,
151 AliESDEvent* /*esd*/) const
154 /* Now done in AliESDpid
155 Double_t parTPC[] = {50., 0.07, 5.}; // MIP nnormalized to channel 50 -MI
156 AliTPCpidESD tpcPID(parTPC);
162 //_____________________________________________________________________________
163 AliTPCParam* AliTPCReconstructor::GetTPCParam() const
165 // get the TPC parameters
167 AliTPCParam* param = AliTPCcalibDB::Instance()->GetParameters();
172 //_____________________________________________________________________________
173 void AliTPCReconstructor::SetSplinesFromOADB(const char* tmplt, AliESDpid *esdPID)
176 // load splines from the OADB using 'template'
179 // only load splines if not already set
181 fArrSplines=new TObjArray(Int_t(AliPID::kSPECIES));
182 fArrSplines->SetOwner();
183 TString stemplate(tmplt);
185 TString fileNamePIDresponse("$ALICE_ROOT/OADB/COMMON/PID/data/TPCPIDResponse.root");
186 TFile f(fileNamePIDresponse.Data());
188 TObjArray *arrPidResponseMaster=0x0;
190 if (f.IsOpen() && !f.IsZombie()){
191 arrPidResponseMaster=dynamic_cast<TObjArray*>(f.Get("TPCPIDResponse"));
195 if (!arrPidResponseMaster){
196 AliError("PID response array not found, cannot assign proper splines");
200 for (Int_t ispec=0; ispec<AliPID::kSPECIES; ++ispec)
203 if (ispec==Int_t(AliPID::kMuon)) ispec2=Int_t(AliPID::kPion);
205 TString particle=AliPID::ParticleName(ispec2);
209 splineName.Form(stemplate.Data(),particle.Data());
210 TObject *spline=arrPidResponseMaster->FindObject(splineName.Data());
212 AliError(Form("No spline found for '%s'", splineName.Data()));
215 AliInfo(Form("Adding Response function %d:%s",ispec,splineName.Data()));
216 fArrSplines->AddAt(spline->Clone(), ispec);
218 arrPidResponseMaster->Delete();
219 delete arrPidResponseMaster;
220 if (fArrSplines->GetEntries()!=Int_t(AliPID::kSPECIES)) {
221 AliError("Splines not found for all species, cannot use proper PID");
228 for (Int_t ispec=0; ispec<AliPID::kSPECIES; ++ispec)
230 esdPID->GetTPCResponse().SetResponseFunction( (AliPID::EParticleType)ispec, fArrSplines->UncheckedAt(ispec) );
233 esdPID->GetTPCResponse().SetUseDatabase(kTRUE);
236 //_____________________________________________________________________________
237 void AliTPCReconstructor::GetPidSettings(AliESDpid *esdPID)
240 // Get TPC pid splines. They should be written to the OCDB during the CPass
241 // the splines themselves are owned by the OCDB object
245 TString allopt(GetOption());
246 TObjArray *optArray=allopt.Tokenize(";");
248 // defines whether the pid was set via a specific option in the rec.C
249 Bool_t pidSetInOptions = kFALSE;
251 for (Int_t iopt=0; iopt<optArray->GetEntriesFast(); ++iopt){
252 if (!optArray->At(iopt)) continue;
253 TString option(static_cast<TObjString*>(optArray->At(iopt))->GetString().Strip(TString::kBoth,' '));
255 if (!option.BeginsWith("PID.")) continue;
257 // remove 'PID.' identifyer
261 if (option.BeginsWith("Static=")){
262 option.Remove(0,option.First('=')+1);
263 if (option.Contains("LHC13b2_fix_PID")) {
264 esdPID->GetTPCResponse().SetBetheBlochParameters(0.0320981, 19.9768, 2.52666e-16, 2.72123, 6.08092);
265 esdPID->GetTPCResponse().SetMip(53.4968);
266 pidSetInOptions=kTRUE;
269 } else if (option.BeginsWith("OADB=")) {
270 option.Remove(0,option.First('=')+1);
271 AliInfo(Form("Setting splines From OADB using template: '%s'",option.Data()));
272 SetSplinesFromOADB(option, esdPID);
273 pidSetInOptions=kTRUE;
274 } else if (option.BeginsWith("OCDB=")){
275 option.Remove(0,option.First('=')+1);
276 // not yet implemented
284 // Initialisation of BB parameters from the OCDB.
285 // They are stored in the AliTPCParam
287 if (!pidSetInOptions) {
288 AliTPCParam* param = AliTPCcalibDB::Instance()->GetParameters();
290 TVectorD *paramBB=param->GetBetheBlochParameters();
292 esdPID->GetTPCResponse().SetBetheBlochParameters((*paramBB)(0),(*paramBB)(1),(*paramBB)(2),(*paramBB)(3),(*paramBB)(4));
293 AliInfo(Form("Setting BB parameters from OCDB (AliTPCParam): %.2g, %.2g, %.2g, %.2g, %.2g",
294 (*paramBB)(0),(*paramBB)(1),(*paramBB)(2),(*paramBB)(3),(*paramBB)(4)));
296 AliError("Couldn't get BB parameters from OCDB, the old default values will be used instead");
299 AliError("Couldn't get TPC parameters");
304 AliTPCcalibDB * calib = AliTPCcalibDB::Instance();
306 //Get pid splines array
307 TObjArray *arrSplines=calib->GetPidResponse();
308 if (!arrSplines) return;
309 AliTPCPIDResponse &tpcPID=esdPID->GetTPCResponse();
310 tpcPID.SetUseDatabase(kTRUE);
312 // check if parametrisations are already set.
313 // since this is uniq for one run, we don't have to reload them
314 if (tpcPID.GetResponseFunction(AliPID::kPion)) return;
316 // get the default object
317 TObject *defaultPID=arrSplines->At(AliPID::kUnknown);
319 // loop over all particle species and set the response functions
320 for (Int_t ispec=0; ispec<AliPID::kUnknown; ++ispec){
321 TObject *pidSpline=arrSplines->At(ispec);
322 if (!pidSpline) pidSpline=defaultPID;
323 tpcPID.SetResponseFunction((AliPID::EParticleType)ispec,pidSpline);
328 //_____________________________________________________________________________
329 void AliTPCReconstructor::ParseOptions( AliTPCtracker* tracker ) const
331 // parse options from rec.C and set in clusterer and tracker
333 TString option = GetOption();
335 Int_t useHLTClusters = 3;
337 if (option.Contains("use")) {
339 AliInfo(Form("Overide TPC RecoParam with option %s",option.Data()));
341 if (option.Contains("useRAW")) {
343 if (option.Contains("useRAWorHLT"))
346 else if (option.Contains("useHLT")) {
348 if (option.Contains("useHLTorRAW"))
353 const AliTPCRecoParam* param = GetRecoParam();
354 useHLTClusters = param->GetUseHLTClusters();
357 AliInfo(Form("Usage of HLT clusters in TPC reconstruction : %d", useHLTClusters));
359 fClusterer->SetUseHLTClusters(useHLTClusters);
360 tracker->SetUseHLTClusters(useHLTClusters);