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);
129 const HepMC::GenEvent* Evt = GenEvt->GetEvent() ;
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
edm::Service< edm::RandomNumberGenerator > rng
static const int NCRYSTAL
Sin< T >::type sin(const T &t)
virtual CLHEP::HepRandomEngine & getEngine(StreamID const &)=0
Use this engine in event methods.
static const double deltaEta
virtual ~EcalTBMCInfoProducer()
Destructor.
Cos< T >::type cos(const T &t)
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
void produce(edm::Event &event, const edm::EventSetup &eventSetup)
Produce digis out of raw data.
XYZPointD XYZPoint
point in space with cartesian internal representation
Geom::Phi< T > phi() const
StreamID streamID() const
EcalTBMCInfoProducer(const edm::ParameterSet &ps)
Constructor.