]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG3/muon/AliAnalysisTaskTrigChEff.cxx
adding new sample component for RAW data analysis
[u/mrichter/AliRoot.git] / PWG3 / muon / AliAnalysisTaskTrigChEff.cxx
CommitLineData
ebbabac1 1/**************************************************************************
2 * Copyright(c) 1998-2007, 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/// \class AliAnalysisTaskSingleMu
18/// Analysis task for single muons in the spectrometer.
19/// The output is a list of histograms.
20/// The macro class can run on AOD or ESDs.
21/// If Monte Carlo information is present, some basics checks are performed.
22///
23/// \author Diego Stocco
24//-----------------------------------------------------------------------------
25
26//----------------------------------------------------------------------------
27// Implementation of the class for trigger chamber efficiency determinaltion
28//----------------------------------------------------------------------------
29
30
59156747 31#define AliAnalysisTaskTrigChEff_cxx
32
33// ROOT includes
59156747 34#include "TH1.h"
6228ecd4 35#include "TH2.h"
59156747 36#include "TCanvas.h"
37#include "TROOT.h"
38#include "TString.h"
39#include "TList.h"
5623f0cb 40#include "TGraphAsymmErrors.h"
59156747 41
42// STEER includes
43#include "AliLog.h"
59156747 44#include "AliESDEvent.h"
45#include "AliESDMuonTrack.h"
59156747 46
59156747 47// ANALYSIS includes
ebbabac1 48#include "AliAnalysisTaskSE.h"
49
59156747 50#include "AliAnalysisTaskTrigChEff.h"
51
52ClassImp(AliAnalysisTaskTrigChEff)
53
54//________________________________________________________________________
55AliAnalysisTaskTrigChEff::AliAnalysisTaskTrigChEff(const char *name) :
ebbabac1 56 AliAnalysisTaskSE(name),
73a0c99f 57 fUseGhosts(kFALSE),
59156747 58 fList(0)
59{
60 //
61 /// Constructor.
62 //
ebbabac1 63 // Output slot #1 writes into a TObjArray container
64 DefineOutput(1, TList::Class());
59156747 65}
66
b201705a 67//________________________________________________________________________
68AliAnalysisTaskTrigChEff::~AliAnalysisTaskTrigChEff()
69{
70 delete fList;
71}
72
6228ecd4 73//_________________________________________________________________________
ebbabac1 74void AliAnalysisTaskTrigChEff::UserCreateOutputObjects() {
59156747 75 //
76 /// Create histograms
77 /// Called once
78 //
59156747 79
6228ecd4 80 TString countTypeName[kNcounts] = {"bendPlane", "nonBendPlane","bothPlanes", "allTracks"};
59156747 81
a6e0ebfe 82 const Char_t* yAxisTitle = "counts";
59156747 83
84 const Int_t kNboards = 234; //AliMpConstants::NofLocalBoards();
85 const Int_t kFirstTrigCh = 11;//AliMpConstants::NofTrackingChambers()+1;
86
87 Int_t chamberBins = kNchambers;
88 Float_t chamberLow = kFirstTrigCh-0.5, chamberHigh = kFirstTrigCh+kNchambers-0.5;
a6e0ebfe 89 const Char_t* chamberName = "chamber";
59156747 90
91 Int_t slatBins = kNslats;
92 Float_t slatLow = 0-0.5, slatHigh = kNslats-0.5;
a6e0ebfe 93 const Char_t* slatName = "slat";
59156747 94
95 Int_t boardBins = kNboards;
96 Float_t boardLow = 1-0.5, boardHigh = kNboards+1.-0.5;
a6e0ebfe 97 const Char_t* boardName = "board";
59156747 98
6228ecd4 99 TString baseName, histoName, histoTitle;
59156747 100 fList = new TList();
101
102 TH1F* histo;
6228ecd4 103 TH2F* histo2D;
104
105 Int_t histoIndex = -1;
106
107 for(Int_t icount=0; icount<kNcounts; icount++){
108 histoName = Form("%sCountChamber", countTypeName[icount].Data());
109 histo = new TH1F(histoName, histoName,
110 chamberBins, chamberLow, chamberHigh);
111 histo->GetXaxis()->SetTitle(chamberName);
112 histo->GetYaxis()->SetTitle(yAxisTitle);
113 histoIndex = GetHistoIndex(kHchamberEff, icount);
114 fList->AddAt(histo, histoIndex);
115 } // loop on counts
59156747 116
6228ecd4 117 for(Int_t icount=0; icount<kNcounts; icount++){
118 for(Int_t ch=0; ch<kNchambers; ch++){
119 histoName = Form("%sCountSlatCh%i", countTypeName[icount].Data(), kFirstTrigCh+ch);
59156747 120 histo = new TH1F(histoName, histoName,
6228ecd4 121 slatBins, slatLow, slatHigh);
122 histo->GetXaxis()->SetTitle(slatName);
59156747 123 histo->GetYaxis()->SetTitle(yAxisTitle);
6228ecd4 124 histoIndex = GetHistoIndex(kHslatEff, icount, ch);
125 fList->AddAt(histo, histoIndex);
126 } // loop on chamber
59156747 127 } // loop on counts
128
6228ecd4 129 for(Int_t icount=0; icount<kNcounts; icount++){
130 for(Int_t ch=0; ch<kNchambers; ch++){
131 histoName = Form("%sCountBoardCh%i", countTypeName[icount].Data(), kFirstTrigCh+ch);
132 histo = new TH1F(histoName, histoName,
133 boardBins, boardLow, boardHigh);
134 histo->GetXaxis()->SetTitle(boardName);
135 histo->GetYaxis()->SetTitle(yAxisTitle);
136 histoIndex = GetHistoIndex(kHboardEff, icount, ch);
137 fList->AddAt(histo, histoIndex);
138 } // loop on chamber
59156747 139 } // loop on counts
73a0c99f 140
6228ecd4 141 histo2D = new TH2F("checkRejectedBoard", "Rejected tracks motivation",
142 4, 20.5, 24.5, boardBins, boardLow, boardHigh);
143 histo2D->GetXaxis()->SetBinLabel(1,"Many pads");
144 histo2D->GetXaxis()->SetBinLabel(2,"Few pads");
145 histo2D->GetXaxis()->SetBinLabel(3,"Outside geom");
146 histo2D->GetXaxis()->SetBinLabel(4,"Tracker track");
147 histo2D->GetYaxis()->SetTitle(boardName);
148 histoIndex = GetHistoIndex(kHcheckBoard);
149 fList->AddAt(histo2D, histoIndex);
59156747 150}
151
152//________________________________________________________________________
ebbabac1 153void AliAnalysisTaskTrigChEff::UserExec(Option_t *) {
59156747 154 //
155 /// Main loop
156 /// Called for each event
157 //
ebbabac1 158 AliESDEvent* esdEvent = dynamic_cast<AliESDEvent*> (InputEvent());
159
160 if (!esdEvent) {
161 Printf("ERROR: esdEvent not available\n");
162 return;
163 }
164
165 Int_t slat = 0, board = 0;
59156747 166 UShort_t pattern = 0;
167 AliESDMuonTrack *esdTrack = 0x0;
59156747 168
ebbabac1 169 Int_t nTracks = esdEvent->GetNumberOfMuonTracks();
73a0c99f 170
59156747 171 const Int_t kFirstTrigCh = 11; //AliMpConstants::NofTrackingChambers()+1;
172
ebbabac1 173 TArrayI othersEfficient(kNchambers);
6228ecd4 174 Int_t histoIndex = -1;
ebbabac1 175
59156747 176 for (Int_t itrack = 0; itrack < nTracks; itrack++) {
ebbabac1 177 esdTrack = esdEvent->GetMuonTrack(itrack);
73a0c99f 178
179 if ( ! esdTrack->ContainTrackerData() && ! fUseGhosts ) continue;
59156747 180
ebbabac1 181 pattern = esdTrack->GetHitsPatternInTrigCh();
73a0c99f 182 Int_t effFlag = AliESDMuonTrack::GetEffFlag(pattern);
59156747 183
6228ecd4 184 board = esdTrack->LoCircuit();
59156747 185
6228ecd4 186 if(effFlag < AliESDMuonTrack::kChEff) {
187 histoIndex = GetHistoIndex(kHcheckBoard);
188 ((TH2F*)fList->At(histoIndex))->Fill(AliESDMuonTrack::GetSlatOrInfo(pattern), board);
189 continue; // Track not good for efficiency calculation
190 }
59156747 191
ebbabac1 192 othersEfficient.Reset(1);
193 for(Int_t cath=0; cath<kNcathodes; cath++){
194 for(Int_t ich=0; ich<kNchambers; ich++){
195 if( ! AliESDMuonTrack::IsChamberHit(pattern, cath, ich)){
196 for(Int_t jch=0; jch<kNchambers; jch++){
197 if ( jch != ich) {
198 othersEfficient[jch] = 0;
ebbabac1 199 }
200 } // loop on other chambers
201 break;
202 } // if chamber not efficient
203 } // loop on chambers
204 } // loop on cathodes
205
206 Bool_t rejectTrack = kTRUE;
207 for (Int_t ich=0; ich<kNchambers; ich++){
208 if ( othersEfficient[ich] > 0 ){
209 rejectTrack = kFALSE;
210 break;
211 }
212 }
213
214 if ( rejectTrack ) continue;
215
216 slat = AliESDMuonTrack::GetSlatOrInfo(pattern);
73a0c99f 217
6228ecd4 218 for(Int_t ch=0; ch<kNchambers; ch++){
219 if ( ! othersEfficient[ch] )
220 continue; // Reject track if the info of the chamber under study
221 // is necessary to create the track itself
59156747 222
6228ecd4 223 Int_t iChamber = kFirstTrigCh + ch;
ebbabac1 224
6228ecd4 225 Bool_t hitsBend = AliESDMuonTrack::IsChamberHit(pattern, 0, ch);
226 Bool_t hitsNonBend = AliESDMuonTrack::IsChamberHit(pattern, 1, ch);
73a0c99f 227
6228ecd4 228 Bool_t fillHisto[kNcounts] = {
229 hitsBend,
230 hitsNonBend,
231 ( hitsBend && hitsNonBend ),
232 kTRUE
233 };
234
235 for (Int_t icount=0; icount<kNcounts; icount++){
236 if ( ! fillHisto[icount] ) continue;
237
238 histoIndex = GetHistoIndex(kHchamberEff, icount);
239 ((TH1F*)fList->At(histoIndex))->Fill(iChamber);
59156747 240
73a0c99f 241 if(effFlag < AliESDMuonTrack::kSlatEff) continue; // Track crossed different slats
6228ecd4 242 histoIndex = GetHistoIndex(kHslatEff, icount, ch);
243 ((TH1F*)fList->At(histoIndex))->Fill(slat);
59156747 244
73a0c99f 245 if(effFlag < AliESDMuonTrack::kBoardEff) continue; // Track crossed different boards
6228ecd4 246 histoIndex = GetHistoIndex(kHboardEff, icount, ch);
247 ((TH1F*)fList->At(histoIndex))->Fill(board);
59156747 248 } // loop on chambers
6228ecd4 249 } // loop on count types
ebbabac1 250 } // loop on tracks
59156747 251
252 // Post final data. It will be written to a file with option "RECREATE"
ebbabac1 253 PostData(1, fList);
59156747 254}
255
256//________________________________________________________________________
257void AliAnalysisTaskTrigChEff::Terminate(Option_t *) {
258 //
259 /// Draw result to the screen
260 /// Called once at the end of the query.
261 //
5623f0cb 262 if ( gROOT->IsBatch() ) return;
263 fList = dynamic_cast<TList*> (GetOutputData(1));
264
6228ecd4 265 if (!fList) return;
266
5623f0cb 267 TCanvas *can;
268 TH1F *num = 0x0;
269 TH1F *den = 0x0;
270 TGraphAsymmErrors* effGraph = 0x0;
271 TString baseName[3] = {"Chamber", "RPC", "Board"};
6228ecd4 272 Int_t baseIndex[3] = {kHchamberEff, kHslatEff, kHboardEff};
273 TString effName[kNcounts-1] = {"BendPlane", "NonBendPlane", "BothPlanes"};
274 Int_t histoIndexNum = -1, histoIndexDen = -1;
5623f0cb 275 for (Int_t itype=0; itype<3; itype++) {
f86fc5df 276 for(Int_t icount=0; icount<kNcounts-1; icount++){
6228ecd4 277 TString canName = Form("efficiencyPer%s_%s",baseName[itype].Data(),effName[icount].Data());
278 can = new TCanvas(canName.Data(),canName.Data(),10*(1+kNcounts*itype+icount),10*(1+kNcounts*itype+icount),310,310);
5623f0cb 279 can->SetFillColor(10); can->SetHighLightColor(10);
280 can->SetLeftMargin(0.15); can->SetBottomMargin(0.15);
281 if ( itype > 0 )
282 can->Divide(2,2);
283
59156747 284 for(Int_t ch=0; ch<kNchambers; ch++){
6228ecd4 285 histoIndexNum = GetHistoIndex(baseIndex[itype], icount, ch);
286 histoIndexDen = GetHistoIndex(baseIndex[itype], kAllTracks, ch);
287 num = (TH1F*)(fList->At(histoIndexNum));
288 den = (TH1F*)(fList->At(histoIndexDen));
5623f0cb 289 effGraph = new TGraphAsymmErrors(num, den);
290 effGraph->GetYaxis()->SetRangeUser(0., 1.1);
291 effGraph->GetYaxis()->SetTitle("Efficiency");
292 effGraph->GetXaxis()->SetTitle(baseName[itype].Data());
293 can->cd(ch+1);
294 effGraph->Draw("AP");
295 if ( itype == 0 ) break;
296 } // loop on chamber
6228ecd4 297 } // loop on count types
5623f0cb 298 } // loop on histo
59156747 299}
6228ecd4 300
301//________________________________________________________________________
302Int_t
303AliAnalysisTaskTrigChEff::GetHistoIndex(Int_t histoType, Int_t countType,
304 Int_t chamber)
305{
306 //
307 /// Return the index of the histogram in the list
308 //
309 switch ( histoType ) {
310 case kHchamberEff:
311 return 0 + countType;
312 case kHslatEff:
313 return 4 + kNchambers*countType + chamber;
314 case kHboardEff:
315 return 20 + kNchambers*countType + chamber;
316 case kHcheckBoard:
317 return 36;
318 }
319
320 /*
321 const Int_t kNhistosPlaneCorr = 38;
322
323 switch ( histoType ){
324 case kHtracksInSlat:
325 return 0 + planeCorrelation*kNhistosPlaneCorr;
326 case kHtracksInBoard:
327 return 1 + planeCorrelation*kNhistosPlaneCorr;
328 case kHchamberEff:
329 return 2 + kNcathodes*countType + cathode
330 + planeCorrelation*kNhistosPlaneCorr;
331 case kHslatEff:
332 return 6 + kNchambers*kNcathodes*countType
333 + kNchambers*cathode + chamber
334 + planeCorrelation*kNhistosPlaneCorr;
335 case kHboardEff:
336 return 22 + kNchambers*kNcathodes*countType
337 + kNchambers*cathode + chamber
338 + planeCorrelation*kNhistosPlaneCorr;
339 case kHcheckBoard:
340 return 0 + 2*kNhistosPlaneCorr;
341 }
342 */
343 return -1;
344}