115 #include "CLHEP/Vector/LorentzVector.h"
138 #include "CLHEP/Units/GlobalPhysicalConstants.h"
139 #include "CLHEP/Units/GlobalSystemOfUnits.h"
170 std::unique_ptr<HOCalibVariableCollection>& hostore,
177 void findHOEtaPhi(
int iphsect,
int& ietaho,
int& iphiho);
267 produces<HOCalibVariableCollection>(
"HOCalibVariableCollection").setBranchAlias(
"HOCalibVariableCollection");
274 for (
int ij = 0; ij < 5; ij++) {
275 sprintf(
title,
"ho_occupency (>%i #sigma)", ij + 2);
293 int irun =
iEvent.id().run();
300 <<
" " <<
iEvent.id().event();
302 auto hostore = std::make_unique<HOCalibVariableCollection>();
309 tmpHOCalib.
nprim = -1;
314 muonOK = (cosmicmuon.
isValid() && !cosmicmuon->empty());
317 muonOK = (collisionmuon.
isValid() && !collisionmuon->empty());
319 if (
iEvent.isRealData()) {
342 int Noccu_old =
Noccu;
346 for (reco::TrackCollection::const_iterator ncosm = cosmicmuon->begin(); ncosm != cosmicmuon->end();
348 if ((*ncosm).ndof() < 15)
350 if ((*ncosm).normalizedChi2() > 30.0)
353 fillHOStore(tRef, tmpHOCalib, hostore, Noccu_old, indx, cosmicmuon, muon1,
iEvent, iSetup);
356 for (muon1 = collisionmuon->begin(); muon1 < collisionmuon->end(); muon1++) {
357 if ((!muon1->isGlobalMuon()) || (!muon1->isTrackerMuon()))
360 fillHOStore(ncosm, tmpHOCalib, hostore, Noccu_old, 0, cosmicmuon, muon1,
iEvent, iSetup);
378 for (
int ij = 0; ij < 5; ij++) {
400 std::unique_ptr<HOCalibVariableCollection>& hostore,
417 int charge = ncosm->charge();
419 double innerr = (*ncosm).innerPosition().Perp2();
420 double outerr = (*ncosm).outerPosition().Perp2();
421 int iiner = (innerr < outerr) ? 1 : 0;
432 double posx, posy, posz;
433 double momx, momy, momz;
436 posx = (*ncosm).innerPosition().X();
437 posy = (*ncosm).innerPosition().Y();
438 posz = (*ncosm).innerPosition().Z();
440 momx = (*ncosm).innerMomentum().X();
441 momy = (*ncosm).innerMomentum().Y();
442 momz = (*ncosm).innerMomentum().Z();
445 posx = (*ncosm).outerPosition().X();
446 posy = (*ncosm).outerPosition().Y();
447 posz = (*ncosm).outerPosition().Z();
449 momx = (*ncosm).outerMomentum().X();
450 momy = (*ncosm).outerMomentum().Y();
451 momz = (*ncosm).outerMomentum().Z();
456 CLHEP::Hep3Vector tmpmuon3v(posx, posy, posz);
457 CLHEP::Hep3Vector tmpmuondir(momx, momy, momz);
459 bool samedir = (tmpmuon3v.dot(tmpmuondir) > 0) ?
true :
false;
460 for (
int ij = 0; ij < 3; ij++) {
461 tmpHOCalib.
caloen[ij] = 0.0;
468 for (reco::TrackCollection::const_iterator ncosmcor = cosmicmuon->begin(); ncosmcor != cosmicmuon->end();
472 CLHEP::Hep3Vector tmpmuon3vcor;
473 CLHEP::Hep3Vector tmpmom3v;
475 tmpmuon3vcor = CLHEP::Hep3Vector(
476 (*ncosmcor).innerPosition().X(), (*ncosmcor).innerPosition().Y(), (*ncosmcor).innerPosition().Z());
477 tmpmom3v = CLHEP::Hep3Vector(
478 (*ncosmcor).innerMomentum().X(), (*ncosmcor).innerMomentum().Y(), (*ncosmcor).innerMomentum().Z());
480 tmpmuon3vcor = CLHEP::Hep3Vector(
481 (*ncosmcor).outerPosition().X(), (*ncosmcor).outerPosition().Y(), (*ncosmcor).outerPosition().Z());
482 tmpmom3v = CLHEP::Hep3Vector(
483 (*ncosmcor).outerMomentum().X(), (*ncosmcor).outerMomentum().Y(), (*ncosmcor).outerMomentum().Z());
486 if (tmpmom3v.mag() < 0.2 || (*ncosmcor).ndof() < 5)
489 double angle = tmpmuon3v.angle(tmpmuon3vcor);
490 if (
angle < 7.5 * CLHEP::deg) {
495 if (
angle < 7.5 * CLHEP::deg) {
496 tmpHOCalib.
caloen[0] += 1.;
498 if (
angle < 15.0 * CLHEP::deg) {
499 tmpHOCalib.
caloen[1] += 1.;
501 if (
angle < 35.0 * CLHEP::deg) {
502 tmpHOCalib.
caloen[2] += 1.;
512 double ith = (*calt).momentum().theta();
513 double iph = (*calt).momentum().phi();
515 CLHEP::Hep3Vector calo3v(
sin(ith) *
cos(iph),
sin(ith) *
sin(iph),
cos(ith));
517 double angle = tmpmuon3v.angle(calo3v);
519 if (
angle < 7.5 * CLHEP::deg) {
520 tmpHOCalib.
caloen[0] += calt->emEnergy() + calt->hadEnergy();
522 if (
angle < 15 * CLHEP::deg) {
523 tmpHOCalib.
caloen[1] += calt->emEnergy() + calt->hadEnergy();
525 if (
angle < 35 * CLHEP::deg) {
526 tmpHOCalib.
caloen[2] += calt->emEnergy() + calt->hadEnergy();
533 double mom =
sqrt(momx * momx + momy * momy + momz * momz);
541 tmpHOCalib.
trkdr = (*ncosm).d0();
542 tmpHOCalib.
trkdz = (*ncosm).dz();
544 tmpHOCalib.
trkvx = glbpt.
x();
545 tmpHOCalib.
trkvy = glbpt.
y();
546 tmpHOCalib.
trkvz = glbpt.
z();
551 tmpHOCalib.
isect = -2;
552 tmpHOCalib.
hodx = -100;
553 tmpHOCalib.
hody = -100;
554 tmpHOCalib.
hoang = -2.0;
556 tmpHOCalib.
ndof = (inearbymuon == 0) ? (
int)(*ncosm).ndof() : -(
int)(*ncosm).ndof();
557 tmpHOCalib.
chisq = (*ncosm).normalizedChi2();
567 tmpHOCalib.
therr = 0.;
568 tmpHOCalib.
pherr = 0.;
571 tmpHOCalib.
therr = innercov(1, 1);
572 tmpHOCalib.
pherr = innercov(2, 2);
575 tmpHOCalib.
therr = outercov(1, 1);
576 tmpHOCalib.
pherr = outercov(2, 2);
584 double phiho = trkpos.
phi();
586 phiho += CLHEP::twopi;
588 int iphisect_dt =
int(6 * (phiho + 10.0 * CLHEP::deg) /
CLHEP::pi);
589 if (iphisect_dt >= 12)
594 for (
int kl = 0; kl <= 2; kl++) {
595 int iphisecttmp = (kl < 2) ? iphisect_dt + kl : iphisect_dt - 1;
598 if (iphisecttmp >= 12)
601 double phipos = iphisecttmp *
CLHEP::pi / 6.;
602 double phirot = phipos;
613 for (
int ik = 1; ik >= 0; ik--) {
615 double radial =
rHOL1;
627 if (steppingHelixstateinfo_.
isValid()) {
634 int ixeta = ClosestCell.
ieta();
635 int ixphi = ClosestCell.
iphi();
642 CLHEP::Hep3Vector hotrkdir2(steppingHelixstateinfo_.
momentum().
x(),
648 double xx = lclvt0.x();
649 double yy = lclvt0.y();
655 iphisect = iphisecttmp;
659 if (iphisect != iphisecttmp)
670 tmpHOCalib.
momatho = hotrkdir2.mag();
671 tmpHOCalib.
hoang = CLHEP::Hep3Vector(zLocal.
x(), zLocal.
y(), zLocal.
z()).
dot(hotrkdir2.unit());
688 for (
int ij = 0; ij < 9; ij++) {
689 tmpHOCalib.
hosig[ij] = -100.0;
691 for (
int ij = 0; ij < 18; ij++) {
694 for (
int ij = 0; ij < 9; ij++) {
695 tmpHOCalib.
hbhesig[ij] = -100.0;
697 tmpHOCalib.
hocro = -100;
698 tmpHOCalib.
htime = -1000;
712 tmpHOCalib.
isect = isect;
744 phimx = 2 *
int((iphiho + 1) / 2.);
747 phimn = 3 *
int((iphiho + 1) / 3.) - 1;
757 for (
int ij = 0; ij < 9; ij++) {
758 tmpHOCalib.
hbhesig[ij] = -100.0;
764 if (!(*hbheht).empty()) {
765 if ((*hbheht).empty())
766 throw(
int)(*hbheht).size();
770 int tmpeta =
id.
ieta();
771 int tmpphi =
id.iphi();
773 int deta = tmpeta - ietaho;
774 if (tmpeta < 0 && ietaho > 0)
776 if (tmpeta > 0 && ietaho < 0)
782 int dphi = tmpphi - iphiho;
796 float signal = (*jk).energy();
798 if (signal > -100 &&
Noccu == Noccu_old) {
799 for (
int ij = 0; ij < 5; ij++) {
800 if (signal > (ij + 2) *
m_sigma) {
811 float signal = (*jk).energy();
813 if (3 * (deta + 1) + dphi + 1 < 9)
814 tmpHOCalib.
hbhesig[3 * (deta + 1) + dphi + 1] = signal;
822 if (!(*hoht).empty()) {
825 int tmpeta =
id.
ieta();
826 int tmpphi =
id.iphi();
829 if (tmpeta >= etamn && tmpeta <= etamx) {
831 ipass1 = (tmpphi >= phimn && tmpphi <= phimx) ? 1 : 0;
833 ipass1 = (tmpphi == 71 || tmpphi == 72 || tmpphi == 1) ? 1 : 0;
837 int deta = tmpeta - ietaho;
838 int dphi = tmpphi - iphiho;
840 if (tmpeta < 0 && ietaho > 0)
842 if (tmpeta > 0 && ietaho < 0)
858 float signal = (*jk).energy();
862 if (ipass1 == 0 && ipass2 == 0)
866 int tmpdph = tmpphi - phimn;
870 int ilog = 2 * (tmpeta - etamn) + tmpdph;
873 ilog = 3 * (tmpeta - etamn) + tmpdph;
875 ilog = 3 * (etamx - tmpeta) + tmpdph;
878 if (ilog > -1 && ilog < 18) {
884 if (3 * (deta + 1) + dphi + 1 < 9) {
885 tmpHOCalib.
hosig[3 * (deta + 1) + dphi + 1] = signal;
889 if (deta == 0 && dphi == 0) {
890 tmpHOCalib.
htime = (*jk).time();
891 tmpHOCalib.
hoflag = (*jk).flags();
896 int hitSeverity = hcalSevLvlComputer->
getSeverityLevel(
id, (*jk).flags(), theStatusValue);
897 tmpHOCalib.
hoflag = hitSeverity;
898 int crphi = tmpphi + 6;
905 int etacr = idcr.
ieta();
906 int phicr = idcr.
iphi();
907 if (tmpeta == etacr && crphi == phicr) {
917 if (
Noccu == Noccu_old)
919 hostore->push_back(tmpHOCalib);
927 const double etalow[16] = {0.025,
943 const double etahgh[16] = {35.145,
960 const double philow[6] = {-76.27, -35.11, 0.35, 35.81, 71.77, 108.93};
961 const double phihgh[6] = {-35.81, -0.35, 35.11, 71.07, 108.23, 140.49};
963 const double philow00[6] = {-60.27, -32.91, 0.35, 33.61, 67.37, 102.23};
964 const double phihgh00[6] = {-33.61, -0.35, 32.91, 66.67, 101.53, 129.49};
966 const double philow01[6] = {-64.67, -34.91, 0.35, 35.61, 71.37, 108.33};
967 const double phihgh01[6] = {-35.61, -0.35, 34.91, 70.67, 107.63, 138.19};
972 for (
int ij = 0; ij <
netabin; ij++) {
973 if (tmpdy > etalow[ij] && tmpdy < etahgh[ij]) {
975 float tmp1 = fabs(tmpdy - etalow[ij]);
976 float tmp2 = fabs(tmpdy - etahgh[ij]);
984 if (ij >= 4 && ij < 10)
996 for (
int ij = 0; ij < 6; ij++) {
997 if (
xhor1 > philow[ij] &&
xhor1 < phihgh[ij]) {
999 float tmp1 = fabs(
xhor1 - philow[ij]);
1000 float tmp2 = fabs(
xhor1 - phihgh[ij]);
1006 for (
int ij = 0; ij < 6; ij++) {
1007 if (
xhor1 > philow01[ij] &&
xhor1 < phihgh01[ij]) {
1009 float tmp1 = fabs(
xhor1 - philow01[ij]);
1010 float tmp2 = fabs(
xhor1 - phihgh01[ij]);
1016 for (
int ij = 0; ij < 6; ij++) {
1017 if (
xhor0 > philow00[ij] &&
xhor0 < phihgh00[ij]) {
1019 float tmp1 = fabs(
xhor0 - philow00[ij]);
1020 float tmp2 = fabs(
xhor0 - phihgh00[ij]);
1022 if (tmpphi != tmpphi0)
1029 for (
int ij = 0; ij < 4; ij++) {
1030 if (tmpdy > etalow[ij] && tmpdy < etahgh[ij]) {
1031 float tmp1 = fabs(tmpdy - etalow[ij]);
1032 float tmp2 = fabs(tmpdy - etahgh[ij]);
1036 if (ij + 1 != ietaho)
1044 iphiho = 6 * iphisect - 2 + tmpphi;