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();
302 auto hostore = std::make_unique<HOCalibVariableCollection>();
309 tmpHOCalib.
nprim = -1;
314 muonOK = (cosmicmuon.isValid() && !cosmicmuon->empty());
317 muonOK = (collisionmuon.
isValid() && !collisionmuon->empty());
322 if (primaryVertices.
isValid()) {
323 tmpHOCalib.
nprim = primaryVertices->size();
332 if (lumiScale->empty()) {
335 tmpHOCalib.
inslumi = lumiScale->begin()->pileup();
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);
365 iEvent.
put(
std::move(hostore),
"HOCalibVariableCollection");
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;
622 auto aPlane2 =
new Plane(pos, rot);
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();
652 if ((
std::abs(yy) < 130 && xx > -64.7 && xx < 138.2)
653 || (
std::abs(yy) > 130 &&
std::abs(yy) < 700 && xx > -76.3 && xx < 140.5)) {
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)
986 if (ij >= 10 && ij < netabin)
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;
constexpr float energy() const
T getParameter(std::string const &) const
const CaloSubdetectorGeometry * getSubdetectorGeometry(const DetId &id) const
access the subdetector geometry for the given subdetector directly
EventNumber_t event() const
Basic3DVector< float > DirectionType
T getUntrackedParameter(std::string const &, T const &) const
edm::EDGetTokenT< CaloTowerCollection > tok_tower_
FreeTrajectoryState getFreeTrajectoryState(const reco::Track &tk, const MagneticField *field, int itag, bool dir)
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
~AlCaHOCalibProducer() override
float sumPt
sum-pt of tracks
double outerPy() const
y coordinate of momentum vector at the outermost hit position
const HcalChannelQuality * theHcalChStatus
void fillHOStore(const reco::TrackRef &ncosm, HOCalibVariables &tmpHOCalib, std::unique_ptr< HOCalibVariableCollection > &hostore, int Noccu_old, int indx, edm::Handle< reco::TrackCollection > cosmicmuon, edm::View< reco::Muon >::const_iterator muon1, const edm::Event &iEvent, const edm::EventSetup &iSetup)
const TrackExtraRef & extra() const
reference to "extra" object
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Sin< T >::type sin(const T &t)
Geom::Theta< T > theta() const
ReturnType plane(const PositionType &pos, const RotationType &rot) const
std::vector< CaloTower >::const_iterator const_iterator
void produce(edm::Event &, const edm::EventSetup &) override
std::map< std::string, bool > fired
T * make(const Args &...args) const
make new ROOT object
edm::EDGetTokenT< reco::TrackCollection > tok_muonsCosmic_
const Item * getValues(DetId fId, bool throwOnFail=true) const
Geom::Phi< T > phi() const
GlobalVector momentum() const
void findHOEtaPhi(int iphsect, int &ietaho, int &iphiho)
double outerZ() const
z coordinate of the outermost hit position
const math::XYZPoint & innerPosition() const
position of the innermost hit
#define DEFINE_FWK_MODULE(type)
void applyRadX0Correction(bool applyRadX0Correction)
GlobalPoint position() const
Basic3DVector< float > RotationType
Vector3DBase< typename PreciseFloatType< T, U >::Type, FrameTag > cross(const Vector3DBase< U, FrameTag > &v) const
Cos< T >::type cos(const T &t)
int ieta() const
get the cell ieta
math::Error< 5 >::type CovarianceMatrix
Abs< T >::type abs(const T &t)
void propagate(const SteppingHelixStateInfo &ftsStart, const Surface &sDest, SteppingHelixStateInfo &out) const
Propagate to Plane given a starting point.
Basic3DVector< float > PositionType
double outerX() const
x coordinate of the outermost hit position
double outerPz() const
z coordinate of momentum vector at the outermost hit position
const_iterator end() const
virtual DetId getClosestCell(const GlobalPoint &r) const
edm::EDGetTokenT< LumiScalersCollection > tok_lumi_
int iphi() const
get the cell iphi
edm::EDGetTokenT< reco::VertexCollection > tok_vertex_
edm::EDGetTokenT< edm::View< reco::Muon > > tok_muons_
edm::Ref< TrackCollection > TrackRef
persistent reference to a Track
int getSeverityLevel(const DetId &myid, const uint32_t &myflag, const uint32_t &mystatus) const
edm::EDGetTokenT< HORecHitCollection > tok_ho_
void beginLuminosityBlock(const edm::LuminosityBlock &, const edm::EventSetup &) override
AlCaHOCalibProducer(const edm::ParameterSet &)
T dot(const Basic3DVector &v) const
Scalar product, or "dot" product, with a vector of same type.
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
const math::XYZVector & innerMomentum() const
momentum vector at the innermost hit position
double outerY() const
y coordinate of the outermost hit position
int charge() const
track electric charge
uint32_t getValue() const
T const * product() const
edm::ESHandle< HcalSeverityLevelComputer > hcalSevLvlComputerHndl
void setMaterialMode(bool noMaterial)
Switch for material effects mode: no material effects if true.
HcalDetId id() const
get the id
double outerPx() const
x coordinate of momentum vector at the outermost hit position
edm::EDGetTokenT< HBHERecHitCollection > tok_hbhe_
const_iterator begin() const
math::Error< dimension >::type CovarianceMatrix
5 parameter covariance matrix
T angle(T x1, T y1, T z1, T x2, T y2, T z2)