126 auto rng_engine = &(rng->
getEngine(sid));
129 std::vector<edm::Handle<reco::TrackToTrackingParticleAssociator> >
associators;
131 associators.emplace_back();
132 auto& back = associators.back();
136 std::vector<float> generalTrackTimes;
155 std::vector<reco::RecoToSimCollection> associatedTracks;
157 associatedTracks.emplace_back(
associator->associateRecoToSim(TrackCollectionH, TPCollectionH));
161 double sumSimTime = 0.;
162 double sumSimTimeSq = 0.;
165 if (puinfo.getBunchCrossing() == 0) {
166 for (
const float &
time : puinfo.getPU_times()) {
167 double simtime =
time;
168 sumSimTime += simtime;
169 sumSimTimeSq += simtime*simtime;
176 double meanSimTime = sumSimTime/double(nsim);
177 double varSimTime = sumSimTimeSq/double(nsim) - meanSimTime*meanSimTime;
180 for(
unsigned itk = 0; itk < TrackCollection.
size(); ++itk ) {
181 const auto tkref = TrackCollection.
refAt(itk);
184 for(
const auto&
association : associatedTracks ) {
189 if (track_tps != associatedTracks.back().end() && track_tps->val.size() == 1) {
192 generalTrackTimes.push_back(time);
195 float rndtime = CLHEP::RandGauss::shoot(rng_engine, meanSimTime, rmsSimTime);
196 generalTrackTimes.push_back(rndtime);
197 if (track_tps != associatedTracks.back().end() && track_tps->val.size() > 1) {
198 LogDebug(
"TooManyTracks") <<
"track matched to " << track_tps->val.size() <<
" tracking particles!" << std::endl;
205 std::vector<float>
times, resos;
207 times.reserve(TrackCollection.
size());
208 resos.reserve(TrackCollection.
size());
210 for(
unsigned i = 0;
i < TrackCollection.
size(); ++
i ) {
215 const float resolution = reso->getTimeResolution(tk);
216 times.push_back( CLHEP::RandGauss::shoot(rng_engine, generalTrackTimes[
i], resolution) );
217 resos.push_back( resolution );
220 times.push_back(0.0
f);
221 resos.push_back(-1.);
225 writeValueMap( evt, TrackCollectionH, times,
tracksName_+name );
226 writeValueMap( evt, TrackCollectionH, resos,
tracksName_+name+resolution );
double p() const
momentum vector magnitude
friend struct const_iterator
bool getByToken(EDGetToken token, Handle< PROD > &result) const
std::vector< Track > TrackCollection
collection of Tracks
reco::TransientTrack build(const reco::Track *p) const
const std::string tracksName_
virtual CLHEP::HepRandomEngine & getEngine(StreamID const &)=0
Use this engine in event methods.
std::vector< std::unique_ptr< const ResolutionModel > > resolutions_
RefToBase< value_type > refAt(size_type i) const
double eta() const
pseudorapidity of momentum vector
double pt() const
track transverse momentum
Abs< T >::type abs(const T &t)
float extractTrackVertexTime(const TrackingParticle &, const reco::TransientTrack &) const
const edm::EDGetTokenT< TrackingParticleCollection > trackingParticles_
const float etaMaxForPtThreshold_
const std::vector< edm::EDGetTokenT< reco::TrackToTrackingParticleAssociator > > associators_
const edm::EDGetTokenT< edm::View< reco::Track > > tracks_
const edm::EDGetTokenT< std::vector< PileupSummaryInfo > > pileupSummaryInfo_