113 #include "CLHEP/Vector/LorentzVector.h"
136 #include "CLHEP/Units/GlobalPhysicalConstants.h"
137 #include "CLHEP/Units/GlobalSystemOfUnits.h"
165 std::unique_ptr<HOCalibVariableCollection>& hostore,
174 void findHOEtaPhi(
int iphsect,
int& ietaho,
int& iphiho);
270 tok_geom_ = esConsumes<CaloGeometry, CaloGeometryRecord>();
272 tok_magField_ = esConsumes<MagneticField, IdealMagneticFieldRecord>();
274 produces<HOCalibVariableCollection>(
"HOCalibVariableCollection").setBranchAlias(
"HOCalibVariableCollection");
281 for (
int ij = 0; ij < 5; ij++) {
282 sprintf(
title,
"ho_occupency (>%i #sigma)", ij + 2);
295 int irun =
iEvent.id().run();
302 <<
" " <<
iEvent.id().event();
306 auto hostore = std::make_unique<HOCalibVariableCollection>();
313 tmpHOCalib.
nprim = -1;
318 muonOK = (cosmicmuon.
isValid() && !cosmicmuon->empty());
321 muonOK = (collisionmuon.
isValid() && !collisionmuon->empty());
323 if (
iEvent.isRealData()) {
346 int Noccu_old =
Noccu;
358 for (reco::TrackCollection::const_iterator ncosm = cosmicmuon->begin(); ncosm != cosmicmuon->end();
360 if ((*ncosm).ndof() < 15)
362 if ((*ncosm).normalizedChi2() > 30.0)
365 fillHOStore(tRef, tmpHOCalib, hostore, Noccu_old, indx, cosmicmuon, muon1,
iEvent, gHO, magField);
368 for (muon1 = collisionmuon->begin(); muon1 < collisionmuon->end(); muon1++) {
369 if ((!muon1->isGlobalMuon()) || (!muon1->isTrackerMuon()))
372 fillHOStore(ncosm, tmpHOCalib, hostore, Noccu_old, 0, cosmicmuon, muon1,
iEvent, gHO, magField);
390 for (
int ij = 0; ij < 5; ij++) {
399 std::unique_ptr<HOCalibVariableCollection>& hostore,
409 int charge = ncosm->charge();
411 double innerr = (*ncosm).innerPosition().Perp2();
412 double outerr = (*ncosm).outerPosition().Perp2();
413 int iiner = (innerr < outerr) ? 1 : 0;
424 double posx, posy, posz;
425 double momx, momy, momz;
428 posx = (*ncosm).innerPosition().X();
429 posy = (*ncosm).innerPosition().Y();
430 posz = (*ncosm).innerPosition().Z();
432 momx = (*ncosm).innerMomentum().X();
433 momy = (*ncosm).innerMomentum().Y();
434 momz = (*ncosm).innerMomentum().Z();
437 posx = (*ncosm).outerPosition().X();
438 posy = (*ncosm).outerPosition().Y();
439 posz = (*ncosm).outerPosition().Z();
441 momx = (*ncosm).outerMomentum().X();
442 momy = (*ncosm).outerMomentum().Y();
443 momz = (*ncosm).outerMomentum().Z();
448 CLHEP::Hep3Vector tmpmuon3v(posx, posy, posz);
449 CLHEP::Hep3Vector tmpmuondir(momx, momy, momz);
451 bool samedir = (tmpmuon3v.dot(tmpmuondir) > 0) ?
true :
false;
452 for (
int ij = 0; ij < 3; ij++) {
453 tmpHOCalib.
caloen[ij] = 0.0;
460 for (reco::TrackCollection::const_iterator ncosmcor = cosmicmuon->begin(); ncosmcor != cosmicmuon->end();
464 CLHEP::Hep3Vector tmpmuon3vcor;
465 CLHEP::Hep3Vector tmpmom3v;
467 tmpmuon3vcor = CLHEP::Hep3Vector(
468 (*ncosmcor).innerPosition().X(), (*ncosmcor).innerPosition().Y(), (*ncosmcor).innerPosition().Z());
469 tmpmom3v = CLHEP::Hep3Vector(
470 (*ncosmcor).innerMomentum().X(), (*ncosmcor).innerMomentum().Y(), (*ncosmcor).innerMomentum().Z());
472 tmpmuon3vcor = CLHEP::Hep3Vector(
473 (*ncosmcor).outerPosition().X(), (*ncosmcor).outerPosition().Y(), (*ncosmcor).outerPosition().Z());
474 tmpmom3v = CLHEP::Hep3Vector(
475 (*ncosmcor).outerMomentum().X(), (*ncosmcor).outerMomentum().Y(), (*ncosmcor).outerMomentum().Z());
478 if (tmpmom3v.mag() < 0.2 || (*ncosmcor).ndof() < 5)
481 double angle = tmpmuon3v.angle(tmpmuon3vcor);
482 if (
angle < 7.5 * CLHEP::deg) {
487 if (
angle < 7.5 * CLHEP::deg) {
488 tmpHOCalib.
caloen[0] += 1.;
490 if (
angle < 15.0 * CLHEP::deg) {
491 tmpHOCalib.
caloen[1] += 1.;
493 if (
angle < 35.0 * CLHEP::deg) {
494 tmpHOCalib.
caloen[2] += 1.;
504 double ith = (*calt).momentum().theta();
505 double iph = (*calt).momentum().phi();
507 CLHEP::Hep3Vector calo3v(
sin(ith) *
cos(iph),
sin(ith) *
sin(iph),
cos(ith));
509 double angle = tmpmuon3v.angle(calo3v);
511 if (
angle < 7.5 * CLHEP::deg) {
512 tmpHOCalib.
caloen[0] += calt->emEnergy() + calt->hadEnergy();
514 if (
angle < 15 * CLHEP::deg) {
515 tmpHOCalib.
caloen[1] += calt->emEnergy() + calt->hadEnergy();
517 if (
angle < 35 * CLHEP::deg) {
518 tmpHOCalib.
caloen[2] += calt->emEnergy() + calt->hadEnergy();
525 double mom =
sqrt(momx * momx + momy * momy + momz * momz);
533 tmpHOCalib.
trkdr = (*ncosm).d0();
534 tmpHOCalib.
trkdz = (*ncosm).dz();
536 tmpHOCalib.
trkvx = glbpt.
x();
537 tmpHOCalib.
trkvy = glbpt.
y();
538 tmpHOCalib.
trkvz = glbpt.
z();
543 tmpHOCalib.
isect = -2;
544 tmpHOCalib.
hodx = -100;
545 tmpHOCalib.
hody = -100;
546 tmpHOCalib.
hoang = -2.0;
548 tmpHOCalib.
ndof = (inearbymuon == 0) ? (
int)(*ncosm).ndof() : -(
int)(*ncosm).ndof();
549 tmpHOCalib.
chisq = (*ncosm).normalizedChi2();
559 tmpHOCalib.
therr = 0.;
560 tmpHOCalib.
pherr = 0.;
563 tmpHOCalib.
therr = innercov(1, 1);
564 tmpHOCalib.
pherr = innercov(2, 2);
567 tmpHOCalib.
therr = outercov(1, 1);
568 tmpHOCalib.
pherr = outercov(2, 2);
574 double phiho = trkpos.
phi();
576 phiho += CLHEP::twopi;
578 int iphisect_dt =
int(6 * (phiho + 10.0 * CLHEP::deg) /
CLHEP::pi);
579 if (iphisect_dt >= 12)
584 for (
int kl = 0; kl <= 2; kl++) {
585 int iphisecttmp = (kl < 2) ? iphisect_dt + kl : iphisect_dt - 1;
588 if (iphisecttmp >= 12)
591 double phipos = iphisecttmp *
CLHEP::pi / 6.;
592 double phirot = phipos;
603 for (
int ik = 1; ik >= 0; ik--) {
605 double radial =
rHOL1;
617 if (steppingHelixstateinfo_.
isValid()) {
624 int ixeta = ClosestCell.
ieta();
625 int ixphi = ClosestCell.
iphi();
632 CLHEP::Hep3Vector hotrkdir2(steppingHelixstateinfo_.
momentum().
x(),
638 double xx = lclvt0.x();
639 double yy = lclvt0.y();
645 iphisect = iphisecttmp;
649 if (iphisect != iphisecttmp)
660 tmpHOCalib.
momatho = hotrkdir2.mag();
661 tmpHOCalib.
hoang = CLHEP::Hep3Vector(zLocal.
x(), zLocal.
y(), zLocal.
z()).
dot(hotrkdir2.unit());
678 for (
int ij = 0; ij < 9; ij++) {
679 tmpHOCalib.
hosig[ij] = -100.0;
681 for (
int ij = 0; ij < 18; ij++) {
684 for (
int ij = 0; ij < 9; ij++) {
685 tmpHOCalib.
hbhesig[ij] = -100.0;
687 tmpHOCalib.
hocro = -100;
688 tmpHOCalib.
htime = -1000;
702 tmpHOCalib.
isect = isect;
734 phimx = 2 *
int((iphiho + 1) / 2.);
737 phimn = 3 *
int((iphiho + 1) / 3.) - 1;
747 for (
int ij = 0; ij < 9; ij++) {
748 tmpHOCalib.
hbhesig[ij] = -100.0;
754 if (!(*hbheht).empty()) {
755 if ((*hbheht).empty())
756 throw(
int)(*hbheht).size();
760 int tmpeta =
id.
ieta();
761 int tmpphi =
id.iphi();
763 int deta = tmpeta - ietaho;
764 if (tmpeta < 0 && ietaho > 0)
766 if (tmpeta > 0 && ietaho < 0)
772 int dphi = tmpphi - iphiho;
786 float signal = (*jk).energy();
788 if (signal > -100 &&
Noccu == Noccu_old) {
789 for (
int ij = 0; ij < 5; ij++) {
790 if (signal > (ij + 2) *
m_sigma) {
801 float signal = (*jk).energy();
803 if (3 * (deta + 1) + dphi + 1 < 9)
804 tmpHOCalib.
hbhesig[3 * (deta + 1) + dphi + 1] = signal;
812 if (!(*hoht).empty()) {
815 int tmpeta =
id.
ieta();
816 int tmpphi =
id.iphi();
819 if (tmpeta >= etamn && tmpeta <= etamx) {
821 ipass1 = (tmpphi >= phimn && tmpphi <= phimx) ? 1 : 0;
823 ipass1 = (tmpphi == 71 || tmpphi == 72 || tmpphi == 1) ? 1 : 0;
827 int deta = tmpeta - ietaho;
828 int dphi = tmpphi - iphiho;
830 if (tmpeta < 0 && ietaho > 0)
832 if (tmpeta > 0 && ietaho < 0)
848 float signal = (*jk).energy();
852 if (ipass1 == 0 && ipass2 == 0)
856 int tmpdph = tmpphi - phimn;
860 int ilog = 2 * (tmpeta - etamn) + tmpdph;
863 ilog = 3 * (tmpeta - etamn) + tmpdph;
865 ilog = 3 * (etamx - tmpeta) + tmpdph;
868 if (ilog > -1 && ilog < 18) {
874 if (3 * (deta + 1) + dphi + 1 < 9) {
875 tmpHOCalib.
hosig[3 * (deta + 1) + dphi + 1] = signal;
879 if (deta == 0 && dphi == 0) {
880 tmpHOCalib.
htime = (*jk).time();
881 tmpHOCalib.
hoflag = (*jk).flags();
887 tmpHOCalib.
hoflag = hitSeverity;
888 int crphi = tmpphi + 6;
895 int etacr = idcr.
ieta();
896 int phicr = idcr.
iphi();
897 if (tmpeta == etacr && crphi == phicr) {
907 if (
Noccu == Noccu_old)
909 hostore->push_back(tmpHOCalib);
917 const double etalow[16] = {0.025,
933 const double etahgh[16] = {35.145,
950 const double philow[6] = {-76.27, -35.11, 0.35, 35.81, 71.77, 108.93};
951 const double phihgh[6] = {-35.81, -0.35, 35.11, 71.07, 108.23, 140.49};
953 const double philow00[6] = {-60.27, -32.91, 0.35, 33.61, 67.37, 102.23};
954 const double phihgh00[6] = {-33.61, -0.35, 32.91, 66.67, 101.53, 129.49};
956 const double philow01[6] = {-64.67, -34.91, 0.35, 35.61, 71.37, 108.33};
957 const double phihgh01[6] = {-35.61, -0.35, 34.91, 70.67, 107.63, 138.19};
962 for (
int ij = 0; ij <
netabin; ij++) {
963 if (tmpdy > etalow[ij] && tmpdy < etahgh[ij]) {
965 float tmp1 = fabs(tmpdy - etalow[ij]);
966 float tmp2 = fabs(tmpdy - etahgh[ij]);
974 if (ij >= 4 && ij < 10)
986 for (
int ij = 0; ij < 6; ij++) {
987 if (
xhor1 > philow[ij] &&
xhor1 < phihgh[ij]) {
989 float tmp1 = fabs(
xhor1 - philow[ij]);
990 float tmp2 = fabs(
xhor1 - phihgh[ij]);
996 for (
int ij = 0; ij < 6; ij++) {
997 if (
xhor1 > philow01[ij] &&
xhor1 < phihgh01[ij]) {
999 float tmp1 = fabs(
xhor1 - philow01[ij]);
1000 float tmp2 = fabs(
xhor1 - phihgh01[ij]);
1006 for (
int ij = 0; ij < 6; ij++) {
1007 if (
xhor0 > philow00[ij] &&
xhor0 < phihgh00[ij]) {
1009 float tmp1 = fabs(
xhor0 - philow00[ij]);
1010 float tmp2 = fabs(
xhor0 - phihgh00[ij]);
1012 if (tmpphi != tmpphi0)
1019 for (
int ij = 0; ij < 4; ij++) {
1020 if (tmpdy > etalow[ij] && tmpdy < etahgh[ij]) {
1021 float tmp1 = fabs(tmpdy - etalow[ij]);
1022 float tmp2 = fabs(tmpdy - etahgh[ij]);
1026 if (ij + 1 != ietaho)
1034 iphiho = 6 * iphisect - 2 + tmpphi;