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

Public Member Functions

 EMEnergyCalib (fhicl::ParameterSet const &pset)
 
void analyze (art::Event const &evt)
 
void reconfigure (fhicl::ParameterSet const &p)
 
void reset ()
 
int FindTrackID (detinfo::DetectorClocksData const &clockData, art::Ptr< recob::Hit > const &hit)
 
- 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 Attributes

TTree * fTree
 
double trueEnergy
 
double depositU
 
double depositV
 
double depositZ
 
double correctedChargeU
 
double correctedChargeV
 
double correctedChargeZ
 
double vertexDetectorDist
 
int nhits
 
int hit_tpc [kMaxHits]
 
int hit_plane [kMaxHits]
 
int hit_wire [kMaxHits]
 
int hit_channel [kMaxHits]
 
double hit_peakT [kMaxHits]
 
double hit_charge [kMaxHits]
 
int hit_truetrackid [kMaxHits]
 
int hit_clusterid [kMaxHits]
 
std::string fHitsModuleLabel
 
std::string fClusterModuleLabel
 
art::ServiceHandle< art::TFileService > tfs
 
art::ServiceHandle< cheat::BackTrackerServicebacktracker
 
art::ServiceHandle< cheat::ParticleInventoryServiceparticleinventory
 
art::ServiceHandle< geo::Geometrygeom
 

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 65 of file EMEnergyCalib_module.cc.

Constructor & Destructor Documentation

emshower::EMEnergyCalib::EMEnergyCalib ( fhicl::ParameterSet const &  pset)

Definition at line 106 of file EMEnergyCalib_module.cc.

106  : EDAnalyzer(pset)
107 {
108  this->reconfigure(pset);
109  fTree = tfs->make<TTree>("EMEnergyCalib","EMEnergyCalib");
110  fTree->Branch("TrueEnergy", &trueEnergy);
111  fTree->Branch("DepositU", &depositU);
112  fTree->Branch("DepositV", &depositV);
113  fTree->Branch("DepositZ", &depositZ);
114  fTree->Branch("CorrectedChargeU", &correctedChargeU);
115  fTree->Branch("CorrectedChargeV", &correctedChargeV);
116  fTree->Branch("CorrectedChargeZ", &correctedChargeZ);
117  fTree->Branch("VertexDetectorDist",&vertexDetectorDist);
118  fTree->Branch("NHits", &nhits);
119  fTree->Branch("Hit_TPC", hit_tpc, "hit_tpc[NHits]/I");
120  fTree->Branch("Hit_Plane", hit_plane, "hit_plane[NHits]/I");
121  fTree->Branch("Hit_Wire", hit_wire, "hit_wire[NHits]/I");
122  fTree->Branch("Hit_Channel", hit_channel, "hit_channel[NHits]/I");
123  fTree->Branch("Hit_PeakT", hit_peakT, "hit_peakT[NHits]/D");
124  fTree->Branch("Hit_Charge", hit_charge, "hit_charge[NHits]/D");
125  fTree->Branch("Hit_TrueTrackID", hit_truetrackid,"hit_truetrackid[NHits]/I");
126  fTree->Branch("Hit_ClusterID", hit_clusterid, "hit_clusterid[NHits]/I");
127 }
EDAnalyzer(fhicl::ParameterSet const &pset)
Definition: EDAnalyzer.h:25
art::ServiceHandle< art::TFileService > tfs
void reconfigure(fhicl::ParameterSet const &p)

Member Function Documentation

void emshower::EMEnergyCalib::analyze ( art::Event const &  evt)
virtual

Analyse function to save information for calibrating shower energies This is written assuming single particle per event

Implements art::EDAnalyzer.

Definition at line 134 of file EMEnergyCalib_module.cc.

134  {
135 
136  /// Analyse function to save information for calibrating shower energies
137  /// This is written assuming single particle per event
138 
139  this->reset();
140 
141  // Get the hits out of the event record
142  std::vector<art::Ptr<recob::Hit> > hits;
143  auto hitHandle = evt.getHandle<std::vector<recob::Hit> >(fHitsModuleLabel);
144  if (hitHandle)
145  art::fill_ptr_vector(hits, hitHandle);
146 
147  // Get the clusters out of the event record
148  std::vector<art::Ptr<recob::Cluster> > clusters;
149  auto clusterHandle = evt.getHandle<std::vector<recob::Cluster> >(fClusterModuleLabel);
150  if (clusterHandle)
151  art::fill_ptr_vector(clusters, clusterHandle);
152 
153  art::FindManyP<recob::Cluster> fmc(hitHandle, evt, fClusterModuleLabel);
154 
155  // Lifetime-corrected charge
156  correctedChargeU = 0;
157  correctedChargeV = 0;
158  correctedChargeZ = 0;
159 
160  // Look at the hits
161  auto const clockData = art::ServiceHandle<detinfo::DetectorClocksService const>()->DataFor(evt);
162  auto const detProp = art::ServiceHandle<detinfo::DetectorPropertiesService const>()->DataFor(evt, clockData);
163  for (unsigned int hitIt = 0; hitIt < hits.size(); ++hitIt) {
164 
165  if (hitIt >= kMaxHits) continue;
166 
167  // Get the hit
168  art::Ptr<recob::Hit> hit = hits.at(hitIt);
169 
170  double correctedHitCharge = ( hit->Integral() * TMath::Exp( (sampling_rate(clockData) * hit->PeakTime()) / (detProp.ElectronLifetime()*1e3) ) );
171  switch (hit->WireID().Plane) {
172  case 0:
173  correctedChargeU += correctedHitCharge;
174  break;
175  case 1:
176  correctedChargeV += correctedHitCharge;
177  break;
178  case 2:
179  correctedChargeZ += correctedHitCharge;
180  break;
181  }
182 
183  // Fill hit level info
184  hit_tpc [hitIt] = hit->WireID().TPC;
185  hit_plane [hitIt] = hit->WireID().Plane;
186  hit_wire [hitIt] = hit->WireID().Wire;
187  hit_peakT [hitIt] = hit->PeakTime();
188  hit_charge [hitIt] = hit->Integral();
189  hit_channel [hitIt] = hit->Channel();
190 
191  // Find the true track this hit is associated with
192  hit_truetrackid[hitIt] = this->FindTrackID(clockData, hit);
193 
194  // Find the cluster index this hit it associated with (-1 if unclustered)
195  if (fmc.isValid()) {
196  std::vector<art::Ptr<recob::Cluster> > clusters = fmc.at(hitIt);
197  if (clusters.size() != 0) {
198  hit_clusterid[hitIt] = clusters.at(0)->ID();
199  }
200  else hit_clusterid[hitIt] = -1;
201  }
202 
203  }
204 
205  // Event level information
206 
207  nhits = hits.size();
208 
209  const sim::ParticleList& trueParticles = particleinventory->ParticleList();
210  const simb::MCParticle* trueParticle = trueParticles.Primary(0);
211 
212  trueEnergy = trueParticle->Momentum().E();
213 
214  // Find the energy deposited on each plane in the TPC
215  const std::vector<art::Ptr< sim::SimChannel > >& simChannels = backtracker->SimChannels();
216  for (auto channelIt = simChannels.begin(); channelIt != simChannels.end(); ++channelIt) {
217  int plane = geom->View((*channelIt)->Channel());
218  for (auto const& tdcIt : (*channelIt)->TDCIDEMap()) {
219  for (auto const& ideIt : tdcIt.second) {
220  switch (plane) {
221  case geo::kU:
222  depositU += ideIt.energy;
223  break;
224  case geo::kV:
225  depositV += ideIt.energy;
226  break;
227  case geo::kZ:
228  depositZ += ideIt.energy;
229  break;
230  }
231  }
232  }
233  }
234 
235  // Find the distance between the particle vertex and the edge of the detector
236  TVector3 vertex = TVector3(trueParticle->Vx(),trueParticle->Vy(),trueParticle->Vz());
237  TVector3 end = TVector3(trueParticle->EndX(),trueParticle->EndY(),trueParticle->EndZ());
238  TVector3 direction = TVector3(trueParticle->Px(),trueParticle->Py(),trueParticle->Pz()).Unit();
239 
240  int distanceStep = 1, steps = 0;
241  TVector3 pos;
242  bool inTPC = true;
243  while (inTPC) {
244  pos = end + ( (steps*distanceStep) * direction );
245  double currentPos[3]; currentPos[0] = pos.X(); currentPos[1] = pos.Y(); currentPos[2] = pos.Z();
246  if (!geom->FindTPCAtPosition(currentPos).isValid)
247  inTPC = false;
248  ++steps;
249  }
250  vertexDetectorDist = (end - pos).Mag();
251 
252  // Put energies in GeV units
253  depositU /= 1000;
254  depositV /= 1000;
255  depositZ /= 1000;
256 
257  fTree->Fill();
258 
259  return;
260 
261 }
end
while True: pbar.update(maxval-len(onlies[E][S])) #print iS, "/", len(onlies[E][S]) found = False for...
double Py(const int i=0) const
Definition: MCParticle.h:231
double EndZ() const
Definition: MCParticle.h:228
art::ServiceHandle< cheat::ParticleInventoryService > particleinventory
Planes which measure V.
Definition: geo_types.h:130
geo::WireID WireID() const
Definition: Hit.h:233
bool isValid
Whether this ID points to a valid element.
Definition: geo_types.h:211
double Px(const int i=0) const
Definition: MCParticle.h:230
Planes which measure Z direction.
Definition: geo_types.h:132
float Integral() const
Integral under the calibrated signal waveform of the hit, in tick x ADC units.
Definition: Hit.h:224
WireID_t Wire
Index of the wire within its plane.
Definition: geo_types.h:580
int FindTrackID(detinfo::DetectorClocksData const &clockData, art::Ptr< recob::Hit > const &hit)
double EndY() const
Definition: MCParticle.h:227
geo::TPCID FindTPCAtPosition(double const worldLoc[3]) const
Returns the ID of the TPC at specified location.
art::ServiceHandle< cheat::BackTrackerService > backtracker
const int kMaxHits
Planes which measure U.
Definition: geo_types.h:129
PlaneID_t Plane
Index of the plane within its TPC.
Definition: geo_types.h:493
View_t View(geo::PlaneID const &pid) const
Returns the view (wire orientation) on the channels of specified TPC plane.
Detector simulation of raw signals on wires.
const sim::ParticleList & ParticleList() const
double Vx(const int i=0) const
Definition: MCParticle.h:221
float PeakTime() const
Time of the signal peak, in tick units.
Definition: Hit.h:218
const TLorentzVector & Momentum(const int i=0) const
Definition: MCParticle.h:220
double Pz(const int i=0) const
Definition: MCParticle.h:232
double Vz(const int i=0) const
Definition: MCParticle.h:223
const std::vector< art::Ptr< sim::SimChannel > > & SimChannels() const
TCEvent evt
Definition: DataStructs.cxx:7
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
double EndX() const
Definition: MCParticle.h:226
double sampling_rate(DetectorClocksData const &data)
Returns the period of the TPC readout electronics clock.
art::ServiceHandle< geo::Geometry > geom
raw::ChannelID_t Channel() const
ID of the readout channel the hit was extracted from.
Definition: Hit.h:230
double Vy(const int i=0) const
Definition: MCParticle.h:222
vertex reconstruction
int emshower::EMEnergyCalib::FindTrackID ( detinfo::DetectorClocksData const &  clockData,
art::Ptr< recob::Hit > const &  hit 
)

Definition at line 263 of file EMEnergyCalib_module.cc.

264  {
265  double particleEnergy = 0;
266  int likelyTrackID = 0;
267  std::vector<sim::TrackIDE> trackIDs = backtracker->HitToTrackIDEs(clockData, hit);
268  for (unsigned int idIt = 0; idIt < trackIDs.size(); ++idIt) {
269  if (trackIDs.at(idIt).energy > particleEnergy) {
270  particleEnergy = trackIDs.at(idIt).energy;
271  likelyTrackID = TMath::Abs(trackIDs.at(idIt).trackID);
272  }
273  }
274  return likelyTrackID;
275 }
std::vector< sim::TrackIDE > HitToTrackIDEs(detinfo::DetectorClocksData const &clockData, recob::Hit const &hit) const
art::ServiceHandle< cheat::BackTrackerService > backtracker
void emshower::EMEnergyCalib::reconfigure ( fhicl::ParameterSet const &  p)

Definition at line 129 of file EMEnergyCalib_module.cc.

129  {
130  fHitsModuleLabel = pset.get<std::string>("HitsModuleLabel");
131  fClusterModuleLabel = pset.get<std::string>("ClusterModuleLabel");
132 }
std::string string
Definition: nybbler.cc:12
void emshower::EMEnergyCalib::reset ( )

Definition at line 277 of file EMEnergyCalib_module.cc.

277  {
278  trueEnergy = 0;
279  depositU = 0;
280  depositV = 0;
281  depositZ = 0;
282  vertexDetectorDist = 0;
283  nhits = 0;
284  for (int hit = 0; hit < kMaxHits; ++hit) {
285  hit_tpc[hit] = 0;
286  hit_plane[hit] = 0;
287  hit_wire[hit] = 0;
288  hit_channel[hit] = 0;
289  hit_peakT[hit] = 0;
290  hit_charge[hit] = 0;
291  hit_clusterid[hit] = 0;
292  }
293 }
const int kMaxHits
Detector simulation of raw signals on wires.

Member Data Documentation

art::ServiceHandle<cheat::BackTrackerService> emshower::EMEnergyCalib::backtracker
private

Definition at line 100 of file EMEnergyCalib_module.cc.

double emshower::EMEnergyCalib::correctedChargeU
private

Definition at line 83 of file EMEnergyCalib_module.cc.

double emshower::EMEnergyCalib::correctedChargeV
private

Definition at line 84 of file EMEnergyCalib_module.cc.

double emshower::EMEnergyCalib::correctedChargeZ
private

Definition at line 85 of file EMEnergyCalib_module.cc.

double emshower::EMEnergyCalib::depositU
private

Definition at line 80 of file EMEnergyCalib_module.cc.

double emshower::EMEnergyCalib::depositV
private

Definition at line 81 of file EMEnergyCalib_module.cc.

double emshower::EMEnergyCalib::depositZ
private

Definition at line 82 of file EMEnergyCalib_module.cc.

std::string emshower::EMEnergyCalib::fClusterModuleLabel
private

Definition at line 98 of file EMEnergyCalib_module.cc.

std::string emshower::EMEnergyCalib::fHitsModuleLabel
private

Definition at line 97 of file EMEnergyCalib_module.cc.

TTree* emshower::EMEnergyCalib::fTree
private

Definition at line 78 of file EMEnergyCalib_module.cc.

art::ServiceHandle<geo::Geometry> emshower::EMEnergyCalib::geom
private

Definition at line 102 of file EMEnergyCalib_module.cc.

int emshower::EMEnergyCalib::hit_channel[kMaxHits]
private

Definition at line 91 of file EMEnergyCalib_module.cc.

double emshower::EMEnergyCalib::hit_charge[kMaxHits]
private

Definition at line 93 of file EMEnergyCalib_module.cc.

int emshower::EMEnergyCalib::hit_clusterid[kMaxHits]
private

Definition at line 95 of file EMEnergyCalib_module.cc.

double emshower::EMEnergyCalib::hit_peakT[kMaxHits]
private

Definition at line 92 of file EMEnergyCalib_module.cc.

int emshower::EMEnergyCalib::hit_plane[kMaxHits]
private

Definition at line 89 of file EMEnergyCalib_module.cc.

int emshower::EMEnergyCalib::hit_tpc[kMaxHits]
private

Definition at line 88 of file EMEnergyCalib_module.cc.

int emshower::EMEnergyCalib::hit_truetrackid[kMaxHits]
private

Definition at line 94 of file EMEnergyCalib_module.cc.

int emshower::EMEnergyCalib::hit_wire[kMaxHits]
private

Definition at line 90 of file EMEnergyCalib_module.cc.

int emshower::EMEnergyCalib::nhits
private

Definition at line 87 of file EMEnergyCalib_module.cc.

art::ServiceHandle<cheat::ParticleInventoryService> emshower::EMEnergyCalib::particleinventory
private

Definition at line 101 of file EMEnergyCalib_module.cc.

art::ServiceHandle<art::TFileService> emshower::EMEnergyCalib::tfs
private

Definition at line 99 of file EMEnergyCalib_module.cc.

double emshower::EMEnergyCalib::trueEnergy
private

Definition at line 79 of file EMEnergyCalib_module.cc.

double emshower::EMEnergyCalib::vertexDetectorDist
private

Definition at line 86 of file EMEnergyCalib_module.cc.


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