CMS 3D CMS Logo

DDAHcalModuleAlgo.cc
Go to the documentation of this file.
1 // File: DDAHcalModuleAlgo.cc
3 // Description: Geometry factory class for HGCal (EE and HESil)
5 
6 #include <algorithm>
7 #include <cmath>
8 #include <string>
9 #include <vector>
10 
23 
24 //#define EDM_ML_DEBUG
25 
26 class DDAHcalModuleAlgo : public DDAlgorithm {
27 public:
28  // Constructor and Destructor
29  DDAHcalModuleAlgo(); // const std::string & name);
30 
31  void initialize(const DDNumericArguments& nArgs,
32  const DDVectorArguments& vArgs,
33  const DDMapArguments& mArgs,
34  const DDStringArguments& sArgs,
35  const DDStringVectorArguments& vsArgs) override;
36  void execute(DDCompactView& cpv) override;
37 
38 protected:
39  void constructLayers(const DDLogicalPart&, DDCompactView& cpv);
41 
42 private:
43  static constexpr double tol_ = 0.00001;
44 
45  std::string tile_; // Scintillator tile
46  std::vector<std::string> materials_; // Materials
47  std::vector<std::string> names_; // Names
48  std::vector<double> thick_; // Thickness of the material
49  std::vector<int> copyNumber_; // Initial copy numbers
50  std::vector<int> layers_; // Number of layers in a section
51  std::vector<double> layerThick_; // Thickness of each section
52  std::vector<int> layerType_; // Type of the layer
53  std::vector<int> layerSense_; // Content of a layer (sensitive?)
54  std::vector<double> widths_; // Width (passive, active)
55  std::vector<double> heights_; // Heights (passive, active)
56  std::vector<int> tileN_; // # of tiles (along x, y)
57  std::vector<double> tileStep_; // Separation between tiles (x, y)
58  double zMinBlock_; // Starting z-value of the block
59  std::string idNameSpace_; // Namespace of this and ALL sub-parts
60 };
61 
63 #ifdef EDM_ML_DEBUG
64  edm::LogVerbatim("HGCalGeom") << "DDAHcalModuleAlgo: Creating an instance";
65 #endif
66 }
67 
69  const DDVectorArguments& vArgs,
70  const DDMapArguments&,
71  const DDStringArguments& sArgs,
72  const DDStringVectorArguments& vsArgs) {
73  tile_ = sArgs["TileName"];
74 #ifdef EDM_ML_DEBUG
75  edm::LogVerbatim("HGCalGeom") << "DDAHcalModuleAlgo: Tile " << tile_;
76 #endif
77  materials_ = vsArgs["MaterialNames"];
78  names_ = vsArgs["VolumeNames"];
79  thick_ = vArgs["Thickness"];
80  copyNumber_.resize(materials_.size(), 1);
81 #ifdef EDM_ML_DEBUG
82  edm::LogVerbatim("HGCalGeom") << "DDAHcalModuleAlgo: " << materials_.size() << " types of volumes";
83  for (unsigned int i = 0; i < names_.size(); ++i)
84  edm::LogVerbatim("HGCalGeom") << "Volume [" << i << "] " << names_[i] << " of thickness " << thick_[i]
85  << " filled with " << materials_[i] << " first copy number " << copyNumber_[i];
86 #endif
87  layers_ = dbl_to_int(vArgs["Layers"]);
88  layerThick_ = vArgs["LayerThick"];
89 #ifdef EDM_ML_DEBUG
90  edm::LogVerbatim("HGCalGeom") << "DDAHcalModuleAlgo: " << layers_.size() << " blocks";
91  for (unsigned int i = 0; i < layers_.size(); ++i)
92  edm::LogVerbatim("HGCalGeom") << "Block [" << i << "] of thickness " << layerThick_[i] << " with " << layers_[i]
93  << " layers";
94 #endif
95  layerType_ = dbl_to_int(vArgs["LayerType"]);
96  layerSense_ = dbl_to_int(vArgs["LayerSense"]);
97 #ifdef EDM_ML_DEBUG
98  edm::LogVerbatim("HGCalGeom") << "DDAHcalModuleAlgo: " << layerType_.size() << " layers";
99  for (unsigned int i = 0; i < layerType_.size(); ++i)
100  edm::LogVerbatim("HGCalGeom") << "Layer [" << i << "] with material type " << layerType_[i] << " sensitive class "
101  << layerSense_[i];
102 #endif
103  widths_ = vArgs["Widths"];
104  heights_ = vArgs["Heights"];
105 #ifdef EDM_ML_DEBUG
106  edm::LogVerbatim("HGCalGeom") << "DDAHcalModuleAlgo: " << widths_.size() << " sizes for width "
107  << "and height:";
108  for (unsigned int i = 0; i < widths_.size(); ++i)
109  edm::LogVerbatim("HGCalGeom") << " [" << i << "] " << widths_[i] << ":" << heights_[i];
110 #endif
111  tileN_ = dbl_to_int(vArgs["TileN"]);
112  tileStep_ = vArgs["TileStep"];
113 #ifdef EDM_ML_DEBUG
114  edm::LogVerbatim("HGCalGeom") << "DDAHcalModuleAlgo: " << tileN_.size() << " tile positioning parameters";
115  for (unsigned int i = 0; i < tileN_.size(); ++i)
116  edm::LogVerbatim("HGCalGeom") << " [" << i << "] " << tileN_[i] << ":" << tileStep_[i];
117 #endif
118  zMinBlock_ = nArgs["zMinBlock"];
120 #ifdef EDM_ML_DEBUG
121  edm::LogVerbatim("HGCalGeom") << "DDHGCalModule: zStart " << zMinBlock_ << " NameSpace " << idNameSpace_;
122 #endif
123 }
124 
126 // DDAHcalModuleAlgo methods...
128 
130 #ifdef EDM_ML_DEBUG
131  edm::LogVerbatim("HGCalGeom") << "==>> Constructing DDAHcalModuleAlgo...";
132 #endif
133  constructLayers(parent(), cpv);
134 #ifdef EDM_ML_DEBUG
135  edm::LogVerbatim("HGCalGeom") << "<<== End of DDAHcalModuleAlgo construction";
136 #endif
137 }
138 
140 #ifdef EDM_ML_DEBUG
141  edm::LogVerbatim("HGCalGeom") << "DDAHcalModuleAlgo test: \t\tInside Layers";
142 #endif
143  double zi(zMinBlock_);
144  int laymin(0);
145  for (unsigned int i = 0; i < layers_.size(); i++) {
146  double zo = zi + layerThick_[i];
147  int laymax = laymin + layers_[i];
148  double zz = zi;
149  double thickTot(0);
150  for (int ly = laymin; ly < laymax; ++ly) {
151  int ii = layerType_[ly];
152  int copy = copyNumber_[ii];
153  zz += (0.5 * thick_[ii]);
154  thickTot += thick_[ii];
155 
156  std::string name = "HGCal" + names_[ii] + std::to_string(copy);
157 #ifdef EDM_ML_DEBUG
158  edm::LogVerbatim("HGCalGeom") << "DDAHcalModuleAlgo test: Layer " << ly << ":" << ii << " Front " << zi
159  << " Back " << zo << " superlayer thickness " << layerThick_[i];
160 #endif
162  DDMaterial matter(matName);
163  DDLogicalPart glog;
164  if (layerSense_[ly] == 0) {
165  DDSolid solid =
166  DDSolidFactory::box(DDName(name, idNameSpace_), 0.5 * widths_[0], 0.5 * heights_[0], 0.5 * thick_[ii]);
167  glog = DDLogicalPart(solid.ddname(), matter, solid);
168 #ifdef EDM_ML_DEBUG
169  edm::LogVerbatim("HGCalGeom") << "DDAHcalModuleAlgo: " << solid.name() << " Box made of " << matName
170  << " of dimensions " << 0.5 * widths_[0] << ", " << 0.5 * heights_[0] << ", "
171  << 0.5 * thick_[ii];
172 #endif
173  } else {
174  DDSolid solid =
175  DDSolidFactory::box(DDName(name, idNameSpace_), 0.5 * widths_[1], 0.5 * heights_[1], 0.5 * thick_[ii]);
176  glog = DDLogicalPart(solid.ddname(), matter, solid);
177 #ifdef EDM_ML_DEBUG
178  edm::LogVerbatim("HGCalGeom") << "DDAHcalModuleAlgo: " << solid.name() << " Box made of " << matName
179  << " of dimensions " << 0.5 * widths_[1] << ", " << 0.5 * heights_[1] << ", "
180  << 0.5 * thick_[ii];
181 #endif
182  positionSensitive(glog, cpv);
183  }
184  DDTranslation r1(0, 0, zz);
185  DDRotation rot;
186  cpv.position(glog, module, copy, r1, rot);
187  ++copyNumber_[ii];
188 #ifdef EDM_ML_DEBUG
189  edm::LogVerbatim("HGCalGeom") << "DDAHcalModuleAlgo: " << glog.name() << " number " << copy << " positioned in "
190  << module.name() << " at " << r1 << " with " << rot;
191 #endif
192  zz += (0.5 * thick_[ii]);
193  } // End of loop over layers in a block
194  zi = zo;
195  laymin = laymax;
196  if (fabs(thickTot - layerThick_[i]) > tol_) {
197  if (thickTot > layerThick_[i]) {
198  edm::LogError("HGCalGeom") << "Thickness of the partition " << layerThick_[i] << " is smaller than thickness "
199  << thickTot << " of all its components **** ERROR ****\n";
200  } else {
201  edm::LogWarning("HGCalGeom") << "Thickness of the partition " << layerThick_[i] << " does not match with "
202  << thickTot << " of the components\n";
203  }
204  }
205  } // End of loop over blocks
206 }
207 
209  int ncol = tileN_[0] / 2;
210  int nrow = tileN_[1] / 2;
211 #ifdef EDM_ML_DEBUG
212  int kount(0);
213  edm::LogVerbatim("HGCalGeom") << glog.ddname() << " Row " << nrow << " Column " << ncol;
214 #endif
215  for (int nr = -nrow; nr <= nrow; ++nr) {
216  int inr = (nr >= 0) ? nr : -nr;
217  double ypos = (nr >= 0) ? (inr - 0.5) * tileStep_[1] : -(inr - 0.5) * tileStep_[1];
218  for (int nc = -ncol; nc <= ncol; ++nc) {
219  int inc = (nc >= 0) ? nc : -nc;
220  double xpos = (nc >= 0) ? (inc - 0.5) * tileStep_[0] : -(inc - 0.5) * tileStep_[0];
221  if (nr != 0 && nc != 0) {
222  DDTranslation tran(xpos, ypos, 0.0);
224  int copy = inr * AHCalParameters::kColumn_ + inc;
225  if (nc < 0)
227  if (nr < 0)
230  cpv.position(name, glog.ddname(), copy, tran, rotation);
231 #ifdef EDM_ML_DEBUG
232  kount++;
233  edm::LogVerbatim("HGCalGeom") << "DDAHcalModuleAlgo: " << name << " number " << copy << " positioned in "
234  << glog.ddname() << " at " << tran << " with " << rotation;
235 #endif
236  }
237  }
238  }
239 #ifdef EDM_ML_DEBUG
240  edm::LogVerbatim("HGCalGeom") << "DDAHcalModuleAlgo: " << kount << " tiles for " << glog.ddname();
241 #endif
242 }
243 
244 DEFINE_EDM_PLUGIN(DDAlgorithmFactory, DDAHcalModuleAlgo, "hgcal:DDAHcalModuleAlgo");
PluginFactory.h
DDAHcalModuleAlgo::execute
void execute(DDCompactView &cpv) override
Definition: DDAHcalModuleAlgo.cc:129
DDCurrentNamespace.h
mps_fire.i
i
Definition: mps_fire.py:428
geometryCSVtoXML.zz
zz
Definition: geometryCSVtoXML.py:19
DDAHcalModuleAlgo::names_
std::vector< std::string > names_
Definition: DDAHcalModuleAlgo.cc:47
MessageLogger.h
DDAHcalModuleAlgo::thick_
std::vector< double > thick_
Definition: DDAHcalModuleAlgo.cc:48
filterCSVwithJSON.copy
copy
Definition: filterCSVwithJSON.py:36
DDName
DDName is used to identify DDD entities uniquely.
Definition: DDName.h:15
DDAHcalModuleAlgo::positionSensitive
void positionSensitive(DDLogicalPart &glog, DDCompactView &cpv)
Definition: DDAHcalModuleAlgo.cc:208
DDAHcalModuleAlgo::layerType_
std::vector< int > layerType_
Definition: DDAHcalModuleAlgo.cc:52
DDSplit.h
edm::second
U second(std::pair< T, U > const &p)
Definition: ParameterSet.cc:222
DDAHcalModuleAlgo::initialize
void initialize(const DDNumericArguments &nArgs, const DDVectorArguments &vArgs, const DDMapArguments &mArgs, const DDStringArguments &sArgs, const DDStringVectorArguments &vsArgs) override
Definition: DDAHcalModuleAlgo.cc:68
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
dqmdumpme.first
first
Definition: dqmdumpme.py:55
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
DDAHcalModuleAlgo::zMinBlock_
double zMinBlock_
Definition: DDAHcalModuleAlgo.cc:58
DDAHcalModuleAlgo::tileStep_
std::vector< double > tileStep_
Definition: DDAHcalModuleAlgo.cc:57
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
DDCompactView
Compact representation of the geometrical detector hierarchy.
Definition: DDCompactView.h:81
DDBase::name
const N & name() const
Definition: DDBase.h:59
DDAHcalModuleAlgo::materials_
std::vector< std::string > materials_
Definition: DDAHcalModuleAlgo.cc:46
DDSolid.h
DDAHcalModuleAlgo::layers_
std::vector< int > layers_
Definition: DDAHcalModuleAlgo.cc:50
DDAHcalModuleAlgo::widths_
std::vector< double > widths_
Definition: DDAHcalModuleAlgo.cc:54
DEFINE_EDM_PLUGIN
#define DEFINE_EDM_PLUGIN(factory, type, name)
Definition: PluginFactory.h:124
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
AHCalParameters::kSignRowColumn_
static constexpr int kSignRowColumn_
Definition: AHCalParameters.h:31
idealTransformation.rotation
dictionary rotation
Definition: idealTransformation.py:1
EgHLTOffHistBins_cfi.nr
nr
Definition: EgHLTOffHistBins_cfi.py:4
DDBase::ddname
const N & ddname() const
Definition: DDBase.h:61
DDAHcalModuleAlgo
Definition: DDAHcalModuleAlgo.cc:26
edmplugin::PluginFactory
Definition: PluginFactory.h:34
DDLogicalPart
A DDLogicalPart aggregates information concerning material, solid and sensitveness ....
Definition: DDLogicalPart.h:93
DDTypes.h
DDMaterial.h
DDutils.h
DDAHcalModuleAlgo::DDAHcalModuleAlgo
DDAHcalModuleAlgo()
Definition: DDAHcalModuleAlgo.cc:62
DDAHcalModuleAlgo::layerSense_
std::vector< int > layerSense_
Definition: DDAHcalModuleAlgo.cc:53
DDAHcalModuleAlgo::tile_
std::string tile_
Definition: DDAHcalModuleAlgo.cc:45
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
DDLogicalPart.h
AHCalParameters::kColumn_
static constexpr int kColumn_
Constants used.
Definition: AHCalParameters.h:27
DDAHcalModuleAlgo::tileN_
std::vector< int > tileN_
Definition: DDAHcalModuleAlgo.cc:56
ReadMapType< double >
DDAlgorithm.h
AHCalParameters.h
diffTwoXMLs.r1
r1
Definition: diffTwoXMLs.py:53
edm::LogVerbatim
Log< level::Info, true > LogVerbatim
Definition: MessageLogger.h:128
DDCurrentNamespace::ns
static std::string & ns()
Definition: DDCurrentNamespace.cc:3
DDAHcalModuleAlgo::idNameSpace_
std::string idNameSpace_
Definition: DDAHcalModuleAlgo.cc:59
makeMuonMisalignmentScenario.rot
rot
Definition: makeMuonMisalignmentScenario.py:322
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
DDSolid
A DDSolid represents the shape of a part.
Definition: DDSolid.h:39
DDRotation
Represents a uniquely identifyable rotation matrix.
Definition: DDTransform.h:57
DDAHcalModuleAlgo::heights_
std::vector< double > heights_
Definition: DDAHcalModuleAlgo.cc:55
DDAHcalModuleAlgo::constructLayers
void constructLayers(const DDLogicalPart &, DDCompactView &cpv)
Definition: DDAHcalModuleAlgo.cc:139
DDAHcalModuleAlgo::tol_
static constexpr double tol_
Definition: DDAHcalModuleAlgo.cc:43
DDAHcalModuleAlgo::copyNumber_
std::vector< int > copyNumber_
Definition: DDAHcalModuleAlgo.cc:49
DDSolidFactory::box
static DDSolid box(const DDName &name, double xHalf, double yHalf, double zHalf)
Creates a box with side length 2*xHalf, 2*yHalf, 2*zHalf.
Definition: DDSolid.cc:533
AHCalParameters::kRowColumn_
static constexpr int kRowColumn_
Definition: AHCalParameters.h:30
DDAlgorithmFactory.h
edm::Log
Definition: MessageLogger.h:70
class-composition.parent
parent
Definition: class-composition.py:88
DDAHcalModuleAlgo::layerThick_
std::vector< double > layerThick_
Definition: DDAHcalModuleAlgo.cc:51
cuy.ii
ii
Definition: cuy.py:590
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