All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Private Attributes | List of all members
icarus::CRTTzeroProducer Class Reference
Inheritance diagram for icarus::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 47 of file icaruscode/icaruscode/CRT/CRTTzeroProducer_module.cc.

Constructor & Destructor Documentation

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

Definition at line 82 of file icaruscode/icaruscode/CRT/CRTTzeroProducer_module.cc.

83  :
84  EDProducer{p},
85  // Initialize member data here.
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"))
90 {
91  // Call appropriate produces<>() functions here.
92  if(store_tzero_ == 1) {
93  produces< std::vector<sbn::crt::CRTTzero> >();
94  //produces<art::Assns<sbn::crt::CRTTzero, sbn::crt::CRTHit> >();
95  }
96 
97 }
pdgs p
Definition: selectors.fcl:22
icarus::CRTTzeroProducer::CRTTzeroProducer ( CRTTzeroProducer const &  )
delete
icarus::CRTTzeroProducer::CRTTzeroProducer ( CRTTzeroProducer &&  )
delete

Member Function Documentation

void icarus::CRTTzeroProducer::beginJob ( )
override

Definition at line 212 of file icaruscode/icaruscode/CRT/CRTTzeroProducer_module.cc.

213 {
214 
215 }
void icarus::CRTTzeroProducer::endJob ( )
override

Definition at line 217 of file icaruscode/icaruscode/CRT/CRTTzeroProducer_module.cc.

218 {
219  // Implementation of optional member function here.
220 }
CRTTzeroProducer& icarus::CRTTzeroProducer::operator= ( CRTTzeroProducer const &  )
delete
CRTTzeroProducer& icarus::CRTTzeroProducer::operator= ( CRTTzeroProducer &&  )
delete
void icarus::CRTTzeroProducer::produce ( art::Event &  e)
override

Definition at line 99 of file icaruscode/icaruscode/CRT/CRTTzeroProducer_module.cc.

100 {
101  std::cout << "getting handle to CRTHits..." << std::endl;
102 
103  // Implementation of required member function here.
104  art::Handle< std::vector<sbn::crt::CRTHit> > rawHandle;
105  evt.getByLabel(data_label_, rawHandle);
106  //check to make sure the data we asked for is valid
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;
111  std::cout << std::endl;
112  return;
113  }
114 
115  //get better access to the data
116  std::vector<sbn::crt::CRTHit> const& CRTHitCollection(*rawHandle);
117 
118  //CRTTzero collection on this event
119  std::unique_ptr<std::vector<sbn::crt::CRTTzero> > CRTTzeroCol(new std::vector<sbn::crt::CRTTzero>);
120 
121  // Output collections
122  //std::unique_ptr<art::Assns<sbn::crt::CRTTzero, sbn::crt::CRTHit>> outputHits(new art::Assns<sbn::crt::CRTTzero, sbn::crt::CRTHit>);
123 
124  // auto outputHits = std::make_unique<art::Assns<sbn::crt::CRTTzero, sbn::crt::CRTHit>>();
125  art::PtrMaker<sbn::crt::CRTHit> hitPtrMaker(evt, rawHandle.id());
126  art::PtrMaker<sbn::crt::CRTTzero> tzeroPtrMaker(evt);
127 
128  int N_CRTHits = CRTHitCollection.size();
129  //int iflag[1000] = {};
130  std::vector<int> iflag;
131 
132  std::cout << "found " << N_CRTHits << " CRTHits" << std::endl;
133 
134  for(int i = 0; i < N_CRTHits; i++) iflag.push_back(0);
135 
136  int nTzero = 0;
137  uint planeA, planeB;
138 
139  for(int i = 0; i < N_CRTHits; i++) {//A
140  if (iflag[i]==0) { // new tzero
141  //temporary hit collection for each tzero
142  std::vector<art::Ptr<sbn::crt::CRTHit>> CRTHitCol;
143  sbn::crt::CRTHit CRTHiteventA = CRTHitCollection[i];
144  art::Ptr<sbn::crt::CRTHit> hptr = hitPtrMaker(i);
145  CRTHitCol.push_back(hptr);
146  double time_s_A = 0; //CRTHiteventA.ts0_s;
147  double time_ns_A = CRTHiteventA.ts1_ns;
148  iflag[i]=1;
149  // create and initialize, ugly code :(
150  sbn::crt::CRTTzero CRTcanTzero;
151  CRTcanTzero.ts0_ns=0;
152  CRTcanTzero.ts1_ns=0;
153  for (int j=0; j<7 ;++j) { // NUMBER OF PLANES, CHANGE TO 7
154  CRTcanTzero.nhits[j]=0;
155  CRTcanTzero.pes[j]=0;
156  }
157  //
158  CRTcanTzero.ts0_s=CRTHiteventA.ts0_s;
159  CRTcanTzero.ts0_s_err=0;
160  planeA = CRTHiteventA.plane;
161  CRTcanTzero.nhits[planeA]=1;
162  int icount=1;
163  CRTcanTzero.pes[planeA]=CRTHiteventA.peshit;
164  for(int j = i+1; j < N_CRTHits; j++) {//B
165  if (iflag[j]==0) {
166  sbn::crt::CRTHit CRTHiteventB = CRTHitCollection[j];
167  //look for coincidences
168  double time_s_B = 0; //CRTHiteventB.ts0_s;
169  double time_ns_B = CRTHiteventB.ts1_ns;
170  double time_diff = time_ns_B - time_ns_A;
171  if( (time_s_A == time_s_B) && (abs(time_diff)<max_time_difference_) ){//D
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;
177  iflag[j]=1;
178  CRTcanTzero.ts1_ns+=(int)(time_diff);
179  CRTcanTzero.ts0_ns+=(CRTHiteventB.ts0_ns-CRTHiteventA.ts0_ns);
180  icount++;
181  }
182  }
183  } // done with this tzero
184  // Make a tzero data product
185  CRTcanTzero.ts1_ns/=icount;
186  CRTcanTzero.ts1_ns+=(int)time_ns_A;
187  CRTcanTzero.ts0_ns/=icount;
188  CRTcanTzero.ts0_ns+=(int)CRTHiteventA.ts0_ns;
189  CRTcanTzero.ts1_ns_err=0.;
190  CRTcanTzero.ts0_ns_err=0.;
191  CRTTzeroCol->push_back(CRTcanTzero);
192  nTzero++;
193  //associate hits to this Tzero
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;
197  //util::CreateAssn(*this,evt,aptz,CRTHitCol,*outputHits);
198 
199  }//B
200 
201  }//A
202  //store tzero collection into event
203 
204  std::cout << "about to move CRTTzero and art::Assns to file..." << std::endl;
205 
206  if(store_tzero_ == 1) {
207  evt.put(std::move(CRTTzeroCol));
208  //evt.put(std::move(outputHits));
209  }
210 }
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)
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 icarus::CRTTzeroProducer::data_label_
private
double icarus::CRTTzeroProducer::max_time_difference_
private
int icarus::CRTTzeroProducer::store_tzero_
private
int icarus::CRTTzeroProducer::verbose_ = 0
private

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