//________________________________________________________________________
-Int_t AliAnalysisMuonUtility::GetPassNumber ( const AliInputEventHandler* eventHandler )
+TString AliAnalysisMuonUtility::GetPassName ( const AliInputEventHandler* eventHandler )
{
- /// Get pass number from event
-
- // At present there is no straightforward way to get the pass number.
- // The pass number is usually written in the path to the ESDs/AODs
+ /// Get pass name from event
+
+ // At present there is no straightforward way to get the pass name.
+ // The pass name is usually written in the path to the ESDs/AODs
// but this won't work for:
// - MC data (no pass info available)
// - local ESDs/AODs
TString filePath = "";
- const AliVEvent* event = eventHandler->GetEvent();
+ const AliVEvent* event = eventHandler->GetEvent();
if ( IsAODEvent(event) ) {
// In AODs, the header contains the path to the input ESD event
// However, sometimes there is not the FULL path of the ESDs.
// (which is a priori safer because it works even on local copies of AODs)
// and if it does not work, directly check the path to the AOD
filePath = static_cast<const AliAODEvent*> (event)->GetHeader()->GetESDFileName();
- Int_t passNumber = GetPassNumber(filePath.Data());
- if ( passNumber < 0 ) AliWarningClass("Check again with the AOD path");
- else return passNumber;
+ TString passName = GetPassName(filePath.Data());
+ if ( passName.IsNull() ) AliWarningClass("Check again with the AOD path");
+ else return passName;
}
filePath = eventHandler->GetTree()->GetCurrentFile()->GetName();
- return GetPassNumber(filePath.Data());
+ return GetPassName(filePath.Data());
+}
+
+
+//________________________________________________________________________
+Int_t AliAnalysisMuonUtility::GetPassNumber ( const AliInputEventHandler* eventHandler )
+{
+ /// Get pass number from event
+
+ // At present there is no straightforward way to get the pass number.
+ // The pass number is usually written in the path to the ESDs/AODs
+ // but this won't work for:
+ // - MC data (no pass info available)
+ // - local ESDs/AODs
+
+ TString passName = GetPassName(eventHandler);
+ return GetPassNumber(passName);
}
+//________________________________________________________________________
+TString AliAnalysisMuonUtility::GetPassName ( const char* str )
+{
+ //
+ /// Get pass name from string
+ //
+
+ TString currName(str);
+ TObjArray* array = currName.Tokenize("/");
+
+ TString passName = "";
+ for ( Int_t ientry=0; ientry<array->GetEntries(); ientry++ ) {
+ TString currToken = static_cast<TObjString*>(array->At(ientry))->GetString();
+ TString checkToken(currToken);
+ checkToken.ToUpper();
+ if ( checkToken.Contains("PASS") || checkToken.Contains("MUON_CALO") ) {
+ passName = currToken;
+ break;
+ }
+ }
+
+ delete array;
+
+ if ( passName.IsNull() ) AliWarningClass(Form("Cannot find pass name in: %s", str));
+
+ return passName;
+}
+
//________________________________________________________________________
Int_t AliAnalysisMuonUtility::GetPassNumber ( const char* str )
{
#include "AliInputEventHandler.h"
#include "AliVEvent.h"
+#include "AliProdInfo.h"
#include "AliOADBContainer.h"
#include "AliAnalysisMuonUtility.h"
fUseCustomParam(kFALSE),
fSharpPtCut(kFALSE),
fAllowDefaultParams(kFALSE),
- fPassNumber(-1),
+ fPassName(""),
fOADBParam()
{
/// Default ctor.
fUseCustomParam(kFALSE),
fSharpPtCut(kFALSE),
fAllowDefaultParams(kFALSE),
- fPassNumber(-1),
+ fPassName(""),
fOADBParam("muonTrackCutsParam")
{
/// Constructor
fUseCustomParam(obj.fUseCustomParam),
fSharpPtCut(obj.fSharpPtCut),
fAllowDefaultParams(obj.fAllowDefaultParams),
- fPassNumber(obj.fPassNumber),
+ fPassName(obj.fPassName),
fOADBParam(obj.fOADBParam)
{
/// Copy constructor
fUseCustomParam = obj.fUseCustomParam;
fSharpPtCut = obj.fSharpPtCut;
fAllowDefaultParams = obj.fAllowDefaultParams;
- fPassNumber = obj.fPassNumber;
+ fPassName = obj.fPassName;
fOADBParam = obj.fOADBParam;
}
return *this;
}
//________________________________________________________________________
-void AliMuonTrackCuts::SetCustomParamFromRun( Int_t runNumber, Int_t passNumber )
+void AliMuonTrackCuts::SetPassNumber ( Int_t passNumber )
+{
+ /// Set pass number (for backward compatibility)
+ AliWarning("Obsolete: please use SetPassName instead");
+ fPassName = Form("pass%i",passNumber);
+}
+
+//________________________________________________________________________
+void AliMuonTrackCuts::SetCustomParamFromRun( Int_t runNumber, TString passName )
{
/// It first searches the default parameters in OADB
/// then disables the access to the OADB
/// and allows to manually modify parameters
-
- fPassNumber = passNumber;
- ReadParamFromOADB ( runNumber, passNumber );
+
+ if ( passName.IsNull() ) passName = fPassName;
+ else fPassName = passName;
+ ReadParamFromOADB ( runNumber, passName );
fUseCustomParam = kTRUE;
- //AliWarning (Form("Setting parameters from run %i pass %i. From now on SetRun does NOTHING!!", runNumber, passNumber));
- AliWarning (Form("From now on SetRun does NOTHING!!"));
+ AliWarning ("From now on SetRun does NOTHING!!");
}
-
//________________________________________________________________________
AliOADBMuonTrackCutsParam* AliMuonTrackCuts::CustomParam ( )
{
}
//________________________________________________________________________
-Bool_t AliMuonTrackCuts::SetRun ( const AliInputEventHandler* eventHandler )
+void AliMuonTrackCuts::SetCustomParam ( const AliInputEventHandler* eventHandler )
{
- /// Get parameters from OADB for current run
+ /// It tries to sets the parameters from the OADB
+ /// for the current run, then gives the possiblity to the user
+ /// to change them in his task
- if ( fUseCustomParam ) return kFALSE;
Int_t runNumber = eventHandler->GetEvent()->GetRunNumber();
+ TString passName = GuessPass(eventHandler);
+ SetCustomParamFromRun( runNumber, passName );
+}
+
+//________________________________________________________________________
+TString AliMuonTrackCuts::GuessPass ( const AliInputEventHandler* eventHandler )
+{
+ /// If pass not defined guess it from event handler
- Int_t passNumber = fPassNumber;
- if ( fPassNumber < 0 && ! fAllowDefaultParams ) {
- // Pass number not set by user: try to guess it from data
- passNumber = AliAnalysisMuonUtility::GetPassNumber(eventHandler);
- AliInfo(Form("Guessing pass number from path: pass%i", passNumber));
+ TString passName = fPassName;
+ if ( passName.IsNull() ) {
+ // Pass number not set by user
+ // First try to get it from data
+ // AliProdInfo prodInfo(eventHandler->GetUserInfo());
+ // if ( prodInfo.GetRecoPass() >= 0 ) {
+ // passNumber = prodInfo.GetRecoPass();
+ // AliInfo(Form("Getting pass number from prodInfo: pass%i", passNumber));
+ // }
+ // else {
+ // If not found, try to guess it from data path
+ passName = AliAnalysisMuonUtility::GetPassName(eventHandler);
+ AliInfo(Form("Guessing pass name from path: %s", passName.Data()));
+ // }
}
- return ReadParamFromOADB ( runNumber, passNumber );
+ return passName;
+}
+
+//________________________________________________________________________
+Bool_t AliMuonTrackCuts::SetRun ( const AliInputEventHandler* eventHandler )
+{
+ /// Get parameters from OADB for current run
+
+ if ( fUseCustomParam ) return kFALSE;
+ Int_t runNumber = eventHandler->GetEvent()->GetRunNumber();
+ TString passName = GuessPass(eventHandler);
+ return ReadParamFromOADB ( runNumber, passName );
}
//________________________________________________________________________
-Bool_t AliMuonTrackCuts::ReadParamFromOADB ( Int_t runNumber, Int_t passNumber )
+Bool_t AliMuonTrackCuts::ReadParamFromOADB ( Int_t runNumber, TString passName )
{
/// Read parameters from OADB
- if ( passNumber < 0 && ! fAllowDefaultParams ) AliFatal("Pass number not specified!");
+ if ( passName.IsNull() && ! fAllowDefaultParams ) AliFatal("Pass name not specified! Please provide one or allow for default parameters");
TString filename = Form("%s/PWG/MUON/MuonTrackCuts.root",AliAnalysisManager::GetOADBPath());
if ( fIsMC ) filename.ReplaceAll(".root", "_MC.root");
}
// Search the container name to find the correct pass
- AliOADBContainer* oadbContainer = 0x0;
- AliOADBMuonTrackCutsParam* runMatchParams = 0x0, *lastMatchParams = 0x0, *lastDefaultParams = 0x0;
+ AliOADBContainer* matchContainer = 0x0, *defaultContainer = 0x0;
+ AliOADBMuonTrackCutsParam* matchParams = 0x0, *defaultParams = 0x0;
- Int_t lastDefaultPass = -999, lastMatchPass = -999, foundPass = -999;
TList* listOfKeys = file->GetListOfKeys();
TIter next(listOfKeys);
TObject* key = 0x0;
// loop on keys
while ( ( key = next() ) ) {
- Int_t currPass = AliAnalysisMuonUtility::GetPassNumber(key->GetName());
- // if user selects a specific pass number, check for it
- if ( fPassNumber >= 0 && currPass != fPassNumber ) continue;
-
- oadbContainer = static_cast<AliOADBContainer*> (file->Get(key->GetName()));
+
+ TString checkName(key->GetName());
+ checkName.ToUpper();
+ Bool_t isDefault = checkName.Contains("DEFAULT");
+ // if user selects a specific pass name, check for it
+ // otherwise use default
+ if ( isDefault ) {
+ if ( ! fAllowDefaultParams ) continue;
+ }
+ else if ( passName.CompareTo(key->GetName()) ) continue;
+
+ AliOADBContainer* oadbContainer = static_cast<AliOADBContainer*> (file->Get(key->GetName()));
// Check if the found parameters are default or match the requested run
AliOADBMuonTrackCutsParam* currParams = static_cast<AliOADBMuonTrackCutsParam*> (oadbContainer->GetObject(runNumber, "default"));
- if ( oadbContainer->GetDefaultObject(currParams->GetName()) ) {
- if ( currPass > lastDefaultPass ) {
- lastDefaultPass = currPass;
- lastDefaultParams = currParams;
- }
+ if ( ! currParams ) continue;
+ if ( isDefault ) {
+ defaultContainer = oadbContainer;
+ defaultParams = currParams;
}
else {
- if ( currPass == passNumber ) {
- foundPass = currPass;
- runMatchParams = currParams;
- break;
- }
- else if ( currPass > lastMatchPass ) {
- lastMatchPass = currPass;
- lastMatchParams = currParams;
- }
+ matchContainer = oadbContainer;
+ matchParams = currParams;
+ break;
}
} // loop on keys
-
- if ( ! oadbContainer ) {
- file->Close();
- AliFatal(Form("Requested pass%i not found!", passNumber));
- return kFALSE; // Not needed, but Coverity could complain
+
+ AliOADBContainer* selectedContainer = 0x0;
+ if ( matchParams ) {
+ selectedContainer = matchContainer;
+ fOADBParam = *matchParams;
}
-
- if ( runMatchParams ) fOADBParam = *runMatchParams;
- else if ( fAllowDefaultParams ) {
- AliOADBMuonTrackCutsParam* currParams = ( lastMatchParams ) ? lastMatchParams : lastDefaultParams;
- if ( ! currParams ) { // This case should be impossible, but Coverity complains
- AliFatal("No parameter found");
- return kFALSE;
- }
- foundPass = ( lastMatchParams ) ? lastMatchPass : lastDefaultPass;
- fOADBParam = *currParams;
- AliWarning(Form("Requested run %i not found in pass%i: using %s (pass%i)", runNumber, passNumber, fOADBParam.GetName(),foundPass));
+ else if ( defaultParams ) {
+ selectedContainer = defaultContainer;
+ fOADBParam = *defaultParams;
+ AliWarning(Form("Requested run %i not found in %s: using %s (%s)", runNumber, passName.Data(), fOADBParam.GetName(), selectedContainer->GetName()));
}
- else AliFatal(Form("Requested run %i not found in pass%i!", runNumber, passNumber));
+ else AliFatal(Form("Requested run %i not found in %s! Please check your pass name or allow default parameters", runNumber, passName.Data()));
file->Close();
- AliInfo(Form("Requested run %i pass%i. Param. set: %s (pass%i)", runNumber, passNumber, fOADBParam.GetName(), foundPass));
+ AliInfo(Form("Requested run %i in pass %s. Param. set: %s (%s)", runNumber, passName.Data(), fOADBParam.GetName(), selectedContainer->GetName()));
return kTRUE;
}
#ifndef ALIMUONTRACKCUTS_H
#define ALIMUONTRACKCUTS_H
+#include "TString.h"
#include "AliAnalysisCuts.h"
#include "AliOADBMuonTrackCutsParam.h"
virtual Bool_t IsSelected ( TList* /*list */ );
void SetDefaultFilterMask();
- void SetPassNumber ( Int_t passNumber ) { fPassNumber = passNumber; }
+ void SetPassNumber ( Int_t passNumber );
+ /// Set pass name
+ void SetPassName ( TString passName ) { fPassName = passName; }
+ /// Set is MC
void SetIsMC ( Bool_t isMC = kTRUE ) { fIsMC = isMC; }
- void SetAllowDefaultParams ( Bool_t allowDefaultParams = kTRUE, Int_t passNumber = -1 ) { fAllowDefaultParams = allowDefaultParams; fPassNumber = passNumber; }
- void SetCustomParamFromRun ( Int_t runNumber = -1, Int_t passNumber = -1 );
+ /// Allow default parameters
+ void SetAllowDefaultParams ( Bool_t allowDefaultParams = kTRUE ) { fAllowDefaultParams = allowDefaultParams; }
+ void SetCustomParamFromRun ( Int_t runNumber = -1, TString passName = "" );
+ void SetCustomParam ( const AliInputEventHandler* eventHandler );
- /// Get pass number
- Int_t GetPassNumber () const { return fPassNumber; }
+ /// Get pass name
+ TString GetPassName () const { return fPassName; }
Bool_t SetRun ( const AliInputEventHandler* eventHandler );
private:
- Bool_t ReadParamFromOADB ( Int_t runNumber, Int_t passNumber );
+ TString GuessPass ( const AliInputEventHandler* eventHandler );
+ Bool_t ReadParamFromOADB ( Int_t runNumber, TString passName );
Bool_t fIsMC; ///< Monte Carlo analysis
Bool_t fUseCustomParam; ///< Use custom parameters (do not search in OADB)
Bool_t fSharpPtCut; ///< Flag to apply sharp pt cut in track-trigger matching
Bool_t fAllowDefaultParams; ///< Flag to allow default parameters from OADB
- Int_t fPassNumber; ///< Pass number
+ TString fPassName; ///< Pass name
AliOADBMuonTrackCutsParam fOADBParam; ///< Track param in OADB
- ClassDef(AliMuonTrackCuts, 4); // Class for muon track filters
+ ClassDef(AliMuonTrackCuts, 5); // Class for muon track filters
};
#endif