3 //**************************************************************************
4 //* This file is property of and copyright by the ALICE Project *
5 //* ALICE Experiment at CERN, All rights reserved. *
7 //* Primary Authors: Matthias Richter <Matthias.Richter@ift.uib.no> *
8 //* Sedat Altinpinar <Sedat.Altinpinar@cern.ch> *
9 //* Hege Erdal <hege.erdal@gmail.com> *
11 //* Permission to use, copy, modify and distribute this software and its *
12 //* documentation strictly for non-commercial purposes is hereby granted *
13 //* without fee, provided that the above copyright notice appears in all *
14 //* copies and that both the copyright notice and this permission notice *
15 //* appear in the supporting documentation. The authors make no claims *
16 //* about the suitability of this software for any purpose. It is *
17 //* provided "as is" without express or implied warranty. *
18 //**************************************************************************
20 /// @file AliDxHFEParticleSelectionEl.cxx
21 /// @author Sedat Altinpinar, Hege Erdal, Matthias Richter
23 /// @brief D0 selection for D0-HFE correlation
25 #include "AliDxHFEParticleSelectionEl.h"
26 #include "AliVParticle.h"
27 #include "AliVEvent.h"
29 #include "AliPIDResponse.h"
30 #include "AliHFEcontainer.h"
31 #include "AliHFEpid.h"
32 #include "AliHFEpidBase.h"
33 #include "AliHFEtools.h"
34 #include "AliHFEcuts.h"
35 #include "AliAODTrack.h"
36 #include "AliAnalysisDataSlot.h"
37 #include "AliAnalysisDataContainer.h"
38 #include "AliAnalysisManager.h"
39 #include "AliCFManager.h"
40 #include "THnSparse.h"
43 #include "TObjArray.h"
50 /// ROOT macro for the implementation of ROOT specific class methods
51 ClassImp(AliDxHFEParticleSelectionEl)
53 AliDxHFEParticleSelectionEl::AliDxHFEParticleSelectionEl(const char* opt)
54 : AliDxHFEParticleSelection("electron", opt)
56 , fElectronProperties(NULL)
68 AliDxHFEParticleSelectionEl::~AliDxHFEParticleSelectionEl()
71 if (fElectronProperties) {
72 delete fElectronProperties;
73 fElectronProperties=NULL;
84 // NOTE: external objects fPID and fCuts are not deleted here
89 const char* AliDxHFEParticleSelectionEl::fgkTrackControlBinNames[]={
95 const char* AliDxHFEParticleSelectionEl::fgkCutBinNames[]={
105 int AliDxHFEParticleSelectionEl::Init()
112 // Implicit call to InitControlObjects() before setting up CFM and fCuts
114 iResult=AliDxHFEParticleSelection::Init();
115 if (iResult<0) return iResult;
117 //--------Initialize correction Framework and Cuts
118 // Consider moving this, either to separate function or
119 // add a set function for AliCFManager
120 // Do we need this? Can we just call AliHFEcuts::CheckParticleCuts
121 AliInfo("Setting up CFM");
122 fCFM = new AliCFManager;
123 // the setup of cut objects is done in AliHFEcuts::Initialize
124 // the ids used by this class must be the same, the code might be broken if
125 // the sequence in AliHFEcuts::Initialize is changed
126 const Int_t kNcutSteps = AliHFEcuts::kNcutStepsMCTrack + AliHFEcuts::kNcutStepsRecTrack + AliHFEcuts::kNcutStepsDETrack;
127 // reset pointers in the CF manager
128 fCFM->SetNStepParticle(kNcutSteps);
129 for(Int_t istep = 0; istep < kNcutSteps; istep++) {
130 fCFM->SetParticleCutsList(istep, NULL);
133 AliWarning("Cuts not available. Default cuts will be used");
134 fCuts = new AliHFEcuts;
135 fCuts->CreateStandardCuts();
137 // TODO: error handling?
138 fCuts->Initialize(fCFM);
144 THnSparse* AliDxHFEParticleSelectionEl::DefineTHnSparse() const
147 // Defines the THnSparse. For now, only calls CreatControlTHnSparse
148 const int thnSize = 3;
149 const double Pi=TMath::Pi();
151 name.Form("%s info", GetName());
155 int thnBins[thnSize] = { 1000, 200, 500};
156 double thnMin [thnSize] = { 0, 0, -1.};
157 double thnMax [thnSize] = { 100, 2*Pi, 1.};
159 return CreateControlTHnSparse(name,thnSize,thnBins,thnMin,thnMax,fgkTrackControlBinNames);
163 int AliDxHFEParticleSelectionEl::InitControlObjects()
165 /// init control and monitoring objects
166 AliInfo("Electron THnSparse");
168 fElectronProperties=DefineTHnSparse();
169 AddControlObject(fElectronProperties);
172 fWhichCut= new TH1F("fWhichCut","effective cut for a rejected particle",kNCutLabels,-0.5,kNCutLabels-0.5);
173 for (int iLabel=0; iLabel<kNCutLabels; iLabel++)
174 fWhichCut->GetXaxis()->SetBinLabel(iLabel+1, fgkCutBinNames[iLabel]);
175 AddControlObject(fWhichCut);
177 return AliDxHFEParticleSelection::InitControlObjects();
180 int AliDxHFEParticleSelectionEl::HistogramParticleProperties(AliVParticle* p, int selectionCode)
182 /// histogram particle properties
183 if (!p) return -EINVAL;
184 //if (!fControlObjects) return 0;
185 if(selectionCode==0) return 0;
186 // TODO: make array a member, consistent dimensions for THnSparse and array
187 Double_t eProperties[3]={0.0, 0.0, 0.0};
188 DefineParticleProperties(p, eProperties, 3);
189 if(fElectronProperties) fElectronProperties->Fill(eProperties);
194 int AliDxHFEParticleSelectionEl::DefineParticleProperties(AliVParticle* p, Double_t* data, int dimension) const
196 // fill the data array from the particle data
197 if (!data) return -EINVAL;
198 AliAODTrack *track=(AliAODTrack*)p;
199 if (!track) return -ENODATA;
201 // TODO: this corresponds to the THnSparse dimensions which is available in the same class
202 // use this consistently
203 const int requiredDimension=3;
204 if (dimension!=requiredDimension) {
205 // TODO: think about filling only the available data and throwing a warning
208 data[i++]=track->Pt();
209 data[i++]=track->Phi();
210 data[i++]=track->Eta();
215 int AliDxHFEParticleSelectionEl::IsSelected(AliVParticle* pEl, const AliVEvent* pEvent)
217 /// select El candidates
218 // TODO: How to handle MC? would be too much duplicate code if copy entire IsSelected.
220 AliAODTrack *track=(AliAODTrack*)pEl;
221 fCFM->SetRecEventInfo(pEvent);
223 //--------track cut selection-----------------------
225 // RecKine: ITSTPC cuts
226 if(!ProcessCutStep(AliHFEcuts::kStepRecKineITSTPC, track)){
227 fWhichCut->Fill(kRecKineITSTPC);
232 if(!ProcessCutStep(AliHFEcuts::kStepRecPrim, track)) {
233 fWhichCut->Fill(kRecPrim);
237 // HFEcuts: ITS layers cuts
238 if(!ProcessCutStep(AliHFEcuts::kStepHFEcutsITS, track)) {
239 fWhichCut->Fill(kHFEcutsITS);
243 // HFE cuts: TOF PID and mismatch flag
244 if(!ProcessCutStep(AliHFEcuts::kStepHFEcutsTOF, track)) {
245 fWhichCut->Fill(kHFEcutsTOF);
249 // HFE cuts: TPC PID cleanup
250 if(!ProcessCutStep(AliHFEcuts::kStepHFEcutsTPC, track)){
251 fWhichCut->Fill(kHFEcutsTPC);
255 // HFEcuts: Nb of tracklets TRD0
256 //if(!ProcessCutStep(AliHFEcuts::kStepHFEcutsTRD, track)) continue;
259 //--------PID selection-----------------------
260 AliHFEpidObject hfetrack;
261 hfetrack.SetAnalysisType(AliHFEpidObject::kAODanalysis);
262 hfetrack.SetRecTrack(track);
264 // TODO: configurable colliding system
265 //if(IsPbPb()) hfetrack.SetPbPb();
268 if(fPID && fPID->IsSelected(&hfetrack)) {
269 AliDebug(3,"Inside FilldPhi, electron is selected");
270 fWhichCut->Fill(kSelected);
274 fWhichCut->Fill(kPID);
279 void AliDxHFEParticleSelectionEl::SetCuts(TObject* cuts, int level)
282 if (level==kCutHFE) {
283 fCuts=dynamic_cast<AliHFEcuts*>(cuts);
284 if (!fCuts && cuts) {
285 AliError(Form("Cut object is not of required type AliHFEcuts but %s", cuts->ClassName()));
290 if (level==kCutPID) {
291 fPID=dynamic_cast<AliHFEpid*>(cuts);
293 AliError(Form("cuts object is not of required type AliHFEpid but %s", cuts->ClassName()));
299 //________________________________________________________________________
300 Bool_t AliDxHFEParticleSelectionEl::ProcessCutStep(Int_t cutStep, AliVParticle *track)
302 // Check single track cuts for a given cut step
303 const Int_t kMCOffset = AliHFEcuts::kNcutStepsMCTrack;
304 if(!fCFM->CheckParticleCuts(cutStep + kMCOffset, track)) return kFALSE;
305 //if(!fCuts->CheckParticleCuts(cutStep + kMCOffset, track)) return kFALSE;