28 #include "Utilities/AssociationUtil.h" 123 default:
return 99999;
132 auto dit = std::min_element(
v.begin(),
v.end(),
141 if (c.
pulses.size() == 0) {
142 return std::numeric_limits<double>::quiet_NaN();
145 double t = std::numeric_limits<double>::quiet_NaN();
147 if (method ==
"Mean") {
149 for (
auto p : c.
pulses) { t +=
p->StartTimeInNanoSec(); }
150 t = t / (double(c.
pulses.size()));
152 }
else if (method ==
"Weighted_MaxAmpNorm") {
154 auto dmaxamp = *std::max_element(c.
pulses.begin(), c.
pulses.end(),
158 double maxamp = dmaxamp->AmplitudeInADC();
161 t +=
p->StartTimeInNanoSec() * (
p->AmplitudeInADC() / maxamp);
162 w +=
p->AmplitudeInADC() / maxamp;
166 }
else if (method ==
"First") {
171 t =
d->StartTimeInNanoSec();
175 <<
"Unknown time of flight cluster time calculation method: " << method <<
"." <<
std::endl;
212 Form(
"Amplitude Channel %d (all hits)",online_channel),
215 Form(
"Charge Integral Channel %d (all hits)",online_channel),
218 Form(
"Start Time Channel %d (all hits)",online_channel),
221 Form(
"Width Channel %d (all hits)",online_channel),
224 Form(
"Amplitude vs Integral Channel %d (all hits)",online_channel),
225 200, 0, 100000, 200, 0, 4000);
227 Form(
"Amplitude vs Width Channel %d (all hits)",online_channel),
228 200, 0, 20, 200, 0, 4000);
247 for (
int i=0;
i<4;
i++) {
248 for (
int j=
i+1;
j<4;
j++) {
253 hUSdt[
i][
j] = usijdir.
make<TH1D>(Form(
"hUSdt%d%d",
i+1,
j+1), Form(
"ToF dt between channels %d and %d",
i+8,
j+8),
255 hUSdA[
i][
j] = usijdir.
make<TH1D>(Form(
"hUSdA%d%d",
i+1,
j+1), Form(
"ToF dA between channels %d and %d",
i+8,
j+8),
257 hUSdI[
i][
j] = usijdir.
make<TH1D>(Form(
"hUSdI%d%d",
i+1,
j+1), Form(
"ToF dI between channels %d and %d",
i+8,
j+8),
259 hUSdAdt[
i][
j] = usijdir.
make<TH2D>(Form(
"hUSdAdt%d%d",
i+1,
j+1), Form(
"ToF dA vs dt channels %d and %d",
i+8,
j+8),
262 hUSdIdt[
i][
j] = usijdir.
make<TH2D>(Form(
"hUSdIdt%d%d",
i+1,
j+1), Form(
"ToF dI vs dt channels %d and %d",
i+8,
j+8),
265 hUSdAdI[
i][
j] = usijdir.
make<TH2D>(Form(
"hUSdAdI%d%d",
i+1,
j+1), Form(
"ToF dA vs dI channels %d and %d",
i+8,
j+8),
269 hDSdt[
i][
j] = dsijdir.
make<TH1D>(Form(
"hDSdt%d%d",
i+1,
j+1), Form(
"ToF dt between channels %d and %d",
i+12,
j+12),
271 hDSdA[
i][
j] = dsijdir.
make<TH1D>(Form(
"hDSdA%d%d",
i+1,
j+1), Form(
"ToF dA between channels %d and %d",
i+12,
j+12),
273 hDSdI[
i][
j] = dsijdir.
make<TH1D>(Form(
"hDSdI%d%d",
i+1,
j+1), Form(
"ToF dI between channels %d and %d",
i+12,
j+12),
275 hDSdAdt[
i][
j] = dsijdir.
make<TH2D>(Form(
"hDSdAdt%d%d",
i+1,
j+1), Form(
"ToF dA vs dt channels %d and %d",
i+12,
j+12),
278 hDSdIdt[
i][
j] = dsijdir.
make<TH2D>(Form(
"hDSdIdt%d%d",
i+1,
j+1), Form(
"ToF dI vs dt channels %d and %d",
i+12,
j+12),
281 hDSdAdI[
i][
j] = dsijdir.
make<TH2D>(Form(
"hDSdAdI%d%d",
i+1,
j+1), Form(
"ToF dA vs dI channels %d and %d",
i+12,
j+12),
285 hSiPMdt[
i][
j] = sipmijdir.
make<TH1D>(Form(
"hSiPMdt%d%d",
i+1,
j+1), Form(
"ToF dt between channels %d and %d",
i+4,
j+4),
287 hSiPMdA[
i][
j] = sipmijdir.
make<TH1D>(Form(
"hSiPMdA%d%d",
i+1,
j+1), Form(
"ToF dA between channels %d and %d",
i+4,
j+4),
289 hSiPMdI[
i][
j] = sipmijdir.
make<TH1D>(Form(
"hSiPMdI%d%d",
i+1,
j+1), Form(
"ToF dI between channels %d and %d",
i+4,
j+4),
291 hSiPMdAdt[
i][
j] = sipmijdir.
make<TH2D>(Form(
"hSiPMdAdt%d%d",
i+1,
j+1), Form(
"ToF dA vs dt channels %d and %d",
i+4,
j+4),
294 hSiPMdIdt[
i][
j] = sipmijdir.
make<TH2D>(Form(
"hSiPMdIdt%d%d",
i+1,
j+1), Form(
"ToF dI vs dt channels %d and %d",
i+4,
j+4),
297 hSiPMdAdI[
i][
j] = sipmijdir.
make<TH2D>(Form(
"hSiPMdAdI%d%d",
i+1,
j+1), Form(
"ToF dA vs dI channels %d and %d",
i+4,
j+4),
308 std::vector<art::Ptr<brb::BeamlineDigit>> tofDigits;
314 unsigned int USHits = 0;
315 unsigned int DSHits = 0;
316 unsigned int SiPMHits = 0;
319 for (
auto d : tofDigits) {
324 switch(
d->ChannelID().Detector) {
350 for (
auto c : usclusters) {
357 double times[4] = { -1, -1, -1, -1 };
358 double amps[4] = { -1, -1, -1, -1 };
359 double areas[4] = { -1, -1, -1, -1 };
360 for (
auto d :
c.pulses) {
365 for (
int i=0;
i<4;
i++) {
366 for (
int j=
i+1;
j<4;
j++) {
367 if ((times[
i] >= 0) && (times[
j] >= 0)) {
368 double dA = amps[
j] - amps[
i];
369 double dI = areas[
j] - areas[
i];
370 double dt = times[
j] - times[
i];
382 for (
auto c : dsclusters) {
386 double times[4] = { -1, -1, -1, -1 };
387 double amps[4] = { -1, -1, -1, -1 };
388 double areas[4] = { -1, -1, -1, -1 };
389 for (
auto d :
c.pulses) {
394 for (
int i=0;
i<4;
i++) {
395 for (
int j=
i+1;
j<4;
j++) {
396 if ((times[
i] >= 0) && (times[
j] >= 0)) {
397 double dA = amps[
j] - amps[
i];
398 double dI = areas[
j] - areas[
i];
399 double dt = times[
j] - times[
i];
411 for (
auto c : sipmclusters) {
415 double times[4] = { -1, -1, -1, -1 };
416 double amps[4] = { -1, -1, -1, -1 };
417 double areas[4] = { -1, -1, -1, -1 };
418 for (
auto d :
c.pulses) {
423 for (
int i=0;
i<4;
i++) {
424 for (
int j=
i+1;
j<4;
j++) {
425 if ((times[
i] >= 0) && (times[
j] >= 0)) {
426 double dA = amps[
j] - amps[
i];
427 double dI = areas[
j] - areas[
i];
428 double dt = times[
j] - times[
i];
double calculateTime(ToFPulseCluster c, std::string method) const
std::vector< ToFPulseCluster > GetClusters(beamlinegeo::ToFCounter counter) const
std::map< beamlinegeo::ChannelID, TH2D * > hAmplitude_vs_Integral_AllHits_channel
std::map< beamlinegeo::ChannelID, TH1D * > hWidth_AllHits_channel
art::ServiceHandle< art::TFileService > tfs
unsigned int fHistdANBins
static std::vector< art::Ptr< brb::BeamlineDigit > >::iterator getEarliest(std::vector< art::Ptr< brb::BeamlineDigit >> v)
int AmplitudeInADC() const
TFileDirectory mkdir(std::string const &dir, std::string const &descr="")
std::vector< ChannelID > ChannelIDs() const
All the ChannelIDs in this channel mapping.
double StartTimeInNanoSec() const
void FindClusters(std::vector< art::Ptr< brb::BeamlineDigit >> digits, double clusterWindow)
DEFINE_ART_MODULE(TestTMapFile)
void reconfigure(const fhicl::ParameterSet &p)
std::map< beamlinegeo::ChannelID, TH1D * > hIntegral_AllHits_channel
TH1I * hSiPMFirstHitDetector
TH1I * hDSHitMultiplicity
static unsigned int onlineChannel(ChannelID id)
Encapsulation of reconstructed digitizer 'hits'. Used for ToF PMTs and SiPMs, and Cherenkov and Muon ...
art::InputTag fToFDigitLabel
std::map< beamlinegeo::ChannelID, TH2D * > hAmplitude_vs_Width_AllHits_channel
unsigned int fHistdAdtNBins
unsigned int fHistdtNBins
T get(std::string const &key) const
TH1I * hUSHitMultiplicity
std::map< beamlinegeo::ChannelID, TH1D * > hStartTime_AllHits_channel
EDAnalyzer(Table< Config > const &config)
std::string fClusterTimeMethod
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
T * make(ARGS...args) const
unsigned int fHistdINBins
TH1I * hSiPMHitMultiplicity
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
art::ServiceHandle< beamlineutil::BeamlineChannelMap > fChannelMap
std::vector< art::Ptr< brb::BeamlineDigit > > pulses
std::map< beamlinegeo::ChannelID, TH1D * > hAmplitude_AllHits_channel
void fill_ptr_vector(std::vector< Ptr< T >> &ptrs, H const &h)
ToFSingleCounterAnalysis(fhicl::ParameterSet const &p)
void analyze(const art::Event &e)
TH1I * hDSFirstHitDetector
unsigned int fHistdAdINBins
Channel mapping service which may be used to interpret the channels which are read out by the various...
unsigned int fHistdIdtNBins
TH1I * hUSFirstHitDetector