CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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  CaloGeometryHelper * calo,
20  const XYZPoint& layer1entrance,
21  const XYZVector& layer1dir,
22  const XYZPoint& layer2entrance,
23  const XYZVector& layer2dir,
24  const LandauFluctuationGenerator* aGenerator):
25  CaloHitMaker(calo,DetId::Ecal,EcalPreshower,2),
26  psLayer1Entrance_(layer1entrance),
27  psLayer1Dir_(layer1dir),
28  psLayer2Entrance_(layer2entrance),
29  psLayer2Dir_(layer2dir),
30  totalLayer1_(0.),totalLayer2_(0.),
31  theGenerator(aGenerator)
32 {
33  double dummyt;
34  anglecorrection1_ = 0.;
35  anglecorrection2_ = 0.;
36  // Check if the entrance points are really on the wafers
37  // Layer 1
38  layer1valid_ = (layer1entrance.Mag2()>0.);
39  if(layer1valid_)
40  {
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();
49  Point(0,0,1),
50  Point(1,0,0),
51  (Point)psLayer1Entrance_,
52  (Point)(psLayer1Entrance_+layer1dir),
53  (Point)(psLayer1Entrance_+planeVec1));
54 
55  anglecorrection1_ = fabs(zaxis.Dot(layer1dir));
57  // std::cout << " Layer 1 entrance " << psLayer1Entrance_ << std::endl;
58  // std::cout << " Layer 1 corr " << anglecorrection1_ << std::endl;
59  }
60 
61  // Layer 2
62  layer2valid_ = (layer2entrance.Mag2()>0.);
63  if(layer2valid_)
64  {
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();
73  Point(0,0,1),
74  Point(1,0,0),
75  (Point)psLayer2Entrance_,
76  (Point)(psLayer2Entrance_+layer2dir),
77  (Point)(psLayer2Entrance_+planeVec2));
78 
79  anglecorrection2_ = fabs(zaxis.Dot(layer2dir));
81  // std::cout << " Layer 2 entrance " << psLayer2Entrance_ << std::endl;
82  // std::cout << " Layer 2 corr " << anglecorrection2_ << std::endl;
83  }
84  // theGenerator=LandauFluctuationGenerator();
85 }
86 
87 
88 bool
89 PreshowerHitMaker::addHit(double r,double phi,unsigned layer)
90 {
91  if((layer==1&&!layer1valid_)||((layer==2&&!layer2valid_))) return false;
92 
93  r*=moliereRadius;
94  XYZPoint point (r*std::cos(phi),r*std::sin(phi),0.);
95  point = (layer==1) ? locToGlobal1_((Point)point) : locToGlobal2_((Point)point);
96  // std::cout << " Point " << point << std::endl;
97  int z=(point.z()>0) ? 1: -1;
98  point = XYZPoint(point.x(),point.y(),z*myCalorimeter->preshowerZPosition(layer));
99  // std::cout << "r " << r << " Point after " << point << std::endl;
100  // std::cout << " Layer " << layer << " " << point << std::endl;
101  DetId strip = myCalorimeter->getEcalPreshowerGeometry()->getClosestCellInPlane(GlobalPoint(point.x(),point.y(),point.z()),layer);
102 
103  float meanspot=(layer==1) ? mip1_ : mip2_;
104  float spote = meanspot + 0.000021*theGenerator->landau();
105  spote *= ( (layer==1) ? anglecorrection1_ : anglecorrection2_ );
106 
107  if(!strip.null())
108  {
109  uint32_t stripNumber=strip.rawId();
110  std::map<uint32_t,float>::iterator cellitr;
111  cellitr = hitMap_.find(stripNumber);
112  if( cellitr==hitMap_.end())
113  {
114  hitMap_.insert(std::pair<uint32_t,float>(stripNumber,spote));
115  }
116  else
117  {
118  cellitr->second+=spote;
119  }
120  // std::cout << " found " << stripNumber << " " << spote <<std::endl;
121  if(layer==1){
122  totalLayer1_+=spote;
123  }
124  else if (layer==2) {
125  totalLayer2_+=spote;
126  }
127  return true;
128  }
129  // std::cout << " Could not find a cell " << point << std::endl;
130  return false;
131 }
double preshowerZPosition(int layer) const
PositionVector3D< Cartesian3D< double >, DefaultCoordinateSystemTag > Point
Definition: Transform3DPJ.h:66
void strip(std::string &input, const std::string &blanks=" \n\t")
Definition: stringTools.cc:16
math::XYZVector XYZPoint
bool addHit(double r, double phi, unsigned layer=0)
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
math::XYZVector XYZPoint
Definition: CaloHitMaker.h:25
const EcalPreshowerGeometry * getEcalPreshowerGeometry() const
Definition: Calorimeter.h:55
Transform3D locToGlobal1_
std::pair< double, double > Point
Definition: CaloEllipse.h:18
const CaloGeometryHelper * myCalorimeter
Definition: CaloHitMaker.h:46
double landau() const
Random generator of the dE/dX spread (Landau function)
Definition: DDAxes.h:10
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
math::XYZPoint Point
virtual DetId getClosestCellInPlane(const GlobalPoint &r, int plane) const
static XYZPoint intersect(const Plane3D &p, const XYZPoint &a, const XYZPoint &b, double &t, bool segment, bool debug=false)
Definition: CaloHitMaker.cc:38
ROOT::Math::Transform3DPJ Transform3D
Definition: DetId.h:20
ROOT::Math::Plane3D Plane3D
Definition: CaloHitMaker.h:26
Transform3D locToGlobal2_
double moliereRadius
Definition: CaloHitMaker.h:48
PreshowerHitMaker(CaloGeometryHelper *calo, const XYZPoint &, const XYZVector &, const XYZPoint &, const XYZVector &, const LandauFluctuationGenerator *aGenerator)
math::XYZVector XYZVector
Definition: CaloHitMaker.h:24
std::map< uint32_t, float > hitMap_
Definition: CaloHitMaker.h:64
const LandauFluctuationGenerator * theGenerator
The Landau Fluctuation generator.
ROOT::Math::Plane3D Plane3D
*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
Definition: DDAxes.h:10