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():
71 // default constructor
75 AliTPCcalibDB * calib = AliTPCcalibDB::Instance();
76 const AliMagF * field = (AliMagF*)TGeoGlobalMagField::Instance()->GetField();
77 calib->SetExBField(field);
78 AliTPCParam* param = GetTPCParam();
80 AliWarning("Loading default TPC parameters !");
81 param = new AliTPCParamSR;
83 fClusterer = new AliTPCclusterer(param);
86 AliTPCReconstructor::AliTPCReconstructor(const AliTPCReconstructor& /*rec*/):
91 // Dummy copu constructor
95 AliTPCReconstructor& AliTPCReconstructor::operator=(const AliTPCReconstructor&){
102 //_____________________________________________________________________________
103 AliTPCReconstructor::~AliTPCReconstructor()
105 if (fClusterer) delete fClusterer;
108 //_____________________________________________________________________________
109 void AliTPCReconstructor::Reconstruct(TTree* digitsTree, TTree* clustersTree) const {
110 // single event local reconstruction
112 fClusterer->SetInput(digitsTree);
113 fClusterer->SetOutput(clustersTree);
114 fClusterer->Digits2Clusters();
117 //_____________________________________________________________________________
118 void AliTPCReconstructor::Reconstruct(AliRawReader* rawReader, TTree* clustersTree) const {
119 // single event local reconstruction
120 // of TPC data starting from raw data
122 fClusterer->SetOutput(clustersTree);
123 fClusterer->Digits2Clusters(rawReader);
126 //_____________________________________________________________________________
127 AliTracker* AliTPCReconstructor::CreateTracker() const
129 // create a TPC tracker
131 AliTPCParam* param = GetTPCParam();
133 AliWarning("Loading default TPC parameters !");
134 param = new AliTPCParamSR;
136 param->ReadGeoMatrices();
138 AliTPCtracker* tracker = new AliTPCtracker(param);
140 ParseOptions(tracker);
145 //_____________________________________________________________________________
146 void AliTPCReconstructor::FillESD(TTree */*digitsTree*/, TTree */*clustersTree*/,
147 AliESDEvent* /*esd*/) const
150 /* Now done in AliESDpid
151 Double_t parTPC[] = {50., 0.07, 5.}; // MIP nnormalized to channel 50 -MI
152 AliTPCpidESD tpcPID(parTPC);
158 //_____________________________________________________________________________
159 AliTPCParam* AliTPCReconstructor::GetTPCParam() const
161 // get the TPC parameters
163 AliTPCParam* param = AliTPCcalibDB::Instance()->GetParameters();
168 //_____________________________________________________________________________
169 void AliTPCReconstructor::SetSplinesFromOADB(const char* tmplt, AliESDpid *esdPID)
172 // load splines from the OADB using 'template'
175 TString stemplate(tmplt);
177 TString fileNamePIDresponse("$ALICE_ROOT/OADB/COMMON/PID/data/TPCPIDResponse.root");
178 TFile f(fileNamePIDresponse.Data());
180 TObjArray *arrPidResponseMaster=0x0;
182 if (f.IsOpen() && !f.IsZombie()){
183 arrPidResponseMaster=dynamic_cast<TObjArray*>(f.Get("TPCPIDResponse"));
187 if (!arrPidResponseMaster){
188 AliError("PID response array not found, cannot assign proper splines");
193 for (Int_t ispec=0; ispec<AliPID::kSPECIES; ++ispec)
196 if (ispec==Int_t(AliPID::kMuon)) ispec2=Int_t(AliPID::kPion);
198 TString particle=AliPID::ParticleName(ispec2);
202 splineName.Form(stemplate.Data(),particle.Data());
203 TObject *spline=arrPidResponseMaster->FindObject(splineName.Data());
205 AliError(Form("No spline found for '%s'", splineName.Data()));
208 AliInfo(Form("Adding Response function %d:%s",ispec,splineName.Data()));
210 esdPID->GetTPCResponse().SetResponseFunction( (AliPID::EParticleType)ispec, spline );
214 if (hasSplines==Int_t(AliPID::kSPECIES)) esdPID->GetTPCResponse().SetUseDatabase(kTRUE);
215 else AliError("Splines not found for all species, cannot use proper PID");
218 //_____________________________________________________________________________
219 void AliTPCReconstructor::GetPidSettings(AliESDpid *esdPID)
222 // Get TPC pid splines. They should be written to the OCDB during the CPass
223 // the splines themselves are owned by the OCDB object
227 TString allopt(GetOption());
228 TObjArray *optArray=allopt.Tokenize(";");
230 for (Int_t iopt=0; iopt<optArray->GetEntriesFast(); ++iopt){
231 if (!optArray->At(iopt)) continue;
232 TString option(static_cast<TObjString*>(optArray->At(iopt))->GetString().Strip(TString::kBoth,' '));
234 if (!option.BeginsWith("PID.")) continue;
236 // remove 'PID.' identifyer
240 if (option.BeginsWith("Static=")){
241 option.Remove(0,option.First('=')+1);
242 if (option.Contains("LHC13b2_fix_PID")) {
243 esdPID->GetTPCResponse().SetBetheBlochParameters(0.0320981, 19.9768, 2.52666e-16, 2.72123, 6.08092);
244 esdPID->GetTPCResponse().SetMip(53.4968);
247 } else if (option.BeginsWith("OADB=")) {
248 option.Remove(0,option.First('=')+1);
249 AliInfo(Form("Setting splines From OADB using template: '%s'",option.Data()));
250 SetSplinesFromOADB(option, esdPID);
251 } else if (option.BeginsWith("OCDB=")){
252 option.Remove(0,option.First('=')+1);
253 // not yet implemented
261 AliTPCcalibDB * calib = AliTPCcalibDB::Instance();
263 //Get pid splines array
264 TObjArray *arrSplines=calib->GetPidResponse();
265 if (!arrSplines) return;
266 AliTPCPIDResponse &tpcPID=esdPID->GetTPCResponse();
267 tpcPID.SetUseDatabase(kTRUE);
269 // check if parametrisations are already set.
270 // since this is uniq for one run, we don't have to reload them
271 if (tpcPID.GetResponseFunction(AliPID::kPion)) return;
273 // get the default object
274 TObject *defaultPID=arrSplines->At(AliPID::kUnknown);
276 // loop over all particle species and set the response functions
277 for (Int_t ispec=0; ispec<AliPID::kUnknown; ++ispec){
278 TObject *pidSpline=arrSplines->At(ispec);
279 if (!pidSpline) pidSpline=defaultPID;
280 tpcPID.SetResponseFunction((AliPID::EParticleType)ispec,pidSpline);
285 //_____________________________________________________________________________
286 void AliTPCReconstructor::ParseOptions( AliTPCtracker* tracker ) const
288 // parse options from rec.C and set in clusterer and tracker
290 TString option = GetOption();
292 Int_t useHLTClusters = 3;
294 if (option.Contains("use")) {
296 AliInfo(Form("Overide TPC RecoParam with option %s",option.Data()));
298 if (!option.Contains("useRAW"))
300 if (!option.Contains("useRAWorHLT"))
302 if (!option.Contains("useHLT"))
304 if (!option.Contains("useHLTorRAW"))
308 const AliTPCRecoParam* param = GetRecoParam();
309 useHLTClusters = param->GetUseHLTClusters();
312 AliInfo(Form("Usage of HLT clusters in TPC reconstruction : %d", useHLTClusters));
314 fClusterer->SetUseHLTClusters(useHLTClusters);
315 tracker->SetUseHLTClusters(useHLTClusters);