CMS 3D CMS Logo

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

#include <CSCDigitizer.h>

Inheritance diagram for CSCDigitizer:

Public Types

typedef edm::DetSetVector< StripDigiSimLinkDigiSimLinks
 

Public Member Functions

 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 *)
 
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 41 of file CSCDigitizer.h.

Member Typedef Documentation

Definition at line 43 of file CSCDigitizer.h.

Constructor & Destructor Documentation

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

configurable parameters

Definition at line 15 of file CSCDigitizer.cc.

References edm::ParameterSet::getParameter(), and theNeutronReader.

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")) {
27  }
28 }
CSCDriftSim * theDriftSim
Definition: CSCDigitizer.h:77
T getParameter(std::string const &) const
unsigned int theLayersNeeded
Definition: CSCDigitizer.h:85
bool digitizeBadChambers_
Definition: CSCDigitizer.h:86
CSCStripElectronicsSim * theStripElectronicsSim
Definition: CSCDigitizer.h:81
CSCNeutronReader * theNeutronReader
Definition: CSCDigitizer.h:82
const CSCGeometry * theCSCGeometry
Definition: CSCDigitizer.h:83
CSCWireHitSim * theWireHitSim
Definition: CSCDigitizer.h:78
CSCWireElectronicsSim * theWireElectronicsSim
Definition: CSCDigitizer.h:80
CSCStripHitSim * theStripHitSim
Definition: CSCDigitizer.h:79
CSCDigitizer::~CSCDigitizer ( )

Definition at line 30 of file CSCDigitizer.cc.

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

30  {
31  delete theNeutronReader;
33  delete theWireElectronicsSim;
34  delete theStripHitSim;
35  delete theWireHitSim;
36  delete theDriftSim;
37 }
CSCDriftSim * theDriftSim
Definition: CSCDigitizer.h:77
CSCStripElectronicsSim * theStripElectronicsSim
Definition: CSCDigitizer.h:81
CSCNeutronReader * theNeutronReader
Definition: CSCDigitizer.h:82
CSCWireHitSim * theWireHitSim
Definition: CSCDigitizer.h:78
CSCWireElectronicsSim * theWireElectronicsSim
Definition: CSCDigitizer.h:80
CSCStripHitSim * theStripHitSim
Definition: CSCDigitizer.h:79

Member Function Documentation

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.

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

Referenced by CSCDigiProducer::produce().

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 }
int chamber() const
Definition: CSCDetId.h:62
std::vector< CSCDetectorHit > & simulate(const CSCLayer *layer, const std::vector< CSCDetectorHit > &wireHits)
unsigned int theLayersNeeded
Definition: CSCDigitizer.h:85
CSCDetId id() const
Definition: CSCLayer.h:39
std::vector< CSCDetectorHit > & simulate(const CSCLayer *layer, const edm::PSimHitContainer &simHits, CLHEP::HepRandomEngine *)
const CSCLayer * findLayer(int detId) const
finds the layer in the geometry associated with this det ID
std::list< int > layersMissing(const CSCStripDigiCollection &stripDigis) const
finds which layers, 1-6, aren&#39;t in the current list
int endcap() const
Definition: CSCDetId.h:85
bool digitizeBadChambers_
Definition: CSCDigitizer.h:86
const DigiSimLinks & digiSimLinks() const
CSCStripElectronicsSim * theStripElectronicsSim
Definition: CSCDigitizer.h:81
CSCNeutronReader * theNeutronReader
Definition: CSCDigitizer.h:82
void fillDigis(CSCWireDigiCollection &digis, CLHEP::HepRandomEngine *)
iterator end() const
CSCDetId chamberId() const
Definition: CSCDetId.h:47
void fillMissingLayer(const CSCLayer *layer, const CSCComparatorDigiCollection &comparators, CSCStripDigiCollection &digis, CLHEP::HepRandomEngine *)
CSCWireHitSim * theWireHitSim
Definition: CSCDigitizer.h:78
int ring() const
Definition: CSCDetId.h:68
CSCWireElectronicsSim * theWireElectronicsSim
Definition: CSCDigitizer.h:80
void fillDigis(CSCStripDigiCollection &digis, CSCComparatorDigiCollection &comparators, CLHEP::HepRandomEngine *)
void addHits(std::map< int, edm::PSimHitContainer > &hitMap, CLHEP::HepRandomEngine *)
int station() const
Definition: CSCDetId.h:79
std::vector< PSimHit > PSimHitContainer
virtual bool isInBadChamber(const CSCDetId &id) const
is supplied layer/chamber flagged as bad? (default impl. is no)
iterator begin() const
void simulate(const CSCLayer *layer, const std::vector< CSCDetectorHit > &inputHits, CLHEP::HepRandomEngine *)
CSCStripHitSim * theStripHitSim
Definition: CSCDigitizer.h:79
CSCStripConditions * theConditions
Definition: CSCDigitizer.h:84
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.

References Exception, CSCGeometry::idToDetUnit(), and theCSCGeometry.

Referenced by doAction().

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 }
const CSCGeometry * theCSCGeometry
Definition: CSCDigitizer.h:83
const GeomDet * idToDetUnit(DetId) const override
Return the pointer to the GeomDetUnit corresponding to a given DetId.
Definition: CSCGeometry.cc:89
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.

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

Referenced by doAction().

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 }
unsigned int theLayersNeeded
Definition: CSCDigitizer.h:85
void CSCDigitizer::setGeometry ( const CSCGeometry geom)
inline

sets geometry

Definition at line 61 of file CSCDigitizer.h.

References relativeConstraints::geom.

Referenced by CSCDigiProducer::produce().

61 { theCSCGeometry = geom; }
const CSCGeometry * theCSCGeometry
Definition: CSCDigitizer.h:83
void CSCDigitizer::setMagneticField ( const MagneticField field)

sets the magnetic field

Definition at line 176 of file CSCDigitizer.cc.

References CSCDriftSim::setMagneticField(), and theDriftSim.

Referenced by CSCDigiProducer::produce().

176 { theDriftSim->setMagneticField(field); }
CSCDriftSim * theDriftSim
Definition: CSCDigitizer.h:77
void setMagneticField(const MagneticField *field)
Definition: CSCDriftSim.h:47
void CSCDigitizer::setParticleDataTable ( const ParticleDataTable pdt)

Definition at line 183 of file CSCDigitizer.cc.

References CSCWireHitSim::setParticleDataTable(), and theWireHitSim.

Referenced by CSCDigiProducer::produce().

CSCWireHitSim * theWireHitSim
Definition: CSCDigitizer.h:78
void setParticleDataTable(const ParticleDataTable *pdt)
void CSCDigitizer::setStripConditions ( CSCStripConditions cond)

Definition at line 178 of file CSCDigitizer.cc.

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

Referenced by CSCDigiProducer::CSCDigiProducer().

178  {
179  theConditions = cond; // cache here
180  theStripElectronicsSim->setStripConditions(cond); // percolate downwards
181 }
void setStripConditions(CSCStripConditions *cond)
CSCStripElectronicsSim * theStripElectronicsSim
Definition: CSCDigitizer.h:81
CSCStripConditions * theConditions
Definition: CSCDigitizer.h:84

Member Data Documentation

bool CSCDigitizer::digitizeBadChambers_
private

Definition at line 86 of file CSCDigitizer.h.

Referenced by doAction().

CSCStripConditions* CSCDigitizer::theConditions
private

Definition at line 84 of file CSCDigitizer.h.

Referenced by doAction(), and setStripConditions().

const CSCGeometry* CSCDigitizer::theCSCGeometry
private

Definition at line 83 of file CSCDigitizer.h.

Referenced by findLayer().

CSCDriftSim* CSCDigitizer::theDriftSim
private

Definition at line 77 of file CSCDigitizer.h.

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

unsigned int CSCDigitizer::theLayersNeeded
private

Definition at line 85 of file CSCDigitizer.h.

Referenced by doAction(), and layersMissing().

CSCNeutronReader* CSCDigitizer::theNeutronReader
private

Definition at line 82 of file CSCDigitizer.h.

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

CSCStripElectronicsSim* CSCDigitizer::theStripElectronicsSim
private

Definition at line 81 of file CSCDigitizer.h.

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

CSCStripHitSim* CSCDigitizer::theStripHitSim
private

Definition at line 79 of file CSCDigitizer.h.

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

CSCWireElectronicsSim* CSCDigitizer::theWireElectronicsSim
private

Definition at line 80 of file CSCDigitizer.h.

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

CSCWireHitSim* CSCDigitizer::theWireHitSim
private

Definition at line 78 of file CSCDigitizer.h.

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