ClusterHitTime_module.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 // Class: ClusterHitTime
3 // Plugin Type: analyzer (art v3_05_00)
4 // File: ClusterHitTime_module.cc
5 //
6 // Generated at Thu Apr 2 08:17:05 2020 by Tingjun Yang using cetskelgen
7 // from cetlib version v3_10_00.
8 ////////////////////////////////////////////////////////////////////////
9 
17 #include "fhiclcpp/ParameterSet.h"
20 #include "canvas/Persistency/Common/FindManyP.h"
21 #include "art_root_io/TFileService.h"
26 
27 #include "TH1D.h"
28 
29 class ClusterHitTime;
30 
31 
33 public:
34  explicit ClusterHitTime(fhicl::ParameterSet const& p);
35  // The compiler-generated destructor is fine for non-base
36  // classes without bare pointers or other resource use.
37 
38  // Plugins should not be copied or assigned.
39  ClusterHitTime(ClusterHitTime const&) = delete;
40  ClusterHitTime(ClusterHitTime&&) = delete;
41  ClusterHitTime& operator=(ClusterHitTime const&) = delete;
43 
44  // Required functions.
45  void analyze(art::Event const& e) override;
46 
47  // Selected optional functions.
48  void beginJob() override;
49 
50 private:
51 
52  TH1D *clutime[3];
54  std::vector<int> fClusterIDs;
55 };
56 
57 
59  : EDAnalyzer{p},
60  fClusterModuleLabel(p.get<art::InputTag>("ClusterModuleLabel","linecluster")),
61  fClusterIDs(p.get<std::vector<int>>("ClusterIDs"))
62 {
63 }
64 
66 {
67 
68  std::vector<art::Ptr<recob::Cluster> > clusterlist;
69  auto clusterListHandle = e.getHandle< std::vector<recob::Cluster> >(fClusterModuleLabel);
70  if (clusterListHandle)
71  art::fill_ptr_vector(clusterlist, clusterListHandle);
72 
73  art::FindManyP<recob::Hit> fmhc(clusterListHandle, e, fClusterModuleLabel);
74 
75  auto const detProp = art::ServiceHandle<detinfo::DetectorPropertiesService const>()->DataFor(e);
76  for (const auto & cluster : clusterlist){
77  bool match = false;
78  for (const auto & id : fClusterIDs){
79  if (int(cluster.key()) == id){
80  match = true;
81  }
82  }
83  //std::cout<<cluster.key()<<std::endl;
84  if (!match) continue;
85  auto &hits = fmhc.at(cluster.key());
86  for (const auto & hit : hits){
87  std::cout<<hit->WireID().Plane<<" "<<hit->PeakTime()<<" "<<detProp.GetXTicksOffset(hit->WireID())<<" "<<hit->Integral()<<std::endl;
88  clutime[hit->WireID().Plane]->Fill(hit->PeakTime()-detProp.GetXTicksOffset(hit->WireID())+5000, hit->Integral());
89  }
90  }
91 
92 }
93 
95 {
97  clutime[0] = tfs->make<TH1D>("clutime_0","Plane 0;Tick;ADC",2000,0,2000);
98  clutime[1] = tfs->make<TH1D>("clutime_1","Plane 1;Tick;ADC",2000,0,2000);
99  clutime[2] = tfs->make<TH1D>("clutime_2","Plane 2;Tick;ADC",2000,0,2000);
100 
101 }
102 
Handle< PROD > getHandle(SelectorBase const &) const
Definition: DataViewImpl.h:382
void analyze(art::Event const &e) override
Cluster finding and building.
EDAnalyzer(fhicl::ParameterSet const &pset)
Definition: EDAnalyzer.h:25
const double e
#define DEFINE_ART_MODULE(klass)
Definition: ModuleMacros.h:67
p
Definition: test.py:223
std::vector< int > fClusterIDs
Detector simulation of raw signals on wires.
ClusterHitTime(fhicl::ParameterSet const &p)
void beginJob() override
ClusterHitTime & operator=(ClusterHitTime const &)=delete
Declaration of signal hit object.
art::InputTag fClusterModuleLabel
void fill_ptr_vector(std::vector< Ptr< T >> &ptrs, H const &h)
Definition: Ptr.h:297
QTextStream & endl(QTextStream &s)