7 #include "CLHEP/Random/RandFlat.h"
23 produces<PEcalTBInfo>();
26 GenVtxToken = consumes<edm::HepMCProduct>(
edm::InputTag(
"moduleLabelVtx",
"source"));
31 beamEta = (fMaxEta + fMinEta) / 2.;
32 beamPhi = (fMaxPhi + fMinPhi) / 2.;
33 beamTheta = 2.0 * atan(
exp(-beamEta));
46 theTestMap->findCrystalAngles(cryIndex,
eta, phi);
50 crysNumber = cryIndex;
52 if (fabs(beamPhi - phi) < 0.017) {
55 crysNumber = cryIndex;
58 if (fabs(beamEta -
eta) < 0.017) {
61 crysNumber = cryIndex;
66 edm::LogInfo(
"EcalTBInfo") <<
"Initialize TB MC ECAL info producer with parameters: \n"
68 <<
"Beam average eta = " << beamEta <<
"\n"
69 <<
"Beam average phi = " << beamPhi <<
"\n"
70 <<
"Corresponding to crystal number = " << crysNumber <<
"\n"
71 <<
"Beam X offset = " << beamXoff <<
"\n"
72 <<
"Beam Y offset = " << beamYoff;
76 double xx = -
cos(beamTheta) *
cos(beamPhi);
77 double xy = -
cos(beamTheta) *
sin(beamPhi);
78 double xz =
sin(beamTheta);
80 double yx =
sin(beamPhi);
81 double yy = -
cos(beamPhi);
84 double zx =
sin(beamTheta) *
cos(beamPhi);
85 double zy =
sin(beamTheta) *
sin(beamPhi);
86 double zz =
cos(beamTheta);
88 fromCMStoTB =
new ROOT::Math::Rotation3D(
xx,
xy,
xz, yx,
yy,
yz, zx, zy,
zz);
93 throw cms::Exception(
"Configuration") <<
"EcalTBMCInfoProducer requires the RandomNumberGeneratorService\n"
94 "which is not present in the configuration file. You must add the "
96 "in the configuration file or remove the modules that require it.";
104 CLHEP::HepRandomEngine *engine = &rng->
getEngine(
event.streamID());
106 unique_ptr<PEcalTBInfo> product(
new PEcalTBInfo());
110 product->setCrystal(crysNumber);
112 product->setBeamDirection(beamEta, beamPhi);
113 product->setBeamOffset(beamXoff, beamYoff);
118 partXhodo = partYhodo = 0.;
121 event.getByToken(GenVtxToken, GenEvt);
124 HepMC::GenEvent::vertex_const_iterator Vtx = Evt->vertices_begin();
126 math::XYZPoint eventCMSVertex((*Vtx)->position().x(), (*Vtx)->position().y(), (*Vtx)->position().z());
128 LogDebug(
"EcalTBInfo") <<
"Generated vertex position = " << eventCMSVertex.x() <<
" " << eventCMSVertex.y() <<
" "
129 << eventCMSVertex.z();
133 LogDebug(
"EcalTBInfo") <<
"Rotated vertex position = " << eventTBVertex.x() <<
" " << eventTBVertex.y() <<
" "
134 << eventTBVertex.z();
136 partXhodo = eventTBVertex.x();
137 partYhodo = eventTBVertex.y();
139 product->setBeamPosition(partXhodo, partYhodo);
142 double thisPhaseShift = CLHEP::RandFlat::shoot(engine);
144 product->setPhaseShift(thisPhaseShift);
145 LogDebug(
"EcalTBInfo") <<
"Asynchronous Phaseshift = " << thisPhaseShift;