CloseInTime_module.cc
Go to the documentation of this file.
1 
2 ////////////////////////////////////////////////////////////////////////
3 // Class: CloseInTime
4 // Module Type: analyzer
5 // File: CloseInTime_module.cc
6 ////////////////////////////////////////////////////////////////////////
7 // This is a very simple module to help determine cuts for the backtracker
8 // function CloseInTime. CloseInTime links cell hits with mc photon signals
9 // by determining if the hit and photon signals are in the same cell, plane,
10 // and reasonably close in time to eachother. This prevents one from counting
11 // photon signals from, for example, another hit later in time but in the
12 // same cell and plane.
13 //
14 // There are two constants to determine for each detector/timing resolution.
15 // The offset is approximately the mean of the histograms this module produces.
16 // The width is approximately the width of the distribution of the histograms.
17 // These constants should be looked at anytime a major change happens to our
18 // timing resolution or a new detector is added.
19 //
20 // For more information, please see docdb 9092 or contact Susan Lein.
21 ////////////////////////////////////////////////////////////////////////
22 #include "TH1.h"
23 
28 
29 #include "MCCheater/BackTracker.h"
30 #include "Geometry/Geometry.h"
31 #include "NovaDAQConventions/DAQConventions.h"
32 
33 namespace mcchk
34 {
36  {
37  public:
38  explicit CloseInTime(const fhicl::ParameterSet& p);
39  virtual ~CloseInTime();
40 
41  virtual void analyze(const art::Event& e);
42  virtual void reconfigure(fhicl::ParameterSet const & p);
43  virtual void beginRun(art::Run const &r);
44 
45  private:
46 
47  std::string fHitModuleLabel; ///< label for module making the hits
48  TH1D* fTimeDiff; ///< histogram of the difference between the time of photon signals in the cell and a cell hit's time
49  TH1D* fTimeExtend; ///< same as TimeDiff, but with an extend range to see the behavior of the tails
50  novadaq::cnv::DetId fDetID; ///< detector id, used to decide histogram extent
51 
52  };
53 
54 //-------------------------------------------------------------------
56  EDAnalyzer(p),
57  fTimeDiff(NULL),
58  fTimeExtend(NULL)
59  {
60  this->reconfigure(p);
61  }
62 
63 //-------------------------------------------------------------------
65  {
66  }
67 
68 //-------------------------------------------------------------------
70  {
71  // check that this is MC, stop if it isn't
73  if(!bt->HaveTruthInfo()){
74  mf::LogWarning("CloseInTime") << "attempting to run MC truth check on "
75  << "things without truth, bail";
76  return;
77  }
78 
79  // get all hits in the event
81  e.getByLabel(fHitModuleLabel, hithdl);
82 
84  for(size_t h = 0; h < hithdl->size(); ++h){
85  art::Ptr<rb::CellHit> hit(hithdl, h);
86  allhits.push_back(hit);
87  }
88 
89  for(size_t s = 0; s < allhits.size(); ++s){
90  if(bt->IsNoise(allhits[s])) continue;
91 
92  //Only look at hits with proper timing fit for FD, ND. NDOS never has good timing enabled.
93  if (!(allhits[s]->GoodTiming()) && !(fDetID == novadaq::cnv::kNDOS)) continue;
94 
95  double hitTime = allhits[s]->TNS();
96 
97  const std::vector<sim::PhotonSignal> photVec = bt->CellToPhotonSignal(allhits[s]->Plane(),allhits[s]->Cell());
98 
99  for(size_t j = 0; j < photVec.size(); ++j){
100  double photTime = photVec[j].TimeMean();
101  fTimeDiff->Fill(photTime-hitTime);
102  fTimeExtend->Fill(photTime-hitTime);
103  }//End of loop over photon signals
104  }//End of loop over all hits
105 
106  }// end analyze
107 
108 //-------------------------------------------------------------------
110  {
111  fHitModuleLabel = p.get< std::string >("HitModuleLabel" );
112  }
113 
114 
115  //-------------------------------------------------------------------
117  {
118  if (!fTimeDiff){
121  fDetID = geom->DetId();
122 
123  if (fDetID == novadaq::cnv::kNDOS){fTimeDiff = tfs->make<TH1D>("TimeDiff",";Photon Time - Hit TNS;Hits",100, -800, 2000);}
124  else {fTimeDiff = tfs->make<TH1D>("TimeDiff",";Photon Time - Hit TNS;Hits",100, -750, 750);}
125 
126  fTimeExtend = tfs->make<TH1D>("TimeExtend",";Photon Time - Hit TNS;Hits",1000, -10000, 10000);
127  }//End of loop to only define histograms once per job
128  }
129 
131 
132 }// end namespace mcchk
std::string fHitModuleLabel
label for module making the hits
back track the reconstruction to the simulation
virtual void analyze(const art::Event &e)
Simple module to analyze MC cosmics distributions.
const char * p
Definition: xmltok.h:285
TH1D * fTimeDiff
histogram of the difference between the time of photon signals in the cell and a cell hit&#39;s time ...
DEFINE_ART_MODULE(TestTMapFile)
TH1D * fTimeExtend
same as TimeDiff, but with an extend range to see the behavior of the tails
bool IsNoise(const art::Ptr< rb::CellHit > &hit) const
Is this hit not associated with any particles?
Definition: Run.h:31
novadaq::cnv::DetId fDetID
detector id, used to decide histogram extent
const XML_Char * s
Definition: expat.h:262
void push_back(Ptr< U > const &p)
Definition: PtrVector.h:441
virtual void beginRun(art::Run const &r)
Prototype Near Detector on the surface at FNAL.
T get(std::string const &key) const
Definition: ParameterSet.h:231
novadaq::cnv::DetId DetId() const
Prefer ds::DetectorService::DetId() instead.
Definition: GeometryBase.h:243
virtual void reconfigure(fhicl::ParameterSet const &p)
const double j
Definition: BetheBloch.cxx:29
CloseInTime(const fhicl::ParameterSet &p)
EDAnalyzer(Table< Config > const &config)
Definition: EDAnalyzer.h:100
size_type size() const
Definition: PtrVector.h:308
const std::vector< sim::PhotonSignal > CellToPhotonSignal(unsigned int const &plane, unsigned int const &cell) const
Returns the PhotonSignals contributing the signal in the specified cell. WARNING: Use with extreme ca...
T * make(ARGS...args) const
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
Definition: DataViewImpl.h:344
Definition: structs.h:12
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
void geom(int which=0)
Definition: geom.C:163
bool HaveTruthInfo() const
Is this a file with truth info in? (Is BackTracker going to be any use to you?)
Definition: BackTracker.h:133
TRandom3 r(0)
Float_t e
Definition: plot.C:35
Encapsulate the geometry of one entire detector (near, far, ndos)
enum BeamMode string