]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG3/hfe/AliHFEtaggedTrackAnalysis.cxx
9cef6086ca51fb53aae7a2bc0faf1326072427b9
[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 // Class AliHFEtaggedTrackAnalysis
17 // Analyses tracks with an apriori PID information (i.e. using the daugther
18 // tracks from well-identified decays of neutral charged particles). Tracks
19 // are processed in the Process function, where given tracks are filtered 
20 // via the track cuts and used for PID later. The plugin fills Correction
21 // Framework containers and additional PID QA containers
22 //
23 // Author:
24 //   Markus Fasel <M.Fasel@gsi.de>
25 //
26 #include "AliCFCutBase.h"
27 #include "AliCFContainer.h"
28 #include "AliCFManager.h"
29 #include "AliLog.h"
30 #include "AliPID.h"
31
32 #include "AliHFEcontainer.h"
33 #include "AliHFEcuts.h"
34 #include "AliHFEpid.h"
35 #include "AliHFEpidTPC.h"
36 #include "AliHFEpidQAmanager.h"
37 #include "AliHFEtaggedTrackAnalysis.h"
38 #include "AliHFEvarManager.h"
39
40 ClassImp(AliHFEtaggedTrackAnalysis)
41
42 //____________________________________________________________
43 AliHFEtaggedTrackAnalysis::AliHFEtaggedTrackAnalysis():
44     TObject()
45   , fVarManager(NULL)
46   , fContainer(NULL)
47   , fPID(NULL)
48   , fPIDqa(NULL)
49   , fCuts(NULL)
50   , fCFM(NULL)
51   , fClean(kFALSE)
52 {
53   //
54   // Default constructor
55   //
56   fVarManager = new AliHFEvarManager("taggedTrackVarManager");
57   fVarManager->AddVariable("pt");
58   fVarManager->AddVariable("eta");
59   fVarManager->AddVariable("phi");
60   fVarManager->AddVariable("charge");
61   fVarManager->AddVariable("species");
62   fPIDqa = new AliHFEpidQAmanager;
63   fCFM = new AliCFManager;
64   SetBit(kIsOwner, kTRUE);
65 }
66
67 //____________________________________________________________
68 AliHFEtaggedTrackAnalysis::AliHFEtaggedTrackAnalysis(const AliHFEtaggedTrackAnalysis &ref):
69     TObject(ref)
70   , fVarManager(ref.fVarManager)
71   , fContainer(NULL)
72   , fPID(ref.fPID)
73   , fPIDqa(ref.fPIDqa)
74   , fCuts(ref.fCuts)
75   , fCFM(ref.fCFM)
76   , fClean(ref.fClean)
77 {
78   //
79   // Copy constructor
80   //
81   if(ref.fContainer){
82     InitContainer();
83   }
84   SetBit(kIsOwner, kFALSE);
85 }
86
87 //____________________________________________________________
88 AliHFEtaggedTrackAnalysis &AliHFEtaggedTrackAnalysis::operator=(const AliHFEtaggedTrackAnalysis &ref){
89   //
90   // Assignment operator
91   //
92   if(&ref != this){
93     fVarManager = ref.fVarManager;
94     fPID = ref.fPID;
95     fPIDqa = ref.fPIDqa;
96     fCuts = ref.fCuts;
97     fCFM = ref.fCFM;
98     fClean = ref.fClean;
99
100     if(ref.fContainer) InitContainer();
101    
102     SetBit(kIsOwner, kFALSE); 
103     SetBit(kIsOwnerCuts, kFALSE);
104   }
105   return *this;
106 }
107
108 //____________________________________________________________
109 AliHFEtaggedTrackAnalysis::~AliHFEtaggedTrackAnalysis(){
110   //
111   // Destructor
112   //
113   if(TestBit(kIsOwner)){
114     if(fVarManager) delete fVarManager;
115     if(fPIDqa) delete fPIDqa;
116   }
117   if(TestBit(kIsOwnerCuts)) delete fCuts;
118   if(fContainer) delete fContainer;
119 }
120
121 //____________________________________________________________
122 void AliHFEtaggedTrackAnalysis::InitContainer(){
123   //
124   // Initialize output container
125   //
126   if(fContainer) return;
127   Int_t nStepPID = 0;
128   if(!fPID){
129     AliError("No PID set - defining container without PID steps");
130   } else {
131     nStepPID = fPID->GetNumberOfPIDdetectors();
132   }
133   fContainer = new AliHFEcontainer("containerV0");
134   fVarManager->DefineVariables(fContainer);
135   fContainer->CreateContainer("taggedTrackContainerReco", "Container for Tagged Tracks", AliHFEcuts::kNcutStepsRecTrack + nStepPID);
136
137   // Set the step titles
138   for(Int_t istep = 0; istep < AliHFEcuts::kNcutStepsRecTrack; istep++)
139     fContainer->SetStepTitle("taggedTrackContainerReco", AliHFEcuts::RecoCutName(istep), istep);
140   for(Int_t ipid = 0; ipid < nStepPID; ipid++){
141     fContainer->SetStepTitle("taggedTrackContainerReco", fPID->SortedDetectorName(ipid), ipid + AliHFEcuts::kNcutStepsRecTrack);
142   }
143   fCFM->SetParticleContainer(fContainer->GetCFContainer("taggedTrackContainerReco"));
144 }
145
146 //____________________________________________________________
147 void AliHFEtaggedTrackAnalysis::ProcessTrack(AliVParticle *track, Int_t abinitioPID){
148   //
149   // Filter tracks tagged by V0 PID class
150   //
151   fVarManager->NewTrack(track, NULL, 0., abinitioPID, kTRUE);
152   Int_t offset = AliHFEcuts::kStepRecKineITSTPC;
153   fVarManager->FillContainer(fCFM->GetParticleContainer(), 0); // Fill Container without filtering
154   
155   Bool_t survived = kTRUE;
156   for(Int_t icut = AliHFEcuts::kStepRecKineITSTPC; icut <= AliHFEcuts::kStepHFEcutsTRD; icut++){
157     AliDebug(2, Form("Checking cut %d for species %s", icut + AliHFEcuts::kNcutStepsMCTrack, AliPID::ParticleName(abinitioPID)));
158   /*
159     TObjArray *cutlist = fCFM->GetParticleCutsList(icut + AliHFEcuts::kNcutStepsMCTrack);
160     if(!cutlist){
161       AliDebug(2, Form("No cuts for step %d set", icut + AliHFEcuts::kNcutStepsMCTrack));
162     } else {
163       AliDebug(2, Form("Cut Collection %s", cutlist->GetName()));
164       TIter cutiter(cutlist);
165       AliCFCutBase *cut;
166       while((cut = dynamic_cast<AliCFCutBase *>(cutiter()))){
167         AliDebug(2, Form("Cut object %s, QA on? %s", cut->GetName(), cut->IsQAOn() ? "yes" : "no"));
168       }
169     }
170   */
171     //if(!fCFM->CheckParticleCuts(icut + AliHFEcuts::kNcutStepsMCTrack, (TObject *)track)){
172     if(!fCuts->CheckParticleCuts(icut + AliHFEcuts::kNcutStepsMCTrack, (TObject *)track)){
173       AliDebug(2, Form("Track didn' survive cut %d", icut + AliHFEcuts::kNcutStepsMCTrack));
174       survived = kFALSE;
175       break;
176     }
177     AliDebug(2, Form("Cut passed, filling container %d", icut - offset + 1));
178     fVarManager->FillContainer(fCFM->GetParticleContainer(), icut - offset + 1);
179   }
180   if(survived){
181     AliDebug(2, "Use track in the PID");
182     // Try a loose cut to reject pion contamination
183     if(fClean) {
184       if(abinitioPID == AliPID::kElectron){
185         AliHFEpidTPC *pidTPC = (AliHFEpidTPC *) fPID->GetDetPID(AliHFEpid::kTPCpid);
186         if(pidTPC) {
187           Double_t numberOfSigmaTPC = pidTPC->NumberOfSigmas(track,AliPID::kElectron,AliHFEpidObject::kESDanalysis);
188           if(numberOfSigmaTPC < -5) return;
189         }
190       }
191     }
192     // Apply PID
193     AliHFEpidObject hfetrack;
194     hfetrack.SetAnalysisType(AliHFEpidObject::kESDanalysis);
195     hfetrack.SetRecTrack(track);
196     hfetrack.SetAbInitioPID(abinitioPID);
197     fPID->SetVarManager(fVarManager);
198     fPID->IsSelected(&hfetrack, fContainer, "taggedTrackContainer", fPIDqa);
199   }
200 }
201
202 //____________________________________________________________
203 void AliHFEtaggedTrackAnalysis::SetCuts(AliHFEcuts *cuts){
204   //
205   // Set HFE cuts to be used to filter the tagged tracks
206   //
207   if(!cuts){
208     AliWarning("Nob cuts provided - Using standard cuts");
209     fCuts = new AliHFEcuts("cutsTagged", "HFE Cuts for the V0 tagged tracks");
210     fCuts->CreateStandardCuts();
211     fCuts->SetQAOn();
212     SetBit(kIsOwnerCuts);
213   }
214   AliDebug(1, "Setting single track cuts");
215   fCuts = cuts;
216   const Int_t kNcutSteps = AliHFEcuts::kNcutStepsMCTrack + AliHFEcuts::kNcutStepsRecTrack + AliHFEcuts::kNcutStepsDETrack;
217   printf("Setting Number of cut steps %d\n", kNcutSteps);
218   fCFM->SetNStepParticle(kNcutSteps);
219   for(Int_t istep = 0; istep < kNcutSteps; istep++)
220     fCFM->SetParticleCutsList(istep, NULL);
221
222   fCuts->Initialize(fCFM); 
223 }
224
225 //____________________________________________________________
226 void AliHFEtaggedTrackAnalysis::SetPID(AliHFEpid *pid){
227   //
228   // Set the PID and initialize the the QA manager
229   //
230   fPID = pid;
231   fPIDqa->Initialize(fPID);
232 }
233
234 //____________________________________________________________
235 TList *AliHFEtaggedTrackAnalysis::GetPIDQA() const {
236   //
237   // return PID QA 
238   //
239   return fPIDqa->MakeList("PIDqa_taggedTracks");
240 }
241
242 //____________________________________________________________
243 TList *AliHFEtaggedTrackAnalysis::GetCutQA() const {
244   //
245   // return Cut QA
246   //
247   return fCuts->GetQAhistograms();
248 }
249