CMS 3D CMS Logo

Public Member Functions | Private Types | Private Attributes

SiStripDigitizer Class Reference

#include <SiStripDigitizer.h>

Inheritance diagram for SiStripDigitizer:
edm::EDProducer edm::ProducerBase edm::ProductRegistryHelper

List of all members.

Public Member Functions

virtual void produce (edm::Event &e, const edm::EventSetup &c)
 SiStripDigitizer (const edm::ParameterSet &conf)
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 Attributes

std::string alias
edm::ParameterSet conf_
std::string geometryType
int numStrips
CLHEP::HepRandomEngine * rndEngine
simhit_map SimHitMap
SimHitSelectorFromDB SimHitSelectorFromDB_
std::map< uint32_t,
std::vector< int > > 
theDetIdList
SiStripDigitizerAlgorithmtheDigiAlgo
std::vector< edm::DetSet
< StripDigiSimLink > > 
theDigiLinkVector
std::vector< edm::DetSet
< SiStripDigi > > 
theDigiVector
std::vector< edm::DetSet
< SiStripRawDigi > > 
theRawDigiVector
SiStripFedZeroSuppressiontheSiFEDZeroSuppress
vstring trackerContainers
bool useConfFromDB
bool zeroSuppression

Detailed Description

SiStripDigitizer to convert hits to digis

Definition at line 35 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 47 of file SiStripDigitizer.h.

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

Definition at line 48 of file SiStripDigitizer.h.

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

Definition at line 46 of file SiStripDigitizer.h.


Constructor & Destructor Documentation

SiStripDigitizer::SiStripDigitizer ( const edm::ParameterSet conf) [explicit]

Definition at line 63 of file SiStripDigitizer.cc.

References alias, conf_, Exception, geometryType, edm::ParameterSet::getParameter(), rndEngine, theDigiAlgo, trackerContainers, useConfFromDB, and zeroSuppression.

                                                              : 
  conf_(conf)
{
  alias = conf.getParameter<std::string>("@module_label");
  edm::ParameterSet ParamSet=conf_.getParameter<edm::ParameterSet>("DigiModeList");
  
  produces<edm::DetSetVector<SiStripDigi> >(ParamSet.getParameter<std::string>("ZSDigi")).setBranchAlias( ParamSet.getParameter<std::string>("ZSDigi") );
  produces<edm::DetSetVector<StripDigiSimLink> >().setBranchAlias ( alias + "siStripDigiSimLink");
  produces<edm::DetSetVector<SiStripRawDigi> >(ParamSet.getParameter<std::string>("SCDigi")).setBranchAlias( alias + ParamSet.getParameter<std::string>("SCDigi") );
  produces<edm::DetSetVector<SiStripRawDigi> >(ParamSet.getParameter<std::string>("VRDigi")).setBranchAlias( alias + ParamSet.getParameter<std::string>("VRDigi") );
  produces<edm::DetSetVector<SiStripRawDigi> >(ParamSet.getParameter<std::string>("PRDigi")).setBranchAlias( alias + ParamSet.getParameter<std::string>("PRDigi") );
  trackerContainers.clear();
  trackerContainers = conf.getParameter<std::vector<std::string> >("ROUList");
  geometryType = conf.getParameter<std::string>("GeometryType");
  useConfFromDB = conf.getParameter<bool>("TrackerConfigurationFromDB");
  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());
  zeroSuppression = conf_.getParameter<bool>("ZeroSuppression");
  theDigiAlgo = new SiStripDigitizerAlgorithm(conf_,(*rndEngine));

}
SiStripDigitizer::~SiStripDigitizer ( ) [virtual]

Definition at line 93 of file SiStripDigitizer.cc.

References theDigiAlgo.

                                    { 
  delete theDigiAlgo;
}  

Member Function Documentation

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

Implements edm::EDProducer.

Definition at line 98 of file SiStripDigitizer.cc.

References conf_, geometryType, edm::EventSetup::get(), edm::Event::getByLabel(), edm::EventSetup::getData(), edm::ParameterSet::getParameter(), SimHitSelectorFromDB::getSimHit(), i, edm::ESHandleBase::isValid(), SiStripDigitizerAlgorithm::make_link(), convertSQLitetoXML_cfg::output, edm::Handle< T >::product(), edm::Event::put(), SiStripDigitizerAlgorithm::run(), SiStripDigitizerAlgorithm::setParticleDataTable(), SimHitMap, SimHitSelectorFromDB_, theDetIdList, theDigiAlgo, theDigiLinkVector, theDigiVector, theRawDigiVector, trackerContainers, useConfFromDB, and zeroSuppression.

{
  // Step A: Get Inputs
  edm::ESHandle < ParticleDataTable > pdt;
  iSetup.getData( pdt );

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

  edm::Handle<CrossingFrame<PSimHit> > cf_simhit;
  std::vector<const CrossingFrame<PSimHit> *> cf_simhitvec;
  for(uint32_t i = 0; i< trackerContainers.size();i++){
    iEvent.getByLabel("mix",trackerContainers[i],cf_simhit);
    cf_simhitvec.push_back(cf_simhit.product());
  }

  std::auto_ptr<MixCollection<PSimHit> > allTrackerHits(new MixCollection<PSimHit>(cf_simhitvec));
  
  //Loop on PSimHit
  SimHitMap.clear();
  
  //inside SimHitSelectorFromDb add the counter information from the original allhits collection 
  std::vector<std::pair<const PSimHit*,int> > trackerHits(SimHitSelectorFromDB_.getSimHit(allTrackerHits,theDetIdList));
  std::vector<std::pair<const PSimHit*,int> >::iterator isim;
  for (isim=trackerHits.begin() ; isim!= trackerHits.end();isim++) {
    //make a pair = <*isim, counter> and save also position in the vector for DigiSimLink
    SimHitMap[((*isim).first)->detUnitId()].push_back(*isim);
  }
  
  edm::ESHandle<TrackerGeometry> pDD;
  iSetup.get<TrackerDigiGeometryRecord>().get(geometryType,pDD);
  
  edm::ESHandle<MagneticField> pSetup;
  iSetup.get<IdealMagneticFieldRecord>().get(pSetup);
  
  //get gain noise pedestal lorentzAngle from ES handle
  edm::ESHandle<SiStripLorentzAngle> lorentzAngleHandle;
  edm::ESHandle<SiStripGain> gainHandle;
  edm::ESHandle<SiStripNoises> noiseHandle;
  edm::ESHandle<SiStripThreshold> thresholdHandle;
  edm::ESHandle<SiStripPedestals> pedestalHandle;
  edm::ESHandle<SiStripBadStrip> deadChannelHandle;
  std::string LAname = conf_.getParameter<std::string>("LorentzAngle");
  iSetup.get<SiStripLorentzAngleSimRcd>().get(LAname,lorentzAngleHandle);
  std::string gainLabel = conf_.getParameter<std::string>("Gain");
  iSetup.get<SiStripGainSimRcd>().get(gainLabel,gainHandle);
  iSetup.get<SiStripNoisesRcd>().get(noiseHandle);
  iSetup.get<SiStripThresholdRcd>().get(thresholdHandle);
  iSetup.get<SiStripPedestalsRcd>().get(pedestalHandle);
  iSetup.get<SiStripBadChannelRcd>().get(deadChannelHandle);
  
  theDigiAlgo->setParticleDataTable(&*pdt);

  // Step B: LOOP on StripGeomDetUnit
  theDigiVector.reserve(10000);
  theDigiVector.clear();
  theDigiLinkVector.reserve(10000);
  theDigiLinkVector.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;
    }
    GlobalVector bfield=pSetup->inTesla((*iu)->surface().position());
    StripGeomDetUnit* sgd = dynamic_cast<StripGeomDetUnit*>((*iu));
    if (sgd != 0){
      edm::DetSet<SiStripDigi> collectorZS((*iu)->geographicalId().rawId());
      edm::DetSet<SiStripRawDigi> collectorRaw((*iu)->geographicalId().rawId());
      edm::DetSet<StripDigiSimLink> linkcollector((*iu)->geographicalId().rawId());
      float langle = (lorentzAngleHandle.isValid()) ? lorentzAngleHandle->getLorentzAngle((*iu)->geographicalId().rawId()) : 0.;
      theDigiAlgo->run(collectorZS,collectorRaw,SimHitMap[(*iu)->geographicalId().rawId()],sgd,bfield,langle,
                       gainHandle,thresholdHandle,noiseHandle,pedestalHandle, deadChannelHandle);
      if(zeroSuppression){
        if(collectorZS.data.size()>0){
          theDigiVector.push_back(collectorZS);
          if(SimHitMap[(*iu)->geographicalId().rawId()].size()>0){
            linkcollector.data = theDigiAlgo->make_link();
            if(linkcollector.data.size()>0)
              theDigiLinkVector.push_back(linkcollector);
          }
        }
      }else{
        if(collectorRaw.data.size()>0){
          theRawDigiVector.push_back(collectorRaw);
          if(SimHitMap[(*iu)->geographicalId().rawId()].size()>0){
            linkcollector.data = theDigiAlgo->make_link();
            if(linkcollector.data.size()>0)
              theDigiLinkVector.push_back(linkcollector);
          }
        }
      }
    }
  }

  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) );
    std::auto_ptr<edm::DetSetVector<StripDigiSimLink> > outputlink(new edm::DetSetVector<StripDigiSimLink>(theDigiLinkVector) );
    // Step D: write output to file
    edm::ParameterSet ParamSet=conf_.getParameter<edm::ParameterSet>("DigiModeList");
    iEvent.put(output,ParamSet.getParameter<std::string>("ZSDigi"));
    iEvent.put(outputlink);
    iEvent.put(output_scopemode,   ParamSet.getParameter<std::string>("SCDigi"));
    iEvent.put(output_virginraw,   ParamSet.getParameter<std::string>("VRDigi"));
    iEvent.put(output_processedraw,ParamSet.getParameter<std::string>("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>() );
    std::auto_ptr<edm::DetSetVector<StripDigiSimLink> > outputlink(new edm::DetSetVector<StripDigiSimLink>(theDigiLinkVector) );
    // Step D: write output to file
    edm::ParameterSet ParamSet=conf_.getParameter<edm::ParameterSet>("DigiModeList");
    iEvent.put(output,ParamSet.getParameter<std::string>("ZSDigi"));
    iEvent.put(outputlink);
    iEvent.put(output_scopemode,   ParamSet.getParameter<std::string>("SCDigi"));
    iEvent.put(output_virginraw,   ParamSet.getParameter<std::string>("VRDigi"));
    iEvent.put(output_processedraw,ParamSet.getParameter<std::string>("PRDigi"));
  }
}

Member Data Documentation

std::string SiStripDigitizer::alias [private]

Definition at line 63 of file SiStripDigitizer.h.

Referenced by SiStripDigitizer().

Definition at line 57 of file SiStripDigitizer.h.

Referenced by produce(), and SiStripDigitizer().

std::string SiStripDigitizer::geometryType [private]

Definition at line 62 of file SiStripDigitizer.h.

Referenced by produce(), and SiStripDigitizer().

Definition at line 60 of file SiStripDigitizer.h.

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

Definition at line 61 of file SiStripDigitizer.h.

Referenced by SiStripDigitizer().

Definition at line 59 of file SiStripDigitizer.h.

Referenced by produce().

Definition at line 53 of file SiStripDigitizer.h.

Referenced by produce().

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

Definition at line 52 of file SiStripDigitizer.h.

Referenced by produce().

Definition at line 50 of file SiStripDigitizer.h.

Referenced by produce(), SiStripDigitizer(), and ~SiStripDigitizer().

Definition at line 56 of file SiStripDigitizer.h.

Referenced by produce().

Definition at line 54 of file SiStripDigitizer.h.

Referenced by produce().

Definition at line 55 of file SiStripDigitizer.h.

Referenced by produce().

Definition at line 51 of file SiStripDigitizer.h.

Definition at line 58 of file SiStripDigitizer.h.

Referenced by produce(), and SiStripDigitizer().

Definition at line 65 of file SiStripDigitizer.h.

Referenced by produce(), and SiStripDigitizer().

Definition at line 64 of file SiStripDigitizer.h.

Referenced by produce(), and SiStripDigitizer().