Public Member Functions | Private Member Functions | Private Attributes | List of all members
Signal2Noise Class Reference
Inheritance diagram for Signal2Noise:
art::EDAnalyzer art::detail::Analyzer art::detail::LegacyModule art::Observer art::ModuleBase

Public Member Functions

 Signal2Noise (fhicl::ParameterSet const &p)
 
 Signal2Noise (Signal2Noise const &)=delete
 
 Signal2Noise (Signal2Noise &&)=delete
 
Signal2Noiseoperator= (Signal2Noise const &)=delete
 
Signal2Noiseoperator= (Signal2Noise &&)=delete
 
void analyze (art::Event const &e) override
 
void beginJob () override
 
- Public Member Functions inherited from art::EDAnalyzer
 EDAnalyzer (fhicl::ParameterSet const &pset)
 
template<typename Config >
 EDAnalyzer (Table< Config > const &config)
 
std::string workerType () const
 
- Public Member Functions inherited from art::detail::Analyzer
virtual ~Analyzer () noexcept
 
 Analyzer (fhicl::ParameterSet const &pset)
 
template<typename Config >
 Analyzer (Table< Config > const &config)
 
void doBeginJob (SharedResources const &resources)
 
void doEndJob ()
 
void doRespondToOpenInputFile (FileBlock const &fb)
 
void doRespondToCloseInputFile (FileBlock const &fb)
 
void doRespondToOpenOutputFiles (FileBlock const &fb)
 
void doRespondToCloseOutputFiles (FileBlock const &fb)
 
bool doBeginRun (RunPrincipal &rp, ModuleContext const &mc)
 
bool doEndRun (RunPrincipal &rp, ModuleContext const &mc)
 
bool doBeginSubRun (SubRunPrincipal &srp, ModuleContext const &mc)
 
bool doEndSubRun (SubRunPrincipal &srp, ModuleContext const &mc)
 
bool doEvent (EventPrincipal &ep, ModuleContext const &mc, std::atomic< std::size_t > &counts_run, std::atomic< std::size_t > &counts_passed, std::atomic< std::size_t > &counts_failed)
 
- Public Member Functions inherited from art::Observer
 ~Observer () noexcept
 
 Observer (Observer const &)=delete
 
 Observer (Observer &&)=delete
 
Observeroperator= (Observer const &)=delete
 
Observeroperator= (Observer &&)=delete
 
void registerProducts (ProductDescriptions &, ModuleDescription const &)
 
void fillDescriptions (ModuleDescription const &)
 
fhicl::ParameterSetID selectorConfig () const
 
- Public Member Functions inherited from art::ModuleBase
virtual ~ModuleBase () noexcept
 
 ModuleBase ()
 
ModuleDescription const & moduleDescription () const
 
void setModuleDescription (ModuleDescription const &)
 
std::array< std::vector< ProductInfo >, NumBranchTypes > const & getConsumables () const
 
void sortConsumables (std::string const &current_process_name)
 
template<typename T , BranchType BT>
ViewToken< T > consumesView (InputTag const &tag)
 
template<typename T , BranchType BT>
ViewToken< T > mayConsumeView (InputTag const &tag)
 

Private Member Functions

void reset ()
 

Private Attributes

std::string fRawDigitLabel
 
std::string fRawInstanceLabel
 
std::string fWireProducerLabel
 
std::string fWireInstanceLabel
 
std::string fHitModuleLabel
 
std::string fTrackModuleLabel
 
std::string fCalorimetryModuleLabel
 
bool fSaveWaveForm
 
std::vector< int > fSelectedWires
 
TTree * fEventTree
 
int event
 
int run
 
int subrun
 
double evttime
 
int year_month_date
 
int hour_min_sec
 
int ntrks
 
int trkid [kMaxTracks]
 
float trkstart [kMaxTracks][3]
 
float trkend [kMaxTracks][3]
 
float trklen [kMaxTracks]
 
float trkthetaxz [kMaxTracks]
 
float trkthetayz [kMaxTracks]
 
float trkstartcosxyz [kMaxTracks][3]
 
float trkendcosxyz [kMaxTracks][3]
 
int ntrkhits [kMaxTracks][3]
 
float trkdqdx [kMaxTracks][3][kMaxHits]
 
float trkx [kMaxTracks][3][kMaxHits]
 
float trkt [kMaxTracks][3][kMaxHits]
 
double trkhitx [kMaxHits][3][kMaxHits]
 
double trkhity [kMaxHits][3][kMaxHits]
 
double trkhitz [kMaxHits][3][kMaxHits]
 
int wireid [kMaxTracks][kMaxHits]
 
int chid [kMaxTracks][kMaxHits]
 
int tpcid [kMaxTracks][kMaxHits]
 
float hit_plane [kMaxTracks][kMaxHits]
 
double cosgma [kMaxTracks][kMaxHits]
 
float amp [kMaxTracks][kMaxHits]
 
int tamp [kMaxTracks][kMaxHits]
 
float ped [kMaxTracks][kMaxHits]
 
float noiserms [kMaxTracks][kMaxHits]
 
float noisermsfit [kMaxTracks][kMaxHits]
 
int fNticks
 
int fNticksReadout
 
float fSampleRate
 
TH1F * fWaveForm [10]
 
float fMaxNoise = 40.
 
TH1F * fWaveFormHist [10]
 

Additional Inherited Members

- Public Types inherited from art::EDAnalyzer
using WorkerType = WorkerT< EDAnalyzer >
 
using ModuleType = EDAnalyzer
 
- Protected Member Functions inherited from art::Observer
std::string const & processName () const
 
bool wantAllEvents () const noexcept
 
bool wantEvent (ScheduleID id, Event const &e) const
 
Handle< TriggerResultsgetTriggerResults (Event const &e) const
 
 Observer (fhicl::ParameterSet const &config)
 
 Observer (std::vector< std::string > const &select_paths, std::vector< std::string > const &reject_paths, fhicl::ParameterSet const &config)
 
- Protected Member Functions inherited from art::ModuleBase
ConsumesCollectorconsumesCollector ()
 
template<typename T , BranchType = InEvent>
ProductToken< T > consumes (InputTag const &)
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > consumesView (InputTag const &)
 
template<typename T , BranchType = InEvent>
void consumesMany ()
 
template<typename T , BranchType = InEvent>
ProductToken< T > mayConsume (InputTag const &)
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > mayConsumeView (InputTag const &)
 
template<typename T , BranchType = InEvent>
void mayConsumeMany ()
 

Detailed Description

Definition at line 85 of file Signal2Noise_module.cc.

Constructor & Destructor Documentation

Signal2Noise::Signal2Noise ( fhicl::ParameterSet const &  p)
explicit

Definition at line 176 of file Signal2Noise_module.cc.

177  : EDAnalyzer{p} // ,
178  // More initializers here.
179 {
180  // Call appropriate consumes<>() for any products to be retrieved by this module.
181  fRawDigitLabel = p.get<std::string>("RawDigitLabel");
182  fRawInstanceLabel = p.get<std::string>("RawInstanceLabel", "daq");
183  fWireProducerLabel = p.get<std::string>("WireProducerLabel");
184  fWireInstanceLabel = p.get<std::string>("WireInstanceLabel", "dataprep");
185  fHitModuleLabel = p.get<std::string>("HitModuleLabel");
186  fTrackModuleLabel = p.get<std::string>("TrackModuleLabel");
187  fCalorimetryModuleLabel = p.get<std::string>("CalorimetryModuleLabel");
188  fSaveWaveForm = p.get<bool>("SaveWaveForm");
189  fSelectedWires = p.get<std::vector<int>>("SelectedWires");
190 
191  if (fRawDigitLabel.empty() && fWireProducerLabel.empty()) {
192  throw cet::exception("AdcThresholdRoiFinder") << "Both RawDigitLabel and WireProducerLabel are empty";
193  }
194 
195  if ((!fRawDigitLabel.empty()) && (!fWireProducerLabel.empty())){
196  throw cet::exception("AdcThresholdRoiFinder") << "Only one of RawDigitLabel and WireProducerLabel should be set";
197  }
198 
199  // DetectorPropertiesService
200  auto const clockData = art::ServiceHandle<detinfo::DetectorClocksService>()->DataForJob();
201  auto const detProp = art::ServiceHandle<detinfo::DetectorPropertiesService>()->DataForJob(clockData);
202  fNticks = detProp.NumberTimeSamples(); // number of clock ticks per event
203  fNticksReadout = detProp.ReadOutWindowSize(); // number of clock ticks per readout window
204  fSampleRate = sampling_rate(clockData); // period of the TPC readout electronics clock
205  cout << "Numer of clock ticks per event: " << fNticks << endl;
206  cout << "Numer of clock ticks per readout window: " << fNticksReadout << endl;
207  cout << "Sampling rate: " << fSampleRate << endl;
208 }
std::string fCalorimetryModuleLabel
std::string string
Definition: nybbler.cc:12
std::vector< int > fSelectedWires
EDAnalyzer(fhicl::ParameterSet const &pset)
Definition: EDAnalyzer.h:25
std::string fTrackModuleLabel
std::string fWireInstanceLabel
p
Definition: test.py:223
std::string fRawInstanceLabel
std::string fHitModuleLabel
std::string fRawDigitLabel
std::string fWireProducerLabel
double sampling_rate(DetectorClocksData const &data)
Returns the period of the TPC readout electronics clock.
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
QTextStream & endl(QTextStream &s)
Signal2Noise::Signal2Noise ( Signal2Noise const &  )
delete
Signal2Noise::Signal2Noise ( Signal2Noise &&  )
delete

Member Function Documentation

void Signal2Noise::analyze ( art::Event const &  e)
overridevirtual

Implements art::EDAnalyzer.

Definition at line 211 of file Signal2Noise_module.cc.

212 {
213  // Implementation of required member function here.
214  reset();
215 
216  // event info
217  run = e.run();
218  subrun = e.subRun();
219  event = e.id().event();
220  art::Timestamp ts = e.time();
221  TTimeStamp tts(ts.timeHigh(), ts.timeLow());
222  evttime = tts.AsDouble();
223 
224  //cout << "tts " << tts << endl;
225  //cout << "evttime " << evttime << endl;
226 
227  UInt_t year=0;
228  UInt_t month=0;
229  UInt_t day=0;
230 
231  year_month_date=tts.GetDate(kTRUE,0,&year,&month,&day);
232 
233  UInt_t hour=0;
234  UInt_t min=0;
235  UInt_t sec=0;
236 
237  hour_min_sec=tts.GetTime(kTRUE,0,&hour,&min,&sec);
238 
239  // channel status
240  lariov::ChannelStatusProvider const& channelStatus
242 
243  // get RawDigit
244  std::vector< art::Ptr<raw::RawDigit> > rawdigitlist;
246  auto rawdigitListHandle = e.getHandle< std::vector<raw::RawDigit> >(itag1);
247  if (rawdigitListHandle) {
248  art::fill_ptr_vector(rawdigitlist, rawdigitListHandle);
249  }
250 
251  //cout << "rawdigitlist.size(): " << rawdigitlist.size() << endl;
252 
253  // get Wire
254  std::vector<art::Ptr<recob::Wire> > wirelist;
255  art::InputTag itag2(fWireProducerLabel, "dataprep");
256  auto wireListHandle = e.getHandle< std::vector<recob::Wire> >(itag2);
257  if (wireListHandle) {
258  art::fill_ptr_vector(wirelist, wireListHandle);
259  }
260 
261  //cout << "wirelist.size(): " << wirelist.size() << endl;
262 
263  // hit
264  std::vector< art::Ptr<recob::Hit> > hitlist;
265  auto hitListHandle = e.getHandle< std::vector<recob::Hit> >(fHitModuleLabel);
266  if (hitListHandle) {
267  art::fill_ptr_vector(hitlist, hitListHandle);
268  }
269 
270  // track
271  std::vector< art::Ptr<recob::Track> > tracklist;
272  auto trackListHandle = e.getHandle< std::vector<recob::Track> >(fTrackModuleLabel);
273  if (trackListHandle) {
274  art::fill_ptr_vector(tracklist, trackListHandle);
275  }
276 
278 
279  art::FindManyP<recob::Hit> fmtrkhit(trackListHandle, e, fTrackModuleLabel);
280  art::FindManyP<anab::Calorimetry> fmtrkcalo(trackListHandle, e, fCalorimetryModuleLabel);
281  //art::FindManyP<raw::RawDigit> fmhitrawdigit(hitListHandle, e, fHitModuleLabel);
282  //art::FindManyP<recob::Wire> fmhitwire(hitListHandle, e, fHitModuleLabel);
283  //art::FindManyP<raw::RawDigit> fmwirerawdigit(wireListHandle, e, "digitwire");
284  art::FindManyP<recob::Hit, recob::TrackHitMeta> fmhittrkmeta(trackListHandle, e, fTrackModuleLabel);
285 
286  auto const detProp = art::ServiceHandle<detinfo::DetectorPropertiesService>()->DataFor(e);
287 
288  // waveform: save several waveforms for check
289  int nwaveform = 0; // only save 10 waveforms
290  int nwaveform_plane_0 = 0; // only save 3 waveforms
291  int nwaveform_plane_1 = 0; // only save 3 waveforms
292  int nwaveform_plane_2 = 0; // only save 3 waveforms
293 
294  ntrks = 0;
295  for (const auto& trk : tracklist) {
296 
297  trkid[ntrks] = trk->ID();
298  trklen[ntrks] = trk->Length();
299 
300  // TVector3
301  auto start = trk->Vertex();
302  auto end = trk->End();
303  auto start_dir = trk->VertexDirection();
304  auto end_dir = trk->EndDirection();
305 
306  trkthetaxz[ntrks] = std::atan2(start_dir.X(), start_dir.Z());
307  trkthetayz[ntrks]= std::atan2(start_dir.Y(), start_dir.Z());
308 
309  trkstart[ntrks][0] = start.X();
310  trkstart[ntrks][1] = start.Y();
311  trkstart[ntrks][2] = start.Z();
312 
313  trkend[ntrks][0] = end.X();
314  trkend[ntrks][1] = end.Y();
315  trkend[ntrks][2] = end.Z();
316 
317  trkstartcosxyz[ntrks][0] = start_dir.X();
318  trkstartcosxyz[ntrks][1] = start_dir.Y();
319  trkstartcosxyz[ntrks][2] = start_dir.Z();
320 
321  trkendcosxyz[ntrks][0] = end_dir.X();
322  trkendcosxyz[ntrks][1] = end_dir.Y();
323  trkendcosxyz[ntrks][2] = end_dir.Z();
324 
325  // calometry
326  if (fmtrkcalo.isValid()) {
327  std::vector<art::Ptr<anab::Calorimetry>> calos = fmtrkcalo.at(ntrks);
328  for (size_t icalo=0; icalo<calos.size(); icalo++) {
329  if (!calos[icalo]) continue;
330  if (!calos[icalo]->PlaneID().isValid) continue;
331  int planenum = calos[icalo]->PlaneID().Plane;
332  if (planenum<0 || planenum>2) continue;
333 
334  const size_t NHits = calos[icalo] -> dEdx().size();
335  ntrkhits[ntrks][planenum] = NHits;
336 
337  double minx = 1e9;
338  for (size_t iHit=0; iHit<NHits; ++iHit) {
339  cout << "plane: "<< planenum << "; pitch: " << (calos[icalo]->TrkPitchVec())[iHit] << endl;
340  if ((calos[icalo]->TrkPitchVec())[iHit]>1) continue;
341  const auto& TrkPos = (calos[icalo] -> XYZ())[iHit];
342  if (TrkPos.X()<minx)
343  minx = TrkPos.X();
344  }// loop NHits
345 
346  for(size_t iHit = 0; iHit < NHits; ++iHit) {
347  if ((calos[icalo]->TrkPitchVec())[iHit]>1) continue;
348  const auto& TrkPos1 = (calos[icalo] -> XYZ())[iHit];
349  double x = TrkPos1.X()-minx; //subtract the minx to get correct t0
350  double XDriftVelocity = detProp.DriftVelocity()*1e-3; //cm/ns
351  double t = x/(XDriftVelocity*1000); //change the velocity units to cm/ns to cm/us
352  trkx[ntrks][planenum][iHit] = x;
353  trkt[ntrks][planenum][iHit] = t;
354  trkdqdx[ntrks][planenum][iHit] = (calos[icalo]->dQdx())[iHit];
355  } // loop over NHits iHit
356  } // end loop over icalo
357  } // end if fmtrkcalo
358 
359  // hits associated with trk
360  std::vector<art::Ptr<recob::Hit>> allhits = fmtrkhit.at(ntrks); // use either trk.key() or ntrks
361 
362  for (size_t ihit=0; ihit<allhits.size(); ihit++) {
363  // wire plane information
364  unsigned int wireplane = allhits[ihit]->WireID().Plane;
365  if (wireplane <0 || wireplane>2) continue;
366  unsigned int wire = allhits[ihit]->WireID().Wire;
367  unsigned int tpc = allhits[ihit]->WireID().TPC;
368  unsigned int channel = allhits[ihit]->Channel();
369 
370  if (channelStatus.IsBad(channel)) continue;
371 
372  // hit position: not all hits are associated with space points, using neighboring space points to interpolate
373  double xyz[3] = {-9999.0, -9999.0, -9999.0};
374  bool fBadhit = false;
375 
376  if (fmhittrkmeta.isValid()) {
377  auto vhit = fmhittrkmeta.at(ntrks);
378  auto vmeta = fmhittrkmeta.data(ntrks);
379 
380  for (size_t ii=0; ii<vhit.size(); ii++) {
381  if (vhit[ii].key() == allhits[ihit].key()) {
382 
383  // nb. LArPandoraTrackCreation_module.cc fills the max of a signed int in an unsigned int
384  // to indicate an invalid index
385 
386  if (vmeta[ii]->Index() >= (unsigned int) std::numeric_limits<int32_t>::max()) {
387  fBadhit = true;
388  continue;
389  }
390 
391  if (vmeta[ii]->Index() >= trk->NumberTrajectoryPoints()) {
392  throw cet::exception("Calorimetry_module.cc") << "Requested track trajectory index "<<vmeta[ii]->Index()<<" exceeds the total number of trajectory points "<<trk->NumberTrajectoryPoints()<<" for track index "<<ntrks<<". Something is wrong with the track reconstruction. Please contact tjyang@fnal.gov!!";
393  }
394 
395  if (!trk->HasValidPoint(vmeta[ii]->Index())) {
396  fBadhit = true;
397  continue;
398  }
399 
400  auto loc = trk->LocationAtPoint(vmeta[ii]->Index());
401  xyz[0] = loc.X();
402  xyz[1] = loc.Y();
403  xyz[2] = loc.Z();
404 
405  break;
406  } // if (vhit[ii].key() == allhits[ihit].key())
407 
408  } // end of for ii
409 
410  } // if fmhittrkmeta.isValid()
411 
412  if (fBadhit) continue;
413 
414  trkhitx[ntrks][wireplane][ihit] = xyz[0];
415  trkhity[ntrks][wireplane][ihit] = xyz[1];
416  trkhitz[ntrks][wireplane][ihit] = xyz[2];
417 
418  wireid[ntrks][ihit] = wire;
419  chid[ntrks][ihit] = channel;
420  tpcid[ntrks][ihit] = tpc;
421  hit_plane[ntrks][ihit] = wireplane;
422 
423  // calculate track angle w.r.t. wire
424  double angleToVert = geom->WireAngleToVertical(geom->View(allhits[ihit]->WireID()), allhits[ihit]->WireID().TPC, allhits[ihit]->WireID().Cryostat)-0.5*::util::pi<>();
425 
426  //cout << "tpc: " << tpc << "; plane: " << wireplane << "; wire: " << wire << "channel: " << channel << "; WireangleToVert: " << angleToVert << "; x: " << xyz[0] << endl;
427 
428  const auto& dir = trk->DirectionAtPoint(0);
429  // angleToVert: return the angle w.r.t y+ axis, anti-closewise
430  // dir: 3d track direction: u = (x,y,z);
431  // vector that perpendicular to wires in yz plane v = (0, sin(angleToVert), cos(angleToVert))
432  // cos gamma = u.Dot(v)/(u.mag()*v.mag()) here, u.mag()=v.mag()=1
433  double tmp_cosgamma = abs(sin(angleToVert)*dir.Y() + std::cos(angleToVert)*dir.Z());
434  cosgma[ntrks][ihit] = tmp_cosgamma;
435 
436  //cout << "track direction: " << trkstartcosxyz[ntrks][0] << ", " << trkstartcosxyz[ntrks][1] << ", " << trkstartcosxyz[ntrks][2] << endl;
437  //cout << "angleToVert: " << angleToVert << endl;
438  //cout << "dir: " << dir.X() << ", " << dir.Y() << ", " << dir.Z() << endl;
439 
440  /*
441  // check wire direction on each plane
442  cout << geom->Plane(wireplane).Wire(wire).ThetaZ(true) << endl;
443  double wirestart[3];
444  double wireend[3];
445  geom->Plane(wireplane).Wire(wire).GetStart(wirestart);
446  geom->Plane(wireplane).Wire(wire).GetEnd(wireend);
447  cout << "wirestart: (" << wirestart[0] << ", " << wirestart[1] << ", "<< wirestart[2] << ")" << endl;
448  cout << "wireend: (" << wireend[0] << ", " << wireend[1] << ", "<< wireend[2] << ")" << endl;
449  */
450 
451  int datasize = fNticks;
452 
453  std::vector<float> adcvec(datasize);
454 
455  // loop over wires
456  // use either rawdigitlist or wirelist (one is empty, the other is not) to find the associated ADCVec with same channel of the hit
457  if (!rawdigitlist.empty()) {
458  int key_rawdigit = -1;
459  for (size_t ird=0; ird<rawdigitlist.size(); ++ird) {
460  if (rawdigitlist[ird]->Channel() == channel) {
461  key_rawdigit = ird;
462  break;
463  }
464  }
465 
466  if (key_rawdigit == -1) continue; // in case of poor bad channel configuration
467  int datasize_tmp = rawdigitlist[key_rawdigit]->Samples();
468  if (datasize_tmp != datasize) continue; // in case of poor bad channel configuration
469 
470  // to use a compressed RawDigit, one has to create a new buffer, fill and use it
471  std::vector<short> rawadc(datasize); // create a buffer
472  raw::Uncompress(rawdigitlist[key_rawdigit]->ADCs(), rawadc, rawdigitlist[key_rawdigit]->Compression());
473 
474  // pedestal
475  ped[ntrks][ihit] = rawdigitlist[key_rawdigit]->GetPedestal(); // Pedestal level (ADC counts)
476 
477  for (size_t jj=0; jj<rawadc.size(); jj++) {
478  adcvec[jj] = rawadc[jj] - ped[ntrks][ihit];
479  }
480  } // if (!rawdigitlist.empty())
481  else if (!wirelist.empty()) {
482  int key_wire = -1;
483  for (size_t iw=0; iw<wirelist.size(); ++iw) {
484  if (wirelist[iw]->Channel() == channel) {
485  key_wire = iw;
486  break;
487  }
488  }
489 
490  if (key_wire == -1) continue;
491  const auto & signal = wirelist[key_wire]->Signal();
492  if (int(signal.size()) != datasize) continue;
493 
494  for (size_t jj=0; jj<signal.size(); jj++) {
495  adcvec[jj] = signal[jj];
496  }
497  } // if (!wirelist.empty())
498 
499  // ROI from the reconstructed hits
500  int t0 = allhits[ihit]->PeakTime() - 5*(allhits[ihit]->RMS());
501  if (t0<0) t0 = 0;
502  int t1 = allhits[ihit]->PeakTime() + 5*(allhits[ihit]->RMS());
503  if (t1>= datasize) t1 = datasize - 1;
504  //cout << "t0: " << t0 << " ; t1: " << t1 << endl;
505 
506  // maximum pulse height of waveform
507  float temp_max_pulseheight = -9999.;
508  //float temp_min_pulseheight = 9999.;
509  int temp_t_max_pulseheight = -1; // time in unit of ticks
510  for (int itime=t0; itime <=t1; itime++) {
511  if (adcvec[itime] > temp_max_pulseheight) {
512  temp_max_pulseheight = adcvec[itime];
513  temp_t_max_pulseheight = itime;
514  }
515 
516  //if (adcvec[itime] < temp_min_pulseheight) {
517  // temp_min_pulseheight = adcvec[itime];
518  //}
519  }
520  //if (temp_max_pulseheight < 0) {
521  // std::cout << "amp: " << temp_max_pulseheight << "; plane: " << wireplane << std::endl;
522  // cout << "amp min: " << temp_min_pulseheight << endl;
523  // cout << "t0: " << t0 << " ; t1: " << t1 << endl;
524  //}
525 
526  amp[ntrks][ihit] = temp_max_pulseheight;
527  tamp[ntrks][ihit] = temp_t_max_pulseheight;
528 
529  // noise rms calculation: ideally, this should be done for all wires, not only wires that have hits
530  // method 1: calculate rms directly
531  int start_ped = 0;
532  int end_ped = datasize-1;
533  float temp_sum = 0.;
534  int temp_number = 0;
535  for (int iped=start_ped; iped<=end_ped; iped++) {
536  if (iped > t0 && iped < t1) continue; // ideally we should use this to skip ROI region
537  if (abs(adcvec[iped]) > fMaxNoise) continue; // skip ROI with a threshold, protection for multiple hits on a wire
538  temp_sum += adcvec[iped]*adcvec[iped];
539  temp_number++;
540  }
541  noiserms[ntrks][ihit] = sqrt(temp_sum/temp_number);
542 
543  // method 2: fit noise histogram with a gaus
544  TH1F *h1_noise = new TH1F(TString::Format("noise_trk%d_hit%d",ntrks, (int)ihit), TString::Format("noise_trk%d_hit%d",ntrks, (int)ihit), (int)fMaxNoise, -fMaxNoise, fMaxNoise);
545 
546  // fill the readout datasize for each wire with hit: signal is included but would not affect the noise rms since signals are far way from the noise peak. One may also exclude signals by using ROI threshold cuts
547  for (int jj=0; jj<datasize; jj++) {
548  if (jj > t0 && jj < t1) continue; // ideally we should use this to skip ROI region
549  if (abs(adcvec[jj]) > fMaxNoise) continue; // skip ROI with a threshold, protection for multiple hits on a wire
550  h1_noise->Fill(adcvec[jj]);
551  }
552  TF1 *f1_noise = new TF1("f1_noise", "gaus" , -fMaxNoise, fMaxNoise);
553  double par[3];
554  h1_noise->Fit(f1_noise, "WWQ");
555  f1_noise->GetParameters(&par[0]);
556  noisermsfit[ntrks][ihit] = par[2]; // sigma from gaus fit
557 
558  if (fSaveWaveForm && nwaveform<10 && nwaveform_plane_0<4 && nwaveform_plane_1<4 && nwaveform_plane_2<5) {
559  if (wireplane==0) nwaveform_plane_0++;
560  if (wireplane==1) nwaveform_plane_1++;
561  if (wireplane==2) nwaveform_plane_2++;
562 
563  fWaveForm[nwaveform]->SetNameTitle(Form("plane_%d_AdcChannel_%d", wireplane, channel), Form("AdcChannel%d", channel));
564 
565  for (int jj=0; jj<datasize; jj++) {
566  fWaveForm[nwaveform]->SetBinContent(jj+1, adcvec[jj]);
567  }//fWaveForm
568 
569  fWaveFormHist[nwaveform]->SetNameTitle(Form("Noise_%d_AdcChannel_%d", wireplane, channel), Form("NhistChannel%d", channel));
570  for (int tt=1; tt<=h1_noise->GetNbinsX(); tt++){
571  fWaveFormHist[nwaveform]->SetBinContent(tt, h1_noise->GetBinContent(tt));
572  }//fWaveFormHist
573  nwaveform++;
574  }
575 
576  delete h1_noise;
577  delete f1_noise;
578 
579  } // end of for ihit
580 
581  ++ ntrks;
582  } // end of for trk
583  fEventTree->Fill();
584 }
virtual bool IsBad(raw::ChannelID_t channel) const =0
Returns whether the specified channel is bad in the current run.
end
while True: pbar.update(maxval-len(onlies[E][S])) #print iS, "/", len(onlies[E][S]) found = False for...
code to link reconstructed objects back to the MC truth information
float noisermsfit[kMaxTracks][kMaxHits]
int wireid[kMaxTracks][kMaxHits]
constexpr std::uint32_t timeLow() const
Definition: Timestamp.h:29
std::string fCalorimetryModuleLabel
int chid[kMaxTracks][kMaxHits]
Format
Definition: utils.h:7
int tamp[kMaxTracks][kMaxHits]
constexpr std::uint32_t timeHigh() const
Definition: Timestamp.h:34
float trkdqdx[kMaxTracks][3][kMaxHits]
float trkthetaxz[kMaxTracks]
float ped[kMaxTracks][kMaxHits]
float hit_plane[kMaxTracks][kMaxHits]
uint8_t channel
Definition: CRTFragment.hh:201
string dir
unsigned int Index
int tpcid[kMaxTracks][kMaxHits]
float noiserms[kMaxTracks][kMaxHits]
float trkend[kMaxTracks][3]
float trkx[kMaxTracks][3][kMaxHits]
float trkthetayz[kMaxTracks]
TH1F * fWaveFormHist[10]
double trkhitx[kMaxHits][3][kMaxHits]
std::string fTrackModuleLabel
float amp[kMaxTracks][kMaxHits]
Definition: type_traits.h:61
T abs(T value)
double dEdx(float dqdx, float Efield)
Definition: doAna.cpp:21
const double e
IDparameter< geo::WireID > WireID
Member type of validated geo::WireID parameter.
def key(type, name=None)
Definition: graph.py:13
double trkhity[kMaxHits][3][kMaxHits]
float trkstart[kMaxTracks][3]
Class providing information about the quality of channels.
static int max(int a, int b)
View_t View(geo::PlaneID const &pid) const
Returns the view (wire orientation) on the channels of specified TPC plane.
std::string fRawInstanceLabel
float trkendcosxyz[kMaxTracks][3]
std::string fHitModuleLabel
float trklen[kMaxTracks]
T min(sqlite3 *const db, std::string const &table_name, std::string const &column_name)
Definition: statistics.h:55
int ntrkhits[kMaxTracks][3]
std::string fRawDigitLabel
std::string fWireProducerLabel
detail::Node< FrameID, bool > PlaneID
Definition: CRTID.h:125
list x
Definition: train.py:276
double trkhitz[kMaxHits][3][kMaxHits]
void fill_ptr_vector(std::vector< Ptr< T >> &ptrs, H const &h)
Definition: Ptr.h:297
void Uncompress(const std::vector< short > &adc, std::vector< short > &uncompressed, raw::Compress_t compress)
Uncompresses a raw data buffer.
Definition: raw.cxx:776
float trkstartcosxyz[kMaxTracks][3]
int trkid[kMaxTracks]
float trkt[kMaxTracks][3][kMaxHits]
double WireAngleToVertical(geo::View_t view, geo::TPCID const &tpcid) const
Returns the angle of the wires in the specified view from vertical.
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
QTextStream & endl(QTextStream &s)
double cosgma[kMaxTracks][kMaxHits]
void Signal2Noise::beginJob ( )
overridevirtual

Reimplemented from art::EDAnalyzer.

Definition at line 587 of file Signal2Noise_module.cc.

587  {
589  fEventTree = tfs->make<TTree>("Event", "Event");
590  fEventTree->Branch("event", &event, "event/I");
591  fEventTree->Branch("run", &run, "run/I");
592  fEventTree->Branch("subrun", &subrun, "subrun/I");
593  fEventTree->Branch("evttime", &evttime, "evttime/D");
594  fEventTree->Branch("year_month_date", &year_month_date, "year_month_date/I");
595  fEventTree->Branch("hour_min_sec", &hour_min_sec, "hour_min_sec/I");
596 
597  // track
598  fEventTree->Branch("ntrks", &ntrks, "ntrks/I");
599  fEventTree->Branch("trkid", trkid, "trkid[ntrks]/I");
600  fEventTree->Branch("trkstart", trkstart, "trkstart[ntrks][3]/F");
601  fEventTree->Branch("trkend", trkend, "trkend[ntrks][3]/F");
602  fEventTree->Branch("trklen", trklen, "trklen[ntrks]/F");
603  fEventTree->Branch("trkthetaxz", trkthetaxz, "trkthetaxz[ntrks]/F");
604  fEventTree->Branch("trkthetayz", trkthetayz, "trkthetayz[ntrks]/F");
605  fEventTree->Branch("trkstartcosxyz", trkstartcosxyz, "trkstartcosxyz[ntrks][3]/F");
606  fEventTree->Branch("trkendcosxyz", trkendcosxyz, "trkendcosxyz[ntrks][3]/F");
607 
608  fEventTree->Branch("ntrkhits", ntrkhits, "ntrkhits[ntrks][3]/I");
609  fEventTree->Branch("trkdqdx", trkdqdx, "trkdqdx[ntrks][3][1000]/F");
610  //fEventTree->Branch("trkdedx", trkdedx, "trkdedx[ntrks][3][1000]/F");
611  fEventTree->Branch("trkx", trkx, "trkx[ntrks][3][1000]/F");
612  fEventTree->Branch("trkt", trkt, "trkt[ntrks][3][1000]/F");
613 
614 
615 
616  // hit
617  fEventTree->Branch("trkhitx", trkhitx, "trkhitx[ntrks][3][1000]/D");
618  fEventTree->Branch("trkhity", trkhity, "trkhity[ntrks][3][1000]/D");
619  fEventTree->Branch("trkhitz", trkhitz, "trkhitz[ntrks][3][1000]/D");
620 
621  fEventTree->Branch("wireid", wireid, "wireid[ntrks][1000]/I");
622  fEventTree->Branch("chid", wireid, "chid[ntrks][1000]/I");
623  fEventTree->Branch("tpcid", wireid, "tpcid[ntrks][1000]/I");
624 
625  fEventTree->Branch("hit_plane", hit_plane, "hit_plane[ntrks][1000]/F");
626  fEventTree->Branch("ped", ped, "ped[ntrks][1000]/F");
627  fEventTree->Branch("amp", amp, "amp[ntrks][1000]/F");
628  fEventTree->Branch("tamp", tamp, "tamp[ntrks][1000]/I");
629  fEventTree->Branch("cosgma", cosgma, "cosgma[ntrks][1000]/D");
630 
631  fEventTree->Branch("noiserms", noiserms, "noiserms[ntrks][1000]/F");
632  fEventTree->Branch("noisermsfit", noisermsfit, "noisermsfit[ntrks][1000]/F");
633 
634 
635  // waveform
636  if (fSaveWaveForm) {
637  for (int i=0; i<10; i++) {
638  fWaveForm[i] = tfs->make<TH1F>(Form("waveform_%d",i), "wire waveform", fNticksReadout, 0, fNticksReadout);
639  fWaveForm[i]->SetStats(0);
640  fWaveForm[i]->GetXaxis()->SetTitle("Time [ticks]");
641  fWaveForm[i]->GetYaxis()->SetTitle("ADC");
642  fWaveFormHist[i] = tfs->make<TH1F>(Form("Noise_%d",i), "noise", (int)fMaxNoise, -fMaxNoise, fMaxNoise);
643  }
644  }
645 }
float noisermsfit[kMaxTracks][kMaxHits]
int wireid[kMaxTracks][kMaxHits]
int tamp[kMaxTracks][kMaxHits]
float trkdqdx[kMaxTracks][3][kMaxHits]
float trkthetaxz[kMaxTracks]
float ped[kMaxTracks][kMaxHits]
float hit_plane[kMaxTracks][kMaxHits]
float noiserms[kMaxTracks][kMaxHits]
float trkend[kMaxTracks][3]
float trkx[kMaxTracks][3][kMaxHits]
float trkthetayz[kMaxTracks]
TH1F * fWaveFormHist[10]
double trkhitx[kMaxHits][3][kMaxHits]
float amp[kMaxTracks][kMaxHits]
double trkhity[kMaxHits][3][kMaxHits]
float trkstart[kMaxTracks][3]
float trkendcosxyz[kMaxTracks][3]
float trklen[kMaxTracks]
int ntrkhits[kMaxTracks][3]
double trkhitz[kMaxHits][3][kMaxHits]
float trkstartcosxyz[kMaxTracks][3]
int trkid[kMaxTracks]
float trkt[kMaxTracks][3][kMaxHits]
Event finding and building.
double cosgma[kMaxTracks][kMaxHits]
Signal2Noise& Signal2Noise::operator= ( Signal2Noise const &  )
delete
Signal2Noise& Signal2Noise::operator= ( Signal2Noise &&  )
delete
void Signal2Noise::reset ( )
private

Definition at line 647 of file Signal2Noise_module.cc.

647  {
648  run = -99999;
649  subrun = -99999;
650  event = -99999;
651  evttime = -99999;
652  year_month_date = -99999;
653  hour_min_sec = -99999;
654 
655 
656  ntrks = -99999;
657  for (size_t i=0; i<kMaxTracks; ++i) {
658  trkid[i] = -1;
659  trklen[i] = -1.0;
660  trkthetaxz[i] = -9999.0;
661  trkthetayz[i] = -9999.0;
662  for (int j=0; j<3; j++) {
663  trkstart[i][j] = -9999.0;
664  trkend[i][j] = -9999.0;
665  trkstartcosxyz[i][j] = -9999.0;
666  trkendcosxyz[i][j] = -9999.0;
667 
668  ntrkhits[i][j] = -9999;
669 
670  for (int k=0; k<kMaxHits; k++) {
671  trkhitx[i][j][k] = -9999.0;
672  trkhity[i][j][k] = -9999.0;
673  trkhitz[i][j][k] = -9999.0;
674 
675  trkdqdx[i][j][k] = -9999.0;
676  //trkdedx[i][j][k] = -9999.0;
677  trkx[i][j][k] = -9999.0;
678  trkt[i][j][k] = -9999.0;
679  }
680  }
681 
682  for (int k=0; k<kMaxHits; k++) {
683  wireid[i][k] = -99;
684  chid[i][k] = -99;
685  tpcid[i][k] = -99;
686 
687  hit_plane[i][k] = -1;
688  ped[i][k] = -9999.0;
689  amp[i][k] = -9999.0;
690  tamp[i][k] = -1;
691 
692  noiserms[i][k] = -999.;
693  noisermsfit[i][k] = -999.;
694 
695  cosgma[i][k] = -99.;
696 
697  }
698 
699  }
700 
701 
702 }
float noisermsfit[kMaxTracks][kMaxHits]
int wireid[kMaxTracks][kMaxHits]
int chid[kMaxTracks][kMaxHits]
int tamp[kMaxTracks][kMaxHits]
float trkdqdx[kMaxTracks][3][kMaxHits]
float trkthetaxz[kMaxTracks]
float ped[kMaxTracks][kMaxHits]
float hit_plane[kMaxTracks][kMaxHits]
int tpcid[kMaxTracks][kMaxHits]
float noiserms[kMaxTracks][kMaxHits]
float trkend[kMaxTracks][3]
float trkx[kMaxTracks][3][kMaxHits]
float trkthetayz[kMaxTracks]
double trkhitx[kMaxHits][3][kMaxHits]
float amp[kMaxTracks][kMaxHits]
double trkhity[kMaxHits][3][kMaxHits]
const int kMaxTracks
float trkstart[kMaxTracks][3]
float trkendcosxyz[kMaxTracks][3]
const int kMaxHits
float trklen[kMaxTracks]
int ntrkhits[kMaxTracks][3]
double trkhitz[kMaxHits][3][kMaxHits]
float trkstartcosxyz[kMaxTracks][3]
int trkid[kMaxTracks]
float trkt[kMaxTracks][3][kMaxHits]
double cosgma[kMaxTracks][kMaxHits]

Member Data Documentation

float Signal2Noise::amp[kMaxTracks][kMaxHits]
private

Definition at line 159 of file Signal2Noise_module.cc.

int Signal2Noise::chid[kMaxTracks][kMaxHits]
private

Definition at line 153 of file Signal2Noise_module.cc.

double Signal2Noise::cosgma[kMaxTracks][kMaxHits]
private

Definition at line 157 of file Signal2Noise_module.cc.

int Signal2Noise::event
private

Definition at line 122 of file Signal2Noise_module.cc.

double Signal2Noise::evttime
private

Definition at line 125 of file Signal2Noise_module.cc.

std::string Signal2Noise::fCalorimetryModuleLabel
private

Definition at line 111 of file Signal2Noise_module.cc.

TTree* Signal2Noise::fEventTree
private

Definition at line 119 of file Signal2Noise_module.cc.

std::string Signal2Noise::fHitModuleLabel
private

Definition at line 109 of file Signal2Noise_module.cc.

float Signal2Noise::fMaxNoise = 40.
private

Definition at line 171 of file Signal2Noise_module.cc.

int Signal2Noise::fNticks
private

Definition at line 167 of file Signal2Noise_module.cc.

int Signal2Noise::fNticksReadout
private

Definition at line 168 of file Signal2Noise_module.cc.

std::string Signal2Noise::fRawDigitLabel
private

Definition at line 105 of file Signal2Noise_module.cc.

std::string Signal2Noise::fRawInstanceLabel
private

Definition at line 106 of file Signal2Noise_module.cc.

float Signal2Noise::fSampleRate
private

Definition at line 169 of file Signal2Noise_module.cc.

bool Signal2Noise::fSaveWaveForm
private

Definition at line 112 of file Signal2Noise_module.cc.

std::vector<int> Signal2Noise::fSelectedWires
private

Definition at line 113 of file Signal2Noise_module.cc.

std::string Signal2Noise::fTrackModuleLabel
private

Definition at line 110 of file Signal2Noise_module.cc.

TH1F* Signal2Noise::fWaveForm[10]
private

Definition at line 170 of file Signal2Noise_module.cc.

TH1F* Signal2Noise::fWaveFormHist[10]
private

Definition at line 172 of file Signal2Noise_module.cc.

std::string Signal2Noise::fWireInstanceLabel
private

Definition at line 108 of file Signal2Noise_module.cc.

std::string Signal2Noise::fWireProducerLabel
private

Definition at line 107 of file Signal2Noise_module.cc.

float Signal2Noise::hit_plane[kMaxTracks][kMaxHits]
private

Definition at line 155 of file Signal2Noise_module.cc.

int Signal2Noise::hour_min_sec
private

Definition at line 127 of file Signal2Noise_module.cc.

float Signal2Noise::noiserms[kMaxTracks][kMaxHits]
private

Definition at line 163 of file Signal2Noise_module.cc.

float Signal2Noise::noisermsfit[kMaxTracks][kMaxHits]
private

Definition at line 164 of file Signal2Noise_module.cc.

int Signal2Noise::ntrkhits[kMaxTracks][3]
private

Definition at line 141 of file Signal2Noise_module.cc.

int Signal2Noise::ntrks
private

Definition at line 130 of file Signal2Noise_module.cc.

float Signal2Noise::ped[kMaxTracks][kMaxHits]
private

Definition at line 161 of file Signal2Noise_module.cc.

int Signal2Noise::run
private

Definition at line 123 of file Signal2Noise_module.cc.

int Signal2Noise::subrun
private

Definition at line 124 of file Signal2Noise_module.cc.

int Signal2Noise::tamp[kMaxTracks][kMaxHits]
private

Definition at line 160 of file Signal2Noise_module.cc.

int Signal2Noise::tpcid[kMaxTracks][kMaxHits]
private

Definition at line 154 of file Signal2Noise_module.cc.

float Signal2Noise::trkdqdx[kMaxTracks][3][kMaxHits]
private

Definition at line 142 of file Signal2Noise_module.cc.

float Signal2Noise::trkend[kMaxTracks][3]
private

Definition at line 133 of file Signal2Noise_module.cc.

float Signal2Noise::trkendcosxyz[kMaxTracks][3]
private

Definition at line 138 of file Signal2Noise_module.cc.

double Signal2Noise::trkhitx[kMaxHits][3][kMaxHits]
private

Definition at line 148 of file Signal2Noise_module.cc.

double Signal2Noise::trkhity[kMaxHits][3][kMaxHits]
private

Definition at line 149 of file Signal2Noise_module.cc.

double Signal2Noise::trkhitz[kMaxHits][3][kMaxHits]
private

Definition at line 150 of file Signal2Noise_module.cc.

int Signal2Noise::trkid[kMaxTracks]
private

Definition at line 131 of file Signal2Noise_module.cc.

float Signal2Noise::trklen[kMaxTracks]
private

Definition at line 134 of file Signal2Noise_module.cc.

float Signal2Noise::trkstart[kMaxTracks][3]
private

Definition at line 132 of file Signal2Noise_module.cc.

float Signal2Noise::trkstartcosxyz[kMaxTracks][3]
private

Definition at line 137 of file Signal2Noise_module.cc.

float Signal2Noise::trkt[kMaxTracks][3][kMaxHits]
private

Definition at line 145 of file Signal2Noise_module.cc.

float Signal2Noise::trkthetaxz[kMaxTracks]
private

Definition at line 135 of file Signal2Noise_module.cc.

float Signal2Noise::trkthetayz[kMaxTracks]
private

Definition at line 136 of file Signal2Noise_module.cc.

float Signal2Noise::trkx[kMaxTracks][3][kMaxHits]
private

Definition at line 144 of file Signal2Noise_module.cc.

int Signal2Noise::wireid[kMaxTracks][kMaxHits]
private

Definition at line 152 of file Signal2Noise_module.cc.

int Signal2Noise::year_month_date
private

Definition at line 126 of file Signal2Noise_module.cc.


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