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 = 1; // 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;
111 //_____________________________________________________________________________
112 void AliTPCReconstructor::Reconstruct(TTree* digitsTree, TTree* clustersTree) const {
113 // single event local reconstruction
115 fClusterer->SetInput(digitsTree);
116 fClusterer->SetOutput(clustersTree);
117 fClusterer->Digits2Clusters();
120 //_____________________________________________________________________________
121 void AliTPCReconstructor::Reconstruct(AliRawReader* rawReader, TTree* clustersTree) const {
122 // single event local reconstruction
123 // of TPC data starting from raw data
125 fClusterer->SetOutput(clustersTree);
126 fClusterer->Digits2Clusters(rawReader);
129 //_____________________________________________________________________________
130 AliTracker* AliTPCReconstructor::CreateTracker() const
132 // create a TPC tracker
134 AliTPCParam* param = GetTPCParam();
136 AliWarning("Loading default TPC parameters !");
137 param = new AliTPCParamSR;
139 param->ReadGeoMatrices();
141 AliTPCtracker* tracker = new AliTPCtracker(param);
143 ParseOptions(tracker);
148 //_____________________________________________________________________________
149 void AliTPCReconstructor::FillESD(TTree */*digitsTree*/, TTree */*clustersTree*/,
150 AliESDEvent* /*esd*/) const
153 /* Now done in AliESDpid
154 Double_t parTPC[] = {50., 0.07, 5.}; // MIP nnormalized to channel 50 -MI
155 AliTPCpidESD tpcPID(parTPC);
161 //_____________________________________________________________________________
162 AliTPCParam* AliTPCReconstructor::GetTPCParam() const
164 // get the TPC parameters
166 AliTPCParam* param = AliTPCcalibDB::Instance()->GetParameters();
171 //_____________________________________________________________________________
172 void AliTPCReconstructor::SetSplinesFromOADB(const char* tmplt, AliESDpid *esdPID)
175 // load splines from the OADB using 'template'
178 // only load splines if not already set
180 fArrSplines=new TObjArray(Int_t(AliPID::kSPECIES));
181 fArrSplines->SetOwner();
182 TString stemplate(tmplt);
184 TString fileNamePIDresponse("$ALICE_ROOT/OADB/COMMON/PID/data/TPCPIDResponse.root");
185 TFile f(fileNamePIDresponse.Data());
187 TObjArray *arrPidResponseMaster=0x0;
189 if (f.IsOpen() && !f.IsZombie()){
190 arrPidResponseMaster=dynamic_cast<TObjArray*>(f.Get("TPCPIDResponse"));
194 if (!arrPidResponseMaster){
195 AliError("PID response array not found, cannot assign proper splines");
199 for (Int_t ispec=0; ispec<AliPID::kSPECIES; ++ispec)
202 if (ispec==Int_t(AliPID::kMuon)) ispec2=Int_t(AliPID::kPion);
204 TString particle=AliPID::ParticleName(ispec2);
208 splineName.Form(stemplate.Data(),particle.Data());
209 TObject *spline=arrPidResponseMaster->FindObject(splineName.Data());
211 AliError(Form("No spline found for '%s'", splineName.Data()));
214 AliInfo(Form("Adding Response function %d:%s",ispec,splineName.Data()));
215 fArrSplines->AddAt(spline->Clone(), ispec);
217 arrPidResponseMaster->Delete();
218 delete arrPidResponseMaster;
219 if (fArrSplines->GetEntries()!=Int_t(AliPID::kSPECIES)) {
220 AliError("Splines not found for all species, cannot use proper PID");
227 for (Int_t ispec=0; ispec<AliPID::kSPECIES; ++ispec)
229 esdPID->GetTPCResponse().SetResponseFunction( (AliPID::EParticleType)ispec, fArrSplines->UncheckedAt(ispec) );
232 esdPID->GetTPCResponse().SetUseDatabase(kTRUE);
235 //_____________________________________________________________________________
236 void AliTPCReconstructor::GetPidSettings(AliESDpid *esdPID)
239 // Get TPC pid splines. They should be written to the OCDB during the CPass
240 // the splines themselves are owned by the OCDB object
244 TString allopt(GetOption());
245 TObjArray *optArray=allopt.Tokenize(";");
247 for (Int_t iopt=0; iopt<optArray->GetEntriesFast(); ++iopt){
248 if (!optArray->At(iopt)) continue;
249 TString option(static_cast<TObjString*>(optArray->At(iopt))->GetString().Strip(TString::kBoth,' '));
251 if (!option.BeginsWith("PID.")) continue;
253 // remove 'PID.' identifyer
257 if (option.BeginsWith("Static=")){
258 option.Remove(0,option.First('=')+1);
259 if (option.Contains("LHC13b2_fix_PID")) {
260 esdPID->GetTPCResponse().SetBetheBlochParameters(0.0320981, 19.9768, 2.52666e-16, 2.72123, 6.08092);
261 esdPID->GetTPCResponse().SetMip(53.4968);
264 } else if (option.BeginsWith("OADB=")) {
265 option.Remove(0,option.First('=')+1);
266 AliInfo(Form("Setting splines From OADB using template: '%s'",option.Data()));
267 SetSplinesFromOADB(option, esdPID);
268 } else if (option.BeginsWith("OCDB=")){
269 option.Remove(0,option.First('=')+1);
270 // not yet implemented
278 AliTPCcalibDB * calib = AliTPCcalibDB::Instance();
280 //Get pid splines array
281 TObjArray *arrSplines=calib->GetPidResponse();
282 if (!arrSplines) return;
283 AliTPCPIDResponse &tpcPID=esdPID->GetTPCResponse();
284 tpcPID.SetUseDatabase(kTRUE);
286 // check if parametrisations are already set.
287 // since this is uniq for one run, we don't have to reload them
288 if (tpcPID.GetResponseFunction(AliPID::kPion)) return;
290 // get the default object
291 TObject *defaultPID=arrSplines->At(AliPID::kUnknown);
293 // loop over all particle species and set the response functions
294 for (Int_t ispec=0; ispec<AliPID::kUnknown; ++ispec){
295 TObject *pidSpline=arrSplines->At(ispec);
296 if (!pidSpline) pidSpline=defaultPID;
297 tpcPID.SetResponseFunction((AliPID::EParticleType)ispec,pidSpline);
302 //_____________________________________________________________________________
303 void AliTPCReconstructor::ParseOptions( AliTPCtracker* tracker ) const
305 // parse options from rec.C and set in clusterer and tracker
307 TString option = GetOption();
309 Int_t useHLTClusters = 3;
311 if (option.Contains("use")) {
313 AliInfo(Form("Overide TPC RecoParam with option %s",option.Data()));
315 if (option.Contains("useRAW")) {
317 if (option.Contains("useRAWorHLT"))
320 else if (option.Contains("useHLT")) {
322 if (option.Contains("useHLTorRAW"))
327 const AliTPCRecoParam* param = GetRecoParam();
328 useHLTClusters = param->GetUseHLTClusters();
331 AliInfo(Form("Usage of HLT clusters in TPC reconstruction : %d", useHLTClusters));
333 fClusterer->SetUseHLTClusters(useHLTClusters);
334 tracker->SetUseHLTClusters(useHLTClusters);