Skip to content
Snippets Groups Projects
Commit ccbfa865 authored by Corentin Allaire's avatar Corentin Allaire
Browse files

Added conversion from athena MaterialStep to Acts MaterialTrack.

parent fe7e4ccd
No related branches found
No related tags found
6 merge requests!58791DataQualityConfigurations: Modify L1Calo config for web display,!46784MuonCondInterface: Enable thread-safety checking.,!46776Updated LArMonitoring config file for WD to match new files produced using MT,!45405updated ART test cron job,!42417Draft: DIRE and VINCIA Base Fragments for Pythia 8.3,!33280Acts mat map
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
//////////////////////////////////////////////////////////////////
// MaterialMapping.h, (c) ATLAS Detector software
///////////////////////////////////////////////////////////////////
#ifndef MATERIALSTEPTOACTSMATRERIALTRACK_H
#define MATERIALSTEPTOACTSMATRERIALTRACK_H
// Athena & Gaudi includes
#include "AthenaBaseComps/AthAlgorithm.h"
#include "GaudiKernel/ToolHandle.h"
#include "GaudiKernel/ServiceHandle.h"
#include "TString.h"
#include <fstream>
#include <iostream>
#include <string>
#include <map>
#include "GeoPrimitives/GeoPrimitives.h"
#include "StoreGate/ReadHandleKey.h"
#include "TrkGeometry/MaterialStepCollection.h"
#ifdef TRKDETDESCR_MEMUSAGE
#include "TrkDetDescrUtils/MemoryLogger.h"
#endif
class TTree;
class ITHistSvc;
/** @class MaterialStepToActsMaterialTrack
A simple algorithm that throws random points through detector and associates them with
the given/found layer.
@author Andreas.Salzburger@cern.ch
*/
class MaterialStepToActsMaterialTrack : public AthAlgorithm {
public:
/** Standard Athena-Algorithm Constructor */
MaterialStepToActsMaterialTrack(const std::string& name, ISvcLocator* pSvcLocator);
/** Default Destructor */
~MaterialStepToActsMaterialTrack();
/** standard Athena-Algorithm method */
StatusCode initialize();
/** standard Athena-Algorithm method */
StatusCode execute();
/** standard Athena-Algorithm method */
StatusCode finalize();
private:
TTree* m_outputTree;
float m_v_x; ///< start global x
float m_v_y; ///< start global y
float m_v_z; ///< start global z
float m_v_px; ///< start global momentum x
float m_v_py; ///< start global momentum y
float m_v_pz; ///< start global momentum z
float m_v_phi; ///< start phi direction
float m_v_eta; ///< start eta direction
float m_tX0; ///< thickness in X0/L0
float m_tL0; ///< thickness in X0/L0
std::vector<float> m_step_x; ///< step x position
std::vector<float> m_step_y; ///< step y position
std::vector<float> m_step_z; ///< step z position
std::vector<float> m_step_length; ///< step length
std::vector<float> m_step_X0; ///< step material x0
std::vector<float> m_step_L0; ///< step material l0
std::vector<float> m_step_A; ///< step material A
std::vector<float> m_step_Z; ///< step material Z
std::vector<float> m_step_rho; ///< step material rho
/** output / input steering */
SG::ReadHandleKey<Trk::MaterialStepCollection> m_inputMaterialStepCollection;
std::string m_ActsFileName;
std::string m_ActsDirName;
std::string m_ActsTreeName;
ITHistSvc * m_thistSvc;
};
#endif
......@@ -64,6 +64,7 @@ atlas_add_component( ActsGeometry
src/ActsTrackingGeometryTool.cxx
src/ActsPropStepRootWriterSvc.cxx
src/ActsCaloTrackingVolumeBuilder.cxx
src/MaterialStepToActsMaterialTrack.cxx
src/components/*.cxx
PUBLIC_HEADERS ActsGeometry
INCLUDE_DIRS ${CLHEP_INCLUDE_DIRS} ${EIGEN_INCLUDE_DIRS} ${BOOST_INCLUDE_DIRS}
......
# This job options creates database files of Geantino/MaterialMapping.
# Mofifled version of Tracking/TrkDetDescr/TrkDetDescrExample/share/MaterialMapping_jobOptions.py. (TrkDetDescrExample-01-00-04)
# See https://twiki.cern.ch/twiki/bin/view/Atlas/UpgradeSimulationInnerTrackerMigrationRel20p3p3#Creation_of_database_files
# necessity to create a new PoolFileCatalog
import os
if os.path.exists('./PoolFileCatalog.xml') :
print '[!] PoolFileCatalog exists in the run directory (may use old PFN!)'
print '[>] Deleting it now !'
os.remove('./PoolFileCatalog.xml')
###############################################################
#
# Job options
#
#==============================================================
#--------------------------------------------------------------
# ATLAS default Application Configuration options
#--------------------------------------------------------------
# Use McEventSelector so we can run with AthenaMP
import AthenaCommon.AtlasUnixStandardJob
#--------------------------------------------------------------
# Private Application Configuration options
#--------------------------------------------------------------
# Full job is a list of algorithms
from AthenaCommon.AlgSequence import AlgSequence
job = AlgSequence()
from AthenaCommon.AppMgr import ServiceMgr as svcMgr
from GaudiSvc.GaudiSvcConf import THistSvc
svcMgr += THistSvc()
svcMgr.THistSvc.Output += ["Acts DATAFILE='material-tracks.root' OPT='RECREATE'" ]
import glob
FileList = glob.glob("MaterialStepCollection*.root*")
import AthenaPoolCnvSvc.ReadAthenaPool
ServiceMgr.EventSelector.InputCollections = FileList
if not hasattr(svcMgr, theApp.EventLoop):
svcMgr += getattr(CfgMgr, theApp.EventLoop)()
evtloop = getattr(svcMgr, theApp.EventLoop)
try:
evtloop.EventPrintoutInterval = 1000
except Exception, err:
msg.info('failed suppressing event loop heartbeat. performances might be sub-par... sorry.')
pass
print "FileList = ", FileList
# Number of events to be processed
theApp.EvtMax = -1
# set up the Material Mapping
from ActsGeometry.ActsGeometryConf import MaterialStepToActsMaterialTrack
alg = MaterialStepToActsMaterialTrack(name ='MaterialStepToActsMaterialTrack')
job += alg
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
///////////////////////////////////////////////////////////////////
// MaterialMapping.cxx, (c) ATLAS Detector software
//////////////////////////////////////////////////////////////////
// Gaudi Units
#include "GaudiKernel/SystemOfUnits.h"
#include "GaudiKernel/ITHistSvc.h"
#include "ActsGeometry//MaterialStepToActsMaterialTrack.h"
#include "TrkGeometry/MaterialStep.h"
#include "TrkGeometry/MaterialStepCollection.h"
#include "TrkGeometry/MaterialProperties.h"
// TrkEvent
#include "TrkNeutralParameters/NeutralParameters.h"
// Amg
#include "GeoPrimitives/GeoPrimitivesToStringConverter.h"
#include "TTree.h"
MaterialStepToActsMaterialTrack::MaterialStepToActsMaterialTrack(const std::string& name, ISvcLocator* pSvcLocator)
: AthAlgorithm(name,pSvcLocator),
m_ActsFileName("material-tracks"),
m_ActsDirName("tracks"),
m_ActsTreeName("mat-tracks"),
m_inputMaterialStepCollection("MaterialStepRecords"),
m_thistSvc(0)
{
declareProperty("ActsMaterialTrackFileName", m_ActsFileName);
}
MaterialStepToActsMaterialTrack::~MaterialStepToActsMaterialTrack()
{}
StatusCode MaterialStepToActsMaterialTrack::initialize()
{
ATH_MSG_INFO("initialize()");
ATH_CHECK( m_inputMaterialStepCollection.initialize() );
ATH_CHECK( service("THistSvc", m_thistSvc) );
m_outputTree = new TTree( TString(m_ActsTreeName), "ACTS" );
std::string fullName = "/Acts/"+m_ActsTreeName;
ATH_CHECK( m_thistSvc->regTree(fullName, m_outputTree) );
/** now add branches and leaves to the tree */
// event tree : one entry per event
m_outputTree->Branch("v_x", &m_v_x);
m_outputTree->Branch("v_y", &m_v_y);
m_outputTree->Branch("v_z", &m_v_z);
m_outputTree->Branch("v_px", &m_v_px);
m_outputTree->Branch("v_py", &m_v_py);
m_outputTree->Branch("v_pz", &m_v_pz);
m_outputTree->Branch("v_phi", &m_v_phi);
m_outputTree->Branch("v_eta", &m_v_eta);
m_outputTree->Branch("t_X0", &m_tX0);
m_outputTree->Branch("t_L0", &m_tL0);
m_outputTree->Branch("mat_x", &m_step_x);
m_outputTree->Branch("mat_y", &m_step_y);
m_outputTree->Branch("mat_z", &m_step_z);
m_outputTree->Branch("mat_step_length", &m_step_length);
m_outputTree->Branch("mat_X0", &m_step_X0);
m_outputTree->Branch("mat_L0", &m_step_L0);
m_outputTree->Branch("mat_A", &m_step_A);
m_outputTree->Branch("mat_Z", &m_step_Z);
m_outputTree->Branch("mat_rho", &m_step_rho);
return StatusCode::SUCCESS;
}
StatusCode MaterialStepToActsMaterialTrack::execute()
{
ATH_MSG_VERBOSE("MaterialMapping execute() start");
SG::ReadHandle<Trk::MaterialStepCollection> materialStepCollection(m_inputMaterialStepCollection);
m_v_x = 0;
m_v_y = 0;
m_v_z = 0;
m_v_px = 0;
m_v_py = 0;
m_v_pz = 0;
m_v_phi = 0;
m_v_eta = 0;
m_tX0 = 0;
m_tL0 = 0;
m_step_x.clear();
m_step_y.clear();
m_step_z.clear();
m_step_length.clear();
m_step_X0.clear();
m_step_L0.clear();
m_step_A.clear();
m_step_Z.clear();
m_step_rho.clear();
// clearing the recorded layers per event
if (materialStepCollection.isValid() && materialStepCollection->size()){
// get the number of material steps
size_t materialSteps = materialStepCollection->size();
ATH_MSG_DEBUG("[+] Successfully read "<< materialSteps << " geantino steps");
// create a direction out of the last material step
m_v_px = (*materialStepCollection)[materialSteps-1]->hitX();
m_v_py = (*materialStepCollection)[materialSteps-1]->hitY();
m_v_pz = (*materialStepCollection)[materialSteps-1]->hitZ();
Amg::Vector3D direction = Amg::Vector3D(m_v_px,m_v_py,m_v_pz).unit();
m_v_px = direction.x();
m_v_py = direction.y();
m_v_pz = direction.z();
m_v_eta = direction.eta();
m_v_phi = direction.phi();
for ( const Trk::MaterialStep* step : *materialStepCollection ) {
m_step_x.push_back(step->hitX());
m_step_y.push_back(step->hitY());
m_step_z.push_back(step->hitZ());
m_step_length.push_back(step->steplength());
m_step_X0.push_back(step->x0());
m_step_L0.push_back(step->l0());
m_step_A.push_back(step->A());
m_step_Z.push_back(step->Z());
m_step_rho.push_back(step->rho());
m_tX0 +=step->steplength()/step->x0();
m_tL0 +=step->steplength()/step->l0();
}
m_outputTree->Fill();
}
return StatusCode::SUCCESS;
}
StatusCode MaterialStepToActsMaterialTrack::finalize()
{
std::cout << "Fin" << std::endl;
return StatusCode::SUCCESS;
}
......@@ -24,6 +24,7 @@
#include "ActsGeometry/ActsMaterialStepConverterTool.h"
// #include "ActsGeometry/ActsMaterialJsonWriterTool.h"
#include "ActsGeometry/MaterialStepToActsMaterialTrack.h"
DECLARE_COMPONENT( ActsExtrapolationAlg )
DECLARE_COMPONENT( ActsWriteTrackingGeometry )
......@@ -46,3 +47,5 @@ DECLARE_COMPONENT( ActsTrackingGeometryTool )
DECLARE_COMPONENT( ActsPropStepRootWriterSvc )
DECLARE_COMPONENT( ActsAlignmentCondAlg )
DECLARE_COMPONENT( ActsCaloTrackingVolumeBuilder )
DECLARE_COMPONENT( MaterialStepToActsMaterialTrack )
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment