11 verboseSimTrack_ =
simTrack.getParameter<
int>(
"verbose");
24 iEvent.
getByToken(simTrackInput_, simTracksH_);
25 iEvent.
getByToken(simVertexInput_, simVerticesH_);
31 simTracks_ = *simTracksH_.product();
32 simVertices_ = *simVerticesH_.product();
33 simHits_ = *simHitsH_.product();
37 trkid_to_index_.clear();
38 for (
const auto&
t : simTracks_) {
39 trkid_to_index_[
t.trackId()] = no;
44 getIdsOfSimTrackShower(track.
trackId(), simTracks_, simVertices_);
45 if (verboseSimTrack_) {
46 edm::LogInfo(
"MuonSimHitMatcher") <<
"Printing track_ids" << std::endl;
47 for (
const auto&
id : track_ids_)
edm::LogInfo(
"MuonSimHitMatcher") <<
"id: " <<
id << std::endl;
54 vector<unsigned int>
result;
55 result.push_back(initial_trk_id);
57 if (!simMuOnly_)
return result;
59 for (
const auto&
t : simTracks_) {
62 bool is_child =
false;
65 if (simVertices_[last_trk.
vertIndex()].noParent())
break;
67 unsigned parentId = simVertices_[last_trk.
vertIndex()].parentIndex();
68 if (parentId == initial_trk_id) {
73 const auto&
association = trkid_to_index_.find(parentId);
79 result.push_back(
t.trackId());
90 unsigned int detid)
const {
91 if (detid_to_hits_.find(detid) == detid_to_hits_.end())
return no_hits_;
92 return detid_to_hits_.at(detid);
96 unsigned int detid)
const {
97 if (chamber_to_hits_.find(detid) == chamber_to_hits_.end())
return no_hits_;
98 return chamber_to_hits_.at(detid);
105 float sumx, sumy, sumz;
106 sumx = sumy = sumz = 0.f;
108 for (
const auto&
h : sim_hits) {
111 geometry_->idToDet(
h.detUnitId())->surface().toGlobal(lp);
125 float sumx, sumy, sumz;
126 sumx = sumy = sumz = 0.f;
128 for (
const auto&
h : sim_hits) {
131 geometry_->idToDet(
h.detUnitId())->surface().toGlobal(lv);
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Global3DPoint GlobalPoint
GlobalPoint simHitsMeanPosition(const edm::PSimHitContainer &sim_hits) const
const edm::PSimHitContainer & simHits(int) const
GlobalVector simHitsMeanMomentum(const edm::PSimHitContainer &sim_hits) const
int vertIndex() const
index of the vertex in the Event container (-1 if no vertex)
unsigned int trackId() const
ParameterSet const & getParameterSet(std::string const &) const
const edm::PSimHitContainer & hitsInDetId(unsigned int) const
std::vector< SimVertex > SimVertexContainer
void match(const SimTrack &t, const SimVertex &v)
do the matching
MuonSimHitMatcher(const edm::ParameterSet &iPS, edm::ConsumesCollector &&iC)
std::vector< PSimHit > PSimHitContainer
std::vector< unsigned int > getIdsOfSimTrackShower(unsigned trk_id, const edm::SimTrackContainer &simTracks, const edm::SimVertexContainer &simVertices)
void init(const edm::Event &e, const edm::EventSetup &eventSetup)
initialize the event
const edm::PSimHitContainer & hitsInChamber(unsigned int) const
std::vector< SimTrack > SimTrackContainer
Global3DVector GlobalVector