Public Member Functions | Private Member Functions | Private Attributes | List of all members
hit::MagDriftAna Class Reference

Base class for creation of raw signals on wires. More...

Inheritance diagram for hit::MagDriftAna:
art::EDAnalyzer art::detail::Analyzer art::detail::LegacyModule art::Observer art::ModuleBase

Public Member Functions

 MagDriftAna (fhicl::ParameterSet const &pset)
 
- 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 analyze (const art::Event &evt) override
 
void endJob () override
 
void ensureHists (art::Event const &evt, detinfo::DetectorClocksData const &clockData)
 

Private Attributes

std::string fFFTHitFinderModuleLabel
 
std::string fLArG4ModuleLabel
 
bool initDone {false}
 
double fDirCosY {0.}
 
double fDirCosZ {0.}
 
TH1D * fChargeXpos {nullptr}
 
TH1D * fChargeYpos {nullptr}
 
TH1D * fChargeZpos {nullptr}
 
TH1D * fHitZpos {nullptr}
 
TH1D * fDriftDeltaZ {nullptr}
 
TH1D * fDeltaZoverX {nullptr}
 
TH2D * fDeltaZvsX {nullptr}
 
TH1D * fDriftDeltaZAway {nullptr}
 
TH1D * fDeltaZoverXAway {nullptr}
 

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

Base class for creation of raw signals on wires.

Definition at line 43 of file MagDriftAna_module.cc.

Constructor & Destructor Documentation

hit::MagDriftAna::MagDriftAna ( fhicl::ParameterSet const &  pset)
explicit

Definition at line 88 of file MagDriftAna_module.cc.

89  : EDAnalyzer(pset)
90  , fFFTHitFinderModuleLabel{pset.get<std::string>("HitsModuleLabel")}
91  , fLArG4ModuleLabel{pset.get<std::string>("LArGeantModuleLabel")}
92  {}
std::string string
Definition: nybbler.cc:12
std::string fLArG4ModuleLabel
std::string fFFTHitFinderModuleLabel
EDAnalyzer(fhicl::ParameterSet const &pset)
Definition: EDAnalyzer.h:25

Member Function Documentation

void hit::MagDriftAna::analyze ( const art::Event evt)
overrideprivate

Definition at line 193 of file MagDriftAna_module.cc.

194  {
195  if (evt.isRealData()) {
196  throw cet::exception("MagDriftAna: ") << "Not for use on Data yet...\n";
197  }
198 
199  auto const clockData = art::ServiceHandle<detinfo::DetectorClocksService const>()->DataFor(evt);
200 
201  ensureHists(evt, clockData);
202 
204  evt.getByLabel(fFFTHitFinderModuleLabel, hitHandle);
205 
207 
208  // We're going to want to compare the reconstructed Z with the
209  // simulted Z. For that purpose we use the simultion backtracking.
210 
212 
213  std::vector<art::Ptr<recob::Hit>> hits;
214  art::fill_ptr_vector(hits, hitHandle);
215 
216  geo::WireID hitWireID;
217 
218  //++++++++++
219  // Loop over the hits (data) and fill histos
220  //++++++++++
221  for (auto itr : hits) {
222 
223  hitWireID = itr->WireID();
224  // By assumption the drift occurs only in the z-direction, so
225  // we can get all the info we need from the z-measug plane.
226  if (hitWireID.Plane != (geom->Nplanes() - 1)) continue;
227 
228  // Charge collected at the wire
229  //
230  // Exactly once for each recob::Hit
231  double w0pos[3] = {0.};
232  geom->TPC(hitWireID.TPC).Plane(hitWireID.Plane).Wire(0).GetCenter(w0pos);
233  double HitZpos = w0pos[2] + hitWireID.Wire * geom->TPC(hitWireID.TPC).WirePitch();
234  double Charge = itr->Integral();
235  fHitZpos->Fill(HitZpos, Charge);
236 
237  // Charge deposition in the detector
238  std::vector<double> xyz = bt_serv->HitToXYZ(clockData, itr);
239  fChargeXpos->Fill(xyz[0], Charge);
240  fChargeYpos->Fill(xyz[1], Charge);
241  double ChargeZpos = xyz[2];
242  fChargeZpos->Fill(ChargeZpos, Charge);
243 
244  // Delta-Z
245  //
246  // Compares the collected z position from the wire to the
247  // simulated z position
248  double DeltaZ = HitZpos - ChargeZpos;
249  fDriftDeltaZ->Fill(DeltaZ, Charge);
250  // Delta Z correlation with X
251  fDeltaZoverX->Fill(DeltaZ / xyz[0], Charge);
252  fDeltaZvsX->Fill(xyz[0], DeltaZ, Charge);
253  // The X related histograms know the dimensions of the
254  // detector, so we use them to set the "away" limit
255  if (xyz[0] > (fChargeYpos->GetXaxis()->GetXmax() * 0.80)) {
256  fDriftDeltaZAway->Fill(DeltaZ, Charge);
257  fDeltaZoverXAway->Fill(DeltaZ / xyz[0], Charge);
258  }
259 
260  } // loop on Hits
261 
262  return;
263  } // end analyze method
WireGeo const & Wire(unsigned int iwire) const
Definition: PlaneGeo.cxx:506
std::string fFFTHitFinderModuleLabel
WireID_t Wire
Index of the wire within its plane.
Definition: geo_types.h:580
std::vector< double > HitToXYZ(detinfo::DetectorClocksData const &clockData, const recob::Hit &hit) const
bool isRealData() const
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
Definition: DataViewImpl.h:633
unsigned int Nplanes(unsigned int tpc=0, unsigned int cstat=0) const
Returns the total number of wire planes in the specified TPC.
double WirePitch(unsigned plane=0) const
Definition: TPCGeo.cxx:396
PlaneID_t Plane
Index of the plane within its TPC.
Definition: geo_types.h:493
void ensureHists(art::Event const &evt, detinfo::DetectorClocksData const &clockData)
constexpr WireID()=default
Default constructor: an invalid TPC ID.
TPCGeo const & TPC(unsigned int const tpc=0, unsigned int const cstat=0) const
Returns the specified TPC.
PlaneGeo const & Plane(geo::View_t view) const
Return the plane in the tpc with View_t view.
Definition: TPCGeo.cxx:263
void GetCenter(double *xyz, double localz=0.0) const
Fills the world coordinate of a point on the wire.
Definition: WireGeo.cxx:73
void fill_ptr_vector(std::vector< Ptr< T >> &ptrs, H const &h)
Definition: Ptr.h:297
TPCID_t TPC
Index of the TPC within its cryostat.
Definition: geo_types.h:406
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
void hit::MagDriftAna::endJob ( )
overrideprivatevirtual

Reimplemented from art::EDAnalyzer.

Definition at line 172 of file MagDriftAna_module.cc.

173  {
174  // Add a line on the deltaZ/X graph to denote the calculated value
175  // of the drift ration
176  TLine* l = new TLine(fDirCosZ, 0, fDirCosZ, 1.05 * fDeltaZoverX->GetMaximum());
177  l->SetLineColor(kRed);
178  l->SetLineStyle(kDotted);
179  fDeltaZoverX->GetListOfFunctions()->Add(l);
180 
181  // I know this looks like a memory leak, but each historgram needs
182  // it's own copy of the line to prevent double freeing by the
183  // framework...
184  l = new TLine(fDirCosZ, 0, fDirCosZ, 1.05 * fDeltaZoverX->GetMaximum());
185 
186  l->SetLineColor(kRed);
187  l->SetLineStyle(kDotted);
188  fDeltaZoverXAway->GetListOfFunctions()->Add(l);
189  }
static QStrList * l
Definition: config.cpp:1044
void hit::MagDriftAna::ensureHists ( art::Event const &  evt,
detinfo::DetectorClocksData const &  clockData 
)
private

Definition at line 96 of file MagDriftAna_module.cc.

97  {
98  if (initDone) return; // Bail if we've already done this.
99  initDone = true; // Insure that we bail later on
100 
102 
103  // Find magnetic field related corrections
104  auto const detProp =
106 
107  // art::ServiceHandle<mag::MagneticField const> MagField;
109  auto const* MagField = MagFieldHandle->provider();
110  double Efield = detProp.Efield();
111  double Temperature = detProp.Temperature();
112  double DriftVelocity = detProp.DriftVelocity(Efield, Temperature) / 1000.;
113 
114  // MagneticField::FieldAtPoint() returns (0, 0, 0) if there is no
115  // field at the requested point, so these direction cosines are
116  // 0 if there is no field
117  fDirCosY = -DriftVelocity * MagField->FieldAtPoint().z() / Efield;
118  fDirCosZ = +DriftVelocity * MagField->FieldAtPoint().y() / Efield;
119  MF_LOG_VERBATIM("MagDriftAna") << "Drift ratios: "
120  << "dY/dX = " << fDirCosY << ", "
121  << "dZ/dX = " << fDirCosZ;
122 
123  // geometry data.
125  // assumes all TPCs are the same
126  double width = 2 * geom->TPC(0).HalfWidth();
127  double halfHeight = geom->TPC(0).HalfHeight();
128  double length = geom->TPC(0).Length();
129 
130  double zScale = std::max(fDirCosZ / 2.0, 4e-4);
131 
132  // Assumes microboone dimensions. Ideally we'd fix this later...
133  fChargeXpos =
134  tfs->make<TH1D>("hChargeXpos", "MC X charge depositions; X (cm); Events", 101, 0.0, width);
135  fChargeYpos = tfs->make<TH1D>(
136  "hChargeYpos", "MC Y charge depositions; Y (cm); Events", 101, -halfHeight, halfHeight);
137  fChargeZpos =
138  tfs->make<TH1D>("hChargeZpos", "MC Z charge depositions; Z (cm); Events", 101, 0.0, length);
139  fHitZpos = tfs->make<TH1D>("hHitZpos", "Z charge collection; Z (cm); Events", 101, 0.0, length);
140 
141  fDriftDeltaZ = tfs->make<TH1D>("hDriftDeltaZ",
142  "Z drift of charge; delta Z (cm); Events",
143  101,
144  -5 * zScale * width,
145  5 * zScale * width);
146  fDeltaZoverX = tfs->make<TH1D>(
147  "hDeltaZoverX", "Z drift of charge; delta Z/X; Events", 51, -10 * zScale, 10 * zScale);
148  fDeltaZvsX = tfs->make<TH2D>("hDeltaZvsX",
149  "delta Z vs X; X (cm); delta Z (cm), Events",
150  51,
151  0.0,
152  width,
153  51,
154  -20 * zScale,
155  20 * zScale);
156 
157  // Some stats only when the Xdrift is large (more than 3/4)
158  fDriftDeltaZAway = tfs->make<TH1D>("hDriftDeltaZAway",
159  "Z drift of charge (long drift); delta Z (cm); Events",
160  101,
161  -5 * zScale * width,
162  5 * zScale * width);
163  fDeltaZoverXAway = tfs->make<TH1D>("hDeltaZoverXAway",
164  "Z drift of charge (long drift); delta Z/X; Events",
165  51,
166  -10 * zScale,
167  10 * zScale);
168  }
double Length() const
Length is associated with z coordinate [cm].
Definition: TPCGeo.h:115
const double e
static int max(int a, int b)
double HalfHeight() const
Height is associated with y coordinate [cm].
Definition: TPCGeo.h:111
#define MF_LOG_VERBATIM(category)
TPCGeo const & TPC(unsigned int const tpc=0, unsigned int const cstat=0) const
Returns the specified TPC.
TCEvent evt
Definition: DataStructs.cxx:7
double HalfWidth() const
Width is associated with x coordinate [cm].
Definition: TPCGeo.h:107

Member Data Documentation

TH1D* hit::MagDriftAna::fChargeXpos {nullptr}
private

Definition at line 70 of file MagDriftAna_module.cc.

TH1D* hit::MagDriftAna::fChargeYpos {nullptr}
private

Definition at line 71 of file MagDriftAna_module.cc.

TH1D* hit::MagDriftAna::fChargeZpos {nullptr}
private

Definition at line 72 of file MagDriftAna_module.cc.

TH1D* hit::MagDriftAna::fDeltaZoverX {nullptr}
private

Definition at line 77 of file MagDriftAna_module.cc.

TH1D* hit::MagDriftAna::fDeltaZoverXAway {nullptr}
private

Definition at line 83 of file MagDriftAna_module.cc.

TH2D* hit::MagDriftAna::fDeltaZvsX {nullptr}
private

Definition at line 78 of file MagDriftAna_module.cc.

double hit::MagDriftAna::fDirCosY {0.}
private

Definition at line 67 of file MagDriftAna_module.cc.

double hit::MagDriftAna::fDirCosZ {0.}
private

Definition at line 68 of file MagDriftAna_module.cc.

TH1D* hit::MagDriftAna::fDriftDeltaZ {nullptr}
private

Definition at line 76 of file MagDriftAna_module.cc.

TH1D* hit::MagDriftAna::fDriftDeltaZAway {nullptr}
private

Definition at line 82 of file MagDriftAna_module.cc.

std::string hit::MagDriftAna::fFFTHitFinderModuleLabel
private

Definition at line 58 of file MagDriftAna_module.cc.

TH1D* hit::MagDriftAna::fHitZpos {nullptr}
private

Definition at line 73 of file MagDriftAna_module.cc.

std::string hit::MagDriftAna::fLArG4ModuleLabel
private

Definition at line 59 of file MagDriftAna_module.cc.

bool hit::MagDriftAna::initDone {false}
private

Definition at line 64 of file MagDriftAna_module.cc.


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