]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGHF/correlationHF/AliAnalysisTaskDxHFEParticleSelection.cxx
689983354708828872c4ca65534cd5c5b3d2c037
[u/mrichter/AliRoot.git] / PWGHF / correlationHF / AliAnalysisTaskDxHFEParticleSelection.cxx
1 // $Id$
2
3 //**************************************************************************
4 //* This file is property of and copyright by the ALICE Project            * 
5 //* ALICE Experiment at CERN, All rights reserved.                         *
6 //*                                                                        *
7 //* Primary Authors: Matthias Richter <Matthias.Richter@ift.uib.no>        *
8 //*                  Sedat Altinpinar <Sedat.Altinpinar@cern.ch>           *
9 //*                  Hege Erdal       <hege.erdal@gmail.com>               *
10 //*                                                                        *
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 //**************************************************************************
19
20 /// @file   AliAnalysisTaskDxHFEParticleSelection.cxx
21 /// @author Sedat Altinpinar, Hege Erdal, Matthias Richter
22 /// @date   2012-03-19
23 /// @brief  AnalysisTask electron selection for D0 - HFE correlation
24 ///
25
26 #include "AliAnalysisTaskDxHFEParticleSelection.h"
27 #include "AliDxHFEParticleSelection.h"
28 #include "AliDxHFEParticleSelectionD0.h"
29 #include "AliAnalysisManager.h"
30 #include "AliLog.h"
31 #include "AliESDInputHandler.h"
32 #include "TChain.h"
33 #include "TSystem.h"
34 #include "TFile.h"
35 #include <memory>
36
37 /// ROOT macro for the implementation of ROOT specific class methods
38 ClassImp(AliAnalysisTaskDxHFEParticleSelection)
39
40 AliAnalysisTaskDxHFEParticleSelection::AliAnalysisTaskDxHFEParticleSelection(const char* opt)
41   : AliAnalysisTaskSE("AliAnalysisTaskDxHFEParticleSelection")
42   , fOutput(0)
43   , fOption(opt)
44   , fSelector(NULL)
45 {
46   // constructor
47   //
48   //
49
50   DefineSlots();
51 }
52
53 int AliAnalysisTaskDxHFEParticleSelection::DefineSlots()
54 {
55   // define the data slots
56   DefineInput(0, TChain::Class());
57   DefineOutput(1, TList::Class());
58   return 0;
59 }
60
61 AliAnalysisTaskDxHFEParticleSelection::~AliAnalysisTaskDxHFEParticleSelection()
62 {
63   // destructor
64   //
65   //
66
67   // histograms are in the output list and deleted when the output
68   // list is deleted by the TSelector dtor
69
70   if (fOutput && !AliAnalysisManager::GetAnalysisManager()->IsProofMode()) {
71     delete fOutput;
72     fOutput = 0;
73   }
74
75   if (fSelector) {
76     fSelector->Clear();
77     delete fSelector;
78     fSelector=NULL;
79   }
80 }
81
82 void AliAnalysisTaskDxHFEParticleSelection::UserCreateOutputObjects()
83 {
84   // create result objects and add to output list
85
86   fOutput = new TList;
87   fOutput->SetOwner();
88
89   fSelector=new AliDxHFEParticleSelectionD0;
90   fSelector->InitControlObjects();
91   fOutput->Add(fSelector);
92   
93   // all tasks must post data once for all outputs
94   PostData(1, fOutput);
95 }
96
97 void AliAnalysisTaskDxHFEParticleSelection::UserExec(Option_t* /*option*/)
98 {
99   // process the event
100
101   // TODO: implement correct input, this is likely not to be the
102   // ESD
103   TObject* pInput=InputEvent();
104   if (!pInput) {
105     AliError("failed to get input");
106     return;
107   }
108   AliVEvent *pEvent = dynamic_cast<AliVEvent*>(pInput);
109   if(!pEvent){
110     AliError(Form("input of wrong class type %s, expecting AliVEvent", pInput->ClassName()));
111     return;
112   }
113
114   std::auto_ptr<TObjArray> selectedTracks(fSelector->Select(pEvent));
115   // TODO: use the array of selected track for something, right now
116   // only the control histograms of the selection class are filled
117   // note: the pointer is deleted automatically once the scope is left
118   // if the array should be published, the auto pointer must be released
119   // first, however some other cleanup will be necessary in that case
120   // probably a clone with a reduced AliVParticle implementation is
121   // appropriate.
122   if (selectedTracks.get()) {
123   }
124
125   PostData(1, fOutput);
126 }
127
128 void AliAnalysisTaskDxHFEParticleSelection::FinishTaskOutput()
129 {
130   // end of the processing
131 }
132
133 void AliAnalysisTaskDxHFEParticleSelection::Terminate(Option_t *)
134 {
135   // last action on the client
136   fOutput = dynamic_cast<TList*> (GetOutputData(1));
137   if (!fOutput) {
138     AliFatal("failed to get output container");
139     return;
140   }
141
142 }