25 #include "Math/GenVector/Rotation3D.h"
26 #include <CLHEP/Random/RandFlat.h>
68 : fMinEta(ps.getParameter<double>(
"MinEta")),
69 fMaxEta(ps.getParameter<double>(
"MaxEta")),
70 fMinPhi(ps.getParameter<double>(
"MinPhi")),
71 fMaxPhi(ps.getParameter<double>(
"MaxPhi")),
72 beamEta((fMaxEta + fMinEta) / 2.),
73 beamPhi((fMaxPhi + fMinPhi) / 2.),
74 beamTheta(2.0 * atan(
exp(-beamEta))),
75 beamXoff(ps.getParameter<double>(
"BeamMeanX")),
76 beamYoff(ps.getParameter<double>(
"BeamMeanX")),
78 produces<PEcalTBInfo>();
82 std::string fullMapName = CrystalMapFile.fullPath();
83 theTestMap = std::make_unique<EcalTBCrystalMap>(fullMapName);
91 theTestMap->findCrystalAngles(cryIndex, eta, phi);
92 if (fabs(
beamEta - eta) < deltaEta && fabs(
beamPhi - phi) < deltaPhi) {
95 crysNumber = cryIndex;
96 }
else if (fabs(
beamEta - eta) < deltaEta && fabs(
beamPhi - phi) > deltaPhi) {
97 if (fabs(
beamPhi - phi) < 0.017) {
100 crysNumber = cryIndex;
102 }
else if (fabs(
beamEta - eta) > deltaEta && fabs(
beamPhi - phi) < deltaPhi) {
103 if (fabs(
beamEta - eta) < 0.017) {
104 deltaEta = fabs(
beamEta - eta);
105 deltaPhi = fabs(
beamPhi - phi);
106 crysNumber = cryIndex;
111 edm::LogVerbatim(
"EcalTBInfo") <<
"Initialize TB MC ECAL info producer with parameters: \n"
112 <<
"Crystal map file: " << CrystalMapFile <<
"\n"
113 <<
"Beam average eta = " <<
beamEta <<
"\n"
114 <<
"Beam average phi = " <<
beamPhi <<
"\n"
115 <<
"Corresponding to crystal number = " << crysNumber <<
"\n"
116 <<
"Beam X offset = " <<
beamXoff <<
"\n"
133 fromCMStoTB = std::make_unique<ROOT::Math::Rotation3D>(xx,
xy, xz, yx, yy, yz, zx, zy, zz);
137 if (!rng.isAvailable()) {
138 throw cms::Exception(
"Configuration") <<
"EcalTBMCInfoProducer requires the RandomNumberGeneratorService\n"
139 "which is not present in the configuration file. You must add the "
141 "in the configuration file or remove the modules that require it.";
149 std::unique_ptr<PEcalTBInfo> product(
new PEcalTBInfo());
166 HepMC::GenEvent::vertex_const_iterator Vtx = Evt->vertices_begin();
168 math::XYZPoint eventCMSVertex((*Vtx)->position().x(), (*Vtx)->position().y(), (*Vtx)->position().z());
170 LogDebug(
"EcalTBInfo") <<
"Generated vertex position = " << eventCMSVertex.x() <<
" " << eventCMSVertex.y() <<
" "
171 << eventCMSVertex.z();
175 LogDebug(
"EcalTBInfo") <<
"Rotated vertex position = " << eventTBVertex.x() <<
" " << eventTBVertex.y() <<
" "
176 << eventTBVertex.z();
184 double thisPhaseShift = CLHEP::RandFlat::shoot(engine);
186 product->setPhaseShift(thisPhaseShift);
187 LogDebug(
"EcalTBInfo") <<
"Asynchronous Phaseshift = " << thisPhaseShift;
Log< level::Info, true > LogVerbatim
std::unique_ptr< ROOT::Math::Rotation3D > fromCMStoTB
static const int NCRYSTAL
#define DEFINE_FWK_MODULE(type)
Sin< T >::type sin(const T &t)
Exp< T >::type exp(const T &t)
virtual CLHEP::HepRandomEngine & getEngine(StreamID const &)=0
Use this engine in event methods.
static const double deltaEta
void produce(edm::Event &event, const edm::EventSetup &eventSetup) override
Produce digis out of raw data.
Cos< T >::type cos(const T &t)
Basic2DVector< T > xy() const
std::unique_ptr< EcalTBCrystalMap > theTestMap
XYZPointD XYZPoint
point in space with cartesian internal representation
T getParameter(std::string const &) const
StreamID streamID() const
const edm::EDGetTokenT< edm::HepMCProduct > GenVtxToken
EcalTBMCInfoProducer(const edm::ParameterSet &ps)
Constructor.
~EcalTBMCInfoProducer() override=default
Destructor.