CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
DDG4ProductionCuts Class Reference

#include <DDG4ProductionCuts.h>

Public Member Functions

 DDG4ProductionCuts (const dd4hep::SpecParRegistry *, const dd4hep::sim::Geant4GeometryMaps::VolumeMap *, int, bool)
 
 DDG4ProductionCuts (const G4LogicalVolumeToDDLogicalPartMap *, int, bool)
 

Private Member Functions

void dd4hepInitialize ()
 
void initialize ()
 
void setProdCuts (const dd4hep::SpecPar *, G4Region *)
 
void setProdCuts (const DDLogicalPart, G4Region *)
 

Private Attributes

const dd4hep::sim::Geant4GeometryMaps::VolumeMap * dd4hepMap_ = nullptr
 
std::vector< std::pair< G4LogicalVolume *, const dd4hep::SpecPar * > > dd4hepVec_
 
const std::string keywordRegion_
 
const G4LogicalVolumeToDDLogicalPartMapmap_ = nullptr
 
const bool protonCut_
 
const dd4hep::SpecParRegistry * specPars_
 
G4LogicalVolumeToDDLogicalPartMap::Vector vec_
 
const int verbosity_
 

Detailed Description

Definition at line 15 of file DDG4ProductionCuts.h.

Constructor & Destructor Documentation

◆ DDG4ProductionCuts() [1/2]

DDG4ProductionCuts::DDG4ProductionCuts ( const G4LogicalVolumeToDDLogicalPartMap map,
int  verb,
bool  pcut 
)
explicit

Definition at line 61 of file DDG4ProductionCuts.cc.

62  : map_(map), keywordRegion_("CMSCutsRegion"), verbosity_(verb), protonCut_(pcut) {
63  initialize();
64 }

References initialize().

◆ DDG4ProductionCuts() [2/2]

DDG4ProductionCuts::DDG4ProductionCuts ( const dd4hep::SpecParRegistry *  specPars,
const dd4hep::sim::Geant4GeometryMaps::VolumeMap *  map,
int  verb,
bool  pcut 
)
explicit

Definition at line 66 of file DDG4ProductionCuts.cc.

70  : dd4hepMap_(map), specPars_(specPars), keywordRegion_("CMSCutsRegion"), verbosity_(verb), protonCut_(pcut) {
72 }

References dd4hepInitialize().

Member Function Documentation

◆ dd4hepInitialize()

void DDG4ProductionCuts::dd4hepInitialize ( )
private

Definition at line 120 of file DDG4ProductionCuts.cc.

120  {
121  dd4hep::SpecParRefs specs;
122  specPars_->filter(specs, keywordRegion_);
123 
124  for (auto const& it : *dd4hepMap_) {
125  for (auto const& fit : specs) {
126  for (auto const& pit : fit.second->paths) {
127  const std::string_view selection = dd4hep::dd::realTopName(pit);
128  const std::string_view name = dd4hep::dd::noNamespace(it.first.name());
129  if (!(dd4hep::dd::isRegex(selection))
130  ? dd4hep::dd::compareEqual(name, selection)
131  : std::regex_match(name.begin(), name.end(), std::regex(std::string(selection)))) {
132  dd4hepVec_.emplace_back(std::make_pair<G4LogicalVolume*, const dd4hep::SpecPar*>(&*it.second, &*fit.second));
133  }
134  }
135  }
136  }
137  // sort all root volumes - to get the same sequence at every run of the application.
138  sort(begin(dd4hepVec_), end(dd4hepVec_), &sortByName);
139 
140  // Now generate all the regions
141  for (auto const& it : dd4hepVec_) {
142  auto regName = it.second->strValue(keywordRegion_);
143  G4Region* region = G4RegionStore::GetInstance()->FindOrCreateRegion({regName.data(), regName.size()});
144  region->AddRootLogicalVolume(it.first);
145  edm::LogVerbatim("Geometry") << it.first->GetName() << ": " << it.second->strValue(keywordRegion_);
146  edm::LogVerbatim("Geometry") << " MakeRegions: added " << it.first->GetName() << " to region " << region->GetName();
147  edm::LogVerbatim("Geometry").log([&](auto& log) {
148  for (auto const& sit : it.second->spars) {
149  log << sit.first << " = " << sit.second[0] << "\n";
150  }
151  });
152  setProdCuts(it.second, region);
153  }
154 
155  if (verbosity_ > 0) {
156  edm::LogVerbatim("SimG4CoreGeometry") << " DDG4ProductionCuts (New) : starting\n"
157  << " DDG4ProductionCuts : Got " << dd4hepVec_.size() << " region roots.\n"
158  << " DDG4ProductionCuts : List of all roots:";
159  for (size_t jj = 0; jj < dd4hepVec_.size(); ++jj)
160  edm::LogVerbatim("SimG4CoreGeometry") << " DDG4ProductionCuts : root=" << dd4hepVec_[jj].first->GetName()
161  << " , " << dd4hepVec_[jj].second->paths.at(0);
162  }
163 }

References dd4hepMap_, dd4hepVec_, mps_fire::end, findQualityFiles::jj, keywordRegion_, dqm-mbProfile::log, Skims_PA_cff::name, HLT_FULL_cff::region, corrVsCorr::selection, setProdCuts(), specPars_, HistogramManager_cfi::specs, AlCaHLTBitMon_QueryRunRegistry::string, and verbosity_.

Referenced by DDG4ProductionCuts().

◆ initialize()

void DDG4ProductionCuts::initialize ( void  )
private

Definition at line 74 of file DDG4ProductionCuts.cc.

74  {
76  // sort all root volumes - to get the same sequence at every run of the application.
77  // (otherwise, the sequence will depend on the pointer (memory address) of the
78  // involved objects, because 'new' does no guarantee that you allways get a
79  // higher (or lower) address when allocating an object of the same type ...
80  sort(vec_.begin(), vec_.end(), &dd_is_greater);
81  if (verbosity_ > 0) {
82  edm::LogVerbatim("Geometry") << " DDG4ProductionCuts : got " << vec_.size() << " region roots.\n"
83  << " DDG4ProductionCuts : List of all roots:";
84  for (auto const& vv : vec_)
85  edm::LogVerbatim("Geometry") << " " << vv.first->GetName() << " : " << vv.second.name();
86  }
87 
88  // Now generate all the regions
89  std::string curName = "";
90  std::string regionName = "";
91  G4Region* region = nullptr;
92  G4RegionStore* store = G4RegionStore::GetInstance();
93  for (auto const& vv : vec_) {
94  unsigned int num = map_->toString(keywordRegion_, vv.second, regionName);
95  edm::LogVerbatim("Geometry") << " num " << num << " regionName: " << regionName << ", the store of size "
96  << store->size();
97  if (num != 1) {
98  throw cms::Exception("SimG4CoreGeometry", " DDG4ProductionCuts::initialize: Problem with Region tags.");
99  }
100  if (regionName != curName) {
101  edm::LogVerbatim("Geometry") << "DDG4ProductionCuts : regionName " << regionName << ", the store of size "
102  << store->size();
103  region = store->FindOrCreateRegion(regionName);
104  edm::LogVerbatim("Geometry") << "DDG4ProductionCuts : region " << region->GetName();
105  if (!region) {
106  throw cms::Exception("SimG4CoreGeometry", " DDG4ProductionCuts::initialize: Problem with Region tags.");
107  }
108  curName = regionName;
109  edm::LogVerbatim("Geometry") << "DDG4ProductionCuts : new G4Region " << vv.first->GetName();
110  setProdCuts(vv.second, region);
111  }
112 
113  region->AddRootLogicalVolume(vv.first);
114 
115  if (verbosity_ > 0)
116  edm::LogVerbatim("Geometry") << " added " << vv.first->GetName() << " to region " << region->GetName();
117  }
118 }

References DDMapper< KeyType, ValueType >::all(), Exception, keywordRegion_, map_, EgammaValidation_cff::num, HLT_FULL_cff::region, setProdCuts(), AlCaHLTBitMon_QueryRunRegistry::string, DDMapper< KeyType, ValueType >::toString(), vec_, and verbosity_.

Referenced by DDG4ProductionCuts().

◆ setProdCuts() [1/2]

void DDG4ProductionCuts::setProdCuts ( const dd4hep::SpecPar *  spec,
G4Region *  region 
)
private

Definition at line 226 of file DDG4ProductionCuts.cc.

226  {
227  //
228  // Create and fill production cuts
229  //
230  G4ProductionCuts* prodCuts = region->GetProductionCuts();
231  if (!prodCuts) {
232  //
233  // search for production cuts
234  // you must have four of them: e+ e- gamma proton
235  //
236  double gammacut = spec->dblValue("ProdCutsForGamma") / MM_2_CM;
237  double electroncut = spec->dblValue("ProdCutsForElectrons") / MM_2_CM;
238  double positroncut = spec->dblValue("ProdCutsForPositrons") / MM_2_CM;
239  double protoncut = spec->dblValue("ProdCutsForProtons") / MM_2_CM;
240  if (protoncut == 0) {
241  protoncut = electroncut;
242  }
243 
244  prodCuts = new G4ProductionCuts();
245  region->SetProductionCuts(prodCuts);
246 
247  prodCuts->SetProductionCut(gammacut, idxG4GammaCut);
248  prodCuts->SetProductionCut(electroncut, idxG4ElectronCut);
249  prodCuts->SetProductionCut(positroncut, idxG4PositronCut);
250  prodCuts->SetProductionCut(protoncut, idxG4ProtonCut);
251  if (verbosity_ > 0) {
252  edm::LogVerbatim("Geometry") << "DDG4ProductionCuts : Setting cuts for " << region->GetName()
253  << "\n Electrons: " << electroncut << "\n Positrons: " << positroncut
254  << "\n Gamma : " << gammacut << "\n Proton : " << protoncut;
255  }
256  } else {
257  if (verbosity_ > 0) {
258  edm::LogVerbatim("Geometry")
259  << "DDG4ProductionCuts : Cuts are already set for " << region->GetName()
260  << "\n Electrons: " << region->GetProductionCuts()->GetProductionCut(idxG4ElectronCut)
261  << "\n Positrons: " << region->GetProductionCuts()->GetProductionCut(idxG4PositronCut)
262  << "\n Gamma : " << region->GetProductionCuts()->GetProductionCut(idxG4GammaCut)
263  << "\n Proton : " << region->GetProductionCuts()->GetProductionCut(idxG4ProtonCut);
264  }
265  }
266 }

References MM_2_CM, HLT_FULL_cff::region, and verbosity_.

◆ setProdCuts() [2/2]

void DDG4ProductionCuts::setProdCuts ( const DDLogicalPart  lpart,
G4Region *  region 
)
private

Definition at line 165 of file DDG4ProductionCuts.cc.

165  {
166  //
167  // search for production cuts
168  // you must have four of them: e+ e- gamma proton
169  //
170  double gammacut = 0.0;
171  double electroncut = 0.0;
172  double positroncut = 0.0;
173  double protoncut = 0.0;
174  int temp = map_->toDouble("ProdCutsForGamma", lpart, gammacut);
175  if (temp != 1) {
176  throw cms::Exception(
177  "SimG4CorePhysics",
178  " DDG4ProductionCuts::setProdCuts: Problem with Region tags - no/more than one ProdCutsForGamma.");
179  }
180  temp = map_->toDouble("ProdCutsForElectrons", lpart, electroncut);
181  if (temp != 1) {
182  throw cms::Exception(
183  "SimG4CorePhysics",
184  " DDG4ProductionCuts::setProdCuts: Problem with Region tags - no/more than one ProdCutsForElectrons.");
185  }
186  temp = map_->toDouble("ProdCutsForPositrons", lpart, positroncut);
187  if (temp != 1) {
188  throw cms::Exception(
189  "SimG4CorePhysics",
190  " DDG4ProductionCuts::setProdCuts: Problem with Region tags - no/more than one ProdCutsForPositrons.");
191  }
192  temp = map_->toDouble("ProdCutsForProtons", lpart, protoncut);
193  if (temp == 0) {
194  // There is no ProdCutsForProtons set in XML,
195  // check if it's a legacy geometry scenario without it
196  if (protonCut_) {
197  protoncut = electroncut;
198  } else {
199  protoncut = 0.;
200  }
201  } else if (temp != 1) {
202  throw cms::Exception(
203  "SimG4CorePhysics",
204  " DDG4ProductionCuts::setProdCuts: Problem with Region tags - more than one ProdCutsForProtons.");
205  }
206 
207  //
208  // Create and fill production cuts
209  //
210  G4ProductionCuts* prodCuts = region->GetProductionCuts();
211  if (!prodCuts) {
212  prodCuts = new G4ProductionCuts();
213  region->SetProductionCuts(prodCuts);
214  }
215  prodCuts->SetProductionCut(gammacut, idxG4GammaCut);
216  prodCuts->SetProductionCut(electroncut, idxG4ElectronCut);
217  prodCuts->SetProductionCut(positroncut, idxG4PositronCut);
218  prodCuts->SetProductionCut(protoncut, idxG4ProtonCut);
219  if (verbosity_ > 0) {
220  edm::LogVerbatim("Geometry") << "DDG4ProductionCuts : Setting cuts for " << region->GetName()
221  << "\n Electrons: " << electroncut << "\n Positrons: " << positroncut
222  << "\n Gamma : " << gammacut << "\n Proton : " << protoncut;
223  }
224 }

References Exception, map_, protonCut_, HLT_FULL_cff::region, groupFilesInBlocks::temp, DDMapper< KeyType, ValueType >::toDouble(), and verbosity_.

Referenced by dd4hepInitialize(), and initialize().

Member Data Documentation

◆ dd4hepMap_

const dd4hep::sim::Geant4GeometryMaps::VolumeMap* DDG4ProductionCuts::dd4hepMap_ = nullptr
private

Definition at line 37 of file DDG4ProductionCuts.h.

Referenced by dd4hepInitialize().

◆ dd4hepVec_

std::vector<std::pair<G4LogicalVolume*, const dd4hep::SpecPar*> > DDG4ProductionCuts::dd4hepVec_
private

Definition at line 38 of file DDG4ProductionCuts.h.

Referenced by dd4hepInitialize().

◆ keywordRegion_

const std::string DDG4ProductionCuts::keywordRegion_
private

Definition at line 43 of file DDG4ProductionCuts.h.

Referenced by dd4hepInitialize(), and initialize().

◆ map_

const G4LogicalVolumeToDDLogicalPartMap* DDG4ProductionCuts::map_ = nullptr
private

Definition at line 28 of file DDG4ProductionCuts.h.

Referenced by initialize(), and setProdCuts().

◆ protonCut_

const bool DDG4ProductionCuts::protonCut_
private

Definition at line 45 of file DDG4ProductionCuts.h.

Referenced by setProdCuts().

◆ specPars_

const dd4hep::SpecParRegistry* DDG4ProductionCuts::specPars_
private

Definition at line 39 of file DDG4ProductionCuts.h.

Referenced by dd4hepInitialize().

◆ vec_

G4LogicalVolumeToDDLogicalPartMap::Vector DDG4ProductionCuts::vec_
private

Definition at line 29 of file DDG4ProductionCuts.h.

Referenced by initialize().

◆ verbosity_

const int DDG4ProductionCuts::verbosity_
private

Definition at line 44 of file DDG4ProductionCuts.h.

Referenced by dd4hepInitialize(), initialize(), and setProdCuts().

DDMapper::toDouble
unsigned int toDouble(const std::string &name, const KeyType &key, double &value, unsigned int pos=0) const
returns the number specific parameters named 'name' and the corrsponding double
Definition: DDMapper.h:111
DDG4ProductionCuts::verbosity_
const int verbosity_
Definition: DDG4ProductionCuts.h:44
HistogramManager_cfi.specs
specs
Definition: HistogramManager_cfi.py:80
DDG4ProductionCuts::dd4hepMap_
const dd4hep::sim::Geant4GeometryMaps::VolumeMap * dd4hepMap_
Definition: DDG4ProductionCuts.h:37
groupFilesInBlocks.temp
list temp
Definition: groupFilesInBlocks.py:142
DDG4ProductionCuts::protonCut_
const bool protonCut_
Definition: DDG4ProductionCuts.h:45
DDG4ProductionCuts::map_
const G4LogicalVolumeToDDLogicalPartMap * map_
Definition: DDG4ProductionCuts.h:28
mps_fire.end
end
Definition: mps_fire.py:242
corrVsCorr.selection
selection
main part
Definition: corrVsCorr.py:100
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
DDG4ProductionCuts::keywordRegion_
const std::string keywordRegion_
Definition: DDG4ProductionCuts.h:43
MM_2_CM
#define MM_2_CM
Definition: DDG4ProductionCuts.cc:23
HLT_FULL_cff.region
region
Definition: HLT_FULL_cff.py:88338
DDG4ProductionCuts::dd4hepVec_
std::vector< std::pair< G4LogicalVolume *, const dd4hep::SpecPar * > > dd4hepVec_
Definition: DDG4ProductionCuts.h:38
DDG4ProductionCuts::specPars_
const dd4hep::SpecParRegistry * specPars_
Definition: DDG4ProductionCuts.h:39
DDMapper::toString
unsigned int toString(const std::string &name, const KeyType &key, std::string &value, unsigned int pos=0) const
same as toDouble but for std::string-valued values of named parameters
Definition: DDMapper.h:172
EgammaValidation_cff.num
num
Definition: EgammaValidation_cff.py:34
std
Definition: JetResolutionObject.h:76
DDG4ProductionCuts::vec_
G4LogicalVolumeToDDLogicalPartMap::Vector vec_
Definition: DDG4ProductionCuts.h:29
edm::LogVerbatim
Log< level::Info, true > LogVerbatim
Definition: MessageLogger.h:128
Exception
Definition: hltDiff.cc:246
findQualityFiles.jj
string jj
Definition: findQualityFiles.py:188
DDG4ProductionCuts::initialize
void initialize()
Definition: DDG4ProductionCuts.cc:74
DDMapper::all
Vector all(const std::string &name, const std::string &value) const
get all std::mapped instances which have a specific 'name' with value 'value'
Definition: DDMapper.h:199
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
dqm-mbProfile.log
log
Definition: dqm-mbProfile.py:17
genParticles_cff.map
map
Definition: genParticles_cff.py:11
DDG4ProductionCuts::setProdCuts
void setProdCuts(const DDLogicalPart, G4Region *)
Definition: DDG4ProductionCuts.cc:165
edm::Log
Definition: MessageLogger.h:70
DDG4ProductionCuts::dd4hepInitialize
void dd4hepInitialize()
Definition: DDG4ProductionCuts.cc:120
fit
Definition: CombinedChiSquaredLikelihood.h:6