21 #include <ktracker/SRecEvent.h>
51 #include <gsl/gsl_randist.h>
52 #include <gsl/gsl_rng.h>
54 #include <boost/lexical_cast.hpp>
60 _hit_container_type(
"Vector"),
65 _out_name(
"RndmEmbedEval.root")
80 int ret = GetNodes(topNode);
89 std::cout <<
"Entering RndmEmbed::process_event: " << _event << std::endl;
93 if(!_hit_vector and _hit_container_type.find(
"Vector") == std::string::npos) {
94 LogInfo(
"!_hit_vector and _hit_container_type.find(\"Vector\") == std::string::npos");
100 gsl_rng* RandomGenerator = gsl_rng_alloc(gsl_rng_mt19937);
104 gsl_rng_set(RandomGenerator, seed);
106 for (
auto i : _noise_rate) {
107 auto detector_name = i.first;
108 auto noise_rate = i.second;
118 for(
int element_id=1; element_id <= plane.
nElements; ++element_id) {
119 bool acc = gsl_ran_flat(RandomGenerator, 0, 1) < noise_rate ?
true :
false;
123 double drift = plane.
spacing * gsl_ran_flat(RandomGenerator, -1, 1);
125 auto up_digiHit = std::unique_ptr<SQMCHit_v1> (
new SQMCHit_v1());
126 auto digiHit = up_digiHit.get();
143 digiHit->
set_truth_x(std::numeric_limits<float>::max());
144 digiHit->
set_truth_y(std::numeric_limits<float>::max());
145 digiHit->
set_truth_z(std::numeric_limits<float>::max());
151 double drift = plane.
spacing * gsl_ran_flat(RandomGenerator, -1, 1);
153 auto up_digiHit = std::unique_ptr<SQMCHit_v1> (
new SQMCHit_v1());
154 auto digiHit = up_digiHit.get();
171 digiHit->
set_truth_x(std::numeric_limits<float>::max());
172 digiHit->
set_truth_y(std::numeric_limits<float>::max());
173 digiHit->
set_truth_z(std::numeric_limits<float>::max());
181 gsl_rng_free(RandomGenerator);
188 std::cout <<
"Leaving RndmEmbed::process_event: " << _event << std::endl;
196 std::cout <<
"RndmEmbed::End" << std::endl;
207 _tout =
new TTree(
"T",
"RndmEmbed");
218 if(_hit_container_type.find(
"Map") != std::string::npos) {
219 _hit_map = findNode::getClass<SQHitMap>(topNode,
"SQHitMap");
226 if(_hit_container_type.find(
"Vector") != std::string::npos) {
227 _hit_vector = findNode::getClass<SQHitVector>(topNode,
"SQHitVector");
virtual void set_element_id(const short id)
virtual short get_element_id() const
Return the element ID of this hit.
int End(PHCompositeNode *topNode)
Called at the end of all processing.
int InitRun(PHCompositeNode *topNode)
virtual void set_detector_id(const short a)
virtual void set_hit_id(const int a)
virtual void set_g4hit_id(const PHG4HitDefs::keytype a)
static PHTFileServer & get(void)
return reference to class singleton
RndmEmbed(const std::string &name="RndmEmbed")
virtual void set_truth_x(const float a)
int Init(PHCompositeNode *topNode)
virtual short get_detector_id() const
Return the detector ID of this hit.
virtual void set_truth_y(const float a)
virtual int Verbosity() const
Gets the verbosity of this module.
virtual void push_back(const SQHit *hit)
virtual void set_pos(const float a)
virtual void set_drift_distance(const float a)
bool cd(const std::string &filename)
change to directory of TFile matching filename
int process_event(PHCompositeNode *topNode)
Output some useful messages during manual command line running.
static GeomSvc * instance()
singlton instance
virtual size_t size() const
virtual void set_hodo_mask(const bool a)
int getDetectorID(const std::string &detectorName) const
Get the plane position.
Plane getPlane(int detectorID) const
virtual void set_truth_z(const float a)
void getMeasurement(int detectorID, int elementID, double &measurement, double &dmeasurement)
Convert the detectorID and elementID to the actual hit position.
virtual void set_in_time(const bool a)
virtual void set_track_id(const int a)
void open(const std::string &filename, const std::string &type="RECREATE")
open a SafeTFile. If filename is not found in the map, create a new TFile and append to the map; incr...