CMS 3D CMS Logo

DDHGCalWaferP.cc
Go to the documentation of this file.
14 
15 #include <string>
16 #include <vector>
17 #include <sstream>
18 
19 //#define EDM_ML_DEBUG
20 
21 class DDHGCalWaferP : public DDAlgorithm {
22 public:
23  // Constructor and Destructor
24  DDHGCalWaferP();
25  ~DDHGCalWaferP() override;
26 
27  void initialize(const DDNumericArguments& nArgs,
28  const DDVectorArguments& vArgs,
29  const DDMapArguments& mArgs,
30  const DDStringArguments& sArgs,
31  const DDStringVectorArguments& vsArgs) override;
32  void execute(DDCompactView& cpv) override;
33 
34 private:
35  std::string material_; // Material name for module with gap
36  double thick_; // Module thickness
37  double waferSize_; // Wafer size
38  double waferSepar_; // Sensor separation
39  double waferThick_; // Wafer thickness
40  std::vector<std::string> tags_; // Tags to be added to each name
41  std::vector<int> partialTypes_; // Type of partial wafer
42  std::vector<int> orientations_; // Orientations of the wafers
43  std::vector<std::string> layerNames_; // Names of the layers
44  std::vector<std::string> materials_; // Materials of the layers
45  std::vector<double> layerThick_; // Thickness of layers
46  std::vector<int> layerType_; // Layer types
47  std::vector<int> layers_; // Number of layers in a section
48  std::string senseName_; // Name of the sensitive layer
49  double senseT_; // Thickness of sensitive layer
50  int senseType_; // Cell Type (0,1,2: Fine, Course 2/3)
51  int posSense_; // Position depleted layer
52  std::string nameSpace_; // Namespace to be used
53 };
54 
56 #ifdef EDM_ML_DEBUG
57  edm::LogVerbatim("HGCalGeom") << "DDHGCalWaferP: Creating an instance";
58 #endif
59 }
60 
62 
64  const DDVectorArguments& vArgs,
65  const DDMapArguments&,
66  const DDStringArguments& sArgs,
67  const DDStringVectorArguments& vsArgs) {
68  material_ = sArgs["ModuleMaterial"];
69  thick_ = nArgs["ModuleThickness"];
70  waferSize_ = nArgs["WaferSize"];
71  waferThick_ = nArgs["WaferThickness"];
72 #ifdef EDM_ML_DEBUG
73  waferSepar_ = nArgs["SensorSeparation"];
74  edm::LogVerbatim("HGCalGeom") << "DDHGCalWaferP: Module " << parent().name() << " made of " << material_ << " T "
75  << thick_ << " Wafer 2r " << waferSize_ << " Half Separation " << waferSepar_ << " T "
76  << waferThick_;
77 #endif
78  tags_ = vsArgs["Tags"];
79  partialTypes_ = dbl_to_int(vArgs["PartialTypes"]);
80  orientations_ = dbl_to_int(vArgs["Orientations"]);
81 #ifdef EDM_ML_DEBUG
82  edm::LogVerbatim("HGCalGeom") << "DDHGCalWaferP: " << tags_.size() << " variations of wafer types";
83  for (unsigned int k = 0; k < tags_.size(); ++k)
84  edm::LogVerbatim("HGCalGeom") << "Type[" << k << "] " << tags_[k] << " Partial " << partialTypes_[k]
85  << " Orientation " << orientations_[k];
86 #endif
87  layerNames_ = vsArgs["LayerNames"];
88  materials_ = vsArgs["LayerMaterials"];
89  layerThick_ = vArgs["LayerThickness"];
90  layerType_ = dbl_to_int(vArgs["LayerTypes"]);
91 #ifdef EDM_ML_DEBUG
92  edm::LogVerbatim("HGCalGeom") << "DDHGCalWaferP: " << layerNames_.size() << " types of volumes";
93  for (unsigned int i = 0; i < layerNames_.size(); ++i)
94  edm::LogVerbatim("HGCalGeom") << "Volume [" << i << "] " << layerNames_[i] << " of thickness " << layerThick_[i]
95  << " filled with " << materials_[i] << " type " << layerType_[i];
96 #endif
97  layers_ = dbl_to_int(vArgs["Layers"]);
98 #ifdef EDM_ML_DEBUG
99  std::ostringstream st1;
100  for (unsigned int i = 0; i < layers_.size(); ++i)
101  st1 << " [" << i << "] " << layers_[i];
102  edm::LogVerbatim("HGCalGeom") << "There are " << layers_.size() << " blocks" << st1.str();
103 #endif
104  senseName_ = sArgs["SenseName"];
105  senseT_ = nArgs["SenseThick"];
106  senseType_ = static_cast<int>(nArgs["SenseType"]);
107  posSense_ = static_cast<int>(nArgs["PosSensitive"]);
109 #ifdef EDM_ML_DEBUG
110  edm::LogVerbatim("HGCalGeom") << "DDHGCalWaferP: NameSpace " << nameSpace_ << " Sensitive Layer Name " << senseName_
111  << " Thickness " << senseT_ << " Type " << senseType_ << " Position " << posSense_;
112 #endif
113 }
114 
116 #ifdef EDM_ML_DEBUG
117  edm::LogVerbatim("HGCalGeom") << "==>> Executing DDHGCalWaferP...";
118 #endif
119 
120  static constexpr double tol = 0.00001;
121  static const double sqrt3 = std::sqrt(3.0);
122  double r = 0.5 * waferSize_;
123  double R = 2.0 * r / sqrt3;
124  std::string parentName = parent().name().name();
125 
126  // Loop over all types
127  for (unsigned int k = 0; k < tags_.size(); ++k) {
128  // First the mother
129  std::string mother = parentName + tags_[k];
130  std::vector<std::pair<double, double> > wxy =
132  std::vector<double> xM, yM;
133  for (unsigned int i = 0; i < (wxy.size() - 1); ++i) {
134  xM.emplace_back(wxy[i].first);
135  yM.emplace_back(wxy[i].second);
136  }
137  std::vector<double> zw = {-0.5 * thick_, 0.5 * thick_};
138  std::vector<double> zx(2, 0), zy(2, 0), scale(2, 1.0);
139  DDSolid solid = DDSolidFactory::extrudedpolygon(mother, xM, yM, zw, zx, zy, scale);
141  DDMaterial matter(matName);
142  DDLogicalPart glogM = DDLogicalPart(solid.ddname(), matter, solid);
143 #ifdef EDM_ML_DEBUG
144  edm::LogVerbatim("HGCalGeom") << "DDHGCalWaferP: " << solid.name() << " extruded polygon made of " << matName
145  << " z|x|y|s (0) " << zw[0] << ":" << zx[0] << ":" << zy[0] << ":" << scale[0]
146  << " z|x|y|s (1) " << zw[1] << ":" << zx[1] << ":" << zy[1] << ":" << scale[1]
147  << " partial " << partialTypes_[k] << " orientation " << orientations_[k] << " and "
148  << xM.size() << " edges";
149  for (unsigned int j = 0; j < xM.size(); ++j)
150  edm::LogVerbatim("HGCalGeom") << "[" << j << "] " << xM[j] << ":" << yM[j];
151 #endif
152 
153  // Then the layers
154  wxy = HGCalWaferMask::waferXY(partialTypes_[k], orientations_[k], 1, r, R, 0.0, 0.0);
155  std::vector<double> xL, yL;
156  for (unsigned int i = 0; i < (wxy.size() - 1); ++i) {
157  xL.emplace_back(wxy[i].first);
158  yL.emplace_back(wxy[i].second);
159  }
160  std::vector<DDLogicalPart> glogs(materials_.size());
161  std::vector<int> copyNumber(materials_.size(), 1);
162  double zi(-0.5 * thick_), thickTot(0.0);
163  for (unsigned int l = 0; l < layers_.size(); l++) {
164  unsigned int i = layers_[l];
165 #ifdef EDM_ML_DEBUG
166  edm::LogVerbatim("HGCalGeom") << "DDHGCalWaferP:Layer " << l << ":" << i << " T " << layerThick_[i] << " Copy "
167  << copyNumber[i];
168 #endif
169  DDRotation rot;
170  if (copyNumber[i] == 1) {
171  if (layerType_[i] > 0) {
172  zw[0] = -0.5 * waferThick_;
173  zw[1] = 0.5 * waferThick_;
174  } else {
175  zw[0] = -0.5 * layerThick_[i];
176  zw[1] = 0.5 * layerThick_[i];
177  }
178  std::string lname = layerNames_[i] + tags_[k];
179  solid = DDSolidFactory::extrudedpolygon(lname, xL, yL, zw, zx, zy, scale);
181  DDMaterial matter(matN);
182  glogs[i] = DDLogicalPart(solid.ddname(), matter, solid);
183 #ifdef EDM_ML_DEBUG
184  edm::LogVerbatim("HGCalGeom") << "DDHGCalWaferP: " << solid.name() << " extruded polygon made of " << matN
185  << " z|x|y|s (0) " << zw[0] << ":" << zx[0] << ":" << zy[0] << ":" << scale[0]
186  << " z|x|y|s (1) " << zw[1] << ":" << zx[1] << ":" << zy[1] << ":" << scale[1]
187  << " partial " << partialTypes_[k] << " orientation " << orientations_[k]
188  << " and " << xL.size() << " edges";
189  for (unsigned int j = 0; j < xL.size(); ++j)
190  edm::LogVerbatim("HGCalGeom") << "[" << j << "] " << xL[j] << ":" << yL[j];
191 #endif
192  if (layerType_[i] > 0) {
193  std::string sname = senseName_ + tags_[k];
194  zw[0] = -0.5 * senseT_;
195  zw[1] = 0.5 * senseT_;
196  solid = DDSolidFactory::extrudedpolygon(sname, xL, yL, zw, zx, zy, scale);
197  DDLogicalPart glog = DDLogicalPart(solid.ddname(), matter, solid);
198 #ifdef EDM_ML_DEBUG
199  edm::LogVerbatim("HGCalGeom") << "DDHGCalWaferP: " << solid.name() << " extruded polygon made of " << matN
200  << " z|x|y|s (0) " << zw[0] << ":" << zx[0] << ":" << zy[0] << ":" << scale[0]
201  << " z|x|y|s (1) " << zw[1] << ":" << zx[1] << ":" << zy[1] << ":" << scale[1]
202  << " partial " << partialTypes_[k] << " orientation " << orientations_[k]
203  << " and " << xL.size() << " edges";
204  for (unsigned int j = 0; j < xL.size(); ++j)
205  edm::LogVerbatim("HGCalGeom") << "[" << j << "] " << xL[j] << ":" << yL[j];
206 #endif
207  double zpos = (posSense_ == 0) ? -0.5 * (waferThick_ - senseT_) : 0.5 * (waferThick_ - senseT_);
208  DDTranslation tran(0, 0, zpos);
209  int copy = 10 + senseType_;
210  cpv.position(glog, glogs[i], copy, tran, rot);
211 #ifdef EDM_ML_DEBUG
212  edm::LogVerbatim("HGCalGeom") << "DDHGCalWaferP: " << glog.name() << " number " << copy << " positioned in "
213  << glogs[i].name() << " at " << tran << " with no rotation";
214 #endif
215  }
216  }
217  DDTranslation tran0(0, 0, (zi + 0.5 * layerThick_[i]));
218  cpv.position(glogs[i], glogM, copyNumber[i], tran0, rot);
219 #ifdef EDM_ML_DEBUG
220  edm::LogVerbatim("HGCalGeom") << "DDHGCalWaferP: " << glogs[i].name() << " number " << copyNumber[i]
221  << " positioned in " << glogM.name() << " at " << tran0 << " with no rotation";
222 #endif
223  ++copyNumber[i];
224  zi += layerThick_[i];
225  thickTot += layerThick_[i];
226  }
227  if (std::abs(thickTot - thick_) >= tol) {
228  if (thickTot > thick_) {
229  edm::LogError("HGCalGeom") << "Thickness of the partition " << thick_ << " is smaller than " << thickTot
230  << ": thickness of all its components **** ERROR ****";
231  } else {
232  edm::LogWarning("HGCalGeom") << "Thickness of the partition " << thick_ << " does not match with " << thickTot
233  << " of the components";
234  }
235  }
236  }
237 }
238 
239 DEFINE_EDM_PLUGIN(DDAlgorithmFactory, DDHGCalWaferP, "hgcal:DDHGCalWaferP");
PluginFactory.h
DDCurrentNamespace.h
mps_fire.i
i
Definition: mps_fire.py:428
MessageLogger.h
DDHGCalWaferP::materials_
std::vector< std::string > materials_
Definition: DDHGCalWaferP.cc:44
L1EGammaCrystalsEmulatorProducer_cfi.scale
scale
Definition: L1EGammaCrystalsEmulatorProducer_cfi.py:10
filterCSVwithJSON.copy
copy
Definition: filterCSVwithJSON.py:36
DDName
DDName is used to identify DDD entities uniquely.
Definition: DDName.h:17
HGCalWaferMask.h
HGCalWaferMask::waferXY
static std::vector< std::pair< double, double > > waferXY(int part, int orient, int zside, double delX, double delY, double xpos, double ypos)
Definition: HGCalWaferMask.cc:1003
DDSplit.h
DDHGCalWaferP::~DDHGCalWaferP
~DDHGCalWaferP() override
Definition: DDHGCalWaferP.cc:61
edm::second
U second(std::pair< T, U > const &p)
Definition: ParameterSet.cc:222
DDHGCalWaferP::senseName_
std::string senseName_
Definition: DDHGCalWaferP.cc:48
DDHGCalWaferP::DDHGCalWaferP
DDHGCalWaferP()
Definition: DDHGCalWaferP.cc:55
DDHGCalWaferP::waferSize_
double waferSize_
Definition: DDHGCalWaferP.cc:37
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
DDHGCalWaferP::posSense_
int posSense_
Definition: DDHGCalWaferP.cc:51
DDHGCalWaferP::waferThick_
double waferThick_
Definition: DDHGCalWaferP.cc:39
DDMaterial
DDMaterial is used to define and access material information.
Definition: DDMaterial.h:45
DDTranslation
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DDTranslation
Definition: DDTranslation.h:7
DDHGCalWaferP::orientations_
std::vector< int > orientations_
Definition: DDHGCalWaferP.cc:42
DDHGCalWaferP::layerNames_
std::vector< std::string > layerNames_
Definition: DDHGCalWaferP.cc:43
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
DDCompactView
Compact representation of the geometrical detector hierarchy.
Definition: DDCompactView.h:81
DDBase::name
const N & name() const
Definition: DDBase.h:59
DDSolid.h
dqmdumpme.k
k
Definition: dqmdumpme.py:60
DEFINE_EDM_PLUGIN
#define DEFINE_EDM_PLUGIN(factory, type, name)
Definition: PluginFactory.h:124
first
auto first
Definition: CAHitNtupletGeneratorKernelsImpl.h:125
DDHGCalWaferP::tags_
std::vector< std::string > tags_
Definition: DDHGCalWaferP.cc:40
DDHGCalWaferP::layers_
std::vector< int > layers_
Definition: DDHGCalWaferP.cc:47
DDHGCalWaferP
Definition: DDHGCalWaferP.cc:21
DDutils.h
DDSolidFactory::extrudedpolygon
static DDSolid extrudedpolygon(const DDName &name, const std::vector< double > &x, const std::vector< double > &y, const std::vector< double > &z, const std::vector< double > &zx, const std::vector< double > &zy, const std::vector< double > &zscale)
Definition: DDSolid.cc:584
DDHGCalWaferP::layerType_
std::vector< int > layerType_
Definition: DDHGCalWaferP.cc:46
DDBase::ddname
const N & ddname() const
Definition: DDBase.h:61
DDHGCalWaferP::waferSepar_
double waferSepar_
Definition: DDHGCalWaferP.cc:38
edmplugin::PluginFactory
Definition: PluginFactory.h:34
DDHGCalWaferP::senseType_
int senseType_
Definition: DDHGCalWaferP.cc:50
DDLogicalPart
A DDLogicalPart aggregates information concerning material, solid and sensitveness ....
Definition: DDLogicalPart.h:93
DDTypes.h
DDMaterial.h
DDHGCalWaferP::thick_
double thick_
Definition: DDHGCalWaferP.cc:36
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
DDLogicalPart.h
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
cmsLHEtoEOSManager.l
l
Definition: cmsLHEtoEOSManager.py:204
alignCSCRings.r
r
Definition: alignCSCRings.py:93
DDHGCalWaferP::initialize
void initialize(const DDNumericArguments &nArgs, const DDVectorArguments &vArgs, const DDMapArguments &mArgs, const DDStringArguments &sArgs, const DDStringVectorArguments &vsArgs) override
Definition: DDHGCalWaferP.cc:63
ReadMapType< double >
DDAlgorithm.h
DDHGCalWaferP::nameSpace_
std::string nameSpace_
Definition: DDHGCalWaferP.cc:52
DDHGCalWaferP::execute
void execute(DDCompactView &cpv) override
Definition: DDHGCalWaferP.cc:115
edm::LogVerbatim
Log< level::Info, true > LogVerbatim
Definition: MessageLogger.h:128
DDCurrentNamespace::ns
static std::string & ns()
Definition: DDCurrentNamespace.cc:3
DDHGCalWaferP::partialTypes_
std::vector< int > partialTypes_
Definition: DDHGCalWaferP.cc:41
DDHGCalWaferP::layerThick_
std::vector< double > layerThick_
Definition: DDHGCalWaferP.cc:45
makeMuonMisalignmentScenario.rot
rot
Definition: makeMuonMisalignmentScenario.py:322
DDSolid
A DDSolid represents the shape of a part.
Definition: DDSolid.h:39
DDRotation
Represents a uniquely identifyable rotation matrix.
Definition: DDTransform.h:57
DDHGCalWaferP::material_
std::string material_
Definition: DDHGCalWaferP.cc:35
zw
auto zw(V v) -> Vec2< typename std::remove_reference< decltype(v[0])>::type >
Definition: ExtVec.h:75
DDHGCalWaferP::senseT_
double senseT_
Definition: DDHGCalWaferP.cc:49
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
dbl_to_int
std::vector< int > dbl_to_int(const std::vector< double > &vecdbl)
Converts a std::vector of doubles to a std::vector of int.
Definition: DDutils.h:7
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
HGCalTypes.h
DDAlgorithmFactory.h
edm::Log
Definition: MessageLogger.h:70
dttmaxenums::R
Definition: DTTMax.h:29
class-composition.parent
parent
Definition: class-composition.py:98
DDSplit
std::pair< std::string, std::string > DDSplit(const std::string &n)
split into (name,namespace), separator = ':'
Definition: DDSplit.cc:3
DDCompactView::position
void position(const DDLogicalPart &self, const DDLogicalPart &parent, const std::string &copyno, const DDTranslation &trans, const DDRotation &rot, const DDDivision *div=nullptr)
Definition: DDCompactView.cc:76