48 #include "CLHEP/Geometry/Point3D.h" 49 #include "CLHEP/Geometry/Transform3D.h" 50 #include "CLHEP/Geometry/Vector3D.h" 51 #include "CLHEP/Units/GlobalSystemOfUnits.h" 52 #include "CLHEP/Units/GlobalPhysicalConstants.h" 66 cell=cell2=sector=sector2=
type=layer=0;
69 int cell, cell2, sector, sector2,
type, layer;
88 void fillHitsInfo(std::pair<hitsinfo,energysum> hit_,
unsigned int itimeslice,
double esum);
115 times_(iConfig.getParameter<
std::vector<double> >(
"TimeSlices")),
116 verbosity_(iConfig.getUntrackedParameter<
int>(
"Verbosity",0)),
128 std::vector<double>
times = {25.0,1000.0};
131 desc.
add<std::vector<double> >(
"TimeSlices",
times);
134 descriptions.
add(
"hgcalSimHitValidationEE",desc);
149 for (HepMC::GenEvent::particle_const_iterator
p = myGenEvent->particles_begin();
150 p != myGenEvent->particles_end(); ++
p, ++
k) {
152 << (*p)->momentum().perp()
154 << (*p)->momentum().eta()
156 << (*p)->momentum().phi();
164 if (theCaloHitContainers.
isValid()) {
167 << theCaloHitContainers->size();
168 std::vector<PCaloHit> caloHits;
169 caloHits.insert(caloHits.end(), theCaloHitContainers->begin(),
170 theCaloHitContainers->end());
172 for (
unsigned int i=0;
i<caloHits.size(); ++
i) {
173 unsigned int id_ = caloHits[
i].
id();
177 caloHits[
i].setID(hid.
rawId());
190 std::map<int, int> OccupancyMap_plus, OccupancyMap_minus;
191 OccupancyMap_plus.clear(); OccupancyMap_minus.clear();
193 std::map<uint32_t,std::pair<hitsinfo,energysum> > map_hits;
198 << hits.size() <<
" PcaloHit elements";
199 unsigned int nused(0);
200 for (
unsigned int i=0;
i<hits.size();
i++) {
201 double energy = hits[
i].energy();
202 double time = hits[
i].time();
203 uint32_t id_ = hits[
i].id();
204 int cell, sector, subsector(0), layer,
zside;
205 int subdet(0), cell2(0),
type(0);
209 if (subdet != static_cast<int>(
HcalEndcap))
continue;
211 sector = detId.
iphi();
213 layer = detId.
depth();
214 zside = detId.
zside();
219 cell = detId.
cellU();
220 cell2 = detId.
cellV();
222 subsector = detId.
waferV();
224 layer = detId.
layer();
225 zside = detId.
zside();
235 layer = detId.
layer();
236 zside = detId.
zside();
243 <<
" zside = " << zside
244 <<
" sector|wafer = " << sector
246 <<
" type = " << type
247 <<
" layer = " << layer
248 <<
" cell = " << cell
250 <<
" energy = " << energy
251 <<
" energyem = " << hits[
i].energyEM()
252 <<
" energyhad = " << hits[
i].energyHad()
253 <<
" time = " <<
time;
255 HepGeom::Point3D<float> gcoord;
259 double rz =
hcons_->
getRZ(subdet,zside*cell,layer);
262 << zside <<
":" << cell <<
":" 263 << sector <<
":" << layer <<
" o/p " 264 << etaphi.first <<
":" 265 << etaphi.second <<
":" << rz;
266 gcoord = HepGeom::Point3D<float>(rz*
cos(etaphi.second)/cosh(etaphi.first),
267 rz*
sin(etaphi.second)/cosh(etaphi.first),
268 rz*tanh(etaphi.first));
271 const HepGeom::Point3D<float> lcoord(xy.first,xy.second,0);
272 int subs = (
symmDet_ ? 0 : subsector);
276 std::pair<float,float>
xy;
286 if (zside < 0) zp = -zp;
287 float xp = (zp < 0) ? -xy.first : xy.first;
288 gcoord = HepGeom::Point3D<float>(xp,xy.second,zp);
290 double tof = (gcoord.mag()*CLHEP::mm)/CLHEP::c_light;
293 <<
" global coordinate " << gcoord
294 <<
" time " << time <<
":" << tof;
299 if (map_hits.count(id_) != 0) {
300 hinfo = map_hits[id_].first;
301 esum = map_hits[id_].second;
303 hinfo.
x = gcoord.x();
304 hinfo.
y = gcoord.y();
305 hinfo.
z = gcoord.z();
312 hinfo.
phi = gcoord.getPhi();
313 hinfo.
eta = gcoord.getEta();
322 << hinfo.
x <<
" gy = " << hinfo.
y 323 <<
" gz = " << hinfo.
z <<
" phi = " 324 << hinfo.
phi <<
" eta = " 326 map_hits[id_] = std::pair<hitsinfo,energysum>(hinfo,esum);
331 <<
" detector elements being hit";
333 std::map<uint32_t,std::pair<hitsinfo,energysum> >::iterator itr;
334 for (itr = map_hits.begin() ; itr != map_hits.end(); ++itr) {
337 int layer = hinfo.
layer;
340 for (
unsigned int itimeslice = 0; itimeslice <
nTimes_; itimeslice++ ) {
349 << hits.size() <<
"|" << nused <<
"|" 350 << map_hits.size() <<
" hits";
352 for (
auto const & itr : OccupancyMap_plus) {
353 int layer = itr.first;
354 int occupancy = itr.second;
357 for (
auto const & itr : OccupancyMap_minus) {
358 int layer = itr.first;
359 int occupancy = itr.second;
366 if (OccupancyMap.find(layer) != OccupancyMap.end()) {
367 ++OccupancyMap[layer];
369 OccupancyMap[layer] = 1;
374 unsigned int itimeslice,
double esum){
376 unsigned int ilayer = hits.first.layer;
378 energy_[itimeslice].at(ilayer)->Fill(esum);
380 EtaPhi_Plus_.at(ilayer) ->Fill(hits.first.eta , hits.first.phi);
381 EtaPhi_Minus_.at(ilayer)->Fill(hits.first.eta , hits.first.phi);
387 << hits.first.sector <<
":" 388 << hits.first.sector2 <<
" layer " 389 << hits.first.layer <<
" cell " 390 << hits.first.cell <<
":" 391 << hits.first.cell2 <<
" energy " 392 << hits.second.etotal;
413 int isd = (name.find(
nameDetector_) == std::string::npos) ? -1 : 1;
416 int nsiz = (
int)(copy.size());
417 int lay = (nsiz > 0) ? copy[nsiz-1] : -1;
418 int sec = (nsiz > 1) ? copy[nsiz-2] : -1;
419 int zp = (nsiz > 3) ? copy[nsiz-4] : -1;
420 if (zp !=1 ) zp = -1;
422 int subs = (trp.
alpha1()>0 ? 1 : 0);
426 fv.
rotation().GetComponents( x, y, z ) ;
427 const CLHEP::HepRep3x3
rotation ( x.X(), y.X(), z.X(),
429 x.Z(), y.Z(), z.Z() );
431 const CLHEP::Hep3Vector h3v ( fv.
translation().X(),
434 const HepGeom::Transform3D ht3d (hr, h3v);
435 transMap_.insert(std::make_pair(
id,ht3d));
438 <<
" Transform using " << h3v
445 <<
" elements and SymmDet_ = " 471 <<
layers_ <<
" Layers with first at " 481 std::ostringstream histoname;
482 for (
unsigned int il=0; il <
layers_; ++il) {
484 histoname.str(
""); histoname <<
"HitOccupancy_Plus_layer_" << ilayer;
486 histoname.str(
""); histoname <<
"HitOccupancy_Minus_layer_" << ilayer;
489 histoname.str(
""); histoname <<
"EtaPhi_Plus_" <<
"layer_" << ilayer;
491 histoname.str(
""); histoname <<
"EtaPhi_Minus_" <<
"layer_" << ilayer;
494 for (
unsigned int itimeslice = 0; itimeslice <
nTimes_ ; itimeslice++ ) {
495 histoname.str(
""); histoname <<
"energy_time_"<< itimeslice <<
"_layer_" << ilayer;
496 energy_[itimeslice].push_back(iB.
book1D(histoname.str().c_str(),
"energy_",100,0,0.1));
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
MonitorElement * MeanHitOccupancy_Plus_
const DDLogicalPart & logicalPart() const
The logical-part of the current node in the filtered-view.
void fillOccupancyMap(std::map< int, int > &OccupancyMap, int layer)
std::pair< double, double > getEtaPhi(const int &subdet, const int &ieta, const int &iphi) const
HcalSubdetector subdet() const
get the subdetector
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
std::vector< MonitorElement * > HitOccupancy_Plus_
void analyze(const edm::Event &, const edm::EventSetup &) override
bool getByToken(EDGetToken token, Handle< PROD > &result) const
nav_type copyNumbers() const
return the stack of copy numbers
int zside() const
get the z-side of the cell (1/-1)
edm::EDGetTokenT< edm::HepMCProduct > tok_hepMC_
const DDRotationMatrix & rotation() const
The absolute rotation of the current node.
Sin< T >::type sin(const T &t)
constexpr uint32_t rawId() const
get the raw id
int type() const
get the type
void analyzeHits(std::vector< PCaloHit > &hits)
int zside() const
get the z-side of the cell (1/-1)
std::vector< MonitorElement * > HitOccupancy_Minus_
const DDSolid & solid(void) const
Returns a reference object of the solid being the shape of this LogicalPart.
std::pair< float, float > locateCell(int cell, int lay, int type, bool reco) const
Compact representation of the geometrical detector hierarchy.
int cellU() const
get the cell #'s in u,v or in x,y
A DDSolid represents the shape of a part.
MonitorElement * MeanHitOccupancy_Minus_
bool defineGeometry(edm::ESTransientHandle< DDCompactView > &ddViewH)
int depth() const
get the tower depth
#define DEFINE_FWK_MODULE(type)
unsigned int layers(bool reco) const
void setCurrentFolder(std::string const &fullpath)
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DD3Vector
A DD Translation is currently implemented with Root Vector3D.
bool next()
set current node to the next node in the filtered tree
const HcalDDDRecConstants * hcons_
int type() const
get the type
int layer() const
get the layer #
std::pair< float, float > locateCellTrap(int lay, int ieta, int iphi, bool reco) const
double getRZ(const int &subdet, const int &ieta, const int &depth) const
Cos< T >::type cos(const T &t)
static const unsigned int maxTime_
void dqmBeginRun(const edm::Run &, const edm::EventSetup &) override
int ieta() const
get the cell ieta
const std::string fullname() const
MonitorElement * book1D(Args &&...args)
Interface to a Trapezoid.
std::pair< T, T > etaphi(T x, T y, T z)
~HGCalSimHitValidation() override
int iphi() const
get the phi index
HGCalGeometryMode::GeometryMode geomMode() const
std::vector< MonitorElement * > EtaPhi_Plus_
ParameterDescriptionBase * add(U const &iLabel, T const &value)
HGCalSimHitValidation(const edm::ParameterSet &)
double waferZ(int layer, bool reco) const
int ietaAbs() const
get the absolute value of the cell ieta
int iphi() const
get the cell iphi
const HepMC::GenEvent * GetEvent() const
MonitorElement * book2D(Args &&...args)
std::string nameDetector_
int getMaxDepth(const int &type) const
static void unpackSquareIndex(const uint32_t &idx, int &z, int &lay, int &sec, int &subsec, int &cell)
double alpha1(void) const
Angle with respect to the y axis from the centre of the side at y=-pDy1 to the centre at y=+pDy1 of t...
edm::EDGetTokenT< edm::PCaloHitContainer > tok_hits_
void add(std::string const &label, ParameterSetDescription const &psetDescription)
std::vector< MonitorElement * > energy_[maxTime_]
int layer() const
get the layer #
int zside() const
get the z-side of the cell (1/-1)
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
std::map< uint32_t, HepGeom::Transform3D > transMap_
bool firstChild()
set the current node to the first child ...
const HGCalDDDConstants * hgcons_
std::string caloHitSource_
std::vector< MonitorElement * > EtaPhi_Minus_
const DDTranslation & translation() const
The absolute translation of the current node.
DetId relabel(const uint32_t testId) const
static uint32_t packSquareIndex(int z, int lay, int sec, int subsec, int cell)
void fillHitsInfo(std::pair< hitsinfo, energysum > hit_, unsigned int itimeslice, double esum)
std::vector< double > times_
static void unpackHexagonIndex(const uint32_t &idx, int &subdet, int &z, int &lay, int &wafer, int &celltyp, int &cell)