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 hasAbilityToProduceInLumis () const final
 
bool hasAbilityToProduceInRuns () 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, hiPixelPairStep_cff::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.

22  {
23 
24  produces<PEcalTBInfo>();
25 
27  GenVtxToken = consumes<edm::HepMCProduct>(edm::InputTag("moduleLabelVtx","source"));
28  double fMinEta = ps.getParameter<double>("MinEta");
29  double fMaxEta = ps.getParameter<double>("MaxEta");
30  double fMinPhi = ps.getParameter<double>("MinPhi");
31  double fMaxPhi = ps.getParameter<double>("MaxPhi");
32  beamEta = (fMaxEta+fMinEta)/2.;
33  beamPhi = (fMaxPhi+fMinPhi)/2.;
34  beamTheta = 2.0*atan(exp(-beamEta));
35  beamXoff = ps.getParameter<double>("BeamMeanX");
36  beamYoff = ps.getParameter<double>("BeamMeanX");
37 
38  string fullMapName = CrystalMapFile.fullPath();
39  theTestMap = new EcalTBCrystalMap(fullMapName);
40  crysNumber = 0;
41 
42  double deltaEta = 999.;
43  double deltaPhi = 999.;
44  for ( int cryIndex = 1; cryIndex <= EcalTBCrystalMap::NCRYSTAL; ++cryIndex) {
45  double eta = 0;
46  double phi = 0.;
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;
52  }
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;
58  }
59  }
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;
65  }
66  }
67  }
68 
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;
76 
77  // rotation matrix to move from the CMS reference frame to the test beam one
78 
79  double xx = -cos(beamTheta)*cos(beamPhi);
80  double xy = -cos(beamTheta)*sin(beamPhi);
81  double xz = sin(beamTheta);
82 
83  double yx = sin(beamPhi);
84  double yy = -cos(beamPhi);
85  double yz = 0.;
86 
87  double zx = sin(beamTheta)*cos(beamPhi);
88  double zy = sin(beamTheta)*sin(beamPhi);
89  double zz = cos(beamTheta);
90 
91  fromCMStoTB = new ROOT::Math::Rotation3D(xx, xy, xz, yx, yy, yz, zx, zy, zz);
92 
93  // random number
95  if ( ! rng.isAvailable()) {
96  throw cms::Exception("Configuration")
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.";
100  }
101 }
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:46
EcalTBCrystalMap * theTestMap
void findCrystalAngles(const int thisCrysIndex, double &thisEta, double &thisPhi)
ROOT::Math::Rotation3D * fromCMStoTB
EcalTBMCInfoProducer::~EcalTBMCInfoProducer ( )
override

Destructor.

Definition at line 103 of file EcalTBMCInfoProducer.cc.

103  {
104  delete theTestMap;
105 }
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 107 of file EcalTBMCInfoProducer.cc.

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

108 {
110  CLHEP::HepRandomEngine* engine = &rng->getEngine(event.streamID());
111 
112  unique_ptr<PEcalTBInfo> product(new PEcalTBInfo());
113 
114  // Fill the run information
115 
116  product->setCrystal(crysNumber);
117 
118  product->setBeamDirection(beamEta, beamPhi);
119  product->setBeamOffset(beamXoff, beamYoff);
120 
121  // Compute the event x,y vertex coordinates in the beam reference system
122  // e.g. in the place orthogonal to the beam average direction
123 
124  partXhodo = partYhodo = 0.;
125 
127  event.getByToken(GenVtxToken,GenEvt);
128 
129  const HepMC::GenEvent* Evt = GenEvt->GetEvent() ;
130  HepMC::GenEvent::vertex_const_iterator Vtx = Evt->vertices_begin();
131 
132  math::XYZPoint eventCMSVertex((*Vtx)->position().x(),
133  (*Vtx)->position().y(),
134  (*Vtx)->position().z());
135 
136  LogDebug("EcalTBInfo") << "Generated vertex position = "
137  << eventCMSVertex.x() << " "
138  << eventCMSVertex.y() << " "
139  << eventCMSVertex.z();
140 
141  math::XYZPoint eventTBVertex = (*fromCMStoTB)*eventCMSVertex;
142 
143  LogDebug("EcalTBInfo") << "Rotated vertex position = "
144  << eventTBVertex.x() << " "
145  << eventTBVertex.y() << " "
146  << eventTBVertex.z();
147 
148  partXhodo = eventTBVertex.x();
149  partYhodo = eventTBVertex.y();
150 
151  product->setBeamPosition(partXhodo, partYhodo);
152 
153  // Asynchronous phase shift
154  double thisPhaseShift = CLHEP::RandFlat::shoot(engine);
155 
156  product->setPhaseShift(thisPhaseShift);
157  LogDebug("EcalTBInfo") << "Asynchronous Phaseshift = " << thisPhaseShift;
158 
159  // store the object in the framework event
160 
161  event.put(std::move(product));
162 }
#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:38
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 38 of file EcalTBMCInfoProducer.h.

double EcalTBMCInfoProducer::beamPhi
private

Definition at line 39 of file EcalTBMCInfoProducer.h.

double EcalTBMCInfoProducer::beamTheta
private

Definition at line 40 of file EcalTBMCInfoProducer.h.

double EcalTBMCInfoProducer::beamXoff
private

Definition at line 44 of file EcalTBMCInfoProducer.h.

double EcalTBMCInfoProducer::beamYoff
private

Definition at line 45 of file EcalTBMCInfoProducer.h.

int EcalTBMCInfoProducer::crysNumber
private

Definition at line 42 of file EcalTBMCInfoProducer.h.

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

Definition at line 52 of file EcalTBMCInfoProducer.h.

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

Definition at line 54 of file EcalTBMCInfoProducer.h.

double EcalTBMCInfoProducer::partXhodo
private

Definition at line 47 of file EcalTBMCInfoProducer.h.

double EcalTBMCInfoProducer::partYhodo
private

Definition at line 48 of file EcalTBMCInfoProducer.h.

EcalTBCrystalMap* EcalTBMCInfoProducer::theTestMap
private

Definition at line 50 of file EcalTBMCInfoProducer.h.