4 #include "TEventList.h"
9 #include "AliESDtrack.h"
10 #include "AliTrackReference.h"
12 #include "AliTRDReconstructor.h"
13 #include "AliTRDtrackV1.h"
14 #include "AliTRDseedV1.h"
15 #include "AliTRDpidRefMaker.h"
16 #include "info/AliTRDv0Info.h"
19 // Defines and implements basic functionality for building reference data for TRD PID.
21 // Here is the list of functionality provided by this class
26 // Alex Bercuci <A.Bercuci@gsi.de>
27 // Alex Wilk <wilka@uni-muenster.de>
28 // Markus Fasel <mfasel@gsi.de>
29 // Markus Heide <mheide@uni-muenster.de>
32 ClassImp(AliTRDpidRefMaker)
34 //________________________________________________________________________
35 AliTRDpidRefMaker::AliTRDpidRefMaker(const char *name, const char *title)
36 :AliTRDrecoTask(name, title)
48 // Default constructor
51 fReconstructor = new AliTRDReconstructor();
52 fReconstructor->SetRecoParam(AliTRDrecoParam::GetLowFluxParam());
53 memset(fdEdx, 0, 10*sizeof(Float_t));
54 memset(fPID, 0, AliPID::kSPECIES*sizeof(Float_t));
56 DefineInput(1, TObjArray::Class());
57 DefineOutput(1, TTree::Class());
61 //________________________________________________________________________
62 AliTRDpidRefMaker::~AliTRDpidRefMaker()
64 if(fReconstructor) delete fReconstructor;
68 //________________________________________________________________________
69 void AliTRDpidRefMaker::ConnectInputData(Option_t *opt)
71 AliTRDrecoTask::ConnectInputData(opt);
72 fV0s = dynamic_cast<TObjArray*>(GetInputData(1));
75 //________________________________________________________________________
76 void AliTRDpidRefMaker::CreateOutputObjects()
81 OpenFile(0, "RECREATE");
82 fContainer = new TObjArray();
83 fContainer->SetName(Form("Moni%s", GetName()));
85 TH2 *h2 = new TH2I("hPDG","Particle abundance", AliPID::kSPECIES, -0.5, 4.5, AliTRDCalPID::kNMom, -0.5, AliTRDCalPID::kNMom-0.5);
86 TAxis *ax = h2->GetXaxis();
87 ax->SetNdivisions(505);
88 ax->SetTitle("Particle species");
89 for(Int_t is=AliPID::kSPECIES; is--;) ax->SetBinLabel(is+1, AliPID::ParticleShortName(is));
90 h2->GetYaxis()->SetTitle("P bins");
91 h2->GetYaxis()->SetNdivisions(511);
93 fContainer->AddAt(h2, 0);
96 //________________________________________________________________________
97 void AliTRDpidRefMaker::Exec(Option_t *)
100 // Called for each event
107 // for(Int_t iv0=0; iv0<fV0s->GetEntriesFast(); iv0++){
108 // v0 = dynamic_cast<AliTRDv0Info*>(fV0s->At(iv0));
112 Int_t labelsacc[10000]; // MC labels
113 memset(labelsacc, 0, sizeof(Int_t) * 10000);
115 AliTRDtrackInfo *track = 0x0;
116 //AliTRDv0Info *v0 = 0x0;
117 AliTRDtrackV1 *TRDtrack = 0x0;
118 AliTrackReference *ref = 0x0;
119 //AliExternalTrackParam *esd = 0x0;
120 AliTRDseedV1 *TRDtracklet = 0x0;
121 for(Int_t itrk=0, nTRD=0; itrk<fTracks->GetEntriesFast(); itrk++){
122 track = (AliTRDtrackInfo*)fTracks->UncheckedAt(itrk);
123 if(!track->HasESDtrack()) continue;
124 ULong_t status = track->GetStatus();
125 if(!(status&AliESDtrack::kTPCout)) continue;
127 if(!(TRDtrack = track->GetTrack())) continue;
128 //&&(track->GetNumberOfClustersRefit()
130 // TOO STRONG and might introduce a bias if short
131 // tracks are to be analysed (A.Bercuci 23.09.09)
132 // use only tracks that hit 6 chambers
133 //if(!(TRDtrack->GetNumberOfTracklets() == AliTRDgeometry::kNlayer)) continue;
136 if(HasMCdata()) labelsacc[nTRD++] = track->GetLabel();
138 // fill the pid information
139 memset(fPID, 0, AliPID::kSPECIES*sizeof(Float_t));
141 case kV0: SetRefPID(kV0, 0x0/*v0*/, fPID); break;
142 case kMC: SetRefPID(kMC, track, fPID); break;
143 case kRec: SetRefPID(kRec, TRDtrack, fPID); break;
146 // fill the momentum and dE/dx information
147 TRDtrack -> SetReconstructor(fReconstructor);
148 for(Int_t ily = 0; ily < AliTRDgeometry::kNlayer; ily++){
149 if(!(TRDtracklet = TRDtrack -> GetTracklet(ily))) continue;
150 if(!CookdEdx(TRDtracklet)) continue;
154 AliError("Could not retrive reference momentum from MC");
157 if(!(ref = track->GetTrackRef(TRDtracklet))) continue;
161 fP = TRDtracklet->GetMomentum();
164 AliWarning("Momentum reference source not implemented");
171 for(Int_t iPart = 0; iPart < AliPID::kSPECIES; iPart++){
172 AliDebug(4, Form("PDG is %d %f", iPart, fPID[iPart]));
176 PostData(0, fContainer);
181 //________________________________________________________________________
182 void AliTRDpidRefMaker::Fill()
187 //________________________________________________________________________
188 void AliTRDpidRefMaker::Terminate(Option_t *)
190 // Draw result to the screen
191 // Called once at the end of the query
193 fContainer = dynamic_cast<TObjArray*>(GetOutputData(0));
195 AliError("List not available");
201 //________________________________________________________________________
202 void AliTRDpidRefMaker::SetRefPID(ETRDpidRefMakerSource select, void *source, Float_t *pid)
204 // !!!! PREMILMINARY FUNCTION !!!!
206 // this is the place for the V0 procedure
207 // as long as there is no one implemented,
208 // just the probabilities
209 // of the TRDtrack are used!
214 AliTRDv0Info *v0 = static_cast<AliTRDv0Info*>(source);
215 v0->Print(); // do something
220 AliError("Could not retrive reference PID from MC");
224 AliTRDtrackInfo *track = static_cast<AliTRDtrackInfo*>(source);
225 switch(track->GetPDG()){
228 fPID[AliPID::kElectron] = 1.;
232 fPID[AliPID::kMuon] = 1.;
236 fPID[AliPID::kPion] = 1.;
240 fPID[AliPID::kKaon] = 1.;
244 fPID[AliPID::kProton] = 1.;
251 AliTRDtrackV1 *TRDtrack = static_cast<AliTRDtrackV1*>(source);
252 TRDtrack -> SetReconstructor(fReconstructor);
253 //fReconstructor -> SetOption("nn");
254 TRDtrack -> CookPID();
255 for(Int_t iPart = 0; iPart < AliPID::kSPECIES; iPart++){
256 pid[iPart] = TRDtrack -> GetPID(iPart);
257 AliDebug(4, Form("PDG is (in V0info) %d %f", iPart, pid[iPart]));
262 AliWarning("PID reference source not implemented");
267 //________________________________________________________________________
268 void AliTRDpidRefMaker::SetAbundance(Float_t train, Float_t test)
270 if(fTrainFreq<0. || fTrainFreq >1. ||
271 fTestFreq<0. || fTestFreq >1.){
272 AliWarning("The input data should be in the interval [0, 1]");
275 if(TMath::Abs(fTrainFreq+fTestFreq - 1.) > 0.001){
276 AliWarning("The sum of the 2 abundances should pe one.");