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 hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () 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::EcalTBMCInfoProducer ( const edm::ParameterSet ps)
explicit

Constructor.

Definition at line 22 of file EcalTBMCInfoProducer.cc.

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 }

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

◆ ~EcalTBMCInfoProducer()

EcalTBMCInfoProducer::~EcalTBMCInfoProducer ( )
override

Destructor.

Definition at line 100 of file EcalTBMCInfoProducer.cc.

100 { delete theTestMap; }

Member Function Documentation

◆ produce()

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.

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 }

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

Member Data Documentation

◆ beamEta

double EcalTBMCInfoProducer::beamEta
private

Definition at line 35 of file EcalTBMCInfoProducer.h.

◆ beamPhi

double EcalTBMCInfoProducer::beamPhi
private

Definition at line 36 of file EcalTBMCInfoProducer.h.

◆ beamTheta

double EcalTBMCInfoProducer::beamTheta
private

Definition at line 37 of file EcalTBMCInfoProducer.h.

◆ beamXoff

double EcalTBMCInfoProducer::beamXoff
private

Definition at line 41 of file EcalTBMCInfoProducer.h.

◆ beamYoff

double EcalTBMCInfoProducer::beamYoff
private

Definition at line 42 of file EcalTBMCInfoProducer.h.

◆ crysNumber

int EcalTBMCInfoProducer::crysNumber
private

Definition at line 39 of file EcalTBMCInfoProducer.h.

◆ fromCMStoTB

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

Definition at line 49 of file EcalTBMCInfoProducer.h.

◆ GenVtxToken

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

Definition at line 51 of file EcalTBMCInfoProducer.h.

◆ partXhodo

double EcalTBMCInfoProducer::partXhodo
private

Definition at line 44 of file EcalTBMCInfoProducer.h.

◆ partYhodo

double EcalTBMCInfoProducer::partYhodo
private

Definition at line 45 of file EcalTBMCInfoProducer.h.

◆ theTestMap

EcalTBCrystalMap* EcalTBMCInfoProducer::theTestMap
private

Definition at line 47 of file EcalTBMCInfoProducer.h.

EcalTBMCInfoProducer::beamYoff
double beamYoff
Definition: EcalTBMCInfoProducer.h:42
edm::RandomNumberGenerator::getEngine
virtual CLHEP::HepRandomEngine & getEngine(StreamID const &)=0
Use this engine in event methods.
geometryCSVtoXML.zz
zz
Definition: geometryCSVtoXML.py:19
geometryCSVtoXML.yz
yz
Definition: geometryCSVtoXML.py:19
EcalTBMCInfoProducer::GenVtxToken
edm::EDGetTokenT< edm::HepMCProduct > GenVtxToken
Definition: EcalTBMCInfoProducer.h:51
EcalTBCrystalMap::findCrystalAngles
void findCrystalAngles(const int thisCrysIndex, double &thisEta, double &thisPhi)
Definition: EcalTBCrystalMap.cc:38
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
edm::Handle< edm::HepMCProduct >
edm::Service::isAvailable
bool isAvailable() const
Definition: Service.h:40
HepMC::GenEvent
Definition: hepmc_rootio.cc:9
funct::sin
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
edm::FileInPath
Definition: FileInPath.h:64
funct::cos
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
spr::deltaEta
static const double deltaEta
Definition: CaloConstants.h:8
SiPixelRawToDigiRegional_cfi.deltaPhi
deltaPhi
Definition: SiPixelRawToDigiRegional_cfi.py:9
PVValHelper::eta
Definition: PVValidationHelpers.h:70
EcalTBMCInfoProducer::fromCMStoTB
ROOT::Math::Rotation3D * fromCMStoTB
Definition: EcalTBMCInfoProducer.h:49
EcalTBCrystalMap
Definition: EcalTBCrystalMap.h:17
EcalTBMCInfoProducer::beamTheta
double beamTheta
Definition: EcalTBMCInfoProducer.h:37
geometryCSVtoXML.xy
xy
Definition: geometryCSVtoXML.py:19
EcalTBMCInfoProducer::partYhodo
double partYhodo
Definition: EcalTBMCInfoProducer.h:45
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:233
math::XYZPoint
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
geometryCSVtoXML.yy
yy
Definition: geometryCSVtoXML.py:19
PEcalTBInfo
Definition: PEcalTBInfo.h:18
geometryCSVtoXML.xz
xz
Definition: geometryCSVtoXML.py:19
edm::Service< edm::RandomNumberGenerator >
EcalTBMCInfoProducer::beamXoff
double beamXoff
Definition: EcalTBMCInfoProducer.h:41
edm::HepMCProduct::GetEvent
const HepMC::GenEvent * GetEvent() const
Definition: HepMCProduct.h:37
EcalTBMCInfoProducer::crysNumber
int crysNumber
Definition: EcalTBMCInfoProducer.h:39
EcalTBMCInfoProducer::partXhodo
double partXhodo
Definition: EcalTBMCInfoProducer.h:44
DDAxes::phi
eostools.move
def move(src, dest)
Definition: eostools.py:511
EcalTBMCInfoProducer::theTestMap
EcalTBCrystalMap * theTestMap
Definition: EcalTBMCInfoProducer.h:47
EcalTBCrystalMap::NCRYSTAL
static const int NCRYSTAL
Definition: EcalTBCrystalMap.h:27
EcalTBMCInfoProducer::beamPhi
double beamPhi
Definition: EcalTBMCInfoProducer.h:36
ecalTB2006H4_GenSimDigiReco_cfg.CrystalMapFile
CrystalMapFile
Definition: ecalTB2006H4_GenSimDigiReco_cfg.py:182
Exception
Definition: hltDiff.cc:245
EcalTBMCInfoProducer::beamEta
double beamEta
Definition: EcalTBMCInfoProducer.h:35
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
JetChargeProducer_cfi.exp
exp
Definition: JetChargeProducer_cfi.py:6
event
Definition: event.py:1
edm::InputTag
Definition: InputTag.h:15
geometryCSVtoXML.xx
xx
Definition: geometryCSVtoXML.py:19