22 #include "cetlib_except/exception.h" 67 fMinCharge = p.get<
double>(
"MinimumCharge", 5.);
78 size_t pos = fWireModuleLabel.find(
":");
79 if (pos != std::string::npos) {
81 fWireModuleLabel = fWireModuleLabel.substr(0, pos);
118 std::map<raw::ChannelID_t, art::Ptr<recob::Wire>> wireMap;
120 for (
size_t wc = 0;
wc < wHandle->size(); ++
wc) {
122 wireMap[wire->
Channel()] = wire;
126 std::vector<const sim::SimChannel*> sccol;
131 std::vector<recob::Hit> hits_on_channel;
137 if (wire.
isNonnull()) rawdigits = WireToRawDigits.at(wire.
key());
147 MF_LOG_DEBUG(
"HitCheater") <<
"putting " << hits.
size() <<
" hits into the event";
155 std::vector<recob::Hit>&
hits,
167 std::vector<geo::WireID> wireids = geo->
ChannelToWire(channel);
169 std::map<geo::WireID, std::map<unsigned int, double>> wireIDSignals;
173 for (
auto const& mapitr : idemap) {
174 unsigned short tdc = mapitr.first;
177 if (tdc < spill * fReadOutWindowSize || tdc > (spill + 1) *
fReadOutWindowSize)
continue;
185 for (
auto const& ideitr : mapitr.second) {
187 const float edep = ideitr.numElectrons;
194 <<
"TPC for position ( " << pos.X() <<
" ; " << pos.Y() <<
" ; " << pos.Z() <<
" )" 195 <<
" in no TPC; move on to the next sim::IDE";
198 const unsigned int tpc = tpcID.
TPC;
199 const unsigned int cstat = tpcID.
Cryostat;
201 for (
auto const& wid : wireids) {
202 if (wid.TPC == tpc && wid.Cryostat == cstat) {
206 if (wid.Wire == geo->
NearestWireID(pos, wid).
Wire) wireIDSignals[wid][tdc] += edep;
213 for (
auto const& widitr : wireIDSignals) {
216 unsigned short prev = widitr.second.begin()->first;
217 unsigned short startTime = prev;
218 double totCharge = 0.;
219 double maxCharge = -1.;
220 double peakTime = 0.;
221 int multiplicity = 1;
225 for (
auto tdcitr : widitr.second) {
226 unsigned short tdc = tdcitr.first;
236 hits.emplace_back(channel,
243 std::sqrt(maxCharge),
246 std::sqrt(totCharge),
256 MF_LOG_DEBUG(
"HitCheater") <<
"new hit is " << hits.back();
275 time.
add(tdc - startTime, adc);
276 if (adc > maxCharge) {
287 hits.emplace_back(channel,
294 std::sqrt(maxCharge),
297 std::sqrt(totCharge),
307 MF_LOG_DEBUG(
"HitCheater") <<
"last hit is " << hits.back();
int fTriggerOffset
from detinfo::DetectorPropertiesService
double fSamplingRate
from detinfo::DetectorPropertiesService
std::string fWireModuleLabel
label name for module making recob::Wires
Energy deposited on a readout channel by simulated tracks.
std::vector< WireID > ChannelToWire(raw::ChannelID_t const channel) const
Returns a list of wires connected to the specified TPC channel.
int fNumberTimeSamples
Number of total time samples (N*readoutwindowsize)
int fNewHitTDCGap
gap allowed in tdcs without charge before making a new hit
enum geo::_plane_proj View_t
Enumerate the possible plane projections.
void FindHitsOnChannel(const sim::SimChannel *sc, std::vector< recob::Hit > &hits, int spill)
Declaration of signal hit object.
EDProducer(fhicl::ParameterSet const &pset)
bool isValid
Whether this ID points to a valid element.
CryostatID_t Cryostat
Index of cryostat.
Definition of basic raw digits.
WireID_t Wire
Index of the wire within its plane.
std::string fCalDataProductInstanceName
label name for module making recob::Wires
Classes gathering simple statistics.
Weight_t RMS() const
Returns the root mean square.
double fMinCharge
Minimum charge required to make a hit.
static void declare_products(art::ProducesCollector &collector, std::string instance_name="", bool doWireAssns=true, bool doRawDigitAssns=true)
Declares the hit products we are going to fill.
int TDCtick_t
Type representing a TDC tick.
Helper functions to create a hit.
TPCID FindTPCAtPosition(Point_t const &point) const
Returns the ID of the TPC at specified location.
A class handling a collection of hits and its associations.
#define DEFINE_ART_MODULE(klass)
std::string fG4ModuleLabel
label name for module making sim::SimChannels
raw::ChannelID_t Channel() const
Returns the ID of the channel (or InvalidChannelID)
enum geo::_plane_sigtype SigType_t
Enumerate the possible plane projections.
key_type key() const noexcept
void emplace_back(recob::Hit &&hit, art::Ptr< recob::Wire > const &wire=art::Ptr< recob::Wire >(), art::Ptr< raw::RawDigit > const &digits=art::Ptr< raw::RawDigit >())
Adds the specified hit to the data collection.
The data type to uniquely identify a TPC.
Definition of data types for geometry description.
void put_into(art::Event &)
Moves the data into an event.
Detector simulation of raw signals on wires.
ProducesCollector & producesCollector() noexcept
std::size_t getView(std::string const &moduleLabel, std::string const &productInstanceName, std::string const &processName, std::vector< ELEMENT const * > &result) const
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
raw::ChannelID_t Channel() const
Returns the readout channel this object describes.
bool isNonnull() const noexcept
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< double >, ROOT::Math::GlobalCoordinateSystemTag > Point_t
Type for representation of position in physical 3D space.
size_t size() const
Returns the number of hits currently in the collection.
SigType_t SignalType(PlaneID const &pid) const
Returns the type of signal on the channels of specified TPC plane.
ValidHandle< PROD > getValidHandle(InputTag const &tag) const
WireID NearestWireID(Point_t const &point, PlaneID const &planeid) const
Returns the ID of wire closest to position in the specified TPC.
int fReadOutWindowSize
Number of samples in a readout window; NOT total samples.
View_t View(PlaneID const &pid) const
Returns the view (wire orientation) on the channels of specified TPC plane.
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
object containing MC truth information necessary for making RawDigits and doing back tracking ...
void produce(art::Event &e) override
int trigger_offset(DetectorClocksData const &data)
HitCheater(fhicl::ParameterSet const &p)
Declaration of basic channel signal object.
TDCIDEs_t const & TDCIDEMap() const
Returns all the deposited energy information as stored.
2D representation of charge deposited in the TDC/wire plane
unsigned int ChannelID_t
Type representing the ID of a readout channel.
double fElectronsToADC
Conversion factor of electrons to ADC counts.
TPCID_t TPC
Index of the TPC within its cryostat.
void clear()
Clears all the statistics.
double sampling_rate(DetectorClocksData const &data)
Returns the period of the TPC readout electronics clock.
Namespace collecting geometry-related classes utilities.
Collects statistics on a single quantity (weighted)
art framework interface to geometry description
void add(Data_t value, Weight_t weight=Weight_t(1.0))
Adds one entry with specified value and weight.