CMS 3D CMS Logo

HectorProducer.cc
Go to the documentation of this file.
1 // Framework headers
10 
11 // SimpleConfigurable replacement
13 
14 // HepMC headers
15 #include "HepMC/GenEvent.h"
16 
17 // Hector headers
20 
21 // SimDataFormats headers
24 
25 #include <CLHEP/Random/RandomEngine.h>
26 
27 #include <iostream>
28 #include <memory>
29 #include <string>
30 
31 class TRandom3;
32 
34  : m_HepMC(consumes<edm::HepMCProduct>(p.getParameter<edm::InputTag>("HepMCProductLabel"))) {
35  m_verbosity = p.getParameter<bool>("Verbosity");
36  m_FP420Transport = p.getParameter<bool>("FP420Transport");
37  m_ZDCTransport = p.getParameter<bool>("ZDCTransport");
38  m_evtAnalysed = 0;
39 
40  produces<edm::HepMCProduct>();
41  produces<edm::LHCTransportLinkContainer>();
42 
44 
46  if (!rng.isAvailable()) {
47  throw cms::Exception("Configuration") << "LHCTransport (HectorProducer) requires the "
48  "RandomNumberGeneratorService\n"
49  "which is not present in the configuration file. You must add the "
50  "service\n"
51  "in the configuration file or remove the modules that require it.";
52  }
53  edm::LogInfo("SimTransportHectorProducer") << "Hector is created";
54 }
55 
57 
59 
61 
64  CLHEP::HepRandomEngine *engine = &rng->getEngine(iEvent.streamID());
65  if (engine->name() != "TRandom3") {
66  throw cms::Exception("Configuration") << "The TRandom3 engine type must be used with HectorProducer, "
67  << "Random Number Generator Service not correctly configured!";
68  }
69  TRandom3 *rootEngine = ((edm::TRandomAdaptor *)engine)->getRootEngine();
70 
71  ++m_evtAnalysed;
72 
73  edm::LogInfo("SimTransportHectorProducer") << "produce evt " << m_evtAnalysed;
74 
76  iEvent.getByToken(m_HepMC, HepMCEvt);
77 
78  if (!HepMCEvt.isValid()) {
79  throw cms::Exception("InvalidReference") << "Invalid reference to HepMCProduct\n";
80  }
81 
82  if (HepMCEvt.provenance()->moduleLabel() == "LHCTransport") {
83  throw cms::Exception("LogicError") << "HectorTrasported HepMCProduce already exists\n";
84  }
85 
86  evt_ = new HepMC::GenEvent(*HepMCEvt->GetEvent());
88  if (m_FP420Transport) {
89  m_Hector->clear();
90  m_Hector->add(evt_, es);
91  m_Hector->filterFP420(rootEngine);
92  }
93  if (m_ZDCTransport) {
94  m_Hector->clear();
95  m_Hector->add(evt_, es);
96  m_Hector->filterZDC(rootEngine);
97 
98  m_Hector->clear();
99  m_Hector->add(evt_, es);
100  m_Hector->filterD1(rootEngine);
101  }
103  if (m_verbosity) {
104  evt_->print();
105  }
106 
107  edm::LogInfo("SimTransportHectorProducer") << "new HepMC product ";
108 
109  unique_ptr<edm::HepMCProduct> NewProduct(new edm::HepMCProduct());
110  NewProduct->addHepMCData(evt_);
111 
112  iEvent.put(std::move(NewProduct));
113 
114  edm::LogInfo("SimTransportHectorProducer") << "new LHCTransportLinkContainer ";
115  unique_ptr<edm::LHCTransportLinkContainer> NewCorrespondenceMap(new edm::LHCTransportLinkContainer());
117  (*NewCorrespondenceMap).swap(thisLink);
118 
119  if (m_verbosity) {
120  for (unsigned int i = 0; i < (*NewCorrespondenceMap).size(); i++)
121  LogDebug("HectorEventProcessing") << "Hector correspondence table: " << (*NewCorrespondenceMap)[i];
122  }
123 
124  iEvent.put(std::move(NewCorrespondenceMap));
125  edm::LogInfo("SimTransportHectorProducer") << "produce end ";
126 }
127 
edm::Provenance::moduleLabel
std::string const & moduleLabel() const
Definition: Provenance.h:55
Hector::addPartToHepMC
HepMC::GenEvent * addPartToHepMC(HepMC::GenEvent *event)
Definition: Hector.cc:515
edm::RandomNumberGenerator::getEngine
virtual CLHEP::HepRandomEngine & getEngine(StreamID const &)=0
Use this engine in event methods.
mps_fire.i
i
Definition: mps_fire.py:355
edm::LHCTransportLinkContainer
std::vector< LHCTransportLink > LHCTransportLinkContainer
Definition: LHCTransportLinkContainer.h:8
ESHandle.h
HectorProducer::produce
void produce(edm::Event &e, const edm::EventSetup &c) override
Definition: HectorProducer.cc:62
Hector.h
edm::Run
Definition: Run.h:45
edm
HLT enums.
Definition: AlignableModifier.h:19
RandomNumberGenerator.h
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
HectorProducer::m_evtAnalysed
int m_evtAnalysed
just to count events that have been analysed
Definition: HectorProducer.h:43
edm::LogInfo
Definition: MessageLogger.h:254
HectorProducer::evt_
HepMC::GenEvent * evt_
Definition: HectorProducer.h:36
HectorProducer::m_verbosity
bool m_verbosity
Definition: HectorProducer.h:40
edm::Handle< edm::HepMCProduct >
edm::Service::isAvailable
bool isAvailable() const
Definition: Service.h:40
Hector::filterD1
void filterD1(TRandom3 *)
Definition: Hector.cc:414
HepMC::GenEvent
Definition: hepmc_rootio.cc:9
HectorProducer::m_HepMC
edm::EDGetTokenT< edm::HepMCProduct > m_HepMC
Definition: HectorProducer.h:39
Hector::add
void add(const HepMC::GenEvent *ev, const edm::EventSetup &es)
Definition: Hector.cc:175
MakerMacros.h
HectorProducer.h
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
Hector::getCorrespondenceMap
std::vector< LHCTransportLink > & getCorrespondenceMap()
Definition: Hector.h:73
TRandomAdaptor.h
HectorProducer::m_Hector
Hector * m_Hector
Definition: HectorProducer.h:37
Service.h
edm::HandleBase::provenance
Provenance const * provenance() const
Definition: HandleBase.h:74
edm::TRandomAdaptor
Definition: TRandomAdaptor.h:13
Hector::clear
void clear()
Definition: Hector.cc:152
HLT_2018_cff.InputTag
InputTag
Definition: HLT_2018_cff.py:79016
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:670
edm::ParameterSet
Definition: ParameterSet.h:36
Hector::clearApertureFlags
void clearApertureFlags()
Definition: Hector.cc:146
ModuleDef.h
edm::Service< edm::RandomNumberGenerator >
iEvent
int iEvent
Definition: GenABIO.cc:224
HectorProducer::~HectorProducer
~HectorProducer() override
Definition: HectorProducer.cc:56
edm::EventSetup
Definition: EventSetup.h:57
edm::HepMCProduct::GetEvent
const HepMC::GenEvent * GetEvent() const
Definition: HepMCProduct.h:34
HltBtagPostValidation_cff.c
c
Definition: HltBtagPostValidation_cff.py:31
InputTag.h
alignCSCRings.r
r
Definition: alignCSCRings.py:93
HectorProducer
Definition: HectorProducer.h:27
Hector::filterFP420
void filterFP420(TRandom3 *)
Definition: Hector.cc:237
eostools.move
def move(src, dest)
Definition: eostools.py:511
HectorProducer::endRun
void endRun(const edm::Run &r, const edm::EventSetup &c) override
Definition: HectorProducer.cc:60
HectorProducer::m_ZDCTransport
bool m_ZDCTransport
Definition: HectorProducer.h:42
Exception
Definition: hltDiff.cc:246
HectorProducer::beginRun
void beginRun(const edm::Run &r, const edm::EventSetup &c) override
Definition: HectorProducer.cc:58
HectorProducer::m_FP420Transport
bool m_FP420Transport
Definition: HectorProducer.h:41
Exception.h
Hector::filterZDC
void filterZDC(TRandom3 *)
Definition: Hector.cc:329
HepMCProduct
edm::HepMCProduct
Definition: HepMCProduct.h:18
ParameterSet.h
HepMCProduct.h
edm::HandleBase::isValid
bool isValid() const
Definition: HandleBase.h:70
edm::Event
Definition: Event.h:73
HectorTransport_cfi.Hector
Hector
Definition: HectorTransport_cfi.py:9
HectorProducer::HectorProducer
HectorProducer(edm::ParameterSet const &p)
Definition: HectorProducer.cc:33