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.

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:78
CSCStripElectronicsSim * theStripElectronicsSim
Definition: CSCDigitizer.h:82
CSCNeutronReader * theNeutronReader
Definition: CSCDigitizer.h:83
CSCWireHitSim * theWireHitSim
Definition: CSCDigitizer.h:79
CSCWireElectronicsSim * theWireElectronicsSim
Definition: CSCDigitizer.h:81
CSCStripHitSim * theStripHitSim
Definition: CSCDigitizer.h:80

◆ 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.

References AlCaHLTBitMon_ParallelJobs::p, 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")) {
26  theNeutronReader = new CSCNeutronReader(p.getParameter<edm::ParameterSet>("neutrons"));
27  }
28 }
CSCDriftSim * theDriftSim
Definition: CSCDigitizer.h:78
unsigned int theLayersNeeded
Definition: CSCDigitizer.h:86
bool digitizeBadChambers_
Definition: CSCDigitizer.h:87
CSCStripElectronicsSim * theStripElectronicsSim
Definition: CSCDigitizer.h:82
CSCNeutronReader * theNeutronReader
Definition: CSCDigitizer.h:83
const CSCGeometry * theCSCGeometry
Definition: CSCDigitizer.h:84
CSCWireHitSim * theWireHitSim
Definition: CSCDigitizer.h:79
CSCWireElectronicsSim * theWireElectronicsSim
Definition: CSCDigitizer.h:81
CSCStripHitSim * theStripHitSim
Definition: CSCDigitizer.h:80

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.

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

◆ 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.

References cms::cuda::assert(), 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 }
assert(be >=bs)
const CSCGeometry * theCSCGeometry
Definition: CSCDigitizer.h:84
const GeomDet * idToDetUnit(DetId) const override
Return the pointer to the GeomDetUnit corresponding to a given DetId.
Definition: CSCGeometry.cc:89

◆ 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.

References CSCDetId::chamberId(), mps_fire::i, dqmiolumiharvest::j, CSCDetId::layer(), genParticles_cff::map, mps_fire::result, DBoxMetadataHelper::set_difference(), 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:86
std::vector< std::string > set_difference(std::vector< std::string > const &v1, std::vector< std::string > const &v2)

◆ 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.

References relativeConstraints::geom, and theCSCGeometry.

Referenced by CSCDigiProducer::produce().

62 { theCSCGeometry = geom; }
const CSCGeometry * theCSCGeometry
Definition: CSCDigitizer.h:84

◆ setMagneticField()

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:78
void setMagneticField(const MagneticField *field)
Definition: CSCDriftSim.h:47

◆ setParticleDataTable()

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:79
void setParticleDataTable(const ParticleDataTable *pdt)

◆ setStripConditions()

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:82
Definition: plugin.cc:23
CSCStripConditions * theConditions
Definition: CSCDigitizer.h:85

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().