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 
47  // helper classe to store configurations
48  const Setup* setup_ = nullptr;
49  // ED input token of TTStubs
51  // ED input token of TTClusterAssociation
53  // ED output token for recosntructable stub association
55  // ED output token for selected stub association
57  // Setup token
59  };
60 
62  // book in- and output ed products
63  getTokenTTStubDetSetVec_ = consumes<TTStubDetSetVec>(iConfig.getParameter<InputTag>("InputTagTTStubDetSetVec"));
64  getTokenTTClusterAssMap_ = consumes<TTClusterAssMap>(iConfig.getParameter<InputTag>("InputTagTTClusterAssMap"));
65  putTokenReconstructable_ = produces<StubAssociation>(iConfig.getParameter<string>("BranchReconstructable"));
66  putTokenSelection_ = produces<StubAssociation>(iConfig.getParameter<string>("BranchSelection"));
67  // book ES product
68  esGetTokenSetup_ = esConsumes<Setup, SetupRcd, Transition::BeginRun>();
69  }
70 
71  void StubAssociator::beginRun(const Run& iRun, const EventSetup& iSetup) {
72  setup_ = &iSetup.getData(esGetTokenSetup_);
73  }
74 
75  void StubAssociator::produce(Event& iEvent, const EventSetup& iSetup) {
76  // associate TTStubs with TrackingParticles
77  Handle<TTStubDetSetVec> handleTTStubDetSetVec;
78  iEvent.getByToken<TTStubDetSetVec>(getTokenTTStubDetSetVec_, handleTTStubDetSetVec);
79  Handle<TTClusterAssMap> handleTTClusterAssMap;
80  Handle<TTStubAssMap> handleTTStubAssMap;
81  iEvent.getByToken<TTClusterAssMap>(getTokenTTClusterAssMap_, handleTTClusterAssMap);
82  map<TPPtr, vector<TTStubRef>> mapTPPtrsTTStubRefs;
83  auto isNonnull = [](const TPPtr& tpPtr) { return tpPtr.isNonnull(); };
84  for (TTStubDetSetVec::const_iterator ttModule = handleTTStubDetSetVec->begin();
85  ttModule != handleTTStubDetSetVec->end();
86  ttModule++) {
87  for (TTStubDetSet::const_iterator ttStub = ttModule->begin(); ttStub != ttModule->end(); ttStub++) {
88  const TTStubRef ttStubRef = makeRefTo(handleTTStubDetSetVec, ttStub);
89  set<TPPtr> tpPtrs;
90  for (unsigned int iClus = 0; iClus < 2; iClus++) {
91  const vector<TPPtr>& assocPtrs =
92  handleTTClusterAssMap->findTrackingParticlePtrs(ttStubRef->clusterRef(iClus));
93  copy_if(assocPtrs.begin(), assocPtrs.end(), inserter(tpPtrs, tpPtrs.begin()), isNonnull);
94  }
95  for (const TPPtr& tpPtr : tpPtrs)
96  mapTPPtrsTTStubRefs[tpPtr].push_back(ttStubRef);
97  }
98  }
99  // associate reconstructable TrackingParticles with TTStubs
100  StubAssociation reconstructable(setup_);
101  StubAssociation selection(setup_);
102  for (const auto& p : mapTPPtrsTTStubRefs) {
103  if (!setup_->useForReconstructable(*p.first) || !setup_->reconstructable(p.second))
104  continue;
105  reconstructable.insert(p.first, p.second);
106  if (setup_->useForAlgEff(*p.first))
107  selection.insert(p.first, p.second);
108  }
109  iEvent.emplace(putTokenReconstructable_, std::move(reconstructable));
110  iEvent.emplace(putTokenSelection_, std::move(selection));
111  }
112 
113 } // namespace tt
114 
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
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:418
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