CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Private Member Functions | Private Attributes
fastsim::SimplifiedGeometryFactory Class Reference

Constructs a tracker layer according to entry in python config (incl interaction models). More...

#include <SimplifiedGeometryFactory.h>

Public Types

enum  LayerType { BARREL, POSFWD, NEGFWD }
 Each layer is either a barrel layer, or a forward layer (either at ppositive or negative Z). More...
 

Public Member Functions

std::unique_ptr< BarrelSimplifiedGeometrycreateBarrelSimplifiedGeometry (const edm::ParameterSet &cfg) const
 Helper method for createSimplifiedGeometry(..) to create a barrel layer (BarrelSimplifiedGeometry). More...
 
std::unique_ptr< ForwardSimplifiedGeometrycreateForwardSimplifiedGeometry (LayerType type, const edm::ParameterSet &cfg) const
 Helper method for createSimplifiedGeometry(..) to create a forward layer (ForwardSimplifiedGeometry). More...
 
std::unique_ptr< SimplifiedGeometrycreateSimplifiedGeometry (LayerType type, const edm::ParameterSet &cfg) const
 Main method of this class. Creates a new detector layer (SimplifiedGeometry). More...
 
 SimplifiedGeometryFactory (const GeometricSearchTracker *geometricSearchTracker, const MagneticField &magneticField, const std::map< std::string, fastsim::InteractionModel * > &interactionModelMap, double magneticFieldHistMaxR, double magneticFieldHistMaxZ)
 Constructor. More...
 

Private Member Functions

const DetLayergetDetLayer (const std::string &detLayerName, const GeometricSearchTracker &geometricSearchTracker) const
 Method returns a pointer to a DetLayer according to the string that was passed. More...
 

Private Attributes

std::map< std::string, const std::vector< BarrelDetLayer const * > * > barrelDetLayersMap_
 A map of strings and pointers to detLayers. More...
 
std::map< std::string, const std::vector< ForwardDetLayer const * > * > forwardDetLayersMap_
 A map of strings and pointers to detLayers. More...
 
const GeometricSearchTracker *const geometricSearchTracker_
 The full tracker geometry. More...
 
const std::map< std::string, fastsim::InteractionModel * > * interactionModelMap_
 Map of interaction models. More...
 
const MagneticField *const magneticField_
 The full magnetic field. More...
 
const double magneticFieldHistMaxR_
 Limit in R for histogram of magnetic field. More...
 
const double magneticFieldHistMaxZ_
 Limit in +-Z for histogram of magnetic field. More...
 

Detailed Description

Constructs a tracker layer according to entry in python config (incl interaction models).

Also creates links to DetLayer (if active layer) and stores strength of magnetic field along the layer. If some parameters are not stored in the config file, tries to get them from the full detector geometry (GeometricSearchTracker). This is however only possible for active layers.

See also
Geometry()
SimplifiedGeometry()

Definition at line 44 of file SimplifiedGeometryFactory.h.

Member Enumeration Documentation

Each layer is either a barrel layer, or a forward layer (either at ppositive or negative Z).

Enumerator
BARREL 
POSFWD 
NEGFWD 

Definition at line 62 of file SimplifiedGeometryFactory.h.

Constructor & Destructor Documentation

fastsim::SimplifiedGeometryFactory::SimplifiedGeometryFactory ( const GeometricSearchTracker geometricSearchTracker,
const MagneticField magneticField,
const std::map< std::string, fastsim::InteractionModel * > &  interactionModelMap,
double  magneticFieldHistMaxR,
double  magneticFieldHistMaxZ 
)

Constructor.

Parameters
geometricSearchTrackerThe full tracker geometry (needed for links to active detLayers).
magneticFieldThe full magnetic field.
interactionModelMapMap of interaction models that should be assigned for that layer.
magneticFieldHistMaxRMax Radius for initialization of magnetic field histogram (TH1, limit of axis).
magneticFieldHistMaxZMax Z for initialization of magnetic field histogram (TH1, limit of axis).

Definition at line 14 of file SimplifiedGeometryFactory.cc.

References barrelDetLayersMap_, forwardDetLayersMap_, geometricSearchTracker_, GeometricSearchTracker::negPixelForwardLayers(), GeometricSearchTracker::negTecLayers(), GeometricSearchTracker::negTidLayers(), GeometricSearchTracker::pixelBarrelLayers(), GeometricSearchTracker::posPixelForwardLayers(), GeometricSearchTracker::posTecLayers(), GeometricSearchTracker::posTidLayers(), GeometricSearchTracker::tibLayers(), and GeometricSearchTracker::tobLayers().

19  : geometricSearchTracker_(geometricSearchTracker)
20  , magneticField_(&magneticField)
21  , interactionModelMap_(&interactionModelMap)
22  , magneticFieldHistMaxR_(magneticFieldHistMaxR)
23  , magneticFieldHistMaxZ_(magneticFieldHistMaxZ)
24 {
25  // naming convention for barrel DetLayer lists
29 
30  // naming convention for forward DetLayer lists
37 }
std::map< std::string, const std::vector< BarrelDetLayer const * > * > barrelDetLayersMap_
A map of strings and pointers to detLayers.
const double magneticFieldHistMaxZ_
Limit in +-Z for histogram of magnetic field.
std::vector< ForwardDetLayer const * > const & posPixelForwardLayers() const
const MagneticField *const magneticField_
The full magnetic field.
std::vector< BarrelDetLayer const * > const & tobLayers() const
std::vector< ForwardDetLayer const * > const & negPixelForwardLayers() const
std::vector< BarrelDetLayer const * > const & pixelBarrelLayers() const
const GeometricSearchTracker *const geometricSearchTracker_
The full tracker geometry.
std::vector< BarrelDetLayer const * > const & tibLayers() const
std::vector< ForwardDetLayer const * > const & posTecLayers() const
std::vector< ForwardDetLayer const * > const & negTidLayers() const
std::map< std::string, const std::vector< ForwardDetLayer const * > * > forwardDetLayersMap_
A map of strings and pointers to detLayers.
std::vector< ForwardDetLayer const * > const & posTidLayers() const
const std::map< std::string, fastsim::InteractionModel * > * interactionModelMap_
Map of interaction models.
std::vector< ForwardDetLayer const * > const & negTecLayers() const
const double magneticFieldHistMaxR_
Limit in R for histogram of magnetic field.

Member Function Documentation

std::unique_ptr< fastsim::BarrelSimplifiedGeometry > fastsim::SimplifiedGeometryFactory::createBarrelSimplifiedGeometry ( const edm::ParameterSet cfg) const

Helper method for createSimplifiedGeometry(..) to create a barrel layer (BarrelSimplifiedGeometry).

Returns
A BarrelSimplifiedGeometry
See also
createSimplifiedGeometry(LayerType type, const edm::ParameterSet & cfg)

Definition at line 39 of file SimplifiedGeometryFactory.cc.

References BARREL, and createSimplifiedGeometry().

Referenced by fastsim::Geometry::update().

40 {
41  std::unique_ptr<fastsim::SimplifiedGeometry> layer = createSimplifiedGeometry(BARREL,cfg);
42  return std::unique_ptr<fastsim::BarrelSimplifiedGeometry>(static_cast<fastsim::BarrelSimplifiedGeometry *>(layer.release()));
43 }
Implementation of a barrel detector layer (cylindrical).
std::unique_ptr< SimplifiedGeometry > createSimplifiedGeometry(LayerType type, const edm::ParameterSet &cfg) const
Main method of this class. Creates a new detector layer (SimplifiedGeometry).
std::unique_ptr< fastsim::ForwardSimplifiedGeometry > fastsim::SimplifiedGeometryFactory::createForwardSimplifiedGeometry ( LayerType  type,
const edm::ParameterSet cfg 
) const

Helper method for createSimplifiedGeometry(..) to create a forward layer (ForwardSimplifiedGeometry).

Parameters
typeEither POSFWD or NEGFWD.
Returns
A ForwardSimplifiedGeometry
See also
createSimplifiedGeometry(LayerType type, const edm::ParameterSet & cfg)

Definition at line 45 of file SimplifiedGeometryFactory.cc.

References createSimplifiedGeometry(), Exception, NEGFWD, and POSFWD.

Referenced by fastsim::Geometry::update().

47 {
48  if(layerType != NEGFWD && layerType != POSFWD)
49  {
50  throw cms::Exception("fastsim::SimplifiedGeometry::createForwardLayer") << " called with forbidden layerType. Allowed layerTypes are NEGFWD and POSFWD";
51  }
52  std::unique_ptr<fastsim::SimplifiedGeometry> layer = createSimplifiedGeometry(layerType,cfg);
53  return std::unique_ptr<fastsim::ForwardSimplifiedGeometry>(static_cast<fastsim::ForwardSimplifiedGeometry *>(layer.release()));
54 }
Implementation of a forward detector layer (disk).
std::unique_ptr< SimplifiedGeometry > createSimplifiedGeometry(LayerType type, const edm::ParameterSet &cfg) const
Main method of this class. Creates a new detector layer (SimplifiedGeometry).
std::unique_ptr< fastsim::SimplifiedGeometry > fastsim::SimplifiedGeometryFactory::createSimplifiedGeometry ( LayerType  type,
const edm::ParameterSet cfg 
) const

Main method of this class. Creates a new detector layer (SimplifiedGeometry).

Reads the config file, does all the initialization etc. and creates either a forward or a barrel layer (depends on LayerType type).

Parameters
typeEither BARREL, POSFWD or NEGFWD.
Returns
A SimplifiedGeometry (either ForwardSimplifiedGeometry or BarrelSimplifiedGeometry).

Definition at line 56 of file SimplifiedGeometryFactory.cc.

References edm::ParameterSet::allToString(), BARREL, fastsim::SimplifiedGeometry::ECAL, Exception, edm::ParameterSet::exists(), geometricSearchTracker_, getDetLayer(), edm::ParameterSet::getUntrackedParameter(), fastsim::SimplifiedGeometry::HCAL, mps_fire::i, interactionModelMap_, MagneticField::inTesla(), ecaldqm::isForward(), diffTwoXMLs::label, magneticField_, magneticFieldHistMaxR_, magneticFieldHistMaxZ_, point, POSFWD, GeometricSearchDet::position(), position, fastsim::SimplifiedGeometry::PRESHOWER1, fastsim::SimplifiedGeometry::PRESHOWER2, AlCaHLTBitMon_QueryRunRegistry::string, fastsim::SimplifiedGeometry::VFCAL, and PV3DBase< T, PVType, FrameType >::z().

Referenced by createBarrelSimplifiedGeometry(), and createForwardSimplifiedGeometry().

58 {
59 
60  // some flags for internal usage
61  bool isForward = true;
62  bool isOnPositiveSide = false;
63  if(layerType == BARREL)
64  {
65  isForward = false;
66  }
67  else if(layerType == POSFWD)
68  {
69  isOnPositiveSide = true;
70  }
71 
72  // -------------------------------
73  // extract DetLayer (i.e. full geometry of tracker modules)
74  // -------------------------------
75 
76  std::string detLayerName = cfg.getUntrackedParameter<std::string>("activeLayer","");
77  const DetLayer * detLayer = nullptr;
78 
79  if(!detLayerName.empty() && geometricSearchTracker_)
80  {
81  if(isForward)
82  {
83  detLayerName = (isOnPositiveSide ? "pos" : "neg") + detLayerName;
84  }
85  detLayer = getDetLayer(detLayerName,*geometricSearchTracker_);
86  }
87 
88  // ------------------------------
89  // radius / z of layers
90  // ------------------------------
91 
92  // first try to get it from the configuration
93  double position = 0;
94  std::string positionParameterName = (isForward ? "z" : "radius");
95  if(cfg.exists(positionParameterName))
96  {
97  position = fabs(cfg.getUntrackedParameter<double>(positionParameterName));
98  if(isForward && !isOnPositiveSide)
99  {
100  position = -position;
101  }
102  }
103  // then try extracting from detLayer
104  else if(detLayer)
105  {
106  if(isForward)
107  {
108  position = static_cast<ForwardDetLayer const*>(detLayer)->surface().position().z();
109  }
110  else
111  {
112  position = static_cast<BarrelDetLayer const*>(detLayer)->specificSurface().radius();
113  }
114  }
115  // then throw error
116  else
117  {
118  std::string cfgString;
119  cfg.allToString(cfgString);
120  throw cms::Exception("fastsim::SimplifiedGeometry") << "Cannot extract a "
121  << (isForward ? "position" : "radius") << " for this "
122  << (isForward ? "forward" : "barrel") << " layer:\n"
123  << cfgString;
124  }
125 
126  // -----------------------------
127  // create the layers
128  // -----------------------------
129 
130  std::unique_ptr<fastsim::SimplifiedGeometry> layer;
131  if(isForward)
132  {
133  layer.reset(new fastsim::ForwardSimplifiedGeometry(position));
134  }
135  else
136  {
137  layer.reset(new fastsim::BarrelSimplifiedGeometry(position));
138  }
139  layer->detLayer_ = detLayer;
140 
141  // -----------------------------
142  // thickness histogram
143  // -----------------------------
144 
145  // Get limits
146  const std::vector<double> & limits = cfg.getUntrackedParameter<std::vector<double> >("limits");
147  // and check order.
148  for(unsigned index = 1;index < limits.size();index++)
149  {
150  if(limits[index] < limits[index-1])
151  {
152  std::string cfgString;
153  cfg.allToString(cfgString);
154  throw cms::Exception("fastsim::SimplifiedGeometryFactory")
155  << "limits must be provided in increasing order. error in:\n"
156  << cfgString;
157  }
158  }
159  // Get thickness values
160  const std::vector<double> & thickness = cfg.getUntrackedParameter<std::vector<double> >("thickness");
161  // and check compatibility with limits
162  if(limits.size() < 2 || thickness.size() != limits.size() - 1)
163  {
164  std::string cfgString;
165  cfg.allToString(cfgString);
166  throw cms::Exception("fastim::SimplifiedGeometryFactory")
167  << "layer thickness and limits not configured properly! error in:"
168  << cfgString;
169  }
170  // create the histogram
171  layer->thicknessHist_.reset(new TH1F("h", "h", limits.size()-1, &limits[0]));
172  layer->thicknessHist_->SetDirectory(nullptr);
173  for(unsigned i = 1; i < limits.size(); ++i){
174  layer->thicknessHist_->SetBinContent(i, thickness[i-1]);
175  }
176 
177  // -----------------------------
178  // nuclear interaction thickness factor
179  // -----------------------------
180 
181  layer->nuclearInteractionThicknessFactor_ = cfg.getUntrackedParameter<double>("nuclearInteractionThicknessFactor",1.);
182 
183  // -----------------------------
184  // magnetic field
185  // -----------------------------
186 
187  layer->magneticFieldHist_.reset(new TH1F("h", "h", 100, 0., isForward ? magneticFieldHistMaxR_ : magneticFieldHistMaxZ_));
188  layer->magneticFieldHist_->SetDirectory(nullptr);
189  for(int i = 1; i <= 101; i++)
190  {
191  GlobalPoint point = isForward ?
192  GlobalPoint(layer->magneticFieldHist_->GetXaxis()->GetBinCenter(i), 0.,position)
193  : GlobalPoint(position, 0.,layer->magneticFieldHist_->GetXaxis()->GetBinCenter(i));
194  layer->magneticFieldHist_->SetBinContent(i, magneticField_->inTesla(point).z());
195  }
196 
197  // -----------------------------
198  // list of interaction models
199  // -----------------------------
200 
201  std::vector<std::string> interactionModelLabels = cfg.getUntrackedParameter<std::vector<std::string> >("interactionModels");
202  for(const auto & label : interactionModelLabels)
203  {
204  std::map<std::string,fastsim::InteractionModel *>::const_iterator interactionModel = interactionModelMap_->find(label);
205  if(interactionModel == interactionModelMap_->end())
206  {
207  throw cms::Exception("fastsim::SimplifiedGeometryFactory") << "unknown interaction model '" << label << "'";
208  }
209  layer->interactionModels_.push_back(interactionModel->second);
210  }
211 
212  // -----------------------------
213  // Hack to interface "old" calorimetry with "new" propagation in tracker
214  // -----------------------------
215 
216  if(cfg.exists("caloType"))
217  {
218  std::string caloType = cfg.getUntrackedParameter<std::string>("caloType");
219 
220  if(caloType == "PRESHOWER1"){
221  layer->setCaloType(SimplifiedGeometry::PRESHOWER1);
222  }else if(caloType == "PRESHOWER2"){
223  layer->setCaloType(SimplifiedGeometry::PRESHOWER2);
224  }else if(caloType == "ECAL"){
225  layer->setCaloType(SimplifiedGeometry::ECAL);
226  }else if(caloType == "HCAL"){
227  layer->setCaloType(SimplifiedGeometry::HCAL);
228  }else if(caloType == "VFCAL"){
229  layer->setCaloType(SimplifiedGeometry::VFCAL);
230  }else{
231  throw cms::Exception("fastsim::SimplifiedGeometryFactory") << "unknown caloType '" << caloType << "' (defined PRESHOWER1, PRESHOWER2, ECAL, HCAL, VFCAL)";
232  }
233  }
234 
235 
236  // -----------------------------
237  // and return the layer!
238  // -----------------------------
239 
240  return layer;
241 }
T getUntrackedParameter(std::string const &, T const &) const
Implementation of a forward detector layer (disk).
const double magneticFieldHistMaxZ_
Limit in +-Z for histogram of magnetic field.
const DetLayer * getDetLayer(const std::string &detLayerName, const GeometricSearchTracker &geometricSearchTracker) const
Method returns a pointer to a DetLayer according to the string that was passed.
const MagneticField *const magneticField_
The full magnetic field.
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
bool isForward(DetId const &)
bool exists(std::string const &parameterName) const
checks if a parameter exists
Implementation of a barrel detector layer (cylindrical).
T z() const
Definition: PV3DBase.h:64
const GeometricSearchTracker *const geometricSearchTracker_
The full tracker geometry.
virtual GlobalVector inTesla(const GlobalPoint &gp) const =0
Field value ad specified global point, in Tesla.
virtual const Surface::PositionType & position() const
Returns position of the surface.
void allToString(std::string &result) const
static int position[264][3]
Definition: ReadPGInfo.cc:509
const std::map< std::string, fastsim::InteractionModel * > * interactionModelMap_
Map of interaction models.
*vegas h *****************************************************used in the default bin number in original ***version of VEGAS is ***a higher bin number might help to derive a more precise ***grade subtle point
Definition: invegas.h:5
const double magneticFieldHistMaxR_
Limit in R for histogram of magnetic field.
const DetLayer * fastsim::SimplifiedGeometryFactory::getDetLayer ( const std::string &  detLayerName,
const GeometricSearchTracker geometricSearchTracker 
) const
private

Method returns a pointer to a DetLayer according to the string that was passed.

A convention for the name of the layer is used. For barrel layers this is "XXX?" where XXX is a part of the tracker and ? is the index of the layer (starting at one). For forward layers one has to add neg/pos in front to distinguish between the disk at -Z and +Z spatial position, so the convention is "xxxXXX?" Valid names: BPix, TIB, TOB, negFPix, posFPix, negTID, posTID, negTEC, posTEC Accordingly, the innermost layer of the barrel pixel detector is "BPix1".

Parameters
detLayerNameA string following the naming convention.

Definition at line 244 of file SimplifiedGeometryFactory.cc.

References barrelDetLayersMap_, relativeConstraints::error, Exception, forwardDetLayersMap_, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by createSimplifiedGeometry().

245 {
246  if(detLayerName.empty())
247  {
248  return nullptr;
249  }
250 
251  // obtain the index from the detLayerName
252  unsigned pos = detLayerName.size();
253  while(isdigit(detLayerName[pos-1]))
254  {
255  pos -= 1;
256  }
257  if(pos == detLayerName.size())
258  {
259  throw cms::Exception("fastsim::SimplifiedGeometry::getDetLayer") << "last part of detLayerName must be index of DetLayer in list. Error in detLayerName" << detLayerName << std::endl;
260  }
261  int index = atoi(detLayerName.substr(pos).c_str());
262  std::string detLayerListName = detLayerName.substr(0,pos);
263 
264  try
265  {
266  // try to find the detLayer in the barrel map
267  if(barrelDetLayersMap_.find(detLayerListName) != barrelDetLayersMap_.end())
268  {
269  auto detLayerList = barrelDetLayersMap_.find(detLayerListName)->second;
270  return detLayerList->at(index-1); // use at, to provoce the throwing of an error in case of a bad index
271  }
272 
273  // try to find the detLayer in the forward map
274  else if(forwardDetLayersMap_.find(detLayerListName) != forwardDetLayersMap_.end())
275  {
276  auto detLayerList = forwardDetLayersMap_.find(detLayerListName)->second;
277  return detLayerList->at(index-1); // use at, to provoce the throwing of an error in case of a bad index
278  }
279  // throw an error
280  else
281  {
282  throw cms::Exception("fastsim::SimplifiedGeometry::getDetLayer") << " could not find list of detLayers corresponding to detLayerName " << detLayerName << std::endl;
283  }
284  }
285  catch (const std::out_of_range& error)
286  {
287  throw cms::Exception("fastsim::SimplifiedGeometry::getDetLayer") << " index out of range for detLayerName: " << detLayerName << " " << error.what() << std::endl;
288  }
289 }
std::map< std::string, const std::vector< BarrelDetLayer const * > * > barrelDetLayersMap_
A map of strings and pointers to detLayers.
std::map< std::string, const std::vector< ForwardDetLayer const * > * > forwardDetLayersMap_
A map of strings and pointers to detLayers.

Member Data Documentation

std::map<std::string, const std::vector<BarrelDetLayer const *> *> fastsim::SimplifiedGeometryFactory::barrelDetLayersMap_
private

A map of strings and pointers to detLayers.

Definition at line 104 of file SimplifiedGeometryFactory.h.

Referenced by getDetLayer(), and SimplifiedGeometryFactory().

std::map<std::string, const std::vector<ForwardDetLayer const *> *> fastsim::SimplifiedGeometryFactory::forwardDetLayersMap_
private

A map of strings and pointers to detLayers.

Definition at line 105 of file SimplifiedGeometryFactory.h.

Referenced by getDetLayer(), and SimplifiedGeometryFactory().

const GeometricSearchTracker* const fastsim::SimplifiedGeometryFactory::geometricSearchTracker_
private

The full tracker geometry.

Definition at line 99 of file SimplifiedGeometryFactory.h.

Referenced by createSimplifiedGeometry(), and SimplifiedGeometryFactory().

const std::map<std::string,fastsim::InteractionModel *>* fastsim::SimplifiedGeometryFactory::interactionModelMap_
private

Map of interaction models.

Definition at line 101 of file SimplifiedGeometryFactory.h.

Referenced by createSimplifiedGeometry().

const MagneticField* const fastsim::SimplifiedGeometryFactory::magneticField_
private

The full magnetic field.

Definition at line 100 of file SimplifiedGeometryFactory.h.

Referenced by createSimplifiedGeometry().

const double fastsim::SimplifiedGeometryFactory::magneticFieldHistMaxR_
private

Limit in R for histogram of magnetic field.

Definition at line 102 of file SimplifiedGeometryFactory.h.

Referenced by createSimplifiedGeometry().

const double fastsim::SimplifiedGeometryFactory::magneticFieldHistMaxZ_
private

Limit in +-Z for histogram of magnetic field.

Definition at line 103 of file SimplifiedGeometryFactory.h.

Referenced by createSimplifiedGeometry().