21 #include "MCCheater/BackTracker.h" 23 #include "nugen/EventGeneratorBase/GENIE/EVGBAssociationUtil.h" 26 #include "CLHEP/Vector/ThreeVector.h" 84 fMinHits = pset.get<
unsigned int >(
"MinHits", 1 );
87 fGeo = gar::providerFrom<geo::GeometryGAr>();
90 consumes< std::vector<gar::rec::CaloHit> >(tag);
92 produces< art::Assns<gar::rec::Cluster, gar::rec::CaloHit> >(
fInstanceName);
101 std::vector< art::Ptr<gar::rec::CaloHit> > artHits;
104 std::map< eveLoc, std::vector< art::Ptr<gar::rec::CaloHit> > > eveCaloHitMap;
107 for(
auto const& itr : artHits ) {
111 for(
size_t ieve = 0; ieve < eveides.size(); ieve++) {
114 if( eveides[ieve].energyFrac < 0.1)
continue;
116 eveLoc el(eveides[ieve].trackID);
117 eveCaloHitMap[el].push_back(itr);
123 std::unique_ptr< std::vector<gar::rec::Cluster> > clustercol(
new std::vector<gar::rec::Cluster>);
126 for(
auto hitMapItr : eveCaloHitMap) {
129 <<
"Found cluster of " << hitMapItr.second.size() <<
" hits" 130 <<
" with eveid " << hitMapItr.first.GetEveID();
132 if(hitMapItr.second.size() <
fMinHits)
continue;
137 <<
"Cannot find MCParticle for eveid: " << hitMapItr.first.GetEveID();
145 clustercol->emplace_back(cluster);
148 MF_LOG_DEBUG(
"CaloClusterCheater") <<
"adding cluster: \n" << clustercol->back() <<
"\nto collection.";
160 auto theHits = evt.
getHandle< std::vector<gar::rec::CaloHit> >(itag);
161 if (!theHits)
return;
163 for (
unsigned int i = 0; i < theHits->size(); ++i)
166 hitVector.push_back(hit);
175 unsigned n = hitVec.size() ;
179 std::vector<float> tmin;
180 std::vector<float> tmax;
182 std::vector<float>
a,
t,
x,
y,
z;
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] ;
199 float r = std::sqrt(y[i]*y[i] + z[i]*z[i]);
205 tmin.push_back(t[i]);
210 tmax.push_back(t[i]);
215 if( rmin >= std::fabs(x[i]) )
217 rmin = std::fabs(x[i]);
218 tmin.push_back(t[i]);
220 if( rmax <= std::fabs(x[i]) )
222 rmax = std::fabs(x[i]);
223 tmax.push_back(t[i]);
231 auto time_first = std::min_element( tmin.begin(), tmin.end() );
232 assert(time_first != tmin.end());
234 auto time_last = std::min_element( tmax.begin(), tmax.end() );
235 assert(time_last != tmax.end());
239 clu.
setEnergy( cs.getTotalAmplitude() ) ;
240 clu.
setTime( cs.getAverageTime(), *time_first - *time_last ) ;
244 float*
d = cs.getEigenVecInertia() ;
248 CLHEP::Hep3Vector v( d[0], d[1], d[2] ) ;
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() ;
std::vector< CalIDE > CaloHitToCalIDEs(art::Ptr< rec::CaloHit > const &hit) const
bool fIgnoreNeutrons
flag to ignore creating neutron clusters
void setParticleID(int pid)
Handle< PROD > getHandle(SelectorBase const &) const
void setShape(const float *shape)
gar::rec::Cluster CreateCluster(const simb::MCParticle *part, std::vector< art::Ptr< gar::rec::CaloHit > > hitVec)
const std::string instance
Description of geometry of one entire detector.
Cluster finding and building.
friend bool operator<(eveLoc const &a, eveLoc const &b)
void setEigenVectors(const float *eigenvectors)
void CollectHits(const art::Event &evt, const std::string &label, const std::string &instance, std::vector< art::Ptr< gar::rec::CaloHit > > &hitVector)
void setEnergy(float energy)
#define DEFINE_ART_MODULE(klass)
std::string fCaloHitModuleLabel
label for module creating rec::CaloHit objects
void setPosition(const float *position)
simb::MCParticle * TrackIDToParticle(int const &id) const
gar::geo::GeometryCore const * fGeo
geometry information
CaloClusterCheater(fhicl::ParameterSet const &pset)
std::string fInstanceName
product instance name
ProductID put(std::unique_ptr< PROD > &&edp, std::string const &instance={})
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.
float GetECALEndcapStartX() const
unsigned int fMinHits
minimum number of hits to make a cluster
General GArSoft Utilities.
void setITheta(float theta)
void produce(art::Event &e) override
#define MF_LOG_WARNING(category)
art framework interface to geometry description
void setTime(float time, float time_diff)