CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
EcalTBMCInfoProducer Class Reference
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=default
 Destructor. More...
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 

Private Attributes

const double beamEta
 
const double beamPhi
 
const double beamTheta
 
const double beamXoff
 
const double beamYoff
 
int crysNumber
 
const double fMaxEta
 
const double fMaxPhi
 
const double fMinEta
 
const double fMinPhi
 
std::unique_ptr< ROOT::Math::Rotation3D > fromCMStoTB
 
const edm::EDGetTokenT< edm::HepMCProductGenVtxToken
 
double partXhodo
 
double partYhodo
 
std::unique_ptr< EcalTBCrystalMaptheTestMap
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
using CacheTypes = CacheContexts< T... >
 
using GlobalCache = typename CacheTypes::GlobalCache
 
using HasAbility = AbilityChecker< T... >
 
using InputProcessBlockCache = typename CacheTypes::InputProcessBlockCache
 
using LuminosityBlockCache = typename CacheTypes::LuminosityBlockCache
 
using LuminosityBlockContext = LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache >
 
using LuminosityBlockSummaryCache = typename CacheTypes::LuminosityBlockSummaryCache
 
using RunCache = typename CacheTypes::RunCache
 
using RunContext = RunContextT< RunCache, GlobalCache >
 
using RunSummaryCache = typename CacheTypes::RunSummaryCache
 

Detailed Description

Definition at line 33 of file EcalTBMCInfoProducer.cc.

Constructor & Destructor Documentation

◆ EcalTBMCInfoProducer()

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

Constructor.

Definition at line 67 of file EcalTBMCInfoProducer.cc.

References beamEta, beamPhi, beamTheta, beamXoff, beamYoff, funct::cos(), crysNumber, ecalTB2006H4_GenSimDigiReco_cfg::CrystalMapFile, spr::deltaEta, SiPixelRawToDigiRegional_cfi::deltaPhi, PVValHelper::eta, Exception, fromCMStoTB, edm::ParameterSet::getParameter(), EcalTBCrystalMap::NCRYSTAL, phi, funct::sin(), AlCaHLTBitMon_QueryRunRegistry::string, theTestMap, geometryCSVtoXML::xx, geometryCSVtoXML::xy, geometryCSVtoXML::xz, geometryCSVtoXML::yy, geometryCSVtoXML::yz, and geometryCSVtoXML::zz.

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")),
77  GenVtxToken(consumes<edm::HepMCProduct>(edm::InputTag("moduleLabelVtx", "source"))) {
78  produces<PEcalTBInfo>();
79 
81 
82  std::string fullMapName = CrystalMapFile.fullPath();
83  theTestMap = std::make_unique<EcalTBCrystalMap>(fullMapName);
84  crysNumber = 0;
85 
86  double deltaEta = 999.;
87  double deltaPhi = 999.;
88  for (int cryIndex = 1; cryIndex <= EcalTBCrystalMap::NCRYSTAL; ++cryIndex) {
89  double eta = 0;
90  double phi = 0.;
91  theTestMap->findCrystalAngles(cryIndex, eta, phi);
92  if (fabs(beamEta - eta) < deltaEta && fabs(beamPhi - phi) < deltaPhi) {
93  deltaEta = fabs(beamEta - eta);
94  deltaPhi = fabs(beamPhi - phi);
95  crysNumber = cryIndex;
96  } else if (fabs(beamEta - eta) < deltaEta && fabs(beamPhi - phi) > deltaPhi) {
97  if (fabs(beamPhi - phi) < 0.017) {
98  deltaEta = fabs(beamEta - eta);
99  deltaPhi = fabs(beamPhi - phi);
100  crysNumber = cryIndex;
101  }
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;
107  }
108  }
109  }
110 
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"
117  << "Beam Y offset = " << beamYoff;
118 
119  // rotation matrix to move from the CMS reference frame to the test beam one
120 
121  double xx = -cos(beamTheta) * cos(beamPhi);
122  double xy = -cos(beamTheta) * sin(beamPhi);
123  double xz = sin(beamTheta);
124 
125  double yx = sin(beamPhi);
126  double yy = -cos(beamPhi);
127  double yz = 0.;
128 
129  double zx = sin(beamTheta) * cos(beamPhi);
130  double zy = sin(beamTheta) * sin(beamPhi);
131  double zz = cos(beamTheta);
132 
133  fromCMStoTB = std::make_unique<ROOT::Math::Rotation3D>(xx, xy, xz, yx, yy, yz, zx, zy, zz);
134 
135  // random number
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 "
140  "service\n"
141  "in the configuration file or remove the modules that require it.";
142  }
143 }
Log< level::Info, true > LogVerbatim
std::unique_ptr< ROOT::Math::Rotation3D > fromCMStoTB
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
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
std::unique_ptr< EcalTBCrystalMap > theTestMap
const edm::EDGetTokenT< edm::HepMCProduct > GenVtxToken

◆ ~EcalTBMCInfoProducer()

EcalTBMCInfoProducer::~EcalTBMCInfoProducer ( )
overridedefault

Destructor.

Member Function Documentation

◆ produce()

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

Produce digis out of raw data.

Definition at line 145 of file EcalTBMCInfoProducer.cc.

References beamEta, beamPhi, beamXoff, beamYoff, crysNumber, GenVtxToken, edm::RandomNumberGenerator::getEngine(), edm::HepMCProduct::GetEvent(), LogDebug, eostools::move(), partXhodo, and partYhodo.

145  {
147  CLHEP::HepRandomEngine *engine = &rng->getEngine(event.streamID());
148 
149  std::unique_ptr<PEcalTBInfo> product(new PEcalTBInfo());
150 
151  // Fill the run information
152 
153  product->setCrystal(crysNumber);
154 
155  product->setBeamDirection(beamEta, beamPhi);
156  product->setBeamOffset(beamXoff, beamYoff);
157 
158  // Compute the event x,y vertex coordinates in the beam reference system
159  // e.g. in the place orthogonal to the beam average direction
160 
161  partXhodo = partYhodo = 0.;
162 
163  const edm::Handle<edm::HepMCProduct> &GenEvt = event.getHandle(GenVtxToken);
164 
165  const HepMC::GenEvent *Evt = GenEvt->GetEvent();
166  HepMC::GenEvent::vertex_const_iterator Vtx = Evt->vertices_begin();
167 
168  math::XYZPoint eventCMSVertex((*Vtx)->position().x(), (*Vtx)->position().y(), (*Vtx)->position().z());
169 
170  LogDebug("EcalTBInfo") << "Generated vertex position = " << eventCMSVertex.x() << " " << eventCMSVertex.y() << " "
171  << eventCMSVertex.z();
172 
173  math::XYZPoint eventTBVertex = (*fromCMStoTB) * eventCMSVertex;
174 
175  LogDebug("EcalTBInfo") << "Rotated vertex position = " << eventTBVertex.x() << " " << eventTBVertex.y() << " "
176  << eventTBVertex.z();
177 
178  partXhodo = eventTBVertex.x();
179  partYhodo = eventTBVertex.y();
180 
181  product->setBeamPosition(partXhodo, partYhodo);
182 
183  // Asynchronous phase shift
184  double thisPhaseShift = CLHEP::RandFlat::shoot(engine);
185 
186  product->setPhaseShift(thisPhaseShift);
187  LogDebug("EcalTBInfo") << "Asynchronous Phaseshift = " << thisPhaseShift;
188 
189  // store the object in the framework event
190 
191  event.put(std::move(product));
192 }
virtual CLHEP::HepRandomEngine & getEngine(StreamID const &)=0
Use this engine in event methods.
const HepMC::GenEvent * GetEvent() const
Definition: HepMCProduct.h:37
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
const edm::EDGetTokenT< edm::HepMCProduct > GenVtxToken
def move(src, dest)
Definition: eostools.py:511
Definition: event.py:1
#define LogDebug(id)

Member Data Documentation

◆ beamEta

const double EcalTBMCInfoProducer::beamEta
private

Definition at line 49 of file EcalTBMCInfoProducer.cc.

Referenced by EcalTBMCInfoProducer(), and produce().

◆ beamPhi

const double EcalTBMCInfoProducer::beamPhi
private

Definition at line 50 of file EcalTBMCInfoProducer.cc.

Referenced by EcalTBMCInfoProducer(), and produce().

◆ beamTheta

const double EcalTBMCInfoProducer::beamTheta
private

Definition at line 51 of file EcalTBMCInfoProducer.cc.

Referenced by EcalTBMCInfoProducer().

◆ beamXoff

const double EcalTBMCInfoProducer::beamXoff
private

Definition at line 52 of file EcalTBMCInfoProducer.cc.

Referenced by EcalTBMCInfoProducer(), and produce().

◆ beamYoff

const double EcalTBMCInfoProducer::beamYoff
private

Definition at line 53 of file EcalTBMCInfoProducer.cc.

Referenced by EcalTBMCInfoProducer(), and produce().

◆ crysNumber

int EcalTBMCInfoProducer::crysNumber
private

Definition at line 57 of file EcalTBMCInfoProducer.cc.

Referenced by EcalTBMCInfoProducer(), and produce().

◆ fMaxEta

const double EcalTBMCInfoProducer::fMaxEta
private

Definition at line 46 of file EcalTBMCInfoProducer.cc.

◆ fMaxPhi

const double EcalTBMCInfoProducer::fMaxPhi
private

Definition at line 48 of file EcalTBMCInfoProducer.cc.

◆ fMinEta

const double EcalTBMCInfoProducer::fMinEta
private

Definition at line 45 of file EcalTBMCInfoProducer.cc.

◆ fMinPhi

const double EcalTBMCInfoProducer::fMinPhi
private

Definition at line 47 of file EcalTBMCInfoProducer.cc.

◆ fromCMStoTB

std::unique_ptr<ROOT::Math::Rotation3D> EcalTBMCInfoProducer::fromCMStoTB
private

Definition at line 64 of file EcalTBMCInfoProducer.cc.

Referenced by EcalTBMCInfoProducer().

◆ GenVtxToken

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

Definition at line 55 of file EcalTBMCInfoProducer.cc.

Referenced by produce().

◆ partXhodo

double EcalTBMCInfoProducer::partXhodo
private

Definition at line 59 of file EcalTBMCInfoProducer.cc.

Referenced by produce().

◆ partYhodo

double EcalTBMCInfoProducer::partYhodo
private

Definition at line 60 of file EcalTBMCInfoProducer.cc.

Referenced by produce().

◆ theTestMap

std::unique_ptr<EcalTBCrystalMap> EcalTBMCInfoProducer::theTestMap
private

Definition at line 62 of file EcalTBMCInfoProducer.cc.

Referenced by EcalTBMCInfoProducer().