]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ESDCheck/AliMUONQATask.cxx
Removed the AliHLTPHOSValidCellDataStruct.h from Makefile.am
[u/mrichter/AliRoot.git] / ESDCheck / AliMUONQATask.cxx
CommitLineData
1dfe075f 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// An analysis task to check the MUON data in simulated data
16//
17//*-- Ivana Hrivnacova
18//////////////////////////////////////////////////////////////////////////////
19//////////////////////////////////////////////////////////////////////////////
20
21#include <TChain.h>
22#include <TFile.h>
23#include <TH1F.h>
24#include <TCanvas.h>
25
26#include "AliMUONQATask.h"
27#include "AliESD.h"
28#include "AliLog.h"
29#include "AliESDVertex.h"
30#include "AliESDMuonTrack.h"
31
32//______________________________________________________________________________
33AliMUONQATask::AliMUONQATask(const char *name) :
34 AliAnalysisTask(name,""),
35 fChain(0),
36 fESD(0),
37 fnTrackTrig(0),
38 ftracktot(0),
39 fnevents(0),
40 fSPLowpt(0),
41 fSPHighpt(0),
42 fSPAllpt(0),
43 fSMLowpt(0),
44 fSMHighpt(0),
45 fSMAllpt(0),
46 fSULowpt(0),
47 fSUHighpt(0),
48 fSUAllpt(0),
49 fUSLowpt(0),
50 fUSHighpt(0),
51 fUSAllpt(0),
52 fLSLowpt(0),
53 fLSHighpt(0),
54 fLSAllpt(0),
55 fhMUONVertex(0),
56 fhMUONMult(0)
57{
58 // Constructor.
59 // Input slot #0 works with an Ntuple
60 DefineInput(0, TChain::Class());
61 // Output slot #0 writes into a TH1 container
62 DefineOutput(0, TObjArray::Class()) ;
63}
64
65//______________________________________________________________________________
66AliMUONQATask::~AliMUONQATask()
67{
68 // dtor
69 fOutputContainer->Clear() ;
70 delete fOutputContainer ;
71
72 delete fhMUONVertex ;
73 delete fhMUONMult ;
74}
75
76//______________________________________________________________________________
77void AliMUONQATask::Init(const Option_t*)
78{
79 // Initialisation of branch container and histograms
80
81 AliInfo(Form("*** Initialization of %s", GetName())) ;
82
83 // Get input data
84 fChain = dynamic_cast<TChain *>(GetInputData(0)) ;
85 if (!fChain) {
86 AliError(Form("Input 0 for %s not found\n", GetName()));
87 return ;
88 }
89
90 if (!fESD) {
91 // One should first check if the branch address was taken by some other task
92 char ** address = (char **)GetBranchAddress(0, "ESD") ;
93 if (address)
94 fESD = (AliESD *)(*address) ;
95 if (!fESD)
96 fChain->SetBranchAddress("ESD", &fESD) ;
97 }
98 // The output objects will be written to
99 TDirectory * cdir = gDirectory ;
100 // Open a file for output #0
101 char outputName[1024] ;
102 sprintf(outputName, "%s.root", GetName() ) ;
103 OpenFile(0, outputName , "RECREATE") ;
104 if (cdir)
105 cdir->cd() ;
106
107 // create histograms
108 fhMUONVertex = new TH1F("hMUONVertex","ITS Vertex" ,100, -25., 25.);
109 fhMUONMult = new TH1F("hMUONMult" ,"Multiplicity of ESD tracks",10, -0.5, 9.5);
110
111
112 // create output container
113
114 fOutputContainer = new TObjArray(2) ;
115 fOutputContainer->SetName(GetName()) ;
116
117 fOutputContainer->AddAt(fhMUONVertex, 0) ;
118 fOutputContainer->AddAt(fhMUONMult, 1) ;
119}
120
121//______________________________________________________________________________
122void AliMUONQATask::Exec(Option_t *)
123{
124 // Processing of one event
125
126 fnevents++ ;
127
128 Long64_t entry = fChain->GetReadEntry() ;
129
130 if (!fESD) {
131 AliError("fESD is not connected to the input!") ;
132 return ;
133 }
134
135 if ( !((entry-1)%100) )
136 AliInfo(Form("%s ----> Processing event # %lld", (dynamic_cast<TChain *>(fChain))->GetFile()->GetName(), entry)) ;
137
138 // ************************ MUON *************************************
139
140 const AliESDVertex* vertex = dynamic_cast<const AliESDVertex*>(fESD->GetVertex()) ;
141
142 Double_t zVertex = 0. ;
143 if (vertex)
144 zVertex = vertex->GetZv() ;
145
146 Int_t nTracks = fESD->GetNumberOfMuonTracks() ;
147
148 ULong64_t trigWord = fESD->GetTriggerMask() ;
149
150 if (trigWord & 0x01)
151 fSPLowpt++;
152 if (trigWord & 0x02)
153 fSPHighpt++;
154 if (trigWord & 0x04)
155 fSPAllpt++;
156 if (trigWord & 0x08)
157 fSMLowpt++;
158 if (trigWord & 0x010)
159 fSMHighpt++;
160 if (trigWord & 0x020)
161 fSMAllpt++;
162 if (trigWord & 0x040)
163 fSULowpt++;
164 if (trigWord & 0x080)
165 fSUHighpt++;
166 if (trigWord & 0x100)
167 fSUAllpt++;
168 if (trigWord & 0x200)
169 fUSLowpt++;
170 if (trigWord & 0x400)
171 fUSHighpt++;
172 if (trigWord & 0x800)
173 fUSAllpt++;
174 if (trigWord & 0x1000)
175 fLSLowpt++;
176 if (trigWord & 0x2000)
177 fLSHighpt++;
178 if (trigWord & 0x4000)
179 fLSAllpt++;
180
181 Int_t tracktrig = 0 ;
182 Int_t iTrack1 ;
183
184 for (iTrack1 = 0 ; iTrack1 < nTracks ; iTrack1++) { //1st loop
185 AliESDMuonTrack* muonTrack = fESD->GetMuonTrack(iTrack1) ;
186 ftracktot++ ;
187 if(muonTrack->GetMatchTrigger()) {
188 fnTrackTrig++ ;
189 tracktrig++ ;
190 }
191 }
192
193 fhMUONVertex->Fill(zVertex) ;
194 fhMUONMult->Fill(Float_t(nTracks)) ;
195
196 PostData(0, fOutputContainer);
197}
198
199//______________________________________________________________________________
200void AliMUONQATask::Terminate(Option_t *)
201{
202 // Processing when the event loop is ended
203
204 AliInfo(Form("Terminate %s:", GetName())) ;
205
958d6715 206 Int_t eff_match = -1 ;
207 if (ftracktot)
208 eff_match = 100 * fnTrackTrig / ftracktot ;
1dfe075f 209
210 printf("===================================================\n") ;
211 printf("================ %s ESD SUMMARY ==============\n", GetName()) ;
212 printf(" \n") ;
213 printf(" Total number of processed events %d \n", fnevents) ;
214 printf("\n") ;
215 printf("\n") ;
216 printf("Table 4: \n") ;
217 printf(" Global Trigger output Low pt High pt All\n") ;
218 printf(" number of Single Plus :\t");
219 printf("%i\t%i\t%i\t", fSPLowpt, fSPHighpt, fSPAllpt) ;
220 printf("\n");
221 printf(" number of Single Minus :\t");
222 printf("%i\t%i\t%i\t", fSMLowpt, fSMHighpt, fSMAllpt) ;
223 printf("\n");
224 printf(" number of Single Undefined :\t");
225 printf("%i\t%i\t%i\t", fSULowpt, fSUHighpt, fSUAllpt) ;
226 printf("\n");
227 printf(" number of UnlikeSign pair :\t");
228 printf("%i\t%i\t%i\t", fUSLowpt, fUSHighpt, fUSAllpt) ;
229 printf("\n");
230 printf(" number of LikeSign pair :\t");
231 printf("%i\t%i\t%i\t", fLSLowpt, fLSHighpt, fLSAllpt) ;
232 printf("\n");
233 printf("===================================================\n") ;
234 printf("\n") ;
235 printf("matching efficiency with the trigger for single tracks = %2d %% \n", eff_match);
236
237 TCanvas * cMUON = new TCanvas("cMUON", "MUON ESD Test", 400, 10, 600, 700) ;
238 cMUON->Divide(1,2) ;
239 cMUON->cd(1) ;
240 fhMUONVertex->Draw() ;
241 cMUON->cd(2) ;
242 fhMUONMult->Draw() ;
243 cMUON->Print("MUON.eps") ;
244
245 char line[1024] ;
246 sprintf(line, ".!tar -zcvf %s.tar.gz *.eps", GetName()) ;
247 gROOT->ProcessLine(line);
248 sprintf(line, ".!rm -fR *.eps");
249 gROOT->ProcessLine(line);
250
251 AliInfo(Form("!!! All the eps files are in %s.tar.gz !!! \n", GetName())) ;
252}