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 final
 
bool wantsGlobalRuns () const final
 
bool wantsInputProcessBlocks () const final
 
bool wantsProcessBlocks () const final
 
bool wantsStreamLuminosityBlocks () const final
 
bool wantsStreamRuns () const 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
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESProxyIndex > 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
 
bool registeredToConsumeMany (TypeID const &, 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::ESRecordsToProxyIndices 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
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 ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
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 203 of file ProtonProducer.cc.

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

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

Referenced by produce(), and ProtonProducer().

◆ tokenRecoProtonsMultiRP_

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

Definition at line 213 of file ProtonProducer.cc.

Referenced by produce().

◆ tokenRecoProtonsSingleRP_

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

Definition at line 214 of file ProtonProducer.cc.

Referenced by produce().

◆ tokenTracksLite_

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

Definition at line 215 of file ProtonProducer.cc.

Referenced by produce().