forked from alisw/AliRoot
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implementation of a virtual track selection
A virtual track selection, hiding differences in the handling of ESDs and AODs, is implemented. The core of is the set of classes AliVTrackSelection, AliAODTrackSelection and AliESDTrackSelection, ported from the EMCAL framework. The primary goal is to make the analysis framework transparent to ESD and AOD analysis. Users need to configure the track selection, either with track cuts inheriting from AliVCuts, or filter bits. Supported aree AliESDtrackCuts as well as all cuts coming from the correction framework. Selected tracks can be accessed by either of the methods IsTrackAccepted or GetAcceptedTracks. As the data type is know typically only at run time, a natural way to handle the track selection is by providing a factory class implementing the creation of the track cuts objets. A base class AliTrackSelectionFactory is provided, having an abstract function CreateTrackSelection. Users have to implement this function in their own class. The AliAnalysisTaskSE is adapted for this, providing pointers to both a track selection factory and a track selection object. Both pointers are not mandatory. Only in case they are set, a track selection is created in CreateOutput objects, matching to the data type used in the analysis. The function GetAcceptedTracks can be used by user analyses. In case track cuts are provided, this method will call the GetAcceptedTracks from AliVTrackSelection and return its result.
- Loading branch information
Showing
12 changed files
with
676 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
/************************************************************************** | ||
* Copyright(c) 1998-2015, 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. * | ||
**************************************************************************/ | ||
|
||
#include <TClonesArray.h> | ||
#include <TBits.h> | ||
#include <TObjArray.h> | ||
|
||
#include <AliAODEvent.h> | ||
#include <AliAODTrack.h> | ||
#include <AliAODTrackSelection.h> | ||
#include <AliESDtrack.h> | ||
#include <AliESDtrackCuts.h> | ||
|
||
/// \cond CLASSIMP | ||
ClassImp(AliAODTrackSelection) | ||
/// \endcond | ||
|
||
/** | ||
* Main constructor, initialises fields with 0 (or NULL). For ROOT I/O, not intended | ||
* to be used by the users. | ||
*/ | ||
AliAODTrackSelection::AliAODTrackSelection() : | ||
AliVTrackSelection(), | ||
fFilterBits(0) | ||
{ | ||
} | ||
|
||
/** | ||
* Main Constructor, initalising also track cuts and filter bits. In case the initial cuts | ||
* is a nullpointer, only filter bits are used for the track selection. This constructor is | ||
* intended to be used by the users. | ||
* | ||
* \param cuts Inital track cut object (of type AliESDtrackCuts, can be a nullpointer) | ||
* \param filterbits Filter bits required | ||
*/ | ||
AliAODTrackSelection::AliAODTrackSelection(AliVCuts* cuts, UInt_t filterbits): | ||
AliVTrackSelection(), | ||
fFilterBits(filterbits) | ||
{ | ||
AddTrackCuts(cuts); | ||
} | ||
|
||
/** | ||
* Function checks whether track is accepted under the given track selection cuts. | ||
* The function can handle AliAODTrack and AliPicoTrack, while for AliPico track an | ||
* AliAODTrack is expected to be the underlying structure. If it is not possible to | ||
* access an AOD track from the input track, the object will not be selected. Otherwise | ||
* first the status bits are checked (if requested), and if further track cuts (of type | ||
* AliESDtrackCuts) are provided, the track is converted to an ESD track for further checks. | ||
* | ||
* \param trk: Track to check | ||
* \return true if selected, false otherwise | ||
*/ | ||
bool AliAODTrackSelection::IsTrackAccepted(AliVTrack * const trk) | ||
{ | ||
AliAODTrack *aodt = dynamic_cast<AliAODTrack*>(trk); | ||
if(!aodt){ | ||
AliError("Failed getting AOD track"); | ||
return kFALSE; | ||
} | ||
|
||
fTrackBitmap.ResetAllBits(); | ||
Int_t cutcounter(0); | ||
if (fFilterBits) { | ||
if(aodt->TestFilterBit(fFilterBits)) fTrackBitmap.SetBitNumber(cutcounter); | ||
cutcounter++; | ||
} | ||
if (fListOfCuts) { | ||
for (TIter cutIter = TIter(fListOfCuts).Begin(); cutIter != TIter::End(); ++cutIter){ | ||
AliVCuts *trackCuts = static_cast<AliVCuts*>(*cutIter); | ||
if (trackCuts->IsA() == AliESDtrackCuts::Class()) { | ||
// If track cuts are AliESDtrackCuts, the track needs to be converted to an AliESDtrack before | ||
AliESDtrack copyTrack(aodt); | ||
if (trackCuts->IsSelected(©Track)) fTrackBitmap.SetBitNumber(cutcounter); | ||
} | ||
else{ | ||
if (trackCuts->IsSelected(aodt)) fTrackBitmap.SetBitNumber(cutcounter); | ||
} | ||
cutcounter++; | ||
} | ||
} | ||
|
||
if (fSelectionModeAny){ | ||
// In case of ANY one of the cuts need to be fulfilled (equivalent to one but set) | ||
return fTrackBitmap.CountBits() > 0 || cutcounter == 0; | ||
} | ||
else { | ||
// In case of ALL all of the cuts need to be fulfilled (equivalent to all bits set) | ||
return fTrackBitmap.CountBits() == cutcounter; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/** | ||
* \file AliAODTrackSelection.h | ||
* \brief Implement virtual track selection for AOD analysis | ||
* | ||
* \author Markus Fasel <[email protected]>, Lawrence Berkeley National Laboratory | ||
* \date Jul 24, 2015 | ||
*/ | ||
#ifndef ALIAODTRACKSELECTIONAOD_H_ | ||
#define ALIAODTRACKSELECTIONAOD_H_ | ||
/* Copyright(c) 1998-2015, ALICE Experiment at CERN, All rights reserved. * | ||
* See cxx source for full Copyright notice */ | ||
|
||
#include <AliVTrackSelection.h> | ||
|
||
class AliVCuts; | ||
class AliVTrack; | ||
|
||
/** | ||
* \class AliAODTrackSelection | ||
* \brief Implement virtual track selection for AOD analysis | ||
* | ||
* Implementation of track selection in case the analysis runs on AODs | ||
* For the moment it uses the AliESDtrackCuts and converts AOD tracks to | ||
* ESD tracks, which might change in the future when an AOD track selection | ||
* framework becomes available. | ||
*/ | ||
class AliAODTrackSelection: public AliVTrackSelection { | ||
public: | ||
AliAODTrackSelection(); | ||
AliAODTrackSelection(AliVCuts *cuts, UInt_t filterbits); | ||
virtual ~AliAODTrackSelection() {} | ||
|
||
virtual bool IsTrackAccepted(AliVTrack * const trk); | ||
|
||
/** | ||
* Add a new filter bit to the track selection. Multiple filter bits can be set | ||
* at the same time (via the bitwise or operator |). | ||
* | ||
* \param filterbits | ||
*/ | ||
void AddFilterBit(UInt_t filterbits) { fFilterBits |= filterbits; } | ||
|
||
private: | ||
UInt_t fFilterBits; ///< Track filter bits | ||
|
||
/// \cond CLASSIMP | ||
ClassDef(AliAODTrackSelection, 2); | ||
/// \endcond | ||
}; | ||
|
||
#endif /* ALIAODTRACKSELECTIONAOD_H_ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/************************************************************************** | ||
* Copyright(c) 1998-2015, 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. * | ||
**************************************************************************/ | ||
#include <AliESDTrackSelection.h> | ||
#include <TBits.h> | ||
#include <TClonesArray.h> | ||
#include <TObjArray.h> | ||
#include <memory> | ||
|
||
#include "AliESDEvent.h" | ||
#include "AliESDtrack.h" | ||
#include "AliESDtrackCuts.h" | ||
#include "AliLog.h" | ||
#include "AliVCuts.h" | ||
|
||
/// \cond CLASSIMP | ||
ClassImp(AliESDTrackSelection) | ||
/// \endcond | ||
|
||
/** | ||
* Default constructor | ||
*/ | ||
AliESDTrackSelection::AliESDTrackSelection(): | ||
AliVTrackSelection() | ||
{ | ||
} | ||
|
||
/** | ||
* Constructor with cuts | ||
*/ | ||
AliESDTrackSelection::AliESDTrackSelection(AliVCuts* cuts): | ||
AliVTrackSelection() | ||
{ | ||
this->AddTrackCuts(cuts); | ||
} | ||
|
||
/** | ||
* Check whether track is accepted. Iterates over all cuts assigned to the track selection. | ||
* | ||
* \param trk: Track to check | ||
* \return: true if selected, false otherwise | ||
*/ | ||
bool AliESDTrackSelection::IsTrackAccepted(AliVTrack* const trk) { | ||
if (!fListOfCuts) return kTRUE; | ||
AliESDtrack *esdt = dynamic_cast<AliESDtrack *>(trk); | ||
if(!esdt){ | ||
AliError("Failed getting ESD track"); | ||
return kFALSE; | ||
} | ||
fTrackBitmap.ResetAllBits(); | ||
Int_t cutcounter = 0; | ||
for (TIter cutIter = TIter(fListOfCuts).Begin(); cutIter != TIter::End(); ++cutIter){ | ||
if((static_cast<AliVCuts *>(*cutIter))->IsSelected(esdt)) fTrackBitmap.SetBitNumber(cutcounter); | ||
cutcounter++; | ||
} | ||
// In case of ANY at least one bit has to be set, while in case of ALL all bits have to be set | ||
if (fSelectionModeAny){ | ||
return fTrackBitmap.CountBits() > 0 || cutcounter == 0; | ||
} else { | ||
return fTrackBitmap.CountBits() == cutcounter; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/** | ||
* \file AliESDTrackSelection.h | ||
* \brief Declaration of class AliESDTrackSelection | ||
* | ||
* In this header file the class AliESDTrackSelection, which implements | ||
* the virtual track selection for ESD tracks, is declared | ||
* | ||
* \author Markus Fasel <[email protected]>, Lawrence Berkeley National Laboratory | ||
* \date Jul 24, 2015 | ||
*/ | ||
#ifndef ALIESDTASKTRACKSELECTION_H_ | ||
#define ALIESDTASKTRACKSELECTION_H_ | ||
/* Copyright(c) 1998-2015, ALICE Experiment at CERN, All rights reserved. * | ||
* See cxx source for full Copyright notice */ | ||
|
||
#include <AliVTrackSelection.h> | ||
|
||
class AliVCuts; | ||
class AliVTrack; | ||
|
||
/** | ||
* \class AliESDTrackSelection | ||
* \brief Implementation of virtual track selection for ESDs | ||
* | ||
* Implementation of the track selection for the analysis on ESDs using | ||
* AliESDtrackCuts as underlying structure | ||
*/ | ||
class AliESDTrackSelection: public AliVTrackSelection { | ||
public: | ||
AliESDTrackSelection(); | ||
AliESDTrackSelection(AliVCuts *cuts); | ||
virtual ~AliESDTrackSelection() {} | ||
|
||
virtual bool IsTrackAccepted(AliVTrack * const trk); | ||
|
||
/// \cond CLASSIMP | ||
ClassDef(AliESDTrackSelection,1); | ||
/// \endcond | ||
}; | ||
|
||
#endif /* ALIESDTRACKSELECTION_H_ */ |
Oops, something went wrong.