]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG4/PartCorrDep/AliAnaChargedParticles.cxx
New script to do common-mode-noise analysis of raw data.
[u/mrichter/AliRoot.git] / PWG4 / PartCorrDep / AliAnaChargedParticles.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
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  **************************************************************************/
15 /* $Id: $ */
16
17 //_________________________________________________________________________
18 //
19 // Class for track selection and identification (not done now)
20 // Tracks from the CTS are kept in the AOD.
21 // Few histograms produced.
22 //
23 //-- Author: Gustavo Conesa (INFN-LNF)
24 //_________________________________________________________________________
25
26
27 // --- ROOT system ---
28 #include "TClonesArray.h"
29 #include "TParticle.h"
30 #include "TH2F.h"
31
32 //---- AliRoot system ----
33 #include "AliAnaChargedParticles.h"
34 #include "AliCaloTrackReader.h"
35 #include "AliAODPWG4Particle.h"
36 #include "AliStack.h"
37 #include "AliCaloPID.h"
38 #include "AliFidutialCut.h"
39 #include "AliAODTrack.h"
40
41 ClassImp(AliAnaChargedParticles)
42   
43 //____________________________________________________________________________
44   AliAnaChargedParticles::AliAnaChargedParticles() : 
45     AliAnaPartCorrBaseClass(),fPdg(0), fhPt(0),fhPhi(0),fhEta(0), 
46     fhPtPion(0),fhPhiPion(0),fhEtaPion(0),
47     fhPtProton(0),fhPhiProton(0),fhEtaProton(0),
48     fhPtElectron(0),fhPhiElectron(0),fhEtaElectron(0),
49     fhPtKaon(0),fhPhiKaon(0),fhEtaKaon(0),
50     fhPtUnknown(0),fhPhiUnknown(0),fhEtaUnknown(0)
51       
52 {
53   //Default Ctor
54
55   //Initialize parameters
56   InitParameters();
57 }
58
59 //____________________________________________________________________________
60 AliAnaChargedParticles::AliAnaChargedParticles(const AliAnaChargedParticles & ch) :   
61   AliAnaPartCorrBaseClass(ch), fPdg(ch.fPdg),  fhPt(ch.fhPt),  fhPhi(ch.fhPhi),fhEta(ch.fhEta), 
62   fhPtPion(ch. fhPtPion),fhPhiPion(ch.fhPhiPion),fhEtaPion(ch.fhEtaPion),
63   fhPtProton(ch.fhPtProton),fhPhiProton(ch.fhPhiProton),fhEtaProton(ch.fhEtaProton),
64   fhPtElectron(ch. fhPtElectron),fhPhiElectron(ch.fhPhiElectron),fhEtaElectron(ch.fhEtaElectron),
65   fhPtKaon(ch. fhPtKaon),fhPhiKaon(ch.fhPhiKaon),fhEtaKaon(ch.fhEtaKaon),
66   fhPtUnknown(ch.fhPtUnknown),fhPhiUnknown(ch.fhPhiUnknown),fhEtaUnknown(ch.fhEtaUnknown)
67   
68 {
69   // cpy ctor
70   
71 }
72
73 //_________________________________________________________________________
74 AliAnaChargedParticles & AliAnaChargedParticles::operator = (const AliAnaChargedParticles & ch)
75 {
76   // assignment operator
77   
78   if(this == &ch)return *this;
79   ((AliAnaPartCorrBaseClass *)this)->operator=(ch);
80  
81   fPdg = ch.fPdg;
82   fhPt = ch.fhPt;
83   fhPhi = ch.fhPhi;
84   fhEta = ch.fhEta;
85   
86   fhPtPion = ch. fhPtPion; fhPhiPion = ch.fhPhiPion; fhEtaPion = ch.fhEtaPion; 
87   fhPtProton = ch.fhPtProton; fhPhiProton = ch.fhPhiProton; fhEtaProton = ch.fhEtaProton; 
88   fhPtElectron = ch. fhPtElectron; fhPhiElectron = ch.fhPhiElectron; fhEtaElectron = ch.fhEtaElectron; 
89   fhPtKaon = ch. fhPtKaon; fhPhiKaon = ch.fhPhiKaon; fhEtaKaon = ch.fhEtaKaon; 
90   fhPtUnknown = ch.fhPtUnknown; fhPhiUnknown = ch.fhPhiUnknown; fhEtaUnknown = ch.fhEtaUnknown;
91
92   return *this;
93   
94 }
95
96 //________________________________________________________________________
97 TList *  AliAnaChargedParticles::GetCreateOutputObjects()
98 {  
99   // Create histograms to be saved in output file and 
100   // store them in fOutputContainer
101   
102   
103   TList * outputContainer = new TList() ; 
104   outputContainer->SetName("ExampleHistos") ; 
105   
106   Int_t nptbins  = GetHistoNPtBins();
107   Int_t nphibins = GetHistoNPhiBins();
108   Int_t netabins = GetHistoNEtaBins();
109   Float_t ptmax  = GetHistoPtMax();
110   Float_t phimax = GetHistoPhiMax();
111   Float_t etamax = GetHistoEtaMax();
112   Float_t ptmin  = GetHistoPtMin();
113   Float_t phimin = GetHistoPhiMin();
114   Float_t etamin = GetHistoEtaMin();    
115   
116   fhPt  = new TH1F ("hPtCharged","p_T distribution", nptbins,ptmin,ptmax); 
117   fhPt->SetXTitle("p_{T} (GeV/c)");
118   outputContainer->Add(fhPt);
119   
120   fhPhi  = new TH2F ("hPhiCharged","#phi distribution",nptbins,ptmin,ptmax, nphibins,phimin,phimax); 
121   fhPhi->SetXTitle("#phi (rad)");
122   outputContainer->Add(fhPhi);
123   
124   fhEta  = new TH2F ("hEtaCharged","#eta distribution",nptbins,ptmin,ptmax, netabins,etamin,etamax); 
125   fhEta->SetXTitle("#eta ");
126   outputContainer->Add(fhEta);
127   
128   
129   if(IsDataMC()){
130     
131     fhPtPion  = new TH1F ("hPtMCPion","p_T distribution from #pi", nptbins,ptmin,ptmax); 
132     fhPtPion->SetXTitle("p_{T} (GeV/c)");
133     outputContainer->Add(fhPtPion);
134     
135     fhPhiPion  = new TH2F ("hPhiMCPion","#phi distribution from #pi",nptbins,ptmin,ptmax, nphibins,phimin,phimax); 
136     fhPhiPion->SetXTitle("#phi (rad)");
137     outputContainer->Add(fhPhiPion);
138     
139     fhEtaPion  = new TH2F ("hEtaMCPion","#eta distribution from #pi",nptbins,ptmin,ptmax, netabins,etamin,etamax); 
140     fhEtaPion->SetXTitle("#eta ");
141     outputContainer->Add(fhEtaPion);
142     
143     fhPtProton  = new TH1F ("hPtMCProton","p_T distribution from proton", nptbins,ptmin,ptmax); 
144     fhPtProton->SetXTitle("p_{T} (GeV/c)");
145     outputContainer->Add(fhPtProton);
146     
147     fhPhiProton  = new TH2F ("hPhiMCProton","#phi distribution from proton",nptbins,ptmin,ptmax, nphibins,phimin,phimax); 
148     fhPhiProton->SetXTitle("#phi (rad)");
149     outputContainer->Add(fhPhiProton);
150     
151     fhEtaProton  = new TH2F ("hEtaMCProton","#eta distribution from proton",nptbins,ptmin,ptmax, netabins,etamin,etamax); 
152     fhEtaProton->SetXTitle("#eta ");
153     outputContainer->Add(fhEtaProton);
154     
155     fhPtKaon  = new TH1F ("hPtMCKaon","p_T distribution from kaon", nptbins,ptmin,ptmax); 
156     fhPtKaon->SetXTitle("p_{T} (GeV/c)");
157     outputContainer->Add(fhPtKaon);
158     
159     fhPhiKaon  = new TH2F ("hPhiMCKaon","#phi distribution from kaon",nptbins,ptmin,ptmax, nphibins,phimin,phimax); 
160     fhPhiKaon->SetXTitle("#phi (rad)");
161     outputContainer->Add(fhPhiKaon);
162     
163     fhEtaKaon  = new TH2F ("hEtaMCKaon","#eta distribution from kaon",nptbins,ptmin,ptmax, netabins,etamin,etamax); 
164     fhEtaKaon->SetXTitle("#eta ");
165     outputContainer->Add(fhEtaKaon);
166     
167     fhPtElectron  = new TH1F ("hPtMCElectron","p_T distribution from electron", nptbins,ptmin,ptmax); 
168     fhPtElectron->SetXTitle("p_{T} (GeV/c)");
169     outputContainer->Add(fhPtElectron);
170     
171     fhPhiElectron  = new TH2F ("hPhiMCElectron","#phi distribution from electron",nptbins,ptmin,ptmax, nphibins,phimin,phimax); 
172     fhPhiElectron->SetXTitle("#phi (rad)");
173     outputContainer->Add(fhPhiElectron);
174     
175     fhEtaElectron  = new TH2F ("hEtaMCElectron","#eta distribution from electron",nptbins,ptmin,ptmax, netabins,etamin,etamax); 
176     fhEtaElectron->SetXTitle("#eta ");
177     outputContainer->Add(fhEtaElectron);
178     
179     fhPtUnknown  = new TH1F ("hPtMCUnknown","p_T distribution from unknown", nptbins,ptmin,ptmax); 
180     fhPtUnknown->SetXTitle("p_{T} (GeV/c)");
181     outputContainer->Add(fhPtUnknown);
182     
183     fhPhiUnknown  = new TH2F ("hPhiMCUnknown","#phi distribution from unknown",nptbins,ptmin,ptmax, nphibins,phimin,phimax); 
184     fhPhiUnknown->SetXTitle("#phi (rad)");
185     outputContainer->Add(fhPhiUnknown);
186     
187     fhEtaUnknown  = new TH2F ("hEtaMCUnknown","#eta distribution from unknown",nptbins,ptmin,ptmax, netabins,etamin,etamax); 
188     fhEtaUnknown->SetXTitle("#eta ");
189     outputContainer->Add(fhEtaUnknown);
190     
191   }
192   
193   return outputContainer;
194
195 }
196
197 //__________________________________________________
198 void AliAnaChargedParticles::InitParameters()
199
200   //Initialize the parameters of the analysis.
201   SetOutputAODClassName("AliAODPWG4Particle");
202   SetOutputAODName("PWG4Particle");
203
204   AddToHistogramsName("AnaCharged_");
205
206   fPdg = -1; //Select all tracks 
207   
208 }
209
210 //__________________________________________________________________
211 void AliAnaChargedParticles::Print(const Option_t * opt) const
212 {
213   //Print some relevant parameters set for the analysis
214   if(! opt)
215     return;
216   
217   printf("**** Print %s %s ****\n", GetName(), GetTitle() ) ;
218   AliAnaPartCorrBaseClass::Print(" ");  
219         
220   printf("Min Pt = %3.2f\n", GetMinPt());
221   printf("Max Pt = %3.2f\n", GetMaxPt());
222   printf("Select clusters with pdg %d \n",fPdg);
223   
224
225
226 //____________________________________________________________________________
227 void AliAnaChargedParticles::Init()
228 {  
229   //Init
230   //Do some checks
231   if(!GetReader()->IsCTSSwitchedOn()){
232     printf("AliAnaChargedParticles::Init() - !!ABORT: You want to use CTS tracks in analysis but not read!! \n!!Check the configuration file!!\n");
233     abort();
234   }
235   
236 }
237
238 //__________________________________________________________________
239 void  AliAnaChargedParticles::MakeAnalysisFillAOD() 
240 {
241   //Do analysis and fill aods
242   if(!GetAODCTS() || GetAODCTS()->GetEntriesFast() == 0) return ;
243   Int_t ntracks = GetAODCTS()->GetEntriesFast();
244   
245   //Some prints
246   if(GetDebug() > 0)
247     printf("AliAnaChargedParticles::MakeAnalysisFillAOD() - In CTS aod entries %d\n", ntracks);
248   
249   //Fill AODParticle with CTS aods
250   TVector3 p3;
251   for(Int_t i = 0; i < ntracks; i++){
252     
253     AliAODTrack * track =  (AliAODTrack*) (GetAODCTS()->At(i));
254     
255     //Fill AODParticle after some selection       
256     Double_t mom[3] = {track->Px(),track->Py(),track->Pz()};
257     p3.SetXYZ(mom[0],mom[1],mom[2]);
258     
259     //Acceptance selection
260     Bool_t in =  GetFidutialCut()->IsInFidutialCut(mom,"CTS") ;
261     if(GetDebug() > 1) printf("AliAnaChargedParticles::MakeAnalysisFillAOD() - Track pt %2.2f, phi %2.2f, in fidutial cut %d\n",p3.Pt(), p3.Phi(), in);
262     if(p3.Pt() > GetMinPt() && in) {
263       //Keep only particles identified with fPdg
264       //Selection not done for the moment
265       //Should be done here.
266       
267       AliAODPWG4Particle tr = AliAODPWG4Particle(mom[0],mom[1],mom[2],0);
268       tr.SetDetector("CTS");
269       tr.SetLabel(track->GetLabel());
270       tr.SetTrackLabel(track->GetID(),-1);
271       AddAODParticle(tr);
272     }//selection
273   }//loop
274   
275   if(GetDebug() > 0)    
276     printf("AliAnaChargedParticles::MakeAnalysisFillAOD() - Final aod branch entries %d\n", GetOutputAODBranch()->GetEntriesFast());   
277
278
279 //__________________________________________________________________
280 void  AliAnaChargedParticles::MakeAnalysisFillHistograms() 
281 {
282   //Do analysis and fill histograms
283   
284   //Loop on stored AODParticles
285   Int_t naod = GetOutputAODBranch()->GetEntriesFast();
286   if(GetDebug() > 0) printf("AliAnaChargedParticles::MakeAnalysisFillHistograms() - aod branch entries %d\n", naod);
287   for(Int_t iaod = 0; iaod < naod ; iaod++){
288     AliAODPWG4Particle* tr =  (AliAODPWG4Particle*) (GetOutputAODBranch()->At(iaod));
289     
290     fhPt->Fill(tr->Pt());
291     fhPhi->Fill(tr->Pt(), tr->Phi());
292     fhEta->Fill(tr->Pt(), tr->Eta());
293     
294     if(IsDataMC()){
295       //Play with the MC stack if available             
296       TParticle * mom = GetMCStack()->Particle(tr->GetLabel());
297       Int_t mompdg =TMath::Abs(mom->GetPdgCode());
298       
299       if(mompdg==211){
300         fhPtPion->Fill(tr->Pt());
301         fhPhiPion->Fill(tr->Pt(), tr->Phi());
302         fhEtaPion->Fill(tr->Pt(), tr->Eta());
303       }
304       else if(mompdg==2212){
305         fhPtProton->Fill(tr->Pt());
306         fhPhiProton->Fill(tr->Pt(), tr->Phi());
307         fhEtaProton->Fill(tr->Pt(), tr->Eta());
308       }
309       else if(mompdg==321){
310         fhPtKaon->Fill(tr->Pt());
311         fhPhiKaon->Fill(tr->Pt(), tr->Phi());
312         fhEtaKaon->Fill(tr->Pt(), tr->Eta());
313       }
314       else if(mompdg==11){
315         fhPtElectron->Fill(tr->Pt());
316         fhPhiElectron->Fill(tr->Pt(), tr->Phi());
317         fhEtaElectron->Fill(tr->Pt(), tr->Eta());
318       }
319       else {
320         //printf("unknown pdg %d\n",mompdg);
321         fhPtUnknown->Fill(tr->Pt());
322         fhPhiUnknown->Fill(tr->Pt(), tr->Phi());
323         fhEtaUnknown->Fill(tr->Pt(), tr->Eta());
324       }
325     }//Work with stack also
326   }// aod branch loop
327   
328 }