LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
evd::Landed Class Reference
Inheritance diagram for evd::Landed:
art::EDAnalyzer art::EventObserverBase art::Consumer art::EngineCreator

Public Types

using WorkerType = WorkerT< EDAnalyzer >
 
using ModuleType = EDAnalyzer
 

Public Member Functions

 Landed (fhicl::ParameterSet const &p)
 
 Landed (Landed const &)=delete
 
 Landed (Landed &&)=delete
 
Landedoperator= (Landed const &)=delete
 
Landedoperator= (Landed &&)=delete
 
void analyze (art::Event const &e) override
 
void beginJob () override
 
void endJob () override
 
std::string workerType () const
 
bool modifiesEvent () const
 
void registerProducts (MasterProductRegistry &, ProductDescriptions &, ModuleDescription const &)
 
std::string const & processName () const
 
bool wantAllEvents () const
 
bool wantEvent (Event const &e)
 
fhicl::ParameterSetID selectorConfig () const
 
art::Handle< art::TriggerResultsgetTriggerResults (Event const &e) const
 
template<typename T , BranchType = InEvent>
ProductToken< T > consumes (InputTag const &)
 
template<typename T , art::BranchType BT>
art::ProductToken< T > consumes (InputTag const &it)
 
template<typename T , BranchType = InEvent>
void consumesMany ()
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > consumesView (InputTag const &)
 
template<typename T , art::BranchType BT>
art::ViewToken< T > consumesView (InputTag const &it)
 
template<typename T , BranchType = InEvent>
ProductToken< T > mayConsume (InputTag const &)
 
template<typename T , art::BranchType BT>
art::ProductToken< T > mayConsume (InputTag const &it)
 
template<typename T , BranchType = InEvent>
void mayConsumeMany ()
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > mayConsumeView (InputTag const &)
 
template<typename T , art::BranchType BT>
art::ViewToken< T > mayConsumeView (InputTag const &it)
 
base_engine_tcreateEngine (seed_t seed)
 
base_engine_tcreateEngine (seed_t seed, std::string const &kind_of_engine_to_make)
 
base_engine_tcreateEngine (seed_t seed, std::string const &kind_of_engine_to_make, label_t const &engine_label)
 
seed_t get_seed_value (fhicl::ParameterSet const &pset, char const key[]="seed", seed_t const implicit_seed=-1)
 

Static Public Member Functions

static cet::exempt_ptr< Consumernon_module_context ()
 

Protected Member Functions

CurrentProcessingContext const * currentContext () const
 
detail::CachedProducts & cachedProducts ()
 
void validateConsumedProduct (BranchType const bt, ProductInfo const &pi)
 
void prepareForJob (fhicl::ParameterSet const &pset)
 
void showMissingConsumes () const
 

Private Attributes

art::ServiceHandle< geo::Geometrygeom_
 
art::ServiceHandle< LandedSocketsock_
 
std::string vrml_
 
std::string outputFilename_
 
std::string which_
 
sqlite3 * ppDb_
 
std::vector< int > events_
 

Detailed Description

Definition at line 63 of file Landed_module.cc.

Member Typedef Documentation

Definition at line 39 of file EDAnalyzer.h.

Definition at line 38 of file EDAnalyzer.h.

Constructor & Destructor Documentation

evd::Landed::Landed ( fhicl::ParameterSet const &  p)
explicit

Definition at line 94 of file Landed_module.cc.

References geo::GeometryCore::GDMLFile(), geom_, outputFilename_, sock_, and vrml_.

94  :
95  EDAnalyzer(p),
96  // More initializers here.
99  outputFilename_(p.get<std::string>("outputFilename", "")),
100  which_(p.get<std::string>("which", "truth")),
101  ppDb_(nullptr),
102  events_(p.get<std::vector<int> >("events", std::vector<int>()))
103 {
104 
105  if (outputFilename_.empty() && !sock_->connect())
106  {
107  throw cet::exception("Landed") << "no output filename specified and unable to connect to LANDED app using local socket\n" <<
108  "please either specify a filename, or check LANDED is running and that you have started the server\n";
109 
110  }
111  // sock_->hello();
112 
113  std::string gdml=geom_->GDMLFile();
114 
115  // g4b::G4Helper* g4helper=new g4b::G4Helper();
116  // g4helper->ConstructDetector(gdml_);
117  // g4helper->InitPhysics();
118  G4RunManager* runManager=new G4RunManager;
119  runManager->SetUserInitialization(new g4b::DetectorConstruction(gdml));
120  runManager->SetUserInitialization(new QGSP_BERT);
121  // Visualization manager construction
122  G4VisManager* visManager = new G4VisExecutive;
123  visManager->Initialize();
124 
125  char tmpdir[1024];
126  strcpy(tmpdir, "/tmp/vcXXXXXX");
127  mkdtemp(tmpdir);
128  strcat(tmpdir, "/");
129  char* vrmlviewer=getenv("G4VRMLFILE_VIEWER");
130  if (vrmlviewer)
131  unsetenv("G4VRMLFILE_VIEWER");
132  char* oldvrmldir=getenv("G4VRMLFILE_DEST_DIR");
133  setenv("G4VRMLFILE_DEST_DIR", tmpdir, 1);
134  G4UImanager* UImanager = G4UImanager::GetUIpointer();
135  UImanager->ApplyCommand("/run/initialize");
136  UImanager->ApplyCommand("/vis/open VRML2FILE");
137  UImanager->ApplyCommand("/vis/drawVolume");
138  UImanager->ApplyCommand("/vis/viewer/flush");
139  if (oldvrmldir)
140  setenv("G4VRMLFILE_DEST_DIR", oldvrmldir, 1);
141  else
142  unsetenv("G4VRMLFILE_DEST_DIR");
143  if (vrmlviewer)
144  setenv("G4VRMLFILE_VIEWER", vrmlviewer, 1);
145 
146  char tmpname[1024];
147  strcpy(tmpname, tmpdir);
148  strcat(tmpname, "g4_00.wrl");
149  std::ifstream geofile(tmpname);
150  std::stringstream geodata;
151  geodata << geofile.rdbuf();
152  geofile.close();
153  ::remove(tmpname);
154  ::remove(tmpdir);
155  vrml_=geodata.str();
156 
157  // std::cout << "!!!!!!! " << geodata.str().length() << std::endl;
158  // std::cout << geodata.str() << std::endl;
159 
160 }
std::string which_
std::vector< int > events_
art::ServiceHandle< geo::Geometry > geom_
std::string GDMLFile() const
Returns the full directory path to the GDML file source.
std::string vrml_
sqlite3 * ppDb_
EDAnalyzer(Table< Config > const &config)
Definition: EDAnalyzer.h:100
std::string outputFilename_
art::ServiceHandle< LandedSocket > sock_
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
evd::Landed::Landed ( Landed const &  )
delete
evd::Landed::Landed ( Landed &&  )
delete

Member Function Documentation

void evd::Landed::analyze ( art::Event const &  e)
overridevirtual

Implements art::EDAnalyzer.

Definition at line 237 of file Landed_module.cc.

References DEFINE_ART_MODULE, energy, events_, geom_, geo::kCollection, outputFilename_, part, ppDb_, geo::GeometryCore::SignalType(), sock_, and which_.

238 {
239  if (!events_.size() || outputFilename_.empty() || std::find(events_.begin(), events_.end(), event.event())!=events_.end())
240  {
241  sqlite3_stmt* stmt;
242  char * sErrMsg = 0;
243 
244  //mc truth
247  //reconstruction
249  //art::Handle<std::vector<recob::Track> > tracks;
250  //art::Handle<std::vector<recob::PFParticle> > particles;
253  std::map<size_t, int> pdgcodes;
254 
255  //get unique event id numbers
256  art::RunNumber_t runnum=event.run();
257  art::SubRunNumber_t subrunnum=event.subRun();
258  art::EventNumber_t eventnum=event.event();
259 
260  std::string whichcalo;
261  if (which_.substr(which_.length()-2, 2)=="dc")
262  whichcalo=which_.substr(0, which_.length()-2)+std::string("calodc");
263  else
264  whichcalo=which_+std::string("calo");
265 
266  if (which_=="truth")
267  {
268  event.getByLabel("largeant", mcparticles);
269  event.getByLabel("largeant", simchannels);
270  }
271  else
272  {
273  event.getByLabel(whichcalo, calorimetry);
274  //event.getByLabel(which_, tracks);
275  //event.getByLabel(which_, particles);
276  event.getByLabel(whichcalo, track2calo);
277  event.getByLabel(which_, particle2track);
278 
279  for (size_t i=0; i<particle2track->size(); i++)
280  {
281  //int pdgcode=particle2track->at(i).first->PdgCode();
282  for (size_t j=0; j<track2calo->size(); j++)
283  {
284  if (track2calo->at(j).first==particle2track->at(i).second)
285  {
286  for (size_t k=0; k<calorimetry->size(); k++)
287  {
288  if (track2calo->at(j).second==art::Ptr<anab::Calorimetry>(calorimetry, k))
289  {
290  pdgcodes[k]=particle2track->at(i).first->PdgCode();
291  }
292  }
293  }
294  }
295  }
296  }
297  // //determine available reconstructions
298  // std::cout << "looking for reco space point sets\n";
299  // std::vector<art::Handle<std::vector<recob::SpacePoint> > > recohits;
300  // event.getManyByType(recohits);
301  // std::cout << "reco hit sets: " << recohits.size() << std::endl;
302  // for (size_t i=0; i<recohits.size(); i++)
303  // {
304  // const art::Provenance* prov=recohits[i].provenance();
305  // std::cout << i << ": ";
306  // std::cout << prov->moduleLabel();
307  // std::cout << std::endl;
308  // }
309  // std::cout << "looking for reco track sets\n";
310  // std::vector<art::Handle<std::vector<recob::Track> > > recotracks;
311  // event.getManyByType(recotracks);
312  // std::cout << "reco track sets: " << recotracks.size() << std::endl;
313  // for (size_t i=0; i<recotracks.size(); i++)
314  // {
315  // const art::Provenance* prov=recotracks[i].provenance();
316  // std::cout << i << ": ";
317  // std::cout << prov->moduleLabel();
318  // std::cout << std::endl;
319  // }
320 
321  // std::cout << "Event: " << event.id() << std::endl;
322 
323  int hitcount=0;
324  int trajtotal=0;
325  if (which_=="truth")
326  {
327  //store sim channels and their ide's
328  for (auto const& simchannel:*simchannels)
329  if (geom_->SignalType(simchannel.Channel()) == geo::kCollection)
330  //ides
331  for (auto const& tdcide:simchannel.TDCIDEMap())
332  hitcount+=tdcide.second.size();
333  if (mcparticles->size())
334  {
335  //put first mctruth particle into database
336  for (auto const& part:*mcparticles)
337  {
338  for (size_t i=0; i<part.NumberTrajectoryPoints(); i++)
339  {
340  trajtotal++;
341  }
342  }
343  }
344  }
345  else
346  {
347  for (size_t tracknum=0; tracknum<calorimetry->size(); tracknum++)
348  {
349  hitcount+=calorimetry->at(tracknum).XYZ().size();
350  }
351  }
352 
353  if (!outputFilename_.empty())
354  {
355  if (sqlite3_prepare(ppDb_, "INSERT INTO Events (RunNumber, SubRunNumber, EventNumber) VALUES ( ?, ?, ? );", 200, &stmt, nullptr)!=SQLITE_OK)
356  throw cet::exception("Landed") << "failed to fill events table on prepare\n";
357  if (sqlite3_bind_int(stmt, 1, runnum)!=SQLITE_OK)
358  throw cet::exception("Landed") << "failed to fill events table on bind\n";
359  if (sqlite3_bind_int(stmt, 2, subrunnum)!=SQLITE_OK)
360  throw cet::exception("Landed") << "failed to fill events table on bind\n";
361  if (sqlite3_bind_int(stmt, 3, eventnum)!=SQLITE_OK)
362  throw cet::exception("Landed") << "failed to fill events table on bind\n";
363  if (sqlite3_step(stmt)!=SQLITE_DONE)
364  throw cet::exception("Landed") << "failed to fill events table on step\n";
365  if (sqlite3_finalize(stmt)!=SQLITE_OK)
366  throw cet::exception("Landed") << "failed to fill events table on finalize\n";
367 
368  if (which_=="truth")
369  {
370  //store sim channels and their ide's
371  for (auto const& simchannel:*simchannels)
372  if (geom_->SignalType(simchannel.Channel()) == geo::kCollection)
373  {
374  //ides
375  sqlite3_exec(ppDb_, "BEGIN TRANSACTION", NULL, NULL, &sErrMsg);
376  for (auto const& tdcide:simchannel.TDCIDEMap())
377  {
378  // unsigned int tdc=tdcide.first;
379  auto const& idevec=tdcide.second;
380  for (auto const& ide:idevec)
381  {
382  // SimChannelID INT, TDC INT, NumElectrons REAL, Energy REAL, X REAL, Y REAL, Z REAL
383  if (sqlite3_prepare(ppDb_, "INSERT INTO Hits (RunNumber, SubRunNumber, EventNumber, NumElectrons, Energy, X, Y, Z, Track ) VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ? );", 200, &stmt, nullptr)!=SQLITE_OK)
384  throw cet::exception("Landed") << "failed to fill hits table on prepare\n";
385  if (sqlite3_bind_int(stmt, 1, runnum)!=SQLITE_OK)
386  throw cet::exception("Landed") << "failed to fill hits table on bind\n";
387  if (sqlite3_bind_int(stmt, 2, subrunnum)!=SQLITE_OK)
388  throw cet::exception("Landed") << "failed to fill hits table on bind\n";
389  if (sqlite3_bind_int(stmt, 3, eventnum)!=SQLITE_OK)
390  throw cet::exception("Landed") << "failed to fill hits table on bind\n";
391  if (sqlite3_bind_double(stmt, 4, ide.numElectrons)!=SQLITE_OK)
392  throw cet::exception("Landed") << "failed to fill hits table on bind\n";
393  if (sqlite3_bind_double(stmt, 5, ide.energy)!=SQLITE_OK)
394  throw cet::exception("Landed") << "failed to fill hits table on bind\n";
395  if (sqlite3_bind_double(stmt, 6, ide.x)!=SQLITE_OK)
396  throw cet::exception("Landed") << "failed to fill hits table on bind\n";
397  if (sqlite3_bind_double(stmt, 7, ide.y)!=SQLITE_OK)
398  throw cet::exception("Landed") << "failed to fill hits table on bind\n";
399  if (sqlite3_bind_double(stmt, 8, ide.z)!=SQLITE_OK)
400  throw cet::exception("Landed") << "failed to fill hits table on bind\n";
401  if (sqlite3_bind_int(stmt, 9, ide.trackID)!=SQLITE_OK)
402  throw cet::exception("Landed") << "failed to fill hits table on bind\n";
403  if (sqlite3_step(stmt)!=SQLITE_DONE)
404  throw cet::exception("Landed") << "failed to fill hits table on step\n";
405  if (sqlite3_finalize(stmt)!=SQLITE_OK)
406  throw cet::exception("Landed") << "failed to fill hits table on finalize\n";
407 
408  }
409  }
410  sqlite3_exec(ppDb_, "END TRANSACTION", NULL, NULL, &sErrMsg);
411  }
412 
413  //store mctruth tracks
414  sqlite3_exec(ppDb_, "BEGIN TRANSACTION", NULL, NULL, &sErrMsg);
415  for (auto const& part:*mcparticles)
416  {
417  for (size_t i=0; i<part.NumberTrajectoryPoints(); i++)
418  {
419  if (sqlite3_prepare(ppDb_, "INSERT INTO Tracks ( RunNumber, SubRunNumber, EventNumber, ID, PDGCode, Segment, Energy, X, Y, Z) VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ? );", 200, &stmt, nullptr)!=SQLITE_OK)
420  throw cet::exception("Landed") << "failed to fill tracks table on prepare\n";
421  if (sqlite3_bind_int(stmt, 1, runnum)!=SQLITE_OK)
422  throw cet::exception("Landed") << "failed to fill tracks table on bind\n";
423  if (sqlite3_bind_int(stmt, 2, subrunnum)!=SQLITE_OK)
424  throw cet::exception("Landed") << "failed to fill tracks table on bind\n";
425  if (sqlite3_bind_int(stmt, 3, eventnum)!=SQLITE_OK)
426  throw cet::exception("Landed") << "failed to fill tracks table on bind\n";
427  if (sqlite3_bind_int(stmt, 4, part.TrackId())!=SQLITE_OK)
428  throw cet::exception("Landed") << "failed to fill tracks table on bind\n";
429  if (sqlite3_bind_int(stmt, 5, part.PdgCode())!=SQLITE_OK)
430  throw cet::exception("Landed") << "failed to fill tracks table on bind\n";
431  if (sqlite3_bind_int(stmt, 6, i)!=SQLITE_OK)
432  throw cet::exception("Landed") << "failed to fill tracks table on bind\n";
433  if (sqlite3_bind_double(stmt, 7, part.E(i))!=SQLITE_OK)
434  throw cet::exception("Landed") << "failed to fill tracks table on bind\n";
435  if (sqlite3_bind_double(stmt, 8, part.Vx(i))!=SQLITE_OK)
436  throw cet::exception("Landed") << "failed to fill tracks table on bind\n";
437  if (sqlite3_bind_double(stmt, 9, part.Vy(i))!=SQLITE_OK)
438  throw cet::exception("Landed") << "failed to fill tracks table on bind\n";
439  if (sqlite3_bind_double(stmt, 10, part.Vz(i))!=SQLITE_OK)
440  throw cet::exception("Landed") << "failed to fill tracks table on bind\n";
441  if (sqlite3_step(stmt)!=SQLITE_DONE)
442  throw cet::exception("Landed") << "failed to fill tracks table on step\n";
443  if (sqlite3_finalize(stmt)!=SQLITE_OK)
444  throw cet::exception("Landed") << "failed to fill tracks table on finalize\n";
445  }
446  }
447  sqlite3_exec(ppDb_, "END TRANSACTION", NULL, NULL, &sErrMsg);
448  }
449  //reconstruction rather than truth
450  else
451  {
452  sqlite3_exec(ppDb_, "BEGIN TRANSACTION", NULL, NULL, &sErrMsg);
453 
454  for (size_t tracknum=0; tracknum<calorimetry->size(); tracknum++)
455  {
456  auto const& calo=calorimetry->at(tracknum);
457  for (size_t hitnum=0; hitnum<calo.dEdx().size() && hitnum<calo.dQdx().size() && hitnum<calo.XYZ().size(); hitnum++)
458  {
459  if (sqlite3_prepare(ppDb_, "INSERT INTO Hits (RunNumber, SubRunNumber, EventNumber, NumElectrons, Energy, X, Y, Z, Track ) VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ? );", 200, &stmt, nullptr)!=SQLITE_OK)
460  throw cet::exception("Landed") << "failed to fill hits table on prepare\n";
461  if (sqlite3_bind_int(stmt, 1, runnum)!=SQLITE_OK)
462  throw cet::exception("Landed") << "failed to fill hits table on bind\n";
463  if (sqlite3_bind_int(stmt, 2, subrunnum)!=SQLITE_OK)
464  throw cet::exception("Landed") << "failed to fill hits table on bind\n";
465  if (sqlite3_bind_int(stmt, 3, eventnum)!=SQLITE_OK)
466  throw cet::exception("Landed") << "failed to fill hits table on bind\n";
467  if (sqlite3_bind_double(stmt, 4, calo.TrkPitchVec().at(hitnum)*calo.dQdx().at(hitnum))!=SQLITE_OK)
468  throw cet::exception("Landed") << "failed to fill hits table on bind\n";
469  if (sqlite3_bind_double(stmt, 5, calo.TrkPitchVec().at(hitnum)*calo.dEdx().at(hitnum))!=SQLITE_OK)
470  throw cet::exception("Landed") << "failed to fill hits table on bind\n";
471  if (sqlite3_bind_double(stmt, 6, calo.XYZ().at(hitnum).X())!=SQLITE_OK)
472  throw cet::exception("Landed") << "failed to fill hits table on bind\n";
473  if (sqlite3_bind_double(stmt, 7, calo.XYZ().at(hitnum).Y())!=SQLITE_OK)
474  throw cet::exception("Landed") << "failed to fill hits table on bind\n";
475  if (sqlite3_bind_double(stmt, 8, calo.XYZ().at(hitnum).Z())!=SQLITE_OK)
476  throw cet::exception("Landed") << "failed to fill hits table on bind\n";
477  if (sqlite3_bind_int(stmt, 9, tracknum+1)!=SQLITE_OK)
478  throw cet::exception("Landed") << "failed to fill hits table on bind\n";
479  if (sqlite3_step(stmt)!=SQLITE_DONE)
480  throw cet::exception("Landed") << "failed to fill hits table on step\n";
481  if (sqlite3_finalize(stmt)!=SQLITE_OK)
482  throw cet::exception("Landed") << "failed to fill hits table on finalize\n";
483  }
484  }
485  sqlite3_exec(ppDb_, "END TRANSACTION", NULL, NULL, &sErrMsg);
486 
487  sqlite3_exec(ppDb_, "BEGIN TRANSACTION", NULL, NULL, &sErrMsg);
488  for (size_t tracknum=0; tracknum<calorimetry->size(); tracknum++)
489  {
490  auto const& calo=calorimetry->at(tracknum);
491  if (calo.dEdx().size()>1)
492  {
493  int pdgcode=0;
494  if (pdgcodes.find(tracknum)!=pdgcodes.end())
495  pdgcode=pdgcodes[tracknum];
496  double energy=calo.KineticEnergy();
497  for (size_t hitnum=0; hitnum<calo.dEdx().size() && hitnum<calo.dQdx().size() && hitnum<calo.XYZ().size(); hitnum++)
498  {
499  if (sqlite3_prepare(ppDb_, "INSERT INTO Tracks ( RunNumber, SubRunNumber, EventNumber, ID, PDGCode, Segment, Energy, X, Y, Z) VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ? );", 200, &stmt, nullptr)!=SQLITE_OK)
500  throw cet::exception("Landed") << "failed to fill tracks table on prepare\n";
501  if (sqlite3_bind_int(stmt, 1, runnum)!=SQLITE_OK)
502  throw cet::exception("Landed") << "failed to fill tracks table on bind\n";
503  if (sqlite3_bind_int(stmt, 2, subrunnum)!=SQLITE_OK)
504  throw cet::exception("Landed") << "failed to fill tracks table on bind\n";
505  if (sqlite3_bind_int(stmt, 3, eventnum)!=SQLITE_OK)
506  throw cet::exception("Landed") << "failed to fill tracks table on bind\n";
507  if (sqlite3_bind_int(stmt, 4, tracknum+1)!=SQLITE_OK)
508  throw cet::exception("Landed") << "failed to fill tracks table on bind\n";
509  if (sqlite3_bind_int(stmt, 5, pdgcode)!=SQLITE_OK)
510  throw cet::exception("Landed") << "failed to fill tracks table on bind\n";
511  if (sqlite3_bind_int(stmt, 6, hitnum+1)!=SQLITE_OK)
512  throw cet::exception("Landed") << "failed to fill tracks table on bind\n";
513  if (sqlite3_bind_double(stmt, 7, energy)!=SQLITE_OK)
514  throw cet::exception("Landed") << "failed to fill tracks table on bind\n";
515  if (sqlite3_bind_double(stmt, 8, calo.XYZ().at(hitnum).X())!=SQLITE_OK)
516  throw cet::exception("Landed") << "failed to fill tracks table on bind\n";
517  if (sqlite3_bind_double(stmt, 9, calo.XYZ().at(hitnum).Y())!=SQLITE_OK)
518  throw cet::exception("Landed") << "failed to fill tracks table on bind\n";
519  if (sqlite3_bind_double(stmt, 10, calo.XYZ().at(hitnum).Z())!=SQLITE_OK)
520  throw cet::exception("Landed") << "failed to fill tracks table on bind\n";
521  if (sqlite3_step(stmt)!=SQLITE_DONE)
522  throw cet::exception("Landed") << "failed to fill tracks table on step\n";
523  if (sqlite3_finalize(stmt)!=SQLITE_OK)
524  throw cet::exception("Landed") << "failed to fill tracks table on finalize\n";
525  energy-=calo.TrkPitchVec().at(hitnum)*calo.dEdx().at(hitnum);
526  }
527  }
528  }
529  }
530  }
531  else
532  {
533  sock_->sendEvent(hitcount, trajtotal, runnum, subrunnum, eventnum);
534  if (which_=="truth")
535  {
536 
537  //store sim channels and their ide's
538  for (auto const& simchannel:*simchannels)
539  if (geom_->SignalType(simchannel.Channel()) == geo::kCollection)
540  //ides
541  for (auto const& tdcide:simchannel.TDCIDEMap())
542  {
543  auto const& idevec=tdcide.second;
544  for (auto const& ide:idevec)
545  {
546  sock_->sendHit(ide.x, ide.y, ide.z, ide.energy, ide.numElectrons, ide.trackID);
547  }
548  }
549  //store mctruth tracks
550  for (auto const& part:*mcparticles)
551  {
552  for (size_t i=0; i<part.NumberTrajectoryPoints(); i++)
553  {
554  sock_->sendVertex(part.Vx(i), part.Vy(i), part.Vz(i), part.E(i), part.TrackId(), part.PdgCode());
555  }
556  }
557  }
558  //reco rather than truth
559  else
560  {
561  for (size_t tracknum=0; tracknum<calorimetry->size(); tracknum++)
562  {
563  auto const& calo=calorimetry->at(tracknum);
564  for (size_t hitnum=0; hitnum<calo.dEdx().size() && hitnum<calo.dQdx().size() && hitnum<calo.XYZ().size(); hitnum++)
565  {
566  sock_->sendHit(calo.XYZ().at(hitnum).X(), calo.XYZ().at(hitnum).Y(), calo.XYZ().at(hitnum).Z(), calo.TrkPitchVec().at(hitnum)*calo.dEdx().at(hitnum), calo.TrkPitchVec().at(hitnum)*calo.dQdx().at(hitnum), tracknum+1);
567  }
568  }
569  for (size_t tracknum=0; tracknum<calorimetry->size(); tracknum++)
570  {
571  int pdgcode=0;
572  if (pdgcodes.find(tracknum)!=pdgcodes.end())
573  pdgcode=pdgcodes[tracknum];
574  auto const& calo=calorimetry->at(tracknum);
575  if (calo.dEdx().size()>1)
576  {
577  double energy=calo.KineticEnergy();
578  for (size_t hitnum=0; hitnum<calo.dEdx().size() && hitnum<calo.dQdx().size() && hitnum<calo.XYZ().size(); hitnum++)
579  {
580  sock_->sendVertex(calo.XYZ().at(hitnum).X(), calo.XYZ().at(hitnum).Y(), calo.XYZ().at(hitnum).Z(), energy, tracknum+1, pdgcode);
581  energy-=calo.TrkPitchVec().at(hitnum)*calo.dEdx().at(hitnum);
582  }
583  }
584  }
585  }
586  }
587  }
588 }
std::string which_
std::vector< int > events_
art::ServiceHandle< geo::Geometry > geom_
SigType_t SignalType(geo::PlaneID const &pid) const
Returns the type of signal on the channels of specified TPC plane.
sqlite3 * ppDb_
TString part[npart]
Definition: Style.C:32
double energy
Definition: plottest35.C:25
IDNumber_t< Level::SubRun > SubRunNumber_t
Definition: IDNumber.h:118
std::string outputFilename_
IDNumber_t< Level::Event > EventNumber_t
Definition: IDNumber.h:117
Definition: fwd.h:25
art::ServiceHandle< LandedSocket > sock_
calorimetry
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
Signal from collection planes.
Definition: geo_types.h:93
IDNumber_t< Level::Run > RunNumber_t
Definition: IDNumber.h:119
void evd::Landed::beginJob ( )
overridevirtual

Reimplemented from art::EDAnalyzer.

Definition at line 162 of file Landed_module.cc.

References outputFilename_, ppDb_, sock_, and vrml_.

163 {
164 
165  if (!outputFilename_.empty())
166  {
167  //compress geometry
168  uLongf complen=compressBound(vrml_.length());
169  Bytef* comp=new Bytef[complen];
170  if (compress(comp, &complen, (const Bytef*)vrml_.c_str(), vrml_.length())!=Z_OK)
171  throw cet::exception("Landed") << "failed to compress geometry vrml\n";
172 
173  //create sqlite output file, compress and store gdml geometry
174  //create sqlite output file
175  ::remove(outputFilename_.c_str());
176  if (sqlite3_open_v2(outputFilename_.c_str(), &ppDb_, SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, "unix")!=SQLITE_OK)
177  throw cet::exception("Landed") << "failed to create sqlite file\n";
178  sqlite3_stmt* stmt;
179  char * sErrMsg = 0;
180  sqlite3_exec(ppDb_, "PRAGMA synchronous = OFF", NULL, NULL, &sErrMsg);
181 
182 
183  //create geometry table
184  if (sqlite3_prepare(ppDb_, "CREATE TABLE Geometry ( vrml BLOB, size INT );", 100, &stmt, nullptr)!=SQLITE_OK)
185  throw cet::exception("Landed") << "failed to create geometry table on prepare\n";
186  if (sqlite3_step(stmt)!=SQLITE_DONE)
187  throw cet::exception("Landed") << "failed to create geometry table on step\n";
188  if (sqlite3_finalize(stmt)!=SQLITE_OK)
189  throw cet::exception("Landed") << "failed to create geometry table on finalize\n";
190  //store geometry
191  if (sqlite3_prepare(ppDb_, "INSERT INTO Geometry ( vrml, size ) VALUES ( ?, ? );", -1, &stmt, nullptr)!=SQLITE_OK)
192  throw cet::exception("Landed") << "failed to fill geometry table on prepare\n";
193  if (sqlite3_bind_blob(stmt, 1, comp, complen, SQLITE_STATIC)!=SQLITE_OK ||
194  sqlite3_bind_int(stmt, 2, vrml_.length())!=SQLITE_OK)
195  throw cet::exception("Landed") << "failed to fill geometry table on bind\n";
196  if (sqlite3_step(stmt)!=SQLITE_DONE)
197  throw cet::exception("Landed") << "failed to fill geometry table on step\n";
198  if (sqlite3_finalize(stmt)!=SQLITE_OK)
199  throw cet::exception("Landed") << "failed to fill geometry table on finalize\n";
200  delete[] comp;
201 
202  //create events table
203  if (sqlite3_prepare(ppDb_, "CREATE TABLE Events ( RunNumber INT, SubRunNumber INT, EventNumber INT);", 200, &stmt, nullptr)!=SQLITE_OK)
204  throw cet::exception("Landed") << "failed to create events table on prepare\n";
205  if (sqlite3_step(stmt)!=SQLITE_DONE)
206  throw cet::exception("Landed") << "failed to create events table on step\n";
207  if (sqlite3_finalize(stmt)!=SQLITE_OK)
208  throw cet::exception("Landed") << "failed to create events table on finalize\n";
209 
210  //create simchannel ide table
211  if (sqlite3_prepare(ppDb_, "CREATE TABLE Hits ( RunNumber INT, SubRunNumber INT, EventNumber INT, NumElectrons REAL, Energy REAL, X REAL, Y REAL, Z REAL, Track INT);", 200, &stmt, nullptr)!=SQLITE_OK)
212  throw cet::exception("Landed") << "failed to create hits table on prepare\n";
213  if (sqlite3_step(stmt)!=SQLITE_DONE)
214  throw cet::exception("Landed") << "failed to create hits table on step\n";
215  if (sqlite3_finalize(stmt)!=SQLITE_OK)
216  throw cet::exception("Landed") << "failed to create hits table on finalize\n";
217 
218  //create mcparticle table
219  if (sqlite3_prepare(ppDb_, "CREATE TABLE Tracks (RunNumber INT, SubRunNumber INT, EventNumber INT, ID INT, PDGCode INT, Segment INT, Energy REAL, X REAL, Y REAL, Z REAL);", 200, &stmt, nullptr)!=SQLITE_OK)
220  throw cet::exception("Landed") << "failed to create tracks table on prepare\n";
221  if (sqlite3_step(stmt)!=SQLITE_DONE)
222  throw cet::exception("Landed") << "failed to create tracks table on step\n";
223  if (sqlite3_finalize(stmt)!=SQLITE_OK)
224  throw cet::exception("Landed") << "failed to create tracks table on finalize\n";
225  }
226  else
227  {
228  //send geometry through landed service
229  sock_->sendGeometry(vrml_);
230  }
231 
232 }
std::string vrml_
sqlite3 * ppDb_
std::string outputFilename_
art::ServiceHandle< LandedSocket > sock_
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
detail::CachedProducts& art::EventObserverBase::cachedProducts ( )
inlineprotectedinherited

Definition at line 79 of file EventObserverBase.h.

References art::EventObserverBase::selectors_.

Referenced by art::EDAnalyzer::doEvent(), and art::OutputModule::doWriteEvent().

80  {
81  return selectors_;
82  }
detail::CachedProducts selectors_
template<typename T , BranchType = InEvent>
ProductToken<T> art::Consumer::consumes ( InputTag const &  )
inherited
template<typename T , art::BranchType BT>
art::ProductToken<T> art::Consumer::consumes ( InputTag const &  it)
inherited

Definition at line 147 of file Consumer.h.

References art::InputTag::instance(), art::InputTag::label(), and art::InputTag::process().

148 {
149  if (!moduleContext_)
150  return ProductToken<T>::invalid();
151 
152  consumables_[BT].emplace_back(ConsumableType::Product,
153  TypeID{typeid(T)},
154  it.label(),
155  it.instance(),
156  it.process());
157  return ProductToken<T>{it};
158 }
static ProductToken< T > invalid()
Definition: ProductToken.h:47
ConsumableProducts consumables_
Definition: Consumer.h:138
bool moduleContext_
Definition: Consumer.h:136
template<typename T , art::BranchType BT>
void art::Consumer::consumesMany ( )
inherited

Definition at line 162 of file Consumer.h.

163 {
164  if (!moduleContext_)
165  return;
166 
167  consumables_[BT].emplace_back(ConsumableType::Many, TypeID{typeid(T)});
168 }
ConsumableProducts consumables_
Definition: Consumer.h:138
bool moduleContext_
Definition: Consumer.h:136
template<typename Element , BranchType = InEvent>
ViewToken<Element> art::Consumer::consumesView ( InputTag const &  )
inherited
template<typename T , art::BranchType BT>
art::ViewToken<T> art::Consumer::consumesView ( InputTag const &  it)
inherited

Definition at line 172 of file Consumer.h.

References art::InputTag::instance(), art::InputTag::label(), and art::InputTag::process().

173 {
174  if (!moduleContext_)
175  return ViewToken<T>::invalid();
176 
177  consumables_[BT].emplace_back(ConsumableType::ViewElement,
178  TypeID{typeid(T)},
179  it.label(),
180  it.instance(),
181  it.process());
182  return ViewToken<T>{it};
183 }
static ViewToken< Element > invalid()
Definition: ProductToken.h:75
ConsumableProducts consumables_
Definition: Consumer.h:138
bool moduleContext_
Definition: Consumer.h:136
EngineCreator::base_engine_t & EngineCreator::createEngine ( seed_t  seed,
std::string const &  kind_of_engine_to_make 
)
inherited

Definition at line 32 of file EngineCreator.cc.

References art::EngineCreator::rng().

34 {
35  return rng()->createEngine(
36  placeholder_schedule_id(), seed, kind_of_engine_to_make);
37 }
long seed
Definition: chem4.cc:68
static art::ServiceHandle< art::RandomNumberGenerator > & rng()
EngineCreator::base_engine_t & EngineCreator::createEngine ( seed_t  seed,
std::string const &  kind_of_engine_to_make,
label_t const &  engine_label 
)
inherited

Definition at line 40 of file EngineCreator.cc.

References art::EngineCreator::rng().

43 {
44  return rng()->createEngine(
45  placeholder_schedule_id(), seed, kind_of_engine_to_make, engine_label);
46 }
long seed
Definition: chem4.cc:68
static art::ServiceHandle< art::RandomNumberGenerator > & rng()
CurrentProcessingContext const * art::EDAnalyzer::currentContext ( ) const
protectedinherited

Definition at line 114 of file EDAnalyzer.cc.

References art::EDAnalyzer::current_context_.

Referenced by art::EDAnalyzer::workerType().

115  {
116  return current_context_.get();
117  }
CPC_exempt_ptr current_context_
Definition: EDAnalyzer.h:179
void evd::Landed::endJob ( )
overridevirtual

Reimplemented from art::EDAnalyzer.

Definition at line 233 of file Landed_module.cc.

References ppDb_.

234 {
235  sqlite3_close(ppDb_);
236 }
sqlite3 * ppDb_
EngineCreator::seed_t EngineCreator::get_seed_value ( fhicl::ParameterSet const &  pset,
char const  key[] = "seed",
seed_t const  implicit_seed = -1 
)
inherited

Definition at line 49 of file EngineCreator.cc.

References fhicl::ParameterSet::get().

Referenced by art::MixFilter< T >::initEngine_().

52 {
53  auto const& explicit_seeds = pset.get<std::vector<int>>(key, {});
54  return explicit_seeds.empty() ? implicit_seed : explicit_seeds.front();
55 }
art::Handle<art::TriggerResults> art::EventObserverBase::getTriggerResults ( Event const &  e) const
inlineinherited

Definition at line 61 of file EventObserverBase.h.

References art::detail::CachedProducts::getOneTriggerResults(), and art::EventObserverBase::selectors_.

Referenced by art::OutputModule::doWriteEvent().

62  {
64  }
detail::CachedProducts selectors_
art::Handle< art::TriggerResults > getOneTriggerResults(Event const &) const
Float_t e
Definition: plot.C:34
template<typename T , BranchType = InEvent>
ProductToken<T> art::Consumer::mayConsume ( InputTag const &  )
inherited
template<typename T , art::BranchType BT>
art::ProductToken<T> art::Consumer::mayConsume ( InputTag const &  it)
inherited

Definition at line 190 of file Consumer.h.

References art::InputTag::instance(), art::InputTag::label(), and art::InputTag::process().

191 {
192  if (!moduleContext_)
193  return ProductToken<T>::invalid();
194 
195  consumables_[BT].emplace_back(ConsumableType::Product,
196  TypeID{typeid(T)},
197  it.label(),
198  it.instance(),
199  it.process());
200  return ProductToken<T>{it};
201 }
static ProductToken< T > invalid()
Definition: ProductToken.h:47
ConsumableProducts consumables_
Definition: Consumer.h:138
bool moduleContext_
Definition: Consumer.h:136
template<typename T , art::BranchType BT>
void art::Consumer::mayConsumeMany ( )
inherited

Definition at line 205 of file Consumer.h.

206 {
207  if (!moduleContext_)
208  return;
209 
210  consumables_[BT].emplace_back(ConsumableType::Many, TypeID{typeid(T)});
211 }
ConsumableProducts consumables_
Definition: Consumer.h:138
bool moduleContext_
Definition: Consumer.h:136
template<typename Element , BranchType = InEvent>
ViewToken<Element> art::Consumer::mayConsumeView ( InputTag const &  )
inherited
template<typename T , art::BranchType BT>
art::ViewToken<T> art::Consumer::mayConsumeView ( InputTag const &  it)
inherited

Definition at line 215 of file Consumer.h.

References art::InputTag::instance(), art::InputTag::label(), and art::InputTag::process().

216 {
217  if (!moduleContext_)
218  return ViewToken<T>::invalid();
219 
220  consumables_[BT].emplace_back(ConsumableType::ViewElement,
221  TypeID{typeid(T)},
222  it.label(),
223  it.instance(),
224  it.process());
225  return ViewToken<T>{it};
226 }
static ViewToken< Element > invalid()
Definition: ProductToken.h:75
ConsumableProducts consumables_
Definition: Consumer.h:138
bool moduleContext_
Definition: Consumer.h:136
bool art::EventObserverBase::modifiesEvent ( ) const
inlineinherited

Definition at line 25 of file EventObserverBase.h.

26  {
27  return false;
28  }
Landed& evd::Landed::operator= ( Landed const &  )
delete
Landed& evd::Landed::operator= ( Landed &&  )
delete
void art::Consumer::prepareForJob ( fhicl::ParameterSet const &  pset)
protectedinherited

Definition at line 89 of file Consumer.cc.

References fhicl::ParameterSet::get_if_present().

Referenced by art::EDProducer::doBeginJob(), art::EDFilter::doBeginJob(), and art::EDAnalyzer::doBeginJob().

90 {
91  if (!moduleContext_)
92  return;
93 
94  pset.get_if_present("errorOnMissingConsumes", requireConsumes_);
95  for (auto& consumablesPerBranch : consumables_) {
96  cet::sort_all(consumablesPerBranch);
97  }
98 }
bool requireConsumes_
Definition: Consumer.h:137
ConsumableProducts consumables_
Definition: Consumer.h:138
bool moduleContext_
Definition: Consumer.h:136
std::string const& art::EventObserverBase::processName ( ) const
inlineinherited
void art::EventObserverBase::registerProducts ( MasterProductRegistry ,
ProductDescriptions ,
ModuleDescription const &   
)
inlineinherited

Definition at line 33 of file EventObserverBase.h.

36  {}
fhicl::ParameterSetID art::EventObserverBase::selectorConfig ( ) const
inlineinherited

Definition at line 56 of file EventObserverBase.h.

References art::EventObserverBase::selector_config_id_.

Referenced by art::RootOutputFile::writeOne().

57  {
58  return selector_config_id_;
59  }
fhicl::ParameterSetID selector_config_id_
void art::Consumer::showMissingConsumes ( ) const
protectedinherited

Definition at line 125 of file Consumer.cc.

Referenced by art::EDProducer::doEndJob(), art::EDFilter::doEndJob(), art::EDAnalyzer::doEndJob(), and art::RootOutput::endJob().

126 {
127  if (!moduleContext_)
128  return;
129 
130  // If none of the branches have missing consumes statements, exit early.
131  if (std::all_of(cbegin(missingConsumes_),
132  cend(missingConsumes_),
133  [](auto const& perBranch) { return perBranch.empty(); }))
134  return;
135 
136  constexpr cet::HorizontalRule rule{60};
137  mf::LogPrint log{"MTdiagnostics"};
138  log << '\n'
139  << rule('=') << '\n'
140  << "The following consumes (or mayConsume) statements are missing from\n"
141  << module_context(moduleDescription_) << '\n'
142  << rule('-') << '\n';
143 
144  cet::for_all_with_index(
145  missingConsumes_, [&log](std::size_t const i, auto const& perBranch) {
146  for (auto const& pi : perBranch) {
147  log << " "
148  << assemble_consumes_statement(static_cast<BranchType>(i), pi)
149  << '\n';
150  }
151  });
152  log << rule('=');
153 }
cet::exempt_ptr< ModuleDescription const > moduleDescription_
Definition: Consumer.h:140
constexpr T pi()
Returns the constant pi (up to 35 decimal digits of precision)
bool moduleContext_
Definition: Consumer.h:136
ConsumableProductSets missingConsumes_
Definition: Consumer.h:139
void art::Consumer::validateConsumedProduct ( BranchType const  bt,
ProductInfo const &  pi 
)
protectedinherited

Definition at line 101 of file Consumer.cc.

References art::errors::ProductRegistrationFailure.

103 {
104  // Early exits if consumes tracking has been disabled or if the
105  // consumed product is an allowed consumable.
106  if (!moduleContext_)
107  return;
108 
109  if (cet::binary_search_all(consumables_[bt], pi))
110  return;
111 
112  if (requireConsumes_) {
114  "Consumer: an error occurred during validation of a "
115  "retrieved product\n\n")
116  << "The following consumes (or mayConsume) statement is missing from\n"
117  << module_context(moduleDescription_) << ":\n\n"
118  << " " << assemble_consumes_statement(bt, pi) << "\n\n";
119  }
120 
121  missingConsumes_[bt].insert(pi);
122 }
cet::exempt_ptr< ModuleDescription const > moduleDescription_
Definition: Consumer.h:140
bool requireConsumes_
Definition: Consumer.h:137
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
constexpr T pi()
Returns the constant pi (up to 35 decimal digits of precision)
ConsumableProducts consumables_
Definition: Consumer.h:138
bool moduleContext_
Definition: Consumer.h:136
ConsumableProductSets missingConsumes_
Definition: Consumer.h:139
bool art::EventObserverBase::wantAllEvents ( ) const
inlineinherited
bool art::EventObserverBase::wantEvent ( Event const &  e)
inlineinherited
std::string art::EDAnalyzer::workerType ( ) const
inlineinherited

Definition at line 109 of file EDAnalyzer.h.

References art::EDAnalyzer::currentContext().

110  {
111  return "WorkerT<EDAnalyzer>";
112  }

Member Data Documentation

std::vector<int> evd::Landed::events_
private

Definition at line 90 of file Landed_module.cc.

Referenced by analyze().

art::ServiceHandle<geo::Geometry> evd::Landed::geom_
private

Definition at line 83 of file Landed_module.cc.

Referenced by analyze(), and Landed().

std::string evd::Landed::outputFilename_
private

Definition at line 87 of file Landed_module.cc.

Referenced by analyze(), beginJob(), and Landed().

sqlite3* evd::Landed::ppDb_
private

Definition at line 89 of file Landed_module.cc.

Referenced by analyze(), beginJob(), and endJob().

art::ServiceHandle<LandedSocket> evd::Landed::sock_
private

Definition at line 84 of file Landed_module.cc.

Referenced by analyze(), beginJob(), and Landed().

std::string evd::Landed::vrml_
private

Definition at line 86 of file Landed_module.cc.

Referenced by beginJob(), and Landed().

std::string evd::Landed::which_
private

Definition at line 88 of file Landed_module.cc.

Referenced by analyze().


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