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

Public Member Functions

 wvfAna (fhicl::ParameterSet const &p)
 
 wvfAna (wvfAna const &)=delete
 
 wvfAna (wvfAna &&)=delete
 
wvfAnaoperator= (wvfAna const &)=delete
 
wvfAnaoperator= (wvfAna &&)=delete
 
void analyze (art::Event const &e) override
 
void beginJob () override
 
void endJob () override
 

Public Attributes

opdet::sbndPDMapAlg pdMap
 

Private Attributes

size_t fEvNumber
 
size_t fChNumber
 
double fSampling
 
double fSampling_Daphne
 
double fStartTime
 
double fEndTime
 
std::string fInputModuleName
 
std::vector< std::string > fOpDetsToPlot
 
std::stringstream histname
 
std::string opdetType
 
std::string opdetElectronics
 

Detailed Description

Definition at line 52 of file wvfAna_module.cc.

Constructor & Destructor Documentation

opdet::wvfAna::wvfAna ( fhicl::ParameterSet const &  p)
explicit

Definition at line 92 of file wvfAna_module.cc.

93  :
94  EDAnalyzer(p) // ,
95  // More initializers here.
96  {
97  fInputModuleName = p.get< std::string >("InputModule" );
98  fOpDetsToPlot = p.get<std::vector<std::string> >("OpDetsToPlot");
99 
100  auto const clockData = art::ServiceHandle<detinfo::DetectorClocksService const>()->DataForJob();
101  fSampling = clockData.OpticalClock().Frequency(); // MHz
102  fSampling_Daphne = p.get<double>("DaphneFrequency" );
103  }
std::string fInputModuleName
pdgs p
Definition: selectors.fcl:22
std::vector< std::string > fOpDetsToPlot
double fSampling_Daphne
opdet::wvfAna::wvfAna ( wvfAna const &  )
delete
opdet::wvfAna::wvfAna ( wvfAna &&  )
delete

Member Function Documentation

void opdet::wvfAna::analyze ( art::Event const &  e)
override

Definition at line 110 of file wvfAna_module.cc.

111  {
112  // Implementation of required member function here.
113  std::cout << "My module on event #" << e.id().event() << std::endl;
114 
115  art::ServiceHandle<art::TFileService> tfs;
116  fEvNumber = e.id().event();
117 
118  art::Handle< std::vector< raw::OpDetWaveform > > waveHandle;
119  e.getByLabel(fInputModuleName, waveHandle);
120 
121  if(!waveHandle.isValid()) {
122  std::cout << Form("Did not find any G4 photons from a producer: %s", "largeant") << std::endl;
123  }
124 
125  // // example of usage for pdMap.getCollectionWithProperty()
126  // //
127  // // define a container
128  // auto inBoxTwo = pdMap.getCollectionWithProperty("pds_box", 2);
129  // // you can cout the whole json object
130  // std::cout << "inBoxTwo:\t" << inBoxTwo << "\n";
131  // // traverse its components in a loop
132  // for (auto const &e: inBoxTwo) {
133  // std::cout << e["pd_type"] << " " << e["channel"] << ' ' << "\n";
134  // }
135 
136  // // example of usage for pdMap.getCollectionFromCondition()
137  // // define a lambda function with the conditions
138  // auto subsetCondition = [](auto const& e)->bool
139  // // modify conditions as you want in the curly braces below
140  // {return e["pd_type"] == "pmt_uncoated" && e["tpc"] == 0;};
141  // // get the container that satisfies the conditions
142  // auto uncoatedsInTPC0 = pdMap.getCollectionFromCondition(subsetCondition);
143  // std::cout << "uncoatedsInTPC0.size():\t" << uncoatedsInTPC0.size() << "\n";
144  // for(auto const& e:uncoatedsInTPC0){
145  // std::cout << "e:\t" << e << "\n";
146  // }
147 
148  std::cout << "Number of waveforms: " << waveHandle->size() << std::endl;
149 
150  std::cout << "fOpDetsToPlot:\t";
151  for (auto const& opdet : fOpDetsToPlot){std::cout << opdet << " ";}
152  std::cout << std::endl;
153 
154  int hist_id = 0;
155  for(auto const& wvf : (*waveHandle)) {
156  fChNumber = wvf.ChannelNumber();
159  if (std::find(fOpDetsToPlot.begin(), fOpDetsToPlot.end(), opdetType) == fOpDetsToPlot.end()) {continue;}
160  histname.str(std::string());
161  histname << "event_" << fEvNumber
162  << "_opchannel_" << fChNumber
163  << "_" << opdetType
164  << "_" << hist_id;
165 
166  fStartTime = wvf.TimeStamp(); //in us
167  if (opdetElectronics == "daphne"){
168  fEndTime = double(wvf.size()) / fSampling_Daphne + fStartTime;
169  } //in us
170  else{
171  fEndTime = double(wvf.size()) / fSampling + fStartTime;
172  } //in us
173 
174  //Create a new histogram
175  TH1D *wvfHist = tfs->make< TH1D >(histname.str().c_str(), TString::Format(";t - %f (#mus);", fStartTime), wvf.size(), fStartTime, fEndTime);
176  for(unsigned int i = 0; i < wvf.size(); i++) {
177  wvfHist->SetBinContent(i + 1, (double)wvf[i]);
178  }
179  hist_id++;
180  }
181  }
std::string fInputModuleName
std::string opdetElectronics
std::stringstream histname
std::vector< std::string > fOpDetsToPlot
std::string opdetType
opdet::sbndPDMapAlg pdMap
std::string electronicsType(size_t ch) const
double fSampling_Daphne
do i e
art::ServiceHandle< art::TFileService > tfs
std::string pdType(size_t ch) const override
BEGIN_PROLOG could also be cout
void opdet::wvfAna::beginJob ( )
override

Definition at line 105 of file wvfAna_module.cc.

106  {
107 
108  }
void opdet::wvfAna::endJob ( )
override

Definition at line 183 of file wvfAna_module.cc.

184  {
185  }
wvfAna& opdet::wvfAna::operator= ( wvfAna const &  )
delete
wvfAna& opdet::wvfAna::operator= ( wvfAna &&  )
delete

Member Data Documentation

size_t opdet::wvfAna::fChNumber
private

Definition at line 76 of file wvfAna_module.cc.

double opdet::wvfAna::fEndTime
private

Definition at line 80 of file wvfAna_module.cc.

size_t opdet::wvfAna::fEvNumber
private

Definition at line 75 of file wvfAna_module.cc.

std::string opdet::wvfAna::fInputModuleName
private

Definition at line 84 of file wvfAna_module.cc.

std::vector<std::string> opdet::wvfAna::fOpDetsToPlot
private

Definition at line 85 of file wvfAna_module.cc.

double opdet::wvfAna::fSampling
private

Definition at line 77 of file wvfAna_module.cc.

double opdet::wvfAna::fSampling_Daphne
private

Definition at line 78 of file wvfAna_module.cc.

double opdet::wvfAna::fStartTime
private

Definition at line 79 of file wvfAna_module.cc.

std::stringstream opdet::wvfAna::histname
private

Definition at line 86 of file wvfAna_module.cc.

std::string opdet::wvfAna::opdetElectronics
private

Definition at line 88 of file wvfAna_module.cc.

std::string opdet::wvfAna::opdetType
private

Definition at line 87 of file wvfAna_module.cc.

opdet::sbndPDMapAlg opdet::wvfAna::pdMap

Definition at line 71 of file wvfAna_module.cc.


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