@@ -68,6 +68,8 @@ class ClusterTPAssociationProducer final : public edm::global::EDProducer<> {
6868 edm::EDGetTokenT<edm::DetSetVector<PixelDigiSimLink> > siphase2OTSimLinksToken_;
6969 edm::EDGetTokenT<edmNew::DetSetVector<SiPixelCluster> > pixelClustersToken_;
7070 edm::EDGetTokenT<edmNew::DetSetVector<SiStripCluster> > stripClustersToken_;
71+ const edm::InputTag otherStripClusterTag_;
72+ edm::EDGetTokenT<edmNew::DetSetVector<SiStripCluster> > stripClustersOtherToken_;
7173 edm::EDGetTokenT<edmNew::DetSetVector<Phase2TrackerCluster1D> > phase2OTClustersToken_;
7274 edm::EDGetTokenT<TrackingParticleCollection> trackingParticleToken_;
7375 bool throwOnMissingCollections_;
@@ -84,6 +86,8 @@ ClusterTPAssociationProducer::ClusterTPAssociationProducer(const edm::ParameterS
8486 consumes<edmNew::DetSetVector<SiPixelCluster> >(cfg.getParameter<edm::InputTag>(" pixelClusterSrc" ))),
8587 stripClustersToken_(
8688 consumes<edmNew::DetSetVector<SiStripCluster> >(cfg.getParameter<edm::InputTag>(" stripClusterSrc" ))),
89+ otherStripClusterTag_(cfg.getParameter<edm::InputTag>(" stripClusterOtherSrc" )),
90+ stripClustersOtherToken_(consumes<edmNew::DetSetVector<SiStripCluster> >(otherStripClusterTag_)),
8791 phase2OTClustersToken_(consumes<edmNew::DetSetVector<Phase2TrackerCluster1D> >(
8892 cfg.getParameter<edm::InputTag>(" phase2OTClusterSrc" ))),
8993 trackingParticleToken_(
@@ -100,6 +104,7 @@ void ClusterTPAssociationProducer::fillDescriptions(edm::ConfigurationDescriptio
100104 desc.add <edm::InputTag>(" phase2OTSimLinkSrc" , edm::InputTag (" simSiPixelDigis" , " Tracker" ));
101105 desc.add <edm::InputTag>(" pixelClusterSrc" , edm::InputTag (" siPixelClusters" ));
102106 desc.add <edm::InputTag>(" stripClusterSrc" , edm::InputTag (" siStripClusters" ));
107+ desc.add <edm::InputTag>(" stripClusterOtherSrc" , edm::InputTag (" " ));
103108 desc.add <edm::InputTag>(" phase2OTClusterSrc" , edm::InputTag (" siPhase2Clusters" ));
104109 desc.add <edm::InputTag>(" trackingParticleSrc" , edm::InputTag (" mix" , " MergedTrackTruth" ));
105110 desc.add <bool >(" throwOnMissingCollections" , true );
@@ -115,6 +120,12 @@ void ClusterTPAssociationProducer::produce(edm::StreamID, edm::Event& iEvent, co
115120 edm::Handle<edmNew::DetSetVector<SiStripCluster> > stripClusters;
116121 bool foundStripClusters = iEvent.getByToken (stripClustersToken_, stripClusters);
117122
123+ // Strip Cluster (other product, if there)
124+ bool foundOtherStripClusters = false ;
125+ edm::Handle<edmNew::DetSetVector<SiStripCluster> > stripClustersOther;
126+ if (otherStripClusterTag_ != edm::InputTag (" " ))
127+ foundOtherStripClusters = iEvent.getByToken (stripClustersOtherToken_, stripClustersOther);
128+
118129 // Phase2 Cluster
119130 edm::Handle<edmNew::DetSetVector<Phase2TrackerCluster1D> > phase2OTClusters;
120131 bool foundPhase2OTClusters = iEvent.getByToken (phase2OTClustersToken_, phase2OTClusters);
@@ -129,9 +140,10 @@ void ClusterTPAssociationProducer::produce(edm::StreamID, edm::Event& iEvent, co
129140 }
130141
131142 // SiStrip DigiSimLink
143+ bool foundAnyStripClusters = (foundStripClusters || foundOtherStripClusters);
132144 edm::Handle<edm::DetSetVector<StripDigiSimLink> > sistripSimLinks;
133145 auto stripSimLinksFound = iEvent.getByToken (sistripSimLinksToken_, sistripSimLinks);
134- if (not throwOnMissingCollections_ and foundStripClusters and not stripSimLinksFound) {
146+ if (not throwOnMissingCollections_ and foundAnyStripClusters and not stripSimLinksFound) {
135147 auto clusterTPList = std::make_unique<ClusterTPAssociation>();
136148 iEvent.put (std::move (clusterTPList));
137149 return ;
@@ -244,6 +256,43 @@ void ClusterTPAssociationProducer::produce(edm::StreamID, edm::Event& iEvent, co
244256 }
245257 }
246258
259+ if (foundOtherStripClusters) {
260+ // Strip Clusters (other product, if there)
261+ clusterTPList->addKeyID (stripClustersOther.id ());
262+ for (edmNew::DetSetVector<SiStripCluster>::const_iterator iter = stripClustersOther->begin (false ),
263+ eter = stripClustersOther->end (false );
264+ iter != eter;
265+ ++iter) {
266+ if (!(*iter).isValid ())
267+ continue ;
268+ uint32_t detid = iter->id ();
269+ DetId detId (detid);
270+ edmNew::DetSet<SiStripCluster> link_strip = (*iter);
271+ for (edmNew::DetSet<SiStripCluster>::const_iterator di = link_strip.begin (); di != link_strip.end (); di++) {
272+ const SiStripCluster& cluster = (*di);
273+ edm::Ref<edmNew::DetSetVector<SiStripCluster>, SiStripCluster> c_ref =
274+ edmNew::makeRefTo (stripClustersOther, di);
275+
276+ simTkIds.clear ();
277+ int first = cluster.firstStrip ();
278+ int last = first + cluster.amplitudes ().size ();
279+
280+ for (int istr = first; istr < last; ++istr) {
281+ trkid.clear ();
282+ getSimTrackId<StripDigiSimLink>(trkid, sistripSimLinks, detId, istr);
283+ simTkIds.insert (trkid.begin (), trkid.end ());
284+ }
285+ for (auto iset = simTkIds.begin (); iset != simTkIds.end (); iset++) {
286+ auto ipos = mapping.find (*iset);
287+ if (ipos != mapping.end ()) {
288+ // std::cout << "cluster in detid: " << detid << " from tp: " << ipos->second.key() << " " << iset->first << std::endl;
289+ clusterTPList->emplace_back (OmniClusterRef (c_ref), ipos->second );
290+ }
291+ }
292+ }
293+ }
294+ }
295+
247296 if (foundPhase2OTClusters) {
248297 // Phase2 Clusters
249298 clusterTPList->addKeyID (phase2OTClusters.id ());
0 commit comments