112 std::vector<edm::Handle<reco::TrackToTrackingParticleAssociator> >
associators;
114 associators.emplace_back();
115 auto& back = associators.back();
119 std::vector<float> generalTrackTimes;
138 std::vector<reco::RecoToSimCollection> associatedTracks;
140 associatedTracks.emplace_back(
associator->associateRecoToSim(TrackCollectionH, TPCollectionH));
144 double sumSimTime = 0.;
145 double sumSimTimeSq = 0.;
148 if (puinfo.getBunchCrossing() == 0) {
149 for (
const float &
time : puinfo.getPU_times()) {
150 double simtime =
time;
151 sumSimTime += simtime;
152 sumSimTimeSq += simtime*simtime;
159 double meanSimTime = sumSimTime/double(nsim);
160 double varSimTime = sumSimTimeSq/double(nsim) - meanSimTime*meanSimTime;
162 std::normal_distribution<float> gausSimTime(meanSimTime, rmsSimTime);
165 unsigned int runNum_uint = static_cast <
unsigned int> (evt.
id().
run());
166 unsigned int lumiNum_uint = static_cast <
unsigned int> (evt.
id().
luminosityBlock());
167 unsigned int evNum_uint = static_cast <
unsigned int> (evt.
id().
event());
168 unsigned int tkChi2_uint = uint32_t(TrackCollection.
empty() ? 0 : TrackCollection.
refAt(0)->chi2()/0.01);
169 std::uint32_t
seed = tkChi2_uint + (lumiNum_uint<<10) + (runNum_uint<<20) + evNum_uint;
170 std::mt19937 rng(seed);
172 for(
unsigned itk = 0; itk < TrackCollection.
size(); ++itk ) {
173 const auto tkref = TrackCollection.
refAt(itk);
176 for(
const auto&
association : associatedTracks ) {
181 if (track_tps != associatedTracks.back().end() && track_tps->val.size() == 1) {
184 generalTrackTimes.push_back(time);
187 float rndtime = gausSimTime(rng);
188 generalTrackTimes.push_back(rndtime);
189 if (track_tps != associatedTracks.back().end() && track_tps->val.size() > 1) {
190 LogDebug(
"TooManyTracks") <<
"track matched to " << track_tps->val.size() <<
" tracking particles!" << std::endl;
197 std::vector<float>
times, resos;
199 times.reserve(TrackCollection.
size());
200 resos.reserve(TrackCollection.
size());
202 for(
unsigned i = 0;
i < TrackCollection.
size(); ++
i ) {
207 const float resolution = reso->getTimeResolution(tk);
208 std::normal_distribution<float> gausGeneralTime(generalTrackTimes[
i], resolution);
209 times.push_back( gausGeneralTime(rng) );
210 resos.push_back( resolution );
213 times.push_back(0.0
f);
214 resos.push_back(-1.);
218 writeValueMap( evt, TrackCollectionH, times,
tracksName_+name );
219 writeValueMap( evt, TrackCollectionH, resos,
tracksName_+name+resolution );
double p() const
momentum vector magnitude
EventNumber_t event() const
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_
LuminosityBlockNumber_t luminosityBlock() const
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_