14#include "CLHEP/Random/RandGauss.h"
15#include "CLHEP/Random/RandomEngine.h"
27 const std::string&
type,
const std::string& name,
const IInterface* parent) :
48 m_output_file = std::make_unique<TFile>(
"HGTD_SmearedDigiOutput.root",
"RECREATE");
49 m_tree = std::make_unique<TTree>(
"SmearedDigiTree",
"SmearedDigiTree");
71 return StatusCode::SUCCESS;
85 return StatusCode::SUCCESS;
90 ATH_MSG_DEBUG(
"[HGTD_SmearedDigitizationTool::processAllSubEvents]");
92 auto cluster_container =
95 cluster_container->cleanup();
102 timed_hit_collection,
103 det_element_rio_map));
107 *cluster_container));
109 return StatusCode::SUCCESS;
122 return StatusCode::SUCCESS;
134 TimedHitCollList_t hit_coll_list;
135 unsigned int num_si_hits(0);
140 hit_coll_list.empty()) {
142 return timed_hit_coll;
145 ATH_MSG_DEBUG(hit_coll_list.size() <<
" SiHitCollections with key "
148 timed_hit_coll.
reserve(num_si_hits);
151 for(
auto hit_coll : hit_coll_list) {
153 timed_hit_coll.
insert(hit_coll.first, si_collection);
157 return timed_hit_coll;
165 ATH_MSG_DEBUG(
"--- HGTD_SmearedDigitizationTool: in digitize() ---");
169 rngWrapper->
setSeed(name(), ctx);
170 CLHEP::HepRandomEngine* rndmEngine = rngWrapper->
getEngine(ctx);
185 int endcap = hit->getBarrelEndcap();
186 int layer = hit->getLayerDisk();
187 int phi_module = hit->getPhiModule();
188 int eta_module = hit->getEtaModule();
191 << endcap <<
", layer_disk " << layer <<
", phi_module "
192 << phi_module <<
", eta_module " << eta_module);
198 if (!curr_det_element) {
199 ATH_MSG_ERROR(
"could not get detector element for SolidStateDetector");
206 HepGeom::Point3D<double> hit_loc_start_pos = hit->localStartPosition();
207 HepGeom::Point3D<double> hit_loc_end_pos = hit->localEndPosition();
209 HepGeom::Point3D<double> hit_glob_start_pos =
211 HepGeom::Point3D<double> hit_glob_end_pos =
214 double globa_entry_x = hit_glob_start_pos.x();
215 double globa_entry_y = hit_glob_start_pos.y();
220 double globa_exit_x = hit_glob_end_pos.x();
221 double globa_exit_y = hit_glob_end_pos.y();
226 double dist_x = std::abs(std::abs(globa_exit_x) - std::abs(globa_entry_x));
227 double dist_y = std::abs(std::abs(globa_exit_y) - std::abs(globa_entry_y));
243 << entry_id <<
" --- exitId " << exit_id);
244 ATH_MSG_DEBUG(
"--- HGTD_SmearedDigitizationTool: entryCellId "
245 << entry_cell_id <<
" --- exitCellId " << exit_cell_id);
252 double intersection_x = 0.5 * (globa_entry_x + globa_exit_x);
253 double intersection_y = 0.5 * (globa_entry_y + globa_exit_y);
258 double times_x = floor(dist_x /
m_pitch_x);
259 double times_y = floor(dist_y /
m_pitch_y);
261 double sigma_x =
m_pitch_x / std::sqrt(12);
262 double sigma_y =
m_pitch_y / std::sqrt(12);
264 int element_x = times_x + 1;
265 int element_y = times_y + 1;
271 curr_det_element->
width() / 2.,
274 curr_det_element->
length() / 2.,
286 std::vector<Identifier> rdo_list = {intersection_id};
291 if (!current_cell_id.
isValid()) {
302 covariance.setIdentity();
307 float hit_time = hit->meanTime();
314 std::vector<int> tot_vec = {0};
317 si_width, curr_det_element, std::move(cluster_err),
330 det_element_rio_map.insert(
331 std::pair<IdentifierHash, const Cluster_t*>(wafer_id, cluster));
336 return StatusCode::SUCCESS;
340 float boundary, CLHEP::HepRandomEngine * rndmEngine) {
341 ATH_MSG_DEBUG(
"[HGTD_SmearedDigitizationTool::smearPosition] pos: "
342 << pos <<
" sig: " << sig <<
" boundary: " << boundary);
343 float smeared_pos = pos;
344 float smear_para = 0.;
347 smear_para = CLHEP::RandGauss::shoot(rndmEngine, 0., sig);
349 }
while (std::abs(smeared_pos + smear_para) > boundary);
350 smeared_pos += smear_para;
356 return time + CLHEP::RandGauss::shoot(rndmEngine, 0., time_res);
364 << *cluster <<
" and link = " << trk_link);
368 map->insert(std::make_pair(cluster->
identify(), trk_link));
372 return StatusCode::SUCCESS;
378 "--- HGTD_SmearedDigitizationTool: in fillClusterContainer() ---");
381 RIO_map_t::iterator i = det_element_rio_map.begin();
382 RIO_map_t::iterator e = det_element_rio_map.end();
384 for (; i != e; i = det_element_rio_map.upper_bound(i->first)) {
386 std::pair<RIO_map_t::iterator, RIO_map_t::iterator> range;
387 range = det_element_rio_map.equal_range(i->first);
389 RIO_map_t::iterator first_det_elem = range.first;
399 for (RIO_map_t::iterator iter = range.first; iter != range.second; ++iter) {
403 cluster_coll->
size());
409 ATH_MSG_WARNING(
"Could not add collection to Identifiable container!");
413 return StatusCode::SUCCESS;
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_WARNING(x)
#define AmgSymMatrix(dim)
AtlasHitsVector< SiHit > SiHitCollection
A wrapper class for event-slot-local random engines.
void setSeed(const std::string &algName, const EventContext &ctx)
Set the random seed using a string (e.g.
CLHEP::HepRandomEngine * getEngine(const EventContext &ctx) const
Retrieve the random engine corresponding to the provided EventContext.
value_type push_back(value_type pElem)
size_type size() const noexcept
virtual const Amg::Vector3D & globalPosition() const
a link optimized in size for a GenParticle in a McEventCollection
bool isValid() const
Validity check.
static HepMcParticleLink getRedirectedLink(const HepMcParticleLink &particleLink, uint32_t eventIndex, const EventContext &ctx)
Return a HepMcParticleLink pointing at the same particle, but in a different GenEvent.
virtual StatusCode addCollection(const T *coll, IdentifierHash hashId) override final
insert collection into container with id hash if IDC should not take ownership of collection,...
This is a "hash" representation of an Identifier.
Identifier for the strip or pixel cell.
bool isValid() const
Test if its in a valid state.
Class to hold geometrical description of a solid state detector element.
double length() const
Length in eta direction (z - barrel, r - endcap)
HepGeom::Point3D< double > hitLocalToLocal3D(const HepGeom::Point3D< double > &hitPosition) const
Same as previuos method but 3D.
double width() const
Methods from design (inline)
virtual SiCellId cellIdFromIdentifier(const Identifier &identifier) const =0
SiCellId from Identifier.
virtual Identifier identify() const override final
identifier of this detector element (inline)
Identifier identifierOfPosition(const Amg::Vector2D &localPos) const
Full identifier of the cell for a given position: assumes a raw local position (no Lorentz shift)
A PRD is mapped onto all contributing particles.
void reserve(unsigned int numberOfHits)
reserve a timed vector numberOfHits in size.
bool nextDetectorElement(const_iterator &b, const_iterator &e)
sets an iterator range with the hits of current detector element returns a bool when done
TimedVector::const_iterator const_iterator
void insert(const PileUpTimeEventIndex &timeEventIndex, const AtlasHitsVector< HIT > *inputCollection)
a smart pointer to a hit that also provides access to the extended timing info of the host event.
unsigned short eventId() const
the index of the component event in PileUpEventInfo.
virtual IdentifierHash identifyHash() const override final
void setIdentifier(Identifier id)
Identifier identify() const
return the identifier
void setHashAndIndex(unsigned short collHash, unsigned short objIndex)
TEMP for testing: might make some classes friends later ...
const Amg::MatrixX & localCovariance() const
return const ref to the error matrix
std::vector< std::string > intersection(std::vector< std::string > &v1, std::vector< std::string > &v2)
bool contains(const std::string &s, const std::string ®x)
does a string contain the substring
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic > MatrixX
Dynamic Matrix - dynamic allocation.
double error(const Amg::MatrixX &mat, int index)
return diagonal error of the matrix caller should ensure the matrix is symmetric and the index is in ...
Eigen::Matrix< double, 2, 1 > Vector2D
bool ignoreTruthLink(const T &p, bool vetoPileUp)
Helper function for SDO creation in PileUpTools.
std::list< value_t > type
type of the collection of timed data object