26 #include "TObjString.h"
27 #include "TObjArray.h"
30 #include "TGraphAsymmErrors.h"
35 #include "AliVParticle.h"
36 #include "AliAODTrack.h"
37 #include "AliESDMuonTrack.h"
40 #include "AliAnalysisManager.h"
41 #include "AliAnalysisDataSlot.h"
42 #include "AliAnalysisDataContainer.h"
45 #include "AliVAnalysisMuon.h"
46 #include "AliMuonEventCuts.h"
47 #include "AliMuonTrackCuts.h"
48 #include "AliMergeableCollection.h"
49 #include "AliAnalysisMuonUtility.h"
73 AliVAnalysisMuon(name, cuts),
88 DefineOutput(2, TList::Class());
103 if ( ! AliAnalysisManager::GetAnalysisManager() || ! AliAnalysisManager::GetAnalysisManager()->IsProofMode() ) {
114 TList* outList =
new TList();
116 FillEffHistoList(physSel, trigClassNames, centrality, trackSelection, outList);
128 if ( ! fMergeableCollection )
return kFALSE;
129 if ( ! outList ) outList =
fList;
130 TString histoName =
"";
131 TString histoPattern =
"";
134 for ( Int_t icount=0; icount<
kNcounts; ++icount ) {
136 histoPattern = Form(
"%s%s", histoName.Data(), trackSelection.Data());
137 histo = (TH1*)GetSum(physSel, trigClassNames, centrality, histoPattern);
139 histo->SetName(histoName.Data());
140 histo->SetTitle(histoName.Data());
141 histo->SetDirectory(0);
146 for ( Int_t icount=0; icount<
kNcounts; ++icount ) {
147 for ( Int_t ich=0; ich<4; ++ich ) {
149 histoPattern = Form(
"%s%s", histoName.Data(), trackSelection.Data());
150 histo = (TH1*)GetSum(physSel, trigClassNames, centrality, histoPattern);
152 histo->SetName(histoName.Data());
153 histo->SetTitle(histoName.Data());
154 histo->SetDirectory(0);
160 for ( Int_t icount=0; icount<
kNcounts; ++icount ) {
161 for ( Int_t ich=0; ich<4; ++ich ) {
163 histoPattern = Form(
"%s%s", histoName.Data(), trackSelection.Data());
164 histo = (TH1*)GetSum(physSel, trigClassNames, centrality, histoPattern);
166 histo->SetName(histoName.Data());
167 histo->SetTitle(histoName.Data());
168 histo->SetDirectory(0);
176 histoPattern = Form(
"%s%s", histoName.Data(), trackSelection.Data());
177 histo = (TH1*)GetSum(physSel, trigClassNames, centrality, histoPattern);
179 histo->SetName(histoName.Data());
180 histo->SetTitle(histoName.Data());
181 histo->SetDirectory(0);
197 TString histoName =
"";
198 for ( Int_t isel=0; isel<kNselections; ++isel ) {
199 for ( Int_t itrig=0; itrig<GetAllSelectedTrigClasses()->GetEntries(); ++itrig ) {
200 for ( Int_t icent=1; icent<=GetCentralityClasses()->GetNbins(); ++icent ) {
201 for ( Int_t itrackSel=0; itrackSel<
kNtrackSel; ++itrackSel ) {
202 for ( Int_t imethod=0; imethod<
kNeffMethods; ++imethod ) {
204 for ( Int_t icount=-1; icount<
kNcounts; ++icount ) {
205 for ( Int_t ich=-1; ich<4; ++ich ) {
208 for ( Int_t jmatch=imatch+1; jmatch<=
kMatchHpt; ++jmatch ) {
209 histoName =
GetHistoName(itype, icount, ich, itrackSel, jmatch, imethod);
210 TH1* histoAdd = (TH1*)fMergeableCollection->GetObject(Form(
"/%s/%s/%s/",fPhysSelKeys->At(isel)->GetName(), GetAllSelectedTrigClasses()->At(itrig)->GetName(), GetCentralityClasses()->GetBinLabel(icent)), histoName);
211 if ( ! histoAdd )
continue;
212 histoName =
GetHistoName(itype, icount, ich, itrackSel, imatch, imethod);
213 if ( ! histo ) histo = (TH1*)GetMergeableObject(fPhysSelKeys->At(isel)->GetName(), GetAllSelectedTrigClasses()->At(itrig)->GetName(), GetCentralityClasses()->GetBinLabel(icent), histoName);
214 AliDebug(2,Form(
"Adding %s (%g) to %s (%g)", histoAdd->GetName(), histoAdd->Integral(), histo->GetName(), histo->Integral()));
215 histo->Add(histoAdd);
227 TString physSel = fPhysSelKeys->At(kPhysSelPass)->GetName();
228 TString trigClass =
"ANY";
229 TString centrality =
"all";
234 AliVAnalysisMuon::FinishTaskOutput();
245 TString matchTrigNames =
"Nopt Apt Lpt Hpt";
248 TString countTypeNames =
"bendPlaneCount nonBendPlaneCount bothPlanesCount allTracksCount";
251 TString histoTypeKeys =
"Chamber Slat Board checkRejectedBoard";
254 TString effMethodKeys =
"FromTrk FromTrg";
257 TString trackSelNames =
"Match NoSelMatch";
268 const Char_t* yAxisTitle =
"counts";
270 Int_t nChamberBins = 4;
271 Float_t chamberLow = 11.-0.5, chamberHigh = (Float_t)(nChamberBins)+11.-0.5;
272 const Char_t* chamberName =
"chamber";
274 Int_t nSlatBins = 18;
275 Float_t slatLow = 0.-0.5, slatHigh = (Float_t)nSlatBins-0.5;
276 const Char_t* slatName =
"slat";
278 Int_t nBoardBins = 234;
279 Float_t boardLow = 1.-0.5, boardHigh = (Float_t)nBoardBins+1.-0.5;
280 const Char_t* boardName =
"board";
282 TString baseName, histoName, histoTitle;
287 for ( Int_t itrackSel = 0; itrackSel<
kNtrackSel; ++itrackSel ) {
288 for ( Int_t imethod=0; imethod<
kNeffMethods; ++imethod ) {
289 for ( Int_t imatch = 0; imatch<
kNtrigMatch; ++imatch ) {
290 for ( Int_t icount=0; icount<
kNcounts; ++icount ) {
292 histo =
new TH1F(histoName, histoName,
293 nChamberBins, chamberLow, chamberHigh);
294 histo->GetXaxis()->SetTitle(chamberName);
295 histo->GetYaxis()->SetTitle(yAxisTitle);
296 AddObjectToCollection(histo);
299 for ( Int_t icount=0; icount<
kNcounts; ++icount ) {
300 for ( Int_t ich=0; ich<4; ++ich ) {
302 histo =
new TH1F(histoName, histoName,
303 nSlatBins, slatLow, slatHigh);
304 histo->GetXaxis()->SetTitle(slatName);
305 histo->GetYaxis()->SetTitle(yAxisTitle);
306 AddObjectToCollection(histo);
310 for ( Int_t icount=0; icount<
kNcounts; ++icount ) {
311 for ( Int_t ich=0; ich<4; ++ich ) {
313 histo =
new TH1F(histoName, histoName,
314 nBoardBins, boardLow, boardHigh);
315 histo->GetXaxis()->SetTitle(boardName);
316 histo->GetYaxis()->SetTitle(yAxisTitle);
317 AddObjectToCollection(histo);
322 histo2D =
new TH2F(histoName.Data(),
"Rejected tracks motivation",
323 5, 20.5, 25.5, nBoardBins, boardLow, boardHigh);
324 histo2D->GetXaxis()->SetBinLabel(1,
"Many pads");
325 histo2D->GetXaxis()->SetBinLabel(2,
"Few pads");
326 histo2D->GetXaxis()->SetBinLabel(3,
"Outside geom");
327 histo2D->GetXaxis()->SetBinLabel(4,
"Tracker track");
328 histo2D->GetXaxis()->SetBinLabel(5,
"Masked board");
329 histo2D->GetYaxis()->SetTitle(boardName);
330 AddObjectToCollection(histo2D);
335 fMuonTrackCuts->Print();
347 TString histoName =
"";
348 if ( itype < kHcheckBoard && icount >= 0 ) histoName +=
static_cast<TObjString*
>(
fCountTypeKeys->At(icount))->GetString();
349 if ( itype >= 0 ) histoName += ((TObjString*)
fHistoTypeKeys->At(itype))->GetString();
350 if ( ichamber >= 0 ) histoName += Form(
"Ch%i", 11+ichamber);
351 if ( itrackSel >= 0 ) histoName +=
static_cast<TObjString*
>(
fTrackSelKeys->At(itrackSel))->GetString();
352 if ( imatch >= 0 ) histoName +=
static_cast<TObjString*
>(
fMatchTrigKeys->At(imatch))->GetString();
353 if ( imethod >= 0 ) histoName +=
static_cast<TObjString*
>(
fEffMethodKeys->At(imethod))->GetString();
364 Int_t slat = 0, board = 0;
366 TString histoName =
"";
368 TArrayI othersEfficient(4);
370 AliVParticle* track = 0x0;
372 UInt_t addMask[4] = {0, AliMuonTrackCuts::kMuMatchApt, AliMuonTrackCuts::kMuMatchApt|AliMuonTrackCuts::kMuMatchLpt, AliMuonTrackCuts::kMuMatchApt|AliMuonTrackCuts::kMuMatchLpt|AliMuonTrackCuts::kMuMatchHpt};
374 Int_t nTracks = AliAnalysisMuonUtility::GetNTracks(InputEvent());
375 for ( Int_t itrack = 0; itrack < nTracks; ++itrack ) {
376 track = AliAnalysisMuonUtility::GetTrack(itrack,InputEvent());
378 Bool_t matchTracker = AliAnalysisMuonUtility::IsMuonTrack(track);
380 Int_t matchTrig = AliAnalysisMuonUtility::GetMatchTrigger(track);
381 UInt_t selection = fMuonTrackCuts->GetSelectionMask(track);
384 UInt_t filterMask = fMuonTrackCuts->GetFilterMask() | addMask[matchTrig];
385 Bool_t isSelected = ( ( selection & filterMask ) == filterMask );
387 for ( Int_t imethod=0; imethod<
kNeffMethods; ++imethod ) {
389 if ( ! matchTracker || track->P() < 10. )
continue;
390 pattern = AliAnalysisMuonUtility::GetMUONTrigHitsMapTrk(track);
391 board = AliESDMuonTrack::GetCrossedBoard(pattern);
394 if ( matchTrig == 0 )
continue;
395 pattern = AliAnalysisMuonUtility::GetMUONTrigHitsMapTrg(track);
396 board = ( AliAnalysisMuonUtility::IsAODEvent(InputEvent()) ) ? AliESDMuonTrack::GetCrossedBoard(pattern) : ((AliESDMuonTrack*)track)->LoCircuit();
399 Int_t effFlag = AliESDMuonTrack::GetEffFlag(pattern);
401 if ( effFlag < AliESDMuonTrack::kChEff ) {
402 for ( Int_t itrackSel=0; itrackSel<
kNtrackSel; ++itrackSel ) {
403 if ( itrackSel ==
kSelectTrack && ! isSelected )
continue;
404 for ( Int_t itrig=0; itrig<selectTrigClasses.GetEntries(); ++itrig ) {
405 TString trigClassName = ((TObjString*)selectTrigClasses.At(itrig))->GetString();
408 ((TH2F*)GetMergeableObject(physSel, trigClassName, centrality, histoName))->Fill(AliESDMuonTrack::GetSlatOrInfo(pattern), board);
414 othersEfficient.Reset(1);
415 for ( Int_t cath=0; cath<2; ++cath ) {
416 for ( Int_t ich=0; ich<4; ++ich ) {
417 if ( ! AliESDMuonTrack::IsChamberHit(pattern, cath, ich) ) {
418 for ( Int_t jch=0; jch<4; jch++ ) {
419 if ( jch != ich ) othersEfficient[jch] = 0;
426 Bool_t rejectTrack = kTRUE;
427 for ( Int_t ich=0; ich<4; ++ich ) {
428 if ( othersEfficient[ich] > 0 ) {
429 rejectTrack = kFALSE;
434 if ( rejectTrack )
continue;
436 slat = AliESDMuonTrack::GetSlatOrInfo(pattern);
438 for ( Int_t ich=0; ich<4; ++ich ) {
439 if ( ! othersEfficient[ich] )
443 Int_t iChamber = 11 + ich;
445 Bool_t hitsBend = AliESDMuonTrack::IsChamberHit(pattern, 0, ich);
446 Bool_t hitsNonBend = AliESDMuonTrack::IsChamberHit(pattern, 1, ich);
451 ( hitsBend && hitsNonBend ),
455 for ( Int_t itrackSel=0; itrackSel<
kNtrackSel; ++itrackSel ) {
456 if ( itrackSel ==
kSelectTrack && ! isSelected )
continue;
457 for (Int_t icount=0; icount<
kNcounts; ++icount){
458 if ( ! fillHisto[icount] )
continue;
459 for ( Int_t itrig=0; itrig<selectTrigClasses.GetEntries(); ++itrig ) {
460 TString trigClassName = ((TObjString*)selectTrigClasses.At(itrig))->GetString();
463 ((TH1*)GetMergeableObject(physSel, trigClassName, centrality, histoName))->Fill(iChamber);
465 if ( effFlag < AliESDMuonTrack::kSlatEff )
continue;
467 ((TH1*)GetMergeableObject(physSel, trigClassName, centrality, histoName))->Fill(slat);
469 if ( effFlag < AliESDMuonTrack::kBoardEff )
continue;
471 ((TH1*)GetMergeableObject(physSel, trigClassName, centrality, histoName))->Fill(board);
490 AliVAnalysisMuon::Terminate(
"");
492 if ( ! fMergeableCollection )
return;
500 TObjArray* physSel = ((TObjString*)fTerminateOptions->At(0))->GetString().Tokenize(
" ");
502 TObjArray* trigClasses = ((TObjString*)fTerminateOptions->At(1))->GetString().Tokenize(
" ");
503 trigClasses->SetOwner();
504 TObjArray* centrality = ((TObjString*)fTerminateOptions->At(2))->GetString().Tokenize(
" ");
505 centrality->SetOwner();
506 TString furtherOpt = ((TObjString*)fTerminateOptions->At(3))->GetString();
508 TString currName =
"";
509 TObjArray* optArr = furtherOpt.Tokenize(
" ");
510 TObjArray trackSel, methodSel;
512 methodSel.SetOwner();
513 TString outFileOpt =
"";
514 for ( Int_t iopt=0; iopt<optArr->GetEntries(); iopt++ ) {
515 currName = optArr->At(iopt)->GetName();
516 if ( currName.Contains(
".root") ) outFileOpt = currName;
517 else if ( currName.Contains(
"Match") ) trackSel.Add(
new TObjString(currName));
518 else if ( currName.Contains(
"From") ) methodSel.Add(
new TObjString(currName));
525 furtherOpt.ToUpper();
531 TString histoName =
"", yAxisTitle =
"";
535 TGraphAsymmErrors* effGraph = 0x0;
541 for ( Int_t icount=0; icount<
kNcounts-1; ++icount ) {
543 TCanvas* can =
new TCanvas(currName.Data(), currName.Data(), igroup1*xshift,igroup2*yshift,600,600);
545 TLegend* leg =
new TLegend(0.6, 0.6, 0.9, 0.9);
546 leg->SetBorderSize(1);
547 for ( Int_t ich=0; ich<4; ++ich ) {
548 TGraph* refGraph = 0x0;
550 gPad->SetRightMargin(0.03);
553 TString drawOpt =
"AP";
554 for ( Int_t isel=0; isel<physSel->GetEntries(); ++isel ) {
555 for ( Int_t itrig=0; itrig<trigClasses->GetEntries(); ++itrig ) {
556 for ( Int_t icent=0; icent<centrality->GetEntries(); ++icent ) {
557 for ( Int_t imethodSel=0; imethodSel<methodSel.GetEntries(); ++imethodSel ) {
558 for ( Int_t itrackSel=0; itrackSel<trackSel.GetEntries(); ++itrackSel ) {
560 histoName += Form(
"%s%s",trackSel.At(itrackSel)->GetName(),methodSel.At(imethodSel)->GetName());
561 den = (TH1*)GetSum(physSel->At(isel)->GetName(), trigClasses->At(itrig)->GetName(), centrality->At(icent)->GetName(), histoName.Data());
563 printf(
"Warning: cannot find %s\n", histoName.Data());
566 histoName =
GetHistoName(chosenType, icount, ich, -1, -1, -1);
567 histoName += Form(
"%s%s",trackSel.At(itrackSel)->GetName(),methodSel.At(imethodSel)->GetName());
568 num = (TH1*)GetSum(physSel->At(isel)->GetName(), trigClasses->At(itrig)->GetName(), centrality->At(icent)->GetName(), histoName.Data());
569 if ( ! num )
continue;
570 effGraph =
new TGraphAsymmErrors(num, den,
"e0");
571 currName = Form(
"%s_%s_%s_%s_%s", physSel->At(isel)->GetName(), trigClasses->At(itrig)->GetName(), centrality->At(icent)->GetName(), trackSel.At(itrackSel)->GetName(), methodSel.At(imethodSel)->GetName());
572 effGraph->SetTitle(currName.Data());
576 yAxisTitle =
"Efficiency";
578 if ( furtherOpt.Contains(
"DIFF") || furtherOpt.Contains(
"PULL") ) {
583 Double_t currX, currY, baseX, baseY, errYlow = 0., errYhigh = 0., newY = 0.;
584 Double_t refVal = 1., errY = 0.;
585 for ( Int_t ipoint=0; ipoint<effGraph->GetN(); ipoint++ ) {
586 refGraph->GetPoint(ipoint, baseX, baseY);
587 effGraph->GetPoint(ipoint, currX, currY);
588 Double_t errX = effGraph->GetErrorXlow(ipoint);
589 if ( furtherOpt.Contains(
"DIFF") ) {
590 refVal = ( baseY > 0. ) ? baseY : 1.;
591 newY = ( currY - baseY ) / refVal;
592 Double_t errYlow1 = effGraph->GetErrorYlow(ipoint);
593 Double_t errYlow2 = refGraph->GetErrorYlow(ipoint);
594 Double_t errYhigh1 = effGraph->GetErrorYhigh(ipoint);
595 Double_t errYhigh2 = refGraph->GetErrorYhigh(ipoint);
596 errYlow = TMath::Sqrt(errYlow1*errYlow1 + errYlow2*errYlow2) / refVal;
597 errYhigh = TMath::Sqrt(errYhigh1*errYhigh1 + errYhigh2*errYhigh2) / refVal;
599 yAxisTitle =
"(eff - ref ) / ref";
600 effGraph->SetTitle(Form(
"Rel. diff. w.r.t. %s", refGraph->GetTitle()));
604 else if ( furtherOpt.Contains(
"PULL") ) {
605 errY = 0.5 * ( effGraph->GetErrorYlow(ipoint) + effGraph->GetErrorYhigh(ipoint));
606 newY = ( errY > 0. ) ? ( currY - baseY ) / errY : 0.;
610 yAxisTitle =
"(eff - ref ) / err";
611 effGraph->SetTitle(Form(
"Pull w.r.t. %s", refGraph->GetTitle()));
615 effGraph->SetPoint(ipoint, currX, newY);
616 effGraph->SetPointError(ipoint, errX, errX, errYlow, errYhigh);
619 effGraph->GetYaxis()->SetRangeUser(ymin, ymax);
620 effGraph->GetYaxis()->SetTitle(yAxisTitle.Data());
621 effGraph->SetLineColor(icolor);
622 effGraph->SetMarkerColor(icolor);
623 effGraph->SetMarkerStyle(20 + istyle);
626 if ( icolor == 5 || icolor == 10 ) icolor++;
628 effGraph->Draw(drawOpt.Data());
630 if ( ich < 3 )
continue;
631 leg->AddEntry(effGraph, currName.Data(),
"lp");
647 fList =
dynamic_cast<TList*
>(GetOutputData(2));
653 TString baseName[3] = {
"Chamber",
"RPC",
"Board"};
655 TString effName[kNcounts-1] = {
"BendPlane",
"NonBendPlane",
"BothPlanes"};
656 for ( Int_t itype=0; itype<3; itype++ ) {
657 for ( Int_t icount=0; icount<kNcounts-1; icount++ ){
658 TString canName = Form(
"efficiencyPer%s_%s",baseName[itype].Data(),effName[icount].Data());
659 TCanvas* can =
new TCanvas(canName.Data(),canName.Data(),10*(1+kNcounts*itype+icount),10*(1+kNcounts*itype+icount),310,310);
660 can->SetFillColor(10); can->SetHighLightColor(10);
661 can->SetLeftMargin(0.15); can->SetBottomMargin(0.15);
665 for ( Int_t ich=-1; ich<4; ich++ ) {
666 histoName =
GetHistoName(baseIndex[itype], icount, ich, -1, -1, -1);
667 num = (TH1*)
fList->FindObject(histoName.Data());
668 histoName =
GetHistoName(baseIndex[itype], kNcounts-1, ich, -1, -1, -1);
669 den = (TH1*)
fList->FindObject(histoName.Data());
670 if ( ! num || ! den )
continue;
671 effGraph =
new TGraphAsymmErrors(num, den,
"e0");
672 effGraph->GetYaxis()->SetRangeUser(0., 1.1);
673 effGraph->GetYaxis()->SetTitle(
"Efficiency");
674 effGraph->GetXaxis()->SetTitle(baseName[itype].Data());
676 effGraph->Draw(
"AP");
677 if ( itype == 0 )
break;
684 if ( ! outFileOpt.IsNull() ) {
685 TObjArray* outFileOptList = outFileOpt.Tokenize(
"?");
686 AliInfo(Form(
"Creating file %s", outFileOptList->At(0)->GetName()));
687 TList* effList =
GetEffHistoList(outFileOptList->At(1)->GetName(), outFileOptList->At(2)->GetName(), outFileOptList->At(3)->GetName(), outFileOptList->At(4)->GetName());
688 effList->SetName(GetOutputSlot(2)->GetContainer()->GetName());
689 if ( effList ->GetEntries() == 0 ) {
690 printf(
"\nWarning: no histograms satisfying the requested conditions.\n(%s %s %s %s).\nOutput %s not created.\n", outFileOptList->At(1)->GetName(), outFileOptList->At(2)->GetName(), outFileOptList->At(3)->GetName(), outFileOptList->At(4)->GetName(),outFileOptList->At(0)->GetName());
693 TFile* outFile = TFile::Open(outFileOptList->At(0)->GetName(),
"RECREATE");
694 effList->Write(effList->GetName(),TObject::kSingleKey);
698 delete outFileOptList;
TObjArray * fTrackSelKeys
Selection names.
ClassImp(AliAnalysisTaskTriggerRates) AliAnalysisTaskTriggerRates
void Terminate(Option_t *option)
void ProcessEvent(TString physSel, const TObjArray &selectTrigClasses, TString centrality)
Hit pattern from tracker track extrapolation.
TObjArray * fHistoTypeKeys
Base histogram name.
Check rejected tracks per board.
Check rejected tracks per board.
TObjArray * fMatchTrigKeys
Match trigger names.
TList * GetEffHistoList(TString physSel, TString trigClassNames, TString centrality, TString trackSelection)
TObjArray * fCountTypeKeys
Count type keys.
Counts per slat histogram index.
Total number of matched types.
Counts per board histogram index.
Total number of track selection.
AliAnalysisTaskTrigChEff()
virtual ~AliAnalysisTaskTrigChEff()
TString GetHistoName(Int_t itype, Int_t icount, Int_t ichamber, Int_t itrackSel, Int_t imatch, Int_t imethod)
Bool_t FillEffHistoList(TString physSel, TString trigClassNames, TString centrality, TString trackSelection, TList *outList=0x0)
void MyUserCreateOutputObjects()
tracks used for calculation
Counts per cathode histogram index.
TList * fList
TList output object.
TObjArray * fEffMethodKeys
Efficiency methods keys.
Total number of efficiency methods.