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
40 #include "TGraphAsymmErrors.h"
44 #include "AliESDEvent.h"
45 #include "AliESDMuonTrack.h"
48 #include "AliAnalysisTaskSE.h"
50 #include "AliAnalysisTaskTrigChEff.h"
52 ClassImp(AliAnalysisTaskTrigChEff)
54 //________________________________________________________________________
55 AliAnalysisTaskTrigChEff::AliAnalysisTaskTrigChEff(const char *name) :
56 AliAnalysisTaskSE(name),
63 // Output slot #1 writes into a TObjArray container
64 DefineOutput(1, TList::Class());
67 //________________________________________________________________________
68 AliAnalysisTaskTrigChEff::~AliAnalysisTaskTrigChEff()
73 //_________________________________________________________________________
74 void AliAnalysisTaskTrigChEff::UserCreateOutputObjects() {
80 TString countTypeName[kNcounts] = {"bendPlane", "nonBendPlane","bothPlanes", "allTracks"};
82 const Char_t* yAxisTitle = "counts";
84 const Int_t kNboards = 234; //AliMpConstants::NofLocalBoards();
85 const Int_t kFirstTrigCh = 11;//AliMpConstants::NofTrackingChambers()+1;
87 Int_t chamberBins = kNchambers;
88 Float_t chamberLow = kFirstTrigCh-0.5, chamberHigh = kFirstTrigCh+kNchambers-0.5;
89 const Char_t* chamberName = "chamber";
91 Int_t slatBins = kNslats;
92 Float_t slatLow = 0-0.5, slatHigh = kNslats-0.5;
93 const Char_t* slatName = "slat";
95 Int_t boardBins = kNboards;
96 Float_t boardLow = 1-0.5, boardHigh = kNboards+1.-0.5;
97 const Char_t* boardName = "board";
99 TString baseName, histoName, histoTitle;
105 Int_t histoIndex = -1;
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);
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);
120 histo = new TH1F(histoName, histoName,
121 slatBins, slatLow, slatHigh);
122 histo->GetXaxis()->SetTitle(slatName);
123 histo->GetYaxis()->SetTitle(yAxisTitle);
124 histoIndex = GetHistoIndex(kHslatEff, icount, ch);
125 fList->AddAt(histo, histoIndex);
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);
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);
152 //________________________________________________________________________
153 void AliAnalysisTaskTrigChEff::UserExec(Option_t *) {
156 /// Called for each event
158 AliESDEvent* esdEvent = dynamic_cast<AliESDEvent*> (InputEvent());
161 Printf("ERROR: esdEvent not available\n");
165 Int_t slat = 0, board = 0;
166 UShort_t pattern = 0;
167 AliESDMuonTrack *esdTrack = 0x0;
169 Int_t nTracks = esdEvent->GetNumberOfMuonTracks();
171 const Int_t kFirstTrigCh = 11; //AliMpConstants::NofTrackingChambers()+1;
173 TArrayI othersEfficient(kNchambers);
174 Int_t histoIndex = -1;
176 for (Int_t itrack = 0; itrack < nTracks; itrack++) {
177 esdTrack = esdEvent->GetMuonTrack(itrack);
179 if ( ! esdTrack->ContainTrackerData() && ! fUseGhosts ) continue;
181 pattern = esdTrack->GetHitsPatternInTrigCh();
182 Int_t effFlag = AliESDMuonTrack::GetEffFlag(pattern);
184 board = esdTrack->LoCircuit();
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
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++){
198 othersEfficient[jch] = 0;
200 } // loop on other chambers
202 } // if chamber not efficient
203 } // loop on chambers
204 } // loop on cathodes
206 Bool_t rejectTrack = kTRUE;
207 for (Int_t ich=0; ich<kNchambers; ich++){
208 if ( othersEfficient[ich] > 0 ){
209 rejectTrack = kFALSE;
214 if ( rejectTrack ) continue;
216 slat = AliESDMuonTrack::GetSlatOrInfo(pattern);
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
223 Int_t iChamber = kFirstTrigCh + ch;
225 Bool_t hitsBend = AliESDMuonTrack::IsChamberHit(pattern, 0, ch);
226 Bool_t hitsNonBend = AliESDMuonTrack::IsChamberHit(pattern, 1, ch);
228 Bool_t fillHisto[kNcounts] = {
231 ( hitsBend && hitsNonBend ),
235 for (Int_t icount=0; icount<kNcounts; icount++){
236 if ( ! fillHisto[icount] ) continue;
238 histoIndex = GetHistoIndex(kHchamberEff, icount);
239 ((TH1F*)fList->At(histoIndex))->Fill(iChamber);
241 if(effFlag < AliESDMuonTrack::kSlatEff) continue; // Track crossed different slats
242 histoIndex = GetHistoIndex(kHslatEff, icount, ch);
243 ((TH1F*)fList->At(histoIndex))->Fill(slat);
245 if(effFlag < AliESDMuonTrack::kBoardEff) continue; // Track crossed different boards
246 histoIndex = GetHistoIndex(kHboardEff, icount, ch);
247 ((TH1F*)fList->At(histoIndex))->Fill(board);
248 } // loop on chambers
249 } // loop on count types
252 // Post final data. It will be written to a file with option "RECREATE"
256 //________________________________________________________________________
257 void AliAnalysisTaskTrigChEff::Terminate(Option_t *) {
259 /// Draw result to the screen
260 /// Called once at the end of the query.
262 if ( gROOT->IsBatch() ) return;
263 fList = dynamic_cast<TList*> (GetOutputData(1));
270 TGraphAsymmErrors* effGraph = 0x0;
271 TString baseName[3] = {"Chamber", "RPC", "Board"};
272 Int_t baseIndex[3] = {kHchamberEff, kHslatEff, kHboardEff};
273 TString effName[kNcounts-1] = {"BendPlane", "NonBendPlane", "BothPlanes"};
274 Int_t histoIndexNum = -1, histoIndexDen = -1;
275 for (Int_t itype=0; itype<3; itype++) {
276 for(Int_t icount=0; icount<kNcounts-1; icount++){
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);
279 can->SetFillColor(10); can->SetHighLightColor(10);
280 can->SetLeftMargin(0.15); can->SetBottomMargin(0.15);
284 for(Int_t ch=0; ch<kNchambers; ch++){
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));
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());
294 effGraph->Draw("AP");
295 if ( itype == 0 ) break;
297 } // loop on count types
301 //________________________________________________________________________
303 AliAnalysisTaskTrigChEff::GetHistoIndex(Int_t histoType, Int_t countType,
307 /// Return the index of the histogram in the list
309 switch ( histoType ) {
311 return 0 + countType;
313 return 4 + kNchambers*countType + chamber;
315 return 20 + kNchambers*countType + chamber;
321 const Int_t kNhistosPlaneCorr = 38;
323 switch ( histoType ){
325 return 0 + planeCorrelation*kNhistosPlaneCorr;
326 case kHtracksInBoard:
327 return 1 + planeCorrelation*kNhistosPlaneCorr;
329 return 2 + kNcathodes*countType + cathode
330 + planeCorrelation*kNhistosPlaneCorr;
332 return 6 + kNchambers*kNcathodes*countType
333 + kNchambers*cathode + chamber
334 + planeCorrelation*kNhistosPlaneCorr;
336 return 22 + kNchambers*kNcathodes*countType
337 + kNchambers*cathode + chamber
338 + planeCorrelation*kNhistosPlaneCorr;
340 return 0 + 2*kNhistosPlaneCorr;