1 /**************************************************************************
2 * Copyright(c) 1998-2007, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
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.
23 /// \author Diego Stocco
24 //-----------------------------------------------------------------------------
26 //----------------------------------------------------------------------------
27 // Implementation of the class for trigger chamber efficiency determinaltion
28 //----------------------------------------------------------------------------
31 #define AliAnalysisTaskTrigChEff_cxx
42 #include "AliESDEvent.h"
43 #include "AliESDMuonTrack.h"
46 #include "AliAnalysisTaskSE.h"
48 #include "AliAnalysisTaskTrigChEff.h"
50 ClassImp(AliAnalysisTaskTrigChEff)
52 //________________________________________________________________________
53 AliAnalysisTaskTrigChEff::AliAnalysisTaskTrigChEff(const char *name) :
54 AliAnalysisTaskSE(name),
61 // Output slot #1 writes into a TObjArray container
62 DefineOutput(1, TList::Class());
65 //___________________________________________________________________________
66 void AliAnalysisTaskTrigChEff::UserCreateOutputObjects() {
72 TString cathCode[2] = {"bendPlane", "nonBendPlane"};
73 TString countTypeName[2] = {"CountInCh", "NonCountInCh"};
75 const Char_t* yAxisTitle = "counts";
77 const Int_t kNboards = 234; //AliMpConstants::NofLocalBoards();
78 const Int_t kFirstTrigCh = 11;//AliMpConstants::NofTrackingChambers()+1;
80 Int_t chamberBins = kNchambers;
81 Float_t chamberLow = kFirstTrigCh-0.5, chamberHigh = kFirstTrigCh+kNchambers-0.5;
82 const Char_t* chamberName = "chamber";
84 Int_t slatBins = kNslats;
85 Float_t slatLow = 0-0.5, slatHigh = kNslats-0.5;
86 const Char_t* slatName = "slat";
88 Int_t boardBins = kNboards;
89 Float_t boardLow = 1-0.5, boardHigh = kNboards+1.-0.5;
90 const Char_t* boardName = "board";
92 Int_t angleBins = 280;
93 Float_t angleLow = -70., angleHigh = 70.;
94 const Char_t* angleNameX = "#theta_{x} (deg)";
95 const Char_t* angleNameY = "#theta_{y} (deg)";
97 TString baseName, histoName;
102 histo = new TH1F("nTracksInSlat", "Num. of tracks used for efficiency calculation",
103 slatBins, slatLow, slatHigh);
104 histo->GetXaxis()->SetTitle(slatName);
105 histo->GetYaxis()->SetTitle("num of used tracks");
107 fList->AddAt(histo, kHtracksInSlat);
109 histo = new TH1F("nTracksInBoard", "Num. of tracks used for efficiency calculation",
110 boardBins, boardLow, boardHigh);
111 histo->GetXaxis()->SetTitle(boardName);
112 histo->GetYaxis()->SetTitle("num of used tracks");
114 fList->AddAt(histo, kHtracksInBoard);
116 for(Int_t hType=0; hType<kNcounts; hType++){
117 Int_t hindex = (hType==0) ? kHchamberEff : kHchamberNonEff;
118 for(Int_t cath=0; cath<kNcathodes; cath++){
119 histoName = Form("%sChamber%s", cathCode[cath].Data(), countTypeName[hType].Data());
120 histo = new TH1F(histoName, histoName,
121 chamberBins, chamberLow, chamberHigh);
122 histo->GetXaxis()->SetTitle(chamberName);
123 histo->GetYaxis()->SetTitle(yAxisTitle);
125 fList->AddAt(histo, hindex + cath);
129 for(Int_t hType=0; hType<kNcounts; hType++){
130 Int_t hindex = (hType==0) ? kHslatEff : kHslatNonEff;
131 for(Int_t cath=0; cath<kNcathodes; cath++){
132 for(Int_t ch=0; ch<kNchambers; ch++){
133 Int_t chCath = GetPlane(cath, ch);
134 histoName = Form("%sSlat%s%i", cathCode[cath].Data(), countTypeName[hType].Data(), kFirstTrigCh+ch);
135 histo = new TH1F(histoName, histoName,
136 slatBins, slatLow, slatHigh);
137 histo->GetXaxis()->SetTitle(slatName);
138 histo->GetYaxis()->SetTitle(yAxisTitle);
140 fList->AddAt(histo, hindex + chCath);
145 for(Int_t hType=0; hType<kNcounts; hType++){
146 Int_t hindex = (hType==0) ? kHboardEff : kHboardNonEff;
147 for(Int_t cath=0; cath<kNcathodes; cath++){
148 for(Int_t ch=0; ch<kNchambers; ch++){
149 Int_t chCath = GetPlane(cath, ch);
150 histoName = Form("%sBoard%s%i", cathCode[cath].Data(), countTypeName[hType].Data(), kFirstTrigCh+ch);
151 histo = new TH1F(histoName, histoName,
152 boardBins, boardLow, boardHigh);
153 histo->GetXaxis()->SetTitle(boardName);
154 histo->GetYaxis()->SetTitle(yAxisTitle);
156 fList->AddAt(histo, hindex + chCath);
161 histo = new TH1F("thetaX", "Angular distribution",
162 angleBins, angleLow, angleHigh);
163 histo->GetXaxis()->SetTitle(angleNameX);
164 histo->GetYaxis()->SetTitle("entries");
165 fList->AddAt(histo, kHthetaX);
167 histo = new TH1F("thetaY", "Angular distribution",
168 angleBins, angleLow, angleHigh);
169 histo->GetXaxis()->SetTitle(angleNameY);
170 histo->GetYaxis()->SetTitle("entries");
171 fList->AddAt(histo, kHthetaY);
175 //________________________________________________________________________
176 void AliAnalysisTaskTrigChEff::UserExec(Option_t *) {
179 /// Called for each event
181 AliESDEvent* esdEvent = dynamic_cast<AliESDEvent*> (InputEvent());
184 Printf("ERROR: esdEvent not available\n");
188 Int_t slat = 0, board = 0;
189 UShort_t pattern = 0;
190 AliESDMuonTrack *esdTrack = 0x0;
192 const Float_t kRadToDeg = 180./TMath::Pi();
193 Int_t nTracks = esdEvent->GetNumberOfMuonTracks();
195 const Int_t kFirstTrigCh = 11; //AliMpConstants::NofTrackingChambers()+1;
197 TArrayI othersEfficient(kNchambers);
199 for (Int_t itrack = 0; itrack < nTracks; itrack++) {
200 esdTrack = esdEvent->GetMuonTrack(itrack);
202 if ( ! esdTrack->ContainTrackerData() && ! fUseGhosts ) continue;
204 pattern = esdTrack->GetHitsPatternInTrigCh();
205 Int_t effFlag = AliESDMuonTrack::GetEffFlag(pattern);
207 if(effFlag < AliESDMuonTrack::kChEff) continue; // Track not good for efficiency calculation
209 ((TH1F*)fList->At(kHthetaX))->Fill(esdTrack->GetThetaX() * kRadToDeg);
210 ((TH1F*)fList->At(kHthetaY))->Fill(esdTrack->GetThetaY() * kRadToDeg);
212 othersEfficient.Reset(1);
213 for(Int_t cath=0; cath<kNcathodes; cath++){
214 for(Int_t ich=0; ich<kNchambers; ich++){
215 if( ! AliESDMuonTrack::IsChamberHit(pattern, cath, ich)){
216 for(Int_t jch=0; jch<kNchambers; jch++){
218 othersEfficient[jch] = 0;
219 //AliInfo(Form("%s ch %i by New", baseOutString.Data(), jch));
221 } // loop on other chambers
223 } // if chamber not efficient
224 } // loop on chambers
225 } // loop on cathodes
227 Bool_t rejectTrack = kTRUE;
228 for (Int_t ich=0; ich<kNchambers; ich++){
229 if ( othersEfficient[ich] > 0 ){
230 rejectTrack = kFALSE;
235 if ( rejectTrack ) continue;
237 slat = AliESDMuonTrack::GetSlatOrInfo(pattern);
238 board = esdTrack->LoCircuit();
240 if(effFlag >= AliESDMuonTrack::kSlatEff) ((TH1F*)fList->At(kHtracksInSlat))->Fill(slat);
241 if(effFlag >= AliESDMuonTrack::kBoardEff) ((TH1F*)fList->At(kHtracksInBoard))->Fill(board);
243 for(Int_t cath=0; cath<kNcathodes; cath++){
244 for(Int_t ch=0; ch<kNchambers; ch++){
245 if ( ! othersEfficient[ch] )
246 continue; // Reject track if the info of the chamber under study
247 // is necessary to create the track itself
249 Int_t whichType = AliESDMuonTrack::IsChamberHit(pattern, cath, ch) ? kChHit : kChNonHit;
251 Int_t iChamber = kFirstTrigCh + ch;
252 Int_t hindex = ( whichType == kChHit ) ? kHchamberEff : kHchamberNonEff;
253 ((TH1F*)fList->At(hindex + cath))->Fill(iChamber);
255 if(effFlag < AliESDMuonTrack::kSlatEff) continue; // Track crossed different slats
256 Int_t chCath = GetPlane(cath, ch);
257 hindex = ( whichType == kChHit ) ? kHslatEff : kHslatNonEff;
258 ((TH1F*)fList->At(hindex + chCath))->Fill(slat);
260 if(effFlag < AliESDMuonTrack::kBoardEff) continue; // Track crossed different boards
261 hindex = ( whichType == kChHit ) ? kHboardEff : kHboardNonEff;
262 ((TH1F*)fList->At(hindex + chCath))->Fill(board);
263 } // loop on chambers
264 } // loop on cathodes
267 // Post final data. It will be written to a file with option "RECREATE"
271 //________________________________________________________________________
272 void AliAnalysisTaskTrigChEff::Terminate(Option_t *) {
274 /// Draw result to the screen
275 /// Called once at the end of the query.
277 if (!gROOT->IsBatch()) {
278 TCanvas *can[kNcathodes];
281 for(Int_t cath=0; cath<kNcathodes; cath++){
282 TString canName = Form("can%i",cath);
283 can[cath] = new TCanvas(canName.Data(),canName.Data(),10*(1+cath),10*(1+cath),310,310);
284 can[cath]->SetFillColor(10); can[cath]->SetHighLightColor(10);
285 can[cath]->SetLeftMargin(0.15); can[cath]->SetBottomMargin(0.15);
286 can[cath]->Divide(2,2);
287 for(Int_t ch=0; ch<kNchambers; ch++){
288 Int_t chCath = GetPlane(cath, ch);
289 num = (TH1F*)(fList->At(kHboardEff + chCath)->Clone());
290 den = (TH1F*)(fList->At(kHboardNonEff + chCath)->Clone());