CMS 3D CMS Logo

Public Types | Public Member Functions | Private Member Functions | Private Attributes

CSCDigitizer Class Reference

#include <CSCDigitizer.h>

List of all members.

Public Types

typedef edm::DetSetVector
< StripDigiSimLink
DigiSimLinks

Public Member Functions

 CSCDigitizer (const edm::ParameterSet &p)
 configurable parameters
void doAction (MixCollection< PSimHit > &simHits, CSCWireDigiCollection &wireDigis, CSCStripDigiCollection &stripDigis, CSCComparatorDigiCollection &comparators, DigiSimLinks &wireDigiSimLinks, DigiSimLinks &stripDigiSimLinks)
void setGeometry (const CSCGeometry *geom)
 sets geometry
void setMagneticField (const MagneticField *field)
 sets the magnetic field
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
std::list< int > layersMissing (const CSCStripDigiCollection &stripDigis) const
 finds which layers, 1-6, aren't in the current list

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]
CSCDigitizer::~CSCDigitizer ( )

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(), CSCStripElectronicsSim::fillDigis(), CSCWireElectronicsSim::fillDigis(), CSCStripElectronicsSim::fillMissingLayer(), findLayer(), CSCLayer::id(), edm::DetSetVector< T >::insert(), CSCStripConditions::isInBadChamber(), CSCDetId::layer(), layersMissing(), LogTrace, CSCDetId::ring(), CSCBaseElectronicsSim::simulate(), CSCWireHitSim::simulate(), CSCStripHitSim::simulate(), CSCDetId::station(), theConditions, theLayersNeeded, theNeutronReader, theStripElectronicsSim, theStripHitSim, theWireElectronicsSim, and theWireHitSim.

Referenced by CSCDigiProducer::produce().

{
  // arrange the hits by layer
  std::map<int, edm::PSimHitContainer> hitMap;
  for(MixCollection<PSimHit>::MixItr hitItr = simHits.begin();
      hitItr != simHits.end(); ++hitItr) 
  {
    hitMap[hitItr->detUnitId()].push_back(*hitItr);
  }

  // count how many layers on each chamber are hit
  std::map<int, std::set<int> > layersInChamberHit;
  for(std::map<int, edm::PSimHitContainer>::const_iterator hitMapItr = hitMap.begin();
      hitMapItr != hitMap.end(); ++hitMapItr)
  {
    CSCDetId cscDetId(hitMapItr->first); 
    int chamberId = cscDetId.chamberId();
    layersInChamberHit[chamberId].insert(cscDetId.layer());
  }

  // add neutron background, if needed
  if(theNeutronReader != 0)
  {
    theNeutronReader->addHits(hitMap);
  }

  // now loop over layers and run the simulation for each one
  for(std::map<int, edm::PSimHitContainer>::const_iterator hitMapItr = hitMap.begin();
      hitMapItr != hitMap.end(); ++hitMapItr)
  {
    int chamberId = CSCDetId(hitMapItr->first).chamberId();
    unsigned int nLayersInChamberHit = layersInChamberHit[chamberId].size();
    if(nLayersInChamberHit < theLayersNeeded) continue;
    // skip bad chambers
    if ( !digitizeBadChambers_ && theConditions->isInBadChamber( CSCDetId(hitMapItr->first) ) ) continue;

    const CSCLayer * layer = findLayer(hitMapItr->first);
    const edm::PSimHitContainer & layerSimHits = hitMapItr->second;

    std::vector<CSCDetectorHit> newWireHits, newStripHits;
  
    LogTrace("CSCDigitizer") << "CSCDigitizer: found " << layerSimHits.size() <<" hit(s) in layer"
       << " E" << layer->id().endcap() << " S" << layer->id().station() << " R" << layer->id().ring()
       << " C" << layer->id().chamber() << " L" << layer->id().layer();

    // turn the edm::PSimHits into WireHits, using the WireHitSim
    {
      newWireHits.swap(theWireHitSim->simulate(layer, layerSimHits));
    }
    if(!newWireHits.empty()) {
      newStripHits.swap(theStripHitSim->simulate(layer, newWireHits));
    }

    // turn the hits into wire digis, using the electronicsSim
    {
      theWireElectronicsSim->simulate(layer, newWireHits);
      theWireElectronicsSim->fillDigis(wireDigis);
      wireDigiSimLinks.insert( theWireElectronicsSim->digiSimLinks() );
    }  
    {
      theStripElectronicsSim->simulate(layer, newStripHits);
      theStripElectronicsSim->fillDigis(stripDigis, comparators);
      stripDigiSimLinks.insert( theStripElectronicsSim->digiSimLinks() );
    }
  }

  // fill in the layers were missing from this chamber
  std::list<int> missingLayers = layersMissing(stripDigis);
  for(std::list<int>::const_iterator missingLayerItr = missingLayers.begin();
      missingLayerItr != missingLayers.end(); ++missingLayerItr)
  {
    const CSCLayer * layer = findLayer(*missingLayerItr);
    theStripElectronicsSim->fillMissingLayer(layer, comparators, stripDigis);
  }
}
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, Exception, CSCGeometry::idToDetUnit(), and theCSCGeometry.

Referenced by doAction().

                                                        {
  assert(theCSCGeometry != 0);
  const GeomDetUnit* detUnit = theCSCGeometry->idToDetUnit(CSCDetId(detId));
  if(detUnit == 0)
  {
    throw cms::Exception("CSCDigiProducer") << "Invalid DetUnit: " << CSCDetId(detId)
      << "\nPerhaps your signal or pileup dataset are not compatible with the current release?";
  }  
  return dynamic_cast<const CSCLayer *>(detUnit);
}
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().

{
  std::list<int> result;

  std::map<int, std::list<int> > layersInChamberWithDigi;
  for (CSCStripDigiCollection::DigiRangeIterator j=stripDigis.begin(); 
       j!=stripDigis.end(); j++) 
  {
    CSCDetId layerId((*j).first);
    // make sure the vector of digis isn't empty
    if((*j).second.first != (*j).second.second)
    {
      int chamberId = layerId.chamberId();
      layersInChamberWithDigi[chamberId].push_back(layerId.layer());
    }
 } 

  std::list<int> oneThruSix;
  for(int i = 1; i <=6; ++i)
    oneThruSix.push_back(i);

  for(std::map<int, std::list<int> >::iterator layersInChamberWithDigiItr = layersInChamberWithDigi.begin();
      layersInChamberWithDigiItr != layersInChamberWithDigi.end(); ++ layersInChamberWithDigiItr)
  {
    std::list<int> & layersHit = layersInChamberWithDigiItr->second;
    if (layersHit.size() < 6 && layersHit.size() >= theLayersNeeded) 
    {
      layersHit.sort();
      std::list<int> missingLayers(6);
      std::list<int>::iterator lastLayerMissing =
        set_difference(oneThruSix.begin(), oneThruSix.end(),
                       layersHit.begin(), layersHit.end(), missingLayers.begin());
      int chamberId = layersInChamberWithDigiItr->first;
      for(std::list<int>::iterator layerMissingItr = missingLayers.begin();
          layerMissingItr != lastLayerMissing; ++layerMissingItr)
      {
        // got from layer 1-6 to layer ID
        result.push_back(chamberId + *layerMissingItr); 
      }
    }
  }
  return result;
}
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().

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

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

{
  theConditions = cond; // cache here
  theStripElectronicsSim->setStripConditions(cond); // percolate downwards
}

Member Data Documentation

Definition at line 84 of file CSCDigitizer.h.

Referenced by doAction().

Definition at line 82 of file CSCDigitizer.h.

Referenced by doAction(), and setStripConditions().

Definition at line 81 of file CSCDigitizer.h.

Referenced by findLayer(), and setGeometry().

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

Definition at line 80 of file CSCDigitizer.h.

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

Definition at line 79 of file CSCDigitizer.h.

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

Definition at line 77 of file CSCDigitizer.h.

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

Definition at line 78 of file CSCDigitizer.h.

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

Definition at line 76 of file CSCDigitizer.h.

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