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)
 
void setGeometry (const CSCGeometry *geom)
 sets geometry More...
 
void setMagneticField (const MagneticField *field)
 sets the magnetic field More...
 
void setParticleDataTable (const ParticleDataTable *pdt)
 
void setRandomEngine (CLHEP::HepRandomEngine &engine)
 
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 37 of file CSCDigitizer.h.

Member Typedef Documentation

Definition at line 40 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:75
T getParameter(std::string const &) const
unsigned int theLayersNeeded
Definition: CSCDigitizer.h:83
bool digitizeBadChambers_
Definition: CSCDigitizer.h:84
CSCStripElectronicsSim * theStripElectronicsSim
Definition: CSCDigitizer.h:79
CSCNeutronReader * theNeutronReader
Definition: CSCDigitizer.h:80
const CSCGeometry * theCSCGeometry
Definition: CSCDigitizer.h:81
CSCWireHitSim * theWireHitSim
Definition: CSCDigitizer.h:76
CSCWireElectronicsSim * theWireElectronicsSim
Definition: CSCDigitizer.h:78
CSCStripHitSim * theStripHitSim
Definition: CSCDigitizer.h:77
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:75
CSCStripElectronicsSim * theStripElectronicsSim
Definition: CSCDigitizer.h:79
CSCNeutronReader * theNeutronReader
Definition: CSCDigitizer.h:80
CSCWireHitSim * theWireHitSim
Definition: CSCDigitizer.h:76
CSCWireElectronicsSim * theWireElectronicsSim
Definition: CSCDigitizer.h:78
CSCStripHitSim * theStripHitSim
Definition: CSCDigitizer.h:77

Member Function Documentation

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

digitize

Definition at line 45 of file CSCDigitizer.cc.

References CSCNeutronReader::addHits(), MixCollection< T >::begin(), 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, CSCDetId::ring(), CSCStripHitSim::simulate(), CSCWireHitSim::simulate(), CSCBaseElectronicsSim::simulate(), CSCDetId::station(), theConditions, theLayersNeeded, theNeutronReader, theStripElectronicsSim, theStripHitSim, theWireElectronicsSim, and theWireHitSim.

Referenced by CSCDigiProducer::produce().

51 {
52  // arrange the hits by layer
53  std::map<int, edm::PSimHitContainer> hitMap;
54  for(MixCollection<PSimHit>::MixItr hitItr = simHits.begin();
55  hitItr != simHits.end(); ++hitItr)
56  {
57  hitMap[hitItr->detUnitId()].push_back(*hitItr);
58  }
59 
60  // count how many layers on each chamber are hit
61  std::map<int, std::set<int> > layersInChamberHit;
62  for(std::map<int, edm::PSimHitContainer>::const_iterator hitMapItr = hitMap.begin();
63  hitMapItr != hitMap.end(); ++hitMapItr)
64  {
65  CSCDetId cscDetId(hitMapItr->first);
66  int chamberId = cscDetId.chamberId();
67  layersInChamberHit[chamberId].insert(cscDetId.layer());
68  }
69 
70  // add neutron background, if needed
71  if(theNeutronReader != 0)
72  {
73  theNeutronReader->addHits(hitMap);
74  }
75 
76  // now loop over layers and run the simulation for each one
77  for(std::map<int, edm::PSimHitContainer>::const_iterator hitMapItr = hitMap.begin();
78  hitMapItr != hitMap.end(); ++hitMapItr)
79  {
80  int chamberId = CSCDetId(hitMapItr->first).chamberId();
81  unsigned int nLayersInChamberHit = layersInChamberHit[chamberId].size();
82  if(nLayersInChamberHit < theLayersNeeded) continue;
83  // skip bad chambers
84  if ( !digitizeBadChambers_ && theConditions->isInBadChamber( CSCDetId(hitMapItr->first) ) ) continue;
85 
86  const CSCLayer * layer = findLayer(hitMapItr->first);
87  const edm::PSimHitContainer & layerSimHits = hitMapItr->second;
88 
89  std::vector<CSCDetectorHit> newWireHits, newStripHits;
90 
91  LogTrace("CSCDigitizer") << "CSCDigitizer: found " << layerSimHits.size() <<" hit(s) in layer"
92  << " E" << layer->id().endcap() << " S" << layer->id().station() << " R" << layer->id().ring()
93  << " C" << layer->id().chamber() << " L" << layer->id().layer();
94 
95  // turn the edm::PSimHits into WireHits, using the WireHitSim
96  {
97  newWireHits.swap(theWireHitSim->simulate(layer, layerSimHits));
98  }
99  if(!newWireHits.empty()) {
100  newStripHits.swap(theStripHitSim->simulate(layer, newWireHits));
101  }
102 
103  // turn the hits into wire digis, using the electronicsSim
104  {
105  theWireElectronicsSim->simulate(layer, newWireHits);
106  theWireElectronicsSim->fillDigis(wireDigis);
107  wireDigiSimLinks.insert( theWireElectronicsSim->digiSimLinks() );
108  }
109  {
110  theStripElectronicsSim->simulate(layer, newStripHits);
111  theStripElectronicsSim->fillDigis(stripDigis, comparators);
112  stripDigiSimLinks.insert( theStripElectronicsSim->digiSimLinks() );
113  }
114  }
115 
116  // fill in the layers were missing from this chamber
117  std::list<int> missingLayers = layersMissing(stripDigis);
118  for(std::list<int>::const_iterator missingLayerItr = missingLayers.begin();
119  missingLayerItr != missingLayers.end(); ++missingLayerItr)
120  {
121  const CSCLayer * layer = findLayer(*missingLayerItr);
122  theStripElectronicsSim->fillMissingLayer(layer, comparators, stripDigis);
123  }
124 }
int chamber() const
Definition: CSCDetId.h:70
std::vector< CSCDetectorHit > & simulate(const CSCLayer *layer, const std::vector< CSCDetectorHit > &wireHits)
unsigned int theLayersNeeded
Definition: CSCDigitizer.h:83
CSCDetId id() const
Definition: CSCLayer.h:42
void fillMissingLayer(const CSCLayer *layer, const CSCComparatorDigiCollection &comparators, CSCStripDigiCollection &digis)
const CSCLayer * findLayer(int detId) const
finds the layer in the geometry associated with this det ID
int layer() const
Definition: CSCDetId.h:63
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:95
iterator end()
bool digitizeBadChambers_
Definition: CSCDigitizer.h:84
const DigiSimLinks & digiSimLinks() const
CSCStripElectronicsSim * theStripElectronicsSim
Definition: CSCDigitizer.h:79
CSCNeutronReader * theNeutronReader
Definition: CSCDigitizer.h:80
#define LogTrace(id)
CSCWireHitSim * theWireHitSim
Definition: CSCDigitizer.h:76
int ring() const
Definition: CSCDetId.h:77
iterator begin()
std::vector< CSCDetectorHit > & simulate(const CSCLayer *layer, const edm::PSimHitContainer &simHits)
void simulate(const CSCLayer *layer, const std::vector< CSCDetectorHit > &inputHits)
void fillDigis(CSCStripDigiCollection &digis, CSCComparatorDigiCollection &comparators)
void fillDigis(CSCWireDigiCollection &digis)
CSCWireElectronicsSim * theWireElectronicsSim
Definition: CSCDigitizer.h:78
int station() const
Definition: CSCDetId.h:88
std::vector< PSimHit > PSimHitContainer
virtual bool isInBadChamber(const CSCDetId &id) const
is supplied layer/chamber flagged as bad? (default impl. is no)
void addHits(std::map< int, edm::PSimHitContainer > &hitMap)
CSCStripHitSim * theStripHitSim
Definition: CSCDigitizer.h:77
CSCStripConditions * theConditions
Definition: CSCDigitizer.h:82
const CSCLayer * CSCDigitizer::findLayer ( int  detId) const
private

finds the layer in the geometry associated with this det ID

Definition at line 199 of file CSCDigitizer.cc.

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

Referenced by doAction().

199  {
200  assert(theCSCGeometry != 0);
201  const GeomDetUnit* detUnit = theCSCGeometry->idToDetUnit(CSCDetId(detId));
202  if(detUnit == 0)
203  {
204  throw cms::Exception("CSCDigiProducer") << "Invalid DetUnit: " << CSCDetId(detId)
205  << "\nPerhaps your signal or pileup dataset are not compatible with the current release?";
206  }
207  return dynamic_cast<const CSCLayer *>(detUnit);
208 }
virtual const GeomDetUnit * idToDetUnit(DetId) const
Return the pointer to the GeomDetUnit corresponding to a given DetId.
Definition: CSCGeometry.cc:93
const CSCGeometry * theCSCGeometry
Definition: CSCDigitizer.h:81
std::list< int > CSCDigitizer::layersMissing ( const CSCStripDigiCollection stripDigis) const
private

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

Definition at line 127 of file CSCDigitizer.cc.

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

Referenced by doAction().

128 {
129  std::list<int> result;
130 
131  std::map<int, std::list<int> > layersInChamberWithDigi;
132  for (CSCStripDigiCollection::DigiRangeIterator j=stripDigis.begin();
133  j!=stripDigis.end(); j++)
134  {
135  CSCDetId layerId((*j).first);
136  // make sure the vector of digis isn't empty
137  if((*j).second.first != (*j).second.second)
138  {
139  int chamberId = layerId.chamberId();
140  layersInChamberWithDigi[chamberId].push_back(layerId.layer());
141  }
142  }
143 
144  std::list<int> oneThruSix;
145  for(int i = 1; i <=6; ++i)
146  oneThruSix.push_back(i);
147 
148  for(std::map<int, std::list<int> >::iterator layersInChamberWithDigiItr = layersInChamberWithDigi.begin();
149  layersInChamberWithDigiItr != layersInChamberWithDigi.end(); ++ layersInChamberWithDigiItr)
150  {
151  std::list<int> & layersHit = layersInChamberWithDigiItr->second;
152  if (layersHit.size() < 6 && layersHit.size() >= theLayersNeeded)
153  {
154  layersHit.sort();
155  std::list<int> missingLayers(6);
156  std::list<int>::iterator lastLayerMissing =
157  set_difference(oneThruSix.begin(), oneThruSix.end(),
158  layersHit.begin(), layersHit.end(), missingLayers.begin());
159  int chamberId = layersInChamberWithDigiItr->first;
160  for(std::list<int>::iterator layerMissingItr = missingLayers.begin();
161  layerMissingItr != lastLayerMissing; ++layerMissingItr)
162  {
163  // got from layer 1-6 to layer ID
164  result.push_back(chamberId + *layerMissingItr);
165  }
166  }
167  }
168  return result;
169 }
int i
Definition: DBlmapReader.cc:9
unsigned int theLayersNeeded
Definition: CSCDigitizer.h:83
tuple result
Definition: query.py:137
int j
Definition: DBlmapReader.cc:9
void CSCDigitizer::setGeometry ( const CSCGeometry geom)
inline

sets geometry

Definition at line 57 of file CSCDigitizer.h.

References relativeConstraints::geom, and theCSCGeometry.

Referenced by CSCDigiProducer::produce().

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

sets the magnetic field

Definition at line 172 of file CSCDigitizer.cc.

References CSCDriftSim::setMagneticField(), and theDriftSim.

Referenced by CSCDigiProducer::produce().

172  {
174 }
CSCDriftSim * theDriftSim
Definition: CSCDigitizer.h:75
void setMagneticField(const MagneticField *field)
Definition: CSCDriftSim.h:43
void CSCDigitizer::setParticleDataTable ( const ParticleDataTable pdt)

Definition at line 184 of file CSCDigitizer.cc.

References CSCWireHitSim::setParticleDataTable(), and theWireHitSim.

Referenced by CSCDigiProducer::produce().

185 {
187 }
CSCWireHitSim * theWireHitSim
Definition: CSCDigitizer.h:76
void setParticleDataTable(const ParticleDataTable *pdt)
void CSCDigitizer::setRandomEngine ( CLHEP::HepRandomEngine &  engine)

Definition at line 190 of file CSCDigitizer.cc.

References SubsystemNeutronReader::setRandomEngine(), CSCWireHitSim::setRandomEngine(), CSCBaseElectronicsSim::setRandomEngine(), theNeutronReader, theStripElectronicsSim, theWireElectronicsSim, and theWireHitSim.

Referenced by CSCDigiProducer::CSCDigiProducer().

191 {
196 }
void setRandomEngine(CLHEP::HepRandomEngine &engine)
CSCStripElectronicsSim * theStripElectronicsSim
Definition: CSCDigitizer.h:79
CSCNeutronReader * theNeutronReader
Definition: CSCDigitizer.h:80
CSCWireHitSim * theWireHitSim
Definition: CSCDigitizer.h:76
void setRandomEngine(CLHEP::HepRandomEngine &engine)
CSCWireElectronicsSim * theWireElectronicsSim
Definition: CSCDigitizer.h:78
void setRandomEngine(CLHEP::HepRandomEngine &engine)
void CSCDigitizer::setStripConditions ( CSCStripConditions cond)

Definition at line 177 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:79
CSCStripConditions * theConditions
Definition: CSCDigitizer.h:82

Member Data Documentation

bool CSCDigitizer::digitizeBadChambers_
private

Definition at line 84 of file CSCDigitizer.h.

Referenced by doAction().

CSCStripConditions* CSCDigitizer::theConditions
private

Definition at line 82 of file CSCDigitizer.h.

Referenced by doAction(), and setStripConditions().

const CSCGeometry* CSCDigitizer::theCSCGeometry
private

Definition at line 81 of file CSCDigitizer.h.

Referenced by findLayer(), and setGeometry().

CSCDriftSim* CSCDigitizer::theDriftSim
private

Definition at line 75 of file CSCDigitizer.h.

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

unsigned int CSCDigitizer::theLayersNeeded
private

Definition at line 83 of file CSCDigitizer.h.

Referenced by doAction(), and layersMissing().

CSCNeutronReader* CSCDigitizer::theNeutronReader
private

Definition at line 80 of file CSCDigitizer.h.

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

CSCStripElectronicsSim* CSCDigitizer::theStripElectronicsSim
private

Definition at line 79 of file CSCDigitizer.h.

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

CSCStripHitSim* CSCDigitizer::theStripHitSim
private

Definition at line 77 of file CSCDigitizer.h.

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

CSCWireElectronicsSim* CSCDigitizer::theWireElectronicsSim
private

Definition at line 78 of file CSCDigitizer.h.

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

CSCWireHitSim* CSCDigitizer::theWireHitSim
private

Definition at line 76 of file CSCDigitizer.h.

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