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 int StartingIndexV = int(TempVertexList_.size());
137 int StartingIndexT = int(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);
173 for (
auto & vertex : TempVertexList_ ) {
175 vertex.clearParentTracks();
176 vertex.clearDaughterTracks();
178 for(
auto const& trackRef : vertex.sourceTracks() ) {
180 vertex.addParentTrack(newRef);
184 for(
auto const& trackRef : vertex.daughterTracks() ) {
186 vertex.addDaughterTrack(newRef);
194 appendDetSetVector(*NewStripLinkList_, *stripLinks);
200 appendDetSetVector(*NewPixelLinkList_, *pixelLinks);
204 e.
getByToken(CSCStripLinkSigToken_, CSCstripLinks);
206 appendDetSetVector(*NewCSCStripLinkList_, *CSCstripLinks);
210 e.
getByToken(CSCWireLinkSigToken_, CSCwireLinks);
212 appendDetSetVector(*NewCSCWireLinkList_, *CSCwireLinks);
218 appendDetSetVector(*NewRPCLinkList_, *RPCLinks);
225 const DTLayerId& layerid = (*detUnit).first;
227 NewDTLinkList_->put(range,layerid);
235 void DataMixingTrackingParticleWorker::addTrackingParticlePileups(
const int bcr,
const EventPrincipal *ep,
unsigned int eventNr,
238 LogDebug(
"DataMixingTrackingParticleWorker") <<
"\n===============> adding pileups from event "<<ep->
id()<<
" for bunchcrossing "<<bcr;
240 int StartingIndexV = int(TempVertexList_.size());
241 int StartingIndexT = int(NewTrackList_->size());
243 std::shared_ptr<Wrapper<std::vector<TrackingVertex> >
const> inputVPTR =
244 getProductByTag<std::vector<TrackingVertex> >(*ep, TrackingParticlePileInputTag_, mcc);
248 const std::vector<TrackingVertex> *vtxs =
const_cast< std::vector<TrackingVertex> *
>(inputVPTR->product());
252 for (std::vector<TrackingVertex>::const_iterator vtx = vtxs->begin(); vtx != vtxs->end(); ++vtx) {
253 TempVertexList_.push_back(*vtx);
258 std::shared_ptr<Wrapper<std::vector<TrackingParticle> >
const> inputPTR =
259 getProductByTag<std::vector<TrackingParticle> >(*ep, TrackingParticlePileInputTag_, mcc);
263 const std::vector<TrackingParticle> *
tracks =
const_cast< std::vector<TrackingParticle> *
>(inputPTR->product());
266 for (std::vector<TrackingParticle>::const_iterator track = tracks->begin(); track != tracks->end(); ++track) {
267 auto oldRef=track->parentVertex();
269 NewTrackList_->push_back(*track);
271 auto & Ntrack = NewTrackList_->back();
273 Ntrack.setParentVertex( newRef );
274 Ntrack.clearDecayVertices();
278 for(
auto const& vertexRef : track->decayVertices() ) {
279 auto newRef=
TrackingVertexRef( VertexListRef_, vertexRef.index()+StartingIndexV );
280 Ntrack.addDecayVertex(newRef);
287 for (
auto & vertex : TempVertexList_ ) {
289 vertex.clearParentTracks();
290 vertex.clearDaughterTracks();
292 for(
auto const& trackRef : vertex.sourceTracks() ) {
294 vertex.addParentTrack(newRef);
298 for(
auto const& trackRef : vertex.daughterTracks() ) {
300 vertex.addDaughterTrack(newRef);
306 std::shared_ptr<Wrapper<edm::DetSetVector<StripDigiSimLink> >
const> inputStripPtr =
307 getProductByTag<edm::DetSetVector<StripDigiSimLink> >(*ep, StripLinkPileInputTag_, mcc);
309 appendDetSetVector(*NewStripLinkList_, *(inputStripPtr->product()));
312 std::shared_ptr<Wrapper<edm::DetSetVector<PixelDigiSimLink> >
const> inputPixelPtr =
313 getProductByTag<edm::DetSetVector<PixelDigiSimLink> >(*ep, PixelLinkPileInputTag_, mcc);
315 appendDetSetVector(*NewPixelLinkList_, *(inputPixelPtr->product()));
318 std::shared_ptr<Wrapper<edm::DetSetVector<StripDigiSimLink> >
const> CSCinputStripPtr =
319 getProductByTag<edm::DetSetVector<StripDigiSimLink> >(*ep, CSCStripLinkPileInputTag_, mcc);
320 if(CSCinputStripPtr) {
321 appendDetSetVector(*NewCSCStripLinkList_, *(CSCinputStripPtr->product()));
324 std::shared_ptr<Wrapper<edm::DetSetVector<StripDigiSimLink> >
const> CSCinputWirePtr =
325 getProductByTag<edm::DetSetVector<StripDigiSimLink> >(*ep, CSCWireLinkPileInputTag_, mcc);
326 if(CSCinputWirePtr) {
327 appendDetSetVector(*NewCSCWireLinkList_, *(CSCinputWirePtr->product()));
330 std::shared_ptr<Wrapper<edm::DetSetVector<RPCDigiSimLink> >
const> inputRPCPtr =
331 getProductByTag<edm::DetSetVector<RPCDigiSimLink> >(*ep, RPCLinkPileInputTag_, mcc);
333 appendDetSetVector(*NewRPCLinkList_, *(inputRPCPtr->product()));
336 std::shared_ptr<Wrapper< DTDigiSimLinkCollection >
const> inputDTPtr =
337 getProductByTag< DTDigiSimLinkCollection >(*ep, DTLinkPileInputTag_, mcc);
341 const DTLayerId& layerid = (*detUnit).first;
343 NewDTLinkList_->put(range,layerid);
351 void DataMixingTrackingParticleWorker::putTrackingParticle(
edm::Event &
e) {
355 NewVertexList_ = std::auto_ptr<std::vector<TrackingVertex>>(
new std::vector<TrackingVertex>(TempVertexList_));
358 LogInfo(
"DataMixingTrackingParticleWorker") <<
"total # Merged Tracks: " << NewTrackList_->size() ;
362 e.
put( NewTrackList_, TrackingParticleCollectionDM_ );
363 e.
put( NewVertexList_, TrackingParticleCollectionDM_ );
365 e.
put( std::move(NewStripLinkList_), StripLinkCollectionDM_ );
366 e.
put( std::move(NewPixelLinkList_), PixelLinkCollectionDM_ );
368 e.
put( std::move(NewCSCStripLinkList_), CSCStripLinkCollectionDM_ );
369 e.
put( std::move(NewCSCWireLinkList_), CSCWireLinkCollectionDM_ );
370 e.
put( std::move(NewRPCLinkList_), RPCLinkCollectionDM_ );
371 e.
put( std::move(NewDTLinkList_), DTLinkCollectionDM_ );
376 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