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  ~StubAssociator() override {}
41 
42  private:
43  void beginRun(const Run&, const EventSetup&) override;
44  void produce(Event&, const EventSetup&) override;
45  void endJob() {}
46  // helper classe to store configurations
47  const Setup* setup_ = nullptr;
48  // ED input token of TTStubs
50  // ED input token of TTClusterAssociation
52  // ED output token for recosntructable stub association
54  // ED output token for selected stub association
56  // Setup token
58  };
59 
61  // book in- and output ed products
62  getTokenTTStubDetSetVec_ = consumes<TTStubDetSetVec>(iConfig.getParameter<InputTag>("InputTagTTStubDetSetVec"));
63  getTokenTTClusterAssMap_ = consumes<TTClusterAssMap>(iConfig.getParameter<InputTag>("InputTagTTClusterAssMap"));
64  putTokenReconstructable_ = produces<StubAssociation>(iConfig.getParameter<string>("BranchReconstructable"));
65  putTokenSelection_ = produces<StubAssociation>(iConfig.getParameter<string>("BranchSelection"));
66  // book ES product
67  esGetTokenSetup_ = esConsumes<Setup, SetupRcd, Transition::BeginRun>();
68  }
69 
70  void StubAssociator::beginRun(const Run& iRun, const EventSetup& iSetup) {
71  setup_ = &iSetup.getData(esGetTokenSetup_);
72  }
73 
74  void StubAssociator::produce(Event& iEvent, const EventSetup& iSetup) {
75  // associate TTStubs with TrackingParticles
76  Handle<TTStubDetSetVec> handleTTStubDetSetVec;
77  iEvent.getByToken<TTStubDetSetVec>(getTokenTTStubDetSetVec_, handleTTStubDetSetVec);
78  Handle<TTClusterAssMap> handleTTClusterAssMap;
79  Handle<TTStubAssMap> handleTTStubAssMap;
80  iEvent.getByToken<TTClusterAssMap>(getTokenTTClusterAssMap_, handleTTClusterAssMap);
81  map<TPPtr, vector<TTStubRef>> mapTPPtrsTTStubRefs;
82  auto isNonnull = [](const TPPtr& tpPtr) { return tpPtr.isNonnull(); };
83  for (TTStubDetSetVec::const_iterator ttModule = handleTTStubDetSetVec->begin();
84  ttModule != handleTTStubDetSetVec->end();
85  ttModule++) {
86  for (TTStubDetSet::const_iterator ttStub = ttModule->begin(); ttStub != ttModule->end(); ttStub++) {
87  const TTStubRef ttStubRef = makeRefTo(handleTTStubDetSetVec, ttStub);
88  set<TPPtr> tpPtrs;
89  for (unsigned int iClus = 0; iClus < 2; iClus++) {
90  const vector<TPPtr>& assocPtrs =
91  handleTTClusterAssMap->findTrackingParticlePtrs(ttStubRef->clusterRef(iClus));
92  copy_if(assocPtrs.begin(), assocPtrs.end(), inserter(tpPtrs, tpPtrs.begin()), isNonnull);
93  }
94  for (const TPPtr& tpPtr : tpPtrs)
95  mapTPPtrsTTStubRefs[tpPtr].push_back(ttStubRef);
96  }
97  }
98  // associate reconstructable TrackingParticles with TTStubs
99  StubAssociation reconstructable(setup_);
100  StubAssociation selection(setup_);
101  for (const auto& p : mapTPPtrsTTStubRefs) {
102  if (!setup_->useForReconstructable(*p.first) || !setup_->reconstructable(p.second))
103  continue;
104  reconstructable.insert(p.first, p.second);
105  if (setup_->useForAlgEff(*p.first))
106  selection.insert(p.first, p.second);
107  }
108  iEvent.emplace(putTokenReconstructable_, std::move(reconstructable));
109  iEvent.emplace(putTokenSelection_, std::move(selection));
110  }
111 
112 } // namespace tt
113 
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
Class to process and provide run-time constants used by Track Trigger emulators.
Definition: Setup.h:44
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
Stores association of Truth Particles (TP) to L1 Track-Trigger Clusters.
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.
~StubAssociator() override
EDPutTokenT< StubAssociation > putTokenSelection_
def move(src, dest)
Definition: eostools.py:511
Definition: Run.h:45