CMS 3D CMS Logo

Public Types | Public Member Functions | Private Attributes

CSCDigiProducer Class Reference

#include <CSCDigiProducer.h>

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

List of all members.

Public Types

typedef CSCDigitizer::DigiSimLinks DigiSimLinks

Public Member Functions

 CSCDigiProducer (const edm::ParameterSet &ps)
virtual void produce (edm::Event &e, const edm::EventSetup &c)
virtual ~CSCDigiProducer ()

Private Attributes

std::string collection_for_XF
std::string geometryType
CSCDigitizer theDigitizer
CSCStripConditionstheStripConditions

Detailed Description

Definition at line 8 of file CSCDigiProducer.h.


Member Typedef Documentation

Definition at line 11 of file CSCDigiProducer.h.


Constructor & Destructor Documentation

CSCDigiProducer::CSCDigiProducer ( const edm::ParameterSet ps) [explicit]

Definition at line 20 of file CSCDigiProducer.cc.

References collection_for_XF, Exception, geometryType, edm::ParameterSet::getParameter(), edm::Service< T >::isAvailable(), CSCStripConditions::setRandomEngine(), CSCDigitizer::setRandomEngine(), CSCDigitizer::setStripConditions(), theDigitizer, and theStripConditions.

:  theDigitizer(ps),
   theStripConditions(0)
{
  produces<CSCWireDigiCollection>("MuonCSCWireDigi");
  produces<CSCStripDigiCollection>("MuonCSCStripDigi");
  produces<CSCComparatorDigiCollection>("MuonCSCComparatorDigi");
  produces<DigiSimLinks>("MuonCSCWireDigiSimLinks");
  produces<DigiSimLinks>("MuonCSCStripDigiSimLinks");
  std::string stripConditions( ps.getParameter<std::string>("stripConditions") );
  geometryType = ps.getParameter<std::string>("GeometryType");
  edm::ParameterSet stripPSet = ps.getParameter<edm::ParameterSet>("strips");
  if( stripConditions == "Configurable" )
  {
    theStripConditions = new CSCConfigurableStripConditions(stripPSet);
  }
  else if ( stripConditions == "Database" )
  {
    theStripConditions = new CSCDbStripConditions(stripPSet);
  }
  else
  {
    throw cms::Exception("CSCDigiProducer") 
      << "Bad option for strip conditions: "
      << stripConditions;
  }
  theDigitizer.setStripConditions(theStripConditions);

  edm::Service<edm::RandomNumberGenerator> rng;
  if ( ! rng.isAvailable()) {
   throw cms::Exception("Configuration")
     << "CSCDigitizer 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.";
  }

  CLHEP::HepRandomEngine& engine = rng->getEngine();

  theDigitizer.setRandomEngine(engine);
  theStripConditions->setRandomEngine(engine);

  //Name of Collection used for create the XF 
  collection_for_XF = ps.getParameter<std::string>("InputCollection");

}
CSCDigiProducer::~CSCDigiProducer ( ) [virtual]

Definition at line 67 of file CSCDigiProducer.cc.

References theStripConditions.

{
  delete theStripConditions;
}

Member Function Documentation

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

Produces the EDM products,

Implements edm::EDProducer.

Definition at line 73 of file CSCDigiProducer.cc.

References collection_for_XF, CSCDigitizer::doAction(), geometryType, edm::EventSetup::get(), edm::Event::getByLabel(), edm::EventSetup::getData(), CSCStripConditions::initializeEvent(), autoMagneticFieldProducer_cfi::magfield, edm::Handle< T >::product(), edm::Event::put(), CSCDigitizer::setGeometry(), CSCDigitizer::setMagneticField(), CSCDigitizer::setParticleDataTable(), theDigitizer, and theStripConditions.

                                                                          {

  edm::Handle<CrossingFrame<PSimHit> > cf;
  e.getByLabel("mix", collection_for_XF, cf);

  std::auto_ptr<MixCollection<PSimHit> > 
    hits( new MixCollection<PSimHit>(cf.product()) );

  // Create empty output

  std::auto_ptr<CSCWireDigiCollection> pWireDigis(new CSCWireDigiCollection());
  std::auto_ptr<CSCStripDigiCollection> pStripDigis(new CSCStripDigiCollection());
  std::auto_ptr<CSCComparatorDigiCollection> pComparatorDigis(new CSCComparatorDigiCollection());
  std::auto_ptr<DigiSimLinks> pWireDigiSimLinks(new DigiSimLinks() );
  std::auto_ptr<DigiSimLinks> pStripDigiSimLinks(new DigiSimLinks() );

  //@@ DOES NOTHING IF NO HITS.  Remove this for when there's real neutrons
  if(hits->size() > 0) 
  {
    // find the geometry & conditions for this event
    edm::ESHandle<CSCGeometry> hGeom;
    eventSetup.get<MuonGeometryRecord>().get(geometryType,hGeom);
    const CSCGeometry *pGeom = &*hGeom;

    theDigitizer.setGeometry( pGeom );

    // find the magnetic field
    edm::ESHandle<MagneticField> magfield;
    eventSetup.get<IdealMagneticFieldRecord>().get(magfield);

    theDigitizer.setMagneticField(&*magfield);


    // set the particle table
    edm::ESHandle < ParticleDataTable > pdt;
    eventSetup.getData( pdt );
    theDigitizer.setParticleDataTable(&*pdt);

    theStripConditions->initializeEvent(eventSetup);

    // run the digitizer
    theDigitizer.doAction(*hits, *pWireDigis, *pStripDigis, *pComparatorDigis,
                          *pWireDigiSimLinks, *pStripDigiSimLinks);
  }


  // store them in the event
  e.put(pWireDigis, "MuonCSCWireDigi");
  e.put(pStripDigis, "MuonCSCStripDigi");
  e.put(pComparatorDigis, "MuonCSCComparatorDigi");
  e.put(pWireDigiSimLinks, "MuonCSCWireDigiSimLinks");
  e.put(pStripDigiSimLinks, "MuonCSCStripDigiSimLinks");
}

Member Data Documentation

std::string CSCDigiProducer::collection_for_XF [private]

Definition at line 26 of file CSCDigiProducer.h.

Referenced by CSCDigiProducer(), and produce().

std::string CSCDigiProducer::geometryType [private]

Definition at line 24 of file CSCDigiProducer.h.

Referenced by CSCDigiProducer(), and produce().

Definition at line 21 of file CSCDigiProducer.h.

Referenced by CSCDigiProducer(), and produce().

Definition at line 22 of file CSCDigiProducer.h.

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