CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Private Member Functions | Private Attributes
CSCDigitizer Class Reference

#include <CSCDigitizer.h>

Public Types

typedef edm::DetSetVector< StripDigiSimLinkDigiSimLinks
 

Public Member Functions

 CSCDigitizer (const CSCDigitizer &)=delete
 
 CSCDigitizer (const edm::ParameterSet &p)
 configurable parameters More...
 
void doAction (MixCollection< PSimHit > &simHits, CSCWireDigiCollection &wireDigis, CSCStripDigiCollection &stripDigis, CSCComparatorDigiCollection &comparators, DigiSimLinks &wireDigiSimLinks, DigiSimLinks &stripDigiSimLinks, CLHEP::HepRandomEngine *)
 
CSCDigitizeroperator= (const CSCDigitizer &)=delete
 
void setGeometry (const CSCGeometry *geom)
 sets geometry More...
 
void setMagneticField (const MagneticField *field)
 sets the magnetic field More...
 
void setParticleDataTable (const ParticleDataTable *pdt)
 
void setStripConditions (CSCStripConditions *cond)
 
 ~CSCDigitizer ()
 

Private Member Functions

const CSCLayerfindLayer (int detId) const
 finds the layer in the geometry associated with this det ID More...
 
std::list< int > layersMissing (const CSCStripDigiCollection &stripDigis) const
 finds which layers, 1-6, aren't in the current list More...
 

Private Attributes

bool digitizeBadChambers_
 
CSCStripConditionstheConditions
 
const CSCGeometrytheCSCGeometry
 
CSCDriftSimtheDriftSim
 
unsigned int theLayersNeeded
 
CSCNeutronReadertheNeutronReader
 
CSCStripElectronicsSimtheStripElectronicsSim
 
CSCStripHitSimtheStripHitSim
 
CSCWireElectronicsSimtheWireElectronicsSim
 
CSCWireHitSimtheWireHitSim
 

Detailed Description

Digitizer class for endcap muon CSCs.

Author
Rick Wilkinson

Definition at line 40 of file CSCDigitizer.h.

Member Typedef Documentation

◆ DigiSimLinks

Definition at line 42 of file CSCDigitizer.h.

Constructor & Destructor Documentation

◆ ~CSCDigitizer()

CSCDigitizer::~CSCDigitizer ( )

Definition at line 30 of file CSCDigitizer.cc.

30  {
31  delete theNeutronReader;
33  delete theWireElectronicsSim;
34  delete theStripHitSim;
35  delete theWireHitSim;
36  delete theDriftSim;
37 }

References theDriftSim, theNeutronReader, theStripElectronicsSim, theStripHitSim, theWireElectronicsSim, and theWireHitSim.

◆ CSCDigitizer() [1/2]

CSCDigitizer::CSCDigitizer ( const CSCDigitizer )
delete

◆ CSCDigitizer() [2/2]

CSCDigitizer::CSCDigitizer ( const edm::ParameterSet p)
explicit

configurable parameters

Definition at line 15 of file CSCDigitizer.cc.

16  : theDriftSim(new CSCDriftSim()),
21  theNeutronReader(nullptr),
22  theCSCGeometry(nullptr),
23  theLayersNeeded(p.getParameter<unsigned int>("layersNeeded")),
24  digitizeBadChambers_(p.getParameter<bool>("digitizeBadChambers")) {
25  if (p.getParameter<bool>("doNeutrons")) {
26  theNeutronReader = new CSCNeutronReader(p.getParameter<edm::ParameterSet>("neutrons"));
27  }
28 }

References AlCaHLTBitMon_ParallelJobs::p, and theNeutronReader.

Member Function Documentation

◆ doAction()

void CSCDigitizer::doAction ( MixCollection< PSimHit > &  simHits,
CSCWireDigiCollection wireDigis,
CSCStripDigiCollection stripDigis,
CSCComparatorDigiCollection comparators,
DigiSimLinks wireDigiSimLinks,
DigiSimLinks stripDigiSimLinks,
CLHEP::HepRandomEngine *  engine 
)

digitize

Definition at line 39 of file CSCDigitizer.cc.

45  {
46  // arrange the hits by layer
47  std::map<int, edm::PSimHitContainer> hitMap;
48  for (MixCollection<PSimHit>::MixItr hitItr = simHits.begin(); hitItr != simHits.end(); ++hitItr) {
49  hitMap[hitItr->detUnitId()].push_back(*hitItr);
50  }
51 
52  // count how many layers on each chamber are hit
53  std::map<int, std::set<int>> layersInChamberHit;
54  for (std::map<int, edm::PSimHitContainer>::const_iterator hitMapItr = hitMap.begin(); hitMapItr != hitMap.end();
55  ++hitMapItr) {
56  CSCDetId cscDetId(hitMapItr->first);
57  int chamberId = cscDetId.chamberId();
58  layersInChamberHit[chamberId].insert(cscDetId.layer());
59  }
60 
61  // add neutron background, if needed
62  if (theNeutronReader != nullptr) {
63  theNeutronReader->addHits(hitMap, engine);
64  }
65 
66  // now loop over layers and run the simulation for each one
67  for (std::map<int, edm::PSimHitContainer>::const_iterator hitMapItr = hitMap.begin(); hitMapItr != hitMap.end();
68  ++hitMapItr) {
69  CSCDetId detId = CSCDetId(hitMapItr->first);
70  int chamberId = detId.chamberId();
71  int endc = detId.endcap();
72  int stat = detId.station();
73  int ring = detId.ring();
74  int cham = detId.chamber();
75 
76  unsigned int nLayersInChamberHitForWireDigis = 0;
77  if (stat == 1 && ring == 1) { // ME1b
78  std::set<int> layersInME1a = layersInChamberHit[CSCDetId(endc, stat, 4, cham, 0)];
79  std::set<int> layersInME11 = layersInChamberHit[chamberId];
80  layersInME11.insert(layersInME1a.begin(), layersInME1a.end());
81  nLayersInChamberHitForWireDigis = layersInME11.size();
82  } else if (stat == 1 && ring == 4) { // ME1a
83  std::set<int> layersInME1b = layersInChamberHit[CSCDetId(endc, stat, 1, cham, 0)];
84  std::set<int> layersInME11 = layersInChamberHit[chamberId];
85  layersInME11.insert(layersInME1b.begin(), layersInME1b.end());
86  nLayersInChamberHitForWireDigis = layersInME11.size();
87  } else
88  nLayersInChamberHitForWireDigis = layersInChamberHit[chamberId].size();
89 
90  unsigned int nLayersInChamberHitForStripDigis = layersInChamberHit[chamberId].size();
91 
92  if (nLayersInChamberHitForWireDigis < theLayersNeeded && nLayersInChamberHitForStripDigis < theLayersNeeded)
93  continue;
94  // skip bad chambers
95  if (!digitizeBadChambers_ && theConditions->isInBadChamber(CSCDetId(hitMapItr->first)))
96  continue;
97 
98  const CSCLayer *layer = findLayer(hitMapItr->first);
99  const edm::PSimHitContainer &layerSimHits = hitMapItr->second;
100 
101  std::vector<CSCDetectorHit> newWireHits, newStripHits;
102 
103  // LogTrace("CSCDigitizer") << "CSCDigitizer: found " <<
104  // layerSimHits.size() <<" hit(s) in layer"
105  edm::LogVerbatim("CSCDigitizer") << "[CSCDigitizer] found " << layerSimHits.size() << " hit(s) in layer"
106  << layer->id();
107  // << " E" << layer->id().endcap() << " S" << layer->id().station() <<
108  // " R" << layer->id().ring()
109  // << " C" << layer->id().chamber() << " L" << layer->id().layer();
110 
111  // turn the edm::PSimHits into WireHits, using the WireHitSim
112  { newWireHits.swap(theWireHitSim->simulate(layer, layerSimHits, engine)); }
113  if (!newWireHits.empty()) {
114  newStripHits.swap(theStripHitSim->simulate(layer, newWireHits));
115  }
116 
117  // turn the hits into wire digis, using the electronicsSim
118  if (nLayersInChamberHitForWireDigis >= theLayersNeeded) {
119  theWireElectronicsSim->simulate(layer, newWireHits, engine);
120  theWireElectronicsSim->fillDigis(wireDigis, engine);
121  wireDigiSimLinks.insert(theWireElectronicsSim->digiSimLinks());
122  }
123  if (nLayersInChamberHitForStripDigis >= theLayersNeeded) {
124  theStripElectronicsSim->simulate(layer, newStripHits, engine);
125  theStripElectronicsSim->fillDigis(stripDigis, comparators, engine);
126  stripDigiSimLinks.insert(theStripElectronicsSim->digiSimLinks());
127  }
128  }
129 
130  // fill in the layers were missing from this chamber
131  std::list<int> missingLayers = layersMissing(stripDigis);
132  for (std::list<int>::const_iterator missingLayerItr = missingLayers.begin(); missingLayerItr != missingLayers.end();
133  ++missingLayerItr) {
134  const CSCLayer *layer = findLayer(*missingLayerItr);
135  theStripElectronicsSim->fillMissingLayer(layer, comparators, stripDigis, engine);
136  }
137 }

References CSCNeutronReader::addHits(), relativeConstraints::cham, CSCDetId::chamber(), CSCDetId::chamberId(), CSCBaseElectronicsSim::digiSimLinks(), digitizeBadChambers_, CSCDetId::endcap(), CSCWireElectronicsSim::fillDigis(), CSCStripElectronicsSim::fillDigis(), CSCStripElectronicsSim::fillMissingLayer(), findLayer(), CSCLayer::id(), edm::DetSetVector< T >::insert(), CSCStripConditions::isInBadChamber(), CSCDetId::layer(), layersMissing(), relativeConstraints::ring, CSCDetId::ring(), FastTrackerRecHitCombiner_cfi::simHits, CSCStripHitSim::simulate(), CSCWireHitSim::simulate(), CSCBaseElectronicsSim::simulate(), hgcalPlots::stat, CSCDetId::station(), theConditions, theLayersNeeded, theNeutronReader, theStripElectronicsSim, theStripHitSim, theWireElectronicsSim, and theWireHitSim.

Referenced by CSCDigiProducer::produce().

◆ findLayer()

const CSCLayer * CSCDigitizer::findLayer ( int  detId) const
private

finds the layer in the geometry associated with this det ID

Definition at line 185 of file CSCDigitizer.cc.

185  {
186  assert(theCSCGeometry != nullptr);
187  const GeomDetUnit *detUnit = theCSCGeometry->idToDetUnit(CSCDetId(detId));
188  if (detUnit == nullptr) {
189  throw cms::Exception("CSCDigiProducer") << "Invalid DetUnit: " << CSCDetId(detId)
190  << "\nPerhaps your signal or pileup dataset are not compatible with "
191  "the current release?";
192  }
193  return dynamic_cast<const CSCLayer *>(detUnit);
194 }

References cms::cuda::assert(), Exception, CSCGeometry::idToDetUnit(), and theCSCGeometry.

Referenced by doAction().

◆ layersMissing()

std::list< int > CSCDigitizer::layersMissing ( const CSCStripDigiCollection stripDigis) const
private

finds which layers, 1-6, aren't in the current list

Definition at line 139 of file CSCDigitizer.cc.

139  {
140  std::list<int> result;
141 
142  std::map<int, std::list<int>> layersInChamberWithDigi;
143  for (CSCStripDigiCollection::DigiRangeIterator j = stripDigis.begin(); j != stripDigis.end(); j++) {
144  CSCDetId layerId((*j).first);
145  // make sure the vector of digis isn't empty
146  if ((*j).second.first != (*j).second.second) {
147  int chamberId = layerId.chamberId();
148  layersInChamberWithDigi[chamberId].push_back(layerId.layer());
149  }
150  }
151 
152  std::list<int> oneThruSix;
153  for (int i = 1; i <= 6; ++i)
154  oneThruSix.push_back(i);
155 
156  for (std::map<int, std::list<int>>::iterator layersInChamberWithDigiItr = layersInChamberWithDigi.begin();
157  layersInChamberWithDigiItr != layersInChamberWithDigi.end();
158  ++layersInChamberWithDigiItr) {
159  std::list<int> &layersHit = layersInChamberWithDigiItr->second;
160  if (layersHit.size() < 6 && layersHit.size() >= theLayersNeeded) {
161  layersHit.sort();
162  std::list<int> missingLayers(6);
163  std::list<int>::iterator lastLayerMissing = set_difference(
164  oneThruSix.begin(), oneThruSix.end(), layersHit.begin(), layersHit.end(), missingLayers.begin());
165  int chamberId = layersInChamberWithDigiItr->first;
166  for (std::list<int>::iterator layerMissingItr = missingLayers.begin(); layerMissingItr != lastLayerMissing;
167  ++layerMissingItr) {
168  // got from layer 1-6 to layer ID
169  result.push_back(chamberId + *layerMissingItr);
170  }
171  }
172  }
173  return result;
174 }

References CSCDetId::chamberId(), mps_fire::i, dqmiolumiharvest::j, CSCDetId::layer(), genParticles_cff::map, mps_fire::result, and theLayersNeeded.

Referenced by doAction().

◆ operator=()

CSCDigitizer& CSCDigitizer::operator= ( const CSCDigitizer )
delete

◆ setGeometry()

void CSCDigitizer::setGeometry ( const CSCGeometry geom)
inline

sets geometry

Definition at line 62 of file CSCDigitizer.h.

62 { theCSCGeometry = geom; }

References relativeConstraints::geom, and theCSCGeometry.

Referenced by CSCDigiProducer::produce().

◆ setMagneticField()

void CSCDigitizer::setMagneticField ( const MagneticField field)

sets the magnetic field

Definition at line 176 of file CSCDigitizer.cc.

176 { theDriftSim->setMagneticField(field); }

References CSCDriftSim::setMagneticField(), and theDriftSim.

Referenced by CSCDigiProducer::produce().

◆ setParticleDataTable()

void CSCDigitizer::setParticleDataTable ( const ParticleDataTable pdt)

◆ setStripConditions()

void CSCDigitizer::setStripConditions ( CSCStripConditions cond)

Definition at line 178 of file CSCDigitizer.cc.

178  {
179  theConditions = cond; // cache here
180  theStripElectronicsSim->setStripConditions(cond); // percolate downwards
181 }

References CSCStripElectronicsSim::setStripConditions(), theConditions, and theStripElectronicsSim.

Referenced by CSCDigiProducer::CSCDigiProducer().

Member Data Documentation

◆ digitizeBadChambers_

bool CSCDigitizer::digitizeBadChambers_
private

Definition at line 87 of file CSCDigitizer.h.

Referenced by doAction().

◆ theConditions

CSCStripConditions* CSCDigitizer::theConditions
private

Definition at line 85 of file CSCDigitizer.h.

Referenced by doAction(), and setStripConditions().

◆ theCSCGeometry

const CSCGeometry* CSCDigitizer::theCSCGeometry
private

Definition at line 84 of file CSCDigitizer.h.

Referenced by findLayer(), and setGeometry().

◆ theDriftSim

CSCDriftSim* CSCDigitizer::theDriftSim
private

Definition at line 78 of file CSCDigitizer.h.

Referenced by setMagneticField(), and ~CSCDigitizer().

◆ theLayersNeeded

unsigned int CSCDigitizer::theLayersNeeded
private

Definition at line 86 of file CSCDigitizer.h.

Referenced by doAction(), and layersMissing().

◆ theNeutronReader

CSCNeutronReader* CSCDigitizer::theNeutronReader
private

Definition at line 83 of file CSCDigitizer.h.

Referenced by CSCDigitizer(), doAction(), and ~CSCDigitizer().

◆ theStripElectronicsSim

CSCStripElectronicsSim* CSCDigitizer::theStripElectronicsSim
private

Definition at line 82 of file CSCDigitizer.h.

Referenced by doAction(), setStripConditions(), and ~CSCDigitizer().

◆ theStripHitSim

CSCStripHitSim* CSCDigitizer::theStripHitSim
private

Definition at line 80 of file CSCDigitizer.h.

Referenced by doAction(), and ~CSCDigitizer().

◆ theWireElectronicsSim

CSCWireElectronicsSim* CSCDigitizer::theWireElectronicsSim
private

Definition at line 81 of file CSCDigitizer.h.

Referenced by doAction(), and ~CSCDigitizer().

◆ theWireHitSim

CSCWireHitSim* CSCDigitizer::theWireHitSim
private

Definition at line 79 of file CSCDigitizer.h.

Referenced by doAction(), setParticleDataTable(), and ~CSCDigitizer().

CSCWireElectronicsSim::fillDigis
void fillDigis(CSCWireDigiCollection &digis, CLHEP::HepRandomEngine *)
Definition: CSCWireElectronicsSim.cc:28
mps_fire.i
i
Definition: mps_fire.py:428
CSCStripElectronicsSim::setStripConditions
void setStripConditions(CSCStripConditions *cond)
Definition: CSCStripElectronicsSim.h:42
CSCDigitizer::theWireHitSim
CSCWireHitSim * theWireHitSim
Definition: CSCDigitizer.h:79
GeomDet
Definition: GeomDet.h:27
CSCStripElectronicsSim
Definition: CSCStripElectronicsSim.h:28
relativeConstraints.cham
cham
Definition: relativeConstraints.py:69
CSCStripHitSim::simulate
std::vector< CSCDetectorHit > & simulate(const CSCLayer *layer, const std::vector< CSCDetectorHit > &wireHits)
Definition: CSCStripHitSim.cc:10
CSCDetId::ring
int ring() const
Definition: CSCDetId.h:68
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
CSCDigitizer::theConditions
CSCStripConditions * theConditions
Definition: CSCDigitizer.h:85
CSCDigitizer::digitizeBadChambers_
bool digitizeBadChambers_
Definition: CSCDigitizer.h:87
cms::cuda::assert
assert(be >=bs)
FastTrackerRecHitCombiner_cfi.simHits
simHits
Definition: FastTrackerRecHitCombiner_cfi.py:5
CSCDriftSim::setMagneticField
void setMagneticField(const MagneticField *field)
Definition: CSCDriftSim.h:47
CSCDigitizer::theLayersNeeded
unsigned int theLayersNeeded
Definition: CSCDigitizer.h:86
CSCLayer
Definition: CSCLayer.h:24
CSCDigitizer::layersMissing
std::list< int > layersMissing(const CSCStripDigiCollection &stripDigis) const
finds which layers, 1-6, aren't in the current list
Definition: CSCDigitizer.cc:139
CSCWireHitSim::setParticleDataTable
void setParticleDataTable(const ParticleDataTable *pdt)
Definition: CSCWireHitSim.cc:77
MixCollection::MixItr
Definition: MixCollection.h:62
CSCNeutronReader::addHits
void addHits(std::map< int, edm::PSimHitContainer > &hitMap, CLHEP::HepRandomEngine *)
Definition: CSCNeutronReader.cc:6
CSCStripHitSim
Definition: CSCStripHitSim.h:21
hgcalPlots.stat
stat
Definition: hgcalPlots.py:1119
CSCLayer::id
CSCDetId id() const
Definition: CSCLayer.h:39
CSCBaseElectronicsSim::digiSimLinks
const DigiSimLinks & digiSimLinks() const
Definition: CSCBaseElectronicsSim.h:46
relativeConstraints.geom
geom
Definition: relativeConstraints.py:72
CSCNeutronReader
Definition: CSCNeutronReader.h:10
CSCStripElectronicsSim::fillDigis
void fillDigis(CSCStripDigiCollection &digis, CSCComparatorDigiCollection &comparators, CLHEP::HepRandomEngine *)
Definition: CSCStripElectronicsSim.cc:286
CSCWireHitSim
Definition: CSCWireHitSim.h:27
CSCWireHitSim::simulate
std::vector< CSCDetectorHit > & simulate(const CSCLayer *layer, const edm::PSimHitContainer &simHits, CLHEP::HepRandomEngine *)
Definition: CSCWireHitSim.cc:15
cond
Definition: plugin.cc:23
edm::ParameterSet
Definition: ParameterSet.h:47
CSCDetId
Definition: CSCDetId.h:26
CSCDigitizer::findLayer
const CSCLayer * findLayer(int detId) const
finds the layer in the geometry associated with this det ID
Definition: CSCDigitizer.cc:185
CSCDigitizer::theCSCGeometry
const CSCGeometry * theCSCGeometry
Definition: CSCDigitizer.h:84
CSCDetId::chamberId
CSCDetId chamberId() const
Definition: CSCDetId.h:47
CSCDetId::chamber
int chamber() const
Definition: CSCDetId.h:62
CSCDriftSim
Definition: CSCDriftSim.h:32
CSCDigitizer::theStripHitSim
CSCStripHitSim * theStripHitSim
Definition: CSCDigitizer.h:80
edm::LogVerbatim
Log< level::Info, true > LogVerbatim
Definition: MessageLogger.h:128
CSCDetId::endcap
int endcap() const
Definition: CSCDetId.h:85
Exception
Definition: hltDiff.cc:246
CSCWireElectronicsSim
Definition: CSCWireElectronicsSim.h:20
CSCStripElectronicsSim::fillMissingLayer
void fillMissingLayer(const CSCLayer *layer, const CSCComparatorDigiCollection &comparators, CSCStripDigiCollection &digis, CLHEP::HepRandomEngine *)
Definition: CSCStripElectronicsSim.cc:398
relativeConstraints.ring
ring
Definition: relativeConstraints.py:68
CSCDigitizer::theDriftSim
CSCDriftSim * theDriftSim
Definition: CSCDigitizer.h:78
mps_fire.result
result
Definition: mps_fire.py:311
genParticles_cff.map
map
Definition: genParticles_cff.py:11
edm::PSimHitContainer
std::vector< PSimHit > PSimHitContainer
Definition: PSimHitContainer.h:11
CSCDetId::station
int station() const
Definition: CSCDetId.h:79
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
DigiContainerIterator
Definition: MuonDigiCollection.h:30
CSCGeometry::idToDetUnit
const GeomDet * idToDetUnit(DetId) const override
Return the pointer to the GeomDetUnit corresponding to a given DetId.
Definition: CSCGeometry.cc:89
CSCDigitizer::theNeutronReader
CSCNeutronReader * theNeutronReader
Definition: CSCDigitizer.h:83
CSCDigitizer::theStripElectronicsSim
CSCStripElectronicsSim * theStripElectronicsSim
Definition: CSCDigitizer.h:82
CSCStripConditions::isInBadChamber
virtual bool isInBadChamber(const CSCDetId &id) const
is supplied layer/chamber flagged as bad? (default impl. is no)
Definition: CSCStripConditions.h:47
CSCBaseElectronicsSim::simulate
void simulate(const CSCLayer *layer, const std::vector< CSCDetectorHit > &inputHits, CLHEP::HepRandomEngine *)
Definition: CSCBaseElectronicsSim.cc:40
CSCDigitizer::theWireElectronicsSim
CSCWireElectronicsSim * theWireElectronicsSim
Definition: CSCDigitizer.h:81