9 if (passedGeometry ==
nullptr)
10 throw(std::runtime_error(
"\n\n TBPositionCalc: wrong initialization.\n\n"));
11 theGeometry_ = passedGeometry;
14 param_LogWeighted_ = providedParameters.find(
"LogWeighted")->second;
15 param_X0_ = providedParameters.find(
"X0")->second;
16 param_T0_ = providedParameters.find(
"T0")->second;
17 param_W0_ = providedParameters.find(
"W0")->second;
30 std::vector<EBDetId> passedDetIds = upassedDetIds;
32 if (passedRecHitsMap ==
nullptr)
33 throw(std::runtime_error(
"\n\n TBPositionCalc::CalculateTBPos called uninitialized.\n\n"));
36 std::vector<EBDetId> validDetIds;
37 std::vector<EBDetId>::const_iterator iter;
38 for (iter = passedDetIds.begin(); iter != passedDetIds.end(); iter++) {
39 if (((*iter) !=
DetId(0)) && (passedRecHitsMap->
find(*iter) != passedRecHitsMap->
end()))
40 validDetIds.push_back(*iter);
43 passedDetIds = validDetIds;
46 CLHEP::Hep3Vector cmsPos = CalculateCMSPos(passedDetIds, myCrystal, passedRecHitsMap);
49 CLHEP::HepRotation *CMStoTB =
new CLHEP::HepRotation();
50 computeRotation(myCrystal, (*CMStoTB));
53 CLHEP::Hep3Vector tbPos = (*CMStoTB) * cmsPos;
66 std::vector<EBDetId>::const_iterator myIt;
67 for (myIt = passedDetIds.begin(); myIt != passedDetIds.end(); myIt++) {
70 thisEne = itt->energy();
77 edm::LogError(
"NegativeClusterEnergy") <<
"cluster with negative energy: " << eTot <<
", setting depth to 0.";
79 depth = param_X0_ * (param_T0_ +
log(eTot));
84 auto center_cell = theGeometry_->getGeometry(maxId_);
85 GlobalPoint center_pos = center_cell->getPosition(depth);
89 double total_weight = 0;
90 double cluster_theta = 0;
91 double cluster_phi = 0;
92 std::vector<EBDetId>::const_iterator myIt2;
93 for (myIt2 = passedDetIds.begin(); myIt2 != passedDetIds.end(); myIt2++) {
97 double ener = itj->energy();
99 if (param_LogWeighted_) {
103 weight =
std::max(0., param_W0_ +
log(fabs(ener) / eTot));
106 weight = ener / eTot;
111 auto jth_cell = theGeometry_->getGeometry(myId);
112 GlobalPoint jth_pos = jth_cell->getPosition(depth);
113 cluster_theta += weight * jth_pos.
theta();
114 cluster_phi += weight * jth_pos.
phi();
118 cluster_theta /= total_weight;
119 cluster_phi /= total_weight;
120 if (cluster_phi >
M_PI) {
121 cluster_phi -= 2. *
M_PI;
123 if (cluster_phi < -
M_PI) {
124 cluster_phi += 2. *
M_PI;
129 sqrt(center_pos.
x() * center_pos.
x() + center_pos.
y() * center_pos.
y() + center_pos.
z() * center_pos.
z());
130 double xpos = radius *
cos(cluster_phi) *
sin(cluster_theta);
131 double ypos = radius *
sin(cluster_phi) *
sin(cluster_theta);
132 double zpos = radius *
cos(cluster_theta);
134 return CLHEP::Hep3Vector(xpos, ypos, zpos);
143 double myTheta = 999.;
144 theTestMap->findCrystalAngles(MyCrystal, myEta, myPhi);
145 myTheta = 2.0 * atan(
exp(-myEta));
148 CLHEP::HepRotation *fromCMStoTB =
new CLHEP::HepRotation();
149 double angle1 = 90. * deg - myPhi;
150 CLHEP::HepRotationZ *
r1 =
new CLHEP::HepRotationZ(angle1);
151 double angle2 = myTheta;
152 CLHEP::HepRotationX *
r2 =
new CLHEP::HepRotationX(angle2);
153 double angle3 = 90. * deg;
154 CLHEP::HepRotationZ *r3 =
new CLHEP::HepRotationZ(angle3);
155 (*fromCMStoTB) *= (*r3);
156 (*fromCMStoTB) *= (*r2);
157 (*fromCMStoTB) *= (*r1);
159 CMStoTB = (*fromCMStoTB);
void computeRotation(int myCrystal, CLHEP::HepRotation &CMStoTB)
static std::vector< std::string > checklist log
Sin< T >::type sin(const T &t)
CLHEP::Hep3Vector CalculateTBPos(const std::vector< EBDetId > &passedDetIds, int myCrystal, EcalRecHitCollection const *passedRecHitsMap)
Geom::Phi< T > phi() const
std::vector< EcalRecHit >::const_iterator const_iterator
Exp< T >::type exp(const T &t)
Log< level::Error, false > LogError
Geom::Theta< T > theta() const
Cos< T >::type cos(const T &t)
const_iterator end() const
CLHEP::Hep3Vector CalculateCMSPos(const std::vector< EBDetId > &passedDetIds, int myCrystal, EcalRecHitCollection const *passedRecHitsMap)
iterator find(key_type k)
static const int SMCRYSTALMODE