Loading src/objects/CMakeLists.txt +2 −0 Original line number Diff line number Diff line Loading @@ -29,6 +29,7 @@ ADD_LIBRARY( DepositedCharge.cpp PropagatedCharge.cpp PixelHit.cpp PixelPulse.cpp MCParticle.cpp MCTrack.cpp) Loading @@ -51,6 +52,7 @@ ROOT_GENERATE_DICTIONARY( ${CMAKE_CURRENT_SOURCE_DIR}/PropagatedCharge.hpp ${CMAKE_CURRENT_SOURCE_DIR}/PixelCharge.hpp ${CMAKE_CURRENT_SOURCE_DIR}/PixelHit.hpp ${CMAKE_CURRENT_SOURCE_DIR}/PixelPulse.hpp MODULE AllpixObjects LINKDEF Loading src/objects/Linkdef.h +4 −0 Original line number Diff line number Diff line Loading @@ -58,5 +58,9 @@ #pragma link C++ class allpix::Object::PointerWrapper < allpix::PixelHit> + ; #pragma link C++ class allpix::Object::BaseWrapper < allpix::PixelHit> + ; #pragma link C++ class allpix::PixelPulse + ; #pragma link C++ class allpix::Object::PointerWrapper < allpix::PixelPulse> + ; #pragma link C++ class allpix::Object::BaseWrapper < allpix::PixelPulse> + ; // Vector of Object for internal storage #pragma link C++ class std::vector < allpix::Object*> + ; src/objects/PixelCharge.hpp +1 −0 Original line number Diff line number Diff line Loading @@ -29,6 +29,7 @@ namespace allpix { */ class PixelCharge : public Object { friend class PixelHit; friend class PixelPulse; public: /** Loading src/objects/PixelPulse.cpp 0 → 100644 +127 −0 Original line number Diff line number Diff line /** * @file * @brief Implementation of object with pulse processed by pixel front-end * * @copyright Copyright (c) 2022 CERN and the Allpix Squared authors. * This software is distributed under the terms of the MIT License, copied verbatim in the file "LICENSE.md". * In applying this license, CERN does not waive the privileges and immunities granted to it by virtue of its status as an * Intergovernmental Organization or submit itself to any jurisdiction. * SPDX-License-Identifier: MIT */ #include "PixelPulse.hpp" #include <set> #include "DepositedCharge.hpp" #include "PropagatedCharge.hpp" #include "objects/exceptions.h" using namespace allpix; PixelPulse::PixelPulse(Pixel pixel, const Pulse& pulse, const PixelCharge* pixel_charge) : Pulse(pulse), pixel_(std::move(pixel)) { pixel_charge_ = PointerWrapper<PixelCharge>(pixel_charge); if(pixel_charge != nullptr) { // Set time reference: local_time_ = pixel_charge->getLocalTime(); global_time_ = pixel_charge->getGlobalTime(); // Get the unique set of MC particles std::set<const MCParticle*> unique_particles; for(const auto& mc_particle : pixel_charge->mc_particles_) { unique_particles.insert(mc_particle.get()); } // Store the MC particle references for(const auto& mc_particle : unique_particles) { mc_particles_.emplace_back(mc_particle); } } } const Pixel& PixelPulse::getPixel() const { return pixel_; } Pixel::Index PixelPulse::getIndex() const { return getPixel().getIndex(); } double PixelPulse::getGlobalTime() const { return global_time_; } double PixelPulse::getLocalTime() const { return local_time_; } /** * @throws MissingReferenceException If the pointed object is not in scope * * Object is stored as TRef and can only be accessed if pointed object is in scope */ const PixelCharge* PixelPulse::getPixelCharge() const { auto* pixel_charge = pixel_charge_.get(); if(pixel_charge == nullptr) { throw MissingReferenceException(typeid(*this), typeid(PixelCharge)); } return pixel_charge; } /** * @throws MissingReferenceException If the pointed object is not in scope * * MCParticles can only be fetched if the full history of objects are in scope and stored */ std::vector<const MCParticle*> PixelPulse::getMCParticles() const { std::vector<const MCParticle*> mc_particles; for(const auto& mc_particle : mc_particles_) { if(mc_particle.get() == nullptr) { throw MissingReferenceException(typeid(*this), typeid(MCParticle)); } mc_particles.emplace_back(mc_particle.get()); } // Return as a vector of mc particles return mc_particles; } /** * @throws MissingReferenceException If the pointed object is not in scope * * MCParticles can only be fetched if the full history of objects are in scope and stored */ std::vector<const MCParticle*> PixelPulse::getPrimaryMCParticles() const { std::vector<const MCParticle*> primary_particles; for(const auto& mc_particle : mc_particles_) { auto* particle = mc_particle.get(); if(particle == nullptr) { throw MissingReferenceException(typeid(*this), typeid(MCParticle)); } // Check for possible parents: if(particle->getParent() != nullptr) { continue; } primary_particles.emplace_back(particle); } // Return as a vector of mc particles return primary_particles; } void PixelPulse::print(std::ostream& out) const { out << "PixelPulse " << this->getIndex().X() << ", " << this->getIndex().Y() << ", " << this->size() << " bins of " << this->getBinning() << "ns"; } void PixelPulse::loadHistory() { pixel_charge_.get(); std::for_each(mc_particles_.begin(), mc_particles_.end(), [](auto& n) { n.get(); }); } void PixelPulse::petrifyHistory() { pixel_charge_.store(); std::for_each(mc_particles_.begin(), mc_particles_.end(), [](auto& n) { n.store(); }); } src/objects/PixelPulse.hpp 0 → 100644 +118 −0 Original line number Diff line number Diff line /** * @file * @brief Definition of object with pulse processed by pixel front-end * * @copyright Copyright (c) 2022 CERN and the Allpix Squared authors. * This software is distributed under the terms of the MIT License, copied verbatim in the file "LICENSE.md". * In applying this license, CERN does not waive the privileges and immunities granted to it by virtue of its status as an * Intergovernmental Organization or submit itself to any jurisdiction. * SPDX-License-Identifier: MIT */ #ifndef ALLPIX_PIXEL_PULSE_H #define ALLPIX_PIXEL_PULSE_H #include <Math/DisplacementVector2D.h> #include <TRef.h> #include "MCParticle.hpp" #include "Object.hpp" #include "PixelCharge.hpp" #include "Pulse.hpp" #include "Pixel.hpp" namespace allpix { /** * @ingroup Objects * @brief Pixel triggered in an event after digitization */ class PixelPulse : public Object, public Pulse { public: /** * @brief Construct a digitized pixel front-end pulse * @param pixel Object holding the information of the pixel * @param pulse Output pulse produced by the digitizer * @param pixel_charge Optional pointer to the related pixel charge */ PixelPulse(Pixel pixel, const Pulse& pulse, const PixelCharge* pixel_charge = nullptr); /** * @brief Get the pixel hit * @return Pixel indices in the grid */ const Pixel& getPixel() const; /** * @brief Shortcut to retrieve the pixel indices * @return Index of the pixel */ Pixel::Index getIndex() const; /** * @brief Get related pixel charge * @return Possible related pixel charge */ const PixelCharge* getPixelCharge() const; /** * @brief Get the Monte-Carlo particles resulting in this pixel hit * @return List of all related Monte-Carlo particles */ std::vector<const MCParticle*> getMCParticles() const; /** * @brief Get all primary Monte-Carlo particles resulting in this pixel hit. A particle is considered primary if it * has no parent particle set. * @return List of all related primary Monte-Carlo particles */ std::vector<const MCParticle*> getPrimaryMCParticles() const; /** * @brief Get time after start of event in global reference frame * @return Time from start event */ double getGlobalTime() const; /** * @brief Get local time in the sensor * @return Time with respect to local sensor */ double getLocalTime() const; /** * @brief Print an ASCII representation of PixelHit to the given stream * @param out Stream to print to */ void print(std::ostream& out) const override; /** * @brief ROOT class definition */ ClassDefOverride(PixelPulse, 1); // NOLINT /** * @brief Default constructor for ROOT I/O */ PixelPulse() = default; void loadHistory() override; void petrifyHistory() override; private: Pixel pixel_; double local_time_{}; double global_time_{}; PointerWrapper<PixelCharge> pixel_charge_; std::vector<PointerWrapper<MCParticle>> mc_particles_; }; /** * @brief Typedef for message carrying pixel pulses */ using PixelPulseMessage = Message<PixelPulse>; } // namespace allpix #endif /* ALLPIX_PIXEL_PULSE_H */ Loading
src/objects/CMakeLists.txt +2 −0 Original line number Diff line number Diff line Loading @@ -29,6 +29,7 @@ ADD_LIBRARY( DepositedCharge.cpp PropagatedCharge.cpp PixelHit.cpp PixelPulse.cpp MCParticle.cpp MCTrack.cpp) Loading @@ -51,6 +52,7 @@ ROOT_GENERATE_DICTIONARY( ${CMAKE_CURRENT_SOURCE_DIR}/PropagatedCharge.hpp ${CMAKE_CURRENT_SOURCE_DIR}/PixelCharge.hpp ${CMAKE_CURRENT_SOURCE_DIR}/PixelHit.hpp ${CMAKE_CURRENT_SOURCE_DIR}/PixelPulse.hpp MODULE AllpixObjects LINKDEF Loading
src/objects/Linkdef.h +4 −0 Original line number Diff line number Diff line Loading @@ -58,5 +58,9 @@ #pragma link C++ class allpix::Object::PointerWrapper < allpix::PixelHit> + ; #pragma link C++ class allpix::Object::BaseWrapper < allpix::PixelHit> + ; #pragma link C++ class allpix::PixelPulse + ; #pragma link C++ class allpix::Object::PointerWrapper < allpix::PixelPulse> + ; #pragma link C++ class allpix::Object::BaseWrapper < allpix::PixelPulse> + ; // Vector of Object for internal storage #pragma link C++ class std::vector < allpix::Object*> + ;
src/objects/PixelCharge.hpp +1 −0 Original line number Diff line number Diff line Loading @@ -29,6 +29,7 @@ namespace allpix { */ class PixelCharge : public Object { friend class PixelHit; friend class PixelPulse; public: /** Loading
src/objects/PixelPulse.cpp 0 → 100644 +127 −0 Original line number Diff line number Diff line /** * @file * @brief Implementation of object with pulse processed by pixel front-end * * @copyright Copyright (c) 2022 CERN and the Allpix Squared authors. * This software is distributed under the terms of the MIT License, copied verbatim in the file "LICENSE.md". * In applying this license, CERN does not waive the privileges and immunities granted to it by virtue of its status as an * Intergovernmental Organization or submit itself to any jurisdiction. * SPDX-License-Identifier: MIT */ #include "PixelPulse.hpp" #include <set> #include "DepositedCharge.hpp" #include "PropagatedCharge.hpp" #include "objects/exceptions.h" using namespace allpix; PixelPulse::PixelPulse(Pixel pixel, const Pulse& pulse, const PixelCharge* pixel_charge) : Pulse(pulse), pixel_(std::move(pixel)) { pixel_charge_ = PointerWrapper<PixelCharge>(pixel_charge); if(pixel_charge != nullptr) { // Set time reference: local_time_ = pixel_charge->getLocalTime(); global_time_ = pixel_charge->getGlobalTime(); // Get the unique set of MC particles std::set<const MCParticle*> unique_particles; for(const auto& mc_particle : pixel_charge->mc_particles_) { unique_particles.insert(mc_particle.get()); } // Store the MC particle references for(const auto& mc_particle : unique_particles) { mc_particles_.emplace_back(mc_particle); } } } const Pixel& PixelPulse::getPixel() const { return pixel_; } Pixel::Index PixelPulse::getIndex() const { return getPixel().getIndex(); } double PixelPulse::getGlobalTime() const { return global_time_; } double PixelPulse::getLocalTime() const { return local_time_; } /** * @throws MissingReferenceException If the pointed object is not in scope * * Object is stored as TRef and can only be accessed if pointed object is in scope */ const PixelCharge* PixelPulse::getPixelCharge() const { auto* pixel_charge = pixel_charge_.get(); if(pixel_charge == nullptr) { throw MissingReferenceException(typeid(*this), typeid(PixelCharge)); } return pixel_charge; } /** * @throws MissingReferenceException If the pointed object is not in scope * * MCParticles can only be fetched if the full history of objects are in scope and stored */ std::vector<const MCParticle*> PixelPulse::getMCParticles() const { std::vector<const MCParticle*> mc_particles; for(const auto& mc_particle : mc_particles_) { if(mc_particle.get() == nullptr) { throw MissingReferenceException(typeid(*this), typeid(MCParticle)); } mc_particles.emplace_back(mc_particle.get()); } // Return as a vector of mc particles return mc_particles; } /** * @throws MissingReferenceException If the pointed object is not in scope * * MCParticles can only be fetched if the full history of objects are in scope and stored */ std::vector<const MCParticle*> PixelPulse::getPrimaryMCParticles() const { std::vector<const MCParticle*> primary_particles; for(const auto& mc_particle : mc_particles_) { auto* particle = mc_particle.get(); if(particle == nullptr) { throw MissingReferenceException(typeid(*this), typeid(MCParticle)); } // Check for possible parents: if(particle->getParent() != nullptr) { continue; } primary_particles.emplace_back(particle); } // Return as a vector of mc particles return primary_particles; } void PixelPulse::print(std::ostream& out) const { out << "PixelPulse " << this->getIndex().X() << ", " << this->getIndex().Y() << ", " << this->size() << " bins of " << this->getBinning() << "ns"; } void PixelPulse::loadHistory() { pixel_charge_.get(); std::for_each(mc_particles_.begin(), mc_particles_.end(), [](auto& n) { n.get(); }); } void PixelPulse::petrifyHistory() { pixel_charge_.store(); std::for_each(mc_particles_.begin(), mc_particles_.end(), [](auto& n) { n.store(); }); }
src/objects/PixelPulse.hpp 0 → 100644 +118 −0 Original line number Diff line number Diff line /** * @file * @brief Definition of object with pulse processed by pixel front-end * * @copyright Copyright (c) 2022 CERN and the Allpix Squared authors. * This software is distributed under the terms of the MIT License, copied verbatim in the file "LICENSE.md". * In applying this license, CERN does not waive the privileges and immunities granted to it by virtue of its status as an * Intergovernmental Organization or submit itself to any jurisdiction. * SPDX-License-Identifier: MIT */ #ifndef ALLPIX_PIXEL_PULSE_H #define ALLPIX_PIXEL_PULSE_H #include <Math/DisplacementVector2D.h> #include <TRef.h> #include "MCParticle.hpp" #include "Object.hpp" #include "PixelCharge.hpp" #include "Pulse.hpp" #include "Pixel.hpp" namespace allpix { /** * @ingroup Objects * @brief Pixel triggered in an event after digitization */ class PixelPulse : public Object, public Pulse { public: /** * @brief Construct a digitized pixel front-end pulse * @param pixel Object holding the information of the pixel * @param pulse Output pulse produced by the digitizer * @param pixel_charge Optional pointer to the related pixel charge */ PixelPulse(Pixel pixel, const Pulse& pulse, const PixelCharge* pixel_charge = nullptr); /** * @brief Get the pixel hit * @return Pixel indices in the grid */ const Pixel& getPixel() const; /** * @brief Shortcut to retrieve the pixel indices * @return Index of the pixel */ Pixel::Index getIndex() const; /** * @brief Get related pixel charge * @return Possible related pixel charge */ const PixelCharge* getPixelCharge() const; /** * @brief Get the Monte-Carlo particles resulting in this pixel hit * @return List of all related Monte-Carlo particles */ std::vector<const MCParticle*> getMCParticles() const; /** * @brief Get all primary Monte-Carlo particles resulting in this pixel hit. A particle is considered primary if it * has no parent particle set. * @return List of all related primary Monte-Carlo particles */ std::vector<const MCParticle*> getPrimaryMCParticles() const; /** * @brief Get time after start of event in global reference frame * @return Time from start event */ double getGlobalTime() const; /** * @brief Get local time in the sensor * @return Time with respect to local sensor */ double getLocalTime() const; /** * @brief Print an ASCII representation of PixelHit to the given stream * @param out Stream to print to */ void print(std::ostream& out) const override; /** * @brief ROOT class definition */ ClassDefOverride(PixelPulse, 1); // NOLINT /** * @brief Default constructor for ROOT I/O */ PixelPulse() = default; void loadHistory() override; void petrifyHistory() override; private: Pixel pixel_; double local_time_{}; double global_time_{}; PointerWrapper<PixelCharge> pixel_charge_; std::vector<PointerWrapper<MCParticle>> mc_particles_; }; /** * @brief Typedef for message carrying pixel pulses */ using PixelPulseMessage = Message<PixelPulse>; } // namespace allpix #endif /* ALLPIX_PIXEL_PULSE_H */