26 for(
auto& detsetSource: source) {
28 std::copy(detsetSource.begin(), detsetSource.end(), std::back_inserter(detsetTarget));
38 DataMixingTrackingParticleWorker::DataMixingTrackingParticleWorker() { }
55 TrackSigToken_ = iC.consumes<std::vector<TrackingParticle> >(TrackingParticleLabelSig_);
56 TrackPileToken_ = iC.consumes<std::vector<TrackingParticle> >(TrackingParticlePileInputTag_);
58 VtxSigToken_ = iC.consumes<std::vector<TrackingVertex> >(TrackingParticleLabelSig_);
59 VtxPileToken_ = iC.consumes<std::vector<TrackingVertex> >(TrackingParticlePileInputTag_);
98 DataMixingTrackingParticleWorker::~DataMixingTrackingParticleWorker() {
107 NewTrackList_ = std::auto_ptr<std::vector<TrackingParticle>>(
new std::vector<TrackingParticle>());
109 TempVertexList_ = std::vector<TrackingVertex>();
111 TrackListRef_ =
const_cast<edm::Event&
>(
e ).getRefBeforePut< std::vector<TrackingParticle> >(TrackingParticleCollectionDM_);
112 VertexListRef_ =
const_cast<edm::Event&
>(
e ).getRefBeforePut< std::vector<TrackingVertex> >(TrackingParticleCollectionDM_);
116 NewStripLinkList_ = std::make_unique<edm::DetSetVector<StripDigiSimLink> >();
117 NewPixelLinkList_ = std::make_unique<edm::DetSetVector<PixelDigiSimLink> >();
121 NewCSCStripLinkList_ = std::make_unique<edm::DetSetVector<StripDigiSimLink> >();
122 NewCSCWireLinkList_ = std::make_unique<edm::DetSetVector<StripDigiSimLink> >();
123 NewRPCLinkList_ = std::make_unique<edm::DetSetVector<RPCDigiSimLink> >();
124 NewDTLinkList_ = std::make_unique< MuonDigiCollection<DTLayerId, DTDigiSimLink> >();
129 void DataMixingTrackingParticleWorker::addTrackingParticleSignals(
const edm::Event &
e) {
136 const size_t StartingIndexV = TempVertexList_.size();
137 const size_t StartingIndexT = NewTrackList_->size();
141 for (std::vector<TrackingVertex>::const_iterator vtx = vtxs->begin(); vtx != vtxs->end(); ++vtx) {
142 TempVertexList_.push_back(*vtx);
152 for (std::vector<TrackingParticle>::const_iterator track = tracks->begin(); track != tracks->end(); ++track) {
153 auto oldRef=track->parentVertex();
155 NewTrackList_->push_back(*track);
157 auto & Ntrack = NewTrackList_->back();
159 Ntrack.setParentVertex( newRef );
160 Ntrack.clearDecayVertices();
164 for(
auto const& vertexRef : track->decayVertices() ) {
165 auto newRef=
TrackingVertexRef( VertexListRef_, vertexRef.index()+StartingIndexV );
166 Ntrack.addDecayVertex(newRef);
174 for (
auto & vertex : TempVertexList_ ) {
177 sourceTrackIndices.reserve(vertex.sourceTracks().size());
178 daughterTrackIndices.reserve(vertex.daughterTracks().size());
179 for(
auto const& ref: vertex.sourceTracks()) sourceTrackIndices.push_back(ref.index());
180 for(
auto const& ref: vertex.daughterTracks()) daughterTrackIndices.push_back(ref.index());
182 vertex.clearParentTracks();
183 vertex.clearDaughterTracks();
185 for(
auto index : sourceTrackIndices ) {
187 vertex.addParentTrack(newRef);
191 for(
auto index : daughterTrackIndices ) {
193 vertex.addDaughterTrack(newRef);
196 sourceTrackIndices.clear();
197 daughterTrackIndices.clear();
204 appendDetSetVector(*NewStripLinkList_, *stripLinks);
210 appendDetSetVector(*NewPixelLinkList_, *pixelLinks);
214 e.
getByToken(CSCStripLinkSigToken_, CSCstripLinks);
216 appendDetSetVector(*NewCSCStripLinkList_, *CSCstripLinks);
220 e.
getByToken(CSCWireLinkSigToken_, CSCwireLinks);
222 appendDetSetVector(*NewCSCWireLinkList_, *CSCwireLinks);
228 appendDetSetVector(*NewRPCLinkList_, *RPCLinks);
235 const DTLayerId& layerid = (*detUnit).first;
237 NewDTLinkList_->put(range,layerid);
245 void DataMixingTrackingParticleWorker::addTrackingParticlePileups(
const int bcr,
const EventPrincipal *ep,
unsigned int eventNr,
248 LogDebug(
"DataMixingTrackingParticleWorker") <<
"\n===============> adding pileups from event "<<ep->
id()<<
" for bunchcrossing "<<bcr;
250 const size_t StartingIndexV = TempVertexList_.size();
251 const size_t StartingIndexT = NewTrackList_->size();
253 std::shared_ptr<Wrapper<std::vector<TrackingVertex> >
const> inputVPTR =
254 getProductByTag<std::vector<TrackingVertex> >(*ep, TrackingParticlePileInputTag_, mcc);
258 const std::vector<TrackingVertex> *vtxs =
const_cast< std::vector<TrackingVertex> *
>(inputVPTR->product());
262 for (std::vector<TrackingVertex>::const_iterator vtx = vtxs->begin(); vtx != vtxs->end(); ++vtx) {
263 TempVertexList_.push_back(*vtx);
268 std::shared_ptr<Wrapper<std::vector<TrackingParticle> >
const> inputPTR =
269 getProductByTag<std::vector<TrackingParticle> >(*ep, TrackingParticlePileInputTag_, mcc);
273 const std::vector<TrackingParticle> *
tracks =
const_cast< std::vector<TrackingParticle> *
>(inputPTR->product());
276 for (std::vector<TrackingParticle>::const_iterator track = tracks->begin(); track != tracks->end(); ++track) {
277 auto oldRef=track->parentVertex();
279 NewTrackList_->push_back(*track);
281 auto & Ntrack = NewTrackList_->back();
283 Ntrack.setParentVertex( newRef );
284 Ntrack.clearDecayVertices();
288 for(
auto const& vertexRef : track->decayVertices() ) {
289 auto newRef=
TrackingVertexRef( VertexListRef_, vertexRef.index()+StartingIndexV );
290 Ntrack.addDecayVertex(newRef);
299 for(
size_t iVertex = StartingIndexV; iVertex != TempVertexList_.size(); ++iVertex) {
300 auto& vertex = TempVertexList_[iVertex];
303 sourceTrackIndices.reserve(vertex.sourceTracks().size());
304 daughterTrackIndices.reserve(vertex.daughterTracks().size());
305 for(
auto const& ref: vertex.sourceTracks()) sourceTrackIndices.push_back(ref.index());
306 for(
auto const& ref: vertex.daughterTracks()) daughterTrackIndices.push_back(ref.index());
308 vertex.clearParentTracks();
309 vertex.clearDaughterTracks();
311 for(
auto index : sourceTrackIndices ) {
313 vertex.addParentTrack(newRef);
317 for(
auto index : daughterTrackIndices ) {
319 vertex.addDaughterTrack(newRef);
322 sourceTrackIndices.clear();
323 daughterTrackIndices.clear();
328 std::shared_ptr<Wrapper<edm::DetSetVector<StripDigiSimLink> >
const> inputStripPtr =
329 getProductByTag<edm::DetSetVector<StripDigiSimLink> >(*ep, StripLinkPileInputTag_, mcc);
331 appendDetSetVector(*NewStripLinkList_, *(inputStripPtr->product()));
334 std::shared_ptr<Wrapper<edm::DetSetVector<PixelDigiSimLink> >
const> inputPixelPtr =
335 getProductByTag<edm::DetSetVector<PixelDigiSimLink> >(*ep, PixelLinkPileInputTag_, mcc);
337 appendDetSetVector(*NewPixelLinkList_, *(inputPixelPtr->product()));
340 std::shared_ptr<Wrapper<edm::DetSetVector<StripDigiSimLink> >
const> CSCinputStripPtr =
341 getProductByTag<edm::DetSetVector<StripDigiSimLink> >(*ep, CSCStripLinkPileInputTag_, mcc);
342 if(CSCinputStripPtr) {
343 appendDetSetVector(*NewCSCStripLinkList_, *(CSCinputStripPtr->product()));
346 std::shared_ptr<Wrapper<edm::DetSetVector<StripDigiSimLink> >
const> CSCinputWirePtr =
347 getProductByTag<edm::DetSetVector<StripDigiSimLink> >(*ep, CSCWireLinkPileInputTag_, mcc);
348 if(CSCinputWirePtr) {
349 appendDetSetVector(*NewCSCWireLinkList_, *(CSCinputWirePtr->product()));
352 std::shared_ptr<Wrapper<edm::DetSetVector<RPCDigiSimLink> >
const> inputRPCPtr =
353 getProductByTag<edm::DetSetVector<RPCDigiSimLink> >(*ep, RPCLinkPileInputTag_, mcc);
355 appendDetSetVector(*NewRPCLinkList_, *(inputRPCPtr->product()));
358 std::shared_ptr<Wrapper< DTDigiSimLinkCollection >
const> inputDTPtr =
359 getProductByTag< DTDigiSimLinkCollection >(*ep, DTLinkPileInputTag_, mcc);
363 const DTLayerId& layerid = (*detUnit).first;
365 NewDTLinkList_->put(range,layerid);
373 void DataMixingTrackingParticleWorker::putTrackingParticle(
edm::Event &
e) {
377 NewVertexList_ = std::auto_ptr<std::vector<TrackingVertex>>(
new std::vector<TrackingVertex>(TempVertexList_));
380 LogInfo(
"DataMixingTrackingParticleWorker") <<
"total # Merged Tracks: " << NewTrackList_->size() ;
384 e.
put( NewTrackList_, TrackingParticleCollectionDM_ );
385 e.
put( NewVertexList_, TrackingParticleCollectionDM_ );
387 e.
put(
std::move(NewStripLinkList_), StripLinkCollectionDM_ );
388 e.
put(
std::move(NewPixelLinkList_), PixelLinkCollectionDM_ );
390 e.
put(
std::move(NewCSCStripLinkList_), CSCStripLinkCollectionDM_ );
391 e.
put(
std::move(NewCSCWireLinkList_), CSCWireLinkCollectionDM_ );
392 e.
put(
std::move(NewRPCLinkList_), RPCLinkCollectionDM_ );
393 e.
put(
std::move(NewDTLinkList_), DTLinkCollectionDM_ );
398 TempVertexList_.clear();
T getParameter(std::string const &) const
bool getByToken(EDGetToken token, Handle< PROD > &result) const
EventID const & id() const
reference find_or_insert(det_id_type id)
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
edm::Ref< TrackingVertexCollection > TrackingVertexRef
std::pair< const_iterator, const_iterator > Range
DigiRangeIterator end() const
static std::string const source
edm::Ref< TrackingParticleCollection > TrackingParticleRef
DigiRangeIterator begin() const