1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
16 //-----------------------------------------------------------------------
17 // Author : R. Vernet, Consorzio Cometa - Catania (it)
18 //-----------------------------------------------------------------------
21 #include "AliCFRsnTask.h"
24 #include "TParticle.h"
27 #include "AliMCEvent.h"
28 #include "AliESDEvent.h"
29 #include "AliCFManager.h"
30 #include "AliCFCutBase.h"
31 #include "AliCFContainer.h"
32 #include "AliESDtrack.h"
34 #include "AliRsnDaughter.h"
35 #include "AliCFPair.h"
36 #include "AliRsnParticle.h"
38 //__________________________________________________________________________
39 AliCFRsnTask::AliCFRsnTask() :
43 fHistEventsProcessed(0x0)
49 //___________________________________________________________________________
50 AliCFRsnTask::AliCFRsnTask(const Char_t* name) :
51 AliAnalysisTaskSE(name),
54 fHistEventsProcessed(0x0)
57 // Constructor. Initialization of Inputs and Outputs
59 Info("AliCFRsnTask","Calling Constructor");
61 DefineInput(0) and DefineOutput(0)
62 are taken care of by AliAnalysisTaskSE constructor
64 DefineOutput(1,TH1I::Class());
65 DefineOutput(2,AliCFContainer::Class());
66 // DefineOutput(3,TList::Class());
69 //___________________________________________________________________________
70 AliCFRsnTask& AliCFRsnTask::operator=(const AliCFRsnTask& c)
73 // Assignment operator
76 AliAnalysisTaskSE::operator=(c) ;
78 fCFManager = c.fCFManager;
79 fHistEventsProcessed = c.fHistEventsProcessed;
84 //___________________________________________________________________________
85 AliCFRsnTask::AliCFRsnTask(const AliCFRsnTask& c) :
88 fCFManager(c.fCFManager),
89 fHistEventsProcessed(c.fHistEventsProcessed)
96 //___________________________________________________________________________
97 AliCFRsnTask::~AliCFRsnTask() {
101 Info("~AliCFRsnTask","Calling Destructor");
102 if (fCFManager) delete fCFManager ;
103 if (fHistEventsProcessed) delete fHistEventsProcessed ;
106 //_________________________________________________
107 void AliCFRsnTask::UserExec(Option_t *)
110 // Main loop function
112 Info("UserExec","") ;
114 AliESDEvent* fESD = dynamic_cast<AliESDEvent*>(fInputEvent);
116 Error("UserExec","NO ESD FOUND!");
120 if (!fMCEvent) Error("UserExec","NO MC INFO FOUND!");
121 fCFManager->SetEventInfo(fMCEvent);
123 AliStack* stack = fMCEvent->Stack();
125 // MC-event selection
126 Double_t containerInput[2] ;
128 //loop on the MC event
129 Info("UserExec","Looping on MC event");
130 for (Int_t ipart=0; ipart<stack->GetNprimary(); ipart++) {
131 AliMCParticle *mcPart = fMCEvent->GetTrack(ipart);
133 //check the MC-level cuts
134 if (!fCFManager->CheckParticleCuts(AliCFManager::kPartGenCuts,mcPart)) continue;
135 containerInput[0] = mcPart->Pt();
136 containerInput[1] = mcPart->Y() ;
137 //fill the container for Gen-level selection
138 fCFManager->GetParticleContainer()->Fill(containerInput,kStepGenerated);
140 //check the Acceptance-level cuts
141 if (!fCFManager->CheckParticleCuts(AliCFManager::kPartAccCuts,mcPart)) continue;
142 //fill the container for Acceptance-level selection
143 fCFManager->GetParticleContainer()->Fill(containerInput,kStepReconstructible);
147 //Now go to rec level
148 Info("UserExec","Looping on ESD event");
150 //SET THE ESD AS EVENT INFO IN RECONSTRUCTION CUTS
151 TObjArray* fCutsReco = fCFManager->GetParticleCutsList(AliCFManager::kPartRecCuts);
152 TObjArray* fCutsPID = fCFManager->GetParticleCutsList(AliCFManager::kPartSelCuts);
153 TObjArrayIter iter1(fCutsReco);
154 TObjArrayIter iter2(fCutsPID);
155 AliCFCutBase *cut = 0;
156 while ( (cut = (AliCFCutBase*)iter1.Next()) ) {
157 cut->SetEvtInfo(fESD);
159 while ( (cut = (AliCFCutBase*)iter2.Next()) ) {
160 cut->SetEvtInfo(fESD);
163 // Loop on negative tracks
164 for (Int_t iTrack1 = 0; iTrack1<fESD->GetNumberOfTracks(); iTrack1++) {
165 AliESDtrack* esdTrack1 = fESD->GetTrack(iTrack1);
167 if (esdTrack1->Charge()>=0) continue;
168 Int_t esdLabel1 = esdTrack1->GetLabel();
169 if (esdLabel1<0) continue;
171 //Loop on positive tracks
172 for (Int_t iTrack2 = 0; iTrack2<fESD->GetNumberOfTracks(); iTrack2++) {
173 AliESDtrack* esdTrack2 = fESD->GetTrack(iTrack2);
175 if (esdTrack2->Charge()<=0) continue;
176 Int_t esdLabel2 = esdTrack2->GetLabel();
177 if (esdLabel2<0) continue;
179 //Create Resonance daughter objects
180 AliRsnDaughter* tmp1 = new AliRsnDaughter(esdTrack1);
181 AliRsnDaughter* tmp2 = new AliRsnDaughter(esdTrack2);
182 AliRsnDaughter track1(*tmp1);
183 AliRsnDaughter track2(*tmp2);
187 //Set MC information to resonance daughters
188 TParticle *part1 = stack->Particle(esdLabel1);
189 track1.InitParticle(part1);
190 track1.GetParticle()->SetPDG(part1->GetPdgCode());
192 Int_t mother1 = part1->GetFirstMother();
193 track1.GetParticle()->SetMother(mother1);
195 TParticle *mum = stack->Particle(mother1);
196 track1.GetParticle()->SetMotherPDG(mum->GetPdgCode());
199 TParticle *part2 = stack->Particle(esdLabel2);
200 track2.InitParticle(part2);
201 track2.GetParticle()->SetPDG(part2->GetPdgCode());
203 Int_t mother2 = part2->GetFirstMother();
204 track2.GetParticle()->SetMother(mother2);
206 TParticle *mum = stack->Particle(mother2);
207 track2.GetParticle()->SetMotherPDG(mum->GetPdgCode());
210 //make a mother resonance from the 2 candidate daughters
211 AliRsnDaughter rsn = AliRsnDaughter::Sum(track1,track2) ;
212 AliCFPair pair(esdTrack1,esdTrack2); // This object is used for cuts (to be replaced)
214 //check if true resonance
215 if (rsn.GetParticle()->PDG() != fRsnPDG) continue;
216 if (!fCFManager->CheckParticleCuts(AliCFManager::kPartRecCuts,&pair)) continue;
218 //check if associated MC resonance passes the cuts
219 Int_t motherLabel=rsn.Label();
220 if (motherLabel<0) continue ;
221 AliMCParticle* mcRsn = fMCEvent->GetTrack(motherLabel);
222 if (!mcRsn) continue;
223 if (!fCFManager->CheckParticleCuts(AliCFManager::kPartGenCuts,mcRsn)) continue;
226 containerInput[0] = rsn.Pt() ;
227 containerInput[1] = GetRapidity(rsn.E(),rsn.Pz());
228 fCFManager->GetParticleContainer()->Fill(containerInput,kStepReconstructed) ;
230 if (!fCFManager->CheckParticleCuts(AliCFManager::kPartSelCuts,&pair)) continue ;
231 fCFManager->GetParticleContainer()->Fill(containerInput,kStepSelected);
235 fHistEventsProcessed->Fill(0);
236 /* PostData(0) is taken care of by AliAnalysisTaskSE */
237 PostData(1,fHistEventsProcessed) ;
238 PostData(2,fCFManager->GetParticleContainer()) ;
240 // TList * list = new TList();
241 // fCFManager->AddQAHistosToList(list);
242 // PostData(2,list) ;
246 //___________________________________________________________________________
247 void AliCFRsnTask::Terminate(Option_t*)
249 // The Terminate() function is the last function to be called during
250 // a query. It always runs on the client, it can be used to present
251 // the results graphically or save the results to file.
253 Info("Terminate","");
255 Double_t max1 = fCFManager->GetParticleContainer()->ShowProjection(0,0)->GetMaximum();
256 Double_t max2 = fCFManager->GetParticleContainer()->ShowProjection(1,0)->GetMaximum();
258 fCFManager->GetParticleContainer()->ShowProjection(0,0)->GetYaxis()->SetRangeUser(0,max1*1.2);
259 fCFManager->GetParticleContainer()->ShowProjection(0,1)->GetYaxis()->SetRangeUser(0,max1*1.2);
260 fCFManager->GetParticleContainer()->ShowProjection(0,2)->GetYaxis()->SetRangeUser(0,max1*1.2);
261 fCFManager->GetParticleContainer()->ShowProjection(0,3)->GetYaxis()->SetRangeUser(0,max1*1.2);
263 fCFManager->GetParticleContainer()->ShowProjection(1,0)->GetYaxis()->SetRangeUser(0,max2*1.2);
264 fCFManager->GetParticleContainer()->ShowProjection(1,1)->GetYaxis()->SetRangeUser(0,max2*1.2);
265 fCFManager->GetParticleContainer()->ShowProjection(1,2)->GetYaxis()->SetRangeUser(0,max2*1.2);
266 fCFManager->GetParticleContainer()->ShowProjection(1,3)->GetYaxis()->SetRangeUser(0,max2*1.2);
268 fCFManager->GetParticleContainer()->ShowProjection(0,0)->SetMarkerStyle(23) ;
269 fCFManager->GetParticleContainer()->ShowProjection(0,1)->SetMarkerStyle(24) ;
270 fCFManager->GetParticleContainer()->ShowProjection(0,2)->SetMarkerStyle(25) ;
271 fCFManager->GetParticleContainer()->ShowProjection(0,3)->SetMarkerStyle(26) ;
273 fCFManager->GetParticleContainer()->ShowProjection(1,0)->SetMarkerStyle(23) ;
274 fCFManager->GetParticleContainer()->ShowProjection(1,1)->SetMarkerStyle(24) ;
275 fCFManager->GetParticleContainer()->ShowProjection(1,2)->SetMarkerStyle(25) ;
276 fCFManager->GetParticleContainer()->ShowProjection(1,3)->SetMarkerStyle(26) ;
278 TCanvas * c =new TCanvas("c","",1400,800);
282 fCFManager->GetParticleContainer()->ShowProjection(0,0)->Draw("p");
284 fCFManager->GetParticleContainer()->ShowProjection(0,1)->Draw("p");
286 fCFManager->GetParticleContainer()->ShowProjection(0,2)->Draw("p");
288 fCFManager->GetParticleContainer()->ShowProjection(0,3)->Draw("p");
290 fCFManager->GetParticleContainer()->ShowProjection(1,0)->Draw("p");
292 fCFManager->GetParticleContainer()->ShowProjection(1,1)->Draw("p");
294 fCFManager->GetParticleContainer()->ShowProjection(1,2)->Draw("p");
296 fCFManager->GetParticleContainer()->ShowProjection(1,3)->Draw("p");
298 c->SaveAs("plots.eps");
300 delete fHistEventsProcessed ;
303 //___________________________________________________________________________
304 void AliCFRsnTask::UserCreateOutputObjects() {
305 //HERE ONE CAN CREATE OUTPUT OBJECTS, IN PARTICULAR IF THE OBJECT PARAMETERS DON'T NEED
306 //TO BE SET BEFORE THE EXECUTION OF THE TASK
308 Info("UserCreateOutputObjects","CreateOutputObjects of task %s\n", GetName());
312 fHistEventsProcessed = new TH1I("fHistEventsProcessed","",1,0,1) ;
315 //___________________________________________________________________________
316 Double_t AliCFRsnTask::GetRapidity(Double_t energy, Double_t pz) {
317 if (energy == pz || energy == -pz) {
318 printf("GetRapidity : ERROR : rapidity for 4-vector with E = Pz -- infinite result");
322 printf("GetRapidity : ERROR : rapidity for 4-vector with E = Pz -- infinite result");
325 Double_t y = 0.5 * log((energy + pz) / (energy - pz));