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 AliAnalysisTaskDxHFEParticleSelection.cxx
21 /// @author Sedat Altinpinar, Hege Erdal, Matthias Richter
23 /// @brief AnalysisTask electron selection for D0 - HFE correlation
26 #include "AliAnalysisTaskDxHFEParticleSelection.h"
27 #include "AliDxHFEParticleSelection.h"
28 #include "AliDxHFEParticleSelectionD0.h"
29 #include "AliDxHFEParticleSelectionMCD0.h"
30 #include "AliAnalysisManager.h"
31 #include "AliAnalysisCuts.h"
34 #include "AliESDInputHandler.h"
35 #include "AliAODHandler.h"
36 #include "AliAODRecoDecayHF2Prong.h"
37 #include "AliRDHFCutsD0toKpi.h"
41 #include "TObjArray.h"
46 /// ROOT macro for the implementation of ROOT specific class methods
47 ClassImp(AliAnalysisTaskDxHFEParticleSelection)
49 AliAnalysisTaskDxHFEParticleSelection::AliAnalysisTaskDxHFEParticleSelection(const char* opt)
50 : AliAnalysisTaskSE("AliAnalysisTaskDxHFEParticleSelection")
65 int AliAnalysisTaskDxHFEParticleSelection::DefineSlots()
67 // define the data slots
68 DefineInput(0, TChain::Class());
69 DefineOutput(1, TList::Class());
73 AliAnalysisTaskDxHFEParticleSelection::~AliAnalysisTaskDxHFEParticleSelection()
79 // histograms are in the output list and deleted when the output
80 // list is deleted by the TSelector dtor
82 if (fOutput && !AliAnalysisManager::GetAnalysisManager()->IsProofMode()) {
99 void AliAnalysisTaskDxHFEParticleSelection::UserCreateOutputObjects()
101 // create result objects and add to output list
106 // setting up for D0s
107 TString selectionD0Options;
108 switch (fFillOnlyD0D0bar) {
109 case 1: selectionD0Options+="FillOnlyD0 "; break;
110 case 2: selectionD0Options+="FillOnlyD0bar "; break;
111 default: selectionD0Options+="FillD0D0bar ";
114 if(fUseMC) fSelector=new AliDxHFEParticleSelectionMCD0(selectionD0Options);
115 else fSelector=new AliDxHFEParticleSelectionD0(selectionD0Options);
116 fSelector->SetCuts(fCuts);
119 // Retrieving the list containing histos and THnSparse
120 // and storing them instead of fSelector
121 // Fix to be able to merge
122 TList *list =(TList*)fSelector->GetControlObjects();
126 while((obj = next())){
130 // all tasks must post data once for all outputs
131 PostData(1, fOutput);
134 void AliAnalysisTaskDxHFEParticleSelection::UserExec(Option_t* /*option*/)
138 // TODO: implement correct input, this is likely not to be the
140 TObject* pInput=InputEvent();
142 AliError("failed to get input");
146 // check if input is an ESD
147 AliVEvent *pEvent = dynamic_cast<AliVEvent*>(pInput);
148 TClonesArray *inputArray=0;
150 if(!pEvent && AODEvent() && IsStandardAOD()) { //Not sure if this is needed.. Keep it for now.
151 // In case there is an AOD handler writing a standard AOD, use the AOD
152 // event in memory rather than the input (ESD) event.
154 // in this case the braches in the deltaAOD (AliAOD.VertexingHF.root)
155 // have to taken from the AOD event hold by the AliAODExtension
156 AliAODHandler* aodHandler = (AliAODHandler*)
157 ((AliAnalysisManager::GetAnalysisManager())->GetOutputEventHandler());
159 if(aodHandler->GetExtensions()) {
160 AliAODExtension *ext = (AliAODExtension*)aodHandler->GetExtensions()->FindObject("AliAOD.VertexingHF.root");
161 AliAODEvent* aodFromExt = ext->GetAOD();
162 inputArray=(TClonesArray*)aodFromExt->GetList()->FindObject("D0toKpi");
165 inputArray=(TClonesArray*)pEvent->GetList()->FindObject("D0toKpi");
167 if(!inputArray || !pEvent) {
168 AliError("Input branch not found!\n");
171 // fix for temporary bug in ESDfilter
172 // the AODs with null vertex pointer didn't pass the PhysSel
173 if(!pEvent->GetPrimaryVertex() || TMath::Abs(pEvent->GetMagneticField())<0.001){
174 AliDebug(2,"Rejected at GetPrimaryvertex");
178 fSelector->HistogramEventProperties(AliDxHFEParticleSelection::kEventsAll);
179 AliRDHFCuts* cuts=dynamic_cast<AliRDHFCuts*>(fCuts);
180 if (!cuts) return; // Fatal thrown already in initialization
182 if(!cuts->IsEventSelected(pEvent)) {
183 AliDebug(2,"rejected at IsEventSelected");
187 // Int_t nInD0toKpi = inputArray->GetEntriesFast();
189 fSelector->HistogramEventProperties(AliDxHFEParticleSelection::kEventsSel);
191 std::auto_ptr<TObjArray> selectedTracks(fSelector->Select(inputArray,pEvent));
192 // TODO: use the array of selected track for something, right now
193 // only the control histograms of the selection class are filled
194 // note: the pointer is deleted automatically once the scope is left
195 // if the array should be published, the auto pointer must be released
196 // first, however some other cleanup will be necessary in that case
197 // probably a clone with a reduced AliVParticle implementation is
200 if(! selectedTracks.get()) {
201 cout << "No selected D0s in this event" << endl;
205 //Test to see if I have read in D0s and retrieved them after selection
206 Int_t nD0Selected = selectedTracks->GetEntriesFast();
208 fSelector->HistogramEventProperties(AliDxHFEParticleSelection::kEventsWithParticle);
210 for(Int_t iD0toKpi = 0; iD0toKpi < nD0Selected; iD0toKpi++) {
211 AliAODRecoDecayHF2Prong *particle = (AliAODRecoDecayHF2Prong*)selectedTracks->UncheckedAt(iD0toKpi);
212 if (!particle) continue;
215 PostData(1, fOutput);
218 void AliAnalysisTaskDxHFEParticleSelection::FinishTaskOutput()
220 // end of the processing
223 void AliAnalysisTaskDxHFEParticleSelection::Terminate(Option_t *)
225 // last action on the client
226 fOutput = dynamic_cast<TList*> (GetOutputData(1));
228 AliFatal("failed to get output container");