CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
EcalTBMCInfoProducer Class Reference

#include <EcalTBMCInfoProducer.h>

Inheritance diagram for EcalTBMCInfoProducer:
edm::stream::EDProducer<>

Public Member Functions

 EcalTBMCInfoProducer (const edm::ParameterSet &ps)
 Constructor. More...
 
void produce (edm::Event &event, const edm::EventSetup &eventSetup) override
 Produce digis out of raw data. More...
 
 ~EcalTBMCInfoProducer () override
 Destructor. More...
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndRuns () const final
 

Private Attributes

double beamEta
 
double beamPhi
 
double beamTheta
 
double beamXoff
 
double beamYoff
 
int crysNumber
 
ROOT::Math::Rotation3D * fromCMStoTB
 
edm::EDGetTokenT< edm::HepMCProductGenVtxToken
 
double partXhodo
 
double partYhodo
 
EcalTBCrystalMaptheTestMap
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
typedef CacheContexts< T... > CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T... > HasAbility
 
typedef CacheTypes::LuminosityBlockCache LuminosityBlockCache
 
typedef LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 

Detailed Description

Definition at line 23 of file EcalTBMCInfoProducer.h.

Constructor & Destructor Documentation

EcalTBMCInfoProducer::EcalTBMCInfoProducer ( const edm::ParameterSet ps)
explicit

Constructor.

Definition at line 22 of file EcalTBMCInfoProducer.cc.

References funct::cos(), ecalTB2006H4_GenSimDigiReco_cfg::CrystalMapFile, spr::deltaEta, SiPixelRawToDigiRegional_cfi::deltaPhi, PVValHelper::eta, Exception, JetChargeProducer_cfi::exp, edm::ParameterSet::getParameter(), HLT_2018_cff::InputTag, edm::Service< T >::isAvailable(), EcalTBCrystalMap::NCRYSTAL, funct::sin(), geometryCSVtoXML::xx, geometryCSVtoXML::xy, geometryCSVtoXML::xz, geometryCSVtoXML::yy, geometryCSVtoXML::yz, and geometryCSVtoXML::zz.

22  {
23  produces<PEcalTBInfo>();
24 
26  GenVtxToken = consumes<edm::HepMCProduct>(edm::InputTag("moduleLabelVtx", "source"));
27  double fMinEta = ps.getParameter<double>("MinEta");
28  double fMaxEta = ps.getParameter<double>("MaxEta");
29  double fMinPhi = ps.getParameter<double>("MinPhi");
30  double fMaxPhi = ps.getParameter<double>("MaxPhi");
31  beamEta = (fMaxEta + fMinEta) / 2.;
32  beamPhi = (fMaxPhi + fMinPhi) / 2.;
33  beamTheta = 2.0 * atan(exp(-beamEta));
34  beamXoff = ps.getParameter<double>("BeamMeanX");
35  beamYoff = ps.getParameter<double>("BeamMeanX");
36 
37  string fullMapName = CrystalMapFile.fullPath();
38  theTestMap = new EcalTBCrystalMap(fullMapName);
39  crysNumber = 0;
40 
41  double deltaEta = 999.;
42  double deltaPhi = 999.;
43  for (int cryIndex = 1; cryIndex <= EcalTBCrystalMap::NCRYSTAL; ++cryIndex) {
44  double eta = 0;
45  double phi = 0.;
46  theTestMap->findCrystalAngles(cryIndex, eta, phi);
47  if (fabs(beamEta - eta) < deltaEta && fabs(beamPhi - phi) < deltaPhi) {
48  deltaEta = fabs(beamEta - eta);
49  deltaPhi = fabs(beamPhi - phi);
50  crysNumber = cryIndex;
51  } else if (fabs(beamEta - eta) < deltaEta && fabs(beamPhi - phi) > deltaPhi) {
52  if (fabs(beamPhi - phi) < 0.017) {
53  deltaEta = fabs(beamEta - eta);
54  deltaPhi = fabs(beamPhi - phi);
55  crysNumber = cryIndex;
56  }
57  } else if (fabs(beamEta - eta) > deltaEta && fabs(beamPhi - phi) < deltaPhi) {
58  if (fabs(beamEta - eta) < 0.017) {
59  deltaEta = fabs(beamEta - eta);
60  deltaPhi = fabs(beamPhi - phi);
61  crysNumber = cryIndex;
62  }
63  }
64  }
65 
66  edm::LogInfo("EcalTBInfo") << "Initialize TB MC ECAL info producer with parameters: \n"
67  << "Crystal map file: " << CrystalMapFile << "\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;
73 
74  // rotation matrix to move from the CMS reference frame to the test beam one
75 
76  double xx = -cos(beamTheta) * cos(beamPhi);
77  double xy = -cos(beamTheta) * sin(beamPhi);
78  double xz = sin(beamTheta);
79 
80  double yx = sin(beamPhi);
81  double yy = -cos(beamPhi);
82  double yz = 0.;
83 
84  double zx = sin(beamTheta) * cos(beamPhi);
85  double zy = sin(beamTheta) * sin(beamPhi);
86  double zz = cos(beamTheta);
87 
88  fromCMStoTB = new ROOT::Math::Rotation3D(xx, xy, xz, yx, yy, yz, zx, zy, zz);
89 
90  // random number
92  if (!rng.isAvailable()) {
93  throw cms::Exception("Configuration") << "EcalTBMCInfoProducer requires the RandomNumberGeneratorService\n"
94  "which is not present in the configuration file. You must add the "
95  "service\n"
96  "in the configuration file or remove the modules that require it.";
97  }
98 }
T getParameter(std::string const &) const
edm::EDGetTokenT< edm::HepMCProduct > GenVtxToken
static const int NCRYSTAL
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
static const double deltaEta
Definition: CaloConstants.h:8
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
bool isAvailable() const
Definition: Service.h:40
EcalTBCrystalMap * theTestMap
void findCrystalAngles(const int thisCrysIndex, double &thisEta, double &thisPhi)
ROOT::Math::Rotation3D * fromCMStoTB
EcalTBMCInfoProducer::~EcalTBMCInfoProducer ( )
override

Destructor.

Definition at line 100 of file EcalTBMCInfoProducer.cc.

100 { delete theTestMap; }
EcalTBCrystalMap * theTestMap

Member Function Documentation

void EcalTBMCInfoProducer::produce ( edm::Event event,
const edm::EventSetup eventSetup 
)
override

Produce digis out of raw data.

Definition at line 102 of file EcalTBMCInfoProducer.cc.

References edm::RandomNumberGenerator::getEngine(), edm::HepMCProduct::GetEvent(), LogDebug, eostools::move(), and edm::Event::streamID().

102  {
104  CLHEP::HepRandomEngine *engine = &rng->getEngine(event.streamID());
105 
106  unique_ptr<PEcalTBInfo> product(new PEcalTBInfo());
107 
108  // Fill the run information
109 
110  product->setCrystal(crysNumber);
111 
112  product->setBeamDirection(beamEta, beamPhi);
113  product->setBeamOffset(beamXoff, beamYoff);
114 
115  // Compute the event x,y vertex coordinates in the beam reference system
116  // e.g. in the place orthogonal to the beam average direction
117 
118  partXhodo = partYhodo = 0.;
119 
121  event.getByToken(GenVtxToken, GenEvt);
122 
123  const HepMC::GenEvent *Evt = GenEvt->GetEvent();
124  HepMC::GenEvent::vertex_const_iterator Vtx = Evt->vertices_begin();
125 
126  math::XYZPoint eventCMSVertex((*Vtx)->position().x(), (*Vtx)->position().y(), (*Vtx)->position().z());
127 
128  LogDebug("EcalTBInfo") << "Generated vertex position = " << eventCMSVertex.x() << " " << eventCMSVertex.y() << " "
129  << eventCMSVertex.z();
130 
131  math::XYZPoint eventTBVertex = (*fromCMStoTB) * eventCMSVertex;
132 
133  LogDebug("EcalTBInfo") << "Rotated vertex position = " << eventTBVertex.x() << " " << eventTBVertex.y() << " "
134  << eventTBVertex.z();
135 
136  partXhodo = eventTBVertex.x();
137  partYhodo = eventTBVertex.y();
138 
139  product->setBeamPosition(partXhodo, partYhodo);
140 
141  // Asynchronous phase shift
142  double thisPhaseShift = CLHEP::RandFlat::shoot(engine);
143 
144  product->setPhaseShift(thisPhaseShift);
145  LogDebug("EcalTBInfo") << "Asynchronous Phaseshift = " << thisPhaseShift;
146 
147  // store the object in the framework event
148 
149  event.put(std::move(product));
150 }
#define LogDebug(id)
edm::EDGetTokenT< edm::HepMCProduct > GenVtxToken
virtual CLHEP::HepRandomEngine & getEngine(StreamID const &)=0
Use this engine in event methods.
const HepMC::GenEvent * GetEvent() const
Definition: HepMCProduct.h:34
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
StreamID streamID() const
Definition: Event.h:96
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

double EcalTBMCInfoProducer::beamEta
private

Definition at line 35 of file EcalTBMCInfoProducer.h.

double EcalTBMCInfoProducer::beamPhi
private

Definition at line 36 of file EcalTBMCInfoProducer.h.

double EcalTBMCInfoProducer::beamTheta
private

Definition at line 37 of file EcalTBMCInfoProducer.h.

double EcalTBMCInfoProducer::beamXoff
private

Definition at line 41 of file EcalTBMCInfoProducer.h.

double EcalTBMCInfoProducer::beamYoff
private

Definition at line 42 of file EcalTBMCInfoProducer.h.

int EcalTBMCInfoProducer::crysNumber
private

Definition at line 39 of file EcalTBMCInfoProducer.h.

ROOT::Math::Rotation3D* EcalTBMCInfoProducer::fromCMStoTB
private

Definition at line 49 of file EcalTBMCInfoProducer.h.

edm::EDGetTokenT<edm::HepMCProduct> EcalTBMCInfoProducer::GenVtxToken
private

Definition at line 51 of file EcalTBMCInfoProducer.h.

double EcalTBMCInfoProducer::partXhodo
private

Definition at line 44 of file EcalTBMCInfoProducer.h.

double EcalTBMCInfoProducer::partYhodo
private

Definition at line 45 of file EcalTBMCInfoProducer.h.

EcalTBCrystalMap* EcalTBMCInfoProducer::theTestMap
private

Definition at line 47 of file EcalTBMCInfoProducer.h.