]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG1/ZDC/AliAnalysisTaskZDC.cxx
Fixing warnings
[u/mrichter/AliRoot.git] / PWG1 / ZDC / AliAnalysisTaskZDC.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-2008, 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
16 /////////////////////////////////////////////////////////////
17 //                                                         //
18 //      Class to analyze ZDC data                          //
19 //                                                         //
20 /////////////////////////////////////////////////////////////
21
22 #include <TList.h>
23 #include <TH2F.h>
24 #include <TH1F.h>
25 #include <TFile.h>
26 #include <TString.h>
27
28 #include "AliAnalysisManager.h"
29 #include "AliInputEventHandler.h"
30 #include "AliVEvent.h"
31 #include "AliESD.h"
32 #include "AliESDEvent.h"
33 #include "AliESDHeader.h"
34 #include "AliESDInputHandler.h"
35 #include "AliESDZDC.h"
36 #include "AliMultiplicity.h"
37 #include "AliAODHandler.h"
38 #include "AliAODEvent.h"
39 #include "AliAODVertex.h"
40 #include "AliAODMCHeader.h"
41 #include "AliMCEventHandler.h"
42 #include "AliMCEvent.h"
43 #include "AliHeader.h"
44 #include "AliAODMCParticle.h"
45 #include "AliAnalysisTaskSE.h"
46 #include "AliGenEventHeader.h"
47 #include "AliGenHijingEventHeader.h"
48 #include "AliPhysicsSelectionTask.h"
49 #include "AliPhysicsSelection.h"
50 #include "AliBackgroundSelection.h"
51 #include "AliTriggerAnalysis.h"
52 #include "AliCentrality.h"
53 #include "AliAnalysisTaskZDC.h"
54
55 ClassImp(AliAnalysisTaskZDC)
56
57
58 //________________________________________________________________________
59 AliAnalysisTaskZDC::AliAnalysisTaskZDC():
60   AliAnalysisTaskSE(),
61     fDebug(0),
62     fIsMCInput(kFALSE),
63     fOutput(0x0),
64     fhTDCZNSum(0x0),
65     fhTDCZNDiff(0x0),
66     fhZNCSpectrum(0x0),
67     fhZNASpectrum(0x0),
68     fhZPCSpectrum(0x0),
69     fhZPASpectrum(0x0),
70     fhZEM1Spectrum(0x0),
71     fhZEM2Spectrum(0x0),
72     fhZNCpmc(0x0),       
73     fhZNApmc(0x0),       
74     fhZPCpmc(0x0),       
75     fhZPApmc(0x0),       
76     fhZNCCentroid(0x0), 
77     fhZNACentroid(0x0), 
78     fhZNCemd(0x0),         
79     fhZNAemd(0x0),
80     fhPMCZNCemd(0x0), 
81     fhPMCZNAemd(0x0),
82     fDebunch(0x0)
83 {   
84    // Default constructor
85 }   
86
87 //________________________________________________________________________
88 AliAnalysisTaskZDC::AliAnalysisTaskZDC(const char *name):
89   AliAnalysisTaskSE(name),
90     fDebug(0),
91     fIsMCInput(kFALSE),
92     fOutput(0x0),
93     fhTDCZNSum(0x0),
94     fhTDCZNDiff(0x0),
95     fhZNCSpectrum(0x0),
96     fhZNASpectrum(0x0),
97     fhZPCSpectrum(0x0),
98     fhZPASpectrum(0x0),
99     fhZEM1Spectrum(0x0),
100     fhZEM2Spectrum(0x0),
101     fhZNCpmc(0x0),       
102     fhZNApmc(0x0),       
103     fhZPCpmc(0x0),       
104     fhZPApmc(0x0),       
105     fhZNCCentroid(0x0), 
106     fhZNACentroid(0x0), 
107     fhZNCemd(0x0),         
108     fhZNAemd(0x0),
109     fhPMCZNCemd(0x0), 
110     fhPMCZNAemd(0x0),
111     fDebunch(0x0) 
112 {  
113   // Output slot #1 writes into a TList container
114   DefineOutput(1, TList::Class()); 
115
116 }
117
118 //________________________________________________________________________
119 AliAnalysisTaskZDC& AliAnalysisTaskZDC::operator=(const AliAnalysisTaskZDC& c)
120 {
121   //
122   // Assignment operator
123   //
124   if (this!=&c) {
125     AliAnalysisTaskSE::operator=(c);
126   }
127   return *this;
128 }
129
130 //________________________________________________________________________
131 AliAnalysisTaskZDC::AliAnalysisTaskZDC(const AliAnalysisTaskZDC& ana):
132   AliAnalysisTaskSE(ana),
133   fDebug(ana.fDebug),     
134   fIsMCInput(ana.fIsMCInput),
135   fOutput(ana.fOutput),
136   fhTDCZNSum(ana.fhTDCZNSum),
137   fhTDCZNDiff(ana.fhTDCZNDiff),
138   fhZNCSpectrum(ana.fhZNCSpectrum),
139   fhZNASpectrum(ana.fhZNASpectrum),
140   fhZPCSpectrum(ana.fhZPCSpectrum),
141   fhZPASpectrum(ana.fhZPASpectrum),
142   fhZEM1Spectrum(ana.fhZEM1Spectrum),
143   fhZEM2Spectrum(ana.fhZEM2Spectrum),
144   fhZNCpmc(ana.fhZNCpmc),       
145   fhZNApmc(ana.fhZNApmc),       
146   fhZPCpmc(ana.fhZPCpmc),       
147   fhZPApmc(ana.fhZPApmc),       
148   fhZNCCentroid(ana.fhZNCCentroid), 
149   fhZNACentroid(ana.fhZNACentroid), 
150   fhZNCemd(ana.fhZNCemd),        
151   fhZNAemd(ana.fhZNAemd),
152   fhPMCZNCemd(ana.fhPMCZNCemd), 
153   fhPMCZNAemd(ana.fhPMCZNAemd),
154   fDebunch(ana.fDebunch)
155 {
156   //
157   // Copy Constructor   
158   //
159 }
160  
161 //________________________________________________________________________
162 AliAnalysisTaskZDC::~AliAnalysisTaskZDC()
163 {
164   // Destructor
165   if(fOutput && !AliAnalysisManager::GetAnalysisManager()->IsProofMode()){
166     delete fOutput; fOutput=0;
167   } 
168    
169 }  
170
171 //________________________________________________________________________
172 void AliAnalysisTaskZDC::UserCreateOutputObjects()
173 {
174   // Create the output containers
175
176   fOutput = new TList;
177   fOutput->SetOwner();
178   //fOutput->SetName("output");
179   
180   fhTDCZNSum = new TH1F("fhTDCZNSum","TDC_{ZNC}+TDC_{ZNA}",60,-100.,-40.);
181   fhTDCZNSum->GetXaxis()->SetTitle("TDC_{ZNC}+TDC_{ZNA} (ns)");
182   fOutput->Add(fhTDCZNSum);      
183   
184   fhTDCZNDiff = new TH1F("fhTDCZNDiff","TDC_{ZNC}-TDC_{ZNA}",60,-30.,30.);
185   fhTDCZNDiff->GetXaxis()->SetTitle("TDC_{ZNC}-TDC_{ZNA} (ns)");
186   fOutput->Add(fhTDCZNDiff);      
187   
188   fhZNCSpectrum = new TH1F("fhZNCSpectrum", "ZNC signal", 200,0., 140000.);
189   fOutput->Add(fhZNCSpectrum);      
190   fhZNASpectrum = new TH1F("fhZNASpectrum", "ZNA signal", 200,0., 140000.) ;
191   fOutput->Add(fhZNASpectrum);      
192   fhZPCSpectrum = new TH1F("fhZPCSpectrum", "ZPC signal", 200,0., 50000.) ;
193   fOutput->Add(fhZPCSpectrum);      
194   fhZPASpectrum = new TH1F("fhZPASpectrum", "ZPA signal", 200,0., 50000.) ;
195   fOutput->Add(fhZPASpectrum);      
196   fhZEM1Spectrum = new TH1F("fhZEM1Spectrum", "ZEM1 signal", 100,0., 2500.);
197   fOutput->Add(fhZEM1Spectrum);      
198   fhZEM2Spectrum = new TH1F("fhZEM2Spectrum", "ZEM2 signal", 100,0., 2500.);
199   fOutput->Add(fhZEM2Spectrum);      
200   
201   fhZNCpmc = new TH1F("fhZNCpmc","ZNC PMC",200, 0., 160000.);
202   fOutput->Add(fhZNCpmc);      
203   fhZNApmc = new TH1F("fhZNApmc","ZNA PMC",200, 0., 160000.); 
204   fOutput->Add(fhZNApmc);      
205   fhZPCpmc = new TH1F("fhZPCpmc","ZPC PMC",200, 0., 40000.); 
206   fOutput->Add(fhZPCpmc);      
207   fhZPApmc = new TH1F("fhZPApmc","ZPA PMC",200, 0., 40000.); 
208   fOutput->Add(fhZPApmc);      
209   
210   fhZNCCentroid = new TH2F("fhZNCCentroid","Centroid over ZNC",70,-3.5,3.5,70,-3.5,3.5); 
211   fOutput->Add(fhZNCCentroid);      
212   fhZNACentroid = new TH2F("fhZNACentroid","Centroid over ZNA",70,-3.5,3.5,70,-3.5,3.5); 
213   fOutput->Add(fhZNACentroid);      
214   
215   fhZNCemd = new TH1F("fhZNCemd","ZNC signal lg",200,0.,6000.);  
216   fOutput->Add(fhZNCemd);      
217   fhZNAemd = new TH1F("fhZNAemd","ZNA signal lg",200,0.,6000.);  
218   fOutput->Add(fhZNAemd);      
219   fhPMCZNCemd = new TH1F("fhPMCZNCemd","ZNC PMC lg",200, 10., 6000.);   
220   fOutput->Add(fhPMCZNCemd);      
221   fhPMCZNAemd = new TH1F("fhPMCZNAemd","ZNA PMC lg",200, 10., 6000.);   
222   fOutput->Add(fhPMCZNAemd);     
223   
224   fDebunch = new TH2F("fDebunch","ZN TDC sum vs. diff", 120,-30,30,120,-100,-40);
225   fOutput->Add(fDebunch);     
226     
227   PostData(1, fOutput);
228 }
229
230 //________________________________________________________________________
231 void AliAnalysisTaskZDC::UserExec(Option_t */*option*/)
232 {
233   // Execute analysis for current event:
234   if(fDebug>1) printf(" **** AliAnalysisTaskZDC::UserExec() \n");
235   
236   if (!InputEvent()) {
237     Printf("ERROR: InputEvent not available");
238     return;
239   }
240
241       
242   AliESDEvent* esd = dynamic_cast<AliESDEvent*> (InputEvent());
243   // Select PHYSICS events (type=7, for data)
244   if(!fIsMCInput && esd->GetEventType()!=7) return; 
245   
246   // ********* MC INFO *********************************
247   if(fIsMCInput){
248
249     AliMCEventHandler* eventHandler = dynamic_cast<AliMCEventHandler*> (AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler());
250     if (!eventHandler) {
251       Printf("ERROR: Could not retrieve MC event handler");
252       return;
253     }
254   
255     AliMCEvent* mcEvent = eventHandler->MCEvent();
256     if (!mcEvent) {
257       Printf("ERROR: Could not retrieve MC event");
258       return;
259    }
260
261     AliGenEventHeader* genHeader = mcEvent->GenEventHeader();
262     if(!genHeader){
263       printf("  Event generator header not available!!!\n");
264       return;
265     }
266
267     /*if(genHeader->InheritsFrom(AliGenHijingEventHeader::Class())){
268       Float_t bMC = ((AliGenHijingEventHeader*) genHeader)->ImpactParameter();
269       Int_t specNeutronProj = ((AliGenHijingEventHeader*) genHeader)->ProjSpectatorsn();
270       Int_t specProtonProj  = ((AliGenHijingEventHeader*) genHeader)->ProjSpectatorsp();
271       Int_t specNeutronTarg = ((AliGenHijingEventHeader*) genHeader)->TargSpectatorsn();
272       Int_t specProtonTarg  = ((AliGenHijingEventHeader*) genHeader)->TargSpectatorsp();
273       Int_t npartTargMC = 208-(specNeutronTarg+specProtonTarg);
274       Int_t npartProjMC = 208-(specNeutronProj+specProtonProj);
275     }*/  
276
277   }
278   // ****************************************************
279   
280   AliAnalysisManager *am = AliAnalysisManager::GetAnalysisManager();
281   
282   if((((AliInputEventHandler*)(am->GetInputEventHandler()))->IsEventSelected() & AliVEvent::kMB)){
283     
284     AliESDZDC *esdZDC = esd->GetESDZDC();
285   
286     for(Int_t i=0; i<4; i++){
287       fhTDCZNSum->Fill(esdZDC->GetZNTDCDiff(i));  
288       fhTDCZNDiff->Fill(esdZDC->GetZNTDCSum(i)); 
289     }
290     fhZNCSpectrum->Fill(esdZDC->GetZDCN1Energy());        
291     fhZNASpectrum->Fill(esdZDC->GetZDCN2Energy());
292     fhZPCSpectrum->Fill(esdZDC->GetZDCP1Energy());                
293     fhZPASpectrum->Fill(esdZDC->GetZDCP2Energy());        
294     fhZEM1Spectrum->Fill(esdZDC->GetZDCEMEnergy(0)/8.);
295     fhZEM2Spectrum->Fill(esdZDC->GetZDCEMEnergy(1)/8.);
296   
297     const Double_t * towZNC = esdZDC->GetZN1TowerEnergy();
298     const Double_t * towZPC = esdZDC->GetZP1TowerEnergy();
299     const Double_t * towZNA = esdZDC->GetZN2TowerEnergy();
300     const Double_t * towZPA = esdZDC->GetZP2TowerEnergy();
301     //    
302     fhZNCpmc->Fill(towZNC[0]);    
303     fhZNApmc->Fill(towZPC[0]);    
304     fhZPCpmc->Fill(towZNA[0]);    
305     fhZPApmc->Fill(towZPA[0]);    
306   
307     Double_t xyZNC[2]={-99.,-99.}, xyZNA[2]={-99.,-99.};
308     esdZDC->GetZNCentroidInPbPb(1380., xyZNC, xyZNA);
309     //esdZDC->GetZNCentroidInpp(xyZNC, xyZNA);
310     
311     fhZNCCentroid->Fill(xyZNC[0], xyZNC[1]); 
312     fhZNACentroid->Fill(xyZNA[0], xyZNA[1]); 
313     
314     const Double_t * towZNCLG = esdZDC->GetZN1TowerEnergyLR();
315     const Double_t * towZNALG = esdZDC->GetZN2TowerEnergyLR();
316     Double_t znclg=0., znalg=0.;
317     for(Int_t iq=0; iq<5; iq++){
318        znclg += towZNCLG[iq];
319        znalg += towZNALG[iq];
320     }
321     fhZNCemd->Fill(znclg);       
322     fhZNAemd->Fill(znalg);       
323     fhPMCZNCemd->Fill(towZNCLG[0]);   
324     fhPMCZNAemd->Fill(towZNALG[0]);   
325     
326     Float_t tdcC = esdZDC->GetZDCTDCCorrected(10,0)-esdZDC->GetZDCTDCCorrected(15,0);
327     Float_t tdcA = esdZDC->GetZDCTDCCorrected(12,0)-esdZDC->GetZDCTDCCorrected(15,0);
328     fDebunch->Fill(tdcC-tdcA, tdcC+tdcA);
329   
330     PostData(1, fOutput);
331   
332   }
333    
334 }
335
336
337
338 //________________________________________________________________________
339 void AliAnalysisTaskZDC::Terminate(Option_t */*option*/)
340 {
341   // Terminate analysis
342   //
343 }