CMS 3D CMS Logo

HcalHitMaker.cc
Go to the documentation of this file.
5 #include <algorithm>
6 #include <cmath>
7 
9 
11  : CaloHitMaker(grid.getCalorimeter(),
12  DetId::Hcal,
13  HcalHitMaker::getSubHcalDet(grid.getFSimTrack()),
14  grid.getFSimTrack()->onHcal() ? grid.getFSimTrack()->onHcal() : grid.getFSimTrack()->onVFcal() + 1,
15  shower),
16  myGrid(grid),
17  myTrack((grid.getFSimTrack())) {
18  // normalize the direction
22  mapCalculated_ = false;
23  //std::cout << " Famos HCAL " << grid.getTrack()->onHcal() << " " << grid.getTrack()->onVFcal() << " " << showerType << std::endl;
24  if (EMSHOWER && (abs(grid.getFSimTrack()->type()) != 11 && grid.getFSimTrack()->type() != 22)) {
25  std::cout << " FamosHcalHitMaker : Strange. The following shower has EM type" << std::endl
26  << *grid.getFSimTrack() << std::endl;
27  }
28 }
29 
30 bool HcalHitMaker::addHit(double r, double phi, unsigned layer) {
31  // std::cout << " FamosHcalHitMaker::addHit - radiusFactor = " << radiusFactor
32  // << std::endl;
33 
35 
36  // Watch out !!!! (Point) is a real point in the MathCore terminology (not a redefined a XYZPoint which
37  // is actually a XYZVector in the MatchCore terminology). Therefore, the Transform3D is correctly applied
39  return addHit(point, layer);
40 }
41 
42 bool HcalHitMaker::addHit(const XYZPoint& point, unsigned layer) {
43  // Temporary nasty hacks to avoid misbehaviour of not-intended-for-that
44  // getClosestCell in case of large (eta beyond HF ...) and in EM showers
45  if (fabs(point.Z()) > 2000 || fabs(point.X()) > 2000 || fabs(point.Y()) > 2000) {
46  if (EMSHOWER)
47  edm::LogWarning("HcalHitMaker") << "received a hit very far from the detector " << point
48  << " coming from an electromagnetic shower. - Ignoring it" << std::endl;
49  else if (HADSHOWER)
50  edm::LogWarning("HcalHitMaker") << "received a hit very far from the detector " << point
51  << " coming from a hadron shower. - Ignoring it" << std::endl;
52  else if (MIP)
53  edm::LogWarning("HcalHitMaker") << "received a hit very far from the detector " << point
54  << " coming from a muon. - Ignoring it" << std::endl;
55  return false;
56  }
57 
58  double pointeta = fabs(point.eta());
59  if (pointeta > 5.19)
60  return false;
61 
62  //calculate time of flight
63  double dist = std::sqrt(point.X() * point.X() + point.Y() * point.Y() + point.Z() * point.Z());
64  double tof = dist / 29.98; //speed of light
65 
66  DetId thecellID(myCalorimeter->getClosestCell(point, false, false));
67 
68  HcalDetId myDetId(thecellID);
69 
70  // if ( myDetId.subdetId() == HcalForward ) {
71  // std::cout << "HcalHitMaker : " << point.Z() << " " << myDetId.depth() << std::endl;
72  // }
73 
74  // std::cout << "BEFORE" << std::endl;
75  // std::cout << "HcalHitMaker : subdetId : " << myDetId.subdetId() << std::endl;
76  // std::cout << "HcalHitMaker : depth : " << myDetId.depth() << std::endl;
77  // std::cout << "HcalHitMaker : ieta : " << myDetId.ieta() << std::endl;
78  // std::cout << "HcalHitMaker : iphi : " << myDetId.iphi() << std::endl;
79  // std::cout << "HcalHitMaker : spotE : " << spotEnergy << std::endl;
80  // std::cout << "HcalHitMaker : point.X : " << point.X() << std::endl;
81  // std::cout << "HcalHitMaker : point.Y : " << point.Y() << std::endl;
82  // std::cout << "HcalHitMaker : point.Z : " << point.Z() << std::endl;
83 
84  if (myDetId.subdetId() == HcalForward) {
85  int mylayer = layer;
86  if (myDetId.depth() == 2) {
87  mylayer = (int)layer;
88  } else {
89  mylayer = 1;
90  }
91  HcalDetId myDetId2((HcalSubdetector)myDetId.subdetId(), myDetId.ieta(), myDetId.iphi(), mylayer);
92  thecellID = myDetId2;
93  myDetId = myDetId2;
94  }
95 
96  if (!thecellID.null() && myDetId.depth() > 0) {
97  CaloHitID current_id(thecellID.rawId(), tof, 0); //no track yet
98 
99  // std::cout << " FamosHcalHitMaker::addHit - the cell num " << cell
100  // << std::endl;
101 
102  std::map<CaloHitID, float>::iterator cellitr;
103  cellitr = hitMap_.find(current_id);
104  if (cellitr == hitMap_.end()) {
105  hitMap_.insert(std::pair<CaloHitID, float>(current_id, spotEnergy));
106  } else {
107  cellitr->second += spotEnergy;
108  }
109  return true;
110  }
111  return false;
112 }
113 
114 bool HcalHitMaker::setDepth(double depth, bool inCm) {
116  std::vector<CaloSegment>::const_iterator segiterator;
117  if (inCm) {
118  segiterator =
120  } else {
121  if (EMSHOWER)
122  segiterator =
124 
125  //Hadron shower
126  if (HADSHOWER)
127  segiterator =
129  }
130 
131  if (segiterator == myGrid.getSegments().end()) {
132  // Special trick - As advised by Salavat, no leakage should be simulated
133  if (depth > myGrid.getSegments().back().sL0Exit()) {
134  segiterator = find_if(myGrid.getSegments().begin(),
135  myGrid.getSegments().end(),
136  CaloSegment::inL0Segment(myGrid.getSegments().back().sL0Exit() - 1.));
137  depth = segiterator->sL0Exit() - 1.;
139  if (segiterator == myGrid.getSegments().end()) {
140  std::cout << " Could not go at such depth " << EMSHOWER << " " << currentDepth_ << std::endl;
141  std::cout << " Track " << *(myGrid.getFSimTrack()) << std::endl;
142  return false;
143  }
144  } else {
145  std::cout << " Could not go at such depth " << EMSHOWER << " " << currentDepth_ << " "
146  << myGrid.getSegments().back().sL0Exit() << std::endl;
147  std::cout << " Track " << *(myGrid.getFSimTrack()) << std::endl;
148  return false;
149  }
150  }
151 
152  XYZPoint origin;
153  if (inCm) {
154  origin = segiterator->positionAtDepthincm(currentDepth_);
155  } else {
156  if (EMSHOWER)
157  origin = segiterator->positionAtDepthinX0(currentDepth_);
158  if (HADSHOWER)
159  origin = segiterator->positionAtDepthinL0(currentDepth_);
160  }
161  XYZVector zaxis(0, 0, 1);
162  XYZVector planeVec1 = (zaxis.Cross(particleDirection)).Unit();
163  locToGlobal_ = Transform3D(Point(0, 0, 0),
164  Point(0, 0, 1),
165  Point(1, 0, 0),
166  (Point)origin,
167  (Point)(origin + particleDirection),
168  (Point)(origin + planeVec1));
169  return true;
170 }
HcalHitMaker::Transform3D
ROOT::Math::Transform3DPJ Transform3D
Definition: HcalHitMaker.h:20
CaloHitMaker::XYZPoint
math::XYZVector XYZPoint
Definition: CaloHitMaker.h:23
MessageLogger.h
HcalHitMaker::particleDirection
XYZVector particleDirection
Definition: HcalHitMaker.h:45
HcalHitMaker::mapCalculated_
bool mapCalculated_
Definition: HcalHitMaker.h:51
gather_cfg.cout
cout
Definition: gather_cfg.py:144
HcalHitMaker::locToGlobal_
Transform3D locToGlobal_
Definition: HcalHitMaker.h:49
getRunAppsInfo.grid
grid
Definition: getRunAppsInfo.py:92
CaloHitMaker::EMSHOWER
bool EMSHOWER
Definition: CaloHitMaker.h:50
CaloHitMaker::interactionLength
double interactionLength
Definition: CaloHitMaker.h:47
HcalHitMaker.h
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
LaserClient_cfi.zaxis
zaxis
Definition: LaserClient_cfi.py:91
CaloHitMaker::MIP
bool MIP
Definition: CaloHitMaker.h:52
funct::sin
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
EcalHitMaker::ecalEntrance
const XYZPoint & ecalEntrance() const
used in FamosHcalHitMaker
Definition: EcalHitMaker.h:123
DetId
Definition: DetId.h:17
CaloGeometryHelper::getClosestCell
DetId getClosestCell(const XYZPoint &point, bool ecal, bool central) const
Definition: CaloGeometryHelper.cc:58
EcalHitMaker::getFSimTrack
const FSimTrack * getFSimTrack() const
To retrieve the track.
Definition: EcalHitMaker.h:120
funct::cos
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
Point
ROOT::Math::Transform3DPJ::Point Point
Definition: HcalHitMaker.cc:8
CaloSegment::inSegment
Definition: CaloSegment.h:131
HcalHitMaker::myGrid
EcalHitMaker & myGrid
Definition: HcalHitMaker.h:41
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
HcalHitMaker::ecalEntrance_
XYZPoint ecalEntrance_
Definition: HcalHitMaker.h:44
FSimTrack::ecalEntrance
const RawParticle & ecalEntrance() const
The particle at ECAL entrance.
Definition: FSimTrack.h:143
HcalHitMaker::currentDepth_
double currentDepth_
Definition: HcalHitMaker.h:48
ROOT::Math::Transform3DPJ::Point
PositionVector3D< Cartesian3D< double >, DefaultCoordinateSystemTag > Point
Definition: Transform3DPJ.h:65
LEDCalibrationChannels.depth
depth
Definition: LEDCalibrationChannels.py:65
RawParticle::Vect
XYZVector Vect() const
the momentum threevector
Definition: RawParticle.h:323
Point
Structure Point Contains parameters of Gaussian fits to DMRs.
Definition: DMRtrends.cc:57
PVValHelper::phi
Definition: PVValidationHelpers.h:68
CaloGeometryHelper.h
HcalDetId.h
HcalDetId
Definition: HcalDetId.h:12
createfilelist.int
int
Definition: createfilelist.py:10
HcalHitMaker
Definition: HcalHitMaker.h:16
EcalHitMaker::getSegments
const std::vector< CaloSegment > & getSegments() const
Definition: EcalHitMaker.h:95
CaloHitMaker::spotEnergy
double spotEnergy
Definition: CaloHitMaker.h:48
HcalHitMaker::setDepth
bool setDepth(double, bool inCm=false)
set the depth in X0 or Lambda0 units depending on showerType
Definition: HcalHitMaker.cc:114
CaloHitMaker::myCalorimeter
const CaloGeometryHelper * myCalorimeter
Definition: CaloHitMaker.h:44
alignCSCRings.r
r
Definition: alignCSCRings.py:93
CaloHitMaker
Definition: CaloHitMaker.h:20
HcalSubdetector
HcalSubdetector
Definition: HcalAssistant.h:31
HcalForward
Definition: HcalAssistant.h:36
DDAxes::phi
CaloHitMaker::HADSHOWER
bool HADSHOWER
Definition: CaloHitMaker.h:51
CaloHitID
Definition: CaloHitID.h:11
CaloHitMaker::hitMap_
std::map< CaloHitID, float > hitMap_
Definition: CaloHitMaker.h:61
EcalHitMaker
Definition: EcalHitMaker.h:24
HcalHitMaker::addHit
bool addHit(double r, double phi, unsigned layer=0) override
add the hit in the HCAL in local coordinates
Definition: HcalHitMaker.cc:30
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
HcalHitMaker::radiusFactor_
double radiusFactor_
Definition: HcalHitMaker.h:50
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
CaloHitMaker::moliereRadius
double moliereRadius
Definition: CaloHitMaker.h:46
HcalHitMaker::myTrack
const FSimTrack * myTrack
Definition: HcalHitMaker.h:43
CaloHitMaker::XYZVector
math::XYZVector XYZVector
Definition: CaloHitMaker.h:22
HcalHitMaker::HcalHitMaker
HcalHitMaker(EcalHitMaker &, unsigned)
Definition: HcalHitMaker.cc:10
CaloSegment::inL0Segment
Definition: CaloSegment.h:109
CaloSegment::inX0Segment
This class is used to determine if a point lies in the segment.
Definition: CaloSegment.h:87