CMS 3D CMS Logo

StubAssociator.cc
Go to the documentation of this file.
11 
15 
16 #include <vector>
17 #include <map>
18 #include <set>
19 #include <algorithm>
20 #include <iterator>
21 #include <cmath>
22 
23 using namespace std;
24 using namespace edm;
25 
26 namespace tt {
27 
38  public:
39  explicit StubAssociator(const ParameterSet&);
40 
41  private:
42  void produce(StreamID, Event&, const EventSetup&) const override;
43  // ED input token of TTStubs
45  // ED input token of TTClusterAssociation
47  // ED output token for recosntructable stub association
49  // ED output token for selected stub association
51  // Setup token
53  };
54 
56  // book in- and output ed products
57  getTokenTTStubDetSetVec_ = consumes<TTStubDetSetVec>(iConfig.getParameter<InputTag>("InputTagTTStubDetSetVec"));
58  getTokenTTClusterAssMap_ = consumes<TTClusterAssMap>(iConfig.getParameter<InputTag>("InputTagTTClusterAssMap"));
59  putTokenReconstructable_ = produces<StubAssociation>(iConfig.getParameter<string>("BranchReconstructable"));
60  putTokenSelection_ = produces<StubAssociation>(iConfig.getParameter<string>("BranchSelection"));
61  // book ES product
62  esGetTokenSetup_ = esConsumes<Setup, SetupRcd>();
63  }
64 
65  void StubAssociator::produce(StreamID, Event& iEvent, const EventSetup& iSetup) const {
66  auto const& setup = iSetup.getData(esGetTokenSetup_);
67 
68  // associate TTStubs with TrackingParticles
69  Handle<TTStubDetSetVec> handleTTStubDetSetVec = iEvent.getHandle(getTokenTTStubDetSetVec_);
70  auto const& ttClusterAssMap = iEvent.get(getTokenTTClusterAssMap_);
71 
72  map<TPPtr, vector<TTStubRef>> mapTPPtrsTTStubRefs;
73  auto isNonnull = [](const TPPtr& tpPtr) { return tpPtr.isNonnull(); };
74  for (TTStubDetSetVec::const_iterator ttModule = handleTTStubDetSetVec->begin();
75  ttModule != handleTTStubDetSetVec->end();
76  ttModule++) {
77  for (TTStubDetSet::const_iterator ttStub = ttModule->begin(); ttStub != ttModule->end(); ttStub++) {
78  const TTStubRef ttStubRef = makeRefTo(handleTTStubDetSetVec, ttStub);
79  set<TPPtr> tpPtrs;
80  for (unsigned int iClus = 0; iClus < 2; iClus++) {
81  const vector<TPPtr>& assocPtrs = ttClusterAssMap.findTrackingParticlePtrs(ttStubRef->clusterRef(iClus));
82  copy_if(assocPtrs.begin(), assocPtrs.end(), inserter(tpPtrs, tpPtrs.begin()), isNonnull);
83  }
84  for (const TPPtr& tpPtr : tpPtrs)
85  mapTPPtrsTTStubRefs[tpPtr].push_back(ttStubRef);
86  }
87  }
88  // associate reconstructable TrackingParticles with TTStubs
89  StubAssociation reconstructable(&setup);
91  for (const auto& p : mapTPPtrsTTStubRefs) {
92  if (!setup.useForReconstructable(*p.first) || !setup.reconstructable(p.second))
93  continue;
94  reconstructable.insert(p.first, p.second);
95  if (setup.useForAlgEff(*p.first))
96  selection.insert(p.first, p.second);
97  }
98  iEvent.emplace(putTokenReconstructable_, std::move(reconstructable));
99  iEvent.emplace(putTokenSelection_, std::move(selection));
100  }
101 
102 } // namespace tt
103 
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
EDPutTokenT< StubAssociation > putTokenReconstructable_
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
Definition: EventSetup.h:119
selection
main part
Definition: corrVsCorr.py:100
data_type const * const_iterator
Definition: DetSetNew.h:31
Class to associate reconstrucable TrackingParticles with TTStubs and vice versa. It may associate mul...
const_iterator end(bool update=false) const
int iEvent
Definition: GenABIO.cc:224
Definition: TTTypes.h:54
ESGetToken< Setup, SetupRcd > esGetTokenSetup_
Ref< typename HandleT::element_type, typename HandleT::element_type::value_type::value_type > makeRefTo(const HandleT &iHandle, det_id_type iDetID, typename HandleT::element_type::value_type::const_iterator itIter)
Definition: DetSetVector.h:409
Class to associate reconstrucable TrackingParticles with TTStubs and vice versa It may associate mult...
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
boost::transform_iterator< IterHelp, const_IdIter > const_iterator
const_iterator begin(bool update=false) const
void insert(const TPPtr &tpPtr, const std::vector< TTStubRef > &ttSTubRefs)
EDGetTokenT< TTStubDetSetVec > getTokenTTStubDetSetVec_
EDGetTokenT< TTClusterAssMap > getTokenTTClusterAssMap_
HLT enums.
EDPutTokenT< StubAssociation > putTokenSelection_
def move(src, dest)
Definition: eostools.py:511