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"
22 #include "canvas/Utilities/InputTag.h"
23 #include "fhiclcpp/ParameterSet.h"
24 #include "messagefacility/MessageLogger/MessageLogger.h"
25 #include "art_root_io/TFileService.h"
62 void produce(art::Event &
e)
override;
79 void vmanip(std::vector<double> v,
double* ave,
double* rms);
86 data_label_(
p.get<std::string>(
"data_label")),
87 max_time_difference_(
p.get<
double>(
"max_time_difference")),
88 store_tzero_(
p.get<
int>(
"store_tzero")),
89 verbose_(
p.get<
int>(
"verbose"))
92 if(store_tzero_ == 1) {
93 produces< std::vector<sbn::crt::CRTTzero> >();
101 std::cout <<
"getting handle to CRTHits..." << std::endl;
104 art::Handle< std::vector<sbn::crt::CRTHit> > rawHandle;
107 if(!rawHandle.isValid()){
108 std::cout <<
"Run " << evt.run() <<
", subrun " << evt.subRun()
109 <<
", event " << evt.event() <<
" has zero"
110 <<
" CRTHits " <<
" in module " <<
data_label_ << std::endl;
116 std::vector<sbn::crt::CRTHit>
const& CRTHitCollection(*rawHandle);
119 std::unique_ptr<std::vector<sbn::crt::CRTTzero> > CRTTzeroCol(
new std::vector<sbn::crt::CRTTzero>);
125 art::PtrMaker<sbn::crt::CRTHit> hitPtrMaker(evt, rawHandle.id());
126 art::PtrMaker<sbn::crt::CRTTzero> tzeroPtrMaker(evt);
128 int N_CRTHits = CRTHitCollection.size();
130 std::vector<int> iflag;
132 std::cout <<
"found " << N_CRTHits <<
" CRTHits" << std::endl;
134 for(
int i = 0; i < N_CRTHits; i++) iflag.push_back(0);
139 for(
int i = 0; i < N_CRTHits; i++) {
142 std::vector<art::Ptr<sbn::crt::CRTHit>> CRTHitCol;
144 art::Ptr<sbn::crt::CRTHit> hptr = hitPtrMaker(i);
145 CRTHitCol.push_back(hptr);
147 double time_ns_A = CRTHiteventA.
ts1_ns;
153 for (
int j=0; j<7 ;++j) {
154 CRTcanTzero.
nhits[j]=0;
155 CRTcanTzero.
pes[j]=0;
160 planeA = CRTHiteventA.
plane;
161 CRTcanTzero.
nhits[planeA]=1;
163 CRTcanTzero.
pes[planeA]=CRTHiteventA.
peshit;
164 for(
int j = i+1; j < N_CRTHits; j++) {
169 double time_ns_B = CRTHiteventB.
ts1_ns;
170 double time_diff = time_ns_B - time_ns_A;
172 art::Ptr<sbn::crt::CRTHit> hptr = hitPtrMaker(j);
173 CRTHitCol.push_back(hptr);
174 planeB = CRTHiteventB.
plane;
175 CRTcanTzero.
nhits[planeB]+=1;
176 CRTcanTzero.
pes[planeB]+=CRTHiteventB.
peshit;
178 CRTcanTzero.
ts1_ns+=(int)(time_diff);
185 CRTcanTzero.
ts1_ns/=icount;
186 CRTcanTzero.
ts1_ns+=(int)time_ns_A;
187 CRTcanTzero.
ts0_ns/=icount;
191 CRTTzeroCol->push_back(CRTcanTzero);
194 art::Ptr<sbn::crt::CRTTzero> aptz = tzeroPtrMaker(CRTTzeroCol->size()-1);
195 std::cout <<
"produced " << CRTTzeroCol->size() <<
" CRTTzero objects" << std::endl;
196 std::cout <<
"pointer to CRTTzero = " << aptz << std::endl;
204 std::cout <<
"about to move CRTTzero and art::Assns to file..." << std::endl;
207 evt.put(std::move(CRTTzeroCol));
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).
void produce(art::Event &e) override
float peshit
Total photo-electron (PE) in a crt hit.
uint64_t ts0_s
Second-only part of timestamp T0.
void set_def(sbn::crt::CRTTzero tz)
double ts0_ns
Timestamp T0 (from White Rabbit), in UTC absolute time scale in nanoseconds from the Epoch...
void vmanip(std::vector< double > v, double *ave, double *rms)
CRTTzeroProducer(fhicl::ParameterSet const &p)
CRTTzeroProducer & operator=(CRTTzeroProducer const &)=delete
BEGIN_PROLOG could also be cout
double max_time_difference_