]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGCF/Correlations/DPhi/TriggerPID/AliTwoParticlePIDCorrKine.cxx
3aa62844a22b8bca6cea04d9507092375ffe9331
[u/mrichter/AliRoot.git] / PWGCF / Correlations / DPhi / TriggerPID / AliTwoParticlePIDCorrKine.cxx
1 #include "TChain.h"
2
3 #include "AliAnalysisDataSlot.h"
4 #include "AliAnalysisDataContainer.h"
5 #include "AliAnalysisManager.h"
6 #include "AliMCEvent.h"
7 #include "AliVEvent.h"
8 #include "AliTwoParticlePIDCorrKine.h"
9 #include "AliGenEventHeader.h"
10 #include "AliCollisionGeometry.h"
11 #include "AliVEvent.h"
12 #include "AliVParticle.h"
13
14
15 ClassImp(AliTwoParticlePIDCorrKine)
16
17 //____________________________________________| Constructor
18 AliTwoParticlePIDCorrKine::AliTwoParticlePIDCorrKine():
19 fEvent(0x0),
20 fMcHandler(0x0),
21   fHistEventsProcessed(0x0),
22   fOutputList(0),
23   fHistZvtx(0),
24   fHistPt(0),
25   fHistImpact(0x0),
26 fZvtxLim(10),
27 fCentralityFrom("Impact"),
28 fCentralityEstimator("V0M")
29
30 {
31   //Default constructor 
32 }
33
34 //____________________________________________| Specific Constructor
35 AliTwoParticlePIDCorrKine::AliTwoParticlePIDCorrKine(const Char_t* name) :
36   AliAnalysisTaskSE(name),
37 fEvent(0x0),
38 fMcHandler(0x0),
39   fHistEventsProcessed(0x0),
40   fOutputList(0),
41   fHistZvtx(0),
42   fHistPt(0),
43   fHistImpact(0x0),
44 fZvtxLim(10),
45 fCentralityFrom("Impact"),
46 fCentralityEstimator("V0M")
47 {
48   // Constructor. Initialization of Inputs and Outputs
49   Info("AliTwoParticlePIDCorrKine","Calling Constructor");
50   // Output slot #1 writes into a TList container (nevents histogram)
51     DefineInput(0, TChain::Class());
52     DefineOutput(1,TList::Class()); // Basic output slot (more needed)
53 }
54
55 //____________________________________________| Destructor
56 AliTwoParticlePIDCorrKine::~AliTwoParticlePIDCorrKine()
57 {
58   // Destructor
59   Info("~AliTwoParticlePIDCorrKine","Calling Destructor");
60   if (fHistEventsProcessed) delete fHistEventsProcessed;
61   if (fOutputList) delete fOutputList;
62   if (fHistZvtx) delete fHistZvtx;
63   if (fHistPt) delete fHistPt;
64
65 }
66
67 //___________________________________________________________________________
68 void AliTwoParticlePIDCorrKine::UserCreateOutputObjects()
69 {
70
71   //    AliAnalysisManager *man=AliAnalysisManager::GetAnalysisManager();
72   //      AliInputEventHandler* inputHandler = (AliInputEventHandler*) (man->GetInputEventHandler());
73     
74     Info("CreateOutputObjects","CreateOutputObjects of task %s", GetName());
75     fOutputList = new TList();
76     fOutputList->SetOwner(kTRUE);
77     //    fOutputList->SetName("KineTest");
78
79
80     fHistEventsProcessed = new TH1F("fHistNEvents","fHistEventsProcessed",3,-0.5,2.5) ;
81     fHistEventsProcessed->GetXaxis()->SetBinLabel(1,"All events");
82     fHistEventsProcessed->GetXaxis()->SetBinLabel(2,"Event within |Ztx| 10cm");
83     fHistEventsProcessed->GetXaxis()->SetBinLabel(3,"Good Reconstructed events");
84     
85     
86     fHistPt = new TH1F("fHistPt", "P_{T} distribution", 15, 0.1, 3.1);
87     fHistPt->GetXaxis()->SetTitle("P_{T} (GeV/c)");
88     fHistPt->GetYaxis()->SetTitle("dN/dP_{T} (c/GeV)");
89     fHistPt->SetMarkerStyle(kFullCircle);
90     
91     fHistZvtx = new TH1F("fHistZvtx", "Zvtx distribution", 40, -20, 20);
92     fHistZvtx->GetXaxis()->SetTitle("ZVtx (cm)");
93     fHistZvtx->GetYaxis()->SetTitle("Nch");
94     fHistZvtx->SetMarkerStyle(kFullCircle);
95
96     fHistImpact = new TH1F ("fHistImpact","ImpactParameter_Dist", 100,0.0,20.0);
97     
98     fOutputList->Add(fHistEventsProcessed);
99     fOutputList->Add(fHistZvtx);
100     fOutputList->Add(fHistPt);
101     fOutputList->Add(fHistImpact);
102
103     PostData(1, fOutputList);
104
105     
106     return;
107 }
108
109
110
111 //____________________________________________| User Exec
112 void AliTwoParticlePIDCorrKine::UserExec(Option_t *)
113 {
114   
115  // fMcHandler = dynamic_cast<AliInputEventHandler*> (AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler()); //get handler
116 //if(!fMCHandler) return;
117
118  fEvent = dynamic_cast<AliVEvent*>(MCEvent());
119   if(!fEvent)
120     {
121       //AliError("event not available");
122       return;
123     }
124
125
126     fHistEventsProcessed->Fill(0.0); // # of Event after passing MC cuts
127     
128     
129
130
131        
132     
133     const AliVVertex *vtxMC = fEvent->GetPrimaryVertex();
134     Float_t zVtx = vtxMC->GetZ();
135     if(TMath::Abs(zVtx) < fZvtxLim)fHistZvtx->Fill(zVtx);
136     else return;
137
138 fHistEventsProcessed->Fill(1.0);
139
140   Double_t gImpactParameter = 0.;
141   //Double_t  gMultiplicity = 0.;
142   Double_t gReactionPlane=0.0;
143   //Double_t gCentrality=0.0;
144
145  AliMCEvent *gMCEvent = dynamic_cast<AliMCEvent*>(fEvent);
146   if(gMCEvent){
147 AliCollisionGeometry* headerH = dynamic_cast<AliCollisionGeometry*>(gMCEvent->GenEventHeader());
148     if(headerH){
149       gImpactParameter = headerH->ImpactParameter();
150       //gMultiplicity =    GenMultiplicity(event); //calculate the multiplicity depending on the choice of centrality estimator                                           
151       gReactionPlane=     headerH->ReactionPlaneAngle();
152      // gCentrality = (CentralityFrom =="Multiplicity") ? gImpactParameter :gMultiplicity;
153     }
154 }
155   
156         fHistImpact->Fill(gImpactParameter);
157   
158      // # of Event after passing MC cuts
159
160     //Printf("MC particles: %d", fEvent->GetNumberOfTracks());
161     
162     for (Int_t iTracks = 0; iTracks < fEvent->GetNumberOfTracks(); iTracks++) {
163         AliVParticle* track = fEvent->GetTrack(iTracks);
164        if (!track) {
165       //AliError(Form("Could not receive particle %d", iTracks));
166       continue;
167     }
168
169         fHistPt->Fill(track->Pt());
170     }
171     
172     
173     fHistEventsProcessed->Fill(2.0); // # of Event after passing MC cuts
174
175   PostData(1, fOutputList);
176   return;
177 }
178
179
180 //___________________________________________________________________________
181 void AliTwoParticlePIDCorrKine::Terminate(Option_t*)
182 {
183   
184   Info("Terminate","Start and end of Method");
185   AliAnalysisTaskSE::Terminate();
186     
187   fOutputList = dynamic_cast<TList*> (GetOutputData(1));
188   if (!fOutputList) {
189         Printf("ERROR: Output list not available");
190         return;
191   }
192
193 }