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 **************************************************************************/
18 //-----------------------------------------------------------------------------
19 /// \class AliAnalysisTaskSingleMu
20 /// Analysis task for single muons in the spectrometer.
21 /// The output is a list of histograms.
22 /// The macro class can run on AOD or ESDs.
23 /// If Monte Carlo information is present, some basics checks are performed.
25 /// \author Diego Stocco
26 //-----------------------------------------------------------------------------
28 //----------------------------------------------------------------------------
29 // Implementation of the class for trigger chamber efficiency determinaltion
30 //----------------------------------------------------------------------------
33 #define AliAnalysisTaskTrigChEff_cxx
42 #include "TGraphAsymmErrors.h"
46 #include "AliESDEvent.h"
47 #include "AliESDMuonTrack.h"
50 #include "AliAnalysisTaskSE.h"
52 #include "AliAnalysisTaskTrigChEff.h"
54 ClassImp(AliAnalysisTaskTrigChEff)
56 //________________________________________________________________________
57 AliAnalysisTaskTrigChEff::AliAnalysisTaskTrigChEff(const char *name) :
58 AliAnalysisTaskSE(name),
65 // Output slot #1 writes into a TObjArray container
66 DefineOutput(1, TList::Class());
69 //________________________________________________________________________
70 AliAnalysisTaskTrigChEff::~AliAnalysisTaskTrigChEff()
75 //_________________________________________________________________________
76 void AliAnalysisTaskTrigChEff::UserCreateOutputObjects() {
82 TString countTypeName[kNcounts] = {"bendPlane", "nonBendPlane","bothPlanes", "allTracks"};
84 const Char_t* yAxisTitle = "counts";
86 const Int_t kNboards = 234; //AliMpConstants::NofLocalBoards();
87 const Int_t kFirstTrigCh = 11;//AliMpConstants::NofTrackingChambers()+1;
89 Int_t chamberBins = kNchambers;
90 Float_t chamberLow = kFirstTrigCh-0.5, chamberHigh = kFirstTrigCh+kNchambers-0.5;
91 const Char_t* chamberName = "chamber";
93 Int_t slatBins = kNslats;
94 Float_t slatLow = 0-0.5, slatHigh = kNslats-0.5;
95 const Char_t* slatName = "slat";
97 Int_t boardBins = kNboards;
98 Float_t boardLow = 1-0.5, boardHigh = kNboards+1.-0.5;
99 const Char_t* boardName = "board";
101 TString baseName, histoName, histoTitle;
107 Int_t histoIndex = -1;
109 for(Int_t icount=0; icount<kNcounts; icount++){
110 histoName = Form("%sCountChamber", countTypeName[icount].Data());
111 histo = new TH1F(histoName, histoName,
112 chamberBins, chamberLow, chamberHigh);
113 histo->GetXaxis()->SetTitle(chamberName);
114 histo->GetYaxis()->SetTitle(yAxisTitle);
115 histoIndex = GetHistoIndex(kHchamberEff, icount);
116 fList->AddAt(histo, histoIndex);
119 for(Int_t icount=0; icount<kNcounts; icount++){
120 for(Int_t ch=0; ch<kNchambers; ch++){
121 histoName = Form("%sCountSlatCh%i", countTypeName[icount].Data(), kFirstTrigCh+ch);
122 histo = new TH1F(histoName, histoName,
123 slatBins, slatLow, slatHigh);
124 histo->GetXaxis()->SetTitle(slatName);
125 histo->GetYaxis()->SetTitle(yAxisTitle);
126 histoIndex = GetHistoIndex(kHslatEff, icount, ch);
127 fList->AddAt(histo, histoIndex);
131 for(Int_t icount=0; icount<kNcounts; icount++){
132 for(Int_t ch=0; ch<kNchambers; ch++){
133 histoName = Form("%sCountBoardCh%i", countTypeName[icount].Data(), kFirstTrigCh+ch);
134 histo = new TH1F(histoName, histoName,
135 boardBins, boardLow, boardHigh);
136 histo->GetXaxis()->SetTitle(boardName);
137 histo->GetYaxis()->SetTitle(yAxisTitle);
138 histoIndex = GetHistoIndex(kHboardEff, icount, ch);
139 fList->AddAt(histo, histoIndex);
143 histo2D = new TH2F("checkRejectedBoard", "Rejected tracks motivation",
144 4, 20.5, 24.5, boardBins, boardLow, boardHigh);
145 histo2D->GetXaxis()->SetBinLabel(1,"Many pads");
146 histo2D->GetXaxis()->SetBinLabel(2,"Few pads");
147 histo2D->GetXaxis()->SetBinLabel(3,"Outside geom");
148 histo2D->GetXaxis()->SetBinLabel(4,"Tracker track");
149 histo2D->GetYaxis()->SetTitle(boardName);
150 histoIndex = GetHistoIndex(kHcheckBoard);
151 fList->AddAt(histo2D, histoIndex);
154 //________________________________________________________________________
155 void AliAnalysisTaskTrigChEff::UserExec(Option_t *) {
158 /// Called for each event
160 AliESDEvent* esdEvent = dynamic_cast<AliESDEvent*> (InputEvent());
163 Printf("ERROR: esdEvent not available\n");
167 Int_t slat = 0, board = 0;
168 UShort_t pattern = 0;
169 AliESDMuonTrack *esdTrack = 0x0;
171 Int_t nTracks = esdEvent->GetNumberOfMuonTracks();
173 const Int_t kFirstTrigCh = 11; //AliMpConstants::NofTrackingChambers()+1;
175 TArrayI othersEfficient(kNchambers);
176 Int_t histoIndex = -1;
178 for (Int_t itrack = 0; itrack < nTracks; itrack++) {
179 esdTrack = esdEvent->GetMuonTrack(itrack);
181 if ( ! esdTrack->ContainTrackerData() && ! fUseGhosts ) continue;
183 pattern = esdTrack->GetHitsPatternInTrigCh();
184 Int_t effFlag = AliESDMuonTrack::GetEffFlag(pattern);
186 board = esdTrack->LoCircuit();
188 if(effFlag < AliESDMuonTrack::kChEff) {
189 histoIndex = GetHistoIndex(kHcheckBoard);
190 ((TH2F*)fList->At(histoIndex))->Fill(AliESDMuonTrack::GetSlatOrInfo(pattern), board);
191 continue; // Track not good for efficiency calculation
194 othersEfficient.Reset(1);
195 for(Int_t cath=0; cath<kNcathodes; cath++){
196 for(Int_t ich=0; ich<kNchambers; ich++){
197 if( ! AliESDMuonTrack::IsChamberHit(pattern, cath, ich)){
198 for(Int_t jch=0; jch<kNchambers; jch++){
200 othersEfficient[jch] = 0;
202 } // loop on other chambers
204 } // if chamber not efficient
205 } // loop on chambers
206 } // loop on cathodes
208 Bool_t rejectTrack = kTRUE;
209 for (Int_t ich=0; ich<kNchambers; ich++){
210 if ( othersEfficient[ich] > 0 ){
211 rejectTrack = kFALSE;
216 if ( rejectTrack ) continue;
218 slat = AliESDMuonTrack::GetSlatOrInfo(pattern);
220 for(Int_t ch=0; ch<kNchambers; ch++){
221 if ( ! othersEfficient[ch] )
222 continue; // Reject track if the info of the chamber under study
223 // is necessary to create the track itself
225 Int_t iChamber = kFirstTrigCh + ch;
227 Bool_t hitsBend = AliESDMuonTrack::IsChamberHit(pattern, 0, ch);
228 Bool_t hitsNonBend = AliESDMuonTrack::IsChamberHit(pattern, 1, ch);
230 Bool_t fillHisto[kNcounts] = {
233 ( hitsBend && hitsNonBend ),
237 for (Int_t icount=0; icount<kNcounts; icount++){
238 if ( ! fillHisto[icount] ) continue;
240 histoIndex = GetHistoIndex(kHchamberEff, icount);
241 ((TH1F*)fList->At(histoIndex))->Fill(iChamber);
243 if(effFlag < AliESDMuonTrack::kSlatEff) continue; // Track crossed different slats
244 histoIndex = GetHistoIndex(kHslatEff, icount, ch);
245 ((TH1F*)fList->At(histoIndex))->Fill(slat);
247 if(effFlag < AliESDMuonTrack::kBoardEff) continue; // Track crossed different boards
248 histoIndex = GetHistoIndex(kHboardEff, icount, ch);
249 ((TH1F*)fList->At(histoIndex))->Fill(board);
250 } // loop on chambers
251 } // loop on count types
254 // Post final data. It will be written to a file with option "RECREATE"
258 //________________________________________________________________________
259 void AliAnalysisTaskTrigChEff::Terminate(Option_t *) {
261 /// Draw result to the screen
262 /// Called once at the end of the query.
264 if ( gROOT->IsBatch() ) return;
265 fList = dynamic_cast<TList*> (GetOutputData(1));
272 TGraphAsymmErrors* effGraph = 0x0;
273 TString baseName[3] = {"Chamber", "RPC", "Board"};
274 Int_t baseIndex[3] = {kHchamberEff, kHslatEff, kHboardEff};
275 TString effName[kNcounts-1] = {"BendPlane", "NonBendPlane", "BothPlanes"};
276 Int_t histoIndexNum = -1, histoIndexDen = -1;
277 for (Int_t itype=0; itype<3; itype++) {
278 for(Int_t icount=0; icount<kNcounts-1; icount++){
279 TString canName = Form("efficiencyPer%s_%s",baseName[itype].Data(),effName[icount].Data());
280 can = new TCanvas(canName.Data(),canName.Data(),10*(1+kNcounts*itype+icount),10*(1+kNcounts*itype+icount),310,310);
281 can->SetFillColor(10); can->SetHighLightColor(10);
282 can->SetLeftMargin(0.15); can->SetBottomMargin(0.15);
286 for(Int_t ch=0; ch<kNchambers; ch++){
287 histoIndexNum = GetHistoIndex(baseIndex[itype], icount, ch);
288 histoIndexDen = GetHistoIndex(baseIndex[itype], kAllTracks, ch);
289 num = (TH1F*)(fList->At(histoIndexNum));
290 den = (TH1F*)(fList->At(histoIndexDen));
291 effGraph = new TGraphAsymmErrors(num, den);
292 effGraph->GetYaxis()->SetRangeUser(0., 1.1);
293 effGraph->GetYaxis()->SetTitle("Efficiency");
294 effGraph->GetXaxis()->SetTitle(baseName[itype].Data());
296 effGraph->Draw("AP");
297 if ( itype == 0 ) break;
299 } // loop on count types
303 //________________________________________________________________________
305 AliAnalysisTaskTrigChEff::GetHistoIndex(Int_t histoType, Int_t countType,
309 /// Return the index of the histogram in the list
311 switch ( histoType ) {
313 return 0 + countType;
315 return 4 + kNchambers*countType + chamber;
317 return 20 + kNchambers*countType + chamber;
323 const Int_t kNhistosPlaneCorr = 38;
325 switch ( histoType ){
327 return 0 + planeCorrelation*kNhistosPlaneCorr;
328 case kHtracksInBoard:
329 return 1 + planeCorrelation*kNhistosPlaneCorr;
331 return 2 + kNcathodes*countType + cathode
332 + planeCorrelation*kNhistosPlaneCorr;
334 return 6 + kNchambers*kNcathodes*countType
335 + kNchambers*cathode + chamber
336 + planeCorrelation*kNhistosPlaneCorr;
338 return 22 + kNchambers*kNcathodes*countType
339 + kNchambers*cathode + chamber
340 + planeCorrelation*kNhistosPlaneCorr;
342 return 0 + 2*kNhistosPlaneCorr;