]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG3/muondep/AliAnalysisTaskMuonTrackingEff.cxx
Adding Id to PWG3 classes for better tracking of the coverity defect fixes (Ivana)
[u/mrichter/AliRoot.git] / PWG3 / muondep / AliAnalysisTaskMuonTrackingEff.cxx
CommitLineData
128a8042 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
27de2dfb 16/* $Id$ */
17
128a8042 18//Class to calculate the intrinsic efficiency of the detection elements of the
19//MUON tracking chambers in function of the position in the detection element.
79720f5b 20//WOrk on ESD only
128a8042 21//Author: Nicolas LE BRIS - SUBATECH Nantes
79720f5b 22// Modified by Matthieu LENHARDT - SUBATECH Nantes
128a8042 23
24
25//ROOT includes
128a8042 26#include <TChain.h>
27#include <TFile.h>
79720f5b 28#include <TList.h>
128a8042 29#include <TH2F.h>
30
31//ANALYSIS includes
32#include "AliAnalysisManager.h"
128a8042 33
34//STEER includes
35#include "AliESDEvent.h"
36#include "AliESDMuonTrack.h"
37#include "AliESDInputHandler.h"
f7a1cc68 38#include "AliMagF.h"
128a8042 39#include "AliTracker.h"
40#include "AliAnalysisManager.h"
fc7a3fd3 41#include "AliGeomManager.h"
79720f5b 42#include "AliCDBManager.h"
fc7a3fd3 43
128a8042 44
27f15548 45//PWG3/muondep includes
128a8042 46#include "AliAnalysisTaskMuonTrackingEff.h"
47#include "AliCheckMuonDetEltResponse.h"
48
49//MUON includes
128a8042 50#include "AliMUONTrackExtrap.h"
27f15548 51#include "AliMUONGeometryTransformer.h"
79720f5b 52#include "AliMUONConstants.h"
128a8042 53
54ClassImp(AliAnalysisTaskMuonTrackingEff)
55
27f15548 56const Int_t AliAnalysisTaskMuonTrackingEff::fgkTotNbrOfDetectionElt = 156;
79720f5b 57const Int_t AliAnalysisTaskMuonTrackingEff::fgkTotNbrOfChamber = AliMUONConstants::NTrackingCh();
128a8042 58
59//________________________________________________________________________
60AliAnalysisTaskMuonTrackingEff::AliAnalysisTaskMuonTrackingEff()
0246246b 61 :
0246246b 62 AliAnalysisTask(),
79720f5b 63 fIsInit(kFALSE),
64 fIsLoaded(kFALSE),
65 fOCDBpath(0),
66 fUsableTracks(0),
0246246b 67 fESD(0x0),
fc7a3fd3 68 fTransformer(0x0),
79720f5b 69 fDetEltTDHistList(0),
70 fDetEltTTHistList(0),
71 fChamberTDHistList(0),
72 fChamberTTHistList(0),
73 fChamberEff(0x0)
128a8042 74{
665701ae 75/// Default constructor
76}
77//________________________________________________________________________
78AliAnalysisTaskMuonTrackingEff::AliAnalysisTaskMuonTrackingEff(const AliAnalysisTaskMuonTrackingEff& src)
0246246b 79 :
0246246b 80 AliAnalysisTask(src),
79720f5b 81 fIsInit(kFALSE),
82 fIsLoaded(kFALSE),
83 fOCDBpath(0),
84 fUsableTracks(0),
0246246b 85 fESD(0x0),
fc7a3fd3 86 fTransformer(0x0),
79720f5b 87 fDetEltTDHistList(0),
88 fDetEltTTHistList(0),
89 fChamberTDHistList(0),
90 fChamberTTHistList(0),
91 fChamberEff(0x0)
665701ae 92{
93 /// copy ctor
94 src.Copy(*this);
95}
96//________________________________________________________________________
97AliAnalysisTaskMuonTrackingEff& AliAnalysisTaskMuonTrackingEff::operator=(const AliAnalysisTaskMuonTrackingEff& src)
98{
99 /// assignement operator
100 if ( this != &src )
101 {
102 src.Copy(*this);
103 }
104 return *this;
128a8042 105}
128a8042 106
107//________________________________________________________________________
79720f5b 108AliAnalysisTaskMuonTrackingEff::AliAnalysisTaskMuonTrackingEff(TString name, TString path)
0246246b 109 :
0246246b 110 AliAnalysisTask(name, "AnalysisTaskESD"),
79720f5b 111 fIsInit(kFALSE),
112 fIsLoaded(kFALSE),
113 fOCDBpath(path),
114 fUsableTracks(0),
0246246b 115 fESD(0x0),
fc7a3fd3 116 fTransformer(0x0),
79720f5b 117 fDetEltTDHistList(0),
118 fDetEltTTHistList(0),
119 fChamberTDHistList(0),
120 fChamberTTHistList(0),
121 fChamberEff(0x0)
128a8042 122{
123//Constructor
124//-----------
128a8042 125//Define input & output
126//---------------------
128a8042 127// -Input slot 0 works with a TChain:
128 DefineInput(0, TChain::Class());
129
5982d2f7 130// -Output slots 0 to 5 writes into a TClonesArray:
79720f5b 131 DefineOutput(0, TList::Class());
132 DefineOutput(1, TList::Class());
133 DefineOutput(2, TList::Class());
134 DefineOutput(3, TList::Class());
128a8042 135}
136
137
138
139//______________________________________________________________________________
140AliAnalysisTaskMuonTrackingEff::~AliAnalysisTaskMuonTrackingEff()
141{
142// Destructor.
fc7a3fd3 143 delete fTransformer;
fc7a3fd3 144 delete fDetEltTDHistList;
145 delete fDetEltTTHistList;
fc7a3fd3 146 delete fChamberTDHistList;
147 delete fChamberTTHistList;
148 delete fChamberEff;
128a8042 149}
150
151
152
153//________________________________________________________________________
154void AliAnalysisTaskMuonTrackingEff::CreateOutputObjects()
155{
79720f5b 156 if (!fIsInit)
157 Init();
158
159 OpenFile(0);
128a8042 160}
161
162
163
164//________________________________________________________________________
165void AliAnalysisTaskMuonTrackingEff::ConnectInputData(Option_t */*option*/)
166
167{
f7a1cc68 168 //Connect input
128a8042 169 AliESDInputHandler* esdHandler = (AliESDInputHandler*) ((AliAnalysisManager::GetAnalysisManager())->GetInputEventHandler());
170 if (!esdHandler)
128a8042 171 Printf("ERROR: Could not get ESDInputHandler");
79720f5b 172
128a8042 173 else fESD = esdHandler->GetEvent();
174}
175
176
177//________________________________________________________________________
178void AliAnalysisTaskMuonTrackingEff::Exec(Option_t */*option*/)
179{
180//Execute analysis for current event
79720f5b 181
182 // Initialize the object first
183 if (!fIsInit)
184 Init();
185
186 // Then load the OCDB and Geometry
187 if (!fIsLoaded)
188 LoadOCDBandGeometry();
189
190 // Fill the histograms
6db6876c 191 if (fChamberEff == 0x0)
192 fChamberEff = new AliCheckMuonDetEltResponse(fTransformer, fESD, fDetEltTDHistList, fDetEltTTHistList, fChamberTDHistList, fChamberTTHistList);
193 fChamberEff->CheckDetEltResponse();
79720f5b 194 fUsableTracks += fChamberEff -> GetNbrUsableTracks();
195
196//Post the output data:
197 PostData(0, fDetEltTDHistList);
198 PostData(1, fDetEltTTHistList);
199 PostData(2, fChamberTDHistList);
200 PostData(3, fChamberTTHistList);
201}
128a8042 202
128a8042 203
0246246b 204
79720f5b 205//________________________________________________________________________
206void AliAnalysisTaskMuonTrackingEff::Terminate(Option_t */*option*/)
207{
208//Terminate analysis
209 fDetEltTDHistList = (TList*) GetOutputData(0);
210 fDetEltTTHistList = (TList*) GetOutputData(1);
211 fChamberTDHistList = (TList*) GetOutputData(2);
212 fChamberTTHistList = (TList*) GetOutputData(3);
213}
0246246b 214
128a8042 215
216
79720f5b 217//________________________________________________________________________
218void AliAnalysisTaskMuonTrackingEff::Init()
219{
220 //Define detection element efficiency histograms
221 //----------------------------------------------
222 fUsableTracks = 0;
128a8042 223
224
79720f5b 225 fDetEltTDHistList = new TList();
226 fDetEltTTHistList = new TList();
128a8042 227
79720f5b 228 fChamberTDHistList = new TList();
229 fChamberTTHistList = new TList();
230
231 TString histName;
232 TString histTitle;
128a8042 233
79720f5b 234
235 for (Int_t ii = 0; ii < fgkTotNbrOfDetectionElt; ++ii)
236 {
237 Int_t iDetElt = 0;
238 if (ii<16) iDetElt = 100*(ii/4+1) + ii - int(ii/4)*4;
239 else if (ii<52) iDetElt = 100*((ii-16)/18+5) + ii - (int((ii-16)/18)*18 + 16);
240 if (ii>51) iDetElt = 100*((ii-52)/26+7) + ii - (int((ii-52)/26)*26 + 52);
0246246b 241
79720f5b 242
243 histTitle.Form("detEltNbr %d",iDetElt);
244 histName.Form("TD_detEltNbr%d",iDetElt);
245 if(ii<16)
246 {// Chambers 1 -> 4
247 TH2F *histo = new TH2F(histName, histTitle, 12, -10.0 , 110.0, 12, -10.0, 110.0);
248 fDetEltTDHistList->AddAt(histo, ii);
249 }
0246246b 250
79720f5b 251 else
252 {// Chambers 5 -> 10
253 TH2F *histo = new TH2F(histName, histTitle, 28, -140.0, 140.0, 8, -40.0, 40.0);
254 fDetEltTDHistList->AddAt(histo, ii);
255 }
0246246b 256
257
79720f5b 258 histName.Form("TT_detEltNbr%d",iDetElt);
259 if(ii<16)
260 {// Chambers 1 -> 4
261 TH2F *histo = new TH2F(histName, histTitle, 12, -10.0 , 110.0, 12, -10.0, 110.0);
262 fDetEltTTHistList->AddAt(histo, ii);
263 }
0246246b 264
79720f5b 265 else
266 {// Chambers 5 -> 10
267 TH2F *histo = new TH2F(histName, histTitle, 28, -140.0, 140.0, 8, -40.0, 40.0);
268 fDetEltTTHistList->AddAt(histo, ii);
269 }
270 }
0246246b 271
128a8042 272
79720f5b 273 for (Int_t jj = 0; jj < fgkTotNbrOfChamber+1; jj++)
274 {
275 histName.Form("TD_ChamberNbr%d", jj+1);
276 histTitle.Form("ChamberNbr %d", jj+1);
277 if (jj<4)
278 {//Chambers 1 -> 4
279 TH1F *histo = new TH1F(histName, histTitle, 4, 0.0, 4.0);
280 fChamberTDHistList->AddAt(histo, jj);
281 }
282 else
283 {
284 if (jj<6)
285 {//Chambers 5 -> 6
286 TH1F *histo = new TH1F(histName, histTitle, 18, 0.0, 18.0);
287 fChamberTDHistList->AddAt(histo, jj);
288 }
128a8042 289
79720f5b 290 if (jj>=6 && jj < 10)
291 {//Chambers 7 -> 10
292 TH1F *histo = new TH1F(histName, histTitle, 26, 0.0, 26.0);
293 fChamberTDHistList->AddAt(histo, jj);
294 }
295 }
296
297 histName.Form("TT_ChamberNbr%d",jj+1);
298 if (jj<4)
299 {//Chambers 1 -> 4
300 TH1F *histo = new TH1F(histName, histTitle, 4, 0.0, 4.0);
301 fChamberTTHistList->AddAt(histo, jj);
302 }
303 else
304 {
305 if (jj<6)
306 {//Chambers 5 -> 6
307 TH1F *histo = new TH1F(histName, histTitle, 18, 0.0, 18.0);
308 fChamberTTHistList->AddAt(histo, jj);
309 }
128a8042 310
79720f5b 311 if (jj>=6 && jj < 10)
312 {//Chambers 7 -> 10
313 TH1F *histo = new TH1F(histName, histTitle, 26, 0.0, 26.0);
314 fChamberTTHistList->AddAt(histo, jj);
315 }
316 }
317
318 if (jj == 10)
319 {
dfbceb5b 320 histName.Form("TD_Chambers %d", jj+1);
321 histTitle.Form("Chambers %d", jj+1);
79720f5b 322 TH1F *histoTDchambers = new TH1F(histName, histTitle, 10, 0.5, 10.5);
323 fChamberTDHistList->AddAt(histoTDchambers, jj);
324
dfbceb5b 325 histName.Form("TT_Chambers %d", jj+1);
79720f5b 326 TH1F *histoTTchambers = new TH1F(histName, histTitle, 10, 0.5, 10.5);
327 fChamberTTHistList->AddAt(histoTTchambers, jj);
328 }
128a8042 329
79720f5b 330 }
331
332 fIsInit = kTRUE;
128a8042 333}
0246246b 334
335
336//________________________________________________________________________
79720f5b 337void AliAnalysisTaskMuonTrackingEff::LoadOCDBandGeometry()
0246246b 338{
79720f5b 339 // Load the OCDB and the Geometry
0246246b 340
79720f5b 341 // OCDB
342 AliCDBManager* man = AliCDBManager::Instance();
343 TString ocdbPath= "alien://folder=/alice/data/2010/OCDB";
344 man->SetDefaultStorage(ocdbPath.Data());
345 man->SetRun(fESD->GetRunNumber());
0246246b 346
79720f5b 347 //Geometry
348 if (!AliGeomManager::GetGeometry())
349 AliGeomManager::LoadGeometry();
350 fTransformer = new AliMUONGeometryTransformer();
351 fTransformer->LoadGeometryData();
0246246b 352
79720f5b 353 //Set Field Map for track extrapolation
354 AliMUONTrackExtrap::SetField();
355
356 fIsLoaded = kTRUE;
0246246b 357}
79720f5b 358