LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
artg4tk Namespace Reference

Classes

class  ActionBase
 
class  ActionHolderService
 
class  ArtG4DetectorConstruction
 
class  ArtG4EventAction
 
class  ArtG4PrimaryGeneratorAction
 
class  ArtG4RunManager
 
class  ArtG4StackingAction
 
class  ArtG4SteppingAction
 
class  artg4tkMain
 
class  ArtG4tkModelConfig
 
class  ArtG4tkParticle
 
class  ArtG4tkVtx
 
class  ArtG4TrackingAction
 
class  CheckCalorimeterHits
 
class  CheckDRCalorimeterHits
 
class  CheckGenParticle
 
class  CheckHits
 
class  CheckInteractions
 
class  CheckPhotonHits
 
class  CheckProtonProduction
 
class  CheckTrackerHits
 
class  DetectorBase
 
class  DetectorHolderService
 
class  DummyService
 
class  EventActionBase
 
class  EventGenerator
 
class  ExampleGeneralActionService
 
class  GenParticle
 
class  HepevtInputActionService
 
class  KillerActionService
 
class  myParticleGunActionService
 
class  PDGCode
 
class  PhysicsListHolderService
 
class  PhysicsListService
 
class  PhysicsListServiceBase
 
class  PrimaryEventActionService
 
class  PrimaryGeneratorActionBase
 
class  RunActionBase
 
struct  RunSettingsBase
 
class  RunSettingsService
 
class  StackingActionBase
 
class  SteppingActionBase
 
class  StringIDs
 
class  TrackingActionBase
 

Typedefs

typedef std::vector< GenParticleGenParticleCollection
 

Functions

std::ostream & operator<< (std::ostream &ost, const GenParticle &genp)
 
template<typename DATATYPE , typename SERVICETYPE >
const DATATYPE & dataFromRunOrService (const art::Run &r, const std::string &producerLabel, const std::string &instanceLabel)
 
template<typename T >
std::enable_if< std::is_base_of< G4VSensitiveDetector, T >::value, T * >::type getSensitiveDetector (G4String name)
 
void setVisAtts (G4LogicalVolume *lv, bool display, const std::vector< double > &rgba)
 
void setVisAtts (G4LogicalVolume *lv, bool display, const std::vector< double > &rgba, std::function< void(G4VisAttributes *)> func)
 
std::string addNumberToName (const std::string &name, int number)
 
std::string basePath (const std::string &envVar, const std::string &pkgName)
 

Typedef Documentation

Definition at line 14 of file GenParticleCollection.hh.

Function Documentation

std::string artg4tk::addNumberToName ( const std::string &  name,
int  number 
)

Definition at line 51 of file util.cc.

Referenced by getSensitiveDetector().

52 {
53 
54  std::ostringstream newName;
55  newName << name << '[' << std::setfill('0') << std::setw(2) << number << ']';
56 
57  return newName.str();
58 }
std::string artg4tk::basePath ( const std::string &  envVar,
const std::string &  pkgName 
)

Definition at line 62 of file util.cc.

Referenced by getSensitiveDetector().

63 {
64  std::string path;
65  char* pathC = std::getenv(envVar.c_str());
66  if (pathC) {
67  path = std::string(pathC);
68  } else {
69  pathC = std::getenv("MRB_BUILDDIR");
70  if (pathC) {
71  path = std::string(pathC) + "/" + pkgName;
72  } else {
73  throw cet::exception("NOBASEPATH")
74  << "Need enviornment variable " << envVar << " or $MRB_BUILDDIR set to find path\n";
75  }
76  }
77 
78  return path;
79 }
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
template<typename DATATYPE , typename SERVICETYPE >
const DATATYPE& artg4tk::dataFromRunOrService ( const art::Run r,
const std::string &  producerLabel,
const std::string &  instanceLabel 
)

Definition at line 25 of file DataFromRunOrService.hh.

References art::ProductRetriever::getMany(), art::Provenance::moduleLabel(), and art::Provenance::productInstanceName().

28  {
29 
30  // Let's try to get the data out of the Run first
31  // std::vector< art::Handle< DATATYPE > > handleVec;
32  // r.getManyByType(handleVec);
33  auto handleVec = r.getMany<DATATYPE>();
34 
35  if (!handleVec.empty()) {
36  // We found something in the run record
37  for (const art::Handle<DATATYPE>& aHandle : handleVec) {
38 
39  // Get the provenance for this handle
40  art::Provenance const* prov = aHandle.provenance();
41 
42  // Check the producer label
43  if (producerLabel.empty() || producerLabel == prov->moduleLabel()) {
44 
45  // Check the instance label
46  if (instanceLabel.empty() || instanceLabel == prov->productInstanceName()) {
47 
48  // We found it!
49  mf::LogDebug("DataFromRunOrService") << "Getting data from Run";
50  return *aHandle;
51  }
52  }
53  }
54  }
55 
56  // If we make it here, then we need to look at the service (throws an exception if the
57  // service does not exist)
58  mf::LogDebug("DataFromRunOrService") << "Getting data from Service";
59  return art::ServiceHandle<SERVICETYPE>()->getData();
60  }
std::string const & productInstanceName() const noexcept
Definition: Provenance.cc:60
std::string const & moduleLabel() const noexcept
Definition: Provenance.cc:54
MaybeLogger_< ELseverityLevel::ELsev_success, false > LogDebug
std::vector< Handle< PROD > > getMany(SelectorBase const &selector=MatchAllSelector{}) const
template<typename T >
std::enable_if<std::is_base_of<G4VSensitiveDetector, T>::value, T*>::type artg4tk::getSensitiveDetector ( G4String  name)

Definition at line 29 of file util.hh.

References addNumberToName(), basePath(), and setVisAtts().

30  {
31  T* SDptr = 0;
32  G4SDManager* fSDM = G4SDManager::GetSDMpointer();
33  if ((SDptr = static_cast<T*>(fSDM->FindSensitiveDetector(name))) == NULL)
34  SDptr = new T(name);
35  return SDptr;
36  }
std::ostream & artg4tk::operator<< ( std::ostream &  ost,
const GenParticle genp 
)

Definition at line 32 of file GenParticle.cc.

References artg4tk::GenParticle::child(), artg4tk::GenParticle::children(), art::PtrVector< T >::empty(), artg4tk::GenParticle::momentum(), artg4tk::GenParticle::parent(), artg4tk::GenParticle::pdgId(), artg4tk::GenParticle::position(), and artg4tk::GenParticle::status().

33 {
34  ost << "[ "
35  << "pdg: " << genp.pdgId() << " "
36  << "Position: " << genp.position() << " "
37  << "4-momentum " << genp.momentum() << " "
38  << "status: " << genp.status() << " "
39  << "parent: ";
40  if (genp.parent().id() == art::ProductID()) {
41  ost << "none ";
42  } else {
43  ost << genp.parent().id() << " " << genp.parent().key() << " ";
44  }
45  ost << " children: ";
46 
47  if (genp.children().empty()) {
48  ost << "none";
49  } else {
50  ost << "( ";
51  for (auto const& child : genp.children()) {
52  ost << " " << child.id() << "." << child.key();
53  }
54  ost << " )";
55  }
56  ost << " ]";
57  return ost;
58 }
void artg4tk::setVisAtts ( G4LogicalVolume *  lv,
bool  display,
const std::vector< double > &  rgba 
)

Definition at line 44 of file util.cc.

Referenced by getSensitiveDetector().

45 {
46  setVisAtts(lv, display, rgba, [](G4VisAttributes*) {});
47 }
void setVisAtts(G4LogicalVolume *lv, bool display, const std::vector< double > &rgba)
Definition: util.cc:44
void artg4tk::setVisAtts ( G4LogicalVolume *  lv,
bool  display,
const std::vector< double > &  rgba,
std::function< void(G4VisAttributes *)>  func 
)

Definition at line 14 of file util.cc.

18 {
19 
20  G4VisAttributes* att;
21 
22  // Do we want to display?
23  if (display) {
24 
25  // We do! Set the color
26  att = new G4VisAttributes(G4Colour(rgba[0], rgba[1], rgba[2], rgba[3]));
27 
28  // Run any function that was passed in
29  func(att);
30 
31  }
32 
33  else {
34  // We do not want to display. Too bad.
35  att = new G4VisAttributes(0);
36  }
37 
38  // Set the attributes in the logical volume
39  lv->SetVisAttributes(att);
40 }