From: martinez Date: Mon, 16 Nov 2009 08:08:08 +0000 (+0000) Subject: Fixing algorithm for efficiency calculation (Diego) X-Git-Url: http://git.uio.no/git/?a=commitdiff_plain;h=ebbabac1f6a975f6223784036ad765d9eb519acf;p=u%2Fmrichter%2FAliRoot.git Fixing algorithm for efficiency calculation (Diego) --- diff --git a/PWG3/muon/AliAnalysisTaskTrigChEff.cxx b/PWG3/muon/AliAnalysisTaskTrigChEff.cxx index d529493093a..3453b05e285 100644 --- a/PWG3/muon/AliAnalysisTaskTrigChEff.cxx +++ b/PWG3/muon/AliAnalysisTaskTrigChEff.cxx @@ -1,7 +1,36 @@ +/************************************************************************** + * Copyright(c) 1998-2007, ALICE Experiment at CERN, All rights reserved. * + * * + * Author: The ALICE Off-line Project. * + * Contributors are mentioned in the code where appropriate. * + * * + * Permission to use, copy, modify and distribute this software and its * + * documentation strictly for non-commercial purposes is hereby granted * + * without fee, provided that the above copyright notice appears in all * + * copies and that both the copyright notice and this permission notice * + * appear in the supporting documentation. The authors make no claims * + * about the suitability of this software for any purpose. It is * + * provided "as is" without express or implied warranty. * + **************************************************************************/ + +//----------------------------------------------------------------------------- +/// \class AliAnalysisTaskSingleMu +/// Analysis task for single muons in the spectrometer. +/// The output is a list of histograms. +/// The macro class can run on AOD or ESDs. +/// If Monte Carlo information is present, some basics checks are performed. +/// +/// \author Diego Stocco +//----------------------------------------------------------------------------- + +//---------------------------------------------------------------------------- +// Implementation of the class for trigger chamber efficiency determinaltion +//---------------------------------------------------------------------------- + + #define AliAnalysisTaskTrigChEff_cxx // ROOT includes -#include "TChain.h" #include "TH1.h" #include "TCanvas.h" #include "TROOT.h" @@ -10,67 +39,35 @@ // STEER includes #include "AliLog.h" - #include "AliESDEvent.h" #include "AliESDMuonTrack.h" -#include "AliESDInputHandler.h" // ANALYSIS includes -#include "AliAnalysisTask.h" -#include "AliAnalysisDataSlot.h" -#include "AliAnalysisManager.h" +#include "AliAnalysisTaskSE.h" + #include "AliAnalysisTaskTrigChEff.h" ClassImp(AliAnalysisTaskTrigChEff) //________________________________________________________________________ AliAnalysisTaskTrigChEff::AliAnalysisTaskTrigChEff(const char *name) : - AliAnalysisTask(name,""), - fESD(0), + AliAnalysisTaskSE(name), fUseGhosts(kFALSE), fList(0) { // /// Constructor. // - // Input slot #0 works with an Ntuple - DefineInput(0, TChain::Class()); - // Output slot #0 writes into a TObjArray container - DefineOutput(0, TList::Class()); + // Output slot #1 writes into a TObjArray container + DefineOutput(1, TList::Class()); } //___________________________________________________________________________ -void AliAnalysisTaskTrigChEff::ConnectInputData(Option_t *) { - // - /// Connect ESD here - /// Called once - // - - TTree* tree = dynamic_cast (GetInputData(0)); - if (!tree) { - Printf("ERROR: Could not read chain from input slot 0"); - } else { - // Disable all branches and enable only the needed ones - // The next two lines are different when data produced as AliESDEvent is read - tree->SetBranchStatus("*", kFALSE); - tree->SetBranchStatus("MuonTracks.*", kTRUE); - - AliESDInputHandler *esdH = dynamic_cast (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()); - - if (!esdH) { - Printf("ERROR: Could not get ESDInputHandler"); - } else - fESD = esdH->GetEvent(); - } -} - -//___________________________________________________________________________ -void AliAnalysisTaskTrigChEff::CreateOutputObjects() { +void AliAnalysisTaskTrigChEff::UserCreateOutputObjects() { // /// Create histograms /// Called once // - Printf(" CreateOutputObjects of task %s\n", GetName()); TString cathCode[2] = {"bendPlane", "nonBendPlane"}; TString countTypeName[2] = {"CountInCh", "NonCountInCh"}; @@ -92,8 +89,8 @@ void AliAnalysisTaskTrigChEff::CreateOutputObjects() { Float_t boardLow = 1-0.5, boardHigh = kNboards+1.-0.5; const Char_t* boardName = "board"; - Int_t angleBins = 140; - Float_t angleLow = -35., angleHigh = 35.; + Int_t angleBins = 280; + Float_t angleLow = -70., angleHigh = 70.; const Char_t* angleNameX = "#theta_{x} (deg)"; const Char_t* angleNameY = "#theta_{y} (deg)"; @@ -117,7 +114,7 @@ void AliAnalysisTaskTrigChEff::CreateOutputObjects() { fList->AddAt(histo, kHtracksInBoard); for(Int_t hType=0; hType (InputEvent()); + + if (!esdEvent) { + Printf("ERROR: esdEvent not available\n"); + return; + } + + Int_t slat = 0, board = 0; UShort_t pattern = 0; AliESDMuonTrack *esdTrack = 0x0; const Float_t kRadToDeg = 180./TMath::Pi(); + Int_t nTracks = esdEvent->GetNumberOfMuonTracks(); - if (!fESD) { - Printf("ERROR: fESD not available"); - return; - } - nTracks = fESD->GetNumberOfMuonTracks(); - - // Object declaration const Int_t kFirstTrigCh = 11; //AliMpConstants::NofTrackingChambers()+1; + TArrayI othersEfficient(kNchambers); + for (Int_t itrack = 0; itrack < nTracks; itrack++) { - esdTrack = fESD->GetMuonTrack(itrack); - pattern = esdTrack->GetHitsPatternInTrigCh(); - board = esdTrack->LoCircuit(); + esdTrack = esdEvent->GetMuonTrack(itrack); if ( ! esdTrack->ContainTrackerData() && ! fUseGhosts ) continue; + pattern = esdTrack->GetHitsPatternInTrigCh(); Int_t effFlag = AliESDMuonTrack::GetEffFlag(pattern); if(effFlag < AliESDMuonTrack::kChEff) continue; // Track not good for efficiency calculation @@ -210,48 +209,63 @@ void AliAnalysisTaskTrigChEff::Exec(Option_t *) { ((TH1F*)fList->At(kHthetaX))->Fill(esdTrack->GetThetaX() * kRadToDeg); ((TH1F*)fList->At(kHthetaY))->Fill(esdTrack->GetThetaY() * kRadToDeg); - Int_t slat = AliESDMuonTrack::GetSlatOrInfo(pattern); + othersEfficient.Reset(1); + for(Int_t cath=0; cath 0 ){ + rejectTrack = kFALSE; + break; + } + } + + if ( rejectTrack ) continue; + + slat = AliESDMuonTrack::GetSlatOrInfo(pattern); + board = esdTrack->LoCircuit(); if(effFlag >= AliESDMuonTrack::kSlatEff) ((TH1F*)fList->At(kHtracksInSlat))->Fill(slat); if(effFlag >= AliESDMuonTrack::kBoardEff) ((TH1F*)fList->At(kHtracksInBoard))->Fill(board); for(Int_t cath=0; cath=0){ - whichType = kChNonEff; - currCh = ineffCh; - nChambers = -1; - } - - Int_t iChamber = kFirstTrigCh + currCh; - Int_t hindex = (whichType==kAllChEff) ? kHchamberAllEff : kHchamberNonEff; + Int_t iChamber = kFirstTrigCh + ch; + Int_t hindex = ( whichType == kChHit ) ? kHchamberEff : kHchamberNonEff; ((TH1F*)fList->At(hindex + cath))->Fill(iChamber); if(effFlag < AliESDMuonTrack::kSlatEff) continue; // Track crossed different slats - Int_t chCath = GetPlane(cath, currCh); - hindex = (whichType==kAllChEff) ? kHslatAllEff : kHslatNonEff; + Int_t chCath = GetPlane(cath, ch); + hindex = ( whichType == kChHit ) ? kHslatEff : kHslatNonEff; ((TH1F*)fList->At(hindex + chCath))->Fill(slat); if(effFlag < AliESDMuonTrack::kBoardEff) continue; // Track crossed different boards - hindex = (whichType==kAllChEff) ? kHboardAllEff : kHboardNonEff; + hindex = ( whichType == kChHit ) ? kHboardEff : kHboardNonEff; ((TH1F*)fList->At(hindex + chCath))->Fill(board); } // loop on chambers } // loop on cathodes - } + } // loop on tracks // Post final data. It will be written to a file with option "RECREATE" - PostData(0, fList); + PostData(1, fList); } //________________________________________________________________________ @@ -272,7 +286,7 @@ void AliAnalysisTaskTrigChEff::Terminate(Option_t *) { can[cath]->Divide(2,2); for(Int_t ch=0; chAt(kHboardAllEff + chCath)->Clone()); + num = (TH1F*)(fList->At(kHboardEff + chCath)->Clone()); den = (TH1F*)(fList->At(kHboardNonEff + chCath)->Clone()); den->Add(num); num->Divide(den); diff --git a/PWG3/muon/AliAnalysisTaskTrigChEff.h b/PWG3/muon/AliAnalysisTaskTrigChEff.h index 88a94fdce4b..b7542696921 100644 --- a/PWG3/muon/AliAnalysisTaskTrigChEff.h +++ b/PWG3/muon/AliAnalysisTaskTrigChEff.h @@ -1,19 +1,21 @@ -#include "TH1.h" -#include "TList.h" +/// \ingroup "PWG3muon" +/// \class AliAnalysisTaskTrigChEff +/// \brief Analysis task for trigger chamber efficiency determination +/// +// Author Diego Stocco -#include "AliESDEvent.h" -#include "AliAODEvent.h" +class TList; -class AliAnalysisTaskTrigChEff : public AliAnalysisTask { +class AliAnalysisTaskTrigChEff : public AliAnalysisTaskSE { public: AliAnalysisTaskTrigChEff(const char *name = "AliAnalysisTaskTrigChEff"); virtual ~AliAnalysisTaskTrigChEff() {} - - virtual void ConnectInputData(Option_t *); - virtual void CreateOutputObjects(); - virtual void Exec(Option_t *option); + + virtual void UserCreateOutputObjects(); + virtual void UserExec(Option_t *option); virtual void Terminate(Option_t *); + /// Use ghost tracks in calculations void SetUseGhostTracks(Bool_t useGhosts = kTRUE) { fUseGhosts = useGhosts; } protected: @@ -25,10 +27,9 @@ private: /// Not implemented AliAnalysisTaskTrigChEff& operator = (const AliAnalysisTaskTrigChEff& rhs); - AliESDEvent* fESD; //!< ESDevent object - Bool_t fUseGhosts; //!< Flag to use also the trigger tracks not matching the tracker in eff. calculation + Bool_t fUseGhosts; ///< Flag to use also the trigger tracks not matching the tracker in eff. calculation - TList* fList; //TList output object + TList* fList; ///