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

Public Member Functions

 CheckCRT (fhicl::ParameterSet const &p)
 
 CheckCRT (CheckCRT const &)=delete
 
 CheckCRT (CheckCRT &&)=delete
 
CheckCRToperator= (CheckCRT const &)=delete
 
CheckCRToperator= (CheckCRT &&)=delete
 
void analyze (art::Event const &e) override
 
void beginJob () override
 
- 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 (SharedResources const &resources)
 
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 &)
 
fhicl::ParameterSetID selectorConfig () 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

std::vector< unsigned short > GetModules (int pixel)
 

Private Attributes

TTree * fTree
 
int run
 
int subrun
 
int event
 
std::vector< uint32_t > crtmask
 
std::vector< ULong64_t > rdtime
 
std::vector< unsigned int > crtmodule
 
std::vector< unsigned long long > crttime
 
std::vector< double > trkstartx_pandora
 
std::vector< double > trkstarty_pandora
 
std::vector< double > trkstartz_pandora
 
std::vector< double > trkendx_pandora
 
std::vector< double > trkendy_pandora
 
std::vector< double > trkendz_pandora
 
std::vector< double > t0_pandora
 
std::vector< double > trkstartx_pmtrack
 
std::vector< double > trkstarty_pmtrack
 
std::vector< double > trkstartz_pmtrack
 
std::vector< double > trkendx_pmtrack
 
std::vector< double > trkendy_pmtrack
 
std::vector< double > trkendz_pmtrack
 
std::vector< double > t0_pmtrack
 

Additional Inherited Members

- Public Types inherited from art::EDAnalyzer
using WorkerType = WorkerT< EDAnalyzer >
 
using ModuleType = EDAnalyzer
 
- Protected Member Functions inherited from art::Observer
std::string const & processName () const
 
bool wantAllEvents () const noexcept
 
bool wantEvent (ScheduleID id, Event const &e) const
 
Handle< TriggerResultsgetTriggerResults (Event const &e) const
 
 Observer (fhicl::ParameterSet const &config)
 
 Observer (std::vector< std::string > const &select_paths, std::vector< std::string > const &reject_paths, fhicl::ParameterSet const &config)
 
- 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 34 of file CheckCRT_module.cc.

Constructor & Destructor Documentation

pdsp::CheckCRT::CheckCRT ( fhicl::ParameterSet const &  p)
explicit

Definition at line 84 of file CheckCRT_module.cc.

85  : EDAnalyzer{p} // ,
86  // More initializers here.
87 {
88 }
EDAnalyzer(fhicl::ParameterSet const &pset)
Definition: EDAnalyzer.h:25
p
Definition: test.py:223
pdsp::CheckCRT::CheckCRT ( CheckCRT const &  )
delete
pdsp::CheckCRT::CheckCRT ( CheckCRT &&  )
delete

Member Function Documentation

void pdsp::CheckCRT::analyze ( art::Event const &  e)
overridevirtual

Implements art::EDAnalyzer.

Definition at line 251 of file CheckCRT_module.cc.

252 {
253 
254  run = e.run();
255  subrun = e.subRun();
256  event = e.id().event();
257 
258  crtmask.clear();
259  rdtime.clear();
260  crtmodule.clear();
261  crttime.clear();
262 
263  trkstartx_pandora.clear();
264  trkstarty_pandora.clear();
265  trkstartz_pandora.clear();
266  trkendx_pandora.clear();
267  trkendy_pandora.clear();
268  trkendz_pandora.clear();
269  t0_pandora.clear();
270 
271  trkstartx_pmtrack.clear();
272  trkstarty_pmtrack.clear();
273  trkstartz_pmtrack.clear();
274  trkendx_pmtrack.clear();
275  trkendy_pmtrack.clear();
276  trkendz_pmtrack.clear();
277  t0_pmtrack.clear();
278 
279  art::ValidHandle<std::vector<raw::RDTimeStamp>> timeStamps = e.getValidHandle<std::vector<raw::RDTimeStamp>>("timingrawdecoder:daq");
280 
281  int trigger = -1;
282  // Check that we have good information
283  if(timeStamps.isValid() && timeStamps->size() == 1){
284  // Access the trigger information. Beam trigger flag = 0xc
285  const raw::RDTimeStamp& timeStamp = timeStamps->at(0);
286  trigger = timeStamp.GetFlags();
287  }
288 
289  if (trigger!=13) return;
290 
291  auto const& pdspctbs = *e.getValidHandle<std::vector<raw::ctb::pdspctb>>("ctbrawdecoder:daq");
292  if (!pdspctbs.empty()){
293  const size_t npdspctbs = pdspctbs.size();
294  for (size_t i=0; i<npdspctbs; ++i){
295 // std::cout << "Number of triggers: " << pdspctbs[i].GetNTriggers() << std::endl;
296 // std::cout << "Number of chstatuses: " << pdspctbs[i].GetNChStatuses() << std::endl;
297 // std::cout << "Number of feedbacks: " << pdspctbs[i].GetNFeedbacks() << std::endl;
298 // std::cout << "Number of miscs: " << pdspctbs[i].GetNMiscs() << std::endl;
299 //
300 // const std::vector<raw::ctb::Trigger> HLTriggers = pdspctbs[i].GetHLTriggers();
301 // std::cout << "Number of HL Triggers: " << HLTriggers.size() << std::endl;
302 // for (size_t j=0; j<HLTriggers.size(); ++j){
303 // std::cout << "HL Trigger: " << j << " " << HLTriggers[j].word_type << " " << HLTriggers[j].trigger_word << " " << HLTriggers[j].timestamp << std::endl;
304 // }
305 
306  const std::vector<raw::ctb::ChStatus> chs = pdspctbs[i].GetChStatusAfterHLTs();
307  std::cout << "Number of CH Status after HLTs: " << chs.size() << std::endl;
308  for (size_t j=0; j<chs.size(); ++j){
309  //std::cout << " chs after HLT: " << j << " " << chs[j].word_type << " " << chs[j].pds << " " << chs[j].crt << " " << chs[j].beam_hi << " " << chs[j].beam_lo << std::endl;
310  crtmask.push_back(chs[j].crt);
311  }
312 //
313 //
314 // const std::vector<raw::ctb::Trigger> LLTriggers = pdspctbs[i].GetLLTriggers();
315 // std::cout << "Number of LL Triggers: " << LLTriggers.size() << std::endl;
316 // for (size_t j=0; j<LLTriggers.size(); ++j){
317 // std::cout << "LL Trigger: " << j << " " << LLTriggers[j].word_type << " " << LLTriggers[j].trigger_word << " " << LLTriggers[j].timestamp << std::endl;
318 // }
319 //
320 // const std::vector<raw::ctb::WordIndex> indexes = pdspctbs[i].GetIndexes();
321 // std::cout << "Number of Indexes: " << indexes.size() << std::endl;
322 // for (size_t j=0; j<indexes.size(); ++j){
323 // std::cout << "Index: " << j << " " << indexes[j].word_type << " " << indexes[j].index << std::endl;
324 // }
325 
326  }
327  }
328  //Save CRT trigger information
329  const auto & triggers = *e.getValidHandle < std::vector < CRT::Trigger >> ("crtrawdecoder");
330  for (const auto& trigger: triggers){
331  //std::cout<<"module: "<<trigger.Channel()<<" time: "<<trigger.Timestamp()<<std::endl;
332  crtmodule.push_back(trigger.Channel());
333  crttime.push_back(trigger.Timestamp());
334  }
335  for (const auto& time : *timeStamps){
336  rdtime.push_back(time.GetTimeStamp());
337  }
338  /*
339  for (auto const& crt_mask : crtmask){
340  int pixel[2] = {-1, -1};
341  for (size_t i = 0; i<32; ++i){
342  if (crt_mask & (1<<i)){
343  if (i<16){
344  pixel[0] = i;
345  }
346  else {
347  pixel[1] = i;
348  }
349  }
350  }
351  std::cout<<"Pixels "<<pixel[0]<<" "<<pixel[1]<<std::endl;
352  for (size_t i = 0; i<2; ++i){
353  if (pixel[i]!=-1){
354  std::vector<unsigned short> modules = GetModules(pixel[i]);
355  for (size_t j = 0; j<2; ++j){
356  for (const auto& trigger: triggers){
357  if (trigger.Channel() == modules[j]){
358  std::cout<<"Pixel: "<<pixel[i]<<" module: "<<trigger.Channel()<<" time: "<<trigger.Timestamp()<<" "<<timeStamps->at(0).GetTimeStamp()<<std::endl;
359  }
360  }
361  }
362  }
363  }
364  }
365  */
366 
367  std::vector< art::Ptr<recob::Track> > pandoratrks;
368  auto pandoratrkHandle = e.getHandle< std::vector<recob::Track> >("pandoraTrack");
369  if (pandoratrkHandle) art::fill_ptr_vector(pandoratrks, pandoratrkHandle);
370  else return;
371 
372  auto pfpListHandle = e.getHandle< std::vector<recob::PFParticle> >("pandora");
373  art::FindManyP<recob::PFParticle> fmpfp(pandoratrkHandle, e, "pandoraTrack");
374  art::FindManyP<anab::T0> fmt0pandora(pfpListHandle, e, "pandora");
375 
376  for (size_t i = 0; i<pandoratrks.size(); ++i){
377  auto & trk = pandoratrks[i];
378  trkstartx_pandora.push_back(trk->Vertex().X());
379  trkstarty_pandora.push_back(trk->Vertex().Y());
380  trkstartz_pandora.push_back(trk->Vertex().Z());
381  trkendx_pandora.push_back(trk->End().X());
382  trkendy_pandora.push_back(trk->End().Y());
383  trkendz_pandora.push_back(trk->End().Z());
384  double t0 = 0;
385  auto &pfps = fmpfp.at(trk.key());
386  if (!pfps.empty()){
387  auto &t0s = fmt0pandora.at(pfps[0].key());
388  if (!t0s.empty()){
389  t0 = t0s[0]->Time();
390  }
391  }
392  t0_pandora.push_back(t0);
393  }
394 
395  /*
396  std::vector< art::Ptr<recob::Track> > pmtracktrks;
397  auto pmtracktrkHandle = e.getHandle< std::vector<recob::Track> >("pmtrack");
398  if (pmtracktrkHandle) art::fill_ptr_vector(pmtracktrks, pmtracktrkHandle);
399 
400  art::FindManyP<anab::T0> fmt0pmtrack(pmtracktrkHandle, e, "pmtrack");
401 
402  for (size_t i = 0; i<pmtracktrks.size(); ++i){
403  auto & trk = pmtracktrks[i];
404  trkstartx_pmtrack.push_back(trk->Vertex().X());
405  trkstarty_pmtrack.push_back(trk->Vertex().Y());
406  trkstartz_pmtrack.push_back(trk->Vertex().Z());
407  trkendx_pmtrack.push_back(trk->End().X());
408  trkendy_pmtrack.push_back(trk->End().Y());
409  trkendz_pmtrack.push_back(trk->End().Z());
410  double t0 = 0;
411  auto &t0s = fmt0pmtrack.at(trk.key());
412  if (!t0s.empty()){
413  t0 = t0s[0]->Time();
414  }
415  t0_pmtrack.push_back(t0);
416  }
417  */
418  fTree->Fill();
419 }
code to link reconstructed objects back to the MC truth information
std::vector< double > trkstartx_pandora
std::vector< double > trkendy_pandora
std::vector< unsigned int > crtmodule
uint16_t GetFlags() const
Definition: RDTimeStamp.h:46
std::vector< double > trkendy_pmtrack
std::vector< double > trkendz_pandora
std::vector< double > trkendx_pandora
const double e
std::vector< double > trkendx_pmtrack
def key(type, name=None)
Definition: graph.py:13
std::vector< double > trkstartz_pmtrack
std::vector< double > t0_pmtrack
std::vector< double > trkstarty_pmtrack
std::vector< double > trkstartx_pmtrack
std::vector< double > t0_pandora
std::vector< uint32_t > crtmask
std::vector< ULong64_t > rdtime
std::vector< double > trkstarty_pandora
std::vector< double > trkstartz_pandora
std::vector< unsigned long long > crttime
void fill_ptr_vector(std::vector< Ptr< T >> &ptrs, H const &h)
Definition: Ptr.h:297
std::vector< double > trkendz_pmtrack
QTextStream & endl(QTextStream &s)
bool isValid() const
Definition: Handle.h:330
void pdsp::CheckCRT::beginJob ( )
overridevirtual

Reimplemented from art::EDAnalyzer.

Definition at line 222 of file CheckCRT_module.cc.

223 {
225  fTree = tfs->make<TTree>("crt","crt tree");
226  fTree->Branch("run",&run,"run/I");
227  fTree->Branch("subrun",&subrun,"subrun/I");
228  fTree->Branch("event",&event,"event/I");
229  fTree->Branch("crtmask", &crtmask);
230  fTree->Branch("rdtime", &rdtime);
231  fTree->Branch("crtmodule", &crtmodule);
232  fTree->Branch("crttime", &crttime);
233  fTree->Branch("trkstartx_pandora",&trkstartx_pandora);
234  fTree->Branch("trkstarty_pandora",&trkstarty_pandora);
235  fTree->Branch("trkstartz_pandora",&trkstartz_pandora);
236  fTree->Branch("trkendx_pandora",&trkendx_pandora);
237  fTree->Branch("trkendy_pandora",&trkendy_pandora);
238  fTree->Branch("trkendz_pandora",&trkendz_pandora);
239  fTree->Branch("t0_pandora",&t0_pandora);
240 
241  fTree->Branch("trkstartx_pmtrack",&trkstartx_pmtrack);
242  fTree->Branch("trkstarty_pmtrack",&trkstarty_pmtrack);
243  fTree->Branch("trkstartz_pmtrack",&trkstartz_pmtrack);
244  fTree->Branch("trkendx_pmtrack",&trkendx_pmtrack);
245  fTree->Branch("trkendy_pmtrack",&trkendy_pmtrack);
246  fTree->Branch("trkendz_pmtrack",&trkendz_pmtrack);
247  fTree->Branch("t0_pmtrack",&t0_pmtrack);
248 
249 }
std::vector< double > trkstartx_pandora
std::vector< double > trkendy_pandora
std::vector< unsigned int > crtmodule
std::vector< double > trkendy_pmtrack
std::vector< double > trkendz_pandora
std::vector< double > trkendx_pandora
std::vector< double > trkendx_pmtrack
std::vector< double > trkstartz_pmtrack
std::vector< double > t0_pmtrack
std::vector< double > trkstarty_pmtrack
std::vector< double > trkstartx_pmtrack
std::vector< double > t0_pandora
std::vector< uint32_t > crtmask
std::vector< ULong64_t > rdtime
std::vector< double > trkstarty_pandora
std::vector< double > trkstartz_pandora
std::vector< unsigned long long > crttime
std::vector< double > trkendz_pmtrack
Event finding and building.
std::vector< unsigned short > pdsp::CheckCRT::GetModules ( int  pixel)
private

Definition at line 89 of file CheckCRT_module.cc.

89  {
90  std::vector<unsigned short> modules(2,-1);
91  if (pixel == 0){
92  modules[0] = 1;
93  modules[1] = 2;
94  }
95  else if (pixel == 1){
96  modules[0] = 0;
97  modules[1] = 2;
98  }
99  else if (pixel == 2){
100  modules[0] = 15;
101  modules[1] = 13;
102  }
103  else if (pixel == 3){
104  modules[0] = 14;
105  modules[1] = 13;
106  }
107  else if (pixel == 4){
108  modules[0] = 14;
109  modules[1] = 12;
110  }
111  else if (pixel == 5){
112  modules[0] = 9;
113  modules[1] = 11;
114  }
115  else if (pixel == 6){
116  modules[0] = 9;
117  modules[1] = 10;
118  }
119  else if (pixel == 7){
120  modules[0] = 8;
121  modules[1] = 10;
122  }
123  else if (pixel == 8){
124  modules[0] = 7;
125  modules[1] = 5;
126  }
127  else if (pixel == 9){
128  modules[0] = 6;
129  modules[1] = 5;
130  }
131  else if (pixel == 10){
132  modules[0] = 6;
133  modules[1] = 4;
134  }
135  else if (pixel == 11){
136  modules[0] = 1;
137  modules[1] = 3;
138  }
139  else if (pixel == 12){
140  modules[0] = 0;
141  modules[1] = 3;
142  }
143  else if (pixel == 13){
144  modules[0] = 15;
145  modules[1] = 12;
146  }
147  else if (pixel == 14){
148  modules[0] = 8;
149  modules[1] = 11;
150  }
151  else if (pixel == 15){
152  modules[0] = 7;
153  modules[1] = 4;
154  }
155  else if (pixel == 16){
156  modules[0] = 17;
157  modules[1] = 18;
158  }
159  else if (pixel == 17){
160  modules[0] = 16;
161  modules[1] = 18;
162  }
163  else if (pixel == 18){
164  modules[0] = 31;
165  modules[1] = 29;
166  }
167  else if (pixel == 19){
168  modules[0] = 30;
169  modules[1] = 29;
170  }
171  else if (pixel == 20){
172  modules[0] = 30;
173  modules[1] = 28;
174  }
175  else if (pixel == 21){
176  modules[0] = 25;
177  modules[1] = 27;
178  }
179  else if (pixel == 22){
180  modules[0] = 25;
181  modules[1] = 26;
182  }
183  else if (pixel == 23){
184  modules[0] = 24;
185  modules[1] = 26;
186  }
187  else if (pixel == 24){
188  modules[0] = 23;
189  modules[1] = 21;
190  }
191  else if (pixel == 25){
192  modules[0] = 22;
193  modules[1] = 21;
194  }
195  else if (pixel == 26){
196  modules[0] = 22;
197  modules[1] = 20;
198  }
199  else if (pixel == 27){
200  modules[0] = 17;
201  modules[1] = 19;
202  }
203  else if (pixel == 28){
204  modules[0] = 16;
205  modules[1] = 19;
206  }
207  else if (pixel == 29){
208  modules[0] = 31;
209  modules[1] = 28;
210  }
211  else if (pixel == 30){
212  modules[0] = 24;
213  modules[1] = 27;
214  }
215  else if (pixel == 31){
216  modules[0] = 23;
217  modules[1] = 20;
218  }
219  return modules;
220 }
CheckCRT& pdsp::CheckCRT::operator= ( CheckCRT const &  )
delete
CheckCRT& pdsp::CheckCRT::operator= ( CheckCRT &&  )
delete

Member Data Documentation

std::vector<uint32_t> pdsp::CheckCRT::crtmask
private

Definition at line 61 of file CheckCRT_module.cc.

std::vector<unsigned int> pdsp::CheckCRT::crtmodule
private

Definition at line 63 of file CheckCRT_module.cc.

std::vector<unsigned long long> pdsp::CheckCRT::crttime
private

Definition at line 64 of file CheckCRT_module.cc.

int pdsp::CheckCRT::event
private

Definition at line 60 of file CheckCRT_module.cc.

TTree* pdsp::CheckCRT::fTree
private

Definition at line 56 of file CheckCRT_module.cc.

std::vector<ULong64_t> pdsp::CheckCRT::rdtime
private

Definition at line 62 of file CheckCRT_module.cc.

int pdsp::CheckCRT::run
private

Definition at line 58 of file CheckCRT_module.cc.

int pdsp::CheckCRT::subrun
private

Definition at line 59 of file CheckCRT_module.cc.

std::vector<double> pdsp::CheckCRT::t0_pandora
private

Definition at line 71 of file CheckCRT_module.cc.

std::vector<double> pdsp::CheckCRT::t0_pmtrack
private

Definition at line 79 of file CheckCRT_module.cc.

std::vector<double> pdsp::CheckCRT::trkendx_pandora
private

Definition at line 68 of file CheckCRT_module.cc.

std::vector<double> pdsp::CheckCRT::trkendx_pmtrack
private

Definition at line 76 of file CheckCRT_module.cc.

std::vector<double> pdsp::CheckCRT::trkendy_pandora
private

Definition at line 69 of file CheckCRT_module.cc.

std::vector<double> pdsp::CheckCRT::trkendy_pmtrack
private

Definition at line 77 of file CheckCRT_module.cc.

std::vector<double> pdsp::CheckCRT::trkendz_pandora
private

Definition at line 70 of file CheckCRT_module.cc.

std::vector<double> pdsp::CheckCRT::trkendz_pmtrack
private

Definition at line 78 of file CheckCRT_module.cc.

std::vector<double> pdsp::CheckCRT::trkstartx_pandora
private

Definition at line 65 of file CheckCRT_module.cc.

std::vector<double> pdsp::CheckCRT::trkstartx_pmtrack
private

Definition at line 73 of file CheckCRT_module.cc.

std::vector<double> pdsp::CheckCRT::trkstarty_pandora
private

Definition at line 66 of file CheckCRT_module.cc.

std::vector<double> pdsp::CheckCRT::trkstarty_pmtrack
private

Definition at line 74 of file CheckCRT_module.cc.

std::vector<double> pdsp::CheckCRT::trkstartz_pandora
private

Definition at line 67 of file CheckCRT_module.cc.

std::vector<double> pdsp::CheckCRT::trkstartz_pmtrack
private

Definition at line 75 of file CheckCRT_module.cc.


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