All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Private Attributes | List of all members
G4InfoReducer Class Reference
Inheritance diagram for G4InfoReducer:

Public Member Functions

 G4InfoReducer (fhicl::ParameterSet const &p)
 
 G4InfoReducer (G4InfoReducer const &)=delete
 
 G4InfoReducer (G4InfoReducer &&)=delete
 
G4InfoReduceroperator= (G4InfoReducer const &)=delete
 
G4InfoReduceroperator= (G4InfoReducer &&)=delete
 
void produce (art::Event &e) override
 

Private Attributes

art::InputTag fSedLabel
 module making the SimEnergyDeposit More...
 
double fMinX
 
double fMinY
 
double fMinZ
 bottom left coordinate of union of all TPC active volumes More...
 
double fVoxelSizeX
 
double fVoxelSizeY
 
double fVoxelSizeZ
 size of a voxel (cm) More...
 
const geo::GeometryCorefGeometry
 

Detailed Description

Definition at line 33 of file G4InfoReducer_module.cc.

Constructor & Destructor Documentation

G4InfoReducer::G4InfoReducer ( fhicl::ParameterSet const &  p)
explicit

Definition at line 59 of file G4InfoReducer_module.cc.

60  : EDProducer{p} // ,
61  , fGeometry(*lar::providerFrom<geo::Geometry>())
62 {
63  fSedLabel = p.get<art::InputTag>("SimEnergyDepositLabel", "largeant:TPCActive");
64 
65  // Prepare for voxelization
66  fVoxelSizeX = p.get<double>("VoxelSizeX", 0.3);
67  fVoxelSizeY = p.get<double>("VoxelSizeY", 0.3);
68  fVoxelSizeZ = p.get<double>("VoxelSizeZ", 0.3);
69  if (fVoxelSizeX <= 0. || fVoxelSizeY <= 0. || fVoxelSizeZ <= 0.) {
70  std::cerr << "Voxel size must be strictly greater than zero." << std::endl;
71  throw std::exception();
72  }
73 
74  double min_x = std::numeric_limits<double>::max();
75  double min_y = std::numeric_limits<double>::max();
76  double min_z = std::numeric_limits<double>::max();
77  for(geo::TPCGeo const& tpc: fGeometry.IterateTPCs()) {
78  auto const& tpcabox = tpc.ActiveBoundingBox();
79  min_x = std::min(min_x, tpcabox.MinX());
80  min_y = std::min(min_y, tpcabox.MinY());
81  min_z = std::min(min_z, tpcabox.MinZ());
82  }
83  auto const clockData = art::ServiceHandle<detinfo::DetectorClocksService const>()->DataForJob();
84  // Take into account TPC readout window size
85  // Ionization electrons travel at ~1.6mm/us at 500 V/cm electric field
86  fMinX = min_x + clockData.TriggerOffsetTPC() * 1.6 / 10;
87  fMinY = min_y;
88  fMinZ = min_z;
89  //std::cout << "G4InfoReducer " << fMinX << " " << fMinY << " " << fMinZ << std::endl;
90  //std::cout << clockData.TriggerOffsetTPC() << std::endl;
91 
92  // Call appropriate produces<>() functions here.
93  produces<std::vector<sim::SimEnergyDepositLite>>();
94 
95  // Call appropriate consumes<>() for any products to be retrieved by this module.
96  consumes<std::vector<sim::SimEnergyDeposit>>(fSedLabel);
97 }
BEGIN_PROLOG could also be cerr
art::InputTag fSedLabel
module making the SimEnergyDeposit
pdgs p
Definition: selectors.fcl:22
Geometry information for a single TPC.
Definition: TPCGeo.h:38
const geo::GeometryCore & fGeometry
double fMinZ
bottom left coordinate of union of all TPC active volumes
double fVoxelSizeZ
size of a voxel (cm)
IteratorBox< TPC_iterator,&GeometryCore::begin_TPC,&GeometryCore::end_TPC > IterateTPCs() const
Enables ranged-for loops on all TPCs of the detector.
G4InfoReducer::G4InfoReducer ( G4InfoReducer const &  )
delete
G4InfoReducer::G4InfoReducer ( G4InfoReducer &&  )
delete

Member Function Documentation

G4InfoReducer& G4InfoReducer::operator= ( G4InfoReducer const &  )
delete
G4InfoReducer& G4InfoReducer::operator= ( G4InfoReducer &&  )
delete
void G4InfoReducer::produce ( art::Event &  e)
override

Definition at line 99 of file G4InfoReducer_module.cc.

100 {
101  // Implementation of required member function here.
102 
103  // Collect SimEnergyDeposit
104  auto handle = e.getValidHandle<std::vector<sim::SimEnergyDeposit>>(fSedLabel);
105  if (!handle.isValid()) {
106  // throw some error
107  std::cerr << "SimEnergyDeposit not found" << std::endl;
108  throw std::exception();
109  }
110 
111  struct comp {
112  bool operator() (sim::SimEnergyDepositLite lhs, sim::SimEnergyDepositLite rhs) const {
113  if (lhs.X() < rhs.X()) return true;
114  if (lhs.X() > rhs.X()) return false;
115  if (lhs.Y() < rhs.Y()) return true;
116  if (lhs.Y() > rhs.Y()) return false;
117  if (lhs.Z() < rhs.Z()) return true;
118  if (lhs.Z() > rhs.Z()) return false;
119  return lhs.TrackID() < rhs.TrackID();
120  }
121  };
122  std::set<sim::SimEnergyDepositLite, comp> sedlite_v2;
123 
124  auto const& sed_v = *handle;
125 
126  /*double total_edep = 0.;
127  for (size_t idx = 0; idx < sed_v.size(); ++idx) {
128  total_edep += sed_v[idx].E();
129  }
130  std::cout << "total edep = " << total_edep << " count = " << sed_v.size() << std::endl;*/
131 
132  for (size_t idx = 0; idx < sed_v.size(); ++idx) {
133  auto const& sed = sed_v[idx];
134  // Voxelize coordinates to closest coordinate using fVoxelSize
135  double x = sed.X() - std::fmod(sed.X() - fMinX, fVoxelSizeX);
136  double y = sed.Y() - std::fmod(sed.Y() - fMinY, fVoxelSizeY);
137  double z = sed.Z() - std::fmod(sed.Z() - fMinZ, fVoxelSizeZ);
138  // Copy info to SimEnergyDepositLite
139  sim::SimEnergyDepositLite sed_lite(sed.E(), geo::Point_t(x, y, z), sed.T(), sed.OrigTrackID());
140  // Attempt to insert, if already exist we sum up energy deposit
141  auto it = sedlite_v2.find(sed_lite);
142  if (it!=sedlite_v2.end()) {
143  double new_energy = sed_lite.E() + it->E();
144  double new_time = std::min(sed_lite.T(), it->T());
145  sedlite_v2.erase(it);
146  sim::SimEnergyDepositLite new_sed_lite(new_energy, geo::Point_t(x, y, z), new_time, sed.OrigTrackID());
147  sedlite_v2.insert(new_sed_lite);
148  }
149  else {
150  sedlite_v2.insert(std::move(sed_lite));
151  }
152  }
153 
154  /*double new_total_edep = 0.;
155  int counts = 0;
156 
157  for (auto it : sedlite_v2) {
158  new_total_edep += it.E();
159  counts += 1;
160  }
161  std::cout << "new total edep = " << new_total_edep << " with counts " << counts << " " << sedlite_v2.size() << std::endl;
162  */
163 
164  // Create vector for SEDLite
165  std::unique_ptr<std::vector<sim::SimEnergyDepositLite>> sedlite_v(new std::vector<sim::SimEnergyDepositLite>(sedlite_v2.begin(), sedlite_v2.end()));
166 
167  // Store SEDLite in event
168  e.put(std::move(sedlite_v));
169 
170 }
process_name opflash particleana ie ie ie z
process_name opflash particleana ie x
BEGIN_PROLOG could also be cerr
art::InputTag fSedLabel
module making the SimEnergyDeposit
geo::Length_t Y() const
geo::Length_t Z() const
double fMinZ
bottom left coordinate of union of all TPC active volumes
geo::Length_t X() const
double fVoxelSizeZ
size of a voxel (cm)
process_name opflash particleana ie ie y
Energy deposition in the active material (lite version).
do i e
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< double >, ROOT::Math::GlobalCoordinateSystemTag > Point_t
Type for representation of position in physical 3D space.
Definition: geo_vectors.h:184

Member Data Documentation

const geo::GeometryCore& G4InfoReducer::fGeometry
private

Definition at line 55 of file G4InfoReducer_module.cc.

double G4InfoReducer::fMinX
private

Definition at line 52 of file G4InfoReducer_module.cc.

double G4InfoReducer::fMinY
private

Definition at line 52 of file G4InfoReducer_module.cc.

double G4InfoReducer::fMinZ
private

bottom left coordinate of union of all TPC active volumes

Definition at line 52 of file G4InfoReducer_module.cc.

art::InputTag G4InfoReducer::fSedLabel
private

module making the SimEnergyDeposit

Definition at line 51 of file G4InfoReducer_module.cc.

double G4InfoReducer::fVoxelSizeX
private

Definition at line 53 of file G4InfoReducer_module.cc.

double G4InfoReducer::fVoxelSizeY
private

Definition at line 53 of file G4InfoReducer_module.cc.

double G4InfoReducer::fVoxelSizeZ
private

size of a voxel (cm)

Definition at line 53 of file G4InfoReducer_module.cc.


The documentation for this class was generated from the following file: