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

Public Member Functions

 CRTTzeroProducer (fhicl::ParameterSet const &p)
 
 CRTTzeroProducer (CRTTzeroProducer const &)=delete
 
 CRTTzeroProducer (CRTTzeroProducer &&)=delete
 
CRTTzeroProduceroperator= (CRTTzeroProducer const &)=delete
 
CRTTzeroProduceroperator= (CRTTzeroProducer &&)=delete
 
void produce (art::Event &e) override
 
void beginJob () override
 
void endJob () override
 

Private Attributes

std::string data_label_
 
double max_time_difference_
 
int store_tzero_
 
int verbose_ = 0
 

Detailed Description

Definition at line 51 of file sbndcode/sbndcode/CRT/CRTTzeroProducer_module.cc.

Constructor & Destructor Documentation

sbnd::CRTTzeroProducer::CRTTzeroProducer ( fhicl::ParameterSet const &  p)
explicit

Definition at line 88 of file sbndcode/sbndcode/CRT/CRTTzeroProducer_module.cc.

89  : EDProducer(p),
90 
91  // Initialize member data here.
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"))
96 
97 {
98 
99  // Call appropriate produces<>() functions here.
100  if(store_tzero_ == 1) {
101  produces< std::vector<sbn::crt::CRTTzero> >();
102  produces<art::Assns<sbn::crt::CRTTzero, sbn::crt::CRTHit> >();
103  }
104 
105 }
pdgs p
Definition: selectors.fcl:22
sbnd::CRTTzeroProducer::CRTTzeroProducer ( CRTTzeroProducer const &  )
delete
sbnd::CRTTzeroProducer::CRTTzeroProducer ( CRTTzeroProducer &&  )
delete

Member Function Documentation

void sbnd::CRTTzeroProducer::beginJob ( )
override

Definition at line 219 of file sbndcode/sbndcode/CRT/CRTTzeroProducer_module.cc.

220 {
221 
222 }
void sbnd::CRTTzeroProducer::endJob ( )
override

Definition at line 224 of file sbndcode/sbndcode/CRT/CRTTzeroProducer_module.cc.

225 {
226  // Implementation of optional member function here.
227 }
CRTTzeroProducer& sbnd::CRTTzeroProducer::operator= ( CRTTzeroProducer const &  )
delete
CRTTzeroProducer& sbnd::CRTTzeroProducer::operator= ( CRTTzeroProducer &&  )
delete
void sbnd::CRTTzeroProducer::produce ( art::Event &  e)
override

Definition at line 107 of file sbndcode/sbndcode/CRT/CRTTzeroProducer_module.cc.

108 {
109  // Implementation of required member function here.
110 
111  art::Handle< std::vector<sbn::crt::CRTHit> > rawHandle;
112  evt.getByLabel(data_label_, rawHandle);
113  //check to make sure the data we asked for is valid
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;
118  std::cout << std::endl;
119  return;
120  }
121 
122  //get better access to the data
123  std::vector<sbn::crt::CRTHit> const& CRTHitCollection(*rawHandle);
124 
125  //CRTTzero collection on this event
126  std::unique_ptr<std::vector<sbn::crt::CRTTzero> > CRTTzeroCol(new std::vector<sbn::crt::CRTTzero>);
127 
128  // Output collections
129  std::unique_ptr<art::Assns<sbn::crt::CRTTzero, sbn::crt::CRTHit>> outputHits(new art::Assns<sbn::crt::CRTTzero, sbn::crt::CRTHit>);
130  // auto outputHits = std::make_unique<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);
133 
134  int N_CRTHits = CRTHitCollection.size();
135 
136  //int iflag[1000] = {};
137  std::vector<int> iflag;
138  for(int i = 0; i < N_CRTHits; i++) iflag.push_back(0);
139  int nTzero = 0;
140  uint planeA, planeB;
141  for(int i = 0; i < N_CRTHits; i++) {//A
142  if (iflag[i]==0) { // new tzero
143  //temporary hit collection for each tzero
144  std::vector<art::Ptr<sbn::crt::CRTHit>> CRTHitCol;
145  sbn::crt::CRTHit CRTHiteventA = CRTHitCollection[i];
146  art::Ptr<sbn::crt::CRTHit> hptr = hitPtrMaker(i);
147  CRTHitCol.push_back(hptr);
148 
149  double time_s_A = 0; //CRTHiteventA.ts0_s;
150  double time_ns_A = CRTHiteventA.ts1_ns;
151 
152  iflag[i]=1;
153 
154  // create and initialize, ugly code :(
155  sbn::crt::CRTTzero CRTcanTzero;
156  CRTcanTzero.ts0_ns=0;
157  CRTcanTzero.ts1_ns=0;
158  for (int j=0; j<7 ;++j) { // NUMBER OF PLANES, CHANGE TO 7
159  CRTcanTzero.nhits[j]=0;
160  CRTcanTzero.pes[j]=0;
161  }
162 
163  //
164  CRTcanTzero.ts0_s=CRTHiteventA.ts0_s;
165  CRTcanTzero.ts0_s_err=0;
166  planeA = CRTHiteventA.plane;
167  CRTcanTzero.nhits[planeA]=1;
168 
169  int icount=1;
170 
171  CRTcanTzero.pes[planeA]=CRTHiteventA.peshit;
172  for(int j = i+1; j < N_CRTHits; j++) {//B
173  if (iflag[j]==0) {
174  sbn::crt::CRTHit CRTHiteventB = CRTHitCollection[j];
175  //look for coincidences
176  double time_s_B = 0; //CRTHiteventB.ts0_s;
177  double time_ns_B = CRTHiteventB.ts1_ns;
178  double time_diff = time_ns_B - time_ns_A;
179 
180  if( (time_s_A == time_s_B) && (abs(time_diff)<max_time_difference_) ){//D
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;
186  iflag[j]=1;
187  CRTcanTzero.ts1_ns+=(int)(time_diff);
188  CRTcanTzero.ts0_ns+=(CRTHiteventB.ts0_ns-CRTHiteventA.ts0_ns);
189  icount++;
190  }
191  }
192  } // done with this tzero
193 
194  // Make a tzero data product
195  CRTcanTzero.ts1_ns/=icount;
196  CRTcanTzero.ts1_ns+=(int)time_ns_A;
197  CRTcanTzero.ts0_ns/=icount;
198  CRTcanTzero.ts0_ns+=(int)CRTHiteventA.ts0_ns;
199  CRTcanTzero.ts1_ns_err=0.;
200  CRTcanTzero.ts0_ns_err=0.;
201  CRTTzeroCol->push_back(CRTcanTzero);
202  nTzero++;
203 
204  //associate hits to this Tzero
205  art::Ptr<sbn::crt::CRTTzero> aptz = tzeroPtrMaker(CRTTzeroCol->size()-1);
206  util::CreateAssn(*this,evt,aptz,CRTHitCol,*outputHits);
207 
208  }//B
209 
210  }//A
211 
212  //store tzero collection into event
213  if(store_tzero_ == 1) {
214  evt.put(std::move(CRTTzeroCol));
215  evt.put(std::move(outputHits));
216  }
217 }
unsigned int event
Definition: DataStructs.h:634
double ts1_ns
Timestamp T1 ([signal time w.r.t. Trigger time]), in UTC absolute time scale in nanoseconds from the ...
Definition: CRTHit.hh:34
unsigned int run
Definition: DataStructs.h:635
double pes[7]
Definition: CRTTzero.hh:32
int plane
Name of the CRT wall (in the form of numbers).
Definition: CRTHit.hh:36
float peshit
Total photo-electron (PE) in a crt hit.
Definition: CRTHit.hh:27
uint32_t ts0_ns
Definition: CRTTzero.hh:25
uint16_t ts1_ns_err
Definition: CRTTzero.hh:28
uint64_t ts0_s
Second-only part of timestamp T0.
Definition: CRTHit.hh:29
double ts0_ns
Timestamp T0 (from White Rabbit), in UTC absolute time scale in nanoseconds from the Epoch...
Definition: CRTHit.hh:32
T abs(T value)
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.
unsigned int subRun
Definition: DataStructs.h:636
uint16_t ts0_s_err
Definition: CRTTzero.hh:24
uint32_t ts0_s
Definition: CRTTzero.hh:23
TCEvent evt
Definition: DataStructs.cxx:8
BEGIN_PROLOG could also be cout
uint16_t ts0_ns_err
Definition: CRTTzero.hh:26

Member Data Documentation

std::string sbnd::CRTTzeroProducer::data_label_
private
double sbnd::CRTTzeroProducer::max_time_difference_
private
int sbnd::CRTTzeroProducer::store_tzero_
private
int sbnd::CRTTzeroProducer::verbose_ = 0
private

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