CMS 3D CMS Logo

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

SiStripDigitizer Class Reference

#include <SiStripDigitizer.h>

List of all members.

Public Member Functions

virtual void accumulate (edm::Event const &e, edm::EventSetup const &c)
virtual void accumulate (PileUpEventPrincipal const &e, edm::EventSetup const &c)
virtual void finalizeEvent (edm::Event &e, edm::EventSetup const &c)
virtual void initializeEvent (edm::Event const &e, edm::EventSetup const &c)
 SiStripDigitizer (const edm::ParameterSet &conf, edm::EDProducer &mixMod)
virtual ~SiStripDigitizer ()

Private Types

typedef std::map< unsigned int,
std::vector< std::pair< const
PSimHit *, int > >, std::less
< unsigned int > > 
simhit_map
typedef simhit_map::iterator simhit_map_iterator
typedef std::vector< std::string > vstring

Private Member Functions

void accumulateStripHits (edm::Handle< std::vector< PSimHit > >, const TrackerTopology *tTopo)

Private Attributes

std::map< unsigned int,
StripGeomDetUnit * > 
detectorUnits
const std::string gainLabel
const std::string geometryType
const std::string hitsProducer
edm::ESHandle< TrackerGeometry > pDD
const std::string PRDigi
edm::ESHandle< MagneticField > pSetup
CLHEP::HepRandomEngine * rndEngine
const std::string SCDigi
std::map< uint32_t,
std::vector< int > > 
theDetIdList
std::unique_ptr
< SiStripDigitizerAlgorithm
theDigiAlgo
const vstring trackerContainers
const bool useConfFromDB
const std::string VRDigi
const bool zeroSuppression
const std::string ZSDigi

Detailed Description

SiStripDigitizer to convert hits to digis

Definition at line 39 of file SiStripDigitizer.h.


Member Typedef Documentation

typedef std::map<unsigned int, std::vector<std::pair<const PSimHit*, int> >,std::less<unsigned int> > SiStripDigitizer::simhit_map [private]

Definition at line 54 of file SiStripDigitizer.h.

typedef simhit_map::iterator SiStripDigitizer::simhit_map_iterator [private]

Definition at line 55 of file SiStripDigitizer.h.

typedef std::vector<std::string> SiStripDigitizer::vstring [private]

Definition at line 53 of file SiStripDigitizer.h.


Constructor & Destructor Documentation

SiStripDigitizer::SiStripDigitizer ( const edm::ParameterSet &  conf,
edm::EDProducer &  mixMod 
) [explicit]

Definition at line 55 of file SiStripDigitizer.cc.

References PRDigi, rndEngine, SCDigi, theDigiAlgo, VRDigi, and ZSDigi.

                                                                                     : 
  gainLabel(conf.getParameter<std::string>("Gain")),
  hitsProducer(conf.getParameter<std::string>("hitsProducer")),
  trackerContainers(conf.getParameter<std::vector<std::string> >("ROUList")),
  ZSDigi(conf.getParameter<edm::ParameterSet>("DigiModeList").getParameter<std::string>("ZSDigi")),
  SCDigi(conf.getParameter<edm::ParameterSet>("DigiModeList").getParameter<std::string>("SCDigi")),
  VRDigi(conf.getParameter<edm::ParameterSet>("DigiModeList").getParameter<std::string>("VRDigi")),
  PRDigi(conf.getParameter<edm::ParameterSet>("DigiModeList").getParameter<std::string>("PRDigi")),
  geometryType(conf.getParameter<std::string>("GeometryType")),
  useConfFromDB(conf.getParameter<bool>("TrackerConfigurationFromDB")),
  zeroSuppression(conf.getParameter<bool>("ZeroSuppression"))
{ 
  const std::string alias("simSiStripDigis");
  
  mixMod.produces<edm::DetSetVector<SiStripDigi> >(ZSDigi).setBranchAlias(ZSDigi);
  mixMod.produces<edm::DetSetVector<SiStripRawDigi> >(SCDigi).setBranchAlias(alias + SCDigi);
  mixMod.produces<edm::DetSetVector<SiStripRawDigi> >(VRDigi).setBranchAlias(alias + VRDigi);
  mixMod.produces<edm::DetSetVector<SiStripRawDigi> >(PRDigi).setBranchAlias(alias + PRDigi);
  edm::Service<edm::RandomNumberGenerator> rng;
  if ( ! rng.isAvailable()) {
    throw cms::Exception("Configuration")
      << "SiStripDigitizer requires the RandomNumberGeneratorService\n"
      "which is not present in the configuration file.  You must add the service\n"
      "in the configuration file or remove the modules that require it.";
  }
  
  rndEngine = &(rng->getEngine());
  theDigiAlgo.reset(new SiStripDigitizerAlgorithm(conf,(*rndEngine)));

}
SiStripDigitizer::~SiStripDigitizer ( ) [virtual]

Definition at line 87 of file SiStripDigitizer.cc.

                                    { 
}  

Member Function Documentation

void SiStripDigitizer::accumulate ( edm::Event const &  e,
edm::EventSetup const &  c 
) [virtual]

Definition at line 112 of file SiStripDigitizer.cc.

References accumulateStripHits(), hitsProducer, linker::i, and trackerContainers.

                                                                                  {
    //Retrieve tracker topology from geometry
    edm::ESHandle<TrackerTopology> tTopoHand;
    iSetup.get<IdealGeometryRecord>().get(tTopoHand);
    const TrackerTopology *tTopo=tTopoHand.product();

    // Step A: Get Inputs
    for(vstring::const_iterator i = trackerContainers.begin(), iEnd = trackerContainers.end(); i != iEnd; ++i) {
      edm::Handle<std::vector<PSimHit> > simHits;
      edm::InputTag tag(hitsProducer, *i);

      iEvent.getByLabel(tag, simHits);
      accumulateStripHits(simHits,tTopo);
    }
  }
void SiStripDigitizer::accumulate ( PileUpEventPrincipal const &  e,
edm::EventSetup const &  c 
) [virtual]

Definition at line 129 of file SiStripDigitizer.cc.

References accumulateStripHits(), hitsProducer, linker::i, and trackerContainers.

                                                                                              {

    edm::ESHandle<TrackerTopology> tTopoHand;
    iSetup.get<IdealGeometryRecord>().get(tTopoHand);
    const TrackerTopology *tTopo=tTopoHand.product();

    // Step A: Get Inputs
    for(vstring::const_iterator i = trackerContainers.begin(), iEnd = trackerContainers.end(); i != iEnd; ++i) {
      edm::Handle<std::vector<PSimHit> > simHits;
      edm::InputTag tag(hitsProducer, *i);

      iEvent.getByLabel(tag, simHits);
      accumulateStripHits(simHits,tTopo);
    }
  }
void SiStripDigitizer::accumulateStripHits ( edm::Handle< std::vector< PSimHit > >  hSimHits,
const TrackerTopology *  tTopo 
) [private]

Definition at line 90 of file SiStripDigitizer.cc.

References detectorUnits, pSetup, and theDigiAlgo.

Referenced by accumulate().

                                                                         {
  if(hSimHits.isValid()) {
    std::set<unsigned int> detIds;
    std::vector<PSimHit> const& simHits = *hSimHits.product();
    for(std::vector<PSimHit>::const_iterator it = simHits.begin(), itEnd = simHits.end(); it != itEnd; ++it) {
      unsigned int detId = (*it).detUnitId();
      if(detIds.insert(detId).second) {
        // The insert succeeded, so this detector element has not yet been processed.
        StripGeomDetUnit* stripdet = detectorUnits[detId];
        //access to magnetic field in global coordinates
        GlobalVector bfield = pSetup->inTesla(stripdet->surface().position());
        LogDebug ("Digitizer ") << "B-field(T) at " << stripdet->surface().position() << "(cm): "
                                << pSetup->inTesla(stripdet->surface().position());
        theDigiAlgo->accumulateSimHits(it, itEnd, stripdet, bfield, tTopo);
      }
    }
  }
}
void SiStripDigitizer::finalizeEvent ( edm::Event &  e,
edm::EventSetup const &  c 
) [virtual]

Definition at line 183 of file SiStripDigitizer.cc.

References gainLabel, Association::output, pDD, PRDigi, SCDigi, theDetIdList, theDigiAlgo, useConfFromDB, VRDigi, zeroSuppression, and ZSDigi.

                                                                                  {
  edm::ESHandle<SiStripGain> gainHandle;
  edm::ESHandle<SiStripNoises> noiseHandle;
  edm::ESHandle<SiStripThreshold> thresholdHandle;
  edm::ESHandle<SiStripPedestals> pedestalHandle;
  iSetup.get<SiStripGainSimRcd>().get(gainLabel,gainHandle);
  iSetup.get<SiStripNoisesRcd>().get(noiseHandle);
  iSetup.get<SiStripThresholdRcd>().get(thresholdHandle);
  iSetup.get<SiStripPedestalsRcd>().get(pedestalHandle);

  std::vector<edm::DetSet<SiStripDigi> > theDigiVector;
  std::vector<edm::DetSet<SiStripRawDigi> > theRawDigiVector;

  
  // Step B: LOOP on StripGeomDetUnit
  theDigiVector.reserve(10000);
  theDigiVector.clear();

  for(TrackingGeometry::DetUnitContainer::const_iterator iu = pDD->detUnits().begin(); iu != pDD->detUnits().end(); iu ++){
    if(useConfFromDB){
      //apply the cable map _before_ digitization: consider only the detis that are connected 
      if(theDetIdList.find((*iu)->geographicalId().rawId())==theDetIdList.end())
        continue;
    }
    StripGeomDetUnit* sgd = dynamic_cast<StripGeomDetUnit*>((*iu));
    if (sgd != 0){
      edm::DetSet<SiStripDigi> collectorZS((*iu)->geographicalId().rawId());
      edm::DetSet<SiStripRawDigi> collectorRaw((*iu)->geographicalId().rawId());
      theDigiAlgo->digitize(collectorZS,collectorRaw,sgd,
                       gainHandle,thresholdHandle,noiseHandle,pedestalHandle);
      if(zeroSuppression){
        if(collectorZS.data.size()>0){
          theDigiVector.push_back(collectorZS);
        }
      }else{
        if(collectorRaw.data.size()>0){
          theRawDigiVector.push_back(collectorRaw);
        }
      }
    }
  }

  if(zeroSuppression){
    // Step C: create output collection
    std::auto_ptr<edm::DetSetVector<SiStripRawDigi> > output_virginraw(new edm::DetSetVector<SiStripRawDigi>());
    std::auto_ptr<edm::DetSetVector<SiStripRawDigi> > output_scopemode(new edm::DetSetVector<SiStripRawDigi>());
    std::auto_ptr<edm::DetSetVector<SiStripRawDigi> > output_processedraw(new edm::DetSetVector<SiStripRawDigi>());
    std::auto_ptr<edm::DetSetVector<SiStripDigi> > output(new edm::DetSetVector<SiStripDigi>(theDigiVector) );
    // Step D: write output to file
    iEvent.put(output, ZSDigi);
    iEvent.put(output_scopemode, SCDigi);
    iEvent.put(output_virginraw, VRDigi);
    iEvent.put(output_processedraw, PRDigi);
  }else{
    // Step C: create output collection
    std::auto_ptr<edm::DetSetVector<SiStripRawDigi> > output_virginraw(new edm::DetSetVector<SiStripRawDigi>(theRawDigiVector));
    std::auto_ptr<edm::DetSetVector<SiStripRawDigi> > output_scopemode(new edm::DetSetVector<SiStripRawDigi>());
    std::auto_ptr<edm::DetSetVector<SiStripRawDigi> > output_processedraw(new edm::DetSetVector<SiStripRawDigi>());
    std::auto_ptr<edm::DetSetVector<SiStripDigi> > output(new edm::DetSetVector<SiStripDigi>() );
    // Step D: write output to file
    iEvent.put(output, ZSDigi);
    iEvent.put(output_scopemode, SCDigi);
    iEvent.put(output_virginraw, VRDigi);
    iEvent.put(output_processedraw, PRDigi);
  }
}
void SiStripDigitizer::initializeEvent ( edm::Event const &  e,
edm::EventSetup const &  c 
) [virtual]

Definition at line 146 of file SiStripDigitizer.cc.

References detectorUnits, geometryType, pDD, pSetup, theDetIdList, theDigiAlgo, and useConfFromDB.

                                                                                          {
  // Step A: Get Inputs

  if(useConfFromDB){
    edm::ESHandle<SiStripDetCabling> detCabling;
    iSetup.get<SiStripDetCablingRcd>().get(detCabling);
    detCabling->addConnected(theDetIdList);
  }

  theDigiAlgo->initializeEvent(iSetup);

  iSetup.get<TrackerDigiGeometryRecord>().get(geometryType,pDD);
  iSetup.get<IdealMagneticFieldRecord>().get(pSetup);

  // FIX THIS! We only need to clear and (re)fill detectorUnits when the geometry type IOV changes.  Use ESWatcher to determine this.
  bool changes = true;
  if(changes) { // Replace with ESWatcher
    detectorUnits.clear();
  }
  for(TrackingGeometry::DetUnitContainer::const_iterator iu = pDD->detUnits().begin(); iu != pDD->detUnits().end(); ++iu) {
    unsigned int detId = (*iu)->geographicalId().rawId();
    DetId idet=DetId(detId);
    unsigned int isub=idet.subdetId();
    if((isub == StripSubdetector::TIB) ||
       (isub == StripSubdetector::TID) ||
       (isub == StripSubdetector::TOB) ||
       (isub == StripSubdetector::TEC)) {
      StripGeomDetUnit* stripdet = dynamic_cast<StripGeomDetUnit*>((*iu));
      assert(stripdet != 0);
      if(changes) { // Replace with ESWatcher
        detectorUnits.insert(std::make_pair(detId, stripdet));
      }
      theDigiAlgo->initializeDetUnit(stripdet, iSetup);
    }
  }
}

Member Data Documentation

std::map<unsigned int, StripGeomDetUnit*> SiStripDigitizer::detectorUnits [private]

Definition at line 72 of file SiStripDigitizer.h.

Referenced by accumulateStripHits(), and initializeEvent().

const std::string SiStripDigitizer::gainLabel [private]

Definition at line 57 of file SiStripDigitizer.h.

Referenced by finalizeEvent().

const std::string SiStripDigitizer::geometryType [private]

Definition at line 64 of file SiStripDigitizer.h.

Referenced by initializeEvent().

const std::string SiStripDigitizer::hitsProducer [private]

Definition at line 58 of file SiStripDigitizer.h.

Referenced by accumulate().

edm::ESHandle<TrackerGeometry> SiStripDigitizer::pDD [private]

Definition at line 70 of file SiStripDigitizer.h.

Referenced by finalizeEvent(), and initializeEvent().

const std::string SiStripDigitizer::PRDigi [private]

Definition at line 63 of file SiStripDigitizer.h.

Referenced by finalizeEvent(), and SiStripDigitizer().

edm::ESHandle<MagneticField> SiStripDigitizer::pSetup [private]

Definition at line 71 of file SiStripDigitizer.h.

Referenced by accumulateStripHits(), and initializeEvent().

CLHEP::HepRandomEngine* SiStripDigitizer::rndEngine [private]

Definition at line 74 of file SiStripDigitizer.h.

Referenced by SiStripDigitizer().

const std::string SiStripDigitizer::SCDigi [private]

Definition at line 61 of file SiStripDigitizer.h.

Referenced by finalizeEvent(), and SiStripDigitizer().

std::map<uint32_t, std::vector<int> > SiStripDigitizer::theDetIdList [private]

Definition at line 69 of file SiStripDigitizer.h.

Referenced by finalizeEvent(), and initializeEvent().

Definition at line 59 of file SiStripDigitizer.h.

Referenced by accumulate().

const bool SiStripDigitizer::useConfFromDB [private]

Definition at line 65 of file SiStripDigitizer.h.

Referenced by finalizeEvent(), and initializeEvent().

const std::string SiStripDigitizer::VRDigi [private]

Definition at line 62 of file SiStripDigitizer.h.

Referenced by finalizeEvent(), and SiStripDigitizer().

const bool SiStripDigitizer::zeroSuppression [private]

Definition at line 66 of file SiStripDigitizer.h.

Referenced by finalizeEvent().

const std::string SiStripDigitizer::ZSDigi [private]

Definition at line 60 of file SiStripDigitizer.h.

Referenced by finalizeEvent(), and SiStripDigitizer().