CMS 3D CMS Logo

PreshowerHitMaker.cc
Go to the documentation of this file.
2 #
8 
9 #include "Math/GenVector/Plane3D.h"
10 
11 #include <cmath>
12 
15 
16 // LandauFluctuationGenerator PreshowerHitMaker::theGenerator=LandauFluctuationGenerator();
17 
19  const XYZPoint& layer1entrance,
20  const XYZVector& layer1dir,
21  const XYZPoint& layer2entrance,
22  const XYZVector& layer2dir,
23  const LandauFluctuationGenerator* aGenerator,
24  const RandomEngineAndDistribution* engine)
25  : CaloHitMaker(calo, DetId::Ecal, EcalPreshower, 2),
26  psLayer1Entrance_(layer1entrance),
27  psLayer1Dir_(layer1dir),
28  psLayer2Entrance_(layer2entrance),
29  psLayer2Dir_(layer2dir),
30  totalLayer1_(0.),
31  totalLayer2_(0.),
32  theGenerator(aGenerator),
33  random(engine) {
34  double dummyt;
35  anglecorrection1_ = 0.;
36  anglecorrection2_ = 0.;
37  // Check if the entrance points are really on the wafers
38  // Layer 1
39  layer1valid_ = (layer1entrance.Mag2() > 0.);
40  if (layer1valid_) {
41  int z = (psLayer1Entrance_.z() > 0) ? 1 : -1;
42  Plane3D plan1(0., 0., 1., -z * myCalorimeter->preshowerZPosition(1));
43 
44  psLayer1Entrance_ = intersect(plan1, layer1entrance, layer1entrance + layer1dir, dummyt, false);
45 
46  XYZVector zaxis(0, 0, 1);
47  XYZVector planeVec1 = (zaxis.Cross(layer1dir)).Unit();
48  locToGlobal1_ = Transform3D(Point(0, 0, 0),
49  Point(0, 0, 1),
50  Point(1, 0, 0),
52  (Point)(psLayer1Entrance_ + layer1dir),
53  (Point)(psLayer1Entrance_ + planeVec1));
54 
55  anglecorrection1_ = fabs(zaxis.Dot(layer1dir));
56  if (anglecorrection1_ != 0.)
58  // std::cout << " Layer 1 entrance " << psLayer1Entrance_ << std::endl;
59  // std::cout << " Layer 1 corr " << anglecorrection1_ << std::endl;
60  }
61 
62  // Layer 2
63  layer2valid_ = (layer2entrance.Mag2() > 0.);
64  if (layer2valid_) {
65  int z = (psLayer2Entrance_.z() > 0) ? 1 : -1;
66  Plane3D plan2(0., 0., 1., -z * myCalorimeter->preshowerZPosition(2));
67 
68  psLayer2Entrance_ = intersect(plan2, layer2entrance, layer2entrance + layer2dir, dummyt, false);
69 
70  XYZVector zaxis(0, 0, 1);
71  XYZVector planeVec2 = (zaxis.Cross(layer2dir)).Unit();
72  locToGlobal2_ = Transform3D(Point(0, 0, 0),
73  Point(0, 0, 1),
74  Point(1, 0, 0),
76  (Point)(psLayer2Entrance_ + layer2dir),
77  (Point)(psLayer2Entrance_ + planeVec2));
78 
79  anglecorrection2_ = fabs(zaxis.Dot(layer2dir));
80  if (anglecorrection2_ != 0.)
82  // std::cout << " Layer 2 entrance " << psLayer2Entrance_ << std::endl;
83  // std::cout << " Layer 2 corr " << anglecorrection2_ << std::endl;
84  }
85  // theGenerator=LandauFluctuationGenerator();
86 }
87 
88 bool PreshowerHitMaker::addHit(double r, double phi, unsigned layer) {
89  if ((layer == 1 && !layer1valid_) || ((layer == 2 && !layer2valid_)))
90  return false;
91 
92  r *= moliereRadius;
93  XYZPoint point(r * std::cos(phi), r * std::sin(phi), 0.);
95  // std::cout << " Point " << point << std::endl;
96  int z = (point.z() > 0) ? 1 : -1;
98  // std::cout << "r " << r << " Point after " << point << std::endl;
99  // std::cout << " Layer " << layer << " " << point << std::endl;
101  GlobalPoint(point.x(), point.y(), point.z()), layer);
102 
103  float meanspot = (layer == 1) ? mip1_ : mip2_;
104  float spote = meanspot + 0.000021 * theGenerator->landau(random);
105  spote *= ((layer == 1) ? anglecorrection1_ : anglecorrection2_);
106 
107  if (!strip.null()) {
108  //calculate time of flight
109  double tof =
110  (myCalorimeter->getEcalPreshowerGeometry()->getGeometry(strip)->getPosition().mag()) / 29.98; //speed of light
111  CaloHitID current_id(strip.rawId(), tof, 0); //no track yet
112  std::map<CaloHitID, float>::iterator cellitr;
113  cellitr = hitMap_.find(current_id);
114  if (cellitr == hitMap_.end()) {
115  hitMap_.insert(std::pair<CaloHitID, float>(current_id, spote));
116  } else {
117  cellitr->second += spote;
118  }
119  // std::cout << " found " << stripNumber << " " << spote <<std::endl;
120  if (layer == 1) {
121  totalLayer1_ += spote;
122  } else if (layer == 2) {
123  totalLayer2_ += spote;
124  }
125  return true;
126  }
127  // std::cout << " Could not find a cell " << point << std::endl;
128  return false;
129 }
PreshowerHitMaker.h
CaloHitMaker::XYZPoint
math::XYZVector XYZPoint
Definition: CaloHitMaker.h:23
PreshowerHitMaker::theGenerator
const LandauFluctuationGenerator * theGenerator
The Landau Fluctuation generator.
Definition: PreshowerHitMaker.h:58
digitizers_cfi.strip
strip
Definition: digitizers_cfi.py:19
PreshowerHitMaker::XYZPoint
math::XYZVector XYZPoint
Definition: PreshowerHitMaker.h:14
Point
ROOT::Math::Transform3DPJ::Point Point
Definition: PreshowerHitMaker.cc:14
PreshowerHitMaker::locToGlobal1_
Transform3D locToGlobal1_
Definition: PreshowerHitMaker.h:50
LaserClient_cfi.zaxis
zaxis
Definition: LaserClient_cfi.py:91
Plane3D
ROOT::Math::Plane3D Plane3D
Definition: PreshowerHitMaker.cc:13
funct::sin
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
DetId
Definition: DetId.h:17
PreshowerHitMaker::anglecorrection2_
float anglecorrection2_
Definition: PreshowerHitMaker.h:53
funct::cos
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
PreshowerHitMaker::psLayer2Entrance_
XYZPoint psLayer2Entrance_
Definition: PreshowerHitMaker.h:46
PreshowerHitMaker::mip2_
double mip2_
Definition: PreshowerHitMaker.h:54
DDAxes::z
PreshowerHitMaker::PreshowerHitMaker
PreshowerHitMaker(CaloGeometryHelper *calo, const XYZPoint &, const XYZVector &, const XYZPoint &, const XYZVector &, const LandauFluctuationGenerator *aGenerator, const RandomEngineAndDistribution *engine)
Definition: PreshowerHitMaker.cc:18
PreshowerHitMaker::layer2valid_
bool layer2valid_
Definition: PreshowerHitMaker.h:49
EcalPreshowerGeometry.h
GlobalPoint
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
PreshowerHitMaker::addHit
bool addHit(double r, double phi, unsigned layer=0) override
Definition: PreshowerHitMaker.cc:88
ROOT::Math::Transform3DPJ::Point
PositionVector3D< Cartesian3D< double >, DefaultCoordinateSystemTag > Point
Definition: Transform3DPJ.h:65
CaloHitMaker::intersect
static XYZPoint intersect(const Plane3D &p, const XYZPoint &a, const XYZPoint &b, double &t, bool segment, bool debug=false)
Definition: CaloHitMaker.cc:41
phase1PixelTopology::layer
constexpr std::array< uint8_t, layerIndexSize > layer
Definition: phase1PixelTopology.h:99
EcalSubdetector.h
EcalPreshowerGeometry::getClosestCellInPlane
virtual DetId getClosestCellInPlane(const GlobalPoint &r, int plane) const
Definition: EcalPreshowerGeometry.cc:139
Point
Structure Point Contains parameters of Gaussian fits to DMRs.
Definition: DMRtrends.cc:57
PVValHelper::phi
Definition: PVValidationHelpers.h:69
PreshowerHitMaker::mip1_
double mip1_
Definition: PreshowerHitMaker.h:54
CaloGeometryHelper.h
PreshowerHitMaker::totalLayer1_
float totalLayer1_
Definition: PreshowerHitMaker.h:55
PreshowerHitMaker::Transform3D
ROOT::Math::Transform3DPJ Transform3D
Definition: PreshowerHitMaker.h:15
LandauFluctuationGenerator::landau
double landau(RandomEngineAndDistribution const *random) const
Random generator of the dE/dX spread (Landau function)
Definition: LandauFluctuationGenerator.h:29
CaloSubdetectorGeometry::getGeometry
virtual std::shared_ptr< const CaloCellGeometry > getGeometry(const DetId &id) const
Get the cell geometry of a given detector id. Should return false if not found.
Definition: CaloSubdetectorGeometry.cc:36
CaloGeometryHelper::preshowerZPosition
double preshowerZPosition(int layer) const
Definition: CaloGeometryHelper.h:33
CaloHitMaker::myCalorimeter
const CaloGeometryHelper * myCalorimeter
Definition: CaloHitMaker.h:44
alignCSCRings.r
r
Definition: alignCSCRings.py:93
CaloHitMaker
Definition: CaloHitMaker.h:20
DDAxes::phi
EcalPreshower
Definition: EcalSubdetector.h:10
PreshowerHitMaker::psLayer1Entrance_
XYZPoint psLayer1Entrance_
Definition: PreshowerHitMaker.h:44
DetId.h
CaloHitMaker::Plane3D
ROOT::Math::Plane3D Plane3D
Definition: CaloHitMaker.h:24
CaloHitID
Definition: CaloHitID.h:11
CaloHitMaker::hitMap_
std::map< CaloHitID, float > hitMap_
Definition: CaloHitMaker.h:61
PreshowerHitMaker::locToGlobal2_
Transform3D locToGlobal2_
Definition: PreshowerHitMaker.h:51
LandauFluctuationGenerator.h
Calorimeter::getEcalPreshowerGeometry
const EcalPreshowerGeometry * getEcalPreshowerGeometry() const
Definition: Calorimeter.h:54
calo
Definition: Common.h:9
point
*vegas h *****************************************************used in the default bin number in original ***version of VEGAS is ***a higher bin number might help to derive a more precise ***grade subtle point
Definition: invegas.h:5
PreshowerHitMaker::random
const RandomEngineAndDistribution * random
Definition: PreshowerHitMaker.h:59
PreshowerHitMaker::anglecorrection1_
float anglecorrection1_
Definition: PreshowerHitMaker.h:52
CaloGeometryHelper
Definition: CaloGeometryHelper.h:18
CaloHitMaker::moliereRadius
double moliereRadius
Definition: CaloHitMaker.h:46
CaloHitMaker::XYZVector
math::XYZVector XYZVector
Definition: CaloHitMaker.h:22
LandauFluctuationGenerator
Definition: LandauFluctuationGenerator.h:20
PreshowerHitMaker::totalLayer2_
float totalLayer2_
Definition: PreshowerHitMaker.h:56
PreshowerHitMaker::layer1valid_
bool layer1valid_
Definition: PreshowerHitMaker.h:48
RandomEngineAndDistribution
Definition: RandomEngineAndDistribution.h:18