CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
AlCaHBHEMuonProducer Class Reference
Inheritance diagram for AlCaHBHEMuonProducer:
edm::stream::EDProducer< edm::GlobalCache< AlCaHBHEMuons::Counters > >

Public Member Functions

 AlCaHBHEMuonProducer (edm::ParameterSet const &, const AlCaHBHEMuons::Counters *count)
 
void endStream () override
 
void produce (edm::Event &, const edm::EventSetup &) override
 
 ~AlCaHBHEMuonProducer () override
 
- Public Member Functions inherited from edm::stream::EDProducer< edm::GlobalCache< AlCaHBHEMuons::Counters > >
 EDProducer ()=default
 
bool hasAbilityToProduceInLumis () const final
 
bool hasAbilityToProduceInRuns () const final
 

Static Public Member Functions

static void globalEndJob (const AlCaHBHEMuons::Counters *counters)
 
static std::unique_ptr< AlCaHBHEMuons::CountersinitializeGlobalCache (edm::ParameterSet const &)
 

Private Member Functions

void beginRun (edm::Run const &, edm::EventSetup const &) override
 
void endRun (edm::Run const &, edm::EventSetup const &) override
 
bool select (const reco::MuonCollection &)
 

Private Attributes

edm::InputTag labelBS_
 
edm::InputTag labelEB_
 
edm::InputTag labelEE_
 
edm::InputTag labelHBHE_
 
edm::InputTag labelMuon_
 
edm::InputTag labelVtx_
 
unsigned int nAll_
 
unsigned int nGood_
 
unsigned int nRun_
 
double pMuonMin_
 
edm::EDGetTokenT< reco::BeamSpottok_BS_
 
edm::EDGetTokenT< EcalRecHitCollectiontok_EB_
 
edm::EDGetTokenT< EcalRecHitCollectiontok_EE_
 
edm::EDGetTokenT< HBHERecHitCollectiontok_HBHE_
 
edm::EDGetTokenT< reco::MuonCollectiontok_Muon_
 
edm::EDGetTokenT< reco::VertexCollectiontok_Vtx_
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer< edm::GlobalCache< AlCaHBHEMuons::Counters > >
typedef CacheContexts< T... > CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T... > HasAbility
 
typedef CacheTypes::LuminosityBlockCache LuminosityBlockCache
 
typedef LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 

Detailed Description

Definition at line 48 of file AlCaHBHEMuonProducer.cc.

Constructor & Destructor Documentation

AlCaHBHEMuonProducer::AlCaHBHEMuonProducer ( edm::ParameterSet const &  iConfig,
const AlCaHBHEMuons::Counters count 
)
explicit

Definition at line 80 of file AlCaHBHEMuonProducer.cc.

References edm::ParameterSet::getParameter(), edm::InputTag::instance(), edm::InputTag::label(), labelBS_, labelEB_, labelEE_, labelHBHE_, labelMuon_, labelVtx_, pMuonMin_, tok_BS_, tok_EB_, tok_EE_, tok_HBHE_, tok_Muon_, and tok_Vtx_.

81  : nRun_(0), nAll_(0), nGood_(0) {
82  //Get the run parameters
83  labelBS_ = iConfig.getParameter<edm::InputTag>("BeamSpotLabel");
84  labelVtx_ = iConfig.getParameter<edm::InputTag>("VertexLabel");
85  labelEB_ = iConfig.getParameter<edm::InputTag>("EBRecHitLabel");
86  labelEE_ = iConfig.getParameter<edm::InputTag>("EERecHitLabel");
87  labelHBHE_ = iConfig.getParameter<edm::InputTag>("HBHERecHitLabel");
88  labelMuon_ = iConfig.getParameter<edm::InputTag>("MuonLabel");
89  pMuonMin_ = iConfig.getParameter<double>("MinimumMuonP");
90 
91  // define tokens for access
92  tok_Vtx_ = consumes<reco::VertexCollection>(labelVtx_);
93  tok_BS_ = consumes<reco::BeamSpot>(labelBS_);
94  tok_EB_ = consumes<EcalRecHitCollection>(labelEB_);
95  tok_EE_ = consumes<EcalRecHitCollection>(labelEE_);
96  tok_HBHE_ = consumes<HBHERecHitCollection>(labelHBHE_);
97  tok_Muon_ = consumes<reco::MuonCollection>(labelMuon_);
98 
99  edm::LogInfo("HcalHBHEMuon") << "Parameters read from config file \n"
100  << "\t minP of muon " << pMuonMin_ << "\t input labels " << labelBS_ << " " << labelVtx_
101  << " " << labelEB_ << " " << labelEE_ << " " << labelHBHE_ << " " << labelMuon_;
102 
103  //saves the following collections
104  produces<reco::BeamSpot>(labelBS_.label());
105  produces<reco::VertexCollection>(labelVtx_.label());
106  produces<EcalRecHitCollection>(labelEB_.instance());
107  produces<EcalRecHitCollection>(labelEE_.instance());
108  produces<HBHERecHitCollection>(labelHBHE_.label());
109  produces<reco::MuonCollection>(labelMuon_.label());
110 }
edm::EDGetTokenT< EcalRecHitCollection > tok_EE_
edm::EDGetTokenT< HBHERecHitCollection > tok_HBHE_
edm::EDGetTokenT< EcalRecHitCollection > tok_EB_
edm::EDGetTokenT< reco::BeamSpot > tok_BS_
std::string const & label() const
Definition: InputTag.h:36
edm::EDGetTokenT< reco::VertexCollection > tok_Vtx_
std::string const & instance() const
Definition: InputTag.h:37
edm::EDGetTokenT< reco::MuonCollection > tok_Muon_
AlCaHBHEMuonProducer::~AlCaHBHEMuonProducer ( )
override

Definition at line 112 of file AlCaHBHEMuonProducer.cc.

112 {}

Member Function Documentation

void AlCaHBHEMuonProducer::beginRun ( edm::Run const &  iRun,
edm::EventSetup const &  iSetup 
)
overrideprivate

Definition at line 226 of file AlCaHBHEMuonProducer.cc.

References nRun_, and edm::RunBase::run().

226  {
227  edm::LogInfo("HcalHBHEMuon") << "Run[" << nRun_ << "] " << iRun.run();
228 }
void AlCaHBHEMuonProducer::endRun ( edm::Run const &  iRun,
edm::EventSetup const &   
)
overrideprivate

Definition at line 230 of file AlCaHBHEMuonProducer.cc.

References nRun_, and edm::RunBase::run().

230  {
231  ++nRun_;
232  edm::LogInfo("HcalHBHEMuon") << "endRun[" << nRun_ << "] " << iRun.run();
233 }
void AlCaHBHEMuonProducer::endStream ( )
override

Definition at line 217 of file AlCaHBHEMuonProducer.cc.

References nAll_, and nGood_.

217  {
218  globalCache()->nAll_ += nAll_;
219  globalCache()->nGood_ += nGood_;
220 }
void AlCaHBHEMuonProducer::globalEndJob ( const AlCaHBHEMuons::Counters counters)
static

Definition at line 222 of file AlCaHBHEMuonProducer.cc.

References AlCaHBHEMuons::Counters::nAll_, and AlCaHBHEMuons::Counters::nGood_.

222  {
223  edm::LogInfo("HcalHBHEMuon") << "Finds " << count->nGood_ << " good tracks in " << count->nAll_ << " events";
224 }
static std::unique_ptr<AlCaHBHEMuons::Counters> AlCaHBHEMuonProducer::initializeGlobalCache ( edm::ParameterSet const &  )
inlinestatic

Definition at line 53 of file AlCaHBHEMuonProducer.cc.

References Ecal2004TBTDCRanges_v1_cff::endRun, and TauGenJetsDecayModeSelectorAllHadrons_cfi::select.

53  {
54  return std::make_unique<AlCaHBHEMuons::Counters>();
55  }
void AlCaHBHEMuonProducer::produce ( edm::Event ,
const edm::EventSetup  
)
override

Definition at line 114 of file AlCaHBHEMuonProducer.cc.

References accept(), reco::BeamSpot::BeamWidthX(), edm::SortedCollection< T, SORT >::begin(), edm::EventBase::bunchCrossing(), reco::BeamSpot::covariance(), reco::BeamSpot::dxdz(), reco::BeamSpot::dydz(), edm::SortedCollection< T, SORT >::end(), edm::EventID::event(), edm::Event::getByToken(), photonIsolationHIProducer_cfi::hbhe, edm::EventBase::id(), edm::InputTag::instance(), edm::HandleBase::isValid(), edm::InputTag::label(), labelBS_, labelEB_, labelEE_, labelHBHE_, labelMuon_, labelVtx_, edm::EventBase::luminosityBlock(), eostools::move(), metsig::muon, extraflags_cff::muons, nAll_, nGood_, reco::BeamSpot::position(), edm::Handle< T >::product(), edm::Event::put(), edm::EventID::run(), select(), reco::BeamSpot::sigmaZ(), tok_BS_, tok_EB_, tok_EE_, tok_HBHE_, tok_Muon_, tok_Vtx_, reco::BeamSpot::type(), and extraflags_cff::vtx.

Referenced by JSONExport.JsonExport::export(), HTMLExport.HTMLExport::export(), and HTMLExport.HTMLExportStatic::export().

114  {
115  ++nAll_;
116  bool valid(true);
117 #ifdef DebugLog
118  edm::LogInfo("HcalHBHEMuon") << "AlCaHBHEMuonProducer::Run " << iEvent.id().run() << " Event " << iEvent.id().event()
119  << " Luminosity " << iEvent.luminosityBlock() << " Bunch " << iEvent.bunchCrossing();
120 #endif
121 
122  //Step1: Get all the relevant containers
124  iEvent.getByToken(tok_BS_, bmspot);
125  if (!bmspot.isValid()) {
126  edm::LogWarning("HcalHBHEMuon") << "AlCaHBHEMuonProducer: Error! can't get product " << labelBS_;
127  valid = false;
128  }
129 
131  iEvent.getByToken(tok_Vtx_, vt);
132  if (!vt.isValid()) {
133  edm::LogWarning("HcalHBHEMuon") << "AlCaHBHEMuonProducer: Error! can't get product " << labelVtx_;
134  valid = false;
135  }
136 
137  edm::Handle<EcalRecHitCollection> barrelRecHitsHandle;
138  iEvent.getByToken(tok_EB_, barrelRecHitsHandle);
139  if (!barrelRecHitsHandle.isValid()) {
140  edm::LogWarning("HcalHBHEMuon") << "AlCaHBHEMuonProducer: Error! can't get product " << labelEB_;
141  valid = false;
142  }
143 
144  edm::Handle<EcalRecHitCollection> endcapRecHitsHandle;
145  iEvent.getByToken(tok_EE_, endcapRecHitsHandle);
146  if (!endcapRecHitsHandle.isValid()) {
147  edm::LogWarning("HcalHBHEMuon") << "AlCaHBHEMuonProducer: Error! can't get product " << labelEE_;
148  valid = false;
149  }
150 
152  iEvent.getByToken(tok_HBHE_, hbhe);
153  if (!hbhe.isValid()) {
154  edm::LogWarning("HcalHBHEMuon") << "AlCaHBHEMuonProducer: Error! can't get product " << labelHBHE_;
155  valid = false;
156  }
157 
159  iEvent.getByToken(tok_Muon_, muonhandle);
160  if (!muonhandle.isValid()) {
161  edm::LogWarning("HcalHBHEMuon") << "AlCaHBHEMuonProducer: Error! can't get product " << labelMuon_;
162  valid = false;
163  }
164 
165 #ifdef DebugLog
166  edm::LogInfo("HcalHBHEMuon") << "AlCaHBHEMuonProducer::obtained the collections with validity flag " << valid;
167 #endif
168 
169  //For accepted events
170  auto outputBeamSpot = std::make_unique<reco::BeamSpot>();
171  auto outputVColl = std::make_unique<reco::VertexCollection>();
172  auto outputEBColl = std::make_unique<EBRecHitCollection>();
173  auto outputEEColl = std::make_unique<EERecHitCollection>();
174  auto outputHBHEColl = std::make_unique<HBHERecHitCollection>();
175  auto outputMColl = std::make_unique<reco::MuonCollection>();
176 
177  if (valid) {
178  const reco::BeamSpot beam = *(bmspot.product());
179  outputBeamSpot = std::make_unique<reco::BeamSpot>(
180  beam.position(), beam.sigmaZ(), beam.dxdz(), beam.dydz(), beam.BeamWidthX(), beam.covariance(), beam.type());
181  const reco::VertexCollection vtx = *(vt.product());
182  const EcalRecHitCollection ebcoll = *(barrelRecHitsHandle.product());
183  const EcalRecHitCollection eecoll = *(endcapRecHitsHandle.product());
184  const HBHERecHitCollection hbhecoll = *(hbhe.product());
185  const reco::MuonCollection muons = *(muonhandle.product());
186 
187  bool accept = select(muons);
188 
189  if (accept) {
190  ++nGood_;
191 
192  for (reco::VertexCollection::const_iterator vtr = vtx.begin(); vtr != vtx.end(); ++vtr)
193  outputVColl->push_back(*vtr);
194 
195  for (edm::SortedCollection<EcalRecHit>::const_iterator ehit = ebcoll.begin(); ehit != ebcoll.end(); ++ehit)
196  outputEBColl->push_back(*ehit);
197 
198  for (edm::SortedCollection<EcalRecHit>::const_iterator ehit = eecoll.begin(); ehit != eecoll.end(); ++ehit)
199  outputEEColl->push_back(*ehit);
200 
201  for (std::vector<HBHERecHit>::const_iterator hhit = hbhecoll.begin(); hhit != hbhecoll.end(); ++hhit)
202  outputHBHEColl->push_back(*hhit);
203 
204  for (reco::MuonCollection::const_iterator muon = muons.begin(); muon != muons.end(); ++muon)
205  outputMColl->push_back(*muon);
206  }
207  }
208 
209  iEvent.put(std::move(outputBeamSpot), labelBS_.label());
210  iEvent.put(std::move(outputVColl), labelVtx_.label());
211  iEvent.put(std::move(outputEBColl), labelEB_.instance());
212  iEvent.put(std::move(outputEEColl), labelEE_.instance());
213  iEvent.put(std::move(outputHBHEColl), labelHBHE_.label());
214  iEvent.put(std::move(outputMColl), labelMuon_.label());
215 }
bool select(const reco::MuonCollection &)
edm::EDGetTokenT< EcalRecHitCollection > tok_EE_
std::vector< T >::const_iterator const_iterator
std::vector< Vertex > VertexCollection
collection of Vertex objects
Definition: VertexFwd.h:9
bool accept(const edm::Event &event, const edm::TriggerResults &triggerTable, const std::string &triggerPath)
Definition: TopDQMHelpers.h:30
std::vector< Muon > MuonCollection
collection of Muon objects
Definition: MuonFwd.h:9
double dydz() const
dydz slope
Definition: BeamSpot.h:84
int iEvent
Definition: GenABIO.cc:224
edm::EDGetTokenT< HBHERecHitCollection > tok_HBHE_
double BeamWidthX() const
beam width X
Definition: BeamSpot.h:86
bool isValid() const
Definition: HandleBase.h:74
double dxdz() const
dxdz slope
Definition: BeamSpot.h:82
const_iterator end() const
T const * product() const
Definition: Handle.h:74
double sigmaZ() const
sigma z
Definition: BeamSpot.h:80
edm::EDGetTokenT< EcalRecHitCollection > tok_EB_
edm::EDGetTokenT< reco::BeamSpot > tok_BS_
std::string const & label() const
Definition: InputTag.h:36
double covariance(int i, int j) const
(i,j)-th element of error matrix
Definition: BeamSpot.h:112
edm::EDGetTokenT< reco::VertexCollection > tok_Vtx_
const Point & position() const
position
Definition: BeamSpot.h:62
std::string const & instance() const
Definition: InputTag.h:37
def move(src, dest)
Definition: eostools.py:511
edm::EDGetTokenT< reco::MuonCollection > tok_Muon_
const_iterator begin() const
BeamType type() const
return beam type
Definition: BeamSpot.h:129
bool AlCaHBHEMuonProducer::select ( const reco::MuonCollection muons)
private

Member Data Documentation

edm::InputTag AlCaHBHEMuonProducer::labelBS_
private

Definition at line 68 of file AlCaHBHEMuonProducer.cc.

Referenced by AlCaHBHEMuonProducer(), and produce().

edm::InputTag AlCaHBHEMuonProducer::labelEB_
private

Definition at line 69 of file AlCaHBHEMuonProducer.cc.

Referenced by AlCaHBHEMuonProducer(), and produce().

edm::InputTag AlCaHBHEMuonProducer::labelEE_
private

Definition at line 69 of file AlCaHBHEMuonProducer.cc.

Referenced by AlCaHBHEMuonProducer(), and produce().

edm::InputTag AlCaHBHEMuonProducer::labelHBHE_
private

Definition at line 69 of file AlCaHBHEMuonProducer.cc.

Referenced by AlCaHBHEMuonProducer(), and produce().

edm::InputTag AlCaHBHEMuonProducer::labelMuon_
private

Definition at line 69 of file AlCaHBHEMuonProducer.cc.

Referenced by AlCaHBHEMuonProducer(), and produce().

edm::InputTag AlCaHBHEMuonProducer::labelVtx_
private

Definition at line 68 of file AlCaHBHEMuonProducer.cc.

Referenced by AlCaHBHEMuonProducer(), and produce().

unsigned int AlCaHBHEMuonProducer::nAll_
private

Definition at line 67 of file AlCaHBHEMuonProducer.cc.

Referenced by endStream(), and produce().

unsigned int AlCaHBHEMuonProducer::nGood_
private

Definition at line 67 of file AlCaHBHEMuonProducer.cc.

Referenced by endStream(), and produce().

unsigned int AlCaHBHEMuonProducer::nRun_
private

Definition at line 67 of file AlCaHBHEMuonProducer.cc.

Referenced by beginRun(), and endRun().

double AlCaHBHEMuonProducer::pMuonMin_
private

Definition at line 70 of file AlCaHBHEMuonProducer.cc.

Referenced by AlCaHBHEMuonProducer(), and select().

edm::EDGetTokenT<reco::BeamSpot> AlCaHBHEMuonProducer::tok_BS_
private

Definition at line 72 of file AlCaHBHEMuonProducer.cc.

Referenced by AlCaHBHEMuonProducer(), and produce().

edm::EDGetTokenT<EcalRecHitCollection> AlCaHBHEMuonProducer::tok_EB_
private

Definition at line 74 of file AlCaHBHEMuonProducer.cc.

Referenced by AlCaHBHEMuonProducer(), and produce().

edm::EDGetTokenT<EcalRecHitCollection> AlCaHBHEMuonProducer::tok_EE_
private

Definition at line 75 of file AlCaHBHEMuonProducer.cc.

Referenced by AlCaHBHEMuonProducer(), and produce().

edm::EDGetTokenT<HBHERecHitCollection> AlCaHBHEMuonProducer::tok_HBHE_
private

Definition at line 76 of file AlCaHBHEMuonProducer.cc.

Referenced by AlCaHBHEMuonProducer(), and produce().

edm::EDGetTokenT<reco::MuonCollection> AlCaHBHEMuonProducer::tok_Muon_
private

Definition at line 77 of file AlCaHBHEMuonProducer.cc.

Referenced by AlCaHBHEMuonProducer(), and produce().

edm::EDGetTokenT<reco::VertexCollection> AlCaHBHEMuonProducer::tok_Vtx_
private

Definition at line 73 of file AlCaHBHEMuonProducer.cc.

Referenced by AlCaHBHEMuonProducer(), and produce().