]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGPP/ZDC/AliAnalysisTaskZDCpA.cxx
Added macros and scripts for ZDC QA automatic trending (M.Leoncino)
[u/mrichter/AliRoot.git] / PWGPP / ZDC / AliAnalysisTaskZDCpA.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 "AliAnalysisTaskZDCpA.h"
54
55 ClassImp(AliAnalysisTaskZDCpA)
56
57
58 //________________________________________________________________________
59 AliAnalysisTaskZDCpA::AliAnalysisTaskZDCpA():
60   AliAnalysisTaskSE(),
61     fDebug(0),
62     fIsMCInput(kFALSE),
63     fOutput(0x0),
64     fhTDCZNC(0x0),
65     fhTDCZNA(0x0),
66     fhTDCZNSum(0x0),
67     fhTDCZNDiff(0x0),
68     fhZNCSumQ(0x0),
69     fhZNASumQ(0x0),
70     fhZPCSumQ(0x0),
71     fhZPASumQ(0x0),
72     fhZEM1Spectrum(0x0),
73     fhZEM2Spectrum(0x0),
74     fhZNCpmc(0x0),       
75     fhZNApmc(0x0),       
76     fhZPCpmc(0x0),       
77     fhZPApmc(0x0),       
78     fhZNCCentroid(0x0), 
79     fhZNACentroid(0x0), 
80     fhPMCZNCemd(0x0), 
81     fhPMCZNAemd(0x0),
82     fDebunch(0x0),
83     fhTDCZNAcorr(0x0),
84     fhTDCZNCcorr(0x0)
85 {   
86    // Default constructor
87 }   
88
89 //________________________________________________________________________
90 AliAnalysisTaskZDCpA::AliAnalysisTaskZDCpA(const char *name):
91   AliAnalysisTaskSE(name),
92     fDebug(0),
93     fIsMCInput(kFALSE),
94     fOutput(0x0),
95     fhTDCZNC(0x0),
96     fhTDCZNA(0x0),
97     fhTDCZNSum(0x0),
98     fhTDCZNDiff(0x0),
99     fhZNCSumQ(0x0),
100     fhZNASumQ(0x0),
101     fhZPCSumQ(0x0),
102     fhZPASumQ(0x0),
103     fhZEM1Spectrum(0x0),
104     fhZEM2Spectrum(0x0),
105     fhZNCpmc(0x0),       
106     fhZNApmc(0x0),       
107     fhZPCpmc(0x0),       
108     fhZPApmc(0x0),       
109     fhZNCCentroid(0x0), 
110     fhZNACentroid(0x0), 
111     fhPMCZNCemd(0x0), 
112     fhPMCZNAemd(0x0),
113     fDebunch(0x0),
114     fhTDCZNAcorr(0x0),
115     fhTDCZNCcorr(0x0)
116
117 {  
118   // Output slot #1 writes into a TList container
119   DefineOutput(1, TList::Class()); 
120
121 }
122
123 //________________________________________________________________________
124 AliAnalysisTaskZDCpA& AliAnalysisTaskZDCpA::operator=(const AliAnalysisTaskZDCpA& c)
125 {
126   //
127   // Assignment operator
128   //
129   if (this!=&c) {
130     AliAnalysisTaskSE::operator=(c);
131   }
132   return *this;
133 }
134
135 //________________________________________________________________________
136 AliAnalysisTaskZDCpA::AliAnalysisTaskZDCpA(const AliAnalysisTaskZDCpA& ana):
137   AliAnalysisTaskSE(ana),
138   fDebug(ana.fDebug),     
139   fIsMCInput(ana.fIsMCInput),
140   fOutput(ana.fOutput),
141   fhTDCZNC(ana.fhTDCZNC),
142   fhTDCZNA(ana.fhTDCZNA),
143   fhTDCZNSum(ana.fhTDCZNSum),
144   fhTDCZNDiff(ana.fhTDCZNDiff),
145   fhZNCSumQ(ana.fhZNCSumQ),
146   fhZNASumQ(ana.fhZNASumQ),
147   fhZPCSumQ(ana.fhZPCSumQ),
148   fhZPASumQ(ana.fhZPASumQ),
149   fhZEM1Spectrum(ana.fhZEM1Spectrum),
150   fhZEM2Spectrum(ana.fhZEM2Spectrum),
151   fhZNCpmc(ana.fhZNCpmc),       
152   fhZNApmc(ana.fhZNApmc),       
153   fhZPCpmc(ana.fhZPCpmc),       
154   fhZPApmc(ana.fhZPApmc),       
155   fhZNCCentroid(ana.fhZNCCentroid), 
156   fhZNACentroid(ana.fhZNACentroid), 
157   fhPMCZNCemd(ana.fhPMCZNCemd), 
158   fhPMCZNAemd(ana.fhPMCZNAemd),
159   fDebunch(ana.fDebunch),
160   fhTDCZNAcorr(ana.fhTDCZNAcorr),
161   fhTDCZNCcorr(ana.fhTDCZNCcorr)
162
163 {
164   //
165   // Copy Constructor   
166   //
167 }
168  
169 //________________________________________________________________________
170 AliAnalysisTaskZDCpA::~AliAnalysisTaskZDCpA()
171 {
172   // Destructor
173   if(fOutput && !AliAnalysisManager::GetAnalysisManager()->IsProofMode()){
174     delete fOutput; fOutput=0;
175   } 
176    
177 }  
178
179 //________________________________________________________________________
180 void AliAnalysisTaskZDCpA::UserCreateOutputObjects()
181 {
182   // Create the output containers
183
184   fOutput = new TList;
185   fOutput->SetOwner();
186   //fOutput->SetName("output");
187   
188   fhTDCZNC = new TH1F("fhTDCZNC","TDC_{ZNC}",120, -60., -20.);
189   fhTDCZNC->GetXaxis()->SetTitle("TDC_{ZNC} (ns)");
190   fOutput->Add(fhTDCZNC);      
191   
192   fhTDCZNA = new TH1F("fhTDCZNA","TDC_{ZNA}",120, -60., -20.);
193   fhTDCZNA->GetXaxis()->SetTitle("TDC_{ZNA} (ns)");
194   fOutput->Add(fhTDCZNA);     
195   
196   fhTDCZNSum = new TH1F("fhTDCZNSum","TDC_{ZNC}+TDC_{ZNA}",120,-30.,30.);
197   fhTDCZNSum->GetXaxis()->SetTitle("TDC_{ZNC}+TDC_{ZNA} (ns)");
198   fOutput->Add(fhTDCZNSum);      
199   
200   fhTDCZNDiff = new TH1F("fhTDCZNDiff","TDC_{ZNC}-TDC_{ZNA}",120,-30.,30.);
201   fhTDCZNDiff->GetXaxis()->SetTitle("TDC_{ZNC}-TDC_{ZNA} (ns)");
202   fOutput->Add(fhTDCZNDiff);     
203   
204   fhZNCSumQ = new TH1F("fhZNCSumQ", "ZNC sumPMQ_i signal", 250,0., 2000.);
205   fOutput->Add(fhZNCSumQ);      
206   fhZNASumQ = new TH1F("fhZNASumQ", "ZNA sumPMQ_i signal", 250,0., 2000.) ;
207   fOutput->Add(fhZNASumQ);      
208   fhZPCSumQ = new TH1F("fhZPCSumQ", "ZPC sumPMQ_i signal", 200,0., 2000.) ;
209   fOutput->Add(fhZPCSumQ);      
210   fhZPASumQ = new TH1F("fhZPASumQ", "ZPA sumPMQ_i signal", 200,0., 2000.) ;
211   fOutput->Add(fhZPASumQ);      
212   fhZEM1Spectrum = new TH1F("fhZEM1Spectrum", "ZEM1 signal", 100,0., 2500.);
213   fOutput->Add(fhZEM1Spectrum);      
214   fhZEM2Spectrum = new TH1F("fhZEM2Spectrum", "ZEM2 signal", 100,0., 2500.);
215   fOutput->Add(fhZEM2Spectrum);      
216   
217   fhZNCpmc = new TH1F("fhZNCpmc","ZNC PMC", 200, 0., 2000.);
218   fOutput->Add(fhZNCpmc);      
219   fhZNApmc = new TH1F("fhZNApmc","ZNA PMC", 200, 0., 2000.); 
220   fOutput->Add(fhZNApmc);      
221   fhZPCpmc = new TH1F("fhZPCpmc","ZPC PMC", 200, 0., 2000.); 
222   fOutput->Add(fhZPCpmc);      
223   fhZPApmc = new TH1F("fhZPApmc","ZPA PMC", 200, 0., 2000.); 
224   fOutput->Add(fhZPApmc);      
225   
226   fhZNCCentroid = new TH2F("fhZNCCentroid","Centroid over ZNC",70,-3.5,3.5,70,-3.5,3.5); 
227   fOutput->Add(fhZNCCentroid);      
228   fhZNACentroid = new TH2F("fhZNACentroid","Centroid over ZNA",70,-3.5,3.5,70,-3.5,3.5); 
229   fOutput->Add(fhZNACentroid);      
230   
231   fhPMCZNCemd = new TH1F("fhPMCZNCemd","ZNC PMC lg",200, 0., 600.);   
232   fOutput->Add(fhPMCZNCemd);      
233   fhPMCZNAemd = new TH1F("fhPMCZNAemd","ZNA PMC lg",200, 0., 600.);   
234   fOutput->Add(fhPMCZNAemd);     
235   
236   fDebunch = new TH2F("fDebunch","ZN TDC sum vs. diff", 120,-30,30,120,-30,-30);
237   fOutput->Add(fDebunch);     
238   
239   fhTDCZNAcorr = new TH1F("fhTDCZNAcorr","ZNA TDC corrected",120, -20., 20.);
240   fOutput->Add(fhTDCZNAcorr);
241   
242   fhTDCZNCcorr = new TH1F("fhTDCZNCcorr","ZNC TDC corrected",120, -20., 20.);
243   fOutput->Add(fhTDCZNCcorr);
244     
245   
246   PostData(1, fOutput);
247 }
248
249 //________________________________________________________________________
250 void AliAnalysisTaskZDCpA::UserExec(Option_t */*option*/)
251 {
252   // Execute analysis for current event:
253   if(fDebug>1) printf(" **** AliAnalysisTaskZDCpA::UserExec() \n");
254   
255   if (!InputEvent()) {
256     Printf("ERROR: InputEvent not available");
257     return;
258   }
259
260       
261   AliESDEvent* esd = dynamic_cast<AliESDEvent*> (InputEvent());
262   if(!esd) return;
263   // Select PHYSICS events (type=7, for data)
264   //if(!fIsMCInput && esd->GetEventType()!=7) return; 
265   
266   // ********* MC INFO *********************************
267   if(fIsMCInput){
268
269     AliMCEventHandler* eventHandler = dynamic_cast<AliMCEventHandler*> (AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler());
270     if (!eventHandler) {
271       Printf("ERROR: Could not retrieve MC event handler");
272       return;
273     }
274   
275     AliMCEvent* mcEvent = eventHandler->MCEvent();
276     if (!mcEvent) {
277       Printf("ERROR: Could not retrieve MC event");
278       return;
279    }
280
281   }
282   // ****************************************************
283   
284 //  AliAnalysisManager *am = AliAnalysisManager::GetAnalysisManager();
285     
286   AliESDZDC *esdZDC = esd->GetESDZDC();
287   
288 //  if((((AliInputEventHandler*)(am->GetInputEventHandler()))->IsEventSelected())){
289
290     fhZEM1Spectrum->Fill(esdZDC->GetZDCEMEnergy(0));
291     fhZEM2Spectrum->Fill(esdZDC->GetZDCEMEnergy(1));
292   
293     const Double_t * towZNC = esdZDC->GetZN1TowerEnergy();
294     const Double_t * towZPC = esdZDC->GetZP1TowerEnergy();
295     const Double_t * towZNA = esdZDC->GetZN2TowerEnergy();
296     const Double_t * towZPA = esdZDC->GetZP2TowerEnergy();
297     //    
298     fhZNCpmc->Fill(towZNC[0]);    
299     fhZNApmc->Fill(towZNA[0]);    
300     fhZPCpmc->Fill(towZPC[0]);    
301     fhZPApmc->Fill(towZPA[0]);
302     //
303     Float_t sumQZNC=0., sumQZNA=0., sumQZPC=0., sumQZPA=0.;
304     for(int iq=1; iq<5; iq++){
305        sumQZNC += towZNC[iq];
306        sumQZNA += towZNA[iq];
307        sumQZPC += towZPC [iq];
308        sumQZPA += towZNC[iq];
309     }     
310   
311     fhZNCSumQ->Fill(sumQZNC);     
312     fhZNASumQ->Fill(sumQZNA);
313     fhZPCSumQ->Fill(sumQZPC);             
314     fhZPASumQ->Fill(sumQZPA);     
315   
316     Double_t xyZNC[2]={-99.,-99.}, xyZNA[2]={-99.,-99.};
317     esdZDC->GetZNCentroidInpp(xyZNC, xyZNA);
318     
319     fhZNCCentroid->Fill(xyZNC[0], xyZNC[1]); 
320     fhZNACentroid->Fill(xyZNA[0], xyZNA[1]); 
321     
322     const Double_t * towZNCLG = esdZDC->GetZN1TowerEnergyLR();
323     const Double_t * towZNALG = esdZDC->GetZN2TowerEnergyLR();
324     fhPMCZNCemd->Fill(towZNCLG[0]);   
325     fhPMCZNAemd->Fill(towZNALG[0]);   
326   
327 //  }
328     
329   for(int i=0; i<4; i++){
330     Float_t tdcC = 0.025*(esdZDC->GetZDCTDCData(10,i));
331     Float_t tdcA = 0.025*(esdZDC->GetZDCTDCData(12,i));
332     Float_t tdcL0 = 0.025*(esdZDC->GetZDCTDCData(15,i));
333     if(tdcC != 0.) fhTDCZNCcorr->Fill(esdZDC->GetZDCTDCCorrected(10,i));
334     if(tdcA != 0.) fhTDCZNAcorr->Fill(esdZDC->GetZDCTDCCorrected(12,i));
335     //
336     if(tdcC != 0.){
337       fhTDCZNC->Fill(tdcC-tdcL0);
338       if(tdcA != 0.){
339         fhTDCZNA->Fill(tdcA-tdcL0);
340         fhTDCZNDiff->Fill(esdZDC->GetZDCTDCCorrected(10,i)-esdZDC->GetZDCTDCCorrected(12,i));
341         fhTDCZNSum->Fill(esdZDC->GetZDCTDCCorrected(10,i)-esdZDC->GetZDCTDCCorrected(12,i));
342         fDebunch->Fill(esdZDC->GetZDCTDCCorrected(10,i)-esdZDC->GetZDCTDCCorrected(12,i),
343                        esdZDC->GetZDCTDCCorrected(10,i)+esdZDC->GetZDCTDCCorrected(12,i));
344       }
345     }
346   }  
347   
348   PostData(1, fOutput);
349    
350 }
351
352
353
354 //________________________________________________________________________
355 void AliAnalysisTaskZDCpA::Terminate(Option_t */*option*/)
356 {
357   // Terminate analysis
358   //
359 }