]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG3/hfe/AliHFEtaggedTrackAnalysis.cxx
Adding Id to PWG3 classes for better tracking of the coverity defect fixes (Ivana)
[u/mrichter/AliRoot.git] / PWG3 / hfe / AliHFEtaggedTrackAnalysis.cxx
1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 *                                                                        *
4 * Author: The ALICE Off-line Project.                                    *
5 * Contributors are mentioned in the code where appropriate.              *
6 *                                                                        *
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 **************************************************************************/
15
16 /* $Id$ */
17
18 //
19 // Class AliHFEtaggedTrackAnalysis
20 // Analyses tracks with an apriori PID information (i.e. using the daugther
21 // tracks from well-identified decays of neutral charged particles). Tracks
22 // are processed in the Process function, where given tracks are filtered 
23 // via the track cuts and used for PID later. The plugin fills Correction
24 // Framework containers and additional PID QA containers
25 //
26 // Author:
27 //   Markus Fasel <M.Fasel@gsi.de>
28 //
29 #include "AliCFCutBase.h"
30 #include "AliCFContainer.h"
31 #include "AliCFManager.h"
32 #include "AliESDtrack.h"
33 #include "AliLog.h"
34 #include "AliPID.h"
35 #include "AliExternalTrackParam.h"
36
37 #include "AliHFEcollection.h"
38 #include "AliHFEcontainer.h"
39 #include "AliHFEcuts.h"
40 #include "AliHFEpid.h"
41 #include "AliHFEpidTPC.h"
42 #include "AliHFEpidQAmanager.h"
43 #include "AliHFEtaggedTrackAnalysis.h"
44 #include "AliHFEvarManager.h"
45
46 ClassImp(AliHFEtaggedTrackAnalysis)
47
48 //____________________________________________________________
49 AliHFEtaggedTrackAnalysis::AliHFEtaggedTrackAnalysis():
50     TObject()
51   , fVarManager(NULL)
52   , fContainer(NULL)
53   , fPID(NULL)
54   , fPIDqa(NULL)
55   , fCuts(NULL)
56   , fCFM(NULL)
57   , fQAhistos(NULL)
58   , fClean(kFALSE)
59   , fMagneticField(0.0)
60   , fVariablesTRD(kFALSE)
61 {
62   //
63   // Default constructor
64   //
65   fVarManager = new AliHFEvarManager("taggedTrackVarManager");
66   fVarManager->AddVariable("pt");
67   fVarManager->AddVariable("eta");
68   fVarManager->AddVariable("phi");
69   fVarManager->AddVariable("charge");
70   fVarManager->AddVariable("species");
71   fPIDqa = new AliHFEpidQAmanager;
72   fCFM = new AliCFManager;
73   SetBit(kIsOwner, kTRUE);
74 }
75
76 //____________________________________________________________
77 AliHFEtaggedTrackAnalysis::AliHFEtaggedTrackAnalysis(const AliHFEtaggedTrackAnalysis &ref):
78     TObject(ref)
79   , fVarManager(ref.fVarManager)
80   , fContainer(NULL)
81   , fPID(ref.fPID)
82   , fPIDqa(ref.fPIDqa)
83   , fCuts(ref.fCuts)
84   , fCFM(ref.fCFM)
85   , fQAhistos(ref.fQAhistos)
86   , fClean(ref.fClean)
87   , fMagneticField(ref.fMagneticField)
88   , fVariablesTRD(ref.fVariablesTRD)
89 {
90   //
91   // Copy constructor
92   //
93   if(ref.fContainer){
94     InitContainer();
95   }
96   SetBit(kIsOwner, kFALSE);
97 }
98
99 //____________________________________________________________
100 AliHFEtaggedTrackAnalysis &AliHFEtaggedTrackAnalysis::operator=(const AliHFEtaggedTrackAnalysis &ref){
101   //
102   // Assignment operator
103   //
104   if(&ref != this){
105     fVarManager = ref.fVarManager;
106     fPID = ref.fPID;
107     fPIDqa = ref.fPIDqa;
108     fCuts = ref.fCuts;
109     fCFM = ref.fCFM;
110     fQAhistos = ref.fQAhistos;
111     fClean = ref.fClean;
112     fMagneticField = ref.fMagneticField;
113     fVariablesTRD = ref.fVariablesTRD;
114
115     if(ref.fContainer) InitContainer();
116    
117     SetBit(kIsOwner, kFALSE); 
118     SetBit(kIsOwnerCuts, kFALSE);
119   }
120   return *this;
121 }
122
123 //____________________________________________________________
124 AliHFEtaggedTrackAnalysis::~AliHFEtaggedTrackAnalysis(){
125   //
126   // Destructor
127   //
128   if(TestBit(kIsOwner)){
129     if(fVarManager) delete fVarManager;
130     if(fPIDqa) delete fPIDqa;
131   }
132   if(TestBit(kIsOwnerCuts)) delete fCuts;
133   if(fContainer) delete fContainer;
134 }
135
136 //____________________________________________________________
137 void AliHFEtaggedTrackAnalysis::InitContainer(){
138   //
139   // Initialize output container
140   //
141   if(fContainer) return;
142   Int_t nStepPID = 0;
143   if(!fPID){
144     AliError("No PID set - defining container without PID steps");
145   } else {
146     nStepPID = fPID->GetNumberOfPIDdetectors();
147   }
148   fContainer = new AliHFEcontainer("containerV0");
149   fVarManager->DefineVariables(fContainer);
150   fContainer->CreateContainer("taggedTrackContainerReco", "Container for Tagged Tracks", AliHFEcuts::kNcutStepsRecTrack + nStepPID);
151
152   // Set the step titles
153   for(Int_t istep = 0; istep < AliHFEcuts::kNcutStepsRecTrack; istep++)
154     fContainer->SetStepTitle("taggedTrackContainerReco", AliHFEcuts::RecoCutName(istep), istep);
155   for(Int_t ipid = 0; ipid < nStepPID; ipid++){
156     fContainer->SetStepTitle("taggedTrackContainerReco", fPID->SortedDetectorName(ipid), ipid + AliHFEcuts::kNcutStepsRecTrack);
157   }
158   fCFM->SetParticleContainer(fContainer->GetCFContainer("taggedTrackContainerReco"));
159
160   // temporarily special QA
161   fQAhistos = new AliHFEcollection("taggedTrackQA", "Special QA for the TaggedTrackAnalysis");
162   fQAhistos->CreateTH2F("TPCclusters2_1", "TPCclusterInfo for findable clusters for 2 neighbors", 30, 0.1, 10., 162, 0., 161.);
163   fQAhistos->CreateTH2F("TPCclusters2_0", "TPCclusterInfo for the ratio for 2 neighbors", 30, 0.1, 10., 110, 0., 1.1);
164   fQAhistos->BinLogAxis("TPCclusters2_1", 0);   // pt axis in logarithmic binning
165   fQAhistos->BinLogAxis("TPCclusters2_0", 0);   // pt axis in logarithmic binning
166 }
167
168 //____________________________________________________________
169 void AliHFEtaggedTrackAnalysis::ProcessTrack(AliVParticle *track, Int_t abinitioPID){
170   //
171   // Filter tracks tagged by V0 PID class
172   //
173   //
174   fVarManager->NewTrack(track, NULL, 0., abinitioPID, kTRUE);
175
176
177
178   // Phi Angle
179   if(fVariablesTRD) {
180     AliESDtrack *esdtrackc = dynamic_cast<AliESDtrack *>(track);
181     if(esdtrackc) {
182       
183       const AliExternalTrackParam *trueparam = NULL;
184       if(esdtrackc->GetOuterParam()) {
185               trueparam = esdtrackc->GetOuterParam();
186               fVarManager->NewTrack((AliVParticle *)trueparam, NULL, 0., abinitioPID, kTRUE);
187       }
188       else return;
189     }
190   }
191   
192
193   // Try a loose cut to reject pion contamination
194   if(fClean) {
195     if(abinitioPID == AliPID::kElectron){
196       AliHFEpidTPC *pidTPC = (AliHFEpidTPC *) fPID->GetDetPID(AliHFEpid::kTPCpid);
197       if(pidTPC) {
198               Double_t numberOfSigmaTPC = pidTPC->NumberOfSigmas(track,AliPID::kElectron,AliHFEpidObject::kESDanalysis);
199               if(numberOfSigmaTPC < -5) return;
200       }
201     }
202   }
203   // temporarily monitoring of the number of TPC clusters 
204   AliESDtrack *esdtrack = dynamic_cast<AliESDtrack *>(track);
205   if(esdtrack && abinitioPID == AliPID::kElectron){
206     if((esdtrack->GetITSClusterMap() & (BIT(0) | BIT(1))) && (TMath::Abs(esdtrack->Eta()) < 0.8)){  // Only select quasi-primary tracks
207       fQAhistos->Fill("TPCclusters2_1", track->Pt(), esdtrack->GetTPCClusterInfo(2,1));
208       fQAhistos->Fill("TPCclusters2_0", track->Pt(), esdtrack->GetTPCNclsF() > 0 ? esdtrack->GetTPCClusterInfo(2,1)/esdtrack->GetTPCNclsF() : 0.);
209     }
210    }
211    
212   Int_t offset = AliHFEcuts::kStepRecKineITSTPC;
213   fVarManager->FillContainer(fCFM->GetParticleContainer(), 0); // Fill Container without filtering
214   
215   Bool_t survived = kTRUE;
216   for(Int_t icut = AliHFEcuts::kStepRecKineITSTPC; icut <= AliHFEcuts::kStepHFEcutsTRD; icut++){
217     AliDebug(2, Form("Checking cut %d for species %s", icut + AliHFEcuts::kNcutStepsMCTrack, AliPID::ParticleName(abinitioPID)));
218     /*
219       TObjArray *cutlist = fCFM->GetParticleCutsList(icut + AliHFEcuts::kNcutStepsMCTrack);
220       if(!cutlist){
221       AliDebug(2, Form("No cuts for step %d set", icut + AliHFEcuts::kNcutStepsMCTrack));
222       } else {
223       AliDebug(2, Form("Cut Collection %s", cutlist->GetName()));
224       TIter cutiter(cutlist);
225       AliCFCutBase *cut;
226       while((cut = dynamic_cast<AliCFCutBase *>(cutiter()))){
227       AliDebug(2, Form("Cut object %s, QA on? %s", cut->GetName(), cut->IsQAOn() ? "yes" : "no"));
228       }
229       }
230     */
231     //if(!fCFM->CheckParticleCuts(icut + AliHFEcuts::kNcutStepsMCTrack, (TObject *)track)){
232     if(!fCuts->CheckParticleCuts(icut + AliHFEcuts::kNcutStepsMCTrack, (TObject *)track)){
233       AliDebug(2, Form("Track didn' survive cut %d", icut + AliHFEcuts::kNcutStepsMCTrack));
234       survived = kFALSE;
235       break;
236     }
237     AliDebug(2, Form("Cut passed, filling container %d", icut - offset + 1));
238     fVarManager->FillContainer(fCFM->GetParticleContainer(), icut - offset + 1);
239   }
240   
241    if(survived){
242      AliDebug(2, "Use track in the PID");
243      // Apply PID
244      AliHFEpidObject hfetrack;
245      hfetrack.SetAnalysisType(AliHFEpidObject::kESDanalysis);
246      hfetrack.SetRecTrack(track);
247      hfetrack.SetAbInitioPID(abinitioPID);
248      fPID->SetVarManager(fVarManager);
249      fPID->IsSelected(&hfetrack, fContainer, "taggedTrackContainer", fPIDqa);
250    }
251 }
252
253 //____________________________________________________________
254 void AliHFEtaggedTrackAnalysis::SetCuts(AliHFEcuts *cuts){
255   //
256   // Set HFE cuts to be used to filter the tagged tracks
257   //
258   if(!cuts){
259     AliWarning("Nob cuts provided - Using standard cuts");
260     fCuts = new AliHFEcuts("cutsTagged", "HFE Cuts for the V0 tagged tracks");
261     fCuts->CreateStandardCuts();
262     fCuts->SetQAOn();
263     SetBit(kIsOwnerCuts);
264   } else {
265     AliDebug(1, "Setting single track cuts");
266     fCuts = cuts;
267   }
268   const Int_t kNcutSteps = AliHFEcuts::kNcutStepsMCTrack + AliHFEcuts::kNcutStepsRecTrack + AliHFEcuts::kNcutStepsDETrack;
269   printf("Setting Number of cut steps %d\n", kNcutSteps);
270   fCFM->SetNStepParticle(kNcutSteps);
271   for(Int_t istep = 0; istep < kNcutSteps; istep++)
272     fCFM->SetParticleCutsList(istep, NULL);
273
274   fCuts->Initialize(fCFM); 
275 }
276
277 //____________________________________________________________
278 void AliHFEtaggedTrackAnalysis::SetPID(AliHFEpid *pid){
279   //
280   // Set the PID and initialize the the QA manager
281   //
282   fPID = pid;
283   fPIDqa->Initialize(fPID);
284 }
285
286 //____________________________________________________________
287 TList *AliHFEtaggedTrackAnalysis::GetPIDQA() const {
288   //
289   // return PID QA 
290   //
291   return fPIDqa->MakeList("PIDqa_taggedTracks");
292 }
293
294 //____________________________________________________________
295 TList *AliHFEtaggedTrackAnalysis::GetCutQA() const {
296   //
297   // return Cut QA
298   //
299   return fCuts->GetQAhistograms();
300 }
301
302