10 #include "art/Framework/Core/EDProducer.h"
11 #include "art/Framework/Core/ModuleMacros.h"
12 #include "art/Framework/Principal/Event.h"
13 #include "art/Framework/Principal/Handle.h"
14 #include "art/Framework/Principal/Run.h"
15 #include "art/Framework/Principal/SubRun.h"
16 #include "canvas/Persistency/Common/Ptr.h"
17 #include "canvas/Persistency/Common/Assns.h"
18 #include "canvas/Persistency/Provenance/ProductID.h"
19 #include "art/Persistency/Common/PtrMaker.h"
23 #include "canvas/Utilities/InputTag.h"
24 #include "fhiclcpp/ParameterSet.h"
25 #include "messagefacility/MessageLogger/MessageLogger.h"
26 #include "art_root_io/TFileService.h"
66 void produce(art::Event &
e)
override;
84 void vmanip(std::vector<double> v,
double* ave,
double* rms);
92 data_label_(p.
get<
std::string>(
"data_label")),
93 max_time_difference_(p.
get<double>(
"max_time_difference")),
94 store_tzero_(p.
get<int>(
"store_tzero")),
95 verbose_(p.
get<int>(
"verbose"))
101 produces< std::vector<sbn::crt::CRTTzero> >();
102 produces<art::Assns<sbn::crt::CRTTzero, sbn::crt::CRTHit> >();
111 art::Handle< std::vector<sbn::crt::CRTHit> > rawHandle;
114 if(!rawHandle.isValid()){
115 std::cout <<
"Run " << evt.run() <<
", subrun " << evt.subRun()
116 <<
", event " << evt.event() <<
" has zero"
117 <<
" CRTHits " <<
" in module " <<
data_label_ << std::endl;
123 std::vector<sbn::crt::CRTHit>
const& CRTHitCollection(*rawHandle);
126 std::unique_ptr<std::vector<sbn::crt::CRTTzero> > CRTTzeroCol(
new std::vector<sbn::crt::CRTTzero>);
129 std::unique_ptr<art::Assns<sbn::crt::CRTTzero, sbn::crt::CRTHit>> outputHits(
new art::Assns<sbn::crt::CRTTzero, sbn::crt::CRTHit>);
131 art::PtrMaker<sbn::crt::CRTHit> hitPtrMaker(evt, rawHandle.id());
132 art::PtrMaker<sbn::crt::CRTTzero> tzeroPtrMaker(evt);
134 int N_CRTHits = CRTHitCollection.size();
137 std::vector<int> iflag;
138 for(
int i = 0; i < N_CRTHits; i++) iflag.push_back(0);
141 for(
int i = 0; i < N_CRTHits; i++) {
144 std::vector<art::Ptr<sbn::crt::CRTHit>> CRTHitCol;
146 art::Ptr<sbn::crt::CRTHit> hptr = hitPtrMaker(i);
147 CRTHitCol.push_back(hptr);
150 double time_ns_A = CRTHiteventA.
ts1_ns;
158 for (
int j=0; j<7 ;++j) {
159 CRTcanTzero.
nhits[j]=0;
160 CRTcanTzero.
pes[j]=0;
166 planeA = CRTHiteventA.
plane;
167 CRTcanTzero.
nhits[planeA]=1;
171 CRTcanTzero.
pes[planeA]=CRTHiteventA.
peshit;
172 for(
int j = i+1; j < N_CRTHits; j++) {
177 double time_ns_B = CRTHiteventB.
ts1_ns;
178 double time_diff = time_ns_B - time_ns_A;
181 art::Ptr<sbn::crt::CRTHit> hptr = hitPtrMaker(j);
182 CRTHitCol.push_back(hptr);
183 planeB = CRTHiteventB.
plane;
184 CRTcanTzero.
nhits[planeB]+=1;
185 CRTcanTzero.
pes[planeB]+=CRTHiteventB.
peshit;
187 CRTcanTzero.
ts1_ns+=(int)(time_diff);
195 CRTcanTzero.
ts1_ns/=icount;
196 CRTcanTzero.
ts1_ns+=(int)time_ns_A;
197 CRTcanTzero.
ts0_ns/=icount;
201 CRTTzeroCol->push_back(CRTcanTzero);
205 art::Ptr<sbn::crt::CRTTzero> aptz = tzeroPtrMaker(CRTTzeroCol->size()-1);
214 evt.put(std::move(CRTTzeroCol));
215 evt.put(std::move(outputHits));
double std(const std::vector< short > &wf, const double ped_mean, size_t start, size_t nsample)
void set_def(sbn::crt::CRTTzero tz)
double ts1_ns
Timestamp T1 ([signal time w.r.t. Trigger time]), in UTC absolute time scale in nanoseconds from the ...
int plane
Name of the CRT wall (in the form of numbers).
float peshit
Total photo-electron (PE) in a crt hit.
void vmanip(std::vector< float > v, float *ave, float *rms)
CRTTzeroProducer & operator=(CRTTzeroProducer const &)=delete
uint64_t ts0_s
Second-only part of timestamp T0.
double max_time_difference_
double ts0_ns
Timestamp T0 (from White Rabbit), in UTC absolute time scale in nanoseconds from the Epoch...
CRTTzeroProducer(fhicl::ParameterSet const &p)
void produce(art::Event &e) override
bool CreateAssn(art::Event &evt, std::vector< T > const &a, art::Ptr< U > const &b, art::Assns< U, T > &assn, std::string a_instance, size_t index=UINT_MAX)
Creates a single one-to-one association.
stream1 can override from command line with o or output services user sbnd
BEGIN_PROLOG could also be cout