84 usesResource(
"TFileService");
95 if (!groupHits_) timeUnit_ = 0.000001;
97 std::cout <<
"HGCalTimingAnalyzer:: Group Hits " << groupHits_ <<
" in " 98 << timeUnit_ <<
" IdBeam " << idBeams_.size() <<
":";
99 for (
const auto&
id : idBeams_)
std::cout <<
" " <<
id;
102 if (idBeams_.size() == 0) idBeams_.push_back(1001);
105 tok_hepMC_ = consumes<edm::HepMCProduct>(tmp0);
107 std::cout <<
"HGCalTimingAnalyzer:: GeneratorSource = " << tmp0 << std::endl;
115 <<
" with tags " << tmp1 << std::endl;
120 std::cout <<
"HGCalTimingAnalyzer:: Detector " << detectorBeam_
121 <<
" with tags " << tmp1 << std::endl;
131 desc.
add<
bool>(
"GroupHits",
false);
132 desc.
add<
double>(
"TimeUnit",0.001);
133 std::vector<int> ids = {1001,1002,1003,1004,1005};
134 desc.
add<std::vector<int>>(
"IDBeams",ids);
139 descriptions.
add(
"HGCalTimingAnalyzer",desc);
181 const HepMC::GenEvent * myGenEvent = evtMC->
GetEvent();
183 for (HepMC::GenEvent::particle_const_iterator
p = myGenEvent->particles_begin();
184 p != myGenEvent->particles_end(); ++
p, ++
k) {
185 std::cout <<
"Particle[" << k <<
"] with p " << (*p)->momentum().rho()
186 <<
" theta " << (*p)->momentum().theta() <<
" phi " 187 << (*p)->momentum().phi() << std::endl;
204 std::vector<PCaloHit> caloHits;
206 if (theCaloHitContainers.
isValid()) {
209 << theCaloHitContainers->size() <<
" hits" << std::endl;
212 caloHits.insert(caloHits.end(), theCaloHitContainers->begin(),
213 theCaloHitContainers->end());
218 <<
" !!!" << std::endl;
223 if (theCaloHitContainers.
isValid()) {
226 << theCaloHitContainers->size() <<
" hits" << std::endl;
229 caloHits.insert(caloHits.end(), theCaloHitContainers->begin(),
230 theCaloHitContainers->end());
235 <<
" !!!" << std::endl;
243 std::vector<PCaloHit>
const&
hits) {
248 std::map<std::pair<uint32_t,uint64_t>,std::pair<double,double> > map_hits;
249 for (
const auto&
hit : hits) {
250 double energy =
hit.energy();
252 uint32_t
id =
hit.
id();
254 int subdet,
zside, layer, sector, subsector, cell;
257 std::pair<int,int> recoLayerCell =
hgcons_->
simToReco(cell,layer,sector,
true);
259 recoLayerCell.second,subsector,sector,
260 recoLayerCell.first).
rawId();
262 std::cout <<
"SimHit:Hit[" << i <<
"] Id " << subdet <<
":" << zside
263 <<
":" << layer <<
":" << sector <<
":" << subsector <<
":" 264 << recoLayerCell.first <<
":" << recoLayerCell.second
265 <<
" Energy " << energy <<
" Time " << time << std::endl;
269 int subdet, layer,
x,
y;
271 std::cout <<
"SimHit:Hit[" << i <<
"] Beam Subdet " << subdet
272 <<
" Layer " << layer <<
" x|y " << x <<
":" << y
273 <<
" Energy " << energy <<
" Time " << time << std::endl;
277 std::pair<uint32_t,uint64_t>
key(
id,tid);
278 auto itr = map_hits.find(key);
279 if (itr == map_hits.end()) {
280 map_hits[
key] = std::pair<double,double>(
time,0.0);
281 itr = map_hits.find(key);
283 energy += (itr->second).
second;
284 map_hits[
key] = std::pair<double,double>((itr->second).
first,energy);
291 std::cout <<
"analyzeSimHits: Finds " << map_hits.size() <<
" hits " 292 <<
" from the Hit Vector of size " << hits.size() <<
" for type " 293 << type << std::endl;
295 for (
const auto& itr: map_hits) {
296 uint32_t
id = (itr.first).
first;
298 double energy = (itr.second).
second;
310 <<
" E: " << energy << std::endl;
321 for (edm::SimTrackContainer::const_iterator simTrkItr = SimTk->begin();
322 simTrkItr!= SimTk->end(); simTrkItr++) {
324 std::cout <<
"Track " << simTrkItr->trackId() <<
" Vertex " 325 << simTrkItr->vertIndex() <<
" Type " << simTrkItr->type()
326 <<
" Charge " << simTrkItr->charge() <<
" momentum " 327 << simTrkItr->momentum() <<
" " << simTrkItr->momentum().P()
330 if (vertIndex == -1) {
331 vertIndex = simTrkItr->vertIndex();
332 pBeam_ = simTrkItr->momentum().P();
335 if (vertIndex != -1 && vertIndex < (
int)SimVtx->size()) {
336 edm::SimVertexContainer::const_iterator simVtxItr= SimVtx->begin();
337 for (
int iv=0; iv<vertIndex; iv++) simVtxItr++;
339 std::cout <<
"Vertex " << vertIndex <<
" position " 340 << simVtxItr->position() << std::endl;
342 xBeam_ = simVtxItr->position().X();
343 yBeam_ = simVtxItr->position().Y();
344 zBeam_ = simVtxItr->position().Z();
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
const HGCalDDDConstants * hgcons_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
virtual void analyze(edm::Event const &, edm::EventSetup const &) override
#define DEFINE_FWK_MODULE(type)
edm::EDGetTokenT< edm::SimTrackContainer > tok_simTk_
edm::EDGetTokenT< edm::PCaloHitContainer > tok_hitsEE_
T * make(const Args &...args) const
make new ROOT object
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
uint32_t rawId() const
get the raw id
U second(std::pair< T, U > const &p)
HGCalTimingAnalyzer(edm::ParameterSet const &)
edm::EDGetTokenT< edm::HepMCProduct > tok_hepMC_
std::pair< int, int > simToReco(int cell, int layer, int mod, bool half) const
std::vector< float > simHitCellEnEE_
unsigned int layers(bool reco) const
std::vector< float > simHitCellTmBeam_
ParameterDescriptionBase * add(U const &iLabel, T const &value)
std::vector< int > idBeams_
std::vector< float > simHitCellEnBeam_
std::vector< uint32_t > simHitCellIdBeam_
std::vector< float > simHitCellTmEE_
std::vector< uint32_t > simHitCellIdEE_
virtual void beginJob() override
const HepMC::GenEvent * GetEvent() const
edm::Service< TFileService > fs_
unsigned long long uint64_t
edm::EDGetTokenT< edm::SimVertexContainer > tok_simVtx_
void add(std::string const &label, ParameterSetDescription const &psetDescription)
virtual void beginRun(edm::Run const &, edm::EventSetup const &) override
static void unpackIndex(const uint32_t &idx, int &det, int &lay, int &x, int &y)
std::string detectorBeam_
void analyzeSimHits(int type, std::vector< PCaloHit > const &hits)
virtual void endRun(edm::Run const &, edm::EventSetup const &) override
static void unpackHexagonIndex(const uint32_t &idx, int &subdet, int &z, int &lay, int &wafer, int &celltyp, int &cell)
void analyzeSimTracks(edm::Handle< edm::SimTrackContainer > const &SimTk, edm::Handle< edm::SimVertexContainer > const &SimVtx)
edm::EDGetTokenT< edm::PCaloHitContainer > tok_hitsBeam_