All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Private Member Functions | Private Attributes | List of all members
shwf::ShowerCheater Class Reference
Inheritance diagram for shwf::ShowerCheater:

Public Member Functions

 ShowerCheater (fhicl::ParameterSet const &pset)
 

Private Member Functions

void produce (art::Event &evt) override
 

Private Attributes

std::string const fCheatedClusterLabel
 
std::string const fG4ModuleLabel
 label for module running G4 and making particles, etc More...
 

Detailed Description

Definition at line 33 of file ShowerCheater_module.cc.

Constructor & Destructor Documentation

shwf::ShowerCheater::ShowerCheater ( fhicl::ParameterSet const &  pset)
explicit

Definition at line 49 of file ShowerCheater_module.cc.

50  : EDProducer{pset}
51  , fCheatedClusterLabel{pset.get<std::string>("CheatedClusterLabel", "cluster")}
52  , fG4ModuleLabel{pset.get<std::string>("G4ModuleLabel", "largeant")}
53  {
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>>();
60  }
std::string const fCheatedClusterLabel
std::string const fG4ModuleLabel
label for module running G4 and making particles, etc

Member Function Documentation

void shwf::ShowerCheater::produce ( art::Event &  evt)
overrideprivate
Todo:
figure out the max transverse width of the shower in the x and y directions

Definition at line 64 of file ShowerCheater_module.cc.

65  {
66  art::ServiceHandle<cheat::BackTrackerService const> bt_serv;
67  art::ServiceHandle<cheat::ParticleInventoryService const> pi_serv;
68  art::ServiceHandle<geo::Geometry const> geo;
69 
70  // grab the clusters that have been reconstructed
71  art::Handle<std::vector<recob::Cluster>> clustercol;
72  evt.getByLabel(fCheatedClusterLabel, clustercol);
73 
74  art::FindManyP<recob::Hit> fmh(clustercol, evt, fCheatedClusterLabel);
75 
76  // make a vector of them - we aren't writing anything out to a file
77  // so no need for a art::PtrVector here
78  std::vector<art::Ptr<recob::Cluster>> clusters;
79  art::fill_ptr_vector(clusters, clustercol);
80 
81  // make a map of vectors of art::Ptrs keyed by eveID values
82  std::map<int, std::vector<std::pair<size_t, art::Ptr<recob::Cluster>>>> eveClusterMap;
83 
84  // loop over all clusters and fill in the map
85  for (size_t c = 0; c < clusters.size(); ++c) {
86 
87  // in the ClusterCheater module we set the cluster ID to be
88  // the eve particle track ID*1000 + plane*100 + tpc*10 + cryostat number. The
89  // floor function on the cluster ID / 1000 will give us
90  // the eve track ID
91  int eveID = floor(clusters[c]->ID() / 1000.);
92 
93  std::pair<size_t, art::Ptr<recob::Cluster>> indexPtr(c, clusters[c]);
94 
95  eveClusterMap[eveID].push_back(indexPtr);
96 
97  } // end loop over clusters
98 
99  // loop over the map and make prongs
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>);
110 
111  auto const clockData = art::ServiceHandle<detinfo::DetectorClocksService const>()->DataFor(evt);
112 
113  for (auto const& clusterMapItr : eveClusterMap) {
114 
115  // separate out the hits for each particle into the different views
116  std::vector<std::pair<size_t, art::Ptr<recob::Cluster>>> const& eveClusters =
117  clusterMapItr.second;
118 
119  size_t startSPIndx = spcol->size();
120 
121  double totalCharge = 0.;
122 
123  std::vector<art::Ptr<recob::Cluster>> ptrvs;
124  std::vector<size_t> idxs;
125 
126  for (auto const& idxPtr : eveClusters) {
127  idxs.push_back(idxPtr.first);
128  ptrvs.push_back(idxPtr.second);
129 
130  // need to make the space points for this prong
131  // loop over the hits for this cluster and make
132  // a space point for each one
133  // set the SpacePoint ID to be the cluster ID*10000
134  // + the hit index in the cluster PtrVector of hits
135  std::vector<art::Ptr<recob::Hit>> const& hits = fmh.at(idxPtr.first);
136 
137  for (size_t h = 0; h < hits.size(); ++h) {
138  art::Ptr<recob::Hit> hit = hits[h];
139  // add up the charge from the hits on the collection plane
140  if (hit->SignalType() == geo::kCollection) totalCharge += hit->Integral();
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};
143 
144  // make the space point and set its ID and XYZ
145  // the errors and chi^2 are set to "good" values as we know the information perfectly
146  recob::SpacePoint sp(&xyz[0], sperr, 0.9, idxPtr.second->ID() * 10000 + h);
147  spcol->push_back(sp);
148 
149  // associate the space point to the hit
150  util::CreateAssn(*this, evt, *spcol, hit, *sphassn);
151 
152  } // end loop over hits
153  } // end loop over pairs of index values and cluster Ptrs
154 
155  size_t endSPIndx = spcol->size();
156 
157  // is this prong electro-magnetic in nature or
158  // hadronic/muonic? EM --> shower, everything else is a track
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) {
162 
163  mf::LogInfo("ShowerCheater")
164  << "prong of " << clusterMapItr.first << " is a shower with pdg code "
165  << pi_serv->ParticleList()[clusterMapItr.first]->PdgCode();
166 
167  // get the direction cosine for the eve ID particle
168  // just use the same for both the start and end of the prong
169  const TLorentzVector initmom = pi_serv->ParticleList()[clusterMapItr.first]->Momentum();
170  TVector3 dcos(
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);
173 
174  /// \todo figure out the max transverse width of the shower in the x and y directions
175  //double maxTransWidth[2] = { util::kBogusD, util::kBogusD };
176  //double distanceMaxWidth = util::kBogusD;
177 
178  // add a prong to the collection. Make the prong
179  // ID be the same as the track ID for the eve particle
181  s.set_id(showercol->size());
182  s.set_direction(dcos);
183  s.set_direction_err(dcosErr);
184  /*
185  showercol->push_back(recob::Shower(dcos, dcosErr, maxTransWidth,
186  distanceMaxWidth, totalCharge, clusterMapItr.first));
187  */
188  showercol->push_back(s);
189  // associate the shower with its clusters
190  util::CreateAssn(*this, evt, *showercol, ptrvs, *scassn);
191 
192  // get the hits associated with each cluster and associate those with the shower
193  for (size_t i = 0; i < idxs.size(); ++i) {
194  std::vector<art::Ptr<recob::Hit>> hits = fmh.at(i);
195  util::CreateAssn(*this, evt, *showercol, hits, *shassn);
196  }
197 
198  // associate the shower with the space points
199  util::CreateAssn(*this, evt, *showercol, *spcol, *sspassn, startSPIndx, endSPIndx);
200 
201  mf::LogInfo("ShowerCheater") << "adding shower: \n"
202  << showercol->back() << "\nto collection.";
203 
204  } // end if this is a shower
205  } // end loop over the map
206 
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));
213  } // end produce
void set_direction_err(const TVector3 &dir_e)
Definition: Shower.h:136
process_name hit
Definition: cheaterreco.fcl:51
while getopts h
void set_id(const int id)
Definition: Shower.h:128
T abs(T value)
void set_direction(const TVector3 &dir)
Definition: Shower.h:135
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
Definition: file_to_url.sh:60
do i e
TCEvent evt
Definition: DataStructs.cxx:8
Signal from collection planes.
Definition: geo_types.h:146

Member Data Documentation

std::string const shwf::ShowerCheater::fCheatedClusterLabel
private

label for module creating recob::Cluster objects

Definition at line 40 of file ShowerCheater_module.cc.

std::string const shwf::ShowerCheater::fG4ModuleLabel
private

label for module running G4 and making particles, etc

Definition at line 42 of file ShowerCheater_module.cc.


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