11 #ifndef TRKF_TRACKCHEATER_H 12 #define TRKF_TRACKCHEATER_H 70 produces< std::vector<recob::Track> >();
71 produces< std::vector<recob::SpacePoint> >();
72 produces< art::Assns<recob::Track, recob::Cluster> >();
73 produces< art::Assns<recob::Track, recob::SpacePoint> >();
74 produces< art::Assns<recob::Track, recob::Hit> >();
106 std::vector< art::Ptr<recob::Cluster> > clusters;
110 std::vector< art::Ptr<recob::Cluster> >
::iterator itr = clusters.begin();
113 std::map< int, std::vector< std::pair<size_t, art::Ptr<recob::Cluster> > > > eveClusterMap;
116 for(
size_t c = 0; c < clusters.size(); ++c){
118 std::pair<size_t, art::Ptr<recob::Cluster> > idxPtr(c, clusters[c]);
124 int eveID = floor((*itr)->ID()/1000.);
126 eveClusterMap[eveID].push_back(idxPtr);
131 std::unique_ptr< std::vector<recob::Track> > trackcol(
new std::vector<recob::Track>);
132 std::unique_ptr< std::vector<recob::SpacePoint> > spcol (
new std::vector<recob::SpacePoint>);
137 for(
auto const& clusterMapItr : eveClusterMap){
140 std::vector< std::pair<size_t, art::Ptr<recob::Cluster> > >
const& eveClusters = clusterMapItr.second;
146 if( abs(part->
PdgCode()) != 11 &&
151 std::vector<TVector3> points;
152 std::vector<TVector3> dirs;
154 size_t nviews = geo->
Nviews();
155 std::vector< std::vector<double> > dQdx(nviews);
157 mf::LogInfo(
"TrackCheater") <<
"G4 id " << clusterMapItr.first
158 <<
" is a track with pdg code " 162 std::vector<size_t> idxs;
163 for(
auto const& idxPtr : eveClusters){
165 idxs.push_back(idxPtr.first);
169 std::vector< art::Ptr<recob::Hit> >
hits;
170 for(
size_t p = 0; p < ptrvs.
size(); ++p){
171 std::vector< art::Ptr<recob::Hit> > chits = fmh.at(idxs[p]);
172 if (!chits.size())
continue;
174 hits.insert(hits.end(), chits.begin(), chits.end());
178 if(hits.size() < 2)
continue;
181 size_t spStart = spcol->size();
182 for(
size_t t = 0; t < hits.size(); ++t){
183 std::vector<double> xyz = bt_serv->
HitToXYZ(hits[t]);
184 points.push_back(TVector3(xyz[0], xyz[1], xyz[2]));
186 std::vector<double> xyz1;
187 double charge = hits[t]->Integral();
191 if(t < hits.size()-1){
192 xyz1 = bt_serv->
HitToXYZ(hits[t+1]);
195 xyz1 = bt_serv->
HitToXYZ(hits[t-1]);
200 dx = std::sqrt(std::pow(xyz1[0] - xyz[0], 2) +
201 std::pow(xyz1[1] - xyz[1], 2) +
202 std::pow(xyz1[2] - xyz[2], 2));
206 dirs.push_back(TVector3(sign*(xyz1[0] - xyz[0])/dx,
207 sign*(xyz1[1] - xyz[1])/dx,
208 sign*(xyz1[2] - xyz[2])/dx));
210 dQdx[0].push_back(charge/dx);
211 dQdx[1].push_back(charge/dx);
212 dQdx[2].push_back(charge/dx);
215 double xyzerr[6] = {1.e-3};
218 spcol->push_back(sp);
221 size_t spEnd = spcol->size();
225 std::vector<double> momentum(2);
226 momentum[0] = part->
P();
228 trackcol->push_back(
recob::Track(points, dirs, dQdx, momentum, clusterMapItr.first));
235 for(
size_t p = 0; p < ptrvs.
size(); ++p){
236 hits = fmh.at(idxs[p]);
245 <<
"\nto collection.";
251 evt.
put(std::move(trackcol));
252 evt.
put(std::move(spcol));
253 evt.
put(std::move(tcassn));
254 evt.
put(std::move(thassn));
255 evt.
put(std::move(tspassn));
void produce(art::Event &evt)
unsigned int NumberTrajectoryPoints() const
std::string fG4ModuleLabel
label for module running G4 and making particles, etc
const std::vector< double > HitToXYZ(const recob::Hit &hit)
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
Declaration of signal hit object.
TrackCheater(fhicl::ParameterSet const &pset)
std::string fCheatedClusterLabel
label for module creating recob::Cluster objects
ProductID put(std::unique_ptr< PROD > &&product)
#define DEFINE_ART_MODULE(klass)
void push_back(Ptr< U > const &p)
double P(const int i=0) const
T get(std::string const &key) const
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.
Declaration of cluster object.
Provides recob::Track data product.
Utility object to perform functions of association.
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
void reconfigure(fhicl::ParameterSet const &pset)
const sim::ParticleList & ParticleList()
unsigned int Nviews() const
Returns the number of views (different wire orientations)
void fill_ptr_vector(std::vector< Ptr< T >> &ptrs, H const &h)
Namespace collecting geometry-related classes utilities.
art framework interface to geometry description
Track from a non-cascading particle.A recob::Track consists of a recob::TrackTrajectory, plus additional members relevant for a "fitted" track:
Signal from collection planes.