]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWGLF/SPECTRA/PiKaPr/TestAOD/AliAnalysisTaskSpectraAOD.cxx
Coverity fix 20210
[u/mrichter/AliRoot.git] / PWGLF / SPECTRA / PiKaPr / TestAOD / AliAnalysisTaskSpectraAOD.cxx
CommitLineData
c88234ad 1/**************************************************************************\r
2 * Copyright(c) 1998-2009, ALICE Experiment at CERN, All rights reserved. *\r
3 * *\r
4 * Author: The ALICE Off-line Project. *\r
5 * Contributors are mentioned in the code where appropriate. *\r
6 * *\r
7 * Permission to use, copy, modify and distribute this software and its *\r
8 * documentation strictly for non-commercial purposes is hereby granted *\r
9 * without fee, provided that the above copyright notice appears in all *\r
10 * copies and that both the copyright notice and this permission notice *\r
11 * appear in the supporting documentation. The authors make no claims *\r
12 * about the suitability of this software for any purpose. It is *\r
13 * provided "as is" without express or implied warranty. *\r
14 **************************************************************************/\r
15\r
16//-----------------------------------------------------------------\r
17// AliAnalysisTaskSpectraAOD class\r
18//-----------------------------------------------------------------\r
19\r
20#include "TChain.h"\r
21#include "TTree.h"\r
22#include "TLegend.h"\r
23#include "TH1F.h"\r
24#include "TH2F.h"\r
25#include "TCanvas.h"\r
26#include "AliAnalysisTask.h"\r
27#include "AliAnalysisManager.h"\r
28#include "AliAODTrack.h"\r
29#include "AliAODMCParticle.h"\r
6522a8cb 30#include "AliVParticle.h"\r
c88234ad 31#include "AliAODEvent.h"\r
32#include "AliAODInputHandler.h"\r
33#include "AliAnalysisTaskSpectraAOD.h"\r
34#include "AliAnalysisTaskESDfilter.h"\r
35#include "AliAnalysisDataContainer.h"\r
36#include "AliSpectraAODHistoManager.h"\r
37#include "AliSpectraAODTrackCuts.h"\r
38#include "AliSpectraAODEventCuts.h"\r
39#include "AliCentrality.h"\r
40#include "TProof.h"\r
41#include "AliPID.h"\r
42#include "AliVEvent.h"\r
43#include "AliPIDResponse.h"\r
823864bf 44#include "AliStack.h"\r
e8b0fe64 45#include "AliSpectraAODPID.h"\r
9fcae40e 46#include <TMCProcess.h>\r
47\r
c88234ad 48#include <iostream>\r
49\r
823864bf 50\r
51\r
52\r
c88234ad 53using namespace AliSpectraNameSpace;\r
54using namespace std;\r
55\r
56ClassImp(AliAnalysisTaskSpectraAOD) // EX1 This stuff tells root to implement the streamer, inspector methods etc (we discussed about it today)\r
57\r
58//________________________________________________________________________\r
10a8ccbe 59AliAnalysisTaskSpectraAOD::AliAnalysisTaskSpectraAOD(const char *name) : AliAnalysisTaskSE(name), fAOD(0), fHistMan(0), fTrackCuts(0), fEventCuts(0), fPID(0), fIsMC(0), fNRebin(0)\r
c88234ad 60{\r
823864bf 61 // Default constructor\r
10a8ccbe 62 \r
823864bf 63 DefineInput(0, TChain::Class());\r
64 DefineOutput(1, AliSpectraAODHistoManager::Class());\r
65 DefineOutput(2, AliSpectraAODEventCuts::Class());\r
66 DefineOutput(3, AliSpectraAODTrackCuts::Class());\r
e8b0fe64 67 DefineOutput(4, AliSpectraAODPID::Class());\r
10a8ccbe 68 fNRebin=0;\r
69 \r
c88234ad 70}\r
71//________________________________________________________________________\r
c88234ad 72//________________________________________________________________________\r
73void AliAnalysisTaskSpectraAOD::UserCreateOutputObjects()\r
74{\r
75 // create output objects\r
10a8ccbe 76 fHistMan = new AliSpectraAODHistoManager("SpectraHistos",fNRebin);\r
c88234ad 77\r
823864bf 78 if (!fTrackCuts) AliFatal("Track Cuts should be set in the steering macro");\r
79 if (!fEventCuts) AliFatal("Event Cuts should be set in the steering macro");\r
e8b0fe64 80 if (!fPID) AliFatal("PID object should be set in the steering macro");\r
c88234ad 81\r
e8b0fe64 82 PostData(1, fHistMan );\r
823864bf 83 PostData(2, fEventCuts);\r
84 PostData(3, fTrackCuts);\r
e8b0fe64 85 PostData(4, fPID );\r
c88234ad 86\r
87}\r
88//________________________________________________________________________\r
89void AliAnalysisTaskSpectraAOD::UserExec(Option_t *)\r
90{\r
91 // main event loop\r
1516046a 92 //Printf("ALIVE");\r
823864bf 93 fAOD = dynamic_cast<AliAODEvent*>(fInputEvent);\r
94 if (strcmp(fAOD->ClassName(), "AliAODEvent"))\r
95 {\r
c88234ad 96 AliFatal("Not processing AODs");\r
823864bf 97 }\r
98 \r
f6a38178 99 if(!fEventCuts->IsSelected(fAOD,fTrackCuts))return;//event selection\r
100 \r
e8b0fe64 101 //AliCentrality fAliCentral*;\r
102 // if ((fAOD->GetCentrality())->GetCentralityPercentile("V0M") > 5.) return;\r
6eee0bf6 103 \r
e8b0fe64 104 // First do MC to fill up the MC particle array, such that we can use it later\r
105 TClonesArray *arrayMC = 0;\r
106 if (fIsMC)\r
107 {\r
108 arrayMC = (TClonesArray*) fAOD->GetList()->FindObject(AliAODMCParticle::StdBranchName());\r
109 if (!arrayMC) {\r
110 AliFatal("Error: MC particles branch not found!\n");\r
c88234ad 111 }\r
e8b0fe64 112 Int_t nMC = arrayMC->GetEntries();\r
113 for (Int_t iMC = 0; iMC < nMC; iMC++)\r
114 {\r
115 AliAODMCParticle *partMC = (AliAODMCParticle*) arrayMC->At(iMC);\r
116 if(!partMC->Charge()) continue;//Skip neutrals\r
00493191 117 //if(partMC->Eta() > fTrackCuts->GetEtaMin() && partMC->Eta() < fTrackCuts->GetEtaMax()){//charged hadron are filled inside the eta acceptance\r
118 //Printf("%f %f-%f",partMC->Eta(),fTrackCuts->GetEtaMin(),fTrackCuts->GetEtaMax());\r
119 if(partMC->Eta() < fTrackCuts->GetEtaMin() || partMC->Eta() > fTrackCuts->GetEtaMax())continue;//ETA CUT ON GENERATED!!!!!!!!!!!!!!!!!!!!!!!!!!\r
120 fHistMan->GetPtHistogram(kHistPtGen)->Fill(partMC->Pt(),partMC->IsPhysicalPrimary());\r
121 \r
e9c44a2a 122 //rapidity cut\r
e8b0fe64 123 if(TMath::Abs(partMC->Y()) > fTrackCuts->GetY() ) continue; \r
124 // check for true PID + and fill P_t histos \r
125 Int_t charge = partMC->Charge() > 0 ? kChPos : kChNeg ;\r
126 Int_t id = fPID->GetParticleSpecie(partMC);\r
127 if(id != kSpUndefined) {\r
128 fHistMan->GetHistogram2D(kHistPtGenTruePrimary,id,charge)->Fill(partMC->Pt(),partMC->IsPhysicalPrimary());\r
823864bf 129 }\r
e8b0fe64 130 }\r
131 }\r
6da07d74 132 \r
e8b0fe64 133 //main loop on tracks\r
134 for (Int_t iTracks = 0; iTracks < fAOD->GetNumberOfTracks(); iTracks++) {\r
135 AliAODTrack* track = fAOD->GetTrack(iTracks);\r
decf69d9 136 if (!fTrackCuts->IsSelected(track,kTRUE)) continue;\r
e8b0fe64 137 \r
138 fPID->FillQAHistos(fHistMan, track, fTrackCuts);\r
6da07d74 139 \r
e8b0fe64 140 //calculate DCA for AOD track\r
9fcae40e 141 Double_t dca=track->DCA();\r
b150ea7e 142 if(dca==-999.){// track->DCA() does not work in old AOD production\r
143 Double_t d[2], covd[3];\r
144 AliAODTrack* track_clone=(AliAODTrack*)track->Clone("track_clone"); // need to clone because PropagateToDCA updates the track parameters\r
145 Bool_t isDCA = track_clone->PropagateToDCA(fAOD->GetPrimaryVertex(),fAOD->GetMagneticField(),9999.,d,covd);\r
146 delete track_clone;\r
147 if(!isDCA)d[0]=-999.;\r
148 dca=d[0];\r
149 }\r
9fcae40e 150 fHistMan->GetPtHistogram(kHistPtRec)->Fill(track->Pt(),dca); // PT histo\r
6da07d74 151 \r
e8b0fe64 152 // get identity and charge\r
972a21ad 153 Int_t idRec = fPID->GetParticleSpecie(fHistMan,track, fTrackCuts);\r
6da07d74 154 \r
e9c44a2a 155 Int_t charge = track->Charge() > 0 ? kChPos : kChNeg;\r
6da07d74 156 \r
e9c44a2a 157 // Fill histograms, only if inside y and nsigma acceptance\r
9fcae40e 158 if(idRec != kSpUndefined && fTrackCuts->CheckYCut ((AODParticleSpecies_t)idRec))fHistMan->GetHistogram2D(kHistPtRecSigma,idRec,charge)->Fill(track->Pt(),dca);\r
e9c44a2a 159 //can't put a continue because we still have to fill allcharged primaries, done later\r
6da07d74 160 \r
e8b0fe64 161 /* MC Part */\r
162 if (arrayMC) {\r
163 AliAODMCParticle *partMC = (AliAODMCParticle*) arrayMC->At(TMath::Abs(track->GetLabel()));\r
164 if (!partMC) { \r
165 AliError("Cannot get MC particle");\r
166 continue; \r
167 }\r
168 // Check if it is primary, secondary from material or secondary from weak decay\r
169 Bool_t isPrimary = partMC->IsPhysicalPrimary();\r
170 Bool_t isSecondaryMaterial = kFALSE; \r
171 Bool_t isSecondaryWeak = kFALSE; \r
172 if(!isPrimary) {\r
173 Int_t mfl=-999,codemoth=-999;\r
174 Int_t indexMoth=partMC->GetMother(); // FIXME ignore fakes? TO BE CHECKED, on ESD is GetFirstMother()\r
175 if(indexMoth>=0){//is not fake\r
176 AliAODMCParticle* moth = (AliAODMCParticle*) arrayMC->At(indexMoth);\r
177 codemoth = TMath::Abs(moth->GetPdgCode());\r
178 mfl = Int_t (codemoth/ TMath::Power(10, Int_t(TMath::Log10(codemoth))));\r
179 }\r
ae0fdd7d 180 //Int_t uniqueID = partMC->GetUniqueID();\r
00493191 181 //cout<<"uniqueID: "<<partMC->GetUniqueID()<<" "<<kPDecay<<endl;\r
182 //cout<<"status: "<<partMC->GetStatus()<<" "<<kPDecay<<endl;\r
9fcae40e 183 // if(uniqueID == kPDecay)Printf("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");\r
e8b0fe64 184 if(mfl==3) isSecondaryWeak = kTRUE; // add if(partMC->GetStatus() & kPDecay)? FIXME\r
185 else isSecondaryMaterial = kTRUE;\r
186 }\r
6da07d74 187 \r
9fcae40e 188 if (isPrimary)fHistMan->GetPtHistogram(kHistPtRecPrimary)->Fill(track->Pt(),dca); // PT histo of primaries\r
e9c44a2a 189 \r
190 //nsigma cut (reconstructed nsigma)\r
191 if(idRec == kSpUndefined) continue;\r
192 \r
193 // rapidity cut (reconstructed pt and identity)\r
194 if(!fTrackCuts->CheckYCut ((AODParticleSpecies_t)idRec)) continue;\r
195 \r
e8b0fe64 196 // Get true ID\r
6da07d74 197 Int_t idGen = fPID->GetParticleSpecie(partMC);\r
198 //if(TMath::Abs(partMC->Y()) > fTrackCuts->GetY() ) continue; // FIXME: do we need a rapidity cut on the generated?\r
e8b0fe64 199 // Fill histograms for primaries\r
e9c44a2a 200 \r
9fcae40e 201 if (idRec == idGen) fHistMan->GetHistogram2D(kHistPtRecTrue, idGen, charge)->Fill(track->Pt(),dca); \r
e9c44a2a 202 \r
203 if (isPrimary) {\r
9fcae40e 204 fHistMan ->GetHistogram2D(kHistPtRecSigmaPrimary, idRec, charge)->Fill(track->Pt(),dca); \r
e9c44a2a 205 if(idGen != kSpUndefined) {\r
9fcae40e 206 fHistMan ->GetHistogram2D(kHistPtRecPrimary, idGen, charge)->Fill(track->Pt(),dca);\r
207 if (idRec == idGen) fHistMan->GetHistogram2D(kHistPtRecTruePrimary, idGen, charge)->Fill(track->Pt(),dca); \r
f6a38178 208 }\r
e8b0fe64 209 }\r
210 //25th Apr - Muons are added to Pions -- FIXME\r
211 if ( partMC->PdgCode() == 13 && idRec == kSpPion) { \r
9fcae40e 212 fHistMan->GetPtHistogram(kHistPtRecTrueMuonPlus)->Fill(track->Pt(),dca); \r
e8b0fe64 213 if(isPrimary)\r
9fcae40e 214 fHistMan->GetPtHistogram(kHistPtRecTruePrimaryMuonPlus)->Fill(track->Pt(),dca); \r
e8b0fe64 215 }\r
216 if ( partMC->PdgCode() == -13 && idRec == kSpPion) { \r
9fcae40e 217 fHistMan->GetPtHistogram(kHistPtRecTrueMuonMinus)->Fill(track->Pt(),dca); \r
e8b0fe64 218 if (isPrimary) {\r
9fcae40e 219 fHistMan->GetPtHistogram(kHistPtRecTruePrimaryMuonMinus)->Fill(track->Pt(),dca); \r
e8b0fe64 220 }\r
221 }\r
6da07d74 222 \r
e8b0fe64 223 ///..... END FIXME\r
f6a38178 224 \r
e8b0fe64 225 // Fill secondaries\r
9fcae40e 226 if(isSecondaryWeak ) fHistMan->GetHistogram2D(kHistPtRecSigmaSecondaryWeakDecay, idRec, charge)->Fill(track->Pt(),dca);\r
227 if(isSecondaryMaterial) fHistMan->GetHistogram2D(kHistPtRecSigmaSecondaryMaterial , idRec, charge)->Fill(track->Pt(),dca);\r
f6a38178 228 \r
e8b0fe64 229 }//end if(arrayMC)\r
230 } // end loop on tracks\r
231 \r
97b01bb0 232 PostData(1, fHistMan );\r
823864bf 233 PostData(2, fEventCuts);\r
234 PostData(3, fTrackCuts);\r
97b01bb0 235 PostData(4, fPID );\r
c88234ad 236}\r
823864bf 237\r
c88234ad 238//_________________________________________________________________\r
239void AliAnalysisTaskSpectraAOD::Terminate(Option_t *)\r
240{\r
823864bf 241 // Terminate\r
c88234ad 242}\r