20 #include "art_root_io/TFileService.h" 119 "fNoParticles_pdg_per_event",
"Average # of Particles per cluster for each event", 500, 0, 5);
121 "fNoParticles_pdg",
"Number of Particles in a Cluster for each cluster", 500, 0, 5);
123 "fNoParticles_trackid",
"Number of different TrackIDs in a Cluster", 300, 0, 30);
126 tfs->make<TH1F>(
"fNoParticles_trackid_mother",
127 "Number of different TrackIDs in a Cluster(using mother)for each cluster",
133 tfs->make<TH1F>(
"fNoParticles_trackid_per_event",
134 "Avg Number of different TrackIDs per Cluster per event",
139 tfs->make<TH1F>(
"fCl_for_Muon",
"Number of Clusters for Muon per plane (pdg)", 1500, 0, 15);
142 tfs->make<TH1F>(
"fNoClustersInEvent",
"Number of Clusters in an Event", 50, 0, 50);
145 tfs->make<TH1F>(
"fPercentNoise",
"% of hits that were marked as Noise by DBSCAN", 250, 0, 25);
148 "fno_of_clusters_per_track",
"Number of Clusters per TrackID per plane", 1500, 0, 15);
151 tfs->make<TH1F>(
"fPercent_lost_muon_hits",
152 "Number of muon hits excluded by dbscan in % (per Event)",
157 tfs->make<TH1F>(
"fPercent_lost_electron_hits",
158 "Number of electron hits excluded by dbscan in % (per Event)",
163 tfs->make<TH1F>(
"fPercent_lost_positron_hits",
164 "Number of positron hits excluded by dbscan in % (per Event)",
169 tfs->make<TH1F>(
"fPercent_lost_111_hits",
170 "Number of pion(111) hits excluded by dbscan in % (per Event)",
175 tfs->make<TH1F>(
"fPercent_lost_211_hits",
176 "Number of pion(211) hits excluded by dbscan in % (per Event)",
181 tfs->make<TH1F>(
"fPercent_lost_m211_hits",
182 "Number of pion(-211) hits excluded by dbscan in % (per Event)",
187 tfs->make<TH1F>(
"fPercent_lost_2212_hits",
188 "Number of proton hits excluded by dbscan in % (per Event)",
193 tfs->make<TH1F>(
"fPercent_lost_2112_hits",
194 "Number of neutron hits excluded by dbscan in % (per Event)",
200 " muon energy excluded by dbscan in % (per Event)",
205 tfs->make<TH1F>(
"fPercent_lost_electron_energy",
206 "electron energy excluded by dbscan in % (per Event)",
211 tfs->make<TH1F>(
"fPercent_lost_positron_energy",
212 " positron energy excluded by dbscan in % (per Event)",
217 tfs->make<TH1F>(
"fPercent_lost_111_energy",
218 "pion(111) energy excluded by dbscan in % (per Event)",
223 tfs->make<TH1F>(
"fPercent_lost_211_energy",
224 "pion(211) energy excluded by dbscan in % (per Event)",
229 tfs->make<TH1F>(
"fPercent_lost_m211_energy",
230 " pion(-211) energy excluded by dbscan in % (per Event)",
235 "proton energy excluded by dbscan in % (per Event)",
240 tfs->make<TH1F>(
"fPercent_lost_2112_energy",
241 "neutron energy excluded by dbscan in % (per Event)",
246 fEnergy = tfs->make<TH1F>(
"fEnergy",
"energy for each voxel", 100000, 0, 0.0005);
249 ";# Electrons deposited; # Electrons detected by hitfinder",
257 ";# Electrons deposited; # Electrons detected by hitfinder",
268 std::cout <<
"run : " << evt.
run() << std::endl;
269 std::cout <<
"event : " << evt.
id().
event() << std::endl;
274 std::cout <<
"**** DBclusterAna: Bailing. Don't call this module if you're not MC. " 302 for (
size_t ii = 0; ii < rdListHandle->size(); ++ii) {
313 std::vector<int> mc_trackids;
315 for (
auto i = _particleList.
begin(); i != _particleList.
end(); ++i) {
316 int trackID = (*i).first;
317 mc_trackids.push_back(trackID);
322 for (
size_t ii = 0; ii < mctruthListHandle->size(); ++ii) {
328 std::vector<art::Ptr<recob::Hit>> hits_vec;
331 std::vector<art::Ptr<recob::Hit>>
hits;
336 for (
unsigned int ii = 0; ii < clusterListHandle->size(); ++ii) {
341 std::cout <<
"in Efficiency, clusters.size()= " << clusters.
size() << std::endl;
346 for (
size_t ii = 0; ii < wireListHandle->size(); ++ii) {
363 double no_of_particles_in_cluster = 0;
364 double sum_vec_trackid = 0;
365 double no_of_clusters = 0;
366 double total_no_hits_in_clusters = 0;
367 std::vector<int> vec_pdg;
368 std::vector<int> vec_trackid, vec_trackid_mother, vec_trackid_mother_en;
369 std::vector<int> all_trackids;
370 std::vector<int> ids;
372 int no_cl_for_muon = 0;
373 int no_cl_for_electron = 0;
374 int no_cl_for_positron = 0;
375 int no_cl_for_pion_111 = 0;
376 int no_cl_for_pion_211 = 0;
377 int no_cl_for_pion_m211 = 0;
378 int no_cl_for_proton = 0;
379 double noCluster = 0;
380 double _hit_13 = 0, _hit_11 = 0, _hit_m_11 = 0, _hit_111 = 0, _hit_211 = 0, _hit_m211 = 0,
381 _hit_2212 = 0, _hit_2112 = 0;
382 double _en_13 = 0, _en_11 = 0, _en_m11 = 0, _en_111 = 0, _en_211 = 0, _en_m211 = 0,
383 _en_2212 = 0, _en_2112 = 0;
384 std::vector<double> diff_vec;
386 double hit_energy = 0;
389 if (clusters.
size() != 0 && hits.size() != 0) {
392 for (
size_t j = 0; j < clusters.
size(); ++j) {
394 if (clusters[j]->View() == view) {
396 std::vector<art::Ptr<recob::Hit>> _hits = fmh.at(j);
399 for (
size_t p = 0; p < _hits.size(); ++p) {
400 _hits_ptr = _hits[p];
401 hits_vec.push_back(_hits_ptr);
404 std::vector<art::Ptr<recob::Hit>>
::iterator itr = hits_vec.begin();
406 while (itr != hits_vec.end()) {
409 hit_energy = _hits[itr - hits_vec.begin()]->Integral();
411 std::vector<sim::TrackIDE> trackides = bt_serv->
HitToTrackIDEs(clockData, *itr);
412 std::vector<sim::TrackIDE> eveides = bt_serv->
HitToEveTrackIDEs(clockData, *itr);
416 while (idesitr != trackides.end()) {
418 vec_trackid.push_back((*idesitr).trackID);
422 if (pdg == 13 || pdg == -13) {
424 _en_13 += hit_energy * ((*idesitr).energyFrac);
433 it = find(vec_pdg.begin(), vec_pdg.end(), 13);
434 if (it != vec_pdg.end()) { no_cl_for_muon++; }
436 it2 = find(vec_pdg.begin(), vec_pdg.end(), 11);
437 if (it2 != vec_pdg.end()) { no_cl_for_electron++; }
439 it3 = find(vec_pdg.begin(), vec_pdg.end(), -11);
440 if (it3 != vec_pdg.end()) { no_cl_for_positron++; }
442 it4 = find(vec_pdg.begin(), vec_pdg.end(), 111);
443 if (it4 != vec_pdg.end()) { no_cl_for_pion_111++; }
444 it6 = find(vec_pdg.begin(), vec_pdg.end(), 211);
445 if (it6 != vec_pdg.end()) { no_cl_for_pion_211++; }
446 it7 = find(vec_pdg.begin(), vec_pdg.end(), -211);
447 if (it7 != vec_pdg.end()) { no_cl_for_pion_m211++; }
448 it8 = find(vec_pdg.begin(), vec_pdg.end(), 2212);
449 if (it8 != vec_pdg.end()) { no_cl_for_proton++; }
451 sort(vec_pdg.begin(), vec_pdg.end());
452 vec_pdg.erase(unique(vec_pdg.begin(), vec_pdg.end()), vec_pdg.end());
456 sort(vec_trackid.begin(), vec_trackid.end());
457 vec_trackid.erase(unique(vec_trackid.begin(), vec_trackid.end()), vec_trackid.end());
458 for (
unsigned int ii = 0; ii < vec_trackid.size(); ++ii) {
459 all_trackids.push_back(vec_trackid[ii]);
465 sort(vec_trackid_mother.begin(), vec_trackid_mother.end());
466 vec_trackid_mother.erase(unique(vec_trackid_mother.begin(), vec_trackid_mother.end()),
467 vec_trackid_mother.end());
471 sort(vec_trackid_mother_en.begin(), vec_trackid_mother_en.end());
472 vec_trackid_mother_en.erase(
473 unique(vec_trackid_mother_en.begin(), vec_trackid_mother_en.end()),
474 vec_trackid_mother_en.end());
479 for (
unsigned int ii = 0; ii < mc_trackids.size(); ++ii) {
480 it5 = find(vec_trackid.begin(), vec_trackid.end(), mc_trackids[ii]);
481 if (it5 != vec_trackid.end()) {
482 ids.push_back(mc_trackids[ii]);
495 no_of_particles_in_cluster += vec_pdg.size();
496 sum_vec_trackid += vec_trackid_mother.size();
497 total_no_hits_in_clusters += _hits.size();
503 vec_trackid_mother.clear();
505 vec_trackid_mother_en.clear();
512 sort(all_trackids.begin(), all_trackids.end());
513 all_trackids.erase(unique(all_trackids.begin(), all_trackids.end()), all_trackids.end());
518 sort(ids.begin(), ids.end());
519 ids.erase(unique(ids.begin(), ids.end()), ids.end());
520 double no_of_clusters_per_track = noCluster / ids.size();
524 if (no_cl_for_muon != 0) {
fCl_for_Muon->Fill(no_cl_for_muon); }
529 no_cl_for_electron = 0;
530 no_cl_for_positron = 0;
531 no_cl_for_pion_111 = 0;
532 no_cl_for_pion_211 = 0;
533 no_cl_for_pion_m211 = 0;
534 no_cl_for_proton = 0;
539 double result = no_of_particles_in_cluster / no_of_clusters;
541 double no_noise_hits = hits.size() - total_no_hits_in_clusters;
542 double percent_noise = double(no_noise_hits / hits.size()) * 100;
544 double no_trackid_per_cl_per_event = sum_vec_trackid / no_of_clusters;
552 for (
unsigned int i = 0; i < mclist.
size(); ++i) {
555 for (
int ii = 0; ii < mc->
NParticles(); ++ii) {
557 std::cout <<
"FROM MC TRUTH,the particle's pdg code is: " <<
part.PdgCode() << std::endl;
558 std::cout <<
"with energy= " <<
part.E();
559 if (
abs(
part.PdgCode()) == 13) { std::cout <<
" I have a muon!!!" << std::endl; }
560 if (
abs(
part.PdgCode()) == 111) { std::cout <<
" I have a pi zero!!!" << std::endl; }
570 double hit_13 = 0, hit_11 = 0, hit_m_11 = 0, hit_111 = 0, hit_211 = 0, hit_m211 = 0,
571 hit_2212 = 0, hit_2112 = 0;
572 double en_13 = 0, en_11 = 0, en_m11 = 0, en_111 = 0, en_211 = 0, en_m211 = 0, en_2212 = 0,
575 std::vector<art::Ptr<recob::Hit>>
::iterator itr = hits.begin();
576 while (itr != hits.end()) {
578 std::vector<sim::TrackIDE> trackides = bt_serv->
HitToTrackIDEs(clockData, *itr);
579 std::vector<sim::TrackIDE> eveides = bt_serv->
HitToEveTrackIDEs(clockData, *itr);
583 hit_energy = hits[itr - hits.begin()]->Integral();
585 while (idesitr != trackides.end()) {
592 if (pdg == 13 || pdg == -13) {
594 en_13 += hit_energy * ((*idesitr).energyFrac);
614 std::cout <<
"****** mu E from clusters = " << _en_13 << std::endl;
615 std::cout <<
"****** mu E from hits = " << en_13 << std::endl;
details::range_type< T > Iterate() const
Initializes the specified ID with the ID of the first cryostat.
std::string fCalDataModuleLabel
DBclusterAna(fhicl::ParameterSet const &pset)
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
enum geo::_plane_proj View_t
Enumerate the possible plane projections.
Declaration of signal hit object.
TH1F * fno_of_clusters_per_track
void SetEveIdCalculator(sim::EveIdCalculator *ec)
TH1F * fPercent_lost_111_hits
mapped_type at(const key_type &key)
constexpr auto abs(T v)
Returns the absolute value of the argument.
Definition of basic raw digits.
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
std::string fDigitModuleLabel
TH1F * fPercent_lost_111_energy
TH1F * fPercent_lost_2112_energy
TH1F * fPercent_lost_m211_hits
#define DEFINE_ART_MODULE(klass)
void push_back(Ptr< U > const &p)
Geometry information for a single wire plane.The plane is represented in the geometry by a solid whic...
TH1F * fPercent_lost_positron_hits
TH1F * fPercent_lost_m211_energy
std::string fLArG4ModuleLabel
The data type to uniquely identify a TPC.
Declaration of cluster object.
const sim::ParticleList & ParticleList() const
const simb::MCParticle & GetParticle(int i) const
TH1F * fNoParticles_trackid_per_event
TH1F * fPercent_lost_electron_hits
decltype(auto) get(T &&obj)
ADL-aware version of std::to_string.
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
Encapsulate the construction of a single detector plane.
TH1F * fPercent_lost_muon_hits
Example routine for calculating the "ultimate e-m mother" of a particle in a simulated event...
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
void fill_ptr_vector(std::vector< Ptr< T >> &ptrs, H const &h)
TH1F * fPercent_lost_2212_hits
Particle list in DetSim contains Monte Carlo particle information.
std::string fClusterFinderModuleLabel
art framework interface to geometry description