13 MinP(
pset.getParameter<double>(
"MinP")),
15 MaxP(
pset.getParameter<double>(
"MaxP")),
16 MinT(
pset.getParameter<double>(
"MinTheta")),
17 MaxT(
pset.getParameter<double>(
"MaxTheta")),
18 MinPh(
pset.getParameter<double>(
"MinPhi")),
19 MaxPh(
pset.getParameter<double>(
"MaxPhi")),
20 MinS(
pset.getParameter<double>(
"MinT0")),
21 MaxS(
pset.getParameter<double>(
"MaxT0")),
22 ELSF(
pset.getParameter<double>(
"ElossScaleFactor")),
23 RTarget(
pset.getParameter<double>(
"RadiusOfTarget")),
24 ZTarget(
pset.getParameter<double>(
"ZDistOfTarget")),
25 ZCTarget(
pset.getParameter<double>(
"ZCentrOfTarget")),
34 PlugVtx(
pset.getParameter<double>(
"PlugVx")),
35 PlugVtz(
pset.getParameter<double>(
"PlugVz")),
36 VarRhoAir(
pset.getParameter<double>(
"RhoAir")),
37 VarRhoWall(
pset.getParameter<double>(
"RhoWall")),
38 VarRhoRock(
pset.getParameter<double>(
"RhoRock")),
39 VarRhoClay(
pset.getParameter<double>(
"RhoClay")),
40 VarRhoPlug(
pset.getParameter<double>(
"RhoPlug")),
41 ClayLayerWidth(
pset.getParameter<double>(
"ClayWidth")),
42 MinEn(
pset.getParameter<double>(
"MinEnu")),
43 MaxEn(
pset.getParameter<double>(
"MaxEnu")),
44 NuPrdAlt(
pset.getParameter<double>(
"NuProdAlt")),
45 AllMu(
pset.getParameter<
bool>(
"AcptAllMu")),
46 extCrossSect(
pset.getUntrackedParameter<double>(
"crossSection", -1.)),
47 extFilterEff(
pset.getUntrackedParameter<double>(
"filterEfficiency", -1.)),
48 cmVerbosity_(
pset.getParameter<
bool>(
"Verbosity")),
49 isInitialized_(
false) {
55 CosMuoGen = std::make_unique<CosmicMuonGenerator>();
94 produces<HepMCProduct>(
"unsmeared");
95 produces<GenEventInfoProduct>();
96 produces<GenRunInfoProduct, edm::Transition::EndRun>();
102 if (!isInitialized_) {
103 isInitialized_ =
true;
105 CosMuoGen->initialize(randomEngineSentry.randomEngine());
112 double cs = CosMuoGen->getRate();
114 genRunInfo->setInternalXSec(0.);
116 genRunInfo->setInternalXSec(
cs);
117 genRunInfo->setExternalXSecLO(extCrossSect);
118 genRunInfo->setFilterEfficiency(extFilterEff);
122 CosMuoGen->terminate();
132 CosMuoGen->nextEvent();
134 bool success = CosMuoGen->nextMultiEvent();
136 std::cout <<
"CosMuoGenProducer.cc: CosMuoGen->nextMultiEvent() failed!" << std::endl;
140 std::cout <<
"CosMuoGenProducer.cc: CosMuoGen->EventWeight=" << CosMuoGen->EventWeight
141 <<
" CosMuoGen: Nmuons=" << CosMuoGen->Id_sf.size() << std::endl;
142 std::cout <<
"CosMuoGen->Id_at=" << CosMuoGen->Id_at <<
" CosMuoGen->Vx_at=" << CosMuoGen->Vx_at
143 <<
" CosMuoGen->Vy_at=" << CosMuoGen->Vy_at <<
" CosMuoGen->Vz_at=" << CosMuoGen->Vz_at
144 <<
" CosMuoGen->T0_at=" << CosMuoGen->T0_at << std::endl;
145 std::cout <<
" Px=" << CosMuoGen->Px_at <<
" Py=" << CosMuoGen->Py_at <<
" Pz=" << CosMuoGen->Pz_at << std::endl;
146 for (
unsigned int i = 0;
i < CosMuoGen->Id_sf.size(); ++
i) {
147 std::cout <<
"Id_sf[" <<
i <<
"]=" << CosMuoGen->Id_sf[
i] <<
" Vx_sf[" <<
i <<
"]=" << CosMuoGen->Vx_sf[
i]
148 <<
" Vy_sf=" << CosMuoGen->Vy_sf[
i] <<
" Vz_sf=" << CosMuoGen->Vz_sf[
i]
149 <<
" T0_sf=" << CosMuoGen->T0_sf[
i] <<
" Px_sf=" << CosMuoGen->Px_sf[
i]
150 <<
" Py_sf=" << CosMuoGen->Py_sf[
i] <<
" Pz_sf=" << CosMuoGen->Pz_sf[
i] << std::endl;
151 std::cout <<
"phi_sf=" << atan2(CosMuoGen->Px_sf[
i], CosMuoGen->Pz_sf[
i]) << std::endl;
152 std::cout <<
"Id_ug[" <<
i <<
"]=" << CosMuoGen->Id_ug[
i] <<
" Vx_ug[" <<
i <<
"]=" << CosMuoGen->Vx_ug[
i]
153 <<
" Vy_ug=" << CosMuoGen->Vy_ug[
i] <<
" Vz_ug=" << CosMuoGen->Vz_ug[
i]
154 <<
" T0_ug=" << CosMuoGen->T0_ug[
i] <<
" Px_ug=" << CosMuoGen->Px_ug[
i]
155 <<
" Py_ug=" << CosMuoGen->Py_ug[
i] <<
" Pz_ug=" << CosMuoGen->Pz_ug[
i] << std::endl;
156 std::cout <<
"phi_ug=" << atan2(CosMuoGen->Px_ug[
i], CosMuoGen->Pz_ug[
i]) << std::endl;
161 auto fEvt = std::make_unique<HepMC::GenEvent>();
163 HepMC::GenVertex* Vtx_at =
new HepMC::GenVertex(HepMC::FourVector(CosMuoGen->Vx_at,
168 HepMC::FourVector p_at(CosMuoGen->Px_at, CosMuoGen->Py_at, CosMuoGen->Pz_at, CosMuoGen->E_at);
170 Vtx_at->add_particle_in(Part_at);
173 for (
unsigned int i = 0;
i < CosMuoGen->Id_sf.size(); ++
i) {
174 HepMC::FourVector p_sf(CosMuoGen->Px_sf[
i], CosMuoGen->Py_sf[
i], CosMuoGen->Pz_sf[
i], CosMuoGen->E_sf[
i]);
176 Vtx_at->add_particle_out(Part_sf_in);
178 HepMC::GenVertex* Vtx_sf =
new HepMC::GenVertex(
179 HepMC::FourVector(CosMuoGen->Vx_sf[
i], CosMuoGen->Vy_sf[
i], CosMuoGen->Vz_sf[
i], CosMuoGen->T0_sf[
i]));
182 Vtx_sf->add_particle_in(Part_sf_in);
183 Vtx_sf->add_particle_out(Part_sf_out);
185 fEvt->add_vertex(Vtx_sf);
187 HepMC::GenVertex* Vtx_ug =
new HepMC::GenVertex(
188 HepMC::FourVector(CosMuoGen->Vx_ug[
i], CosMuoGen->Vy_ug[
i], CosMuoGen->Vz_ug[
i], CosMuoGen->T0_ug[
i]));
190 HepMC::FourVector p_ug(CosMuoGen->Px_ug[
i], CosMuoGen->Py_ug[
i], CosMuoGen->Pz_ug[
i], CosMuoGen->E_ug[
i]);
193 Vtx_ug->add_particle_in(Part_sf_out);
194 Vtx_ug->add_particle_out(Part_ug);
196 fEvt->add_vertex(Vtx_ug);
199 fEvt->add_vertex(Vtx_at);
200 fEvt->set_signal_process_vertex(Vtx_at);
202 fEvt->set_event_number(
e.id().event());
203 fEvt->set_signal_process_id(13);
205 fEvt->weights().push_back(CosMuoGen->EventWeight);
206 fEvt->weights().push_back(CosMuoGen->Trials);
215 std::unique_ptr<HepMCProduct> CMProduct(
new HepMCProduct());
216 CMProduct->addHepMCData(fEvt.release());
void endRunProduce(Run &r, const EventSetup &es) override
std::string MultiMuonFileName
std::unique_ptr< CosmicMuonGenerator > CosMuoGen
CosMuoGenProducer(const ParameterSet &)
int32_t MultiMuonFileFirstEvent
void produce(Event &e, const EventSetup &es) override
void beginLuminosityBlock(LuminosityBlock const &, EventSetup const &) override
~CosMuoGenProducer() override
MaxP
negative means MinP_CMS = MinP.
void clear(HadCaloObj &c)