CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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
 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

double beamEta
 
double beamPhi
 
double beamTheta
 
double beamXoff
 
double beamYoff
 
int crysNumber
 
ROOT::Math::Rotation3D * fromCMStoTB
 
edm::EDGetTokenT
< edm::HepMCProduct
GenVtxToken
 
double partXhodo
 
double partYhodo
 
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 32 of file EcalTBMCInfoProducer.cc.

Constructor & Destructor Documentation

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

Constructor.

Definition at line 63 of file EcalTBMCInfoProducer.cc.

References beamEta, beamPhi, beamTheta, beamXoff, beamYoff, funct::cos(), crysNumber, reco_application_tbsim_DetSim-Digi_cfg::CrystalMapFile, spr::deltaEta, srCondWrite_cfg::deltaPhi, PVValHelper::eta, Exception, funct::exp(), EcalTBCrystalMap::findCrystalAngles(), fromCMStoTB, GenVtxToken, edm::ParameterSet::getParameter(), HLT_FULL_cff::InputTag, edm::Service< T >::isAvailable(), EcalTBCrystalMap::NCRYSTAL, phi, funct::sin(), AlCaHLTBitMon_QueryRunRegistry::string, theTestMap, and xy().

63  {
64  produces<PEcalTBInfo>();
65 
67  GenVtxToken = consumes<edm::HepMCProduct>(edm::InputTag("moduleLabelVtx", "source"));
68  double fMinEta = ps.getParameter<double>("MinEta");
69  double fMaxEta = ps.getParameter<double>("MaxEta");
70  double fMinPhi = ps.getParameter<double>("MinPhi");
71  double 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 
78  std::string fullMapName = CrystalMapFile.fullPath();
79  theTestMap = new EcalTBCrystalMap(fullMapName);
80  crysNumber = 0;
81 
82  double deltaEta = 999.;
83  double deltaPhi = 999.;
84  for (int cryIndex = 1; cryIndex <= EcalTBCrystalMap::NCRYSTAL; ++cryIndex) {
85  double eta = 0;
86  double phi = 0.;
87  theTestMap->findCrystalAngles(cryIndex, eta, phi);
88  if (fabs(beamEta - eta) < deltaEta && fabs(beamPhi - phi) < deltaPhi) {
89  deltaEta = fabs(beamEta - eta);
90  deltaPhi = fabs(beamPhi - phi);
91  crysNumber = cryIndex;
92  } else if (fabs(beamEta - eta) < deltaEta && fabs(beamPhi - phi) > deltaPhi) {
93  if (fabs(beamPhi - phi) < 0.017) {
94  deltaEta = fabs(beamEta - eta);
95  deltaPhi = fabs(beamPhi - phi);
96  crysNumber = cryIndex;
97  }
98  } else if (fabs(beamEta - eta) > deltaEta && fabs(beamPhi - phi) < deltaPhi) {
99  if (fabs(beamEta - eta) < 0.017) {
100  deltaEta = fabs(beamEta - eta);
101  deltaPhi = fabs(beamPhi - phi);
102  crysNumber = cryIndex;
103  }
104  }
105  }
106 
107  edm::LogVerbatim("EcalTBInfo") << "Initialize TB MC ECAL info producer with parameters: \n"
108  << "Crystal map file: " << CrystalMapFile << "\n"
109  << "Beam average eta = " << beamEta << "\n"
110  << "Beam average phi = " << beamPhi << "\n"
111  << "Corresponding to crystal number = " << crysNumber << "\n"
112  << "Beam X offset = " << beamXoff << "\n"
113  << "Beam Y offset = " << beamYoff;
114 
115  // rotation matrix to move from the CMS reference frame to the test beam one
116 
117  double xx = -cos(beamTheta) * cos(beamPhi);
118  double xy = -cos(beamTheta) * sin(beamPhi);
119  double xz = sin(beamTheta);
120 
121  double yx = sin(beamPhi);
122  double yy = -cos(beamPhi);
123  double yz = 0.;
124 
125  double zx = sin(beamTheta) * cos(beamPhi);
126  double zy = sin(beamTheta) * sin(beamPhi);
127  double zz = cos(beamTheta);
128 
129  fromCMStoTB = new ROOT::Math::Rotation3D(xx, xy, xz, yx, yy, yz, zx, zy, zz);
130 
131  // random number
133  if (!rng.isAvailable()) {
134  throw cms::Exception("Configuration") << "EcalTBMCInfoProducer requires the RandomNumberGeneratorService\n"
135  "which is not present in the configuration file. You must add the "
136  "service\n"
137  "in the configuration file or remove the modules that require it.";
138  }
139 }
Log< level::Info, true > LogVerbatim
edm::EDGetTokenT< edm::HepMCProduct > GenVtxToken
static const int NCRYSTAL
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
Exp< T >::type exp(const T &t)
Definition: Exp.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
Basic2DVector< T > xy() const
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
void findCrystalAngles(const int thisCrysIndex, double &thisEta, double &thisPhi)
ROOT::Math::Rotation3D * fromCMStoTB
EcalTBMCInfoProducer::~EcalTBMCInfoProducer ( )
override

Destructor.

Definition at line 141 of file EcalTBMCInfoProducer.cc.

References theTestMap.

141 { 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 143 of file EcalTBMCInfoProducer.cc.

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

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

Member Data Documentation

double EcalTBMCInfoProducer::beamEta
private

Definition at line 44 of file EcalTBMCInfoProducer.cc.

Referenced by EcalTBMCInfoProducer(), and produce().

double EcalTBMCInfoProducer::beamPhi
private

Definition at line 45 of file EcalTBMCInfoProducer.cc.

Referenced by EcalTBMCInfoProducer(), and produce().

double EcalTBMCInfoProducer::beamTheta
private

Definition at line 46 of file EcalTBMCInfoProducer.cc.

Referenced by EcalTBMCInfoProducer().

double EcalTBMCInfoProducer::beamXoff
private

Definition at line 50 of file EcalTBMCInfoProducer.cc.

Referenced by EcalTBMCInfoProducer(), and produce().

double EcalTBMCInfoProducer::beamYoff
private

Definition at line 51 of file EcalTBMCInfoProducer.cc.

Referenced by EcalTBMCInfoProducer(), and produce().

int EcalTBMCInfoProducer::crysNumber
private

Definition at line 48 of file EcalTBMCInfoProducer.cc.

Referenced by EcalTBMCInfoProducer(), and produce().

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

Definition at line 58 of file EcalTBMCInfoProducer.cc.

Referenced by EcalTBMCInfoProducer().

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

Definition at line 60 of file EcalTBMCInfoProducer.cc.

Referenced by EcalTBMCInfoProducer(), and produce().

double EcalTBMCInfoProducer::partXhodo
private

Definition at line 53 of file EcalTBMCInfoProducer.cc.

Referenced by produce().

double EcalTBMCInfoProducer::partYhodo
private

Definition at line 54 of file EcalTBMCInfoProducer.cc.

Referenced by produce().

EcalTBCrystalMap* EcalTBMCInfoProducer::theTestMap
private

Definition at line 56 of file EcalTBMCInfoProducer.cc.

Referenced by EcalTBMCInfoProducer(), and ~EcalTBMCInfoProducer().