CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
CSCChamberMasker Class Reference

#include <SimMuon/CSCDigitizer/plugins/CSCChamberMasker.cc>

Inheritance diagram for CSCChamberMasker:
edm::stream::EDProducer<>

Public Member Functions

 CSCChamberMasker (const edm::ParameterSet &)
 
 ~CSCChamberMasker () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
bool hasAbilityToProduceInLumis () const final
 
bool hasAbilityToProduceInRuns () const final
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &)
 

Private Member Functions

template<typename T , typename C = MuonDigiCollection<CSCDetId, T>>
void ageDigis (edm::Event &event, edm::EDGetTokenT< C > &digiToken, CLHEP::HepRandomEngine &randGen, std::unique_ptr< C > &filteredDigis)
 
void beginRun (edm::Run const &, edm::EventSetup const &) override
 
template<typename T , typename C = MuonDigiCollection<CSCDetId, T>>
void copyDigis (edm::Event &event, edm::EDGetTokenT< C > &digiToken, std::unique_ptr< C > &filteredDigis)
 
void createMaskedChamberCollection (edm::ESHandle< CSCGeometry > &)
 
void produce (edm::Event &, const edm::EventSetup &) override
 

Private Attributes

edm::EDGetTokenT< CSCALCTDigiCollectionm_alctDigiToken
 
edm::EDGetTokenT< CSCCLCTDigiCollectionm_clctDigiToken
 
std::map< CSCDetId, std::pair< unsigned int, float > > m_CSCEffs
 
edm::EDGetTokenT< CSCStripDigiCollectionm_stripDigiToken
 
edm::EDGetTokenT< CSCWireDigiCollectionm_wireDigiToken
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
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

Description: Class to mask CSC digis on a chamber by chamber basis

Definition at line 69 of file CSCChamberMasker.cc.

Constructor & Destructor Documentation

CSCChamberMasker::CSCChamberMasker ( const edm::ParameterSet iConfig)
explicit

Definition at line 118 of file CSCChamberMasker.cc.

119  :
120  m_stripDigiToken(consumes<CSCStripDigiCollection>(iConfig.getParameter<edm::InputTag>("stripDigiTag")) )
121  ,m_wireDigiToken(consumes<CSCWireDigiCollection>(iConfig.getParameter<edm::InputTag>("wireDigiTag")) )
122  ,m_clctDigiToken(consumes<CSCCLCTDigiCollection>(iConfig.getParameter<edm::InputTag>("clctDigiTag")) )
123  ,m_alctDigiToken(consumes<CSCALCTDigiCollection>(iConfig.getParameter<edm::InputTag>("alctDigiTag")) )
124 {
125 
126  produces<CSCStripDigiCollection>("MuonCSCStripDigi");
127  produces<CSCWireDigiCollection>("MuonCSCWireDigi");
128  produces<CSCCLCTDigiCollection>("MuonCSCCLCTDigi");
129  produces<CSCALCTDigiCollection>("MuonCSCALCTDigi");
130 
131 }
T getParameter(std::string const &) const
edm::EDGetTokenT< CSCWireDigiCollection > m_wireDigiToken
edm::EDGetTokenT< CSCStripDigiCollection > m_stripDigiToken
edm::EDGetTokenT< CSCCLCTDigiCollection > m_clctDigiToken
edm::EDGetTokenT< CSCALCTDigiCollection > m_alctDigiToken
CSCChamberMasker::~CSCChamberMasker ( )
override

Definition at line 134 of file CSCChamberMasker.cc.

135 {
136 
137 }

Member Function Documentation

template<typename T , typename C >
void CSCChamberMasker::ageDigis ( edm::Event event,
edm::EDGetTokenT< C > &  digiToken,
CLHEP::HepRandomEngine &  randGen,
std::unique_ptr< C > &  filteredDigis 
)
private

Definition at line 203 of file CSCChamberMasker.cc.

References CSCDetId::chamber(), EFF_CHAMBER, EFF_STRIPS, EFF_WIRES, CSCDetId::endcap(), edm::EDGetTokenT< T >::isUninitialized(), plotBeamSpotDB::last, CSCDetId::layer(), m_CSCEffs, CSCDetId::ring(), CSCDetId::station(), and relativeConstraints::value.

207 {
208 
209  if(!digiToken.isUninitialized())
210  {
211  edm::Handle<C> digis;
212  event.getByToken(digiToken, digis);
213 
214  for ( const auto & j : (*digis) )
215  {
216  auto digiItr = j.second.first;
217  auto last = j.second.second;
218 
219  CSCDetId const cscDetId = j.first;
220 
221  // Since lookups are chamber-centric, make new DetId with layer=0
222  CSCDetId chId = CSCDetId(cscDetId.endcap(), cscDetId.station(), cscDetId.ring(), cscDetId.chamber(), 0);
223 
224  for( ; digiItr != last; ++digiItr) {
225 
226  auto chEffIt = m_CSCEffs.find(chId);
227 
228  if (chEffIt != m_CSCEffs.end())
229  {
230 
231  std::pair<unsigned int, float> typeEff = chEffIt->second;
232  int type = typeEff.first % 10; // second digit gives type of inefficiency
233  int layer = typeEff.first/10; // first digit gives layer (0 = chamber level)
234 
235  bool doRandomize = false;
236  if (((std::is_same<T,CSCStripDigi>::value && type == EFF_WIRES) ||
238  type == EFF_CHAMBER) && (layer == 0 || cscDetId.layer() == layer)) doRandomize = true;
239 
240  if (!doRandomize || (randGen.flat() <= typeEff.second)) {
241  filteredDigis->insertDigi(cscDetId,*digiItr);
242  }
243  }
244 
245  }
246  }
247  }
248 }
int chamber() const
Definition: CSCDetId.h:68
type
Definition: HCALResponse.h:21
int layer() const
Definition: CSCDetId.h:61
int endcap() const
Definition: CSCDetId.h:93
int ring() const
Definition: CSCDetId.h:75
bool isUninitialized() const
Definition: EDGetToken.h:73
int station() const
Definition: CSCDetId.h:86
std::map< CSCDetId, std::pair< unsigned int, float > > m_CSCEffs
void CSCChamberMasker::beginRun ( edm::Run const &  run,
edm::EventSetup const &  iSetup 
)
overrideprivate

Definition at line 253 of file CSCChamberMasker.cc.

References CSCDetId::chamber(), CSCGeometry::chambers(), chambers, CSCDetId::endcap(), edm::EventSetup::get(), MuonSystemAging::m_CSCChambEffs, m_CSCEffs, CSCDetId::rawIdMaker(), CSCDetId::ring(), and CSCDetId::station().

254 {
255 
256  m_CSCEffs.clear();
257 
259  iSetup.get<MuonGeometryRecord>().get(cscGeom);
260 
262  iSetup.get<MuonSystemAgingRcd>().get(agingObj);
263 
264  const auto chambers = cscGeom->chambers();
265 
266  for ( const auto * ch : chambers)
267  {
268 
269  CSCDetId chId = ch->id();
270  unsigned int rawId = chId.rawIdMaker(chId.endcap(), chId.station(), chId.ring(), chId.chamber(), 0);
271  float eff = 1.;
272  int type = 0;
273  for ( auto & agingPair : agingObj->m_CSCChambEffs)
274  {
275  if ( agingPair.first != rawId) continue;
276 
277  type = agingPair.second.first;
278  eff = agingPair.second.second;
279  m_CSCEffs[chId] = std::make_pair(type, eff);
280  break;
281  }
282 
283  }
284 
285 }
int chamber() const
Definition: CSCDetId.h:68
type
Definition: HCALResponse.h:21
static int rawIdMaker(int iendcap, int istation, int iring, int ichamber, int ilayer)
Definition: CSCDetId.h:144
const ChamberContainer & chambers() const
Return a vector of all chambers.
Definition: CSCGeometry.cc:121
int endcap() const
Definition: CSCDetId.h:93
std::map< unsigned int, std::pair< unsigned int, float > > m_CSCChambEffs
int ring() const
Definition: CSCDetId.h:75
int station() const
Definition: CSCDetId.h:86
static char chambers[264][20]
Definition: ReadPGInfo.cc:243
std::map< CSCDetId, std::pair< unsigned int, float > > m_CSCEffs
template<typename T , typename C >
void CSCChamberMasker::copyDigis ( edm::Event event,
edm::EDGetTokenT< C > &  digiToken,
std::unique_ptr< C > &  filteredDigis 
)
private

Definition at line 175 of file CSCChamberMasker.cc.

References edm::EDGetTokenT< T >::isUninitialized(), and plotBeamSpotDB::last.

178 {
179 
180  if (!digiToken.isUninitialized())
181  {
182  edm::Handle<C> digis;
183  event.getByToken(digiToken, digis);
184  for ( const auto & j : (*digis) )
185  {
186  auto digiItr = j.second.first;
187  auto last = j.second.second;
188 
189  CSCDetId const cscDetId = j.first;
190 
191  for( ; digiItr != last; ++digiItr)
192  {
193  filteredDigis->insertDigi(cscDetId,*digiItr);
194  }
195  }
196  }
197 
198 }
bool isUninitialized() const
Definition: EDGetToken.h:73
void CSCChamberMasker::createMaskedChamberCollection ( edm::ESHandle< CSCGeometry > &  )
private
void CSCChamberMasker::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 290 of file CSCChamberMasker.cc.

References edm::ConfigurationDescriptions::add(), edm::ParameterSetDescription::add(), and DEFINE_FWK_MODULE.

291 {
292 
294  desc.add<edm::InputTag>("stripDigiTag", edm::InputTag("simMuonCSCDigis:MuonCSCStripDigi"));
295  desc.add<edm::InputTag>("wireDigiTag", edm::InputTag("simMuonCSCDigis:MuonCSCWireDigi"));
296  desc.add<edm::InputTag>("comparatorDigiTag", edm::InputTag("simMuonCSCDigis:MuonCSCComparatorDigi"));
297  desc.add<edm::InputTag>("rpcDigiTag", edm::InputTag("simMuonCSCDigis:MuonCSCRPCDigi"));
298  desc.add<edm::InputTag>("alctDigiTag", edm::InputTag("simMuonCSCDigis:MuonCSCALCTDigi"));
299  desc.add<edm::InputTag>("clctDigiTag", edm::InputTag("simMuonCSCDigis:MuonCSCCLCTDigi"));
300  descriptions.add("cscChamberMasker",desc);
301 
302 }
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
void CSCChamberMasker::produce ( edm::Event event,
const edm::EventSetup conditions 
)
overrideprivate

Definition at line 146 of file CSCChamberMasker.cc.

References event(), edm::RandomNumberGenerator::getEngine(), m_alctDigiToken, m_clctDigiToken, m_stripDigiToken, m_wireDigiToken, eostools::move(), and edm::Event::streamID().

147 {
148 
150  CLHEP::HepRandomEngine& randGen = randGenService->getEngine(event.streamID());
151 
152  std::unique_ptr<CSCStripDigiCollection> filteredStripDigis(new CSCStripDigiCollection());
153  std::unique_ptr<CSCWireDigiCollection> filteredWireDigis(new CSCWireDigiCollection());
154  std::unique_ptr<CSCCLCTDigiCollection> filteredCLCTDigis(new CSCCLCTDigiCollection());
155  std::unique_ptr<CSCALCTDigiCollection> filteredALCTDigis(new CSCALCTDigiCollection());
156 
157  // Handle wire and strip digis
158  ageDigis<CSCStripDigi>(event,m_stripDigiToken,randGen,filteredStripDigis);
159  ageDigis<CSCWireDigi>(event,m_wireDigiToken,randGen,filteredWireDigis);
160 
161  // Don't touch CLCT or ALCT digis
162  copyDigis<CSCCLCTDigi>(event,m_clctDigiToken,filteredCLCTDigis);
163  copyDigis<CSCALCTDigi>(event,m_alctDigiToken,filteredALCTDigis);
164 
165  event.put(std::move(filteredStripDigis), "MuonCSCStripDigi");
166  event.put(std::move(filteredWireDigis), "MuonCSCWireDigi");
167  event.put(std::move(filteredCLCTDigis), "MuonCSCCLCTDigi");
168  event.put(std::move(filteredALCTDigis), "MuonCSCALCTDigi");
169 
170 }
edm::EDGetTokenT< CSCWireDigiCollection > m_wireDigiToken
MuonDigiCollection< CSCDetId, CSCStripDigi > CSCStripDigiCollection
edm::EDGetTokenT< CSCStripDigiCollection > m_stripDigiToken
MuonDigiCollection< CSCDetId, CSCCLCTDigi > CSCCLCTDigiCollection
edm::EDGetTokenT< CSCCLCTDigiCollection > m_clctDigiToken
virtual CLHEP::HepRandomEngine & getEngine(StreamID const &)=0
Use this engine in event methods.
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
edm::EDGetTokenT< CSCALCTDigiCollection > m_alctDigiToken
MuonDigiCollection< CSCDetId, CSCWireDigi > CSCWireDigiCollection
StreamID streamID() const
Definition: Event.h:96
MuonDigiCollection< CSCDetId, CSCALCTDigi > CSCALCTDigiCollection
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

edm::EDGetTokenT<CSCALCTDigiCollection> CSCChamberMasker::m_alctDigiToken
private

Definition at line 101 of file CSCChamberMasker.cc.

Referenced by produce().

edm::EDGetTokenT<CSCCLCTDigiCollection> CSCChamberMasker::m_clctDigiToken
private

Definition at line 100 of file CSCChamberMasker.cc.

Referenced by produce().

std::map<CSCDetId, std::pair<unsigned int,float> > CSCChamberMasker::m_CSCEffs
private

Definition at line 102 of file CSCChamberMasker.cc.

Referenced by ageDigis(), and beginRun().

edm::EDGetTokenT<CSCStripDigiCollection> CSCChamberMasker::m_stripDigiToken
private

Definition at line 98 of file CSCChamberMasker.cc.

Referenced by produce().

edm::EDGetTokenT<CSCWireDigiCollection> CSCChamberMasker::m_wireDigiToken
private

Definition at line 99 of file CSCChamberMasker.cc.

Referenced by produce().