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 44 of file CSCDigitizer.h.

Constructor & Destructor Documentation

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

configurable parameters

Definition at line 16 of file CSCDigitizer.cc.

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

17 : theDriftSim(new CSCDriftSim()),
22  theNeutronReader(nullptr),
23  theCSCGeometry(nullptr),
24  theLayersNeeded(p.getParameter<unsigned int>("layersNeeded")),
25  digitizeBadChambers_(p.getParameter<bool>("digitizeBadChambers"))
26 {
27  if(p.getParameter<bool>("doNeutrons"))
28  {
30  }
31 }
CSCDriftSim * theDriftSim
Definition: CSCDigitizer.h:78
T getParameter(std::string const &) const
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
CSCDigitizer::~CSCDigitizer ( )

Definition at line 34 of file CSCDigitizer.cc.

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

34  {
35  delete theNeutronReader;
37  delete theWireElectronicsSim;
38  delete theStripHitSim;
39  delete theWireHitSim;
40  delete theDriftSim;
41 }
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

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

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

finds the layer in the geometry associated with this det ID

Definition at line 215 of file CSCDigitizer.cc.

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

Referenced by doAction().

215  {
216  assert(theCSCGeometry != nullptr);
217  const GeomDetUnit* detUnit = theCSCGeometry->idToDetUnit(CSCDetId(detId));
218  if(detUnit == nullptr)
219  {
220  throw cms::Exception("CSCDigiProducer") << "Invalid DetUnit: " << CSCDetId(detId)
221  << "\nPerhaps your signal or pileup dataset are not compatible with the current release?";
222  }
223  return dynamic_cast<const CSCLayer *>(detUnit);
224 }
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:93
std::list< int > CSCDigitizer::layersMissing ( const CSCStripDigiCollection stripDigis) const
private

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

Definition at line 152 of file CSCDigitizer.cc.

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

Referenced by doAction().

153 {
154  std::list<int> result;
155 
156  std::map<int, std::list<int> > layersInChamberWithDigi;
157  for (CSCStripDigiCollection::DigiRangeIterator j=stripDigis.begin();
158  j!=stripDigis.end(); j++)
159  {
160  CSCDetId layerId((*j).first);
161  // make sure the vector of digis isn't empty
162  if((*j).second.first != (*j).second.second)
163  {
164  int chamberId = layerId.chamberId();
165  layersInChamberWithDigi[chamberId].push_back(layerId.layer());
166  }
167  }
168 
169  std::list<int> oneThruSix;
170  for(int i = 1; i <=6; ++i)
171  oneThruSix.push_back(i);
172 
173  for(std::map<int, std::list<int> >::iterator layersInChamberWithDigiItr = layersInChamberWithDigi.begin();
174  layersInChamberWithDigiItr != layersInChamberWithDigi.end(); ++ layersInChamberWithDigiItr)
175  {
176  std::list<int> & layersHit = layersInChamberWithDigiItr->second;
177  if (layersHit.size() < 6 && layersHit.size() >= theLayersNeeded)
178  {
179  layersHit.sort();
180  std::list<int> missingLayers(6);
181  std::list<int>::iterator lastLayerMissing =
182  set_difference(oneThruSix.begin(), oneThruSix.end(),
183  layersHit.begin(), layersHit.end(), missingLayers.begin());
184  int chamberId = layersInChamberWithDigiItr->first;
185  for(std::list<int>::iterator layerMissingItr = missingLayers.begin();
186  layerMissingItr != lastLayerMissing; ++layerMissingItr)
187  {
188  // got from layer 1-6 to layer ID
189  result.push_back(chamberId + *layerMissingItr);
190  }
191  }
192  }
193  return result;
194 }
unsigned int theLayersNeeded
Definition: CSCDigitizer.h:86
void CSCDigitizer::setGeometry ( const CSCGeometry geom)
inline

sets geometry

Definition at line 62 of file CSCDigitizer.h.

References relativeConstraints::geom.

Referenced by CSCDigiProducer::produce().

const CSCGeometry * theCSCGeometry
Definition: CSCDigitizer.h:84
void CSCDigitizer::setMagneticField ( const MagneticField field)

sets the magnetic field

Definition at line 197 of file CSCDigitizer.cc.

References CSCDriftSim::setMagneticField(), and theDriftSim.

Referenced by CSCDigiProducer::produce().

197  {
199 }
CSCDriftSim * theDriftSim
Definition: CSCDigitizer.h:78
void setMagneticField(const MagneticField *field)
Definition: CSCDriftSim.h:46
void CSCDigitizer::setParticleDataTable ( const ParticleDataTable pdt)

Definition at line 209 of file CSCDigitizer.cc.

References CSCWireHitSim::setParticleDataTable(), and theWireHitSim.

Referenced by CSCDigiProducer::produce().

210 {
212 }
CSCWireHitSim * theWireHitSim
Definition: CSCDigitizer.h:79
void setParticleDataTable(const ParticleDataTable *pdt)
void CSCDigitizer::setStripConditions ( CSCStripConditions cond)

Definition at line 202 of file CSCDigitizer.cc.

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

Referenced by CSCDigiProducer::CSCDigiProducer().

203 {
204  theConditions = cond; // cache here
205  theStripElectronicsSim->setStripConditions(cond); // percolate downwards
206 }
void setStripConditions(CSCStripConditions *cond)
CSCStripElectronicsSim * theStripElectronicsSim
Definition: CSCDigitizer.h:82
CSCStripConditions * theConditions
Definition: CSCDigitizer.h:85

Member Data Documentation

bool CSCDigitizer::digitizeBadChambers_
private

Definition at line 87 of file CSCDigitizer.h.

Referenced by doAction().

CSCStripConditions* CSCDigitizer::theConditions
private

Definition at line 85 of file CSCDigitizer.h.

Referenced by doAction(), and setStripConditions().

const CSCGeometry* CSCDigitizer::theCSCGeometry
private

Definition at line 84 of file CSCDigitizer.h.

Referenced by findLayer().

CSCDriftSim* CSCDigitizer::theDriftSim
private

Definition at line 78 of file CSCDigitizer.h.

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

unsigned int CSCDigitizer::theLayersNeeded
private

Definition at line 86 of file CSCDigitizer.h.

Referenced by doAction(), and layersMissing().

CSCNeutronReader* CSCDigitizer::theNeutronReader
private

Definition at line 83 of file CSCDigitizer.h.

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

CSCStripElectronicsSim* CSCDigitizer::theStripElectronicsSim
private

Definition at line 82 of file CSCDigitizer.h.

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

CSCStripHitSim* CSCDigitizer::theStripHitSim
private

Definition at line 80 of file CSCDigitizer.h.

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

CSCWireElectronicsSim* CSCDigitizer::theWireElectronicsSim
private

Definition at line 81 of file CSCDigitizer.h.

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

CSCWireHitSim* CSCDigitizer::theWireHitSim
private

Definition at line 79 of file CSCDigitizer.h.

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