]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ESDCheck/AliVZEROQATask.cxx
Adding OpenFile in CreateOutput (Yves)
[u/mrichter/AliRoot.git] / ESDCheck / AliVZEROQATask.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
16 /* $Id$ */
17 //
18 // An analysis task to check the ESD VZERO data in simulated data
19 //
20 //////////////////////////////////////////////////////////////////////////////
21
22  
23 #include <TROOT.h>
24 #include <TChain.h>
25 #include <TH1.h>
26 #include <TH1F.h>
27 #include <TH1I.h>
28 #include <TCanvas.h>
29 #include <TLegend.h> 
30 #include <TVector3.h> 
31 #include <TFile.h> 
32
33 #include "AliVZEROQATask.h" 
34 #include "AliESD.h" 
35 #include "AliESDVZERO.h"
36 #include "AliLog.h"
37
38 //______________________________________________________________________________
39 AliVZEROQATask::AliVZEROQATask(const char *name) : 
40   AliAnalysisTask(name,""),  
41   fChain(0),
42   fESD(0),
43   fOutputContainer(0), 
44   fhVZERONbPMA(0),
45   fhVZERONbPMC(0),
46   fhVZEROMultA(0),
47   fhVZEROMultC(0)
48      
49 {
50   // Constructor.
51   // Input slot #0 works with an Ntuple
52   DefineInput(0, TChain::Class());
53   // Output slot #0 writes into a TH1 container
54   DefineOutput(0,  TObjArray::Class()) ; 
55 }
56
57 //______________________________________________________________________________
58 AliVZEROQATask::~AliVZEROQATask()
59 {
60   // dtor
61   
62   fOutputContainer->Clear(); 
63   delete fOutputContainer; 
64   
65   delete fhVZERONbPMA;
66   delete fhVZERONbPMC; 
67   delete fhVZEROMultA;
68   delete fhVZEROMultC;
69 }
70
71 //______________________________________________________________________________
72 void AliVZEROQATask::ConnectInputData(const Option_t*)
73 {
74   // Initialises branch container and histograms 
75     
76   AliInfo(Form("*** Initialization of %s", GetName())) ; 
77   
78   // Gets input data
79   fChain = dynamic_cast<TChain *>(GetInputData(0)) ;
80   if (!fChain) {
81     AliError(Form("Input 0 for %s not found\n", GetName()));
82     return ;
83   }
84   
85   // One should first check if the branch address was taken by some other task
86   char ** address = (char **)GetBranchAddress(0, "ESD");
87   if (address) {
88     fESD = (AliESD*)(*address);
89   } else {
90     fESD = new AliESD();
91     SetBranchAddress(0, "ESD", &fESD);
92   }
93 }
94
95 //________________________________________________________________________
96 void AliVZEROQATask::CreateOutputObjects()
97 {  
98   // Creates histograms 
99      
100   OpenFile(0) ; 
101
102   fhVZERONbPMA  = new TH1I("Nb of fired PMs in V0A", "VZERONbPMA" ,100 ,0 ,99);
103   fhVZERONbPMC  = new TH1I("Nb of fired PMs in V0C", "VZERONbPMC" ,100 ,0 ,99);
104   fhVZEROMultA  = new TH1I("Multiplicity in V0A", "VZEROMultA" ,50 ,0 ,49);
105   fhVZEROMultC  = new TH1I("Multiplicity in V0C", "VZEROMultC" ,50 ,0 ,49);
106   
107   // Creates output container
108   
109   fOutputContainer = new TObjArray(4); 
110   fOutputContainer->SetName(GetName()) ; 
111   fOutputContainer->AddAt(fhVZERONbPMA, 0); 
112   fOutputContainer->AddAt(fhVZERONbPMC, 1); 
113   fOutputContainer->AddAt(fhVZEROMultA, 2); 
114   fOutputContainer->AddAt(fhVZEROMultC, 3); 
115    
116 }
117
118 //______________________________________________________________________________
119 void AliVZEROQATask::Exec(Option_t *) 
120 {
121   // Processing of one event
122   Long64_t entry = fChain->GetReadEntry() ;
123
124   if (!fESD) {
125     AliError("fESD is not connected to the input!") ; 
126     return ; 
127   }
128   
129   if ( !((entry-1)%100) ) 
130     AliInfo(Form("%s ----> Processing event # %lld",  (dynamic_cast<TChain *>(fChain))->GetFile()->GetName(), entry)) ; 
131  
132   AliESDVZERO *esdVZERO=fESD->GetVZEROData();
133    
134   if (esdVZERO) { 
135     fhVZERONbPMA->Fill(esdVZERO->GetNbPMV0A());
136     fhVZERONbPMC->Fill(esdVZERO->GetNbPMV0C());  
137     fhVZEROMultA->Fill(esdVZERO->GetMTotV0A());
138     fhVZEROMultC->Fill(esdVZERO->GetMTotV0C());  
139   }
140   PostData(0, fOutputContainer);
141   
142 }
143
144 //______________________________________________________________________________
145 void AliVZEROQATask::Terminate(Option_t *)
146 {
147   // Processed when the event loop is ended
148   
149   fOutputContainer = (TObjArray*)GetOutputData(0);
150   fhVZERONbPMA     = (TH1I*)fOutputContainer->At(0);
151   fhVZERONbPMC     = (TH1I*)fOutputContainer->At(1);
152   fhVZEROMultA     = (TH1I*)fOutputContainer->At(2);
153   fhVZEROMultC     = (TH1I*)fOutputContainer->At(3);
154   
155   Bool_t problem = kFALSE ; 
156   AliInfo(Form(" *** %s Report:", GetName())) ; 
157   printf("        V0A Multiplicity Mean : %5.3f , RMS : %5.3f \n",fhVZEROMultA->GetMean(),fhVZEROMultA->GetRMS());
158   printf("        V0C Multiplicity Mean : %5.3f , RMS : %5.3f \n",fhVZEROMultC->GetMean(),fhVZEROMultC->GetRMS());
159
160   TCanvas  * c1 = new TCanvas("Number of PMs fired in V0A", "Number of PMs fired in V0A", 1);
161   fhVZERONbPMA->SetAxisRange(0, 99);
162   fhVZERONbPMA->SetLineColor(2);
163   fhVZERONbPMA->Draw("SAME");
164   c1->Update();
165  
166   TCanvas  * c2 = new TCanvas("Number of PMs fired in V0C", "Number of PMs fired in V0C", 1);
167   fhVZERONbPMC->SetAxisRange(0,99);
168   fhVZERONbPMC->SetLineColor(2);
169   fhVZERONbPMC->Draw("SAME");
170   c2->Update();
171
172   TCanvas  * c3 = new TCanvas("Multiplicity in V0A", "Multiplicity in V0A", 1);
173   fhVZEROMultA->SetAxisRange(0, 49);
174   fhVZEROMultA->SetLineColor(2);
175   fhVZEROMultA->Draw("SAME");
176   c3->Update();
177  
178   TCanvas  * c4 = new TCanvas("Multiplicity in V0C", "Multiplicity in V0C", 1);
179   fhVZEROMultC->SetAxisRange(0,49);
180   fhVZEROMultC->SetLineColor(2);
181   fhVZEROMultC->Draw("SAME");
182   c4->Update();
183
184   c1->Print("V0AMultiplicity.eps");
185   c2->Print("V0CMultiplicity.eps");
186   c3->Print("NumberV0APMs.eps");
187   c4->Print("NumberV0CPMs.eps");
188   
189   char line[1024] ; 
190   sprintf(line, ".!tar -zcf %s.tar.gz *.eps", GetName()) ; 
191   gROOT->ProcessLine(line);
192   sprintf(line, ".!rm -fR *.eps"); 
193   gROOT->ProcessLine(line);
194  
195   AliInfo(Form("!!! All the eps files are in %s.tar.gz !!! ", GetName())) ;
196   
197   char * report ; 
198   if(problem)
199     report="Problems found, please check!!!";  
200   else 
201     report="OK";
202   
203   AliInfo(Form("*** %s Summary Report: %s\n",GetName(), report)) ; 
204   
205 }