CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Protected Attributes
ProtonProducer Class Reference

#include <PhysicsTools/NanoAOD/plugins/ProtonProducer.cc>

Inheritance diagram for ProtonProducer:
edm::global::EDProducer<> edm::global::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

void produce (edm::StreamID id, edm::Event &iEvent, const edm::EventSetup &iSetup) const override
 
 ProtonProducer (edm::ParameterSet const &ps)
 
 ~ProtonProducer () override
 
- Public Member Functions inherited from edm::global::EDProducer<>
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
EDProduceroperator= (const EDProducer &)=delete
 
bool wantsGlobalLuminosityBlocks () const noexcept final
 
bool wantsGlobalRuns () const noexcept final
 
bool wantsInputProcessBlocks () const noexcept final
 
bool wantsProcessBlocks () const noexcept final
 
bool wantsStreamLuminosityBlocks () const noexcept final
 
bool wantsStreamRuns () const noexcept final
 
- Public Member Functions inherited from edm::global::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDProducerBase () override
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
std::vector< edm::ProductResolverIndex > const & putTokenIndexToProductResolverIndex () const
 
std::vector< bool > const & recordProvenanceList () const
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription const &)> registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, ModuleToResolverIndicies const &iIndicies, std::string const &moduleLabel)
 
TypeLabelList const & typeLabelList () const
 used by the fwk to register the list of products of this module More...
 
 ~ProducerBase () noexcept(false) override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESResolverIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESResolverIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex > const & esGetTokenRecordIndicesVector (edm::Transition iTrans) const
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::array< std::vector< ModuleDescription const *> *, NumBranchTypes > &modulesAll, std::vector< ModuleProcessName > &modulesInPreviousProcesses, ProductRegistry const &preg, std::map< std::string, ModuleDescription const *> const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
void selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProductResolverIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 
- Static Public Member Functions inherited from edm::global::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 

Protected Attributes

const bool storeSingleRPProtons_
 
const edm::EDGetTokenT< reco::ForwardProtonCollectiontokenRecoProtonsMultiRP_
 
const edm::EDGetTokenT< reco::ForwardProtonCollectiontokenRecoProtonsSingleRP_
 
const edm::EDGetTokenT< std::vector< CTPPSLocalTrackLite > > tokenTracksLite_
 

Additional Inherited Members

- Public Types inherited from edm::global::EDProducerBase
typedef EDProducerBase ModuleType
 
- Public Types inherited from edm::ProducerBase
template<typename T >
using BranchAliasSetterT = ProductRegistryHelper::BranchAliasSetterT< T >
 
using ModuleToResolverIndicies = std::unordered_multimap< std::string, std::tuple< edm::TypeID const *, const char *, edm::ProductResolverIndex > >
 
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Protected Member Functions inherited from edm::ProducerBase
template<Transition Tr = Transition::Event>
auto produces (std::string instanceName) noexcept
 declare what type of product will make and with which optional label More...
 
template<Transition B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<BranchType B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<class ProductType >
BranchAliasSetterT< ProductType > produces ()
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces ()
 
template<class ProductType >
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces ()
 
template<Transition Tr = Transition::Event>
auto produces () noexcept
 
ProducesCollector producesCollector ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< Bconsumes (edm::InputTag tag) noexcept
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes ()
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag)
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
void resetItemsToGetFrom (BranchType iType)
 

Detailed Description

Description: Realavent proton variables for analysis usage Implementation:

Definition at line 44 of file ProtonProducer.cc.

Constructor & Destructor Documentation

◆ ProtonProducer()

ProtonProducer::ProtonProducer ( edm::ParameterSet const &  ps)
inline

Definition at line 46 of file ProtonProducer.cc.

References storeSingleRPProtons_.

48  mayConsume<reco::ForwardProtonCollection>(ps.getParameter<edm::InputTag>("tagRecoProtonsMulti"))),
50  mayConsume<reco::ForwardProtonCollection>(ps.getParameter<edm::InputTag>("tagRecoProtonsSingle"))),
51  tokenTracksLite_(mayConsume<std::vector<CTPPSLocalTrackLite>>(ps.getParameter<edm::InputTag>("tagTrackLite"))),
52  storeSingleRPProtons_(ps.getParameter<bool>("storeSingleRPProtons")) {
53  produces<edm::ValueMap<int>>("arm");
54  produces<nanoaod::FlatTable>("ppsTrackTable");
56  produces<edm::ValueMap<int>>("protonRPId");
57  }
const edm::EDGetTokenT< reco::ForwardProtonCollection > tokenRecoProtonsMultiRP_
const edm::EDGetTokenT< reco::ForwardProtonCollection > tokenRecoProtonsSingleRP_
const edm::EDGetTokenT< std::vector< CTPPSLocalTrackLite > > tokenTracksLite_
EDGetTokenT< ProductType > mayConsume(edm::InputTag const &tag)
const bool storeSingleRPProtons_

◆ ~ProtonProducer()

ProtonProducer::~ProtonProducer ( )
inlineoverride

Definition at line 58 of file ProtonProducer.cc.

58 {}

Member Function Documentation

◆ fillDescriptions()

static void ProtonProducer::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
inlinestatic

Definition at line 199 of file ProtonProducer.cc.

References edm::ConfigurationDescriptions::add(), and submitPVResolutionJobs::desc.

199  {
201  desc.add<edm::InputTag>("tagRecoProtonsMulti")->setComment("multiRP proton collection");
202  desc.add<edm::InputTag>("tagRecoProtonsSingle")->setComment("singleRP proton collection");
203  desc.add<edm::InputTag>("tagTrackLite")->setComment("pps local tracks lite collection");
204  desc.add<bool>("storeSingleRPProtons")->setComment("flag to store singleRP protons and associated tracks");
205  descriptions.add("ProtonProducer", desc);
206  }
void add(std::string const &label, ParameterSetDescription const &psetDescription)

◆ produce()

void ProtonProducer::produce ( edm::StreamID  id,
edm::Event iEvent,
const edm::EventSetup iSetup 
) const
inlineoverridevirtual

Implements edm::global::EDProducerBase.

Definition at line 61 of file ProtonProducer.cc.

References CTPPSDetId::arm(), protons_cff::decRPId, edm::helper::Filler< Map >::fill(), newFWLiteAna::found, iEvent, edm::helper::Filler< Map >::insert(), eostools::move(), storeSingleRPProtons_, tokenRecoProtonsMultiRP_, tokenRecoProtonsSingleRP_, and tokenTracksLite_.

61  {
62  // Get Forward Proton handle
63  auto hRecoProtonsMultiRP = iEvent.getHandle(tokenRecoProtonsMultiRP_);
64  auto hRecoProtonsSingleRP = iEvent.getHandle(tokenRecoProtonsSingleRP_);
65 
66  // Get PPS Local Track handle
67  auto ppsTracksLite = iEvent.getHandle(tokenTracksLite_);
68 
69  // book output variables for protons
70  std::vector<int> multiRP_arm;
71 
72  // book output variables for tracks
73  std::vector<float> trackX, trackY, trackTime, trackTimeUnc;
74  std::vector<int> multiRPProtonIdx, decRPId, rpType;
75  std::vector<int> singleRPProtonIdx, singleRP_protonRPId;
76 
78  // process single-RP protons
79  {
80  const auto &num_proton = hRecoProtonsSingleRP->size();
81  singleRP_protonRPId.reserve(num_proton);
82 
83  for (const auto &proton : *hRecoProtonsSingleRP) {
84  CTPPSDetId rpId((*proton.contributingLocalTracks().begin())->rpId());
85  unsigned int rpDecId = rpId.arm() * 100 + rpId.station() * 10 + rpId.rp();
86  singleRP_protonRPId.push_back(rpDecId);
87  }
88  }
89 
90  // process multi-RP protons
91  {
92  const auto &num_proton = hRecoProtonsMultiRP->size();
93  multiRP_arm.reserve(num_proton);
94 
95  for (const auto &proton : *hRecoProtonsMultiRP) {
96  multiRP_arm.push_back((proton.pz() < 0.) ? 1 : 0);
97  }
98  }
99 
100  // process local tracks
101  for (unsigned int tr_idx = 0; tr_idx < ppsTracksLite->size(); ++tr_idx) {
102  const auto &tr = ppsTracksLite->at(tr_idx);
103 
104  bool found = false;
105 
106  CTPPSDetId rpId(tr.rpId());
107  unsigned int rpDecId = rpId.arm() * 100 + rpId.station() * 10 + rpId.rp();
108 
109  signed int singleRP_idx = -1;
110  for (unsigned int p_idx = 0; p_idx < hRecoProtonsSingleRP->size(); ++p_idx) {
111  const auto &proton = hRecoProtonsSingleRP->at(p_idx);
112 
113  for (const auto &ref : proton.contributingLocalTracks()) {
114  if (ref.key() == tr_idx) {
115  singleRP_idx = p_idx;
116  found = true;
117  }
118  }
119  }
120 
121  signed int multiRP_idx = -1;
122  for (unsigned int p_idx = 0; p_idx < hRecoProtonsMultiRP->size(); ++p_idx) {
123  const auto &proton = hRecoProtonsMultiRP->at(p_idx);
124 
125  for (const auto &ref : proton.contributingLocalTracks()) {
126  if (ref.key() == tr_idx) {
127  multiRP_idx = p_idx;
128  found = true;
129  }
130  }
131  }
132 
133  if (found) {
134  singleRPProtonIdx.push_back(singleRP_idx);
135  multiRPProtonIdx.push_back(multiRP_idx);
136  decRPId.push_back(rpDecId);
137  rpType.push_back(rpId.subdetId());
138  trackX.push_back(tr.x());
139  trackY.push_back(tr.y());
140  trackTime.push_back(tr.time());
141  trackTimeUnc.push_back(tr.timeUnc());
142  }
143  }
144  }
145 
146  else {
147  for (unsigned int p_idx = 0; p_idx < hRecoProtonsMultiRP->size(); ++p_idx) {
148  const auto &proton = hRecoProtonsMultiRP->at(p_idx);
149  multiRP_arm.push_back((proton.pz() < 0.) ? 1 : 0);
150 
151  for (const auto &ref : proton.contributingLocalTracks()) {
152  multiRPProtonIdx.push_back(p_idx);
153  CTPPSDetId rpId(ref->rpId());
154  unsigned int rpDecId = rpId.arm() * 100 + rpId.station() * 10 + rpId.rp();
155  decRPId.push_back(rpDecId);
156  rpType.push_back(rpId.subdetId());
157  trackX.push_back(ref->x());
158  trackY.push_back(ref->y());
159  trackTime.push_back(ref->time());
160  trackTimeUnc.push_back(ref->timeUnc());
161  }
162  }
163  }
164 
165  // update proton tables
166  std::unique_ptr<edm::ValueMap<int>> multiRP_armV(new edm::ValueMap<int>());
167  edm::ValueMap<int>::Filler fillermultiArm(*multiRP_armV);
168  fillermultiArm.insert(hRecoProtonsMultiRP, multiRP_arm.begin(), multiRP_arm.end());
169  fillermultiArm.fill();
170 
171  std::unique_ptr<edm::ValueMap<int>> protonRPIdV(new edm::ValueMap<int>());
172  edm::ValueMap<int>::Filler fillerID(*protonRPIdV);
173  if (storeSingleRPProtons_) {
174  fillerID.insert(hRecoProtonsSingleRP, singleRP_protonRPId.begin(), singleRP_protonRPId.end());
175  fillerID.fill();
176  }
177 
178  // build track table
179  auto ppsTab = std::make_unique<nanoaod::FlatTable>(trackX.size(), "PPSLocalTrack", false);
180  ppsTab->addColumn<int>("multiRPProtonIdx", multiRPProtonIdx, "local track - proton correspondence");
182  ppsTab->addColumn<int>("singleRPProtonIdx", singleRPProtonIdx, "local track - proton correspondence");
183  ppsTab->addColumn<float>("x", trackX, "local track x", 16);
184  ppsTab->addColumn<float>("y", trackY, "local track y", 13);
185  ppsTab->addColumn<float>("time", trackTime, "local track time", 16);
186  ppsTab->addColumn<float>("timeUnc", trackTimeUnc, "local track time uncertainty", 13);
187  ppsTab->addColumn<int>("decRPId", decRPId, "local track detector dec id");
188  ppsTab->addColumn<int>("rpType", rpType, "strip=3, pixel=4, diamond=5, timing=6");
189  ppsTab->setDoc("ppsLocalTrack variables");
190 
191  // save output
192  iEvent.put(std::move(multiRP_armV), "arm");
193  iEvent.put(std::move(ppsTab), "ppsTrackTable");
195  iEvent.put(std::move(protonRPIdV), "protonRPId");
196  }
const edm::EDGetTokenT< reco::ForwardProtonCollection > tokenRecoProtonsMultiRP_
uint32_t arm() const
Definition: CTPPSDetId.h:57
int iEvent
Definition: GenABIO.cc:224
const edm::EDGetTokenT< reco::ForwardProtonCollection > tokenRecoProtonsSingleRP_
Base class for CTPPS detector IDs.
Definition: CTPPSDetId.h:32
const edm::EDGetTokenT< std::vector< CTPPSLocalTrackLite > > tokenTracksLite_
const bool storeSingleRPProtons_
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

◆ storeSingleRPProtons_

const bool ProtonProducer::storeSingleRPProtons_
protected

Definition at line 212 of file ProtonProducer.cc.

Referenced by produce(), and ProtonProducer().

◆ tokenRecoProtonsMultiRP_

const edm::EDGetTokenT<reco::ForwardProtonCollection> ProtonProducer::tokenRecoProtonsMultiRP_
protected

Definition at line 209 of file ProtonProducer.cc.

Referenced by produce().

◆ tokenRecoProtonsSingleRP_

const edm::EDGetTokenT<reco::ForwardProtonCollection> ProtonProducer::tokenRecoProtonsSingleRP_
protected

Definition at line 210 of file ProtonProducer.cc.

Referenced by produce().

◆ tokenTracksLite_

const edm::EDGetTokenT<std::vector<CTPPSLocalTrackLite> > ProtonProducer::tokenTracksLite_
protected

Definition at line 211 of file ProtonProducer.cc.

Referenced by produce().