1 #define AliAnalysisTaskTrigChEff_cxx
14 #include "AliESDEvent.h"
15 #include "AliESDMuonTrack.h"
16 #include "AliESDInputHandler.h"
19 #include "AliAnalysisTask.h"
20 #include "AliAnalysisDataSlot.h"
21 #include "AliAnalysisManager.h"
22 #include "AliAnalysisTaskTrigChEff.h"
24 ClassImp(AliAnalysisTaskTrigChEff)
26 //________________________________________________________________________
27 AliAnalysisTaskTrigChEff::AliAnalysisTaskTrigChEff(const char *name) :
28 AliAnalysisTask(name,""),
36 // Input slot #0 works with an Ntuple
37 DefineInput(0, TChain::Class());
38 // Output slot #0 writes into a TObjArray container
39 DefineOutput(0, TList::Class());
42 //___________________________________________________________________________
43 void AliAnalysisTaskTrigChEff::ConnectInputData(Option_t *) {
49 TTree* tree = dynamic_cast<TTree*> (GetInputData(0));
51 Printf("ERROR: Could not read chain from input slot 0");
53 // Disable all branches and enable only the needed ones
54 // The next two lines are different when data produced as AliESDEvent is read
55 tree->SetBranchStatus("*", kFALSE);
56 tree->SetBranchStatus("MuonTracks.*", kTRUE);
58 AliESDInputHandler *esdH = dynamic_cast<AliESDInputHandler*> (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
61 Printf("ERROR: Could not get ESDInputHandler");
63 fESD = esdH->GetEvent();
67 //___________________________________________________________________________
68 void AliAnalysisTaskTrigChEff::CreateOutputObjects() {
73 Printf(" CreateOutputObjects of task %s\n", GetName());
75 TString cathCode[2] = {"bendPlane", "nonBendPlane"};
76 TString countTypeName[2] = {"CountInCh", "NonCountInCh"};
78 const Char_t* yAxisTitle = "counts";
80 const Int_t kNboards = 234; //AliMpConstants::NofLocalBoards();
81 const Int_t kFirstTrigCh = 11;//AliMpConstants::NofTrackingChambers()+1;
83 Int_t chamberBins = kNchambers;
84 Float_t chamberLow = kFirstTrigCh-0.5, chamberHigh = kFirstTrigCh+kNchambers-0.5;
85 const Char_t* chamberName = "chamber";
87 Int_t slatBins = kNslats;
88 Float_t slatLow = 0-0.5, slatHigh = kNslats-0.5;
89 const Char_t* slatName = "slat";
91 Int_t boardBins = kNboards;
92 Float_t boardLow = 1-0.5, boardHigh = kNboards+1.-0.5;
93 const Char_t* boardName = "board";
95 Int_t angleBins = 140;
96 Float_t angleLow = -35., angleHigh = 35.;
97 const Char_t* angleNameX = "#theta_{x} (deg)";
98 const Char_t* angleNameY = "#theta_{y} (deg)";
100 TString baseName, histoName;
105 histo = new TH1F("nTracksInSlat", "Num. of tracks used for efficiency calculation",
106 slatBins, slatLow, slatHigh);
107 histo->GetXaxis()->SetTitle(slatName);
108 histo->GetYaxis()->SetTitle("num of used tracks");
110 fList->AddAt(histo, kHtracksInSlat);
112 histo = new TH1F("nTracksInBoard", "Num. of tracks used for efficiency calculation",
113 boardBins, boardLow, boardHigh);
114 histo->GetXaxis()->SetTitle(boardName);
115 histo->GetYaxis()->SetTitle("num of used tracks");
117 fList->AddAt(histo, kHtracksInBoard);
119 for(Int_t hType=0; hType<kNcounts; hType++){
120 Int_t hindex = (hType==0) ? kHchamberAllEff : kHchamberNonEff;
121 for(Int_t cath=0; cath<kNcathodes; cath++){
122 histoName = Form("%sChamber%s", cathCode[cath].Data(), countTypeName[hType].Data());
123 histo = new TH1F(histoName, histoName,
124 chamberBins, chamberLow, chamberHigh);
125 histo->GetXaxis()->SetTitle(chamberName);
126 histo->GetYaxis()->SetTitle(yAxisTitle);
128 fList->AddAt(histo, hindex + cath);
132 for(Int_t hType=0; hType<kNcounts; hType++){
133 Int_t hindex = (hType==0) ? kHslatAllEff : kHslatNonEff;
134 for(Int_t cath=0; cath<kNcathodes; cath++){
135 for(Int_t ch=0; ch<kNchambers; ch++){
136 Int_t chCath = GetPlane(cath, ch);
137 histoName = Form("%sSlat%s%i", cathCode[cath].Data(), countTypeName[hType].Data(), kFirstTrigCh+ch);
138 histo = new TH1F(histoName, histoName,
139 slatBins, slatLow, slatHigh);
140 histo->GetXaxis()->SetTitle(slatName);
141 histo->GetYaxis()->SetTitle(yAxisTitle);
143 fList->AddAt(histo, hindex + chCath);
148 for(Int_t hType=0; hType<kNcounts; hType++){
149 Int_t hindex = (hType==0) ? kHboardAllEff : kHboardNonEff;
150 for(Int_t cath=0; cath<kNcathodes; cath++){
151 for(Int_t ch=0; ch<kNchambers; ch++){
152 Int_t chCath = GetPlane(cath, ch);
153 histoName = Form("%sBoard%s%i", cathCode[cath].Data(), countTypeName[hType].Data(), kFirstTrigCh+ch);
154 histo = new TH1F(histoName, histoName,
155 boardBins, boardLow, boardHigh);
156 histo->GetXaxis()->SetTitle(boardName);
157 histo->GetYaxis()->SetTitle(yAxisTitle);
159 fList->AddAt(histo, hindex + chCath);
164 histo = new TH1F("thetaX", "Angular distribution",
165 angleBins, angleLow, angleHigh);
166 histo->GetXaxis()->SetTitle(angleNameX);
167 histo->GetYaxis()->SetTitle("entries");
168 fList->AddAt(histo, kHthetaX);
170 histo = new TH1F("thetaY", "Angular distribution",
171 angleBins, angleLow, angleHigh);
172 histo->GetXaxis()->SetTitle(angleNameY);
173 histo->GetYaxis()->SetTitle("entries");
174 fList->AddAt(histo, kHthetaY);
178 //________________________________________________________________________
179 void AliAnalysisTaskTrigChEff::Exec(Option_t *) {
182 /// Called for each event
184 Int_t nTracks = 0, board = 0;
185 UShort_t pattern = 0;
186 AliESDMuonTrack *esdTrack = 0x0;
188 const Float_t kRadToDeg = 180./TMath::Pi();
191 Printf("ERROR: fESD not available");
194 nTracks = fESD->GetNumberOfMuonTracks();
196 // Object declaration
197 const Int_t kFirstTrigCh = 11; //AliMpConstants::NofTrackingChambers()+1;
199 for (Int_t itrack = 0; itrack < nTracks; itrack++) {
200 esdTrack = fESD->GetMuonTrack(itrack);
201 pattern = esdTrack->GetHitsPatternInTrigCh();
202 board = esdTrack->LoCircuit();
204 if ( ! esdTrack->ContainTrackerData() && ! fUseGhosts ) continue;
206 Int_t effFlag = AliESDMuonTrack::GetEffFlag(pattern);
208 if(effFlag < AliESDMuonTrack::kChEff) continue; // Track not good for efficiency calculation
210 ((TH1F*)fList->At(kHthetaX))->Fill(esdTrack->GetThetaX() * kRadToDeg);
211 ((TH1F*)fList->At(kHthetaY))->Fill(esdTrack->GetThetaY() * kRadToDeg);
213 Int_t slat = AliESDMuonTrack::GetSlatOrInfo(pattern);
215 if(effFlag >= AliESDMuonTrack::kSlatEff) ((TH1F*)fList->At(kHtracksInSlat))->Fill(slat);
216 if(effFlag >= AliESDMuonTrack::kBoardEff) ((TH1F*)fList->At(kHtracksInBoard))->Fill(board);
218 for(Int_t cath=0; cath<kNcathodes; cath++){
220 for(Int_t ich=0; ich<kNchambers; ich++){
221 if(!AliESDMuonTrack::IsChamberHit(pattern, cath, ich)){
227 Int_t nChambers = kNchambers;
228 for(Int_t ch=0; ch<nChambers; ch++){
229 Int_t whichType = kAllChEff;
232 whichType = kChNonEff;
237 Int_t iChamber = kFirstTrigCh + currCh;
238 Int_t hindex = (whichType==kAllChEff) ? kHchamberAllEff : kHchamberNonEff;
239 ((TH1F*)fList->At(hindex + cath))->Fill(iChamber);
241 if(effFlag < AliESDMuonTrack::kSlatEff) continue; // Track crossed different slats
242 Int_t chCath = GetPlane(cath, currCh);
243 hindex = (whichType==kAllChEff) ? kHslatAllEff : kHslatNonEff;
244 ((TH1F*)fList->At(hindex + chCath))->Fill(slat);
246 if(effFlag < AliESDMuonTrack::kBoardEff) continue; // Track crossed different boards
247 hindex = (whichType==kAllChEff) ? kHboardAllEff : kHboardNonEff;
248 ((TH1F*)fList->At(hindex + chCath))->Fill(board);
249 } // loop on chambers
250 } // loop on cathodes
253 // Post final data. It will be written to a file with option "RECREATE"
257 //________________________________________________________________________
258 void AliAnalysisTaskTrigChEff::Terminate(Option_t *) {
260 /// Draw result to the screen
261 /// Called once at the end of the query.
263 if (!gROOT->IsBatch()) {
264 TCanvas *can[kNcathodes];
267 for(Int_t cath=0; cath<kNcathodes; cath++){
268 TString canName = Form("can%i",cath);
269 can[cath] = new TCanvas(canName.Data(),canName.Data(),10*(1+cath),10*(1+cath),310,310);
270 can[cath]->SetFillColor(10); can[cath]->SetHighLightColor(10);
271 can[cath]->SetLeftMargin(0.15); can[cath]->SetBottomMargin(0.15);
272 can[cath]->Divide(2,2);
273 for(Int_t ch=0; ch<kNchambers; ch++){
274 Int_t chCath = GetPlane(cath, ch);
275 num = (TH1F*)(fList->At(kHboardAllEff + chCath)->Clone());
276 den = (TH1F*)(fList->At(kHboardNonEff + chCath)->Clone());