10 #include "CLHEP/Random/RandFlat.h" 24 produces<PEcalTBInfo>();
27 GenVtxToken = consumes<edm::HepMCProduct>(
edm::InputTag(
"moduleLabelVtx",
"source"));
32 beamEta = (fMaxEta+fMinEta)/2.;
33 beamPhi = (fMaxPhi+fMinPhi)/2.;
34 beamTheta = 2.0*atan(
exp(-beamEta));
38 string fullMapName = CrystalMapFile.fullPath();
47 theTestMap->findCrystalAngles(cryIndex, eta, phi);
48 if ( fabs(beamEta - eta) < deltaEta && fabs(beamPhi - phi) < deltaPhi ) {
49 deltaEta = fabs(beamEta - eta);
50 deltaPhi = fabs(beamPhi - phi);
51 crysNumber = cryIndex;
53 else if (fabs(beamEta - eta)<deltaEta && fabs(beamPhi - phi)>deltaPhi ) {
54 if ( fabs(beamPhi - phi) < 0.017 ) {
55 deltaEta = fabs(beamEta - eta);
56 deltaPhi = fabs(beamPhi - phi);
57 crysNumber = cryIndex;
60 else if (fabs(beamEta - eta)>deltaEta && fabs(beamPhi - phi)<deltaPhi ) {
61 if ( fabs(beamEta - eta) < 0.017 ) {
62 deltaEta = fabs(beamEta - eta);
63 deltaPhi = fabs(beamPhi - phi);
64 crysNumber = cryIndex;
69 edm::LogInfo(
"EcalTBInfo") <<
"Initialize TB MC ECAL info producer with parameters: \n" 70 <<
"Crystal map file: " << CrystalMapFile <<
"\n" 71 <<
"Beam average eta = " << beamEta <<
"\n" 72 <<
"Beam average phi = " << beamPhi <<
"\n" 73 <<
"Corresponding to crystal number = " << crysNumber <<
"\n" 74 <<
"Beam X offset = " << beamXoff <<
"\n" 75 <<
"Beam Y offset = " << beamYoff;
79 double xx = -
cos(beamTheta)*
cos(beamPhi);
80 double xy = -
cos(beamTheta)*
sin(beamPhi);
81 double xz =
sin(beamTheta);
83 double yx =
sin(beamPhi);
84 double yy = -
cos(beamPhi);
87 double zx =
sin(beamTheta)*
cos(beamPhi);
88 double zy =
sin(beamTheta)*
sin(beamPhi);
89 double zz =
cos(beamTheta);
91 fromCMStoTB =
new ROOT::Math::Rotation3D(xx, xy, xz, yx, yy, yz, zx, zy, zz);
97 <<
"EcalTBMCInfoProducer requires the RandomNumberGeneratorService\n" 98 "which is not present in the configuration file. You must add the service\n" 99 "in the configuration file or remove the modules that require it.";
112 unique_ptr<PEcalTBInfo> product(
new PEcalTBInfo());
116 product->setCrystal(crysNumber);
118 product->setBeamDirection(beamEta, beamPhi);
119 product->setBeamOffset(beamXoff, beamYoff);
124 partXhodo = partYhodo = 0.;
127 event.getByToken(GenVtxToken,GenEvt);
130 HepMC::GenEvent::vertex_const_iterator Vtx = Evt->vertices_begin();
133 (*Vtx)->position().y(),
134 (*Vtx)->position().z());
136 LogDebug(
"EcalTBInfo") <<
"Generated vertex position = " 137 << eventCMSVertex.x() <<
" " 138 << eventCMSVertex.y() <<
" " 139 << eventCMSVertex.z();
143 LogDebug(
"EcalTBInfo") <<
"Rotated vertex position = " 144 << eventTBVertex.x() <<
" " 145 << eventTBVertex.y() <<
" " 146 << eventTBVertex.z();
148 partXhodo = eventTBVertex.x();
149 partYhodo = eventTBVertex.y();
151 product->setBeamPosition(partXhodo, partYhodo);
154 double thisPhaseShift = CLHEP::RandFlat::shoot(engine);
156 product->setPhaseShift(thisPhaseShift);
157 LogDebug(
"EcalTBInfo") <<
"Asynchronous Phaseshift = " << thisPhaseShift;
T getParameter(std::string const &) const
static const int NCRYSTAL
Sin< T >::type sin(const T &t)
~EcalTBMCInfoProducer() override
Destructor.
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)
Namespace of DDCMS conversion namespace.
const HepMC::GenEvent * GetEvent() const
XYZPointD XYZPoint
point in space with cartesian internal representation
StreamID streamID() const
EcalTBMCInfoProducer(const edm::ParameterSet &ps)
Constructor.