CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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
< StripDigiSimLink
DigiSimLinks
 

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()),
23  theCSCGeometry(0),
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(), CSCDetId, 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(), LogTrace, 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 != 0)
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  << " E" << layer->id().endcap() << " S" << layer->id().station() << " R" << layer->id().ring()
116  << " C" << layer->id().chamber() << " L" << layer->id().layer();
117 
118  // turn the edm::PSimHits into WireHits, using the WireHitSim
119  {
120  newWireHits.swap(theWireHitSim->simulate(layer, layerSimHits, engine));
121  }
122  if(!newWireHits.empty()) {
123  newStripHits.swap(theStripHitSim->simulate(layer, newWireHits));
124  }
125 
126  // turn the hits into wire digis, using the electronicsSim
127  if (nLayersInChamberHitForWireDigis >= theLayersNeeded) {
128  theWireElectronicsSim->simulate(layer, newWireHits, engine);
129  theWireElectronicsSim->fillDigis(wireDigis, engine);
130  wireDigiSimLinks.insert( theWireElectronicsSim->digiSimLinks() );
131  }
132  if (nLayersInChamberHitForStripDigis >= theLayersNeeded) {
133  theStripElectronicsSim->simulate(layer, newStripHits, engine);
134  theStripElectronicsSim->fillDigis(stripDigis, comparators, engine);
135  stripDigiSimLinks.insert( theStripElectronicsSim->digiSimLinks() );
136  }
137  }
138 
139  // fill in the layers were missing from this chamber
140  std::list<int> missingLayers = layersMissing(stripDigis);
141  for(std::list<int>::const_iterator missingLayerItr = missingLayers.begin();
142  missingLayerItr != missingLayers.end(); ++missingLayerItr)
143  {
144  const CSCLayer * layer = findLayer(*missingLayerItr);
145  theStripElectronicsSim->fillMissingLayer(layer, comparators, stripDigis, engine);
146  }
147 }
int chamber() const
Definition: CSCDetId.h:81
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
int layer() const
Definition: CSCDetId.h:74
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:106
iterator end()
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 *)
CSCDetId chamberId() const
Definition: CSCDetId.h:66
void fillMissingLayer(const CSCLayer *layer, const CSCComparatorDigiCollection &comparators, CSCStripDigiCollection &digis, CLHEP::HepRandomEngine *)
#define LogTrace(id)
CSCWireHitSim * theWireHitSim
Definition: CSCDigitizer.h:79
int ring() const
Definition: CSCDetId.h:88
iterator begin()
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:99
std::vector< PSimHit > PSimHitContainer
virtual bool isInBadChamber(const CSCDetId &id) const
is supplied layer/chamber flagged as bad? (default impl. is no)
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 213 of file CSCDigitizer.cc.

References assert(), CSCDetId, edm::hlt::Exception, CSCGeometry::idToDetUnit(), and theCSCGeometry.

Referenced by doAction().

213  {
214  assert(theCSCGeometry != 0);
215  const GeomDetUnit* detUnit = theCSCGeometry->idToDetUnit(CSCDetId(detId));
216  if(detUnit == 0)
217  {
218  throw cms::Exception("CSCDigiProducer") << "Invalid DetUnit: " << CSCDetId(detId)
219  << "\nPerhaps your signal or pileup dataset are not compatible with the current release?";
220  }
221  return dynamic_cast<const CSCLayer *>(detUnit);
222 }
assert(m_qm.get())
const CSCGeometry * theCSCGeometry
Definition: CSCDigitizer.h:84
virtual const GeomDetUnit * 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 150 of file CSCDigitizer.cc.

References CSCDetId::chamberId(), i, j, CSCDetId::layer(), python.multivaluedict::map(), query::result, and theLayersNeeded.

Referenced by doAction().

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

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

sets the magnetic field

Definition at line 195 of file CSCDigitizer.cc.

References CSCDriftSim::setMagneticField(), and theDriftSim.

Referenced by CSCDigiProducer::produce().

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

Definition at line 207 of file CSCDigitizer.cc.

References CSCWireHitSim::setParticleDataTable(), and theWireHitSim.

Referenced by CSCDigiProducer::produce().

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

Definition at line 200 of file CSCDigitizer.cc.

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

Referenced by CSCDigiProducer::CSCDigiProducer().

201 {
202  theConditions = cond; // cache here
203  theStripElectronicsSim->setStripConditions(cond); // percolate downwards
204 }
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(), and setGeometry().

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