44 #include "TProfile2D.h"
116 std::cout <<
"HGCalTBAnalyzer:: SimHits = " << doSimHits_ <<
" Digis = "
117 << doDigis_ <<
":" << sampleIndex_ <<
" RecHits = " << doRecHits_
118 <<
" useDets " << ifEE_ <<
":" << ifHE_ << std::endl;
122 tok_hepMC_ = consumes<edm::HepMCProduct>(tmp0);
124 std::cout <<
"HGCalTBAnalyzer:: GeneratorSource = " << tmp0 << std::endl;
137 << tmp1 <<
", " << tmp2 <<
", " << tmp3 << std::endl;
148 std::cout <<
"HGCalTBAnalyzer:: Detector " << detectorHE_ <<
" with tags "
149 << tmp1 <<
", " << tmp2 <<
", " << tmp3 << std::endl;
167 hBeam_ =
fs_->
make<TH1D>(
"BeamP",
"Beam Momentum", 1000, 0, 1000.0);
168 for (
int i=0;
i<2; ++
i) {
173 sprintf (name,
"SimHitEn%s", det.c_str());
174 sprintf (title,
"Sim Hit Energy for %s", det.c_str());
176 sprintf (name,
"SimHitEnX%s", det.c_str());
177 sprintf (title,
"Sim Hit Energy for %s", det.c_str());
179 sprintf (name,
"SimHitTm%s", det.c_str());
180 sprintf (title,
"Sim Hit Timing for %s", det.c_str());
182 sprintf (name,
"SimHitLat%s", det.c_str());
183 sprintf (title,
"Lateral Shower profile (Sim Hit) for %s", det.c_str());
185 sprintf (name,
"SimHitLng%s", det.c_str());
186 sprintf (title,
"Longitudinal Shower profile (Sim Hit) for %s",det.c_str());
188 sprintf (name,
"SimHitLng1%s", det.c_str());
189 sprintf (title,
"Longitudinal Shower profile (Layer) for %s",det.c_str());
191 sprintf (name,
"SimHitLng2%s", det.c_str());
192 sprintf (title,
"Longitudinal Shower profile (Layer) for %s",det.c_str());
197 sprintf (name,
"DigiADC%s", det.c_str());
198 sprintf (title,
"ADC at Digi level for %s", det.c_str());
200 sprintf (name,
"DigiOcc%s", det.c_str());
201 sprintf (title,
"Occupancy (Digi)for %s", det.c_str());
203 sprintf (name,
"DigiLng%s", det.c_str());
204 sprintf (title,
"Longitudinal Shower profile (Digi) for %s",det.c_str());
209 sprintf (name,
"RecHitEn%s", det.c_str());
210 sprintf (title,
"Rec Hit Energy for %s", det.c_str());
212 sprintf (name,
"RecHitOcc%s", det.c_str());
213 sprintf (title,
"Occupancy (Rec Hit)for %s", det.c_str());
215 sprintf (name,
"RecHitLat%s", det.c_str());
216 sprintf (title,
"Lateral Shower profile (Rec Hit) for %s", det.c_str());
218 sprintf (name,
"RecHitLng%s", det.c_str());
219 sprintf (title,
"Longitudinal Shower profile (Rec Hit) for %s",det.c_str());
221 sprintf (name,
"RecHitLng1%s", det.c_str());
222 sprintf (title,
"Longitudinal Shower profile vs Layer for %s",det.c_str());
260 sprintf (name,
"SimHitEnA%d%s",
l,
detectorEE_.c_str());
261 sprintf (title,
"Sim Hit Energy in SIM layer %d for %s",
l+1,
265 sprintf (name,
"SimHitEnB%d%s", (
l/3+1),
detectorEE_.c_str());
266 sprintf (title,
"Sim Hit Energy in layer %d for %s",(
l/3+1),
292 sprintf (name,
"SimHitEnA%d%s",
l,
detectorHE_.c_str());
293 sprintf (title,
"Sim Hit Energy in layer %d for %s",
l+1,
297 sprintf (name,
"SimHitEnB%d%s", (
l/3+1),
detectorHE_.c_str());
298 sprintf (title,
"Sim Hit Energy in layer %d for %s",(
l/3+1),
322 const HepMC::GenEvent * myGenEvent = evtMC->GetEvent();
324 for (HepMC::GenEvent::particle_const_iterator
p = myGenEvent->particles_begin();
325 p != myGenEvent->particles_end(); ++
p, ++
k) {
326 if (k == 0)
hBeam_->Fill((*p)->momentum().rho());
328 std::cout <<
"Particle[" << k <<
"] with p " << (*p)->momentum().rho()
329 <<
" theta " << (*p)->momentum().theta() <<
" phi "
330 << (*p)->momentum().phi() << std::endl;
348 std::vector<PCaloHit> caloHits;
355 if (theCaloHitContainers.
isValid()) {
358 << theCaloHitContainers->size() <<
" hits" << std::endl;
361 caloHits.insert(caloHits.end(), theCaloHitContainers->begin(),
362 theCaloHitContainers->end());
367 <<
" !!!" << std::endl;
377 if (theCaloHitContainers.
isValid()) {
380 << theCaloHitContainers->size() <<
" hits" << std::endl;
383 caloHits.insert(caloHits.end(), theCaloHitContainers->begin(),
384 theCaloHitContainers->end());
389 <<
" !!!" << std::endl;
401 if (theDigiContainers.
isValid()) {
404 << theDigiContainers->size() <<
" element(s)" << std::endl;
407 it !=theDigiContainers->end(); ++it) {
410 uint16_t
adc = hgcSample.
data();
418 if (theDigiContainers.
isValid()) {
421 << theDigiContainers->size() <<
" element(s)" << std::endl;
424 it !=theDigiContainers->end(); ++it) {
427 uint16_t
adc = hgcSample.
data();
439 if (theCaloHitContainers.
isValid()) {
442 << theCaloHitContainers->size() <<
" hits" << std::endl;
448 <<
" !!!" << std::endl;
454 if (theCaloHitContainers.
isValid()) {
457 << theCaloHitContainers->size() <<
" hits" << std::endl;
463 <<
" !!!" << std::endl;
472 std::map<uint32_t,double> map_hits, map_hitn;
473 std::map<int,double> map_hitLayer, map_hitDepth;
474 std::map<int,std::pair<uint32_t,double> > map_hitCell;
476 for (
unsigned int i=0;
i<hits.size();
i++) {
477 double energy = hits[
i].energy();
478 double time = hits[
i].time();
479 uint32_t
id = hits[
i].id();
481 int subdet,
zside, layer, sector, subsector, cell;
486 std::cout <<
"SimHit:Hit[" <<
i <<
"] Id " << subdet <<
":" << zside <<
":"
487 << layer <<
":" << sector <<
":" << subsector <<
":" << cell
488 <<
":" << depth <<
" Energy " << energy <<
" Time " << time
491 if (map_hits.count(
id) != 0) {
496 if (map_hitLayer.count(layer) != 0) {
497 map_hitLayer[layer] +=
energy;
499 map_hitLayer[layer] =
energy;
502 if (map_hitCell.count(cell) != 0) {
503 double ee = energy + map_hitCell[cell].second;
504 map_hitCell[cell] = std::pair<uint32_t,double>(id,ee);
506 map_hitCell[cell] = std::pair<uint32_t,double>(id,
energy);
508 if (map_hitDepth.count(depth) != 0) {
516 if (map_hitn.count(idn) != 0) {
526 for (std::map<uint32_t,double>::iterator itr = map_hits.begin() ;
527 itr != map_hits.end(); ++itr) {
531 for (std::map<int,double>::iterator itr = map_hitLayer.begin();
532 itr != map_hitLayer.end(); ++itr) {
533 int layer = itr->first - 1;
534 double energy = itr->second;
537 std::cout <<
"SimHit:Layer " << layer+1 <<
" " << zp <<
" " << energy
554 for (std::map<int,double>::iterator itr = map_hitDepth.begin();
555 itr != map_hitDepth.end(); ++itr) {
556 int layer = itr->first - 1;
557 double energy = itr->second;
559 std::cout <<
"SimHit:Layer " << layer+1 <<
" " << energy << std::endl;
575 for (std::map<
int,std::pair<uint32_t,double> >::iterator itr = map_hitCell.begin();
576 itr != map_hitCell.end(); ++itr) {
577 uint32_t
id = ((itr->second).
first);
579 int subdet,
zside, layer, sector, subsector, cell;
584 double xx = (zp < 0) ? -xy.first : xy.first;
588 for (std::map<uint32_t,double>::iterator itr = map_hitn.begin();
589 itr != map_hitn.end(); ++itr) {
590 uint32_t
id = itr->first;
591 double energy = itr->second;
605 for (edm::SimTrackContainer::const_iterator simTrkItr = SimTk->begin();
606 simTrkItr!= SimTk->end(); simTrkItr++) {
608 std::cout <<
"Track " << simTrkItr->trackId() <<
" Vertex "
609 << simTrkItr->vertIndex() <<
" Type " << simTrkItr->type()
610 <<
" Charge " << simTrkItr->charge() <<
" momentum "
611 << simTrkItr->momentum() <<
" " << simTrkItr->momentum().P()
614 if (vertIndex == -1) {
615 vertIndex = simTrkItr->vertIndex();
616 pBeam = simTrkItr->momentum().P();
619 if (vertIndex != -1 && vertIndex < (
int)SimVtx->size()) {
620 edm::SimVertexContainer::const_iterator simVtxItr= SimVtx->begin();
621 for (
int iv=0; iv<vertIndex; iv++) simVtxItr++;
623 std::cout <<
"Vertex " << vertIndex <<
" position "
624 << simVtxItr->position() << std::endl;
626 xBeam = simVtxItr->position().X();
627 yBeam = simVtxItr->position().Y();
628 zBeam = simVtxItr->position().Z();
646 std::map<int,double> map_hitLayer;
647 std::map<int,std::pair<DetId,double> > map_hitCell;
649 it != hits->end(); ++it) {
650 DetId detId = it->id();
652 double energy = it->energy();
657 if (map_hitLayer.count(layer) != 0) {
658 map_hitLayer[layer] +=
energy;
660 map_hitLayer[layer] =
energy;
662 if (map_hitCell.count(cell) != 0) {
663 double ee = energy + map_hitCell[cell].second;
664 map_hitCell[cell] = std::pair<uint32_t,double>(detId,ee);
666 map_hitCell[cell] = std::pair<uint32_t,double>(detId,
energy);
669 std::cout <<
"RecHit: " << layer <<
" " << global.
x() <<
" " << global.
y()
670 <<
" " << global.
z() <<
" " << energy << std::endl;
674 for (std::map<int,double>::iterator itr = map_hitLayer.begin();
675 itr != map_hitLayer.end(); ++itr) {
676 int layer = itr->first;
677 double energy = itr->second;
680 std::cout <<
"SimHit:Layer " << layer <<
" " << zp <<
" " << energy
687 for (std::map<
int,std::pair<DetId,double> >::iterator itr = map_hitCell.begin();
688 itr != map_hitCell.end(); ++itr) {
int adc(sample_type sample)
get the ADC sample (12 bits)
T getParameter(std::string const &) const
std::vector< float > simHitLayEn2E
T getUntrackedParameter(std::string const &, T const &) const
void analyzeSimTracks(edm::Handle< edm::SimTrackContainer > const &SimTk, edm::Handle< edm::SimVertexContainer > const &SimVtx)
TProfile * hSimHitLng_[2]
TProfile * hSimHitLng1_[2]
bool getByToken(EDGetToken token, Handle< PROD > &result) const
TProfile * hRecHitLng_[2]
TProfile * hRecHitLng1_[2]
#define DEFINE_FWK_MODULE(type)
TProfile * hSimHitLng2_[2]
static uint32_t packHexagonIndex(int subdet, int z, int lay, int wafer, int celltyp, int cell)
std::vector< HGCEEDataFrame >::const_iterator const_iterator
edm::Service< TFileService > fs_
HGCalTBAnalyzer(edm::ParameterSet const &)
virtual void beginRun(edm::Run const &, edm::EventSetup const &) override
std::vector< float > simHitCellEnH
T * make(const Args &...args) const
make new ROOT object
GlobalPoint getPosition(const DetId &id) const
std::vector< uint32_t > simHitCellIdH
std::vector< float > simHitLayEn1E
std::vector< float > simHitLayEn1H
std::pair< float, float > locateCell(int cell, int lay, int type, bool reco) const
edm::EDGetToken tok_digiHE_
edm::EDGetToken tok_hitrHE_
U second(std::pair< T, U > const &p)
std::vector< TH1D * > hSimHitLayEn1H_
std::vector< TH1D * > hSimHitLayEn2E_
std::pair< int, int > simToReco(int cell, int layer, int mod, bool half) const
void addDefault(ParameterSetDescription const &psetDescription)
unsigned int layers(bool reco) const
void analyzeRecHits(int type, edm::Handle< HGCRecHitCollection > &hits)
const HGCalGeometry * hgeom_[2]
usesResource(TFileService::kSharedResource)
std::vector< float > simHitCellEnE
edm::EDGetTokenT< edm::SimTrackContainer > tok_simTk_
virtual void analyze(edm::Event const &, edm::EventSetup const &) override
const HGCalDDDConstants * hgcons_[2]
edm::EDGetTokenT< edm::HepMCProduct > tok_hepMC_
std::vector< uint32_t > simHitCellIdE
edm::EDGetTokenT< edm::PCaloHitContainer > tok_hitsHE_
double waferZ(int layer, bool reco) const
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
std::vector< TH1D * > hSimHitLayEn2H_
int cell() const
get the absolute value of the cell #'s in x and y
std::vector< float > simHitLayEn2H
void analyzeSimHits(int type, std::vector< PCaloHit > &hits)
T const * product() const
TProfile2D * hRecHitLat_[2]
void analyzeDigi(int type, const T1 &detId, uint16_t adc)
virtual void endRun(edm::Run const &, edm::EventSetup const &) override
edm::EDGetTokenT< edm::PCaloHitContainer > tok_hitsEE_
TProfile2D * hSimHitLat_[2]
std::vector< TH1D * > hSimHitLayEn1E_
edm::EDGetToken tok_hitrEE_
edm::EDGetTokenT< edm::SimVertexContainer > tok_simVtx_
static void unpackHexagonIndex(const uint32_t &idx, int &subdet, int &z, int &lay, int &wafer, int &celltyp, int &cell)
int layer() const
get the layer #
virtual void beginJob() override
edm::EDGetToken tok_digiEE_