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

Public Member Functions

 SimTestPulse (fhicl::ParameterSet const &p)
 
 SimTestPulse (SimTestPulse const &)=delete
 
 SimTestPulse (SimTestPulse &&)=delete
 
SimTestPulseoperator= (SimTestPulse const &)=delete
 
SimTestPulseoperator= (SimTestPulse &&)=delete
 
void produce (art::Event &e) override
 
void beginRun (art::Run &run) override
 
void beginJob () override
 
void endJob () override
 

Private Attributes

bool fVerbose
 verbosity More...
 
double fTriggerTime
 Trigger timing in electronics clock [us]. More...
 
std::vector< double > fSimTime_v
 Charge timing in electronics clock [us]. More...
 
std::vector< double > fY_v
 Charge Y position in detector coordinate [cm]. More...
 
std::vector< double > fZ_v
 Charge Z position in detector coordinate [cm]. More...
 
std::vector< double > fNumElectrons_v
 Charge amount in electron count. More...
 
std::vector< int > fTick_v
 Corresponding tick. More...
 
std::vector< int > fPlane0Channel_v
 Resulting plane 0 channel number where charge is deposited. More...
 
std::vector< int > fPlane1Channel_v
 Resulting plane 1 channel number where charge is deposited. More...
 
std::vector< int > fPlane2Channel_v
 Resulting plane 2 channel number where charge is deposited. More...
 
std::vector< int > fPlane0Wire_v
 Resulting plane 0 wire number where charge is deposited. More...
 
std::vector< int > fPlane1Wire_v
 Resulting plane 1 wire number where charge is deposited. More...
 
std::vector< int > fPlane2Wire_v
 Resulting plane 2 wire number where charge is deposited. More...
 
int _run
 
int _subrun
 
int _event
 
TTree * fTupleTree
 output analysis tree More...
 

Detailed Description

Definition at line 39 of file SimTestPulse_module.cc.

Constructor & Destructor Documentation

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

Definition at line 90 of file SimTestPulse_module.cc.

91  : EDProducer{p}
92 // Initialize member data here.
93 {
94  produces< std::vector<sim::SimChannel> >();
95  produces< std::vector<sim::SimEnergyDeposit> >();
96  produces< std::vector<raw::Trigger> >();
98 
99  auto const clockData = art::ServiceHandle<detinfo::DetectorClocksService const>()->DataForJob();
100  fTriggerTime = clockData.TriggerTime();
101 
102 // fTriggerTime = p.get< double> ("TriggerTime_us");
103  fSimTime_v = p.get< std::vector<double> >("SimTimeArray_us");
104  fY_v = p.get< std::vector<double> >("YArray_cm");
105  fZ_v = p.get< std::vector<double> >("ZArray_cm");
106  fNumElectrons_v = p.get< std::vector<double> >("NumElectronsArray");
107  fVerbose = p.get< bool> ("Verbose",false);
108 
109  assert( fSimTime_v.size() == fY_v.size() &&
110  fSimTime_v.size() == fZ_v.size() &&
111  fSimTime_v.size() == fNumElectrons_v.size() );
112 }
std::vector< double > fSimTime_v
Charge timing in electronics clock [us].
pdgs p
Definition: selectors.fcl:22
std::vector< double > fNumElectrons_v
Charge amount in electron count.
produces< sumdata::RunData, art::InRun >()
double fTriggerTime
Trigger timing in electronics clock [us].
std::vector< double > fY_v
Charge Y position in detector coordinate [cm].
std::vector< double > fZ_v
Charge Z position in detector coordinate [cm].
bool fVerbose
verbosity
SimTestPulse::SimTestPulse ( SimTestPulse const &  )
delete
SimTestPulse::SimTestPulse ( SimTestPulse &&  )
delete

Member Function Documentation

void SimTestPulse::beginJob ( )
override

Definition at line 114 of file SimTestPulse_module.cc.

115 {
116  art::ServiceHandle<art::TFileService> tfs;
117 
118  fTupleTree = tfs->make<TTree>("simTestPulse", "Tree by SimTestPulse_module");
119  fTupleTree->Branch("run",&_run,"run/I");
120  fTupleTree->Branch("subrun",&_subrun,"subrun/I");
121  fTupleTree->Branch("event",&_event,"event/I");
122  fTupleTree->Branch("trigger_time",&fTriggerTime,"trigger_time/D");
123  fTupleTree->Branch("charge_time_v","std::vector<double>",&fSimTime_v);
124  fTupleTree->Branch("tick_v","std::vector<int>",&fTick_v);
125  fTupleTree->Branch("y_v","std::vector<double>",&fY_v);
126  fTupleTree->Branch("z_v","std::vector<double>",&fZ_v);
127  fTupleTree->Branch("e_v","std::vector<double>",&fNumElectrons_v);
128 
129  fTupleTree->Branch("ch_plane0","std::vector<int>",&fPlane0Channel_v);
130  fTupleTree->Branch("ch_plane1","std::vector<int>",&fPlane1Channel_v);
131  fTupleTree->Branch("ch_plane2","std::vector<int>",&fPlane2Channel_v);
132 
133  fTupleTree->Branch("wire_plane0","std::vector<int>",&fPlane0Wire_v);
134  fTupleTree->Branch("wire_plane1","std::vector<int>",&fPlane1Wire_v);
135  fTupleTree->Branch("wire_plane2","std::vector<int>",&fPlane2Wire_v);
136 }
std::vector< int > fPlane1Channel_v
Resulting plane 1 channel number where charge is deposited.
TTree * fTupleTree
output analysis tree
std::vector< double > fSimTime_v
Charge timing in electronics clock [us].
std::vector< double > fNumElectrons_v
Charge amount in electron count.
std::vector< int > fPlane2Wire_v
Resulting plane 2 wire number where charge is deposited.
std::vector< int > fPlane0Channel_v
Resulting plane 0 channel number where charge is deposited.
std::vector< int > fPlane2Channel_v
Resulting plane 2 channel number where charge is deposited.
std::vector< int > fPlane0Wire_v
Resulting plane 0 wire number where charge is deposited.
std::vector< int > fTick_v
Corresponding tick.
double fTriggerTime
Trigger timing in electronics clock [us].
std::vector< double > fY_v
Charge Y position in detector coordinate [cm].
std::vector< int > fPlane1Wire_v
Resulting plane 1 wire number where charge is deposited.
art::ServiceHandle< art::TFileService > tfs
std::vector< double > fZ_v
Charge Z position in detector coordinate [cm].
void SimTestPulse::beginRun ( art::Run &  run)
override

Definition at line 143 of file SimTestPulse_module.cc.

144 {
145  // grab the geometry object to see what geometry we are using
146  art::ServiceHandle<geo::Geometry> geo;
147 
148  std::unique_ptr<sumdata::RunData> runData(new sumdata::RunData(geo->DetectorName()));
149 
150  run.put(std::move(runData));
151 
152  return;
153 }
void SimTestPulse::endJob ( )
override

Definition at line 138 of file SimTestPulse_module.cc.

139 {
141 }
static void destroy()
Definition: ParamHolder.h:28
SimTestPulse& SimTestPulse::operator= ( SimTestPulse const &  )
delete
SimTestPulse& SimTestPulse::operator= ( SimTestPulse &&  )
delete
void SimTestPulse::produce ( art::Event &  e)
override

track id, keep 0 = invalid

energy, keep -1 = invalid

Definition at line 155 of file SimTestPulse_module.cc.

156 {
157  std::unique_ptr<std::vector<raw::Trigger> > trigger_v(new std::vector<raw::Trigger> );
158  trigger_v->push_back(raw::Trigger(0,fTriggerTime,fTriggerTime,1));
159 
160  std::unique_ptr<std::vector<sim::SimChannel> > simch_v(new std::vector<sim::SimChannel> );
161 
162  std::unique_ptr<std::vector<sim::SimEnergyDeposit>> simDep_v(new std::vector<sim::SimEnergyDeposit>);
163 
164  geo::Point_t chargeDepCoords = {0., 0., 0.};
165 
166  auto const clockData = art::ServiceHandle<detinfo::DetectorClocksService const>()->DataFor(e);
167  art::ServiceHandle<geo::Geometry> geo;
168 
169  auto const detProp = art::ServiceHandle<detinfo::DetectorPropertiesService const>()->DataForJob(clockData);
170 
171  fPlane0Channel_v.clear();
172  fPlane1Channel_v.clear();
173  fPlane2Channel_v.clear();
174  fPlane0Wire_v.clear();
175  fPlane1Wire_v.clear();
176  fPlane2Wire_v.clear();
177  fTick_v.clear();
178 
179  auto& pholder = alternative::ParamHolder::get();
180  pholder.Clear();
181 
182  for(size_t index=0; index < fSimTime_v.size(); ++index) {
183 
184  int tdc = fSimTime_v[index] / clockData.TPCClock().TickPeriod();
185  fTick_v.push_back(clockData.TPCTDC2Tick(tdc));
186 
187  if(fVerbose)
188  std::cout << "[BUFFOON!] Charge injection id " << index << " @ TDC=" << tdc
189  << " @ Y=" << fY_v[index] << " @ Z=" << fZ_v[index]
190  << " with " << fNumElectrons_v[index] << " electrons " << std::endl;
191 
192  if(tdc<0) {
193  std::cerr << "\033[93m[WARNING BUFFOON!]\033[00m ignoring fSimTime " << fSimTime_v[index]
194  << " as it results in negative TDC (invalid)" << std::endl;
195  continue;
196  }
197 
198  const geo::PlaneGeo& planeGeo = geo->Plane(geo::PlaneID(0,0,0)); // Get the coordinates of the first wire plane
199 
200  TVector3 planeCoords = planeGeo.GetCenter();
201  TVector3 planeNormal = planeGeo.GetNormalDirection();
202 
203  // Assume C=0, T=1
204  chargeDepCoords = geo::Point_t(planeCoords[0] + 1. * planeNormal[0],fY_v[index],fZ_v[index]);
205 
206  alternative::TruthHit pulse_record;
207  pulse_record.tdc = tdc;
208  pulse_record.num_electrons = fNumElectrons_v[index];
209  pulse_record.tick = clockData.TPCTDC2Tick(tdc);
210 
211  double nElecADC = detProp.ElectronsToADC() * fNumElectrons_v[index];
212  double eDeposit = 23.6 * fNumElectrons_v[index] / 1000.; // This is a guesstimate for now but hopefully not far off, note we assume wirecell will handle recombination
213 
214  std::cout << "==> x position of plane 0: " << planeCoords[0] << ", normal: " << planeNormal[0] << ", nElec: " << fNumElectrons_v[index] << ", nElecADC: " << nElecADC << ", edep: " << eDeposit << std::endl;
215  std::cout << " x position of charge deposit: " << chargeDepCoords.X() << std::endl;
216 
217  simDep_v->emplace_back(0,
218  fNumElectrons_v[index],
219  0.,
220  eDeposit,
221  geo::Point_t(chargeDepCoords.X(),chargeDepCoords.Y()+0.001,chargeDepCoords.Z()+0.001),
222  geo::Point_t(chargeDepCoords.X(),chargeDepCoords.Y()-0.001,chargeDepCoords.Z()-0.001));
223 
224  geo::PlaneID collectionPlaneID(0,0,2);
225 
226  for(size_t plane=0; plane<3; ++plane) {
227  geo::PlaneID planeID(0,0,plane);
228  double xyz[3] = {chargeDepCoords.X(),chargeDepCoords.Y(),chargeDepCoords.Z()};
229 
230  std::cout << "++ Searching for nearest wire id for planeID: " << planeID << ", xyz: " << xyz[0] << "," << xyz[1] << "," << xyz[2] << std::endl;
231  geo::WireID nearestID = geo->NearestWireID(xyz,plane);
232  std::cout << " WireID: " << nearestID << std::endl;
233  std::cout << "** Searching for nearest channel with plane: " << plane << ", xyz: " << xyz[0] << "," << xyz[1] << "," << xyz[2] << std::endl;
234  auto channel = geo->NearestChannel(xyz,plane);
235  std::cout << " Returned with channel: " << channel << std::endl;
236  auto wire = geo->ChannelToWire(channel).front().Wire;
237  std::cout << " which gives wire: " << wire << std::endl;
238  if(fVerbose) std::cout << "[BUFFOON!] plane " << plane << " channel "
239  << channel << " ... wire " << wire << std::endl;
240  pulse_record.channel_list[plane] = channel;
241  switch(plane) {
242  case 0: fPlane0Channel_v.push_back(channel); fPlane0Wire_v.push_back(wire); break;
243  case 1: fPlane1Channel_v.push_back(channel); fPlane1Wire_v.push_back(wire); break;
244  case 2: fPlane2Channel_v.push_back(channel); fPlane2Wire_v.push_back(wire); break;
245  default:
246  std::cerr << "[BUFFOON!] unexpected plane! " << plane << std::endl;
247  throw std::exception();
248  }
249  sim::SimChannel sch(channel);
250  unsigned planeTDC = clockData.TPCTick2TDC(pulse_record.tick + detProp.GetXTicksOffset(planeID) - detProp.GetXTicksOffset(collectionPlaneID));
251  sch.AddIonizationElectrons(1, /// track id, keep 0 = invalid
252  (unsigned int)planeTDC,
253  fNumElectrons_v[index],
254  xyz,
255  100.); /// energy, keep -1 = invalid
256  simch_v->emplace_back(std::move(sch));
257  }
258  pholder.Register(std::move(pulse_record));
259  }
260 
261  _run = e.id().run();
262  _subrun = e.id().subRun();
263  _event = e.id().event();
264 
265  fTupleTree->Fill();
266  e.put(std::move(simch_v));
267  e.put(std::move(simDep_v));
268  e.put(std::move(trigger_v));
269 
270  return;
271 }
std::vector< int > fPlane1Channel_v
Resulting plane 1 channel number where charge is deposited.
unsigned int tick
Definition: ParamHolder.h:13
static ParamHolder & get()
Definition: ParamHolder.h:23
Energy deposited on a readout channel by simulated tracks.
Definition: SimChannel.h:145
BEGIN_PROLOG could also be cerr
unsigned int tdc
Definition: ParamHolder.h:12
TTree * fTupleTree
output analysis tree
std::vector< double > fSimTime_v
Charge timing in electronics clock [us].
The data type to uniquely identify a Plane.
Definition: geo_types.h:472
std::vector< double > fNumElectrons_v
Charge amount in electron count.
std::vector< int > fPlane2Wire_v
Resulting plane 2 wire number where charge is deposited.
Vector GetNormalDirection() const
Returns the direction normal to the plane.
Definition: PlaneGeo.h:442
std::vector< int > fPlane0Channel_v
Resulting plane 0 channel number where charge is deposited.
std::vector< int > fPlane2Channel_v
Resulting plane 2 channel number where charge is deposited.
Point GetCenter() const
Returns the centre of the wire plane in world coordinates [cm].
Definition: PlaneGeo.h:479
Geometry information for a single wire plane.The plane is represented in the geometry by a solid whic...
Definition: PlaneGeo.h:82
std::vector< int > fPlane0Wire_v
Resulting plane 0 wire number where charge is deposited.
std::vector< int > fTick_v
Corresponding tick.
std::array< int, 3 > channel_list
Definition: ParamHolder.h:11
double fTriggerTime
Trigger timing in electronics clock [us].
std::vector< double > fY_v
Charge Y position in detector coordinate [cm].
std::vector< int > fPlane1Wire_v
Resulting plane 1 wire number where charge is deposited.
do i e
std::vector< double > fZ_v
Charge Z position in detector coordinate [cm].
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
BEGIN_PROLOG could also be cout
auto const detProp
bool fVerbose
verbosity

Member Data Documentation

int SimTestPulse::_event
private

Definition at line 85 of file SimTestPulse_module.cc.

int SimTestPulse::_run
private

Definition at line 85 of file SimTestPulse_module.cc.

int SimTestPulse::_subrun
private

Definition at line 85 of file SimTestPulse_module.cc.

std::vector<double> SimTestPulse::fNumElectrons_v
private

Charge amount in electron count.

Definition at line 71 of file SimTestPulse_module.cc.

std::vector<int> SimTestPulse::fPlane0Channel_v
private

Resulting plane 0 channel number where charge is deposited.

Definition at line 77 of file SimTestPulse_module.cc.

std::vector<int> SimTestPulse::fPlane0Wire_v
private

Resulting plane 0 wire number where charge is deposited.

Definition at line 81 of file SimTestPulse_module.cc.

std::vector<int> SimTestPulse::fPlane1Channel_v
private

Resulting plane 1 channel number where charge is deposited.

Definition at line 78 of file SimTestPulse_module.cc.

std::vector<int> SimTestPulse::fPlane1Wire_v
private

Resulting plane 1 wire number where charge is deposited.

Definition at line 82 of file SimTestPulse_module.cc.

std::vector<int> SimTestPulse::fPlane2Channel_v
private

Resulting plane 2 channel number where charge is deposited.

Definition at line 79 of file SimTestPulse_module.cc.

std::vector<int> SimTestPulse::fPlane2Wire_v
private

Resulting plane 2 wire number where charge is deposited.

Definition at line 83 of file SimTestPulse_module.cc.

std::vector<double> SimTestPulse::fSimTime_v
private

Charge timing in electronics clock [us].

Definition at line 68 of file SimTestPulse_module.cc.

std::vector<int> SimTestPulse::fTick_v
private

Corresponding tick.

Definition at line 76 of file SimTestPulse_module.cc.

double SimTestPulse::fTriggerTime
private

Trigger timing in electronics clock [us].

Definition at line 67 of file SimTestPulse_module.cc.

TTree* SimTestPulse::fTupleTree
private

output analysis tree

Definition at line 87 of file SimTestPulse_module.cc.

bool SimTestPulse::fVerbose
private

verbosity

Definition at line 62 of file SimTestPulse_module.cc.

std::vector<double> SimTestPulse::fY_v
private

Charge Y position in detector coordinate [cm].

Definition at line 69 of file SimTestPulse_module.cc.

std::vector<double> SimTestPulse::fZ_v
private

Charge Z position in detector coordinate [cm].

Definition at line 70 of file SimTestPulse_module.cc.


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