CMS 3D CMS Logo

Public Member Functions | Private Types | Private Attributes

cms::SiPixelDigitizer Class Reference

#include <SiPixelDigitizer.h>

Inheritance diagram for cms::SiPixelDigitizer:
edm::EDProducer edm::ProducerBase edm::ProductRegistryHelper

List of all members.

Public Member Functions

virtual void beginJob ()
virtual void produce (edm::Event &e, const edm::EventSetup &c)
 SiPixelDigitizer (const edm::ParameterSet &conf)
virtual ~SiPixelDigitizer ()

Private Types

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

Private Attributes

SiPixelDigitizerAlgorithm_pixeldigialgo
edm::ParameterSet conf_
bool first
std::string geometryType
CLHEP::HepRandomEngine * rndEngine
simhit_map SimHitMap
std::vector< edm::DetSet
< PixelDigiSimLink > > 
theDigiLinkVector
std::vector< edm::DetSet
< PixelDigi > > 
theDigiVector
vstring trackerContainers

Detailed Description

Definition at line 36 of file SiPixelDigitizer.h.


Member Typedef Documentation

typedef std::map<unsigned int, std::vector<PSimHit>,std::less<unsigned int> > cms::SiPixelDigitizer::simhit_map [private]

Definition at line 53 of file SiPixelDigitizer.h.

typedef simhit_map::iterator cms::SiPixelDigitizer::simhit_map_iterator [private]

Definition at line 54 of file SiPixelDigitizer.h.

typedef std::vector<std::string> cms::SiPixelDigitizer::vstring [private]

Definition at line 51 of file SiPixelDigitizer.h.


Constructor & Destructor Documentation

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

Definition at line 86 of file SiPixelDigitizer.cc.

References _pixeldigialgo, Exception, geometryType, edm::ParameterSet::getParameter(), rndEngine, and trackerContainers.

                                                                  :
    conf_(iConfig),first(true)
  {
    edm::LogInfo ("PixelDigitizer ") <<"Enter the Pixel Digitizer";
    
    std::string alias ( iConfig.getParameter<std::string>("@module_label") ); 
    
    produces<edm::DetSetVector<PixelDigi> >().setBranchAlias( alias );
    produces<edm::DetSetVector<PixelDigiSimLink> >().setBranchAlias ( alias + "siPixelDigiSimLink");
    trackerContainers.clear();
    trackerContainers = iConfig.getParameter<std::vector<std::string> >("ROUList");
    geometryType = iConfig.getParameter<std::string>("GeometryType");
    edm::Service<edm::RandomNumberGenerator> rng;
    if ( ! rng.isAvailable()) {
      throw cms::Exception("Configuration")
        << "SiPixelDigitizer 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());
    _pixeldigialgo = new SiPixelDigitizerAlgorithm(iConfig,(*rndEngine));

  }
SiPixelDigitizer::~SiPixelDigitizer ( ) [virtual]

Definition at line 111 of file SiPixelDigitizer.cc.

References _pixeldigialgo.

                                     {  
    edm::LogInfo ("PixelDigitizer ") <<"Destruct the Pixel Digitizer";
    delete _pixeldigialgo;
  }

Member Function Documentation

virtual void cms::SiPixelDigitizer::beginJob ( void  ) [inline, virtual]

Reimplemented from edm::EDProducer.

Definition at line 46 of file SiPixelDigitizer.h.

{}
void SiPixelDigitizer::produce ( edm::Event e,
const edm::EventSetup c 
) [virtual]

Implements edm::EDProducer.

Definition at line 123 of file SiPixelDigitizer.cc.

References _pixeldigialgo, MixCollection< T >::begin(), edm::DetSet< T >::data, cond::rpcobgas::detid, MixCollection< T >::end(), first, geometryType, edm::EventSetup::get(), edm::Event::getByLabel(), i, SiPixelDigitizerAlgorithm::init(), LogDebug, SiPixelDigitizerAlgorithm::make_link(), convertSQLitetoXML_cfg::output, PixelSubdetector::PixelBarrel, PixelSubdetector::PixelEndcap, edm::Handle< T >::product(), edm::Event::put(), SiPixelDigitizerAlgorithm::run(), SimHitMap, DetId::subdetId(), theDigiLinkVector, theDigiVector, and trackerContainers.

  {

    if(first){
      _pixeldigialgo->init(iSetup);
      first = false;
    }

    // Step A: Get Inputs
    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> > allPixelTrackerHits(new MixCollection<PSimHit>(cf_simhitvec));

    edm::ESHandle<TrackerGeometry> pDD;
    
    iSetup.get<TrackerDigiGeometryRecord> ().get(geometryType,pDD);
 
    edm::ESHandle<MagneticField> pSetup;
    iSetup.get<IdealMagneticFieldRecord>().get(pSetup);

    //Loop on PSimHit
    SimHitMap.clear();

    MixCollection<PSimHit>::iterator isim;
    for (isim=allPixelTrackerHits->begin(); isim!= allPixelTrackerHits->end();isim++) {
      DetId detid=DetId((*isim).detUnitId());
      unsigned int subid=detid.subdetId();
      if ((subid==  PixelSubdetector::PixelBarrel) || (subid== PixelSubdetector::PixelEndcap)) {
        SimHitMap[(*isim).detUnitId()].push_back((*isim));
      }
    }

    // Step B: LOOP on PixelGeomDetUnit //
    for(TrackingGeometry::DetUnitContainer::const_iterator iu = pDD->detUnits().begin(); iu != pDD->detUnits().end(); iu ++){
      DetId idet=DetId((*iu)->geographicalId().rawId());
      unsigned int isub=idet.subdetId();
      
      
      if  ((isub==  PixelSubdetector::PixelBarrel) || (isub== PixelSubdetector::PixelEndcap)) {  
        
        
        //access to magnetic field in global coordinates
        GlobalVector bfield=pSetup->inTesla((*iu)->surface().position());
        LogDebug ("PixelDigitizer ") << "B-field(T) at "<<(*iu)->surface().position()<<"(cm): " 
                                     << pSetup->inTesla((*iu)->surface().position());
        //
        
        edm::DetSet<PixelDigi> collector((*iu)->geographicalId().rawId());
        edm::DetSet<PixelDigiSimLink> linkcollector((*iu)->geographicalId().rawId());
        
        
        collector.data=
          _pixeldigialgo->run(SimHitMap[(*iu)->geographicalId().rawId()],
                             dynamic_cast<PixelGeomDetUnit*>((*iu)),
                             bfield);
        if (collector.data.size()>0){
          theDigiVector.push_back(collector);
          
          //digisimlink
          if(SimHitMap[(*iu)->geographicalId().rawId()].size()>0){
              linkcollector.data=_pixeldigialgo->make_link();
              if (linkcollector.data.size()>0) theDigiLinkVector.push_back(linkcollector);
          }
          
        }
      }
      
    }
    
    // Step C: create collection with the cache vector of DetSet 
    std::auto_ptr<edm::DetSetVector<PixelDigi> > 
      output(new edm::DetSetVector<PixelDigi>(theDigiVector) );
    std::auto_ptr<edm::DetSetVector<PixelDigiSimLink> > 
      outputlink(new edm::DetSetVector<PixelDigiSimLink>(theDigiLinkVector) );

    // Step D: write output to file 
    iEvent.put(output);
    iEvent.put(outputlink);
  }

Member Data Documentation

Definition at line 50 of file SiPixelDigitizer.h.

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

Definition at line 48 of file SiPixelDigitizer.h.

Definition at line 49 of file SiPixelDigitizer.h.

Referenced by produce().

std::string cms::SiPixelDigitizer::geometryType [private]

Definition at line 58 of file SiPixelDigitizer.h.

Referenced by produce(), and SiPixelDigitizer().

CLHEP::HepRandomEngine* cms::SiPixelDigitizer::rndEngine [private]

Definition at line 59 of file SiPixelDigitizer.h.

Referenced by SiPixelDigitizer().

Definition at line 55 of file SiPixelDigitizer.h.

Referenced by produce().

Definition at line 57 of file SiPixelDigitizer.h.

Referenced by produce().

Definition at line 56 of file SiPixelDigitizer.h.

Referenced by produce().

Definition at line 52 of file SiPixelDigitizer.h.

Referenced by produce(), and SiPixelDigitizer().