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