CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
PrintMTDSens Class Reference
Inheritance diagram for PrintMTDSens:
SimWatcher Observer< const BeginOfRun *>

Public Member Functions

 PrintMTDSens (edm::ParameterSet const &p)
 
 ~PrintMTDSens () override
 
- Public Member Functions inherited from SimWatcher
virtual void beginRun (edm::EventSetup const &)
 
bool isMT () const
 
const SimWatcheroperator= (const SimWatcher &)=delete
 
virtual void registerConsumes (edm::ConsumesCollector)
 
 SimWatcher ()
 
 SimWatcher (const SimWatcher &)=delete
 
virtual ~SimWatcher ()
 
- Public Member Functions inherited from Observer< const BeginOfRun *>
 Observer ()
 
void slotForUpdate (const BeginOfRun * iT)
 
virtual ~Observer ()
 

Private Member Functions

int dumpTouch (G4VPhysicalVolume *pv, unsigned int leafDepth, int ns)
 
bool getBaseNumber ()
 
G4VPhysicalVolume * getTopPV ()
 
void update (const BeginOfRun *run) override
 This routine will be called when the appropriate signal arrives. More...
 

Private Attributes

BTLNumberingScheme btlNS_
 
ETLNumberingScheme etlNS_
 
G4NavigationHistory fHistory
 
std::vector< std::string > names_
 
std::vector< size_t > nsens_
 
MTDBaseNumber thisN_
 

Additional Inherited Members

- Protected Member Functions inherited from SimWatcher
void setMT (bool val)
 

Detailed Description

Definition at line 28 of file PrintMTDSens.cc.

Constructor & Destructor Documentation

◆ PrintMTDSens()

PrintMTDSens::PrintMTDSens ( edm::ParameterSet const &  p)

Definition at line 49 of file PrintMTDSens.cc.

References ecalTB2006H4_GenSimDigiReco_cfg::G4cout, names_, nsens_, and AlCaHLTBitMon_ParallelJobs::p.

49  : thisN_(), btlNS_(), etlNS_() {
50  names_ = p.getUntrackedParameter<std::vector<std::string>>("Name");
51  nsens_.resize(names_.size());
52  for (size_t index = 0; index < nsens_.size(); index++) {
53  nsens_[index] = 0;
54  }
55  G4cout << "PrintMTDSens:: Print position of MTD Sensitive Touchables: " << G4endl;
56  for (const auto &thisName : names_) {
57  G4cout << " for name " << thisName << "\n";
58  }
59  G4cout << " Total of " << names_.size() << " sensitive volume types" << G4endl;
60 }
ETLNumberingScheme etlNS_
Definition: PrintMTDSens.cc:46
std::vector< size_t > nsens_
Definition: PrintMTDSens.cc:41
MTDBaseNumber thisN_
Definition: PrintMTDSens.cc:44
std::vector< std::string > names_
Definition: PrintMTDSens.cc:40
BTLNumberingScheme btlNS_
Definition: PrintMTDSens.cc:45

◆ ~PrintMTDSens()

PrintMTDSens::~PrintMTDSens ( )
override

Definition at line 62 of file PrintMTDSens.cc.

62 {}

Member Function Documentation

◆ dumpTouch()

int PrintMTDSens::dumpTouch ( G4VPhysicalVolume *  pv,
unsigned int  leafDepth,
int  ns 
)
private

Definition at line 75 of file PrintMTDSens.cc.

References btlNS_, edm::contains(), etlNS_, fHistory, alignBH_cfg::fixed, ecalTB2006H4_GenSimDigiReco_cfg::G4cout, getBaseNumber(), ETLNumberingScheme::getUnitID(), BTLNumberingScheme::getUnitID(), recoMuon::in, PixelPluginsPhase0_cfi::isBarrel, names_, nsens_, groupFilesInBlocks::ntotal, riemannFit::printIt(), DetId::rawId(), cms_rounding::roundIfNear0(), contentValuesCheck::ss, AlCaHLTBitMon_QueryRunRegistry::string, and thisN_.

Referenced by update().

75  {
76  if (leafDepth == 0)
77  fHistory.SetFirstEntry(pv);
78  else
79  fHistory.NewLevel(pv, kNormal, pv->GetCopyNo());
80 
81  int ntotal(ns);
82  G4ThreeVector globalpoint = fHistory.GetTopTransform().Inverse().TransformPoint(G4ThreeVector(0, 0, 0));
83  G4LogicalVolume *lv = pv->GetLogicalVolume();
84 
85  std::string mother = "World";
86  bool printIt(false);
87  if (pv->GetMotherLogical()) {
88  mother = pv->GetMotherLogical()->GetName();
89  }
90  size_t index(0);
91  for (const auto &thisName : names_) {
92  G4String g4name(thisName);
93  if (G4StrUtil::contains(lv->GetName(), g4name)) {
94  printIt = true;
95  break;
96  }
97  index++;
98  }
99 
100  if (lv->GetSensitiveDetector() && printIt) {
101  std::stringstream sunitt;
102  ++ntotal;
103  ++nsens_[index];
104  bool isBarrel = getBaseNumber();
105  if (isBarrel) {
107  sunitt << theId.rawId();
108 #ifdef EDM_ML_DEBUG
109  G4cout << theId << G4endl;
110 #endif
111  } else {
113  sunitt << theId.rawId();
114 #ifdef EDM_ML_DEBUG
115  G4cout << theId << G4endl;
116 #endif
117  }
118 
119  auto fround = [&](double in) {
120  std::stringstream ss;
121  ss << std::fixed << std::setw(14) << roundIfNear0(in);
122  return ss.str();
123  };
124 
125  G4Box *thisSens = static_cast<G4Box *>(lv->GetSolid());
126  G4ThreeVector cn1Global = fHistory.GetTopTransform().Inverse().TransformPoint(
127  G4ThreeVector(thisSens->GetXHalfLength(), thisSens->GetYHalfLength(), thisSens->GetZHalfLength()));
128 
129  sunitt << fround(globalpoint.x()) << fround(globalpoint.y()) << fround(globalpoint.z()) << fround(cn1Global.x())
130  << fround(cn1Global.y()) << fround(cn1Global.z());
131  edm::LogVerbatim("MTDG4sensUnitTest") << sunitt.str();
132  }
133 
134  int NoDaughters = lv->GetNoDaughters();
135  while ((NoDaughters--) > 0) {
136  G4VPhysicalVolume *pvD = lv->GetDaughter(NoDaughters);
137  if (!pvD->IsReplicated())
138  ntotal = dumpTouch(pvD, leafDepth + 1, ntotal);
139  }
140 
141  if (leafDepth > 0)
142  fHistory.BackLevel();
143  return ntotal;
144 }
Log< level::Info, true > LogVerbatim
int dumpTouch(G4VPhysicalVolume *pv, unsigned int leafDepth, int ns)
Definition: PrintMTDSens.cc:75
bool contains(EventRange const &lh, EventID const &rh)
Definition: EventRange.cc:37
ETLNumberingScheme etlNS_
Definition: PrintMTDSens.cc:46
std::vector< size_t > nsens_
Definition: PrintMTDSens.cc:41
G4NavigationHistory fHistory
Definition: PrintMTDSens.cc:42
MTDBaseNumber thisN_
Definition: PrintMTDSens.cc:44
std::vector< std::string > names_
Definition: PrintMTDSens.cc:40
BTLNumberingScheme btlNS_
Definition: PrintMTDSens.cc:45
constexpr valType roundIfNear0(valType value, double tolerance=1.e-7)
Definition: Rounding.h:11
bool getBaseNumber()
uint32_t getUnitID(const MTDBaseNumber &baseNumber) const override
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
Detector identifier class for the Endcap Timing Layer.
Definition: ETLDetId.h:16
uint32_t getUnitID(const MTDBaseNumber &baseNumber) const override
Detector identifier class for the Barrel Timing Layer. The crystal count must start from 0...
Definition: BTLDetId.h:19
__host__ __device__ void printIt(C *m, const char *prefix="")
Definition: FitUtils.h:53

◆ getBaseNumber()

bool PrintMTDSens::getBaseNumber ( )
private

Definition at line 150 of file PrintMTDSens.cc.

References MTDBaseNumber::addLevel(), edm::contains(), fHistory, ecalTB2006H4_GenSimDigiReco_cfg::G4cout, MTDBaseNumber::getCapacity(), cuy::ii, MTDBaseNumber::reset(), MTDBaseNumber::setSize(), and thisN_.

Referenced by dumpTouch().

150  {
151  bool isBTL(false);
152  thisN_.reset();
153  thisN_.setSize(fHistory.GetMaxDepth());
154  int theSize = fHistory.GetDepth() + 1;
155  if (thisN_.getCapacity() < theSize)
156  thisN_.setSize(theSize);
157  //Get name and copy numbers
158  if (theSize > 1) {
159 #ifdef EDM_ML_DEBUG
160  G4cout << "Building MTD basenumber:" << G4endl;
161 #endif
162  for (int ii = theSize; ii-- > 0;) {
163  thisN_.addLevel(fHistory.GetVolume(ii)->GetName(), fHistory.GetReplicaNo(ii));
164 #ifdef EDM_ML_DEBUG
165  G4cout << "PrintMTDSens::getBaseNumber(): Adding level " << theSize - 1 - ii << ": "
166  << fHistory.GetVolume(ii)->GetName() << "[" << fHistory.GetReplicaNo(ii) << "]" << G4endl;
167 #endif
168  if (!isBTL) {
169  isBTL = G4StrUtil::contains(fHistory.GetVolume(ii)->GetName(), "BarrelTimingLayer");
170  }
171  }
172  }
173  return isBTL;
174 }
bool contains(EventRange const &lh, EventID const &rh)
Definition: EventRange.cc:37
G4NavigationHistory fHistory
Definition: PrintMTDSens.cc:42
void addLevel(const std::string_view name, const int copyNumber)
MTDBaseNumber thisN_
Definition: PrintMTDSens.cc:44
ii
Definition: cuy.py:589
void setSize(const int size)

◆ getTopPV()

G4VPhysicalVolume * PrintMTDSens::getTopPV ( )
private

Definition at line 146 of file PrintMTDSens.cc.

Referenced by update().

146  {
147  return G4TransportationManager::GetTransportationManager()->GetNavigatorForTracking()->GetWorldVolume();
148 }

◆ update()

void PrintMTDSens::update ( const BeginOfRun )
overrideprivatevirtual

This routine will be called when the appropriate signal arrives.

Implements Observer< const BeginOfRun *>.

Definition at line 64 of file PrintMTDSens.cc.

References dumpTouch(), ecalTB2006H4_GenSimDigiReco_cfg::G4cout, getTopPV(), names_, nsens_, and groupFilesInBlocks::ntotal.

Referenced by progressbar.ProgressBar::__next__(), MatrixUtil.Matrix::__setitem__(), MatrixUtil.Steps::__setitem__(), progressbar.ProgressBar::finish(), and MatrixUtil.Steps::overwrite().

64  {
65  G4VPhysicalVolume *theTopPV = getTopPV();
66  int ntotal = dumpTouch(theTopPV, 0, 0);
67  G4cout << "\nTotal number of sensitive detector volumes for MTD is " << ntotal << G4endl;
68  for (size_t index = 0; index < nsens_.size(); index++) {
69  G4cout << "Sensitive volume " << names_[index] << " # copies " << nsens_[index] << G4endl;
70  }
71 }
int dumpTouch(G4VPhysicalVolume *pv, unsigned int leafDepth, int ns)
Definition: PrintMTDSens.cc:75
std::vector< size_t > nsens_
Definition: PrintMTDSens.cc:41
std::vector< std::string > names_
Definition: PrintMTDSens.cc:40
G4VPhysicalVolume * getTopPV()

Member Data Documentation

◆ btlNS_

BTLNumberingScheme PrintMTDSens::btlNS_
private

Definition at line 45 of file PrintMTDSens.cc.

Referenced by dumpTouch().

◆ etlNS_

ETLNumberingScheme PrintMTDSens::etlNS_
private

Definition at line 46 of file PrintMTDSens.cc.

Referenced by dumpTouch().

◆ fHistory

G4NavigationHistory PrintMTDSens::fHistory
private

Definition at line 42 of file PrintMTDSens.cc.

Referenced by dumpTouch(), and getBaseNumber().

◆ names_

std::vector<std::string> PrintMTDSens::names_
private

Definition at line 40 of file PrintMTDSens.cc.

Referenced by dumpTouch(), PrintMTDSens(), and update().

◆ nsens_

std::vector<size_t> PrintMTDSens::nsens_
private

Definition at line 41 of file PrintMTDSens.cc.

Referenced by dumpTouch(), PrintMTDSens(), and update().

◆ thisN_

MTDBaseNumber PrintMTDSens::thisN_
private

Definition at line 44 of file PrintMTDSens.cc.

Referenced by dumpTouch(), and getBaseNumber().