CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
CSCDigiProducer.cc
Go to the documentation of this file.
2 
4 
7 
9 
12 
14 
23 
24 #include <string>
25 
27 : theDigitizer(ps),
28  theStripConditions(0)
29 {
30  produces<CSCWireDigiCollection>("MuonCSCWireDigi");
31  produces<CSCStripDigiCollection>("MuonCSCStripDigi");
32  produces<CSCComparatorDigiCollection>("MuonCSCComparatorDigi");
33  produces<DigiSimLinks>("MuonCSCWireDigiSimLinks");
34  produces<DigiSimLinks>("MuonCSCStripDigiSimLinks");
35  std::string stripConditions( ps.getParameter<std::string>("stripConditions") );
36  geometryType = ps.getParameter<std::string>("GeometryType");
37  edm::ParameterSet stripPSet = ps.getParameter<edm::ParameterSet>("strips");
38  if( stripConditions == "Configurable" )
39  {
41  }
42  else if ( stripConditions == "Database" )
43  {
45  }
46  else
47  {
48  throw cms::Exception("CSCDigiProducer")
49  << "Bad option for strip conditions: "
50  << stripConditions;
51  }
53 
55  if ( ! rng.isAvailable()) {
56  throw cms::Exception("Configuration")
57  << "CSCDigitizer requires the RandomNumberGeneratorService\n"
58  "which is not present in the configuration file. You must add the service\n"
59  "in the configuration file or remove the modules that require it.";
60  }
61 
62  std::string mix_ = ps.getParameter<std::string>("mixLabel");
63  std::string collection_ = ps.getParameter<std::string>("InputCollection");
64  cf_token = consumes<CrossingFrame<PSimHit> >( edm::InputTag(mix_, collection_) );
65 }
66 
67 
69 {
70  delete theStripConditions;
71 }
72 
73 
75 
77  CLHEP::HepRandomEngine* engine = &rng->getEngine(e.streamID());
78 
80  e.getByToken(cf_token, cf);
81 
82  std::auto_ptr<MixCollection<PSimHit> >
83  hits( new MixCollection<PSimHit>(cf.product()) );
84 
85  // Create empty output
86 
87  std::auto_ptr<CSCWireDigiCollection> pWireDigis(new CSCWireDigiCollection());
88  std::auto_ptr<CSCStripDigiCollection> pStripDigis(new CSCStripDigiCollection());
89  std::auto_ptr<CSCComparatorDigiCollection> pComparatorDigis(new CSCComparatorDigiCollection());
90  std::auto_ptr<DigiSimLinks> pWireDigiSimLinks(new DigiSimLinks() );
91  std::auto_ptr<DigiSimLinks> pStripDigiSimLinks(new DigiSimLinks() );
92 
93  //@@ DOES NOTHING IF NO HITS. Remove this for when there's real neutrons
94  if(hits->size() > 0)
95  {
96  // find the geometry & conditions for this event
98  eventSetup.get<MuonGeometryRecord>().get(geometryType,hGeom);
99  const CSCGeometry *pGeom = &*hGeom;
100 
101  theDigitizer.setGeometry( pGeom );
102 
103  // find the magnetic field
105  eventSetup.get<IdealMagneticFieldRecord>().get(magfield);
106 
107  theDigitizer.setMagneticField(&*magfield);
108 
109 
110  // set the particle table
112  eventSetup.getData( pdt );
114 
115  theStripConditions->initializeEvent(eventSetup);
116 
117  // run the digitizer
118  theDigitizer.doAction(*hits, *pWireDigis, *pStripDigis, *pComparatorDigis,
119  *pWireDigiSimLinks, *pStripDigiSimLinks, engine);
120  }
121 
122 
123  // store them in the event
124  e.put(pWireDigis, "MuonCSCWireDigi");
125  e.put(pStripDigis, "MuonCSCStripDigi");
126  e.put(pComparatorDigis, "MuonCSCComparatorDigi");
127  e.put(pWireDigiSimLinks, "MuonCSCWireDigiSimLinks");
128  e.put(pStripDigiSimLinks, "MuonCSCStripDigiSimLinks");
129 }
130 
T getParameter(std::string const &) const
CSCDigiProducer(const edm::ParameterSet &ps)
CSCDigitizer::DigiSimLinks DigiSimLinks
CSCDigitizer theDigitizer
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
tuple magfield
Definition: HLT_ES_cff.py:2311
MuonDigiCollection< CSCDetId, CSCStripDigi > CSCStripDigiCollection
CSCStripConditions * theStripConditions
virtual void initializeEvent(const edm::EventSetup &es)
std::string geometryType
void getData(T &iHolder) const
Definition: EventSetup.h:67
MuonDigiCollection< CSCDetId, CSCComparatorDigi > CSCComparatorDigiCollection
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:116
edm::EDGetTokenT< CrossingFrame< PSimHit > > cf_token
bool isAvailable() const
Definition: Service.h:46
void setStripConditions(CSCStripConditions *cond)
MuonDigiCollection< CSCDetId, CSCWireDigi > CSCWireDigiCollection
const T & get() const
Definition: EventSetup.h:55
void setParticleDataTable(const ParticleDataTable *pdt)
T const * product() const
Definition: Handle.h:81
virtual CLHEP::HepRandomEngine & getEngine(StreamID const &) const =0
Use this engine in event methods.
void doAction(MixCollection< PSimHit > &simHits, CSCWireDigiCollection &wireDigis, CSCStripDigiCollection &stripDigis, CSCComparatorDigiCollection &comparators, DigiSimLinks &wireDigiSimLinks, DigiSimLinks &stripDigiSimLinks, CLHEP::HepRandomEngine *)
Definition: CSCDigitizer.cc:45
virtual void produce(edm::Event &e, const edm::EventSetup &c)
StreamID streamID() const
Definition: Event.h:75
void setGeometry(const CSCGeometry *geom)
sets geometry
Definition: CSCDigitizer.h:62
virtual ~CSCDigiProducer()
void setMagneticField(const MagneticField *field)
sets the magnetic field