HitSdpPlotter_module.cc
Go to the documentation of this file.
1 /*
2  * \file: HitSdpPlotter_module.cc
3  * \author: JStock (jason.stock@mines.sdsmt.edu)
4  * \brief: This is a small analysis Tree made for use in the Calibration group to investigate radiological backgrounds and calibration sources.
5  *
6  */
7 
8 #include "HitSdpPlotter.h"
10 #include <vector>
11 #include <TObject.h>
12 
13 namespace{}
14 
15 
16 namespace HitSdpPlotter {
17 
18  //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
20  :EDAnalyzer(pSet),
21  private_OpHitLabel(pSet.get<art::InputTag>("OpHitLabel", "ophit")),
22  private_BtrLabel(pSet.get<art::InputTag>("BTRLabel", "largeant"))
23  { }
24 
25  //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
26  /*
27  HitSdpPlotter::CalibrationTree(fhiclConfig const& config)
28  :EDAnalyzer(config),
29  private_HitLabel(config.HitLabel()),
30  private_OpHitLabel(config.OpHitLabel())
31  { }
32  */ //Commented out until I have a subtable for EDAnalyzer
33 
34  //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
36 //int nOpDets=private_geom->NOpDets();
37  mDir = std::make_unique<art::TFileDirectory>(private_service_tfs->mkdir("hists","hists"));
38  widths = private_service_tfs->make<TH1D>("ophit_widths", "width of ophits", 1000, -1, 2001);
39 
40  //PEs On X Axis
41  }
42 
43  //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
45 
46  std::vector<art::Ptr<recob::OpHit>> ophitList;
47  auto ophitHandle = evt.getHandle<std::vector<recob::OpHit> >(private_OpHitLabel);
48  if (ophitHandle)
49  art::fill_ptr_vector(ophitList, ophitHandle);
50 
51  std::vector<art::Ptr<sim::OpDetBacktrackerRecord>> btrList;
52  auto btrHandle = evt.getHandle<std::vector<sim::OpDetBacktrackerRecord> >(private_BtrLabel);
53  if (btrHandle)
54  art::fill_ptr_vector(btrList, btrHandle);
55 
56  for( auto& btr : btrList ){
57  TH1D* dummy = 0;
58  UInt_t opdet = btr->OpDetNum();
59  auto empIt = sdp_time_hists.emplace(std::make_pair(opdet, dummy));
60  if(empIt.second==true){
61  TString histName = TString("SDPTime")+TString(std::to_string(opdet))+TString("Hist");
62  TString histTitle = TString("PD ")+TString(std::to_string(opdet))+TString(" SDP Times.");
63  TH1D* tmphist1 = mDir->make<TH1D>(histName, histTitle, 30000, -1500000, 1500000);
64  empIt.first->second = std::move(tmphist1);
65  }
66  auto time_sdps = btr->timePDclockSDPsMap();
67  for( auto& time_sdp : time_sdps ){
68  double time = time_sdp.first;
69  empIt.first->second->Fill(time);
70  }
71  }
72 
73  for ( auto& ophit : ophitList ){
74  TH1D* dummy = 0;
75  UInt_t opdet = private_service_geom->OpDetFromOpChannel(ophit->OpChannel());
76  auto empIt = detTimeHist.emplace(std::make_pair(opdet, dummy));
77  //auto empIt = detTimeHist.emplace(std::make_pair(opdet, TH1D*(0)));
78 // auto empLowIt = detLowerTimeHist.emplace(std::make_pair(opdet, dummy));
79  //auto empLowIt = detLowerTimeHist.emplace(std::make_pair(opdet, TH1D*(0)));
80 // auto empUpIt = detUpperTimeHist.emplace(std::make_pair(opdet, dummy));
81  //auto empUpIt = detUpperTimeHist.emplace(std::make_pair(opdet, TH1D*(0)));
82  if(empIt.second==true){
83  TString histName = TString("PD")+TString(std::to_string(opdet))+TString("Hist");
84  TString histTitle = TString("PD ")+TString(std::to_string(opdet))+TString(" OpHit Times.");
85  /*
86  TString histLowName = TString("PD")+TString(std::to_string(opdet))+TString("LowHist");
87  TString histLowTitle = TString("PD ")+TString(std::to_string(opdet))+TString(" OpHit Lower Times.");
88  TString histUpName = TString("PD")+TString(std::to_string(opdet))+TString("UpHist");
89  TString histUpTitle = TString("PD ")+TString(std::to_string(opdet))+TString(" OpHit Upper Times.");
90  */
91  TH1D* tmphist1 = mDir->make<TH1D>(histName, histTitle, 30000, -1500000, 1500000);
92  empIt.first->second = std::move(tmphist1);
93  //TH1D* tmphist2 = mDir->make<TH1D>(histLowName, histLowTitle, 3000000, -1500000, 1500000);
94  //empLowIt.first->second = std::move(tmphist2);
95  //TH1D* tmphist3 = mDir->make<TH1D>(histUpName, histUpTitle, 3000000, -1500000, 1500000);
96  //empUpIt.first->second = std::move(tmphist3);
97  }
98  if((private_service_pbt->OpHitToSimSDPs_Ps(ophit)).size()>1){
99  double time = ophit->PeakTime() * 1000;
100  double width = ophit->Width() * 1000;
101  widths->Fill(width);
102  empIt.first->second->Fill(time);
103  //empLowIt.first->second->Fill(time - width);
104  //empUpIt.first->second->Fill(time + width);
105  }
106  }
107 
108 
109  } //end analyze
110 
111  //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
112  void HitSdpPlotter::endJob(){
113  }
114 
115 }//end namespace
116 
117 
def analyze(root, level, gtrees, gbranches, doprint)
Definition: rootstat.py:69
Handle< PROD > getHandle(SelectorBase const &) const
Definition: DataViewImpl.h:382
decltype(auto) constexpr size(T &&obj)
ADL-aware version of std::size.
Definition: StdUtils.h:92
#define DEFINE_ART_MODULE(klass)
Definition: ModuleMacros.h:67
void beginJob()
Definition: Breakpoints.cc:14
def move(depos, offset)
Definition: depos.py:107
cet::LibraryManager dummy("noplugin")
TCEvent evt
Definition: DataStructs.cxx:7
auto const & get(AssnsNode< L, R, D > const &r)
Definition: AssnsNode.h:115
void fill_ptr_vector(std::vector< Ptr< T >> &ptrs, H const &h)
Definition: Ptr.h:297
std::string to_string(ModuleType const mt)
Definition: ModuleType.h:34