1 // -------------------------------------------------------------------------
2 // Copies all info that is needed for the DiHadronPID analysis.
3 // Possible Extension: At this moment the object is protected for returning
4 // pointers to the original tracks. It could at some point be beneficial to
5 // be able to access this information.
6 // -------------------------------------------------------------------------
7 // Author: Misha Veldhoen (misha.veldhoen@cern.ch)
13 #include "AliAODTrack.h"
14 #include "AliAODEvent.h"
15 #include "AliAODVertex.h"
16 #include "AliAODMCParticle.h"
20 #include "AliPIDResponse.h"
21 #include "AliTPCPIDResponse.h"
23 // Objects own include.
24 #include "AliTrackDiHadronPID.h"
26 ClassImp(AliTrackDiHadronPID);
28 // -------------------------------------------------------------------------
29 AliTrackDiHadronPID::AliTrackDiHadronPID():
36 fBasicInfoAvailable(kFALSE),
37 fFlagsAvailable(kFALSE),
38 fDCAInfoAvailable(kFALSE),
39 fITSInfoAvailable(kFALSE),
40 fTPCInfoAvailable(kFALSE),
41 fTOFInfoAvailable(kFALSE),
42 fMCInfoAvailable(kFALSE),
54 fIsTOFmismatch(kFALSE),
62 fIsPhysicalPrimary(kFALSE),
63 fIsSecondaryFromWeakDecay(kFALSE),
64 fIsSecondaryFromMaterial(kFALSE),
70 // Default Constructor.
73 if (fDebug) {cout << Form("File: %s, Line: %i, Function: %s",__FILE__,__LINE__,__func__) << endl;}
75 for (Int_t iSpecies = 0; iSpecies < 3; iSpecies++) {
76 fTOFsignalMinusExpected[iSpecies] = -999.;
77 fTOFNsigma[iSpecies] = -999.;
78 fTPCsignalMinusExpected[iSpecies] = -999.;
79 fTPCNsigma[iSpecies] = -999.;
83 for (Int_t iITSlayer = 0; iITSlayer < 6; iITSlayer++) {
84 fITSHits[iITSlayer] = kFALSE;
89 // -------------------------------------------------------------------------
90 AliTrackDiHadronPID::AliTrackDiHadronPID(AliAODTrack* track, AliAODTrack* globaltrack, AliAODMCParticle* mcparticle, AliPIDResponse* pidresponse):
97 fBasicInfoAvailable(kFALSE),
98 fFlagsAvailable(kFALSE),
99 fDCAInfoAvailable(kFALSE),
100 fITSInfoAvailable(kFALSE),
101 fTPCInfoAvailable(kFALSE),
102 fTOFInfoAvailable(kFALSE),
103 fMCInfoAvailable(kFALSE),
115 fIsTOFmismatch(kFALSE),
123 fIsPhysicalPrimary(kFALSE),
124 fIsSecondaryFromWeakDecay(kFALSE),
125 fIsSecondaryFromMaterial(kFALSE),
133 if (fDebug) {cout << Form("File: %s, Line: %i, Function: %s",__FILE__,__LINE__,__func__) << endl;}
135 for (Int_t iSpecies = 0; iSpecies < 3; iSpecies++) {
136 fTOFsignalMinusExpected[iSpecies] = -999.;
137 fTOFNsigma[iSpecies] = -999.;
138 fTPCsignalMinusExpected[iSpecies] = -999.;
139 fTPCNsigma[iSpecies] = -999.;
140 fY[iSpecies] = -999.;
143 for (Int_t iITSlayer = 0; iITSlayer < 6; iITSlayer++) {
144 fITSHits[iITSlayer] = kFALSE;
149 fAODEvent = track->GetAODEvent();
151 if (globaltrack) fAODGlobalTrack = globaltrack;
152 if (mcparticle) fAODMCParticle = mcparticle;
153 if (pidresponse) fPIDResponse = pidresponse;
155 // Copy AOD Track info.
157 CopyBasicTrackInfo();
159 AliError("No Track Supplied.");
162 // Find the Global Track.
163 if (fID >= 0) fAODGlobalTrack = fAODTrack;
165 // Copy DCA and PID info.
166 if (fAODGlobalTrack) {
168 if (fAODEvent) CopyDCAInfo();
169 else AliError("Couln't find AOD Event.");
171 if (fPIDResponse) CopyTPCInfo();
174 AliError("Couldn't find Global Track.");
178 if (fAODMCParticle) {
183 /* Double_t sigmaTOFProton = TMath::Abs(fPIDResponse->NumberOfSigmasTOF(fAODTrack, AliPID::kProton));
184 if ( sigmaTOFProton < 1.0) {cout<<"tofsigmabelowone: "<<sigmaTOFProton<<endl;}
186 Double_t sigmaTPCProton = TMath::Abs(fPIDResponse->NumberOfSigmasTPC(fAODTrack, AliPID::kProton));
187 if ( sigmaTPCProton < 1.0) {cout<<"tpcsigmabelowone: "<<sigmaTPCProton<<endl;}*/
190 // -------------------------------------------------------------------------
191 Bool_t AliTrackDiHadronPID::CopyBasicTrackInfo() {
194 // Copies everything available in every AOD track.
197 if (fDebug) {cout << Form("File: %s, Line: %i, Function: %s",__FILE__,__LINE__,__func__) << endl;}
199 fPt = fAODTrack->Pt();
200 fEta = fAODTrack->Eta();
201 fPhi = fAODTrack->Phi();
203 fY[0] = fAODTrack->Y(AliAODTrack::kPion);
204 fY[1] = fAODTrack->Y(AliAODTrack::kKaon);
205 fY[2] = fAODTrack->Y(AliAODTrack::kProton);
207 //fFlags = fAODTrack->GetFlags(); // FLAGS MUST BE TAKEN FROM GLOBAL TRACKS.
208 fFilterMap = fAODTrack->GetFilterMap();
210 fID = fAODTrack->GetID();
211 fLabel = fAODTrack->GetLabel();
213 fCharge = fAODTrack->Charge();
215 fBasicInfoAvailable = kTRUE;
216 return fBasicInfoAvailable;
220 // -------------------------------------------------------------------------
221 Bool_t AliTrackDiHadronPID::CopyFlags() {
224 // Copies Flags (properly stored in global track)
227 if (fDebug) {cout << Form("File: %s, Line: %i, Function: %s",__FILE__,__LINE__,__func__) << endl;}
230 fFlags = fAODGlobalTrack->GetFlags();
233 if (AliAODTrack::kTOFmismatch&fFlags) {
234 fIsTOFmismatch = kTRUE;
235 //cout<<"Found TOF mismatch!"<<endl;
237 else fIsTOFmismatch = kFALSE;
239 fFlagsAvailable = kTRUE;
240 return fFlagsAvailable;
244 // -------------------------------------------------------------------------
245 Bool_t AliTrackDiHadronPID::CopyDCAInfo() {
248 // Copies DCA info. (only stored in a global track)
251 if (fDebug) {cout << Form("File: %s, Line: %i, Function: %s",__FILE__,__LINE__,__func__) << endl;}
253 // Propagate track to DCA.
254 Double_t PosAtDCA[2] = {-999,-999};
255 Double_t covar[3] = {-999,-999,-999};
256 //cout<<fAODTrack<<" "<<fAODGlobalTrack<<endl;
257 Bool_t propagate = fAODGlobalTrack->PropagateToDCA(fAODEvent->GetPrimaryVertex(),fAODEvent->GetMagneticField(),100.,PosAtDCA,covar);
260 fDCAxy = PosAtDCA[0];
263 //AliError("Could not propagate track to DCA.");
266 if (propagate) fDCAInfoAvailable = kTRUE;
267 return fDCAInfoAvailable;
271 // -------------------------------------------------------------------------
272 Bool_t AliTrackDiHadronPID::CopyITSInfo() {
278 if (fDebug) {cout << Form("File: %s, Line: %i, Function: %s",__FILE__,__LINE__,__func__) << endl;}
280 // Get the ITS clustermap
281 fITSClusterMap = fAODGlobalTrack->GetITSClusterMap();
283 // Copy the ITS hits.
284 for (Int_t iITSlayer = 0; iITSlayer < 6; iITSlayer++) {
285 fITSHits[iITSlayer] = fAODGlobalTrack->HasPointOnITSLayer(iITSlayer);
288 fITSInfoAvailable = kTRUE;
289 return fITSInfoAvailable;
293 // -------------------------------------------------------------------------
294 Bool_t AliTrackDiHadronPID::CopyTPCInfo() {
297 // Copies TPC info. (needs global track and pid response)
300 if (fDebug) {cout << Form("File: %s, Line: %i, Function: %s",__FILE__,__LINE__,__func__) << endl;}
303 fTPCsignal = fAODGlobalTrack->GetTPCsignal();
305 // Compute expected TPC signal under pi/K/p mass assumption.
306 AliTPCPIDResponse& TPCPIDResponse = fPIDResponse->GetTPCResponse();
307 fTPCmomentum = fAODGlobalTrack->GetTPCmomentum();
309 fTPCsignalMinusExpected[0] = fTPCsignal - TPCPIDResponse.GetExpectedSignal(fTPCmomentum,AliPID::kPion);
310 fTPCsignalMinusExpected[1] = fTPCsignal - TPCPIDResponse.GetExpectedSignal(fTPCmomentum,AliPID::kKaon);
311 fTPCsignalMinusExpected[2] = fTPCsignal - TPCPIDResponse.GetExpectedSignal(fTPCmomentum,AliPID::kProton);
313 fTPCNsigma[0] = fPIDResponse->NumberOfSigmasTPC(fAODGlobalTrack, AliPID::kPion);
314 fTPCNsigma[1] = fPIDResponse->NumberOfSigmasTPC(fAODGlobalTrack, AliPID::kKaon);
315 fTPCNsigma[2] = fPIDResponse->NumberOfSigmasTPC(fAODGlobalTrack, AliPID::kProton);
317 fTPCInfoAvailable = kTRUE;
318 return fTPCInfoAvailable;
322 // -------------------------------------------------------------------------
323 Bool_t AliTrackDiHadronPID::CopyTOFInfo() {
326 // Copies TOF info. (needs global track)
329 if (fDebug) {cout << Form("File: %s, Line: %i, Function: %s",__FILE__,__LINE__,__func__) << endl;}
332 fTOFsignal = fAODGlobalTrack->GetTOFsignal();
334 // Compute expected TOF signal under pi/K/p mass assumption.
335 Double_t times[AliPID::kSPECIES];
336 fAODGlobalTrack->GetIntegratedTimes(times);
337 fTOFsignalMinusExpected[0] = fTOFsignal - times[AliPID::kPion];
338 fTOFsignalMinusExpected[1] = fTOFsignal - times[AliPID::kKaon];
339 fTOFsignalMinusExpected[2] = fTOFsignal - times[AliPID::kProton];
341 fTOFNsigma[0] = fPIDResponse->NumberOfSigmasTOF(fAODGlobalTrack, AliPID::kPion);
342 fTOFNsigma[1] = fPIDResponse->NumberOfSigmasTOF(fAODGlobalTrack, AliPID::kKaon);
343 fTOFNsigma[2] = fPIDResponse->NumberOfSigmasTOF(fAODGlobalTrack, AliPID::kProton);
345 fTOFInfoAvailable = kTRUE;
346 return fTOFInfoAvailable;
350 // -------------------------------------------------------------------------
351 Bool_t AliTrackDiHadronPID::CopyMCInfo() {
353 // Copies MC info (needs an MC track with the same label)
355 // Check if the label of the current track matches the label of the
356 // generated particle. Note that the label of the AOD track can be
357 // negative. This means that the quality of this track is not awesome,
358 // but that it does correspond to the MC particle.
360 if (fDebug) {cout << Form("File: %s, Line: %i, Function: %s",__FILE__,__LINE__,__func__) << endl;}
363 if (fAODMCParticle->Label() != TMath::Abs(fAODTrack->GetLabel())) {
364 cout<<"Label of supplied MC particle and reconstructed track do not match."<<endl;
368 // Note: It seems like the Label of the AOD track points to the INDEX of the
369 // MCPArticle, not to the label (See AliAnalysisTaskCompareAODTrackCuts.cxx)
371 fMCPt = fAODMCParticle->Pt();
372 fMCEta = fAODMCParticle->Eta();
373 fMCPhi = fAODMCParticle->Phi();
374 fMCY = fAODMCParticle->Y();
375 fPdgCode = fAODMCParticle->PdgCode();
377 TClonesArray* mcArray = 0x0;
378 mcArray = dynamic_cast<TClonesArray*>(fAODEvent->FindListObject(AliAODMCParticle::StdBranchName()));
380 AliFatal("No MC array found in the AOD.");
384 if ( fAODMCParticle->IsPhysicalPrimary() ){
385 fIsPhysicalPrimary = kTRUE;
387 // Safety check for mother existence.
388 if (fAODMCParticle->GetMother() >= 0){
390 Int_t mcMotherPDG = -999;
391 Int_t firstInt = -999;
393 AliAODMCParticle* mcMother = (AliAODMCParticle*) mcArray->At(TMath::Abs(fAODMCParticle->GetMother()));
394 mcMotherPDG = TMath::Abs(mcMother->GetPdgCode());
396 // Need a way to get the first intiger, for now Marek's method:
397 firstInt = Int_t (mcMotherPDG/ TMath::Power(10, Int_t(TMath::Log10(mcMotherPDG))));
398 // cout<<"Mother PDG: "<<mcMotherPDG<<"; Firt integer: "<<firstInt<<endl;
402 fIsSecondaryFromWeakDecay = kTRUE;
405 fIsSecondaryFromMaterial = kTRUE;
410 fMCInfoAvailable = kTRUE;
411 return fMCInfoAvailable;