]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ESDCheck/AliMUONQATask.cxx
Adding the new MUONcalib library (Ivana)
[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 **************************************************************************/
0b28fd57 15
16/* $Id$ */
17
1dfe075f 18// An analysis task to check the MUON data in simulated data
19//
20//*-- Ivana Hrivnacova
21//////////////////////////////////////////////////////////////////////////////
22//////////////////////////////////////////////////////////////////////////////
23
0b28fd57 24#include <TCanvas.h>
1dfe075f 25#include <TChain.h>
26#include <TFile.h>
27#include <TH1F.h>
0b28fd57 28#include <TROOT.h>
1dfe075f 29
30#include "AliMUONQATask.h"
31#include "AliESD.h"
32#include "AliLog.h"
33#include "AliESDVertex.h"
34#include "AliESDMuonTrack.h"
35
36//______________________________________________________________________________
37AliMUONQATask::AliMUONQATask(const char *name) :
38 AliAnalysisTask(name,""),
39 fChain(0),
40 fESD(0),
41 fnTrackTrig(0),
42 ftracktot(0),
43 fnevents(0),
44 fSPLowpt(0),
45 fSPHighpt(0),
46 fSPAllpt(0),
47 fSMLowpt(0),
48 fSMHighpt(0),
49 fSMAllpt(0),
50 fSULowpt(0),
51 fSUHighpt(0),
52 fSUAllpt(0),
53 fUSLowpt(0),
54 fUSHighpt(0),
55 fUSAllpt(0),
56 fLSLowpt(0),
57 fLSHighpt(0),
58 fLSAllpt(0),
59 fhMUONVertex(0),
60 fhMUONMult(0)
61{
62 // Constructor.
63 // Input slot #0 works with an Ntuple
64 DefineInput(0, TChain::Class());
65 // Output slot #0 writes into a TH1 container
66 DefineOutput(0, TObjArray::Class()) ;
67}
68
69//______________________________________________________________________________
70AliMUONQATask::~AliMUONQATask()
71{
72 // dtor
73 fOutputContainer->Clear() ;
74 delete fOutputContainer ;
75
76 delete fhMUONVertex ;
77 delete fhMUONMult ;
78}
79
80//______________________________________________________________________________
c52c2132 81void AliMUONQATask::ConnectInputData(const Option_t*)
1dfe075f 82{
83 // Initialisation of branch container and histograms
84
85 AliInfo(Form("*** Initialization of %s", GetName())) ;
86
87 // Get input data
88 fChain = dynamic_cast<TChain *>(GetInputData(0)) ;
89 if (!fChain) {
90 AliError(Form("Input 0 for %s not found\n", GetName()));
91 return ;
92 }
93
c52c2132 94 // One should first check if the branch address was taken by some other task
95 char ** address = (char **)GetBranchAddress(0, "ESD");
96 if (address) {
97 fESD = (AliESD*)(*address);
98 } else {
99 fESD = new AliESD();
100 SetBranchAddress(0, "ESD", &fESD);
1dfe075f 101 }
c52c2132 102}
103
104//________________________________________________________________________
105void AliMUONQATask::CreateOutputObjects()
106{
1dfe075f 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())) ;
c52c2132 205 fOutputContainer = (TObjArray*)GetOutputData(0);
206 fhMUONVertex = (TH1F*)fOutputContainer->At(0);
207 fhMUONMult = (TH1F*)fOutputContainer->At(1);
1dfe075f 208
958d6715 209 Int_t eff_match = -1 ;
210 if (ftracktot)
211 eff_match = 100 * fnTrackTrig / ftracktot ;
1dfe075f 212
213 printf("===================================================\n") ;
214 printf("================ %s ESD SUMMARY ==============\n", GetName()) ;
215 printf(" \n") ;
216 printf(" Total number of processed events %d \n", fnevents) ;
217 printf("\n") ;
218 printf("\n") ;
219 printf("Table 4: \n") ;
220 printf(" Global Trigger output Low pt High pt All\n") ;
221 printf(" number of Single Plus :\t");
222 printf("%i\t%i\t%i\t", fSPLowpt, fSPHighpt, fSPAllpt) ;
223 printf("\n");
224 printf(" number of Single Minus :\t");
225 printf("%i\t%i\t%i\t", fSMLowpt, fSMHighpt, fSMAllpt) ;
226 printf("\n");
227 printf(" number of Single Undefined :\t");
228 printf("%i\t%i\t%i\t", fSULowpt, fSUHighpt, fSUAllpt) ;
229 printf("\n");
230 printf(" number of UnlikeSign pair :\t");
231 printf("%i\t%i\t%i\t", fUSLowpt, fUSHighpt, fUSAllpt) ;
232 printf("\n");
233 printf(" number of LikeSign pair :\t");
234 printf("%i\t%i\t%i\t", fLSLowpt, fLSHighpt, fLSAllpt) ;
235 printf("\n");
236 printf("===================================================\n") ;
237 printf("\n") ;
238 printf("matching efficiency with the trigger for single tracks = %2d %% \n", eff_match);
239
240 TCanvas * cMUON = new TCanvas("cMUON", "MUON ESD Test", 400, 10, 600, 700) ;
241 cMUON->Divide(1,2) ;
242 cMUON->cd(1) ;
243 fhMUONVertex->Draw() ;
244 cMUON->cd(2) ;
245 fhMUONMult->Draw() ;
246 cMUON->Print("MUON.eps") ;
247
248 char line[1024] ;
249 sprintf(line, ".!tar -zcvf %s.tar.gz *.eps", GetName()) ;
250 gROOT->ProcessLine(line);
251 sprintf(line, ".!rm -fR *.eps");
252 gROOT->ProcessLine(line);
253
254 AliInfo(Form("!!! All the eps files are in %s.tar.gz !!! \n", GetName())) ;
255}