CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Attributes
EcalTBMCInfoProducer Class Reference

#include <EcalTBMCInfoProducer.h>

Inheritance diagram for EcalTBMCInfoProducer:
edm::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 EcalTBMCInfoProducer (const edm::ParameterSet &ps)
 Constructor. More...
 
void produce (edm::Event &event, const edm::EventSetup &eventSetup)
 Produce digis out of raw data. More...
 
virtual ~EcalTBMCInfoProducer ()
 Destructor. More...
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndex indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndex > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndex > &) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Attributes

double beamEta
 
double beamPhi
 
double beamTheta
 
double beamXoff
 
double beamYoff
 
int crysNumber
 
CLHEP::RandFlat * flatDistribution_
 
ROOT::Math::Rotation3D * fromCMStoTB
 
std::string GenVtxLabel
 
double partXhodo
 
double partYhodo
 
EcalTBCrystalMaptheTestMap
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
typedef WorkerT< EDProducerWorkerType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDProducer
CurrentProcessingContext const * currentContext () const
 
- Protected Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

Definition at line 34 of file EcalTBMCInfoProducer.h.

Constructor & Destructor Documentation

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

Constructor.

Definition at line 19 of file EcalTBMCInfoProducer.cc.

References beamEta, beamPhi, beamTheta, beamXoff, beamYoff, funct::cos(), crysNumber, reco_application_tbsim_DetSim-Digi_cfg::CrystalMapFile, HLTFastRecoForTau_cff::deltaEta, SiPixelRawToDigiRegional_cfi::deltaPhi, eta(), edm::hlt::Exception, create_public_lumi_plots::exp, EcalTBCrystalMap::findCrystalAngles(), flatDistribution_, fromCMStoTB, GenVtxLabel, edm::RandomNumberGenerator::getEngine(), edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), edm::Service< T >::isAvailable(), EcalTBCrystalMap::NCRYSTAL, phi, funct::sin(), theTestMap, and create_public_lumi_plots::xy.

19  : flatDistribution_(0) {
20 
21  produces<PEcalTBInfo>();
22 
24  GenVtxLabel = ps.getUntrackedParameter<string>("moduleLabelVtx","source");
25  double fMinEta = ps.getParameter<double>("MinEta");
26  double fMaxEta = ps.getParameter<double>("MaxEta");
27  double fMinPhi = ps.getParameter<double>("MinPhi");
28  double fMaxPhi = ps.getParameter<double>("MaxPhi");
29  beamEta = (fMaxEta+fMinEta)/2.;
30  beamPhi = (fMaxPhi+fMinPhi)/2.;
31  beamTheta = 2.0*atan(exp(-beamEta));
32  beamXoff = ps.getParameter<double>("BeamMeanX");
33  beamYoff = ps.getParameter<double>("BeamMeanX");
34 
35  string fullMapName = CrystalMapFile.fullPath();
36  theTestMap = new EcalTBCrystalMap(fullMapName);
37  crysNumber = 0;
38 
39  double deltaEta = 999.;
40  double deltaPhi = 999.;
41  for ( int cryIndex = 1; cryIndex <= EcalTBCrystalMap::NCRYSTAL; ++cryIndex) {
42  double eta = 0;
43  double phi = 0.;
44  theTestMap->findCrystalAngles(cryIndex, eta, phi);
45  if ( fabs(beamEta - eta) < deltaEta && fabs(beamPhi - phi) < deltaPhi ) {
46  deltaEta = fabs(beamEta - eta);
47  deltaPhi = fabs(beamPhi - phi);
48  crysNumber = cryIndex;
49  }
50  else if (fabs(beamEta - eta)<deltaEta && fabs(beamPhi - phi)>deltaPhi ) {
51  if ( fabs(beamPhi - phi) < 0.017 ) {
52  deltaEta = fabs(beamEta - eta);
53  deltaPhi = fabs(beamPhi - phi);
54  crysNumber = cryIndex;
55  }
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")
94  << "EcalTBMCInfoProducer requires the RandomNumberGeneratorService\n"
95  "which is not present in the configuration file. You must add the service\n"
96  "in the configuration file or remove the modules that require it.";
97  }
98  CLHEP::HepRandomEngine& engine = rng->getEngine();
99  flatDistribution_ = new CLHEP::RandFlat(engine);
100 
101 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
static const int NCRYSTAL
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
T eta() const
CLHEP::RandFlat * flatDistribution_
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
bool isAvailable() const
Definition: Service.h:47
virtual CLHEP::HepRandomEngine & getEngine() const =0
Use this to get the random number engine, this is the only function most users should call...
EcalTBCrystalMap * theTestMap
void findCrystalAngles(const int thisCrysIndex, double &thisEta, double &thisPhi)
ROOT::Math::Rotation3D * fromCMStoTB
Definition: DDAxes.h:10
EcalTBMCInfoProducer::~EcalTBMCInfoProducer ( )
virtual

Destructor.

Definition at line 103 of file EcalTBMCInfoProducer.cc.

References flatDistribution_, and theTestMap.

103  {
104 
105  delete flatDistribution_;
106  delete theTestMap;
107 
108 }
CLHEP::RandFlat * flatDistribution_
EcalTBCrystalMap * theTestMap

Member Function Documentation

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

Produce digis out of raw data.

Implements edm::EDProducer.

Definition at line 110 of file EcalTBMCInfoProducer.cc.

References beamEta, beamPhi, beamXoff, beamYoff, crysNumber, flatDistribution_, GenVtxLabel, LogDebug, partXhodo, and partYhodo.

111 {
112  auto_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.getByLabel(GenVtxLabel,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 = flatDistribution_->fire();
155 
156  product->setPhaseShift(thisPhaseShift);
157  LogDebug("EcalTBInfo") << "Asynchronous Phaseshift = " << thisPhaseShift;
158 
159  // store the object in the framework event
160 
161  event.put(product);
162 }
#define LogDebug(id)
CLHEP::RandFlat * flatDistribution_
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:13

Member Data Documentation

double EcalTBMCInfoProducer::beamEta
private

Definition at line 56 of file EcalTBMCInfoProducer.h.

Referenced by EcalTBMCInfoProducer(), and produce().

double EcalTBMCInfoProducer::beamPhi
private

Definition at line 57 of file EcalTBMCInfoProducer.h.

Referenced by EcalTBMCInfoProducer(), and produce().

double EcalTBMCInfoProducer::beamTheta
private

Definition at line 58 of file EcalTBMCInfoProducer.h.

Referenced by EcalTBMCInfoProducer().

double EcalTBMCInfoProducer::beamXoff
private

Definition at line 62 of file EcalTBMCInfoProducer.h.

Referenced by EcalTBMCInfoProducer(), and produce().

double EcalTBMCInfoProducer::beamYoff
private

Definition at line 63 of file EcalTBMCInfoProducer.h.

Referenced by EcalTBMCInfoProducer(), and produce().

int EcalTBMCInfoProducer::crysNumber
private

Definition at line 60 of file EcalTBMCInfoProducer.h.

Referenced by EcalTBMCInfoProducer(), and produce().

CLHEP::RandFlat* EcalTBMCInfoProducer::flatDistribution_
private

Definition at line 74 of file EcalTBMCInfoProducer.h.

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

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

Definition at line 70 of file EcalTBMCInfoProducer.h.

Referenced by EcalTBMCInfoProducer().

std::string EcalTBMCInfoProducer::GenVtxLabel
private

Definition at line 72 of file EcalTBMCInfoProducer.h.

Referenced by EcalTBMCInfoProducer(), and produce().

double EcalTBMCInfoProducer::partXhodo
private

Definition at line 65 of file EcalTBMCInfoProducer.h.

Referenced by produce().

double EcalTBMCInfoProducer::partYhodo
private

Definition at line 66 of file EcalTBMCInfoProducer.h.

Referenced by produce().

EcalTBCrystalMap* EcalTBMCInfoProducer::theTestMap
private

Definition at line 68 of file EcalTBMCInfoProducer.h.

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