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 ()
 
ModuleDescription const & moduleDescription () const
 
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 ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) 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
 
- 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::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 33 of file EcalTBMCInfoProducer.h.

Constructor & Destructor Documentation

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

Constructor.

Definition at line 18 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.

18  : flatDistribution_(0) {
19 
20  produces<PEcalTBInfo>();
21 
23  GenVtxLabel = ps.getUntrackedParameter<string>("moduleLabelVtx","source");
24  double fMinEta = ps.getParameter<double>("MinEta");
25  double fMaxEta = ps.getParameter<double>("MaxEta");
26  double fMinPhi = ps.getParameter<double>("MinPhi");
27  double fMaxPhi = ps.getParameter<double>("MaxPhi");
28  beamEta = (fMaxEta+fMinEta)/2.;
29  beamPhi = (fMaxPhi+fMinPhi)/2.;
30  beamTheta = 2.0*atan(exp(-beamEta));
31  beamXoff = ps.getParameter<double>("BeamMeanX");
32  beamYoff = ps.getParameter<double>("BeamMeanX");
33 
34  string fullMapName = CrystalMapFile.fullPath();
35  theTestMap = new EcalTBCrystalMap(fullMapName);
36  crysNumber = 0;
37 
38  double deltaEta = 999.;
39  double deltaPhi = 999.;
40  for ( int cryIndex = 1; cryIndex <= EcalTBCrystalMap::NCRYSTAL; ++cryIndex) {
41  double eta = 0;
42  double phi = 0.;
43  theTestMap->findCrystalAngles(cryIndex, eta, phi);
44  if ( fabs(beamEta - eta) < deltaEta && fabs(beamPhi - phi) < deltaPhi ) {
45  deltaEta = fabs(beamEta - eta);
46  deltaPhi = fabs(beamPhi - phi);
47  crysNumber = cryIndex;
48  }
49  else if (fabs(beamEta - eta)<deltaEta && fabs(beamPhi - phi)>deltaPhi ) {
50  if ( fabs(beamPhi - phi) < 0.017 ) {
51  deltaEta = fabs(beamEta - eta);
52  deltaPhi = fabs(beamPhi - phi);
53  crysNumber = cryIndex;
54  }
55  }
56  else if (fabs(beamEta - eta)>deltaEta && fabs(beamPhi - phi)<deltaPhi ) {
57  if ( fabs(beamEta - eta) < 0.017 ) {
58  deltaEta = fabs(beamEta - eta);
59  deltaPhi = fabs(beamPhi - phi);
60  crysNumber = cryIndex;
61  }
62  }
63  }
64 
65  edm::LogInfo("EcalTBInfo") << "Initialize TB MC ECAL info producer with parameters: \n"
66  << "Crystal map file: " << CrystalMapFile << "\n"
67  << "Beam average eta = " << beamEta << "\n"
68  << "Beam average phi = " << beamPhi << "\n"
69  << "Corresponding to crystal number = " << crysNumber << "\n"
70  << "Beam X offset = " << beamXoff << "\n"
71  << "Beam Y offset = " << beamYoff;
72 
73  // rotation matrix to move from the CMS reference frame to the test beam one
74 
75  double xx = -cos(beamTheta)*cos(beamPhi);
76  double xy = -cos(beamTheta)*sin(beamPhi);
77  double xz = sin(beamTheta);
78 
79  double yx = sin(beamPhi);
80  double yy = -cos(beamPhi);
81  double yz = 0.;
82 
83  double zx = sin(beamTheta)*cos(beamPhi);
84  double zy = sin(beamTheta)*sin(beamPhi);
85  double zz = cos(beamTheta);
86 
87  fromCMStoTB = new ROOT::Math::Rotation3D(xx, xy, xz, yx, yy, yz, zx, zy, zz);
88 
89  // random number
91  if ( ! rng.isAvailable()) {
92  throw cms::Exception("Configuration")
93  << "EcalTBMCInfoProducer requires the RandomNumberGeneratorService\n"
94  "which is not present in the configuration file. You must add the service\n"
95  "in the configuration file or remove the modules that require it.";
96  }
97  CLHEP::HepRandomEngine& engine = rng->getEngine();
98  flatDistribution_ = new CLHEP::RandFlat(engine);
99 
100 }
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:46
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 102 of file EcalTBMCInfoProducer.cc.

References flatDistribution_, and theTestMap.

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

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

110 {
111  auto_ptr<PEcalTBInfo> product(new PEcalTBInfo());
112 
113  // Fill the run information
114 
115  product->setCrystal(crysNumber);
116 
117  product->setBeamDirection(beamEta, beamPhi);
118  product->setBeamOffset(beamXoff, beamYoff);
119 
120  // Compute the event x,y vertex coordinates in the beam reference system
121  // e.g. in the place orthogonal to the beam average direction
122 
123  partXhodo = partYhodo = 0.;
124 
126  event.getByLabel(GenVtxLabel,GenEvt);
127 
128  const HepMC::GenEvent* Evt = GenEvt->GetEvent() ;
129  HepMC::GenEvent::vertex_const_iterator Vtx = Evt->vertices_begin();
130 
131  math::XYZPoint eventCMSVertex((*Vtx)->position().x(),
132  (*Vtx)->position().y(),
133  (*Vtx)->position().z());
134 
135  LogDebug("EcalTBInfo") << "Generated vertex position = "
136  << eventCMSVertex.x() << " "
137  << eventCMSVertex.y() << " "
138  << eventCMSVertex.z();
139 
140  math::XYZPoint eventTBVertex = (*fromCMStoTB)*eventCMSVertex;
141 
142  LogDebug("EcalTBInfo") << "Rotated vertex position = "
143  << eventTBVertex.x() << " "
144  << eventTBVertex.y() << " "
145  << eventTBVertex.z();
146 
147  partXhodo = eventTBVertex.x();
148  partYhodo = eventTBVertex.y();
149 
150  product->setBeamPosition(partXhodo, partYhodo);
151 
152  // Asynchronous phase shift
153  double thisPhaseShift = flatDistribution_->fire();
154 
155  product->setPhaseShift(thisPhaseShift);
156  LogDebug("EcalTBInfo") << "Asynchronous Phaseshift = " << thisPhaseShift;
157 
158  // store the object in the framework event
159 
160  event.put(product);
161 }
#define LogDebug(id)
CLHEP::RandFlat * flatDistribution_
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12

Member Data Documentation

double EcalTBMCInfoProducer::beamEta
private

Definition at line 55 of file EcalTBMCInfoProducer.h.

Referenced by EcalTBMCInfoProducer(), and produce().

double EcalTBMCInfoProducer::beamPhi
private

Definition at line 56 of file EcalTBMCInfoProducer.h.

Referenced by EcalTBMCInfoProducer(), and produce().

double EcalTBMCInfoProducer::beamTheta
private

Definition at line 57 of file EcalTBMCInfoProducer.h.

Referenced by EcalTBMCInfoProducer().

double EcalTBMCInfoProducer::beamXoff
private

Definition at line 61 of file EcalTBMCInfoProducer.h.

Referenced by EcalTBMCInfoProducer(), and produce().

double EcalTBMCInfoProducer::beamYoff
private

Definition at line 62 of file EcalTBMCInfoProducer.h.

Referenced by EcalTBMCInfoProducer(), and produce().

int EcalTBMCInfoProducer::crysNumber
private

Definition at line 59 of file EcalTBMCInfoProducer.h.

Referenced by EcalTBMCInfoProducer(), and produce().

CLHEP::RandFlat* EcalTBMCInfoProducer::flatDistribution_
private

Definition at line 73 of file EcalTBMCInfoProducer.h.

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

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

Definition at line 69 of file EcalTBMCInfoProducer.h.

Referenced by EcalTBMCInfoProducer().

std::string EcalTBMCInfoProducer::GenVtxLabel
private

Definition at line 71 of file EcalTBMCInfoProducer.h.

Referenced by EcalTBMCInfoProducer(), and produce().

double EcalTBMCInfoProducer::partXhodo
private

Definition at line 64 of file EcalTBMCInfoProducer.h.

Referenced by produce().

double EcalTBMCInfoProducer::partYhodo
private

Definition at line 65 of file EcalTBMCInfoProducer.h.

Referenced by produce().

EcalTBCrystalMap* EcalTBMCInfoProducer::theTestMap
private

Definition at line 67 of file EcalTBMCInfoProducer.h.

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