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 // Task to prepare efficiency and response matrix for unfolding
18 //-----------------------------------------------------------------------
19 // Author : R. Vernet, INFN - Catania (it)
20 //-----------------------------------------------------------------------
24 #include "AliCFTaskForUnfolding.h"
27 #include "TParticle.h"
29 #include "AliMCEvent.h"
30 #include "AliAnalysisManager.h"
31 #include "AliESDEvent.h"
32 #include "AliAODEvent.h"
33 #include "AliCFManager.h"
34 #include "AliCFCutBase.h"
35 #include "AliCFContainer.h"
37 #include "AliESDtrack.h"
39 #include "THnSparse.h"
42 ClassImp(AliCFTaskForUnfolding)
44 //__________________________________________________________________________
45 AliCFTaskForUnfolding::AliCFTaskForUnfolding() :
47 fHistEventsProcessed(0x0),
54 //___________________________________________________________________________
55 AliCFTaskForUnfolding::AliCFTaskForUnfolding(const Char_t* name) :
56 AliAnalysisTaskSE(name),
58 fHistEventsProcessed(0x0),
62 // Constructor. Initialization of Inputs and Outputs
64 Info("AliCFTaskForUnfolding","Calling Constructor");
67 DefineInput(0) and DefineOutput(0)
68 are taken care of by AliAnalysisTaskSE constructor
70 DefineOutput(1,TH1I::Class());
71 DefineOutput(2,AliCFContainer::Class());
72 DefineOutput(3,THnSparseD::Class());
75 //___________________________________________________________________________
76 AliCFTaskForUnfolding::~AliCFTaskForUnfolding() {
80 Info("~AliCFTaskForUnfolding","Calling Destructor");
81 if (fCFManager) delete fCFManager ;
82 if (fHistEventsProcessed) delete fHistEventsProcessed ;
83 if (fCorrelation) delete fCorrelation ;
86 //_________________________________________________
87 void AliCFTaskForUnfolding::UserExec(Option_t *)
94 AliVEvent* fEvent = fInputEvent ;
98 Error("UserExec","NO EVENT FOUND!");
102 if (!fMCEvent) Error("UserExec","NO MC INFO FOUND");
104 //pass the MC evt handler to the cuts that need it
105 fCFManager->SetMCEventInfo(fMCEvent);
107 // MC-event selection
108 Double_t containerInput[2] ;
110 //loop on the MC event
111 for (Int_t ipart=0; ipart<fMCEvent->GetNumberOfTracks(); ipart++) {
112 AliMCParticle *mcPart = (AliMCParticle*)fMCEvent->GetTrack(ipart);
114 if (!fCFManager->CheckParticleCuts(0,mcPart)) continue;
115 containerInput[0] = (Float_t)mcPart->Pt();
116 containerInput[1] = (Float_t)mcPart->Eta();
117 fCFManager->GetParticleContainer()->Fill(containerInput,0);
120 //Now go to rec level
121 for (Int_t iTrack = 0; iTrack<fEvent->GetNumberOfTracks(); iTrack++) {
123 track = fEvent->GetTrack(iTrack);
124 if (!fCFManager->CheckParticleCuts(1,track)) continue;
126 Int_t label = track->GetLabel();
127 if (label<0) continue;
128 AliMCParticle* mcPart = (AliMCParticle*)fMCEvent->GetTrack(label);
129 // check if this track was part of the signal
130 if (!fCFManager->CheckParticleCuts(0,mcPart)) continue;
135 Double_t pt=TMath::Sqrt(mom[0]*mom[0]+mom[1]*mom[1]);
136 containerInput[0] = pt;
137 containerInput[1] = track->Eta();
138 fCFManager->GetParticleContainer()->Fill(containerInput,1) ;
139 containerInput[0] = mcPart->Pt();
140 containerInput[1] = mcPart->Eta();
141 fCFManager->GetParticleContainer()->Fill(containerInput,2);
143 Double_t fill[4]; //fill response matrix
144 // dimensions 0&1 : pt,eta (Rec)
146 fill[1] = track->Eta();
147 // dimensions 2&3 : pt,eta (MC)
148 fill[2] = mcPart->Pt();
149 fill[3] = mcPart->Eta();
150 fCorrelation->Fill(fill);
153 fHistEventsProcessed->Fill(0);
155 /* PostData(0) is taken care of by AliAnalysisTaskSE */
156 PostData(1,fHistEventsProcessed) ;
157 PostData(2,fCFManager->GetParticleContainer()) ;
158 PostData(3,fCorrelation) ;
162 //___________________________________________________________________________
163 void AliCFTaskForUnfolding::Terminate(Option_t*)
165 // The Terminate() function is the last function to be called during
166 // a query. It always runs on the client, it can be used to present
167 // the results graphically or save the results to file.
169 Info("Terminate","");
170 AliAnalysisTaskSE::Terminate();
172 gStyle->SetPalette(1);
174 //draw some example plots....
176 AliCFContainer *cont= dynamic_cast<AliCFContainer*> (GetOutputData(2));
177 TH2D* h00 = cont->ShowProjection(0,1,0) ;
178 TH2D* h01 = cont->ShowProjection(0,1,1) ;
179 THnSparseD* hcorr = dynamic_cast<THnSparseD*> (GetOutputData(3));
181 TCanvas * c =new TCanvas("c","",800,400);
187 c->SaveAs("spectra.eps");
189 TCanvas * c2 =new TCanvas("c2","",800,400);
192 hcorr->Projection(0,2)->Draw("text");
194 hcorr->Projection(1,3)->Draw("text");
195 c2->SaveAs("correlation.eps");
199 //___________________________________________________________________________
200 void AliCFTaskForUnfolding::UserCreateOutputObjects() {
201 //HERE ONE CAN CREATE OUTPUT OBJECTS, IN PARTICULAR IF THE OBJECT PARAMETERS DON'T NEED
202 //TO BE SET BEFORE THE EXECUTION OF THE TASK
204 Info("CreateOutputObjects","CreateOutputObjects of task %s", GetName());
208 fHistEventsProcessed = new TH1I("fHistEventsProcessed","",1,0,1) ;