23 #include "art/Framework/Core/EDProducer.h"
24 #include "art/Framework/Core/ModuleMacros.h"
25 #include "art/Framework/Principal/Event.h"
26 #include "art/Framework/Principal/Handle.h"
27 #include "art/Framework/Services/Registry/ServiceHandle.h"
28 #include "canvas/Persistency/Common/FindManyP.h"
29 #include "fhiclcpp/ParameterSet.h"
30 #include "messagefacility/MessageLogger/MessageLogger.h"
51 , fCheatedClusterLabel{pset.get<std::string>(
"CheatedClusterLabel",
"cluster")}
52 , fG4ModuleLabel{pset.get<std::string>(
"G4ModuleLabel",
"largeant")}
54 produces<std::vector<recob::Shower>>();
55 produces<std::vector<recob::SpacePoint>>();
56 produces<art::Assns<recob::Shower, recob::Cluster>>();
57 produces<art::Assns<recob::Shower, recob::SpacePoint>>();
58 produces<art::Assns<recob::Shower, recob::Hit>>();
59 produces<art::Assns<recob::Hit, recob::SpacePoint>>();
66 art::ServiceHandle<cheat::BackTrackerService const> bt_serv;
67 art::ServiceHandle<cheat::ParticleInventoryService const> pi_serv;
68 art::ServiceHandle<geo::Geometry const> geo;
71 art::Handle<std::vector<recob::Cluster>> clustercol;
78 std::vector<art::Ptr<recob::Cluster>> clusters;
79 art::fill_ptr_vector(clusters, clustercol);
82 std::map<int, std::vector<std::pair<size_t, art::Ptr<recob::Cluster>>>> eveClusterMap;
85 for (
size_t c = 0; c < clusters.size(); ++c) {
91 int eveID = floor(clusters[c]->ID() / 1000.);
93 std::pair<size_t, art::Ptr<recob::Cluster>> indexPtr(c, clusters[c]);
95 eveClusterMap[eveID].push_back(indexPtr);
100 std::unique_ptr<std::vector<recob::Shower>> showercol(
new std::vector<recob::Shower>);
101 std::unique_ptr<std::vector<recob::SpacePoint>> spcol(
new std::vector<recob::SpacePoint>);
102 std::unique_ptr<art::Assns<recob::Shower, recob::Cluster>> scassn(
103 new art::Assns<recob::Shower, recob::Cluster>);
104 std::unique_ptr<art::Assns<recob::Shower, recob::Hit>> shassn(
105 new art::Assns<recob::Shower, recob::Hit>);
106 std::unique_ptr<art::Assns<recob::Shower, recob::SpacePoint>> sspassn(
107 new art::Assns<recob::Shower, recob::SpacePoint>);
108 std::unique_ptr<art::Assns<recob::Hit, recob::SpacePoint>> sphassn(
109 new art::Assns<recob::Hit, recob::SpacePoint>);
111 auto const clockData = art::ServiceHandle<detinfo::DetectorClocksService const>()->DataFor(evt);
113 for (
auto const& clusterMapItr : eveClusterMap) {
116 std::vector<std::pair<size_t, art::Ptr<recob::Cluster>>>
const& eveClusters =
117 clusterMapItr.second;
119 size_t startSPIndx = spcol->size();
121 double totalCharge = 0.;
123 std::vector<art::Ptr<recob::Cluster>> ptrvs;
124 std::vector<size_t> idxs;
126 for (
auto const& idxPtr : eveClusters) {
127 idxs.push_back(idxPtr.first);
128 ptrvs.push_back(idxPtr.second);
135 std::vector<art::Ptr<recob::Hit>>
const& hits = fmh.at(idxPtr.first);
137 for (
size_t h = 0;
h < hits.size(); ++
h) {
138 art::Ptr<recob::Hit>
hit = hits[
h];
141 std::vector<double> xyz = bt_serv->HitToXYZ(clockData, hit);
142 double sperr[6] = {0.01, 0.01, 0.1, 0.001, 0.001, 0.001};
147 spcol->push_back(sp);
155 size_t endSPIndx = spcol->size();
159 if (
std::abs(pi_serv->ParticleList()[clusterMapItr.first]->PdgCode()) == 11 ||
160 std::abs(pi_serv->ParticleList()[clusterMapItr.first]->PdgCode()) == 22 ||
161 std::abs(pi_serv->ParticleList()[clusterMapItr.first]->PdgCode()) == 111) {
163 mf::LogInfo(
"ShowerCheater")
164 <<
"prong of " << clusterMapItr.first <<
" is a shower with pdg code "
165 << pi_serv->ParticleList()[clusterMapItr.first]->PdgCode();
169 const TLorentzVector initmom = pi_serv->ParticleList()[clusterMapItr.first]->Momentum();
171 initmom.Px() / initmom.Mag(), initmom.Py() / initmom.Mag(), initmom.Pz() / initmom.Mag());
172 TVector3 dcosErr(1.
e-3, 1.
e-3, 1.
e-3);
181 s.
set_id(showercol->size());
188 showercol->push_back(s);
193 for (
size_t i = 0; i < idxs.size(); ++i) {
194 std::vector<art::Ptr<recob::Hit>> hits = fmh.at(i);
199 util::CreateAssn(*
this, evt, *showercol, *spcol, *sspassn, startSPIndx, endSPIndx);
201 mf::LogInfo(
"ShowerCheater") <<
"adding shower: \n"
202 << showercol->back() <<
"\nto collection.";
207 evt.put(std::move(showercol));
208 evt.put(std::move(spcol));
209 evt.put(std::move(scassn));
210 evt.put(std::move(shassn));
211 evt.put(std::move(sspassn));
212 evt.put(std::move(sphassn));
void produce(art::Event &evt) override
void set_direction_err(const TVector3 &dir_e)
Declaration of signal hit object.
ShowerCheater(fhicl::ParameterSet const &pset)
void set_id(const int id)
void set_direction(const TVector3 &dir)
Declaration of cluster object.
std::string const fCheatedClusterLabel
bool CreateAssn(art::Event &evt, std::vector< T > const &a, art::Ptr< U > const &b, art::Assns< U, T > &assn, std::string a_instance, size_t index=UINT_MAX)
Creates a single one-to-one association.
then echo File list $list not found else cat $list while read file do echo $file sed s
std::string const fG4ModuleLabel
label for module running G4 and making particles, etc
art framework interface to geometry description
Signal from collection planes.