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 }
std::map< CaloHitID, float > hitMap_
Definition: CaloHitMaker.h:61
math::XYZVector XYZPoint
double preshowerZPosition(int layer) const
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
math::XYZVector XYZPoint
Definition: CaloHitMaker.h:23
Transform3D locToGlobal1_
PreshowerHitMaker(CaloGeometryHelper *calo, const XYZPoint &, const XYZVector &, const XYZPoint &, const XYZVector &, const LandauFluctuationGenerator *aGenerator, const RandomEngineAndDistribution *engine)
const CaloGeometryHelper * myCalorimeter
Definition: CaloHitMaker.h:44
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
bool addHit(double r, double phi, unsigned layer=0) override
PositionVector3D< Cartesian3D< double >, DefaultCoordinateSystemTag > Point
Definition: Transform3DPJ.h:58
static XYZPoint intersect(const Plane3D &p, const XYZPoint &a, const XYZPoint &b, double &t, bool segment, bool debug=false)
Definition: CaloHitMaker.cc:41
ROOT::Math::Transform3DPJ Transform3D
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: DetId.h:17
double landau(RandomEngineAndDistribution const *random) const
Random generator of the dE/dX spread (Landau function)
ROOT::Math::Plane3D Plane3D
Definition: CaloHitMaker.h:24
Transform3D locToGlobal2_
ROOT::Math::Transform3DPJ::Point Point
double moliereRadius
Definition: CaloHitMaker.h:46
Structure Point Contains parameters of Gaussian fits to DMRs.
const EcalPreshowerGeometry * getEcalPreshowerGeometry() const
Definition: Calorimeter.h:54
virtual DetId getClosestCellInPlane(const GlobalPoint &r, int plane) const
math::XYZVector XYZVector
Definition: CaloHitMaker.h:22
const LandauFluctuationGenerator * theGenerator
The Landau Fluctuation generator.
ROOT::Math::Plane3D Plane3D
Definition: Common.h:9
*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
const RandomEngineAndDistribution * random