Public Member Functions | Private Member Functions | Private Attributes | List of all members
MyMuoncountertimes::Muoncountertimes Class Reference
Inheritance diagram for MyMuoncountertimes::Muoncountertimes:
art::EDAnalyzer art::detail::Analyzer art::detail::LegacyModule art::Observer art::ModuleBase

Public Member Functions

 Muoncountertimes (fhicl::ParameterSet const &p)
 
virtual ~Muoncountertimes ()
 
void beginJob ()
 
void endJob ()
 
void reconfigure (fhicl::ParameterSet const &pset)
 
void analyze (const art::Event &evt)
 
- Public Member Functions inherited from art::EDAnalyzer
 EDAnalyzer (fhicl::ParameterSet const &pset)
 
template<typename Config >
 EDAnalyzer (Table< Config > const &config)
 
std::string workerType () const
 
- Public Member Functions inherited from art::detail::Analyzer
virtual ~Analyzer () noexcept
 
 Analyzer (fhicl::ParameterSet const &pset)
 
template<typename Config >
 Analyzer (Table< Config > const &config)
 
void doBeginJob ()
 
void doEndJob ()
 
void doRespondToOpenInputFile (FileBlock const &fb)
 
void doRespondToCloseInputFile (FileBlock const &fb)
 
void doRespondToOpenOutputFiles (FileBlock const &fb)
 
void doRespondToCloseOutputFiles (FileBlock const &fb)
 
bool doBeginRun (RunPrincipal &rp, ModuleContext const &mc)
 
bool doEndRun (RunPrincipal &rp, ModuleContext const &mc)
 
bool doBeginSubRun (SubRunPrincipal &srp, ModuleContext const &mc)
 
bool doEndSubRun (SubRunPrincipal &srp, ModuleContext const &mc)
 
bool doEvent (EventPrincipal &ep, ModuleContext const &mc, std::atomic< std::size_t > &counts_run, std::atomic< std::size_t > &counts_passed, std::atomic< std::size_t > &counts_failed)
 
- Public Member Functions inherited from art::Observer
 ~Observer () noexcept
 
 Observer (Observer const &)=delete
 
 Observer (Observer &&)=delete
 
Observeroperator= (Observer const &)=delete
 
Observeroperator= (Observer &&)=delete
 
void registerProducts (ProductDescriptions &, ModuleDescription const &)
 
void fillDescriptions (ModuleDescription const &)
 
std::string const & processName () const
 
bool wantAllEvents () const
 
bool wantEvent (Event const &e)
 
fhicl::ParameterSetID selectorConfig () const
 
Handle< TriggerResultsgetTriggerResults (Event const &e) const
 
- Public Member Functions inherited from art::ModuleBase
virtual ~ModuleBase () noexcept
 
 ModuleBase ()
 
ModuleDescription const & moduleDescription () const
 
void setModuleDescription (ModuleDescription const &)
 
std::array< std::vector< ProductInfo >, NumBranchTypes > const & getConsumables () const
 
void sortConsumables (std::string const &current_process_name)
 
template<typename T , BranchType BT>
ViewToken< T > consumesView (InputTag const &tag)
 
template<typename T , BranchType BT>
ViewToken< T > mayConsumeView (InputTag const &tag)
 

Private Member Functions

void ResetVars ()
 

Private Attributes

int run
 
int subrun
 
int event
 
int event_Count = 0
 
std::vector< TH1D * > fHist_Vec
 
int fLower_Block1
 
int fUpper_Block1
 
int fLower_Block2
 
int fUpper_Block2
 
int fCoincidence_Window
 
double fCombinedTimeDelay
 
std::string fCounterModuleLabel
 
std::string fFragType
 
std::string fRawDataLabel
 
std::string fPTBMapFile
 
std::string fPTBMapDir
 
std::map< int, int > fPTBMap
 

Additional Inherited Members

- Public Types inherited from art::EDAnalyzer
using WorkerType = WorkerT< EDAnalyzer >
 
using ModuleType = EDAnalyzer
 
- Protected Member Functions inherited from art::Observer
 Observer (fhicl::ParameterSet const &config)
 
 Observer (std::vector< std::string > const &paths, fhicl::ParameterSet const &config)
 
detail::ProcessAndEventSelectorsprocessAndEventSelectors ()
 
- Protected Member Functions inherited from art::ModuleBase
ConsumesCollectorconsumesCollector ()
 
template<typename T , BranchType = InEvent>
ProductToken< T > consumes (InputTag const &)
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > consumesView (InputTag const &)
 
template<typename T , BranchType = InEvent>
void consumesMany ()
 
template<typename T , BranchType = InEvent>
ProductToken< T > mayConsume (InputTag const &)
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > mayConsumeView (InputTag const &)
 
template<typename T , BranchType = InEvent>
void mayConsumeMany ()
 

Detailed Description

Definition at line 52 of file MuonCounterTimes_module.cc.

Constructor & Destructor Documentation

MyMuoncountertimes::Muoncountertimes::Muoncountertimes ( fhicl::ParameterSet const &  p)
explicit

Definition at line 104 of file MuonCounterTimes_module.cc.

105  : EDAnalyzer(pset)
106 {
107  // Read in the parameters from the .fcl file.
108  this->reconfigure(pset);
109 }
EDAnalyzer(fhicl::ParameterSet const &pset)
Definition: EDAnalyzer.h:27
void reconfigure(fhicl::ParameterSet const &pset)
MyMuoncountertimes::Muoncountertimes::~Muoncountertimes ( )
virtual

Definition at line 133 of file MuonCounterTimes_module.cc.

134 {
135  // Clean up dynamic memory and other resources here.
136 }

Member Function Documentation

void MyMuoncountertimes::Muoncountertimes::analyze ( const art::Event evt)

Definition at line 138 of file MuonCounterTimes_module.cc.

139 {
140  // Implementation of required member function here.
141  ResetVars();
142 
144 
145  run = evt.run();
146  subrun = evt.subRun();
147  event = evt.id().event();
148 
149  // New way to get counter hits
150  /*
151  art::Handle< std::vector< raw::ExternalTrigger> > externalTriggerListHandle;
152  evt.getByLabel(fCounterModuleLabel, externalTriggerListHandle);
153  std::vector< art::Ptr< raw::ExternalTrigger> > trigs;
154  art::fill_ptr_vector(trigs,externalTriggerListHandle);
155  */
156 
158 
159  evt.getByLabel(fRawDataLabel, fFragType, fragment);
160 
161  // Check if there is PTB data in this event
162  // Don't crash code if not present, just don't save anything
163  try { fragment->size(); }
164  catch(std::exception const&) {
165  mf::LogWarning("MuonCounterTimes") << "WARNING: Raw PTB data not found in event " << evt.event();
166  return;
167  }
168 
169  // Check that the data is valid
170  if(!fragment.isValid()){
171  mf::LogError("MuonCounterTimes") << "Run: " << evt.run()
172  << ", SubRun: " << evt.subRun()
173  << ", Event: " << evt.event()
174  << " is NOT VALID";
175  throw cet::exception("raw NOT VALID");
176  return;
177  }
178 
179  std::vector<std::vector<int>> coincidences(2);
180  std::vector<std::vector<int>> trig_ID_Vec(2);
181  std::vector<std::vector<long long>> trig_Times_Vec(2);
182  lbne::PennMicroSlice::Payload_Timestamp *FirstPTBTimestamp = nullptr;
183  auto trigs = DAQToOffline::PennFragmentToExternalTrigger(*fragment, fPTBMap, FirstPTBTimestamp);
184 
185  unsigned int total_Hits = trigs.size();
186 
187  for(unsigned int i = 0; i < total_Hits; i++)
188  {
189  int auxdetid = trigs.at(i).GetTrigID();
190  long long trig_Time = trigs.at(i).GetTrigTime();
191 
192  if(auxdetid>=fLower_Block1 && auxdetid<=fUpper_Block1)
193  {
194  trig_ID_Vec.at(0).push_back(auxdetid);
195  trig_Times_Vec.at(0).push_back(trig_Time);
196  }
197  else if(auxdetid>=fLower_Block2 && auxdetid<=fUpper_Block2)
198  {
199  trig_ID_Vec.at(1).push_back(auxdetid);
200  trig_Times_Vec.at(1).push_back(trig_Time);
201  }
202  }
203 
204  for(unsigned int i = 0; i < trig_ID_Vec.at(0).size(); i++)
205  {
206  for(unsigned int j = 0; j < trig_ID_Vec.at(1).size(); j++)
207  {
208  if(j<=i)
209  {
210  if(std::abs(trig_Times_Vec.at(0).at(i)-trig_Times_Vec.at(1).at(j))<fCoincidence_Window)
211  {
212  coincidences.at(0).push_back(trig_ID_Vec.at(0).at(i));
213  coincidences.at(1).push_back(trig_ID_Vec.at(1).at(j));
214  }
215  }
216  }
217  }
218 
219  for(unsigned int i = 0; i < coincidences.at(0).size(); i++)
220  {
221  fHist_Vec.at(coincidences.at(0).at(i)-fLower_Block1)->Fill(coincidences.at(1).at(i));
222  }
223  event_Count+=1;
224 }
EventNumber_t event() const
Definition: DataViewImpl.cc:96
MaybeLogger_< ELseverityLevel::ELsev_error, false > LogError
bool isValid() const
Definition: Handle.h:183
T abs(T value)
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
Definition: DataViewImpl.h:446
SubRunNumber_t subRun() const
Definition: DataViewImpl.cc:89
RunNumber_t run() const
Definition: DataViewImpl.cc:82
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
EventNumber_t event() const
Definition: EventID.h:116
std::vector< raw::ExternalTrigger > PennFragmentToExternalTrigger(artdaq::Fragments const &Fragments, std::map< int, int > &channelMap, lbne::PennMicroSlice::Payload_Timestamp *&FirstPTBTimestamp)
EventID id() const
Definition: Event.cc:37
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
void MyMuoncountertimes::Muoncountertimes::beginJob ( )
virtual

Reimplemented from art::EDAnalyzer.

Definition at line 226 of file MuonCounterTimes_module.cc.

227 {
228  // Implementation of optional member function here.
229 
231 
233 
234  for(unsigned int i = 0; i < fHist_Vec.size(); i++)
235  {
236  TString key = Form("h%i", i);
237  TH1D *tempHist = tfs->make<TH1D>(key, key, fUpper_Block2-fLower_Block2+1, fLower_Block2, fUpper_Block2+1);
238  fHist_Vec.at(i) = tempHist;
239  }
240 }
def key(type, name=None)
Definition: graph.py:13
void MyMuoncountertimes::Muoncountertimes::endJob ( )
virtual

Reimplemented from art::EDAnalyzer.

Definition at line 242 of file MuonCounterTimes_module.cc.

243 {
244  for(unsigned int i = 0; i < fHist_Vec.size(); i++)
245  {
246  TString fHist_Title1 = Form("Coincidence Plots, run %i, ", run);
247  TString fHist_Title2 = Form("counter %i.", i+fLower_Block1);
248  TString fHist_Title = fHist_Title1 + fHist_Title2;
249 
250  TString fHist_Name1 = Form("Run%i", run);
251  TString fHist_Name2 = Form("Counter%i", i+fLower_Block1);
252  TString fHist_Name = fHist_Name1 + fHist_Name2;
253 
254  fHist_Vec.at(i)->GetXaxis()->SetTitle("Coincidence Partner");
255  fHist_Vec.at(i)->GetYaxis()->SetTitle("Frequency");
256  fHist_Vec.at(i)->GetYaxis()->SetTitleOffset(1.);
257 
258  fHist_Vec.at(i)->SetTitle(fHist_Title);
259  fHist_Vec.at(i)->SetName(fHist_Name);
260 
261  fHist_Vec.at(i)->Sumw2();
262  }
263 }
void MyMuoncountertimes::Muoncountertimes::reconfigure ( fhicl::ParameterSet const &  pset)

Definition at line 111 of file MuonCounterTimes_module.cc.

112 { // Read parameters from the .fcl file. The names in the arguments
113  // to p.get<TYPE> must match names in the .fcl file.
114 
115  fLower_Block1 = p.get<int>("LowerBlock1");
116  fUpper_Block1 = p.get<int>("UpperBlock1");
117  fLower_Block2 = p.get<int>("LowerBlock2");
118  fUpper_Block2 = p.get<int>("UpperBlock2");
119  fCoincidence_Window = p.get<int>("CoincidenceWindow");
120  fCounterModuleLabel = p.get< std::string >("CounterModuleLabel");
121  // fLArG4ModuleLabel(p.get< std::string >("LArGeantModuleLabel", "largeant"));
122  fCombinedTimeDelay = p.get< double >("CombinedTimeDelay");
123  fFragType = p.get<std::string>("FragType");
124  fRawDataLabel = p.get<std::string>("DataLabel");
125  fPTBMapFile = p.get<std::string>("PTBMapFile");
126  fPTBMapDir = p.get<std::string>("PTBMapDir");
127 
128  DAQToOffline::BuildPTBChannelMap(fPTBMapDir, fPTBMapFile, fPTBMap);
129 
130  return;
131 }
std::string string
Definition: nybbler.cc:12
void BuildPTBChannelMap(std::string MapDir, std::string MapFile, std::map< int, int > &channelMap)
p
Definition: test.py:223
void MyMuoncountertimes::Muoncountertimes::ResetVars ( void  )
private

Definition at line 265 of file MuonCounterTimes_module.cc.

265  {
266 
267  run = -99999;
268  subrun = -99999;
269  event = -99999;
270 }

Member Data Documentation

int MyMuoncountertimes::Muoncountertimes::event
private

Definition at line 83 of file MuonCounterTimes_module.cc.

int MyMuoncountertimes::Muoncountertimes::event_Count = 0
private

Definition at line 84 of file MuonCounterTimes_module.cc.

int MyMuoncountertimes::Muoncountertimes::fCoincidence_Window
private

Definition at line 93 of file MuonCounterTimes_module.cc.

double MyMuoncountertimes::Muoncountertimes::fCombinedTimeDelay
private

Definition at line 94 of file MuonCounterTimes_module.cc.

std::string MyMuoncountertimes::Muoncountertimes::fCounterModuleLabel
private

Definition at line 95 of file MuonCounterTimes_module.cc.

std::string MyMuoncountertimes::Muoncountertimes::fFragType
private

Definition at line 96 of file MuonCounterTimes_module.cc.

std::vector<TH1D*> MyMuoncountertimes::Muoncountertimes::fHist_Vec
private

Definition at line 87 of file MuonCounterTimes_module.cc.

int MyMuoncountertimes::Muoncountertimes::fLower_Block1
private

Definition at line 89 of file MuonCounterTimes_module.cc.

int MyMuoncountertimes::Muoncountertimes::fLower_Block2
private

Definition at line 91 of file MuonCounterTimes_module.cc.

std::map<int,int> MyMuoncountertimes::Muoncountertimes::fPTBMap
private

Definition at line 101 of file MuonCounterTimes_module.cc.

std::string MyMuoncountertimes::Muoncountertimes::fPTBMapDir
private

Definition at line 99 of file MuonCounterTimes_module.cc.

std::string MyMuoncountertimes::Muoncountertimes::fPTBMapFile
private

Definition at line 98 of file MuonCounterTimes_module.cc.

std::string MyMuoncountertimes::Muoncountertimes::fRawDataLabel
private

Definition at line 97 of file MuonCounterTimes_module.cc.

int MyMuoncountertimes::Muoncountertimes::fUpper_Block1
private

Definition at line 90 of file MuonCounterTimes_module.cc.

int MyMuoncountertimes::Muoncountertimes::fUpper_Block2
private

Definition at line 92 of file MuonCounterTimes_module.cc.

int MyMuoncountertimes::Muoncountertimes::run
private

Definition at line 81 of file MuonCounterTimes_module.cc.

int MyMuoncountertimes::Muoncountertimes::subrun
private

Definition at line 82 of file MuonCounterTimes_module.cc.


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