Commit 7a3cb16e authored by Jiří Mašík's avatar Jiří Mašík
Browse files

remove package. ATR-23835, ATR-22797

parent d84cb5f2
# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
# Declare the package name:
atlas_subdir( TrigInDetTruthAlgs )
# Component(s) in the package:
atlas_add_component( TrigInDetTruthAlgs
src/*.cxx
src/components/*.cxx
LINK_LIBRARIES AthenaBaseComps AtlasHepMCLib GenzModuleEvent InDetIdentifier InDetPrepRawData InDetSimData TrigInDetEvent TrigInDetToolInterfacesLib TrigInDetTruthEvent TrkTruthData )
# Install files from the package:
atlas_install_python_modules( python/*.py POST_BUILD_CMD ${ATLAS_FLAKE8} )
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
/**
@page TrigInDetTruthAlgs_page TrigInDetTruthAlgs
@author R.Goncalo
@section TrigInDetTruthAlgs_introduction_TrigInDetTruthAlgs Introduction
Finds GenParticles which match a TrigInDetTrack,
creates a TrigInDetTrackTruth for each track and
fills a TrigInDetTrackTruthMap with them.
@section TrigInDetTruthAlgs_overview_TrigInDetTruthAlgs Class Overview
The TrigInDetTruthAlgs package contains of following classes:
- TrigInDetTruthMaker
@section TrigInDetTruthAlgs_extras_TrigInDetTruthAlgs Extra Pages
*/
# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
from TrigInDetTruthAlgs.TrigInDetTruthAlgsConf import TrigInDetTrackTruthMaker
# configurable class
class TrigIDTruthMaker ( TrigInDetTrackTruthMaker ):
__slots__ = []
def __init__(self, name="TrigInDetTrackTruthMaker"):
super( TrigInDetTrackTruthMaker, self ).__init__( name )
def setDefaults(self, handle):
handle.TrigIDTrackTruthMapName = "TrigInDetTrackTruthMap"
handle.PixelSDO_MapName = "PixelSDO_Map"
handle.SCT_SDO_MapName = "SCT_SDO_Map"
handle.TRT_SDO_MapName = "TRT_SDO_Map"
handle.MinNrMatchingHits = 2
handle.TrigInDetTrackCollectionKeys= ["HLT",
"HLT_TrigIDSCAN_Jet",
"HLT_TrigIDSCAN_Tau",
"HLT_TrigIDSCAN_eGamma",
"HLT_TrigIDSCAN_Muon",
"HLT_TrigIDSCAN_muonIso",
"HLT_TrigIDSCAN_Bphysics",
"HLT_TrigIDSCAN_FullScan",
#"HLT_TrigIDSCAN_BeamSpot",
"HLT_TrigIDSCAN_Cosmics",
"HLT_TrigIDSCAN_eGamma_Brem",
"HLT_TrigIDSCAN_Tile",
"HLT_TrigSiTrack_eGamma",
"HLT_TrigSiTrack_Muon",
"HLT_TrigSiTrack_muonIso",
"HLT_TrigSiTrack_Tau",
"HLT_TrigSiTrack_Jet",
"HLT_TrigSiTrack_Bphysics",
"HLT_TrigSiTrack_FullScan",
#"HLT_TrigSiTrack_BeamSpot",
"HLT_TrigSiTrack_Tile",
"HLT_TrigSiTrack_Cosmics",
"HLT_TrigSiTrack_eGamma_robust",
"HLT_TrigSiTrack_Muon_robust",
"HLT_TrigSiTrack_muonIso_robust",
"HLT_TrigSiTrack_Tau_robust",
"HLT_TrigSiTrack_Jet_robust",
"HLT_TrigSiTrack_Bphysics_robust",
"HLT_TrigSiTrack_FullScan_robust",
"HLT_TrigSiTrack_Tile_robust",
"HLT_TrigL2SiTrackFinder_MuonA",
"HLT_TRTSegmentFinder",
"HLT_TRTxK"]
# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
# File: TrigAnalysisTestConfig/__init__.py
__version__ = '1.0.0'
__author__ = 'r.goncalo@rhul.ac.uk'
__all__ = [ 'TrigIDTruthMaker' ]
/*
Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
*/
/**************************************************************************
**
** File: TrigInDetTrackTruthMaker.h
**
** Description: - Finds GenParticles which match a TrigInDetTrack,
** creates a TrigInDetTrackTruth for each track and
** fills a TrigInDetTrackTruthMap with them.
**
** Author: R.Goncalo
**
** Created: Sat Jan 24 19:55:56 GMT 2006
** Modified:
**
**
**
**************************************************************************/
#ifndef TRIGINDETTRACK_TRUTH_MAKER_H
#define TRIGINDETTRACK_TRUTH_MAKER_H
// Base class
#include "AthenaBaseComps/AthAlgorithm.h"
// core stuff
// #include "GaudiKernel/MsgStream.h"
// tracking stuff
#include "TrigInDetEvent/TrigInDetTrackCollection.h"
#include "TrigInDetTruthEvent/TrigInDetTrackTruthMap.h"
class TrigIDHitStats;
// offline inner detector truth EDM
class DetailedTrackTruth;
class DetailedTrackTruthCollection;
class TruthTrajectory;
// detector geometry and helper classes
#include "InDetSimData/InDetSimDataCollection.h"
class SCT_ID;
class PixelID;
class TRT_ID;
// monte carlo edm
class KineHepMcmap;
class GenParticle;
/** @class TrigInDetTrackTruthMaker
* This is TrigInDetTrackTruthMaker */
class TrigInDetTrackTruthMaker : public AthAlgorithm
{
public:
TrigInDetTrackTruthMaker(const std::string &name, ISvcLocator *pSvcLocator); //!< Algorithm constructor
~TrigInDetTrackTruthMaker(); //!< Algorithm deconstructor
/** IAlgorithm virtual methods to implement */
StatusCode initialize(); //!< Initialisation
StatusCode execute(); //!< Execution
StatusCode finalize(); //!< Finalisation
private:
/** StoreGate key for truth map and flags to be set by properties */
std::string m_trackTruthMapKey;
unsigned int m_minNrMatchHits;
std::vector<std::string> m_TrigInDetTrackCollectionKeys;
/** SDO maps for */
std::string m_pixel_SDO_Map; //!< Pixel
std::string m_SCT_SDO_Map; //!< SCT
std::string m_TRT_SDO_Map; //!< TRT
/** Internal properties */
bool m_havePIXmap; //!< set for each event
bool m_haveSCTmap;
bool m_haveTRTmap;
/** Pointers to Identifier helper classes for */
const PixelID* m_PIXid; //!< Pixel detector data
const SCT_ID* m_SCTid; //!< SCT detector data
const TRT_ID* m_TRTid; //!< TRT detector data
/** Maps: std::map<Identifier,InDetSimData> */
const InDetSimDataCollection* m_id2SimDataMapPIX;
const InDetSimDataCollection* m_id2SimDataMapSCT;
const InDetSimDataCollection* m_id2SimDataMapTRT;
// to retrieve GenParticles from kine (G3 only): G3 not considered!
// const KineHepMcmap* m_KineHepMcmap;
/** Find all the GenParticles which contribute to this TrigInDetTrack */
bool TrackTruth(const TrigInDetTrack* p_trk, TrigInDetTrackTruth* p_truth) const;
/** Method to find GenParticles which contributed to a spacepoint;
* fills vector of GenParticles : specific to Space Points from SCT */
void SCTspTruth(const TrigSiSpacePoint* p_SP,std::vector<HepMcParticleLink>* p_GP) const;
/** Method to find GenParticles which contributed to a spacepoint;
* fills vector of GenParticles : specific to Space Points from SCT */
void PIXspTruth(const TrigSiSpacePoint* p_SP,std::vector<HepMcParticleLink>* p_GP) const;
/** Method to find GenParticles which contributed to a spacepoint;
* fills vector of GenParticles : specific to Space Points from SCT */
void TRTdcTruth(const InDet::TRT_DriftCircle* p_DC,std::vector<HepMcParticleLink>* p_GP) const;
/** Method to retrieve the <Identifier, InDetSimData> maps for Pixel,SCT,TRT;
* returns true if at least one map was found */
bool GetTruthMaps();
/** Add to map (hits_map) of <GenParticle,nr.of hits> all the GenParticles from vector (p_vec) which are not yet in the map; for those which are, increment numbers of hits */
void updatePLmap(std::vector<HepMcParticleLink>* p_vec,std::map<HepMcParticleLink, unsigned int>& hits_map) const;
/** Private helper method to update temporary vector of all the GenParticles which contributed to a cluster or drift circle InDetSimData */
void updatePLvector(std::vector<HepMcParticleLink>* p_GP, InDetSimDataCollection::const_iterator& simData) const;
};
#endif
/*
Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
*/
////////////////////////////////////////////////////////////////////////////////
// TrigL2SpacePointTruthTool tool
// -------------------------------
// ATLAS Collaboration
//
// 21.09.2011 Tool created
//
// Author: Dmitry Emeliyanov, RAL
// e-mail: D.Emeliyanov@rl.ac.uk
//
////////////////////////////////////////////////////////////////////////////////
#include <cmath>
#include <iostream>
#include "TrigInDetEvent/TrigSiSpacePoint.h"
#include "InDetPrepRawData/SCT_Cluster.h"
#include "InDetPrepRawData/PixelCluster.h"
// detector geometry and helper classes
#include "InDetIdentifier/SCT_ID.h"
#include "InDetIdentifier/PixelID.h"
// monte carlo edm
#include "GenzModuleEvent/KineHepMcmap.h"
#include "AtlasHepMC/GenParticle.h"
#include "TrigInDetToolInterfaces/ITrigL2SpacePointTruthTool.h"
#include "TrigL2SpacePointTruthTool.h"
TrigL2SpacePointTruthTool::TrigL2SpacePointTruthTool(const std::string& t,
const std::string& n,
const IInterface* p ): AthAlgTool(t,n,p)
{
declareInterface< ITrigL2SpacePointTruthTool >( this );
declareProperty("PixelSDO_MapName", m_pixel_SDO_Map = "PixelSDO_Map");
declareProperty("SCT_SDO_MapName", m_SCT_SDO_Map = "SCT_SDO_Map");
}
StatusCode TrigL2SpacePointTruthTool::initialize()
{
StatusCode sc = AlgTool::initialize();
ATH_MSG_INFO("In initialize...");
// Get SCT & pixel Identifier helpers
if (detStore()->retrieve(m_PIXid, "PixelID").isFailure()) {
ATH_MSG_FATAL("Could not get Pixel ID helper");
return StatusCode::FAILURE;
}
if (detStore()->retrieve(m_SCTid, "SCT_ID").isFailure()) {
ATH_MSG_FATAL("Could not get SCT ID helper");
return StatusCode::FAILURE;
}
// Get StoreGate service
//
ATH_MSG_INFO("TrigL2SpacePointTruthTool constructed ");
return sc;
}
StatusCode TrigL2SpacePointTruthTool::finalize()
{
StatusCode sc = AlgTool::finalize();
return sc;
}
TrigL2SpacePointTruthTool::~TrigL2SpacePointTruthTool()
{
}
void TrigL2SpacePointTruthTool::getBarCodes(std::vector<TrigSiSpacePoint*>& vsp, std::vector<int>& vBar) {
vBar.clear();
if(!GetTruthMaps()) {
for(std::vector<TrigSiSpacePoint*>::const_iterator it = vsp.begin();it!=vsp.end();++it) {
vBar.push_back(-1);
}
return;
}
for(std::vector<TrigSiSpacePoint*>::const_iterator it = vsp.begin();it!=vsp.end();++it) {
int nBestBarCode=-1;
TrigSiSpacePoint* pSP = (*it);
if(pSP->clusters().second==NULL) {
std::vector<HepMcParticleLink> vPL;
const Trk::PrepRawData* pPIXclus = pSP->clusters().first;
PIX_ClusterTruth(pPIXclus,vPL);
nBestBarCode = analyzeClusterMatchings(vPL);
}
else {
std::vector<HepMcParticleLink> vPL;
const Trk::PrepRawData* pSCTclus;
pSCTclus = pSP->clusters().first;
SCT_ClusterTruth(pSCTclus,vPL);
int uCode = analyzeClusterMatchings(vPL);
pSCTclus = pSP->clusters().second;
vPL.clear();
SCT_ClusterTruth(pSCTclus,vPL);
int vCode = analyzeClusterMatchings(vPL);
if(vCode!=uCode) {
nBestBarCode=-2;
}
else {
nBestBarCode=vCode;
}
}
pSP->barCode(nBestBarCode);
vBar.push_back(nBestBarCode);
}
}
void TrigL2SpacePointTruthTool::getBarCodes(std::vector<TrigSiSpacePointBase>& vsp, std::vector<int>& vBar) {
vBar.clear();
if(!GetTruthMaps()) {
for(std::vector<TrigSiSpacePointBase>::const_iterator it = vsp.begin();it!=vsp.end();++it) {
vBar.push_back(-1);
}
return;
}
for(TrigSiSpacePointBase& pSP : vsp) {
int nBestBarCode=-1;
if(pSP.offlineSpacePoint()->clusterList().second==NULL) {
std::vector<HepMcParticleLink> vPL;
const Trk::PrepRawData* pPIXclus = pSP.offlineSpacePoint()->clusterList().first;
PIX_ClusterTruth(pPIXclus,vPL);
nBestBarCode = analyzeClusterMatchings(vPL);
}
else {
std::vector<HepMcParticleLink> vPL;
const Trk::PrepRawData* pSCTclus;
pSCTclus = pSP.offlineSpacePoint()->clusterList().first;
SCT_ClusterTruth(pSCTclus,vPL);
int uCode = analyzeClusterMatchings(vPL);
pSCTclus = pSP.offlineSpacePoint()->clusterList().second;
vPL.clear();
SCT_ClusterTruth(pSCTclus,vPL);
int vCode = analyzeClusterMatchings(vPL);
if(vCode!=uCode) {
nBestBarCode=-2;
}
else {
nBestBarCode=vCode;
}
}
pSP.barCode(nBestBarCode);
vBar.push_back(nBestBarCode);
}
}
void TrigL2SpacePointTruthTool::SCT_ClusterTruth(const Trk::PrepRawData* pSCTclus,std::vector<HepMcParticleLink>& pl) {
if(pSCTclus==NULL) return;
ATH_MSG_DEBUG("SCTspTruth() : cluster-id: " << m_SCTid->print_to_string((*pSCTclus).identify()));
// get list of Raw Data Objects identifiers in cluster
const std::vector<Identifier> clusRDOids = pSCTclus->rdoList();
ATH_MSG_DEBUG("SCTspTruth() : cluster has " << clusRDOids.size() << " RDO identifiers");
std::vector<Identifier>::const_iterator rdoIter=clusRDOids.begin();
std::vector<Identifier>::const_iterator lastRDO=clusRDOids.end();
// loop over RDO identifiers and get collection of InDetSimData
for (int iRDO=0; rdoIter != lastRDO; ++rdoIter, ++iRDO) {
ATH_MSG_DEBUG("SCTspTruth() : Doing RDO nr " << iRDO);
// find InDetSimData object corresponding to this RDO from the
// SCT InDetSimDataCollection map; a InDetSimData is basically a
// vector of deposits (typedef of pair<HepMcParticleLink,float>)
// a InDetSimDataCollection is a map<Identifier,InDetSimData>
InDetSimDataCollection::const_iterator clusSimData = m_id2SimDataMapSCT->find(*rdoIter);
// check if the InDetSimData corresponding to the RDO was found
if (clusSimData == m_id2SimDataMapSCT->end()) {
ATH_MSG_DEBUG("SCTspTruth() : Cannot find simulation info for " << m_SCTid->print_to_string(*rdoIter));
continue;
} else {
// add all GenParticles which contributed to this cluster into vector
updatePLvector(pl,clusSimData);
}
}
}
void TrigL2SpacePointTruthTool::PIX_ClusterTruth(const Trk::PrepRawData* pPIXclus,std::vector<HepMcParticleLink>& pl) {
if (!pPIXclus) return;
ATH_MSG_DEBUG("PIXspTruth() : cluster-id: " << m_PIXid->print_to_string((*pPIXclus).identify()));
// get list of Raw Data Objects identifiers in cluster
const std::vector<Identifier> clusRDOids = pPIXclus->rdoList();
ATH_MSG_DEBUG("PIXspTruth() : cluster has " << clusRDOids.size() << " RDO identifiers");
std::vector<Identifier>::const_iterator rdoIter = clusRDOids.begin();
std::vector<Identifier>::const_iterator lastRDO = clusRDOids.end();
// loop over RDO identifiers and get collection of InDetSimData
for (int iRDO=0; rdoIter != lastRDO; ++rdoIter, ++iRDO) {
ATH_MSG_DEBUG("PIXspTruth() : Doing RDO nr " << iRDO);
if ( ! (*rdoIter).is_valid() ) {
ATH_MSG_WARNING("Invalid identifier from pixel SP->rdoList() !!");
continue;
} else {
ATH_MSG_DEBUG("Pixel identifier: " << m_PIXid->print_to_string(*rdoIter));
}
// find InDetSimData object corresponding to this RDO from the
// PIXel InDetSimDataCollection map; a InDetSimData is basically a
// vector of deposits (typedef of pair<HepMcParticleLink,float>)
// a InDetSimDataCollection is a map<Identifier,InDetSimData>
InDetSimDataCollection::const_iterator clusSimData = m_id2SimDataMapPIX->find(*rdoIter);
if (clusSimData == m_id2SimDataMapPIX->end()) {
// we didn't find the ID in the map - check if it is a ganged pixel
ATH_MSG_DEBUG("PIXspTruth() : Cannot find simulation info for "
<< m_PIXid->print_to_string(*rdoIter) <<" : looking for ganged pixel");
const unsigned int phi_index = m_PIXid->phi_index(*rdoIter);
unsigned int ganged_phi_index=0;
switch (phi_index) {
case 153: ganged_phi_index = 160; break;
case 155: ganged_phi_index = 161; break;
case 157: ganged_phi_index = 162; break;
case 159: ganged_phi_index = 163; break;
case 168: ganged_phi_index = 164; break;
case 170: ganged_phi_index = 165; break;
case 172: ganged_phi_index = 166; break;
case 174: ganged_phi_index = 167; break;
default: ganged_phi_index =0;
}
if ( ganged_phi_index != 0) {
// it is a ganged pixel : get the ID of the partner.
const Identifier new_rdoID = m_PIXid->pixel_id(m_PIXid->barrel_ec(*rdoIter),
m_PIXid->layer_disk(*rdoIter),
m_PIXid->phi_module(*rdoIter),
m_PIXid->eta_module(*rdoIter),
ganged_phi_index,
m_PIXid->eta_index(*rdoIter));
ATH_MSG_DEBUG("PIXspTruth() : ganged to pixel " << m_PIXid->print_to_string(new_rdoID));
clusSimData = m_id2SimDataMapPIX->find(new_rdoID);
}
if(clusSimData == m_id2SimDataMapPIX->end() ) {
// check again, in case ganged pixel is also not in map
ATH_MSG_DEBUG("SCTspTruth() : Cannot find simulation info for "
<< m_PIXid->print_to_string(*rdoIter));
continue;
}
}
// add all GenParticles which contributed to this cluster into vector
updatePLvector(pl,clusSimData);
}
}
int TrigL2SpacePointTruthTool::analyzeClusterMatchings(std::vector<HepMcParticleLink>& vPL) {
int bestCode=-1;
std::map<int,int> codeMap;
int nTotalParticles = vPL.size();
if(nTotalParticles==0)
return bestCode;
nTotalParticles=0;
for(std::vector<HepMcParticleLink>::iterator pIt = vPL.begin(); pIt!=vPL.end();++pIt) {
HepMcParticleLink partLink = (*pIt);
int barCode = partLink.barcode();
int eventIndex = partLink.eventIndex();
if(eventIndex!=0) continue;
nTotalParticles++;
std::map<int,int>::iterator it = codeMap.find(barCode);
if(it==codeMap.end()) {
codeMap.insert(std::pair<int,int>(barCode,1));
}
else {
(*it).second++;
}
}
if(nTotalParticles==0)
return bestCode;
int max=-1;
for(std::map<int,int>::iterator it=codeMap.begin();it!=codeMap.end();++it) {
if((*it).second>max) {
max=(*it).second;
bestCode=(*it).first;
}
}
float P = (1.0*max)/nTotalParticles;
if(P>0.5) return bestCode;
else return -1;
}
void TrigL2SpacePointTruthTool::updatePLvector(std::vector<HepMcParticleLink>& pl,
InDetSimDataCollection::const_iterator& simData)
{
// get the vector of deposits for each GenParticle from the InDetSimData
const std::vector< std::pair<HepMcParticleLink,float> >& simDeposits = ((*simData).second).getdeposits();
ATH_MSG_DEBUG("updatePLvector() : RDO has "
<< simDeposits.size() << " deposits");
// loop over the deposits and get info from HepMcParticleLinks
std::vector< std::pair<HepMcParticleLink,float> >::const_iterator depIter = simDeposits.begin();
std::vector< std::pair<HepMcParticleLink,float> >::const_iterator lastDep = simDeposits.end();
for (int iDep=0 ; depIter != lastDep; ++depIter, ++iDep) {
ATH_MSG_DEBUG("updatePLvector() : Doing deposit " << iDep);
// get the HepMcParticleLink from the Deposit particle link and check it's ok
HepMcParticleLink partLink = (*depIter).first;
ATH_MSG_DEBUG("updatePLvector() : Deposit " << iDep
<< ": kine " << partLink.barcode()
<< ", event index " << partLink.eventIndex()
<< ", energy deposit " << (*depIter).second);
if (partLink.isValid()) {
// add the GenParticle to vector if it's not there yet
std::vector<HepMcParticleLink>::iterator gpIter = pl.begin();
std::vector<HepMcParticleLink>::iterator lastGP = pl.end();
bool putGPinVec = true;
for (; gpIter != lastGP; ++gpIter) {
if (partLink == (*gpIter)) {
putGPinVec = false;
break;
}
}
if (putGPinVec) {
pl.push_back(partLink);
ATH_MSG_DEBUG("updatePLvector() : Added particle to vector: "
<< pl.size() << " matches so far");
}
}
}
return;