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

Public Member Functions

 ProtoDUNEelectronWireAna (fhicl::ParameterSet const &p)
 
 ProtoDUNEelectronWireAna (ProtoDUNEelectronWireAna const &)=delete
 
 ProtoDUNEelectronWireAna (ProtoDUNEelectronWireAna &&)=delete
 
ProtoDUNEelectronWireAnaoperator= (ProtoDUNEelectronWireAna const &)=delete
 
ProtoDUNEelectronWireAnaoperator= (ProtoDUNEelectronWireAna &&)=delete
 
void analyze (art::Event const &evt) 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 Initialize ()
 

Private Attributes

protoana::ProtoDUNEPFParticleUtils pfpUtil
 
protoana::ProtoDUNEShowerUtils showerUtil
 
protoana::ProtoDUNETruthUtils truthUtil
 
geo::GeometryCore const * fGeometry = &*(art::ServiceHandle<geo::Geometry>())
 
std::string fShowerTag
 
std::string fPFParticleTag
 
std::string fWireTag
 
TTree * fTree
 
unsigned int frun
 
unsigned int fsubrun
 
unsigned int fevent
 
std::vector< int > fprimary_Shower_wire_w
 
std::vector< float > fprimary_Shower_wire_ch
 
std::vector< float > fprimary_Shower_wire_X
 
std::vector< float > fprimary_Shower_wire_Z
 
std::vector< float > fprimary_Shower_wire_Y
 
std::vector< float > fprimary_Shower_MCwire_E
 
std::vector< int > fprimary_Shower_MCwire_w
 
float fprimaryStartPosition [3]
 

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 54 of file ProtoDUNEelectronWireAna_module.cc.

Constructor & Destructor Documentation

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

Definition at line 119 of file ProtoDUNEelectronWireAna_module.cc.

120  : EDAnalyzer{p},
121  fShowerTag(p.get<std::string>("ShowerTag")),
122  fPFParticleTag(p.get<std::string>("PFParticleTag")),
123  fWireTag(p.get<std::string>("WireTag"))
124 {
125  // Call appropriate consumes<>() for any products to be retrieved by this module.
126 }
std::string string
Definition: nybbler.cc:12
EDAnalyzer(fhicl::ParameterSet const &pset)
Definition: EDAnalyzer.h:25
p
Definition: test.py:223
ProtoDUNEelectronWireAna::ProtoDUNEelectronWireAna ( ProtoDUNEelectronWireAna const &  )
delete
ProtoDUNEelectronWireAna::ProtoDUNEelectronWireAna ( ProtoDUNEelectronWireAna &&  )
delete

Member Function Documentation

void ProtoDUNEelectronWireAna::analyze ( art::Event const &  evt)
overridevirtual

Implements art::EDAnalyzer.

Definition at line 128 of file ProtoDUNEelectronWireAna_module.cc.

129 {
130 
131  Initialize();
132  frun = evt.run();
133  fsubrun = evt.subRun();
134  fevent = evt.id().event();
135 
136  //check for reco pandora stuff
137  auto recoParticleHandle = evt.getHandle<std::vector<recob::PFParticle>>(fPFParticleTag);
138  if( !recoParticleHandle ) return;
139 
140  //std::vector<int> hit_w;
141  std::map<int,std::vector<double>> hit_w_and_t1;
142  std::map<int,std::vector<double>> hit_w_and_t2;
143  std::map<int,std::vector<double>> hit_w_and_y;
144  std::map<int,std::vector<double>> hit_w_and_x;
145  std::vector<const recob::PFParticle*> pfParticles = pfpUtil.GetPFParticlesFromBeamSlice(evt,fPFParticleTag);
146  const simb::MCParticle* mcparticle = NULL;
147  bool doAna = false;
148  auto const clockData = art::ServiceHandle<detinfo::DetectorClocksService>()->DataFor(evt);
149  auto const detProp = art::ServiceHandle<detinfo::DetectorPropertiesService>()->DataFor(evt, clockData);
150  for(const recob::PFParticle* particle : pfParticles){
151  const recob::Shower* thisShower = pfpUtil.GetPFParticleShower(*particle,evt,fPFParticleTag,fShowerTag);
152  if( thisShower == 0x0 ) continue;
153  if( !evt.isRealData() ){
154  mcparticle = truthUtil.GetMCParticleFromRecoShower(clockData, *thisShower, evt, "pandoraShower");
155  if( abs(mcparticle->PdgCode()) != 11 ) return;
156  }
157  fprimaryStartPosition[0] = thisShower->ShowerStart().X();
158  fprimaryStartPosition[1] = thisShower->ShowerStart().Y();
159  fprimaryStartPosition[2] = thisShower->ShowerStart().Z();
160  doAna = true;
161  const std::vector<const recob::Hit*> sh_hits = showerUtil.GetRecoShowerHits(*thisShower, evt, fShowerTag);
162  art::FindManyP<recob::Wire> wFromHits(sh_hits,evt,"hitpdune");
163  art::FindManyP<recob::SpacePoint> spFromShowerHits(sh_hits,evt,fPFParticleTag);
164  for( size_t j=0; j<sh_hits.size() && j<MAXHits; ++j){
165  if( sh_hits[j]->WireID().Plane != 2 ) continue;
166  std::vector<art::Ptr<recob::Wire>> wires = wFromHits.at(j);
167  //hit_w.push_back(wires[0]->Channel());
168  hit_w_and_t1[wires[0]->Channel()].push_back(sh_hits[j]->PeakTimeMinusRMS(5.0));
169  hit_w_and_t2[wires[0]->Channel()].push_back(sh_hits[j]->PeakTimePlusRMS(5.0));
170  //std::cout<<wires[0]->Channel()<<" "<<sh_hits[j]->PeakTime()<<" "<<sh_hits[j]->PeakTimePlusRMS(5.0)<<" "<<sh_hits[j]->PeakTimeMinusRMS(5.0)<<std::endl;
171  hit_w_and_x[wires[0]->Channel()].push_back(detProp.ConvertTicksToX(sh_hits[j]->PeakTime(),sh_hits[j]->WireID().Plane,sh_hits[j]->WireID().TPC,0));
172  std::vector<art::Ptr<recob::SpacePoint>> sp = spFromShowerHits.at(j);
173  if(!sp.empty()){
174  hit_w_and_y[wires[0]->Channel()].push_back(sp[0]->XYZ()[1]);
175  }
176  else hit_w_and_y[wires[0]->Channel()].push_back(fprimaryStartPosition[1]); //use vtx if no sp
177  }
178  break;
179  }
180 
181  //one wire can have various hits so lets remove duplicate wires
182  //std::sort(hit_w.begin(),hit_w.end());
183  //hit_w.erase(std::unique(hit_w.begin(),hit_w.end()), hit_w.end());
184 
185  if( doAna ){
186  auto const& wires = evt.getValidHandle<std::vector<recob::Wire> >(fWireTag);
187  //auto const& wires = evt.getValidHandle<std::vector<recob::Wire> >("wclsdatasp:gauss"); //new reco
188  auto w1 = hit_w_and_t1.begin();
189  auto w2 = hit_w_and_t2.begin();
190  auto x = hit_w_and_x.begin();
191  auto y = hit_w_and_y.begin();
192  while( w1 != hit_w_and_t1.end()){
193  int it_w = w1->first;
194  int n_hits = w1->second.size();
195  // std::cout<<it_w<<" "<<n_hits<<" "<<w1->second[n_hits-1]<<" "<<w2->second[n_hits-1]<<std::endl;
196  double t1 = w1->second[0]; //first hit
197  double t2 = w2->second[n_hits-1]; //last hit
198  double x_w, y_w;
199  if( x->second.size() < 1 ){
200  x_w = (x->second[0]-x->second[n_hits-1])/2.0;
201  y_w = (y->second[0]-y->second[n_hits-1])/2.0;
202  }
203  else {
204  x_w = x->second[0];
205  y_w = y->second[0];
206  }
207  for(auto & wire : * wires){
208  int channel_no = wire.Channel();
209  int plane = fGeometry->View(wire.Channel());
210  if( plane != 2 ) continue;
211  std::vector< geo::WireID > wireID= fGeometry->ChannelToWire(channel_no);
212  const geo::WireGeo* pwire = fGeometry->WirePtr(wireID.at(0)); //for collection plane there is one wire per channel
213  TVector3 xyzWire = pwire->GetCenter<TVector3>();
214  if( it_w == channel_no ){
215  double charge =0.0;
216  for(size_t i = 0; i < wire.Signal().size(); ++i){
217  if( i > t1 && i < t2 ) charge += wire.Signal()[i];
218  }
219  fprimary_Shower_wire_Z.push_back(xyzWire.Z());
220  fprimary_Shower_wire_Y.push_back(y_w);
221  fprimary_Shower_wire_X.push_back(x_w);
222  fprimary_Shower_wire_ch.push_back(charge);
223  fprimary_Shower_wire_w.push_back(channel_no);
224 
225  break;
226  }
227  }// all recob::wire
228  w1 ++; w2 ++;
229  x ++; y ++;
230  }//wire from shower
231 
232  //look at MC info if available
233  if(!evt.isRealData()){
234  auto mcTruths = evt.getValidHandle<std::vector<simb::MCTruth>>("generator");
235  const simb::MCParticle* geantGoodParticle = truthUtil.GetGeantGoodParticle((*mcTruths)[0],evt);
236  int trackid = mcparticle->TrackId();
237  if( mcparticle->TrackId() == geantGoodParticle->TrackId() ){
238  if( doAna ){ //we have a reco shower
239  auto simchannelHandle = evt.getHandle< std::vector<sim::SimChannel> >("largeant");
240  if (simchannelHandle){
241  for(auto const& simchannel : (*simchannelHandle)){
242  if(fGeometry->View(simchannel.Channel()) != 2) continue;
243  auto const& alltimeslices = simchannel.TDCIDEMap();
244  double EperCh=0;
245  for(auto const& tslice : alltimeslices){
246  auto const& simide = tslice.second;
247  // Loop over energy deposits
248  for(auto const& eDep : simide){
249  if(eDep.trackID == trackid || eDep.trackID == -trackid){
250  EperCh += eDep.energy;
251  }
252  }
253  }
254  if( EperCh== 0 ) continue;//save only channeles with ID
255  fprimary_Shower_MCwire_w.push_back(simchannel.Channel());
256  fprimary_Shower_MCwire_E.push_back(EperCh);
257  }
258  }
259  }//do analysis of MC
260  }//is MC same as beam?
261  }//is MC?
262  }//shower
263 
264 
265  fTree->Fill();
266 }
Geometry description of a TPC wireThe wire is a single straight segment on a wire plane...
Definition: WireGeo.h:65
const TVector3 & ShowerStart() const
Definition: Shower.h:192
const std::vector< const recob::Hit * > GetRecoShowerHits(const recob::Shower &shower, art::Event const &evt, const std::string showerModule) const
Get the hits from a given reco shower.
int PdgCode() const
Definition: MCParticle.h:212
unsigned int event
Definition: DataStructs.h:636
const simb::MCParticle * GetGeantGoodParticle(const simb::MCTruth &genTruth, const art::Event &evt) const
unsigned int run
Definition: DataStructs.h:637
const recob::Shower * GetPFParticleShower(const recob::PFParticle &particle, art::Event const &evt, const std::string particleLabel, const std::string showerLabel) const
Get the shower associated to this particle. Returns a null pointer if not found.
std::vector< geo::WireID > ChannelToWire(raw::ChannelID_t const channel) const
Returns a list of wires connected to the specified TPC channel.
protoana::ProtoDUNETruthUtils truthUtil
int TrackId() const
Definition: MCParticle.h:210
T abs(T value)
IDparameter< geo::WireID > WireID
Member type of validated geo::WireID parameter.
const std::vector< const recob::PFParticle * > GetPFParticlesFromBeamSlice(art::Event const &evt, const std::string particleLabel) const
Return the pointers for the PFParticles in the beam slice. Returns an empty vector is no beam slice w...
View_t View(geo::PlaneID const &pid) const
Returns the view (wire orientation) on the channels of specified TPC plane.
Hierarchical representation of particle flow.
Definition: PFParticle.h:44
unsigned int subRun
Definition: DataStructs.h:638
protoana::ProtoDUNEPFParticleUtils pfpUtil
list x
Definition: train.py:276
void GetCenter(double *xyz, double localz=0.0) const
Fills the world coordinate of a point on the wire.
Definition: WireGeo.cxx:73
TCEvent evt
Definition: DataStructs.cxx:7
const simb::MCParticle * GetMCParticleFromRecoShower(detinfo::DetectorClocksData const &clockData, const recob::Shower &shower, art::Event const &evt, std::string showerModule) const
protoana::ProtoDUNEShowerUtils showerUtil
WireGeo const * WirePtr(geo::WireID const &wireid) const
Returns the specified wire.
void ProtoDUNEelectronWireAna::beginJob ( )
overridevirtual

Reimplemented from art::EDAnalyzer.

Definition at line 98 of file ProtoDUNEelectronWireAna_module.cc.

99 {
100 
102  fTree = tfs->make<TTree>("WireAna","Recob::Wire");
103  fTree->Branch("run",&frun,"run/I");
104  fTree->Branch("subrun",&fsubrun,"subrun/I");
105  fTree->Branch("event",&fevent,"event/I");
106 
107  fTree->Branch("primaryStartPosition", &fprimaryStartPosition, "primaryStartPosition[3]/f");
108  fTree->Branch("primary_Shower_wire_w",&fprimary_Shower_wire_w);
109  fTree->Branch("primary_Shower_wire_ch",&fprimary_Shower_wire_ch);
110  fTree->Branch("primary_Shower_wire_X",&fprimary_Shower_wire_X);
111  fTree->Branch("primary_Shower_wire_Z",&fprimary_Shower_wire_Z);
112  fTree->Branch("primary_Shower_wire_Y",&fprimary_Shower_wire_Y);
113  fTree->Branch("primary_Shower_MCwire_w",&fprimary_Shower_MCwire_w);
114  fTree->Branch("primary_Shower_MCwire_E",&fprimary_Shower_MCwire_E);
115 
116 }
void ProtoDUNEelectronWireAna::Initialize ( void  )
private

Definition at line 267 of file ProtoDUNEelectronWireAna_module.cc.

267  {
268  frun =-999;
269  fsubrun =-999;
270  fevent =-999;
271  fprimary_Shower_wire_w.clear();
272  fprimary_Shower_wire_Y.clear();
273  fprimary_Shower_wire_X.clear();
274  fprimary_Shower_wire_Z.clear();
275  fprimary_Shower_wire_ch.clear();
276  fprimary_Shower_MCwire_w.clear();
277  fprimary_Shower_MCwire_E.clear();
278  for(int k=0; k < 3; k++){
279  fprimaryStartPosition[k] = -999.0;
280  }
281 }
ProtoDUNEelectronWireAna& ProtoDUNEelectronWireAna::operator= ( ProtoDUNEelectronWireAna const &  )
delete
ProtoDUNEelectronWireAna& ProtoDUNEelectronWireAna::operator= ( ProtoDUNEelectronWireAna &&  )
delete

Member Data Documentation

unsigned int ProtoDUNEelectronWireAna::fevent
private

Definition at line 86 of file ProtoDUNEelectronWireAna_module.cc.

geo::GeometryCore const* ProtoDUNEelectronWireAna::fGeometry = &*(art::ServiceHandle<geo::Geometry>())
private

Definition at line 77 of file ProtoDUNEelectronWireAna_module.cc.

std::string ProtoDUNEelectronWireAna::fPFParticleTag
private

Definition at line 80 of file ProtoDUNEelectronWireAna_module.cc.

std::vector<float> ProtoDUNEelectronWireAna::fprimary_Shower_MCwire_E
private

Definition at line 93 of file ProtoDUNEelectronWireAna_module.cc.

std::vector<int> ProtoDUNEelectronWireAna::fprimary_Shower_MCwire_w
private

Definition at line 94 of file ProtoDUNEelectronWireAna_module.cc.

std::vector<float> ProtoDUNEelectronWireAna::fprimary_Shower_wire_ch
private

Definition at line 88 of file ProtoDUNEelectronWireAna_module.cc.

std::vector<int> ProtoDUNEelectronWireAna::fprimary_Shower_wire_w
private

Definition at line 87 of file ProtoDUNEelectronWireAna_module.cc.

std::vector<float> ProtoDUNEelectronWireAna::fprimary_Shower_wire_X
private

Definition at line 89 of file ProtoDUNEelectronWireAna_module.cc.

std::vector<float> ProtoDUNEelectronWireAna::fprimary_Shower_wire_Y
private

Definition at line 91 of file ProtoDUNEelectronWireAna_module.cc.

std::vector<float> ProtoDUNEelectronWireAna::fprimary_Shower_wire_Z
private

Definition at line 90 of file ProtoDUNEelectronWireAna_module.cc.

float ProtoDUNEelectronWireAna::fprimaryStartPosition[3]
private

Definition at line 95 of file ProtoDUNEelectronWireAna_module.cc.

unsigned int ProtoDUNEelectronWireAna::frun
private

Definition at line 84 of file ProtoDUNEelectronWireAna_module.cc.

std::string ProtoDUNEelectronWireAna::fShowerTag
private

Definition at line 79 of file ProtoDUNEelectronWireAna_module.cc.

unsigned int ProtoDUNEelectronWireAna::fsubrun
private

Definition at line 85 of file ProtoDUNEelectronWireAna_module.cc.

TTree* ProtoDUNEelectronWireAna::fTree
private

Definition at line 83 of file ProtoDUNEelectronWireAna_module.cc.

std::string ProtoDUNEelectronWireAna::fWireTag
private

Definition at line 81 of file ProtoDUNEelectronWireAna_module.cc.

protoana::ProtoDUNEPFParticleUtils ProtoDUNEelectronWireAna::pfpUtil
private

Definition at line 73 of file ProtoDUNEelectronWireAna_module.cc.

protoana::ProtoDUNEShowerUtils ProtoDUNEelectronWireAna::showerUtil
private

Definition at line 74 of file ProtoDUNEelectronWireAna_module.cc.

protoana::ProtoDUNETruthUtils ProtoDUNEelectronWireAna::truthUtil
private

Definition at line 75 of file ProtoDUNEelectronWireAna_module.cc.


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