Public Member Functions | Private Member Functions | Private Attributes | List of all members
gar::rec::CaloClusterCheater Class Reference
Inheritance diagram for gar::rec::CaloClusterCheater:
art::EDProducer art::detail::Producer art::detail::LegacyModule art::Modifier art::ModuleBase art::ProductRegistryHelper

Public Member Functions

 CaloClusterCheater (fhicl::ParameterSet const &pset)
 
 CaloClusterCheater (CaloClusterCheater const &)=delete
 
 CaloClusterCheater (CaloClusterCheater &&)=delete
 
CaloClusterCheateroperator= (CaloClusterCheater const &)=delete
 
CaloClusterCheateroperator= (CaloClusterCheater &&)=delete
 
void produce (art::Event &e) override
 
- Public Member Functions inherited from art::EDProducer
 EDProducer (fhicl::ParameterSet const &pset)
 
template<typename Config >
 EDProducer (Table< Config > const &config)
 
std::string workerType () const
 
- Public Member Functions inherited from art::detail::Producer
virtual ~Producer () noexcept
 
 Producer (fhicl::ParameterSet const &)
 
 Producer (Producer const &)=delete
 
 Producer (Producer &&)=delete
 
Produceroperator= (Producer const &)=delete
 
Produceroperator= (Producer &&)=delete
 
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::Modifier
 ~Modifier () noexcept
 
 Modifier ()
 
 Modifier (Modifier const &)=delete
 
 Modifier (Modifier &&)=delete
 
Modifieroperator= (Modifier const &)=delete
 
Modifieroperator= (Modifier &&)=delete
 
- 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 CollectHits (const art::Event &evt, const std::string &label, const std::string &instance, std::vector< art::Ptr< gar::rec::CaloHit > > &hitVector)
 
gar::rec::Cluster CreateCluster (const simb::MCParticle *part, std::vector< art::Ptr< gar::rec::CaloHit > > hitVec)
 

Private Attributes

std::string fCaloHitModuleLabel
 label for module creating rec::CaloHit objects More...
 
std::string fInstanceName
 product instance name More...
 
unsigned int fMinHits
 minimum number of hits to make a cluster More...
 
bool fIgnoreNeutrons
 flag to ignore creating neutron clusters More...
 
gar::geo::GeometryCore const * fGeo
 geometry information More...
 

Additional Inherited Members

- Public Types inherited from art::EDProducer
using ModuleType = EDProducer
 
using WorkerType = WorkerT< EDProducer >
 
- Public Types inherited from art::detail::Producer
template<typename UserConfig , typename KeysToIgnore = void>
using Table = Modifier::Table< UserConfig, KeysToIgnore >
 
- Public Types inherited from art::Modifier
template<typename UserConfig , typename UserKeysToIgnore = void>
using Table = ProducerTable< UserConfig, detail::ModuleConfig, UserKeysToIgnore >
 
- Static Public Member Functions inherited from art::EDProducer
static void commitEvent (EventPrincipal &ep, Event &e)
 
- 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 49 of file CaloClusterCheater_module.cc.

Constructor & Destructor Documentation

gar::rec::CaloClusterCheater::CaloClusterCheater ( fhicl::ParameterSet const &  pset)
explicit

Definition at line 78 of file CaloClusterCheater_module.cc.

78  :
79  EDProducer{pset}
80  {
81  fCaloHitModuleLabel = pset.get< std::string >("CaloHitModuleLabel", "calohit" );
82  fInstanceName = pset.get<std::string >("InstanceLabelName", "");
83 
84  fMinHits = pset.get< unsigned int >("MinHits", 1 );
85  fIgnoreNeutrons = pset.get< bool >("IgnoreNeutrons", true );
86 
87  fGeo = gar::providerFrom<geo::GeometryGAr>();
88 
89  art::InputTag tag(fCaloHitModuleLabel, fInstanceName);
90  consumes< std::vector<gar::rec::CaloHit> >(tag);
91  produces< std::vector<gar::rec::Cluster> >(fInstanceName);
92  produces< art::Assns<gar::rec::Cluster, gar::rec::CaloHit> >(fInstanceName);
93  }
bool fIgnoreNeutrons
flag to ignore creating neutron clusters
std::string string
Definition: nybbler.cc:12
EDProducer(fhicl::ParameterSet const &pset)
Definition: EDProducer.h:20
std::string fCaloHitModuleLabel
label for module creating rec::CaloHit objects
gar::geo::GeometryCore const * fGeo
geometry information
std::string fInstanceName
product instance name
unsigned int fMinHits
minimum number of hits to make a cluster
gar::rec::CaloClusterCheater::CaloClusterCheater ( CaloClusterCheater const &  )
delete
gar::rec::CaloClusterCheater::CaloClusterCheater ( CaloClusterCheater &&  )
delete

Member Function Documentation

void gar::rec::CaloClusterCheater::CollectHits ( const art::Event evt,
const std::string label,
const std::string instance,
std::vector< art::Ptr< gar::rec::CaloHit > > &  hitVector 
)
private

Definition at line 157 of file CaloClusterCheater_module.cc.

158  {
160  auto theHits = evt.getHandle< std::vector<gar::rec::CaloHit> >(itag);
161  if (!theHits) return;
162 
163  for (unsigned int i = 0; i < theHits->size(); ++i)
164  {
165  const art::Ptr<gar::rec::CaloHit> hit(theHits, i);
166  hitVector.push_back(hit);
167  }
168  }
Handle< PROD > getHandle(SelectorBase const &) const
Definition: DataViewImpl.h:382
const std::string instance
Detector simulation of raw signals on wires.
gar::rec::Cluster gar::rec::CaloClusterCheater::CreateCluster ( const simb::MCParticle part,
std::vector< art::Ptr< gar::rec::CaloHit > >  hitVec 
)
private

Definition at line 171 of file CaloClusterCheater_module.cc.

172  {
173  gar::rec::Cluster clu;
174 
175  unsigned n = hitVec.size() ;
176  unsigned i = 0 ;
177  float rmin = 9999.;
178  float rmax = 0.;
179  std::vector<float> tmin;
180  std::vector<float> tmax;
181 
182  std::vector<float> a, t, x, y, z;
183  a.resize(n);
184  t.resize(n);
185  x.resize(n);
186  y.resize(n);
187  z.resize(n);
188 
189  for( auto const &it : hitVec ) {
190  a[i] = it->Energy() ;
191  t[i] = it->Time().first ;
192  x[i] = it->Position()[0] ;
193  y[i] = it->Position()[1] ;
194  z[i] = it->Position()[2] ;
195 
196  // clu.addHit( it , a[i] ) ;
197 
198  //get time of first layer and last layer to compute the difference
199  float r = std::sqrt(y[i]*y[i] + z[i]*z[i]);
200  if( std::fabs(x[i]) < fGeo->GetECALEndcapStartX() ){
201  //case in barrel
202  if(rmin >= r)
203  {
204  rmin = r;
205  tmin.push_back(t[i]);
206  }
207  if(rmax <= r)
208  {
209  rmax = r;
210  tmax.push_back(t[i]);
211  }
212  }
213  else{
214  //case endcap
215  if( rmin >= std::fabs(x[i]) )
216  {
217  rmin = std::fabs(x[i]);
218  tmin.push_back(t[i]);
219  }
220  if( rmax <= std::fabs(x[i]) )
221  {
222  rmax = std::fabs(x[i]);
223  tmax.push_back(t[i]);
224  }
225  }
226 
227  ++i ;
228  }
229 
230  //get minimum time of the first layer
231  auto time_first = std::min_element( tmin.begin(), tmin.end() );
232  assert(time_first != tmin.end());
233  //get minimum time of the last layer
234  auto time_last = std::min_element( tmax.begin(), tmax.end() );
235  assert(time_last != tmax.end());
236 
237  util::ClusterShapes cs(n, a, t, x, y, z) ;
238 
239  clu.setEnergy( cs.getTotalAmplitude() ) ;
240  clu.setTime( cs.getAverageTime(), *time_first - *time_last ) ;
241  clu.setPosition( cs.getCenterOfGravity() ) ;
242 
243  // direction of cluster's PCA
244  float* d = cs.getEigenVecInertia() ;
245  clu.setEigenVectors( d );
246 
247  //Main eigenvector
248  CLHEP::Hep3Vector v( d[0], d[1], d[2] ) ;
249 
250  clu.setITheta( v.theta() ) ;
251  clu.setIPhi( v.phi() ) ;
252 
253  float param[6] ;
254 
255  // param[0] = cs.getElipsoid_r1() ;
256  param[0] = cs.getElipsoid_r_forw();
257  param[1] = cs.getElipsoid_r_back();
258  param[2] = cs.getElipsoid_r2() ;
259  param[3] = cs.getElipsoid_r3() ;
260  param[4] = cs.getElipsoid_vol() ;
261  param[5] = cs.getWidth() ;
262 
263  clu.setShape( param ) ;
264 
265  clu.setParticleID( part->PdgCode() );
266 
267  return clu;
268  }
int PdgCode() const
Definition: MCParticle.h:212
void setParticleID(int pid)
Definition: Cluster.cxx:59
void setShape(const float *shape)
Definition: Cluster.cxx:54
void setEigenVectors(const float *eigenvectors)
Definition: Cluster.cxx:49
void setEnergy(float energy)
Definition: Cluster.cxx:18
std::void_t< T > n
void setPosition(const float *position)
Definition: Cluster.cxx:34
const double a
gar::geo::GeometryCore const * fGeo
geometry information
float GetECALEndcapStartX() const
Definition: GeometryCore.h:975
void setIPhi(float phi)
Definition: Cluster.cxx:44
void setITheta(float theta)
Definition: Cluster.cxx:39
list x
Definition: train.py:276
const char * cs
void setTime(float time, float time_diff)
Definition: Cluster.cxx:28
CaloClusterCheater& gar::rec::CaloClusterCheater::operator= ( CaloClusterCheater const &  )
delete
CaloClusterCheater& gar::rec::CaloClusterCheater::operator= ( CaloClusterCheater &&  )
delete
void gar::rec::CaloClusterCheater::produce ( art::Event e)
overridevirtual

Implements art::EDProducer.

Definition at line 96 of file CaloClusterCheater_module.cc.

97  {
98  cheat::BackTrackerCore const* bt = gar::providerFrom<cheat::BackTracker>();
99 
100  //Collect the hits to be passed to the algo
101  std::vector< art::Ptr<gar::rec::CaloHit> > artHits;
102  this->CollectHits(e, fCaloHitModuleLabel, fInstanceName, artHits);
103 
104  std::map< eveLoc, std::vector< art::Ptr<gar::rec::CaloHit> > > eveCaloHitMap;
105 
106  // loop over all hits and fill in the map
107  for( auto const& itr : artHits ) {
108 
109  std::vector<gar::cheat::CalIDE> eveides = bt->CaloHitToCalIDEs(itr);
110  // loop over all eveides for this hit
111  for(size_t ieve = 0; ieve < eveides.size(); ieve++) {
112  // don't worry about eve particles that contribute less than 10% of the
113  // energy in the current hit
114  if( eveides[ieve].energyFrac < 0.1) continue;
115 
116  eveLoc el(eveides[ieve].trackID);
117  eveCaloHitMap[el].push_back(itr);
118 
119  } // end loop over eve IDs for this hit
120  }// end loop over hits
121 
122  // loop over the map and make clusters
123  std::unique_ptr< std::vector<gar::rec::Cluster> > clustercol(new std::vector<gar::rec::Cluster>);
124  std::unique_ptr< art::Assns<gar::rec::Cluster, gar::rec::CaloHit> > assn(new art::Assns<gar::rec::Cluster, gar::rec::CaloHit>);
125 
126  for(auto hitMapItr : eveCaloHitMap) {
127 
128  MF_LOG_DEBUG("CaloClusterCheater")
129  << "Found cluster of " << hitMapItr.second.size() << " hits"
130  << " with eveid " << hitMapItr.first.GetEveID();
131 
132  if(hitMapItr.second.size() < fMinHits) continue;
133 
134  const simb::MCParticle *part = bt->TrackIDToParticle(hitMapItr.first.GetEveID());
135  if(!part) {
136  MF_LOG_WARNING("CaloClusterCheater")
137  << "Cannot find MCParticle for eveid: " << hitMapItr.first.GetEveID();
138  continue;
139  }
140 
141  if(fIgnoreNeutrons && part->PdgCode() == 2112) continue;
142 
143  gar::rec::Cluster cluster = this->CreateCluster(part, hitMapItr.second);
144 
145  clustercol->emplace_back(cluster);
146  // association the hits to this cluster
147  evgb::util::CreateAssn(*this, e, *clustercol, hitMapItr.second, *assn, clustercol->size() - 1);
148  MF_LOG_DEBUG("CaloClusterCheater") << "adding cluster: \n" << clustercol->back() << "\nto collection.";
149 
150  } // end loop over the map
151 
152  e.put(std::move(clustercol), fInstanceName);
153  e.put(std::move(assn), fInstanceName);
154  }
int PdgCode() const
Definition: MCParticle.h:212
bool fIgnoreNeutrons
flag to ignore creating neutron clusters
gar::rec::Cluster CreateCluster(const simb::MCParticle *part, std::vector< art::Ptr< gar::rec::CaloHit > > hitVec)
Cluster finding and building.
void CollectHits(const art::Event &evt, const std::string &label, const std::string &instance, std::vector< art::Ptr< gar::rec::CaloHit > > &hitVector)
bt
Definition: tracks.py:83
std::string fCaloHitModuleLabel
label for module creating rec::CaloHit objects
def move(depos, offset)
Definition: depos.py:107
std::string fInstanceName
product instance name
ProductID put(std::unique_ptr< PROD > &&edp, std::string const &instance={})
Definition: DataViewImpl.h:686
bool CreateAssn(PRODUCER const &prod, art::Event &evt, std::vector< T > const &a, art::Ptr< U > const &b, art::Assns< U, T > &assn, std::string a_instance, size_t indx=UINT_MAX)
Creates a single one-to-one association.
unsigned int fMinHits
minimum number of hits to make a cluster
#define MF_LOG_DEBUG(id)
#define MF_LOG_WARNING(category)

Member Data Documentation

std::string gar::rec::CaloClusterCheater::fCaloHitModuleLabel
private

label for module creating rec::CaloHit objects

Definition at line 64 of file CaloClusterCheater_module.cc.

gar::geo::GeometryCore const* gar::rec::CaloClusterCheater::fGeo
private

geometry information

Definition at line 70 of file CaloClusterCheater_module.cc.

bool gar::rec::CaloClusterCheater::fIgnoreNeutrons
private

flag to ignore creating neutron clusters

Definition at line 68 of file CaloClusterCheater_module.cc.

std::string gar::rec::CaloClusterCheater::fInstanceName
private

product instance name

Definition at line 65 of file CaloClusterCheater_module.cc.

unsigned int gar::rec::CaloClusterCheater::fMinHits
private

minimum number of hits to make a cluster

Definition at line 67 of file CaloClusterCheater_module.cc.


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