20 #include "art_root_io/TFileService.h" 21 #include "canvas/Persistency/Common/FindManyP.h" 36 #include "nug4/ParticleNavigation/EmEveIdCalculator.h" 37 #include "nug4/ParticleNavigation/ParticleList.h" 120 "fNoParticles_pdg_per_event",
"Average # of Particles per cluster for each event", 500, 0, 5);
122 "fNoParticles_pdg",
"Number of Particles in a Cluster for each cluster", 500, 0, 5);
124 "fNoParticles_trackid",
"Number of different TrackIDs in a Cluster", 300, 0, 30);
127 tfs->make<TH1F>(
"fNoParticles_trackid_mother",
128 "Number of different TrackIDs in a Cluster(using mother)for each cluster",
134 tfs->make<TH1F>(
"fNoParticles_trackid_per_event",
135 "Avg Number of different TrackIDs per Cluster per event",
140 tfs->make<TH1F>(
"fCl_for_Muon",
"Number of Clusters for Muon per plane (pdg)", 1500, 0, 15);
143 tfs->make<TH1F>(
"fNoClustersInEvent",
"Number of Clusters in an Event", 50, 0, 50);
146 tfs->make<TH1F>(
"fPercentNoise",
"% of hits that were marked as Noise by DBSCAN", 250, 0, 25);
149 "fno_of_clusters_per_track",
"Number of Clusters per TrackID per plane", 1500, 0, 15);
152 tfs->make<TH1F>(
"fPercent_lost_muon_hits",
153 "Number of muon hits excluded by dbscan in % (per Event)",
158 tfs->make<TH1F>(
"fPercent_lost_electron_hits",
159 "Number of electron hits excluded by dbscan in % (per Event)",
164 tfs->make<TH1F>(
"fPercent_lost_positron_hits",
165 "Number of positron hits excluded by dbscan in % (per Event)",
170 tfs->make<TH1F>(
"fPercent_lost_111_hits",
171 "Number of pion(111) hits excluded by dbscan in % (per Event)",
176 tfs->make<TH1F>(
"fPercent_lost_211_hits",
177 "Number of pion(211) hits excluded by dbscan in % (per Event)",
182 tfs->make<TH1F>(
"fPercent_lost_m211_hits",
183 "Number of pion(-211) hits excluded by dbscan in % (per Event)",
188 tfs->make<TH1F>(
"fPercent_lost_2212_hits",
189 "Number of proton hits excluded by dbscan in % (per Event)",
194 tfs->make<TH1F>(
"fPercent_lost_2112_hits",
195 "Number of neutron hits excluded by dbscan in % (per Event)",
201 " muon energy excluded by dbscan in % (per Event)",
206 tfs->make<TH1F>(
"fPercent_lost_electron_energy",
207 "electron energy excluded by dbscan in % (per Event)",
212 tfs->make<TH1F>(
"fPercent_lost_positron_energy",
213 " positron energy excluded by dbscan in % (per Event)",
218 tfs->make<TH1F>(
"fPercent_lost_111_energy",
219 "pion(111) energy excluded by dbscan in % (per Event)",
224 tfs->make<TH1F>(
"fPercent_lost_211_energy",
225 "pion(211) energy excluded by dbscan in % (per Event)",
230 tfs->make<TH1F>(
"fPercent_lost_m211_energy",
231 " pion(-211) energy excluded by dbscan in % (per Event)",
236 "proton energy excluded by dbscan in % (per Event)",
241 tfs->make<TH1F>(
"fPercent_lost_2112_energy",
242 "neutron energy excluded by dbscan in % (per Event)",
247 fEnergy = tfs->make<TH1F>(
"fEnergy",
"energy for each voxel", 100000, 0, 0.0005);
250 ";# Electrons deposited; # Electrons detected by hitfinder",
258 ";# Electrons deposited; # Electrons detected by hitfinder",
276 std::cout <<
"**** DBclusterAna: Bailing. Don't call this module if you're not MC. " 304 for (
size_t ii = 0; ii < rdListHandle->size(); ++ii) {
313 sim::ParticleList
const& _particleList = pi_serv->
ParticleList();
315 std::vector<int> mc_trackids;
317 for (
auto i = _particleList.begin(); i != _particleList.end(); ++i) {
318 int trackID = (*i).first;
319 mc_trackids.push_back(trackID);
324 for (
size_t ii = 0; ii < mctruthListHandle->size(); ++ii) {
330 std::vector<art::Ptr<recob::Hit>> hits_vec;
333 std::vector<art::Ptr<recob::Hit>> hits;
338 for (
unsigned int ii = 0; ii < clusterListHandle->size(); ++ii) {
343 std::cout <<
"in Efficiency, clusters.size()= " << clusters.
size() <<
std::endl;
348 for (
size_t ii = 0; ii < wireListHandle->size(); ++ii) {
365 double no_of_particles_in_cluster = 0;
366 double sum_vec_trackid = 0;
367 double no_of_clusters = 0;
368 double total_no_hits_in_clusters = 0;
369 std::vector<int> vec_pdg;
370 std::vector<int> vec_trackid, vec_trackid_mother, vec_trackid_mother_en;
371 std::vector<int> all_trackids;
372 std::vector<int> ids;
374 int no_cl_for_muon = 0;
375 int no_cl_for_electron = 0;
376 int no_cl_for_positron = 0;
377 int no_cl_for_pion_111 = 0;
378 int no_cl_for_pion_211 = 0;
379 int no_cl_for_pion_m211 = 0;
380 int no_cl_for_proton = 0;
381 double noCluster = 0;
382 double _hit_13 = 0, _hit_11 = 0, _hit_m_11 = 0, _hit_111 = 0, _hit_211 = 0, _hit_m211 = 0,
383 _hit_2212 = 0, _hit_2112 = 0;
384 double _en_13 = 0, _en_11 = 0, _en_m11 = 0, _en_111 = 0, _en_211 = 0, _en_m211 = 0,
385 _en_2212 = 0, _en_2112 = 0;
386 std::vector<double> diff_vec;
388 double hit_energy = 0;
389 double total_Q_cluster_hits = 0;
392 if (clusters.
size() != 0 && hits.size() != 0) {
393 for (
unsigned int plane = 0; plane < geom->
Nplanes(); ++plane) {
395 for (
size_t j = 0; j < clusters.
size(); ++j) {
397 if (clusters[j]->
View() == view) {
399 std::vector<art::Ptr<recob::Hit>> _hits = fmh.at(j);
402 for (
size_t p = 0;
p < _hits.size(); ++
p) {
403 _hits_ptr = _hits[
p];
404 hits_vec.push_back(_hits_ptr);
405 total_Q_cluster_hits += _hits[
p]->Integral();
408 std::vector<art::Ptr<recob::Hit>>
::iterator itr = hits_vec.begin();
410 while (itr != hits_vec.end()) {
413 hit_energy = _hits[itr - hits_vec.begin()]->Integral();
415 std::vector<sim::TrackIDE> trackides = bt_serv->
HitToTrackIDEs(clockData, *itr);
416 std::vector<sim::TrackIDE> eveides = bt_serv->
HitToEveTrackIDEs(clockData, *itr);
420 while (idesitr != trackides.end()) {
422 vec_trackid.push_back((*idesitr).trackID);
426 if (pdg == 13 || pdg == -13) {
428 _en_13 += hit_energy * ((*idesitr).energyFrac);
437 it = find(vec_pdg.begin(), vec_pdg.end(), 13);
438 if (it != vec_pdg.end()) { no_cl_for_muon++; }
440 it2 = find(vec_pdg.begin(), vec_pdg.end(), 11);
441 if (it2 != vec_pdg.end()) { no_cl_for_electron++; }
443 it3 = find(vec_pdg.begin(), vec_pdg.end(), -11);
444 if (it3 != vec_pdg.end()) { no_cl_for_positron++; }
446 it4 = find(vec_pdg.begin(), vec_pdg.end(), 111);
447 if (it4 != vec_pdg.end()) { no_cl_for_pion_111++; }
448 it6 = find(vec_pdg.begin(), vec_pdg.end(), 211);
449 if (it6 != vec_pdg.end()) { no_cl_for_pion_211++; }
450 it7 = find(vec_pdg.begin(), vec_pdg.end(), -211);
451 if (it7 != vec_pdg.end()) { no_cl_for_pion_m211++; }
452 it8 = find(vec_pdg.begin(), vec_pdg.end(), 2212);
453 if (it8 != vec_pdg.end()) { no_cl_for_proton++; }
455 sort(vec_pdg.begin(), vec_pdg.end());
456 vec_pdg.erase(unique(vec_pdg.begin(), vec_pdg.end()), vec_pdg.end());
460 sort(vec_trackid.begin(), vec_trackid.end());
461 vec_trackid.erase(unique(vec_trackid.begin(), vec_trackid.end()), vec_trackid.end());
462 for (
unsigned int ii = 0; ii < vec_trackid.size(); ++ii) {
463 all_trackids.push_back(vec_trackid[ii]);
469 sort(vec_trackid_mother.begin(), vec_trackid_mother.end());
470 vec_trackid_mother.erase(unique(vec_trackid_mother.begin(), vec_trackid_mother.end()),
471 vec_trackid_mother.end());
475 sort(vec_trackid_mother_en.begin(), vec_trackid_mother_en.end());
476 vec_trackid_mother_en.erase(
477 unique(vec_trackid_mother_en.begin(), vec_trackid_mother_en.end()),
478 vec_trackid_mother_en.end());
483 for (
unsigned int ii = 0; ii < mc_trackids.size(); ++ii) {
484 it5 = find(vec_trackid.begin(), vec_trackid.end(), mc_trackids[ii]);
485 if (it5 != vec_trackid.end()) {
486 ids.push_back(mc_trackids[ii]);
499 no_of_particles_in_cluster += vec_pdg.size();
500 sum_vec_trackid += vec_trackid_mother.size();
501 total_no_hits_in_clusters += _hits.size();
507 vec_trackid_mother.clear();
509 vec_trackid_mother_en.clear();
516 sort(all_trackids.begin(), all_trackids.end());
517 all_trackids.erase(unique(all_trackids.begin(), all_trackids.end()), all_trackids.end());
522 sort(ids.begin(), ids.end());
523 ids.erase(unique(ids.begin(), ids.end()), ids.end());
524 double no_of_clusters_per_track = noCluster / ids.size();
528 if (no_cl_for_muon != 0) {
fCl_for_Muon->Fill(no_cl_for_muon); }
533 no_cl_for_electron = 0;
534 no_cl_for_positron = 0;
535 no_cl_for_pion_111 = 0;
536 no_cl_for_pion_211 = 0;
537 no_cl_for_pion_m211 = 0;
538 no_cl_for_proton = 0;
543 double result = no_of_particles_in_cluster / no_of_clusters;
545 double no_noise_hits = hits.size() - total_no_hits_in_clusters;
546 double percent_noise = double(no_noise_hits / hits.size()) * 100;
548 double no_trackid_per_cl_per_event = sum_vec_trackid / no_of_clusters;
556 for (
unsigned int i = 0; i < mclist.
size(); ++i) {
559 for (
int ii = 0; ii < mc->
NParticles(); ++ii) {
561 std::cout <<
"FROM MC TRUTH,the particle's pdg code is: " << part.
PdgCode() <<
std::endl;
562 std::cout <<
"with energy= " << part.E();
563 if (
abs(part.PdgCode()) == 13) { std::cout <<
" I have a muon!!!" <<
std::endl; }
564 if (
abs(part.PdgCode()) == 111) { std::cout <<
" I have a pi zero!!!" <<
std::endl; }
574 double hit_13 = 0, hit_11 = 0, hit_m_11 = 0, hit_111 = 0, hit_211 = 0, hit_m211 = 0,
575 hit_2212 = 0, hit_2112 = 0;
576 double en_13 = 0, en_11 = 0, en_m11 = 0, en_111 = 0, en_211 = 0, en_m211 = 0, en_2212 = 0,
579 std::vector<art::Ptr<recob::Hit>>
::iterator itr = hits.begin();
580 while (itr != hits.end()) {
582 std::vector<sim::TrackIDE> trackides = bt_serv->
HitToTrackIDEs(clockData, *itr);
583 std::vector<sim::TrackIDE> eveides = bt_serv->
HitToEveTrackIDEs(clockData, *itr);
587 hit_energy = hits[itr - hits.begin()]->Integral();
589 while (idesitr != trackides.end()) {
596 if (pdg == 13 || pdg == -13) {
598 en_13 += hit_energy * ((*idesitr).energyFrac);
618 std::cout <<
"****** mu E from clusters = " << _en_13 <<
std::endl;
619 std::cout <<
"****** mu E from hits = " << en_13 <<
std::endl;
std::string fCalDataModuleLabel
DBclusterAna(fhicl::ParameterSet const &pset)
PlaneGeo const & Plane(unsigned int const p, unsigned int const tpc=0, unsigned int const cstat=0) const
Returns the specified wire.
TH1F * fPercent_lost_2212_energy
TH1F * fPercent_lost_muon_energy
TH1F * fNoParticles_trackid
std::vector< sim::TrackIDE > HitToTrackIDEs(detinfo::DetectorClocksData const &clockData, recob::Hit const &hit) const
AdcChannelData::View View
enum geo::_plane_proj View_t
Enumerate the possible plane projections.
TH1F * fno_of_clusters_per_track
void SetEveIdCalculator(sim::EveIdCalculator *ec)
TH1F * fPercent_lost_111_hits
std::string fGenieGenModuleLabel
void analyze(const art::Event &evt)
read access to event
Cluster finding and building.
EDAnalyzer(fhicl::ParameterSet const &pset)
TH1F * fNoClustersInEvent
TH1F * fPercent_lost_electron_energy
art framework interface to geometry description
std::string fDigitModuleLabel
TH1F * fPercent_lost_111_energy
View_t View() const
Which coordinate does this plane measure.
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
unsigned int Nplanes(unsigned int tpc=0, unsigned int cstat=0) const
Returns the total number of wire planes in the specified TPC.
TH1F * fPercent_lost_2112_energy
TH1F * fPercent_lost_m211_hits
#define DEFINE_ART_MODULE(klass)
void push_back(Ptr< U > const &p)
TH1F * fPercent_lost_positron_hits
TH1F * fPercent_lost_m211_energy
std::string fLArG4ModuleLabel
const sim::ParticleList & ParticleList() const
const simb::MCParticle & GetParticle(int i) const
TH1F * fNoParticles_trackid_per_event
TH1F * fPercent_lost_electron_hits
Declaration of signal hit object.
Encapsulate the construction of a single detector plane.
TH1F * fPercent_lost_muon_hits
std::vector< sim::TrackIDE > HitToEveTrackIDEs(detinfo::DetectorClocksData const &clockData, recob::Hit const &hit) const
TH1F * fNoParticles_pdg_per_event
TH1F * fPercent_lost_positron_energy
EventNumber_t event() const
Declaration of basic channel signal object.
TH1F * fNoParticles_trackid_mother
std::string fHitsModuleLabel
TH1F * fPercent_lost_211_hits
TH1F * fPercent_lost_2112_hits
TH1F * fPercent_lost_211_energy
auto const & get(AssnsNode< L, R, D > const &r)
void fill_ptr_vector(std::vector< Ptr< T >> &ptrs, H const &h)
TH1F * fPercent_lost_2212_hits
std::string fClusterFinderModuleLabel
QTextStream & endl(QTextStream &s)