46 #include "CLHEP/Geometry/Point3D.h" 47 #include "CLHEP/Geometry/Transform3D.h" 48 #include "CLHEP/Geometry/Vector3D.h" 49 #include "CLHEP/Units/GlobalSystemOfUnits.h" 50 #include "CLHEP/Units/GlobalPhysicalConstants.h" 86 void fillHitsInfo(std::pair<hitsinfo,energysum> hit_,
unsigned int itimeslice,
double esum);
111 times_(iConfig.getParameter<
std::vector<double> >(
"TimeSlices")),
112 verbosity_(iConfig.getUntrackedParameter<
int>(
"Verbosity",0)),
124 std::vector<double>
times = {25.0,1000.0};
127 desc.
add<std::vector<double> >(
"TimeSlices",
times);
130 descriptions.
add(
"hgcalSimHitValidationEE",desc);
142 const HepMC::GenEvent * myGenEvent = evtMC->
GetEvent();
144 for (HepMC::GenEvent::particle_const_iterator
p = myGenEvent->particles_begin();
145 p != myGenEvent->particles_end(); ++
p, ++
k) {
147 << (*p)->momentum().perp() <<
" eta " 148 << (*p)->momentum().eta() <<
" phi " 149 << (*p)->momentum().phi();
156 if (theCaloHitContainers.
isValid()) {
159 << theCaloHitContainers->size();
160 std::vector<PCaloHit> caloHits;
161 caloHits.insert(caloHits.end(), theCaloHitContainers->begin(),
162 theCaloHitContainers->end());
164 for (
unsigned int i=0;
i<caloHits.size(); ++
i) {
165 unsigned int id_ = caloHits[
i].
id();
168 caloHits[
i].setID(hid.
rawId());
181 std::map<int, int> OccupancyMap_plus, OccupancyMap_minus;
182 OccupancyMap_plus.clear(); OccupancyMap_minus.clear();
184 std::map<uint32_t,std::pair<hitsinfo,energysum> > map_hits;
189 << hits.size() <<
" PcaloHit elements";
190 unsigned int nused(0);
191 for (
unsigned int i=0;
i<hits.size();
i++) {
192 double energy = hits[
i].energy();
193 double time = hits[
i].time();
194 uint32_t id_ = hits[
i].id();
195 int cell, sector, subsector, layer,
zside;
200 if (subdet != static_cast<int>(
HcalEndcap))
continue;
202 sector = detId.
iphi();
204 layer = detId.
depth();
205 zside = detId.
zside();
216 <<
" zside = " << zside
217 <<
" sector|wafer = " << sector
218 <<
" subsector|type = " << subsector
219 <<
" layer = " << layer
220 <<
" cell = " << cell
221 <<
" energy = " << energy
222 <<
" energyem = " << hits[
i].energyEM()
223 <<
" energyhad = " << hits[
i].energyHad()
224 <<
" time = " <<
time;
226 HepGeom::Point3D<float> gcoord;
229 double rz =
hcons_->
getRZ(subdet,zside*cell,layer);
232 << zside <<
":" << cell <<
":" 233 << sector <<
":" << layer <<
" o/p " 234 << etaphi.first <<
":" 235 << etaphi.second <<
":" << rz;
236 gcoord = HepGeom::Point3D<float>(rz*
cos(etaphi.second)/cosh(etaphi.first),
237 rz*
sin(etaphi.second)/cosh(etaphi.first),
238 rz*tanh(etaphi.first));
242 const HepGeom::Point3D<float> lcoord(xy.first,xy.second,0);
243 int subs = (
symmDet_ ? 0 : subsector);
249 if (zside < 0) zp = -zp;
250 float xp = (zp < 0) ? -xy.first : xy.first;
251 gcoord = HepGeom::Point3D<float>(xp,xy.second,zp);
254 double tof = (gcoord.mag()*CLHEP::mm)/CLHEP::c_light;
257 <<
" global coordinate " << gcoord
258 <<
" time " << time <<
":" << tof;
263 if (map_hits.count(id_) != 0) {
264 hinfo = map_hits[id_].first;
265 esum = map_hits[id_].second;
267 hinfo.
x = gcoord.x();
268 hinfo.
y = gcoord.y();
269 hinfo.
z = gcoord.z();
273 hinfo.
phi = gcoord.getPhi();
274 hinfo.
eta = gcoord.getEta();
282 << hinfo.
x <<
" gy = " << hinfo.
y 283 <<
" gz = " << hinfo.
z <<
" phi = " 284 << hinfo.
phi <<
" eta = " << hinfo.
eta;
285 map_hits[id_] = std::pair<hitsinfo,energysum>(hinfo,esum);
290 <<
" detector elements being hit";
292 std::map<uint32_t,std::pair<hitsinfo,energysum> >::iterator itr;
293 for (itr = map_hits.begin() ; itr != map_hits.end(); ++itr) {
296 int layer = hinfo.
layer;
298 for (
unsigned int itimeslice = 0; itimeslice <
nTimes_; itimeslice++ ) {
307 edm::LogVerbatim(
"HGCalValidation") <<
"With map:used:total " << hits.size()
308 <<
"|" << nused <<
"|" << map_hits.size()
311 for (
auto itr = OccupancyMap_plus.begin() ; itr != OccupancyMap_plus.end(); ++itr) {
312 int layer = (*itr).first;
313 int occupancy = (*itr).second;
316 for (
auto itr = OccupancyMap_minus.begin() ; itr != OccupancyMap_minus.end(); ++itr) {
317 int layer = (*itr).first;
318 int occupancy = (*itr).second;
324 if (OccupancyMap.find(layer) != OccupancyMap.end()) {
325 OccupancyMap[layer] ++;
327 OccupancyMap[layer] = 1;
332 unsigned int itimeslice,
double esum){
334 unsigned int ilayer = hits.first.layer - 1;
336 energy_[itimeslice].at(ilayer)->Fill(esum);
338 EtaPhi_Plus_.at(ilayer)->Fill(hits.first.eta , hits.first.phi);
339 EtaPhi_Minus_.at(ilayer)->Fill(hits.first.eta , hits.first.phi);
345 << hits.first.sector <<
" layer " 346 << hits.first.layer <<
" cell " 347 << hits.first.cell <<
" energy " 348 << hits.second.etotal;
369 int isd = (name.find(
nameDetector_) == std::string::npos) ? -1 : 1;
372 int nsiz = (
int)(copy.size());
373 int lay = (nsiz > 0) ? copy[nsiz-1] : -1;
374 int sec = (nsiz > 1) ? copy[nsiz-2] : -1;
375 int zp = (nsiz > 3) ? copy[nsiz-4] : -1;
376 if (zp !=1 ) zp = -1;
378 int subs = (trp.
alpha1()>0 ? 1 : 0);
382 fv.
rotation().GetComponents( x, y, z ) ;
383 const CLHEP::HepRep3x3
rotation ( x.X(), y.X(), z.X(),
385 x.Z(), y.Z(), z.Z() );
387 const CLHEP::Hep3Vector h3v ( fv.
translation().X(),
390 const HepGeom::Transform3D ht3d (hr, h3v);
391 transMap_.insert(std::make_pair(
id,ht3d));
394 <<
" Transform using " << h3v
401 <<
" elements and SymmDet_ = " 435 std::ostringstream histoname;
436 for (
unsigned int ilayer = 0; ilayer <
layers_; ilayer++ ) {
437 histoname.str(
""); histoname <<
"HitOccupancy_Plus_layer_" << ilayer;
439 histoname.str(
""); histoname <<
"HitOccupancy_Minus_layer_" << ilayer;
442 histoname.str(
""); histoname <<
"EtaPhi_Plus_" <<
"layer_" << ilayer;
444 histoname.str(
""); histoname <<
"EtaPhi_Minus_" <<
"layer_" << ilayer;
447 for (
unsigned int itimeslice = 0; itimeslice <
nTimes_ ; itimeslice++ ) {
448 histoname.str(
""); histoname <<
"energy_time_"<< itimeslice <<
"_layer_" << ilayer;
449 energy_[itimeslice].push_back(iB.
book1D(histoname.str().c_str(),
"energy_",100,0,0.1));
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
MonitorElement * MeanHitOccupancy_Plus_
std::vector< MonitorElement * > energy_[6]
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)
#define DEFINE_FWK_MODULE(type)
edm::EDGetTokenT< edm::HepMCProduct > tok_hepMC_
const DDRotationMatrix & rotation() const
The absolute rotation of the current node.
Sin< T >::type sin(const T &t)
void analyzeHits(std::vector< PCaloHit > &hits)
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
type of data representation of DDCompactView
A DDSolid represents the shape of a part.
MonitorElement * MeanHitOccupancy_Minus_
uint32_t rawId() const
get the raw id
bool defineGeometry(edm::ESTransientHandle< DDCompactView > &ddViewH)
int depth() const
get the tower depth
unsigned int layers(bool reco) const
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_
double getRZ(const int &subdet, const int &ieta, const int &depth) const
Cos< T >::type cos(const T &t)
void dqmBeginRun(const edm::Run &, const edm::EventSetup &) override
int ieta() const
get the cell ieta
MonitorElement * book1D(Args &&...args)
Interface to a Trapezoid.
std::pair< T, T > etaphi(T x, T y, T z)
~HGCalSimHitValidation() override
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
void setCurrentFolder(const std::string &fullpath)
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)
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)