fixed the reading of the FMD primary data (speed issue)
[u/mrichter/AliRoot.git] / FMD / analysis / AliFMDAnalysisTaskSE.cxx
1 #include "AliFMDAnalysisTaskSE.h"
2 #include "AliESDEvent.h"
3 #include "iostream"
4 #include "AliESDFMD.h"
5 #include "AliMCEventHandler.h"
6 #include "AliAnalysisManager.h"
7
8 ClassImp(AliFMDAnalysisTaskSE)
9
10 //_____________________________________________________________________
11 AliFMDAnalysisTaskSE::AliFMDAnalysisTaskSE():
12 AliAnalysisTaskSE(),
13   fListOfHistos(0),
14   fSharing("Sharing",kFALSE),
15   fDensity("Density",kFALSE),
16   fBackground("BackgroundCorrected",kFALSE),
17   fDndeta("dNdeta",kFALSE),
18   fPrimary(kTRUE),
19   fRecordHits(kFALSE)
20 {
21   // Default constructor
22 }
23 //_____________________________________________________________________
24 AliFMDAnalysisTaskSE::AliFMDAnalysisTaskSE(const char* name):
25   AliAnalysisTaskSE(name),
26   fListOfHistos(0),
27   fSharing("Sharing",kFALSE),
28   fDensity("Density",kFALSE),
29   fBackground("BackgroundCorrected",kFALSE),
30   fDndeta("dNdeta",kFALSE),
31   fPrimary(kTRUE),
32   fRecordHits(kFALSE)
33 {
34   
35   DefineOutput(1, TList::Class());
36 }
37 //_____________________________________________________________________
38 void AliFMDAnalysisTaskSE::UserCreateOutputObjects()
39 {
40 // Create the output containers
41 //
42   fListOfHistos = new TList();
43   
44   AliESDFMD* fmd = new AliESDFMD();
45   AliESDVertex* vertex = new AliESDVertex();
46   
47   TObjString* vtxString1 = new TObjString();
48   
49   TList* densitylist = new TList();
50   
51   TList* bgcorlist = new TList();
52   
53   fSharing.SetFMDData(fmd);
54   fSharing.SetVertex(vertex);
55   fSharing.SetOutputList(fListOfHistos);
56
57   fDensity.SetOutputList(densitylist);
58   fDensity.SetInputESDFMD(fmd) ;
59   fDensity.SetInputVertex(vertex);
60   
61   fBackground.SetInputList(densitylist);
62   fBackground.SetOutputList(bgcorlist);
63   fBackground.SetHitList(fListOfHistos);
64   fBackground.SetOutputVertex(vtxString1);
65   
66   fDndeta.SetInputVertex(vtxString1);
67   fDndeta.SetInputList(bgcorlist); 
68   fDndeta.SetOutputList(fListOfHistos); 
69   fDndeta.SetAnalyzePrimary(fPrimary);
70   fDndeta.SetRecordHits(fRecordHits);
71   fSharing.CreateOutputObjects();
72   fDensity.CreateOutputObjects();
73   fBackground.CreateOutputObjects();
74   fDndeta.CreateOutputObjects();
75   
76   
77   
78 }
79 //_____________________________________________________________________
80 void AliFMDAnalysisTaskSE::Init()
81 {
82   std::cout<<"Init"<<std::endl;
83 }
84 //_____________________________________________________________________
85 void AliFMDAnalysisTaskSE::UserExec(Option_t */*option*/)
86 {
87   // Execute analysis for current event
88   //
89   AliESDEvent* fESD = (AliESDEvent*)InputEvent();
90   fSharing.SetInputESD(fESD);
91   
92   fSharing.Exec("");
93   if(fSharing.GetEventStatus()) {
94     fDensity.Exec("");
95     if(fDensity.GetEventStatus()) {
96       fBackground.Exec("");  
97       //AliMCEvent* mcevent =  MCEvent();
98       if(fPrimary) {
99         AliMCEventHandler* eventHandler = dynamic_cast<AliMCEventHandler*> (AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler());
100         AliMCEvent* mcevent = eventHandler->MCEvent();
101         fDndeta.SetMCEvent(mcevent);
102       }
103       fDndeta.Exec("");
104       
105     }
106   }
107   else
108     return;
109   
110   //fListOfHistos = fBackground.GetOutputList();
111   
112   PostData(1, fListOfHistos);
113 }
114 //_____________________________________________________________________
115 void AliFMDAnalysisTaskSE::Terminate(Option_t */*option*/)
116 {
117   fDndeta.Terminate("");
118
119 }
120 //_____________________________________________________________________
121 //
122 // EOF
123 //