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 **************************************************************************/
18 //-----------------------------------------------------------------------
19 // Example of task (running locally, on AliEn and CAF),
20 // which provides standard way of calculating acceptance and efficiency
21 // between different steps of the procedure.
22 // The ouptut of the task is a AliCFContainer from which the efficiencies
24 //-----------------------------------------------------------------------
25 // Author : R. Vernet, Consorzio Cometa - Catania (it)
26 //-----------------------------------------------------------------------
27 // Modification done by X. Lopez - LPC Clermont (fr)
28 //-----------------------------------------------------------------------
30 #ifndef ALICFMUONSINGLETASK1_CXX
31 #define ALICFMUONSINGLETASK1_CXX
33 #include "AliCFMuonSingleTask1.h"
34 #include "AliHeader.h"
35 #include "AliESDHeader.h"
37 #include "TParticle.h"
38 #include "TLorentzVector.h"
40 #include "AliMCEvent.h"
41 #include "AliAnalysisManager.h"
42 #include "AliESDEvent.h"
43 #include "AliAODEvent.h"
44 #include "AliCFManager.h"
45 #include "AliCFCutBase.h"
46 #include "AliCFContainer.h"
48 #include "AliESDtrack.h"
50 #include "AliESDMuonTrack.h"
51 #include "AliESDtrack.h"
52 #include "AliESDInputHandler.h"
55 ClassImp(AliCFMuonSingleTask1)
57 //__________________________________________________________________________
58 AliCFMuonSingleTask1::AliCFMuonSingleTask1() :
62 fHistEventsProcessed(0x0),
70 //___________________________________________________________________________
71 AliCFMuonSingleTask1::AliCFMuonSingleTask1(const Char_t* name) :
72 AliAnalysisTaskSE(name),
76 fHistEventsProcessed(0x0),
81 // Constructor. Initialization of Inputs and Outputs
83 Info("AliCFMuonSingleTask1","Calling Constructor");
85 fHistEventsProcessed = new TH1I("fHistEventsProcessed","",1,0,1) ;
87 DefineOutput(1,TH1I::Class());
88 DefineOutput(2,AliCFContainer::Class());
92 //___________________________________________________________________________
93 AliCFMuonSingleTask1& AliCFMuonSingleTask1::operator=(const AliCFMuonSingleTask1& c)
96 // Assignment operator
99 AliAnalysisTaskSE::operator=(c) ;
100 fReadAODData = c.fReadAODData ;
101 fCFManager = c.fCFManager;
102 fQAHistList = c.fQAHistList ;
103 fHistEventsProcessed = c.fHistEventsProcessed;
109 //___________________________________________________________________________
110 AliCFMuonSingleTask1::AliCFMuonSingleTask1(const AliCFMuonSingleTask1& c) :
111 AliAnalysisTaskSE(c),
112 fReadAODData(c.fReadAODData),
113 fCFManager(c.fCFManager),
114 fQAHistList(c.fQAHistList),
115 fHistEventsProcessed(c.fHistEventsProcessed),
124 //___________________________________________________________________________
125 AliCFMuonSingleTask1::~AliCFMuonSingleTask1() {
129 Info("~AliCFMuonSingleTask1","Calling Destructor");
130 if (fCFManager) delete fCFManager ;
131 if (fHistEventsProcessed) delete fHistEventsProcessed ;
132 if (fQAHistList) {fQAHistList->Clear(); delete fQAHistList;}
135 //_________________________________________________
136 void AliCFMuonSingleTask1::UserExec(Option_t *)
139 // Main loop function
142 Info("UserExec"," ") ;
143 if (!fMCEvent && fIsMC) {
144 Error("UserExec","NO MC EVENT FOUND!");
149 fCFManager->SetEventInfo(fMCEvent);
150 Double_t containerInput[18] ;
156 // loop on the MC part
160 for (Int_t ipart=0; ipart<fMCEvent->GetNumberOfTracks(); ipart++) {
162 AliMCParticle *mcPart = (AliMCParticle*) fMCEvent->GetTrack(ipart);
163 TParticle *part = mcPart->Particle();
165 // rapidity and Pt cuts (default -4<y<-2.5 et 0<pt<20)
166 if (!fCFManager->CheckParticleCuts(AliCFManager::kPartAccCuts,mcPart)) continue;
169 Int_t pdg=part->GetPdgCode();
170 if(TMath::Abs(pdg)==13){
172 Float_t emc = part->Energy();
173 Float_t pzmc = part->Pz();
174 Float_t rapmc = Rap(emc,pzmc);
175 Float_t phimc = part->Phi();
176 phimc = Phideg(phimc);
177 Float_t ptmc = part->Pt();
178 Float_t pmc = part->P();
179 Float_t zmc = part->Vz();
180 Float_t etamc = part->Eta();
182 if(pdg==13) chargemc=-1;
183 if(pdg==-13) chargemc=1;
185 thetamc = TMath::Abs(-TMath::Pi()+TMath::ASin(ptmc/pmc)); // convention for EVGEN
186 Float_t ymc = part->Vy();
187 Float_t xmc = part->Vx();
188 Float_t rmc = TMath::Sqrt(xmc*xmc+ymc*ymc);
190 containerInput[0] = etamc ;
191 containerInput[1] = rapmc ;
192 containerInput[2] = phimc ;
193 containerInput[3] = ptmc ;
194 containerInput[4] = pmc ;
195 containerInput[14] = zmc ;
196 containerInput[16] = chargemc ;
197 containerInput[17] = thetamc ;
199 // 10 var calculated only for ESD .i.e set at 1 in MC step
200 for(Int_t i=5; i<=13; i++){
201 containerInput[i] = 1;
204 containerInput[7] = 3;
205 containerInput[10] = rmc ; // radius at production
206 containerInput[15] = 175. ; // rabsmc
208 // fill the container at the first step
209 fCFManager->GetParticleContainer()->Fill(containerInput,0);
219 Int_t trig1MuL = 1 ,trig1MuH = 2, trigUSL = 4, trigUSH = 8, trigLSL = 16, trigLSH = 32;
223 AliESDInputHandler *esdH = dynamic_cast<AliESDInputHandler*>
224 (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
225 fESD = esdH->GetEvent();
229 if (fESD->GetTriggerMask() & trig1MuL) trig = 1;
230 if (fESD->GetTriggerMask() & trig1MuH) trig = 2;
231 if (fESD->GetTriggerMask() & trigUSL) trig = 3;
232 if (fESD->GetTriggerMask() & trigUSH) trig = 4;
233 if (fESD->GetTriggerMask() & trigLSL) trig = 5;
234 if (fESD->GetTriggerMask() & trigLSH) trig = 6;
238 Float_t vx = -200 , vy = -200 , vz = -200, vt=-200;
241 AliESDVertex* vertex = (AliESDVertex*) fESD->GetVertex();
242 if (vertex->GetNContributors()) {
243 vz = vertex->GetZv();
244 vy = vertex->GetYv();
245 vx = vertex->GetXv();
246 vt=TMath::Sqrt(vx*vx+vy*vy);
247 Ncont=vertex->GetNContributors();
252 Int_t mult1 = fESD->GetNumberOfMuonTracks() ;
254 for (Int_t j = 0; j<mult1; j++) {
255 AliESDMuonTrack* mu1 = new AliESDMuonTrack(*(fESD->GetMuonTrack(j)));
257 if (!mu1->ContainTrackerData()) { mu1=0; continue; }
259 Float_t charger = mu1->Charge();
260 Float_t er = mu1->E();
261 Float_t pzr = mu1->Pz();
262 Float_t rapr=Rap(er,pzr);
263 Float_t phir = mu1->Phi();
265 Float_t ptr = mu1->Pt();
266 Float_t pr = mu1->P();
267 Float_t hit = mu1->GetNHit();
268 Float_t chi2 = mu1->GetChi2() / (2.0 * hit - 5);
269 Int_t matchtrig = mu1->GetMatchTrigger();
270 Float_t chi2match = mu1->GetChi2MatchTrigger();
271 Float_t dcar = mu1->GetDCA();
272 Float_t zr = mu1->GetZ();
273 Float_t etar = mu1->Eta();
274 Float_t rabs = mu1->GetRAtAbsorberEnd();
276 thetar = TMath::Abs(-TMath::Pi()+TMath::ASin(ptr/pr));
278 // rapidity and Pt cuts (default -4<y<-2.5 et 0<pt<20)
279 if (!fCFManager->CheckParticleCuts(AliCFManager::kPartAccCuts,mu1)) continue;
281 Float_t thetaAbs = 180.*(1.-TMath::ATan(rabs/505.)/TMath::Pi());
282 if (thetaAbs<171 || thetaAbs>178) continue;
284 containerInput[0] = etar ;
285 containerInput[1] = rapr ;
286 containerInput[2] = phir ;
287 containerInput[3] = ptr ;
288 containerInput[4] = pr ;
289 containerInput[5] = hit ;
290 containerInput[6] = chi2 ;
291 containerInput[7] = matchtrig ;
292 containerInput[8] = chi2match ;
293 containerInput[9] = Ncont ;
294 containerInput[10] = vt ;
295 containerInput[11] = vz ;
296 containerInput[12] = trig ;
297 containerInput[13] = dcar ;
298 containerInput[14] = zr ;
299 containerInput[15] = thetaAbs;
300 containerInput[16] = charger ;
301 containerInput[17] = thetar ;
303 // fill the container at the second step (for simu, first for data)
305 fCFManager->GetParticleContainer()->Fill(containerInput,1);
308 fCFManager->GetParticleContainer()->Fill(containerInput,0);
315 fHistEventsProcessed->Fill(0);
316 PostData(1,fHistEventsProcessed) ;
317 PostData(2,fCFManager->GetParticleContainer()) ;
320 //________________________________________________________________________
321 Float_t AliCFMuonSingleTask1::Rap(Float_t e, Float_t pz)
323 // calculate rapidity
326 rap = 0.5*TMath::Log((e+pz)/(e-pz));
334 //________________________________________________________________________
335 Float_t AliCFMuonSingleTask1::Phideg(Float_t phi)
337 // calculate Phi in range [-180,180]
340 phideg = phi-TMath::Pi();
341 phideg = phideg*57.296;
344 //________________________________________________________________________
345 void AliCFMuonSingleTask1::Terminate(Option_t *)
347 // project pt (var[3]) from the two steps MC(0) and ESD(1)
349 AliCFContainer *cont = dynamic_cast<AliCFContainer*> (GetOutputData(2));
351 TH1D *kpt = cont->ShowProjection(16,0);
352 TH1D *rpt = cont->ShowProjection(16,1);
354 TCanvas *c1 = new TCanvas("AliCFMuonSingleTask1"," MC & ESD",10,10,510,510);
362 //________________________________________________________________________