129 #include "CLHEP/Vector/LorentzVector.h" 130 #include "CLHEP/Units/GlobalPhysicalConstants.h" 131 #include "CLHEP/Units/GlobalSystemOfUnits.h" 161 std::unique_ptr<HOCalibVariableCollection>& hostore,
170 void findHOEtaPhi(
int iphsect,
int& ietaho,
int& iphiho);
268 tok_geom_ = esConsumes<CaloGeometry, CaloGeometryRecord>();
270 tok_magField_ = esConsumes<MagneticField, IdealMagneticFieldRecord>();
272 produces<HOCalibVariableCollection>(
"HOCalibVariableCollection").setBranchAlias(
"HOCalibVariableCollection");
279 for (
int ij = 0; ij < 5; ij++) {
280 sprintf(
title,
"ho_occupency (>%i #sigma)", ij + 2);
294 desc.addUntracked<
bool>(
"hotime",
false);
295 desc.addUntracked<
bool>(
"hbinfo",
false);
296 desc.addUntracked<
double>(
"sigma", 1.0);
297 desc.addUntracked<
bool>(
"plotOccupancy",
false);
298 desc.addUntracked<
bool>(
"CosmicData",
false);
302 desc.addUntracked<
double>(
"m_scale", 4.0);
303 desc.addUntracked<
bool>(
"debug",
false);
308 descriptions.
add(
"alcaHOCalibProducer",
desc);
313 int irun =
iEvent.id().run();
320 <<
" " <<
iEvent.id().event();
324 auto hostore = std::make_unique<HOCalibVariableCollection>();
331 tmpHOCalib.
nprim = -1;
336 muonOK = (cosmicmuon.isValid() && !cosmicmuon->empty());
339 muonOK = (collisionmuon.
isValid() && !collisionmuon->empty());
341 if (
iEvent.isRealData()) {
353 if (metaData.isValid()) {
354 tmpHOCalib.
pileup = metaData->avgPileUp();
360 edm::LogWarning(
"HOCalib") <<
"Neither LumiScalers nor OnlineMetadata collections found in the event";
366 int Noccu_old =
Noccu;
378 for (reco::TrackCollection::const_iterator ncosm = cosmicmuon->begin(); ncosm != cosmicmuon->end();
380 if ((*ncosm).ndof() < 15)
382 if ((*ncosm).normalizedChi2() > 30.0)
385 fillHOStore(tRef, tmpHOCalib, hostore, Noccu_old, indx, cosmicmuon, muon1,
iEvent, gHO, magField);
388 for (muon1 = collisionmuon->begin(); muon1 < collisionmuon->end(); muon1++) {
389 if ((!muon1->isGlobalMuon()) || (!muon1->isTrackerMuon()))
392 fillHOStore(ncosm, tmpHOCalib, hostore, Noccu_old, 0, cosmicmuon, muon1,
iEvent, gHO, magField);
410 for (
int ij = 0; ij < 5; ij++) {
419 std::unique_ptr<HOCalibVariableCollection>& hostore,
429 int charge = ncosm->charge();
431 double innerr = (*ncosm).innerPosition().Perp2();
432 double outerr = (*ncosm).outerPosition().Perp2();
433 int iiner = (innerr < outerr) ? 1 : 0;
444 double posx, posy, posz;
445 double momx, momy, momz;
448 posx = (*ncosm).innerPosition().X();
449 posy = (*ncosm).innerPosition().Y();
450 posz = (*ncosm).innerPosition().Z();
452 momx = (*ncosm).innerMomentum().X();
453 momy = (*ncosm).innerMomentum().Y();
454 momz = (*ncosm).innerMomentum().Z();
457 posx = (*ncosm).outerPosition().X();
458 posy = (*ncosm).outerPosition().Y();
459 posz = (*ncosm).outerPosition().Z();
461 momx = (*ncosm).outerMomentum().X();
462 momy = (*ncosm).outerMomentum().Y();
463 momz = (*ncosm).outerMomentum().Z();
468 CLHEP::Hep3Vector tmpmuon3v(posx, posy, posz);
469 CLHEP::Hep3Vector tmpmuondir(momx, momy, momz);
471 bool samedir = (tmpmuon3v.dot(tmpmuondir) > 0) ?
true :
false;
472 for (
int ij = 0; ij < 3; ij++) {
473 tmpHOCalib.
caloen[ij] = 0.0;
480 for (reco::TrackCollection::const_iterator ncosmcor = cosmicmuon->begin(); ncosmcor != cosmicmuon->end();
484 CLHEP::Hep3Vector tmpmuon3vcor;
485 CLHEP::Hep3Vector tmpmom3v;
487 tmpmuon3vcor = CLHEP::Hep3Vector(
488 (*ncosmcor).innerPosition().X(), (*ncosmcor).innerPosition().Y(), (*ncosmcor).innerPosition().Z());
489 tmpmom3v = CLHEP::Hep3Vector(
490 (*ncosmcor).innerMomentum().X(), (*ncosmcor).innerMomentum().Y(), (*ncosmcor).innerMomentum().Z());
492 tmpmuon3vcor = CLHEP::Hep3Vector(
493 (*ncosmcor).outerPosition().X(), (*ncosmcor).outerPosition().Y(), (*ncosmcor).outerPosition().Z());
494 tmpmom3v = CLHEP::Hep3Vector(
495 (*ncosmcor).outerMomentum().X(), (*ncosmcor).outerMomentum().Y(), (*ncosmcor).outerMomentum().Z());
498 if (tmpmom3v.mag() < 0.2 || (*ncosmcor).ndof() < 5)
501 double angle = tmpmuon3v.angle(tmpmuon3vcor);
502 if (
angle < 7.5 * CLHEP::deg) {
507 if (
angle < 7.5 * CLHEP::deg) {
508 tmpHOCalib.
caloen[0] += 1.;
510 if (
angle < 15.0 * CLHEP::deg) {
511 tmpHOCalib.
caloen[1] += 1.;
513 if (
angle < 35.0 * CLHEP::deg) {
514 tmpHOCalib.
caloen[2] += 1.;
523 double ith = (*calt).momentum().theta();
524 double iph = (*calt).momentum().phi();
526 CLHEP::Hep3Vector calo3v(
sin(ith) *
cos(iph),
sin(ith) *
sin(iph),
cos(ith));
528 double angle = tmpmuon3v.angle(calo3v);
530 if (
angle < 7.5 * CLHEP::deg) {
531 tmpHOCalib.
caloen[0] += calt->emEnergy() + calt->hadEnergy();
533 if (
angle < 15 * CLHEP::deg) {
534 tmpHOCalib.
caloen[1] += calt->emEnergy() + calt->hadEnergy();
536 if (
angle < 35 * CLHEP::deg) {
537 tmpHOCalib.
caloen[2] += calt->emEnergy() + calt->hadEnergy();
544 double mom =
sqrt(momx * momx + momy * momy + momz * momz);
552 tmpHOCalib.
trkdr = (*ncosm).d0();
553 tmpHOCalib.
trkdz = (*ncosm).dz();
555 tmpHOCalib.
trkvx = glbpt.
x();
556 tmpHOCalib.
trkvy = glbpt.
y();
557 tmpHOCalib.
trkvz = glbpt.
z();
562 tmpHOCalib.
isect = -2;
563 tmpHOCalib.
hodx = -100;
564 tmpHOCalib.
hody = -100;
565 tmpHOCalib.
hoang = -2.0;
567 tmpHOCalib.
ndof = (inearbymuon == 0) ? (
int)(*ncosm).ndof() : -(
int)(*ncosm).ndof();
568 tmpHOCalib.
chisq = (*ncosm).normalizedChi2();
578 tmpHOCalib.
therr = 0.;
579 tmpHOCalib.
pherr = 0.;
582 tmpHOCalib.
therr = innercov(1, 1);
583 tmpHOCalib.
pherr = innercov(2, 2);
586 tmpHOCalib.
therr = outercov(1, 1);
587 tmpHOCalib.
pherr = outercov(2, 2);
593 double phiho = trkpos.
phi();
595 phiho += CLHEP::twopi;
597 int iphisect_dt =
int(6 * (phiho + 10.0 * CLHEP::deg) /
CLHEP::pi);
598 if (iphisect_dt >= 12)
603 for (
int kl = 0; kl <= 2; kl++) {
604 int iphisecttmp = (kl < 2) ? iphisect_dt + kl : iphisect_dt - 1;
607 if (iphisecttmp >= 12)
610 double phipos = iphisecttmp *
CLHEP::pi / 6.;
611 double phirot = phipos;
622 for (
int ik = 1; ik >= 0; ik--) {
624 double radial =
rHOL1;
636 if (steppingHelixstateinfo_.
isValid()) {
643 int ixeta = ClosestCell.
ieta();
644 int ixphi = ClosestCell.
iphi();
651 CLHEP::Hep3Vector hotrkdir2(steppingHelixstateinfo_.
momentum().
x(),
657 double xx = lclvt0.x();
658 double yy = lclvt0.y();
664 iphisect = iphisecttmp;
668 if (iphisect != iphisecttmp)
679 tmpHOCalib.
momatho = hotrkdir2.mag();
680 tmpHOCalib.
hoang = CLHEP::Hep3Vector(zLocal.
x(), zLocal.
y(), zLocal.
z()).
dot(hotrkdir2.unit());
697 for (
int ij = 0; ij < 9; ij++) {
698 tmpHOCalib.
hosig[ij] = -100.0;
700 for (
int ij = 0; ij < 18; ij++) {
703 for (
int ij = 0; ij < 9; ij++) {
704 tmpHOCalib.
hbhesig[ij] = -100.0;
706 tmpHOCalib.
hocro = -100;
707 tmpHOCalib.
htime = -1000;
721 tmpHOCalib.
isect = isect;
753 phimx = 2 *
int((iphiho + 1) / 2.);
756 phimn = 3 *
int((iphiho + 1) / 3.) - 1;
766 for (
int ij = 0; ij < 9; ij++) {
767 tmpHOCalib.
hbhesig[ij] = -100.0;
771 if (!(*hbheht).empty()) {
772 if ((*hbheht).empty())
773 throw (
int)(*hbheht).size();
777 int tmpeta =
id.
ieta();
778 int tmpphi =
id.iphi();
780 int deta = tmpeta - ietaho;
781 if (tmpeta < 0 && ietaho > 0)
783 if (tmpeta > 0 && ietaho < 0)
789 int dphi = tmpphi - iphiho;
803 float signal = (*jk).energy();
805 if (signal > -100 &&
Noccu == Noccu_old) {
806 for (
int ij = 0; ij < 5; ij++) {
807 if (signal > (ij + 2) *
m_sigma) {
818 float signal = (*jk).energy();
820 if (3 * (deta + 1) + dphi + 1 < 9)
821 tmpHOCalib.
hbhesig[3 * (deta + 1) + dphi + 1] = signal;
828 if (!(*hoht).empty()) {
831 int tmpeta =
id.
ieta();
832 int tmpphi =
id.iphi();
835 if (tmpeta >= etamn && tmpeta <= etamx) {
837 ipass1 = (tmpphi >= phimn && tmpphi <= phimx) ? 1 : 0;
839 ipass1 = (tmpphi == 71 || tmpphi == 72 || tmpphi == 1) ? 1 : 0;
843 int deta = tmpeta - ietaho;
844 int dphi = tmpphi - iphiho;
846 if (tmpeta < 0 && ietaho > 0)
848 if (tmpeta > 0 && ietaho < 0)
864 float signal = (*jk).energy();
868 if (ipass1 == 0 && ipass2 == 0)
872 int tmpdph = tmpphi - phimn;
876 int ilog = 2 * (tmpeta - etamn) + tmpdph;
879 ilog = 3 * (tmpeta - etamn) + tmpdph;
881 ilog = 3 * (etamx - tmpeta) + tmpdph;
884 if (ilog > -1 && ilog < 18) {
890 if (3 * (deta + 1) + dphi + 1 < 9) {
891 tmpHOCalib.
hosig[3 * (deta + 1) + dphi + 1] = signal;
895 if (deta == 0 && dphi == 0) {
896 tmpHOCalib.
htime = (*jk).time();
897 tmpHOCalib.
hoflag = (*jk).flags();
903 tmpHOCalib.
hoflag = hitSeverity;
904 int crphi = tmpphi + 6;
911 int etacr = idcr.
ieta();
912 int phicr = idcr.
iphi();
913 if (tmpeta == etacr && crphi == phicr) {
923 if (
Noccu == Noccu_old)
925 hostore->push_back(tmpHOCalib);
933 const double etalow[16] = {0.025,
949 const double etahgh[16] = {35.145,
966 const double philow[6] = {-76.27, -35.11, 0.35, 35.81, 71.77, 108.93};
967 const double phihgh[6] = {-35.81, -0.35, 35.11, 71.07, 108.23, 140.49};
969 const double philow00[6] = {-60.27, -32.91, 0.35, 33.61, 67.37, 102.23};
970 const double phihgh00[6] = {-33.61, -0.35, 32.91, 66.67, 101.53, 129.49};
972 const double philow01[6] = {-64.67, -34.91, 0.35, 35.61, 71.37, 108.33};
973 const double phihgh01[6] = {-35.61, -0.35, 34.91, 70.67, 107.63, 138.19};
978 for (
int ij = 0; ij <
netabin; ij++) {
979 if (tmpdy > etalow[ij] && tmpdy < etahgh[ij]) {
981 float tmp1 = fabs(tmpdy - etalow[ij]);
982 float tmp2 = fabs(tmpdy - etahgh[ij]);
990 if (ij >= 4 && ij < 10)
1002 for (
int ij = 0; ij < 6; ij++) {
1003 if (
xhor1 > philow[ij] &&
xhor1 < phihgh[ij]) {
1005 float tmp1 = fabs(
xhor1 - philow[ij]);
1006 float tmp2 = fabs(
xhor1 - phihgh[ij]);
1012 for (
int ij = 0; ij < 6; ij++) {
1013 if (
xhor1 > philow01[ij] &&
xhor1 < phihgh01[ij]) {
1015 float tmp1 = fabs(
xhor1 - philow01[ij]);
1016 float tmp2 = fabs(
xhor1 - phihgh01[ij]);
1022 for (
int ij = 0; ij < 6; ij++) {
1023 if (
xhor0 > philow00[ij] &&
xhor0 < phihgh00[ij]) {
1025 float tmp1 = fabs(
xhor0 - philow00[ij]);
1026 float tmp2 = fabs(
xhor0 - phihgh00[ij]);
1028 if (tmpphi != tmpphi0)
1035 for (
int ij = 0; ij < 4; ij++) {
1036 if (tmpdy > etalow[ij] && tmpdy < etahgh[ij]) {
1037 float tmp1 = fabs(tmpdy - etalow[ij]);
1038 float tmp2 = fabs(tmpdy - etahgh[ij]);
1042 if (ij + 1 != ietaho)
1050 iphiho = 6 * iphisect - 2 + tmpphi;
static const std::string kSharedResource
double outerY() const
y coordinate of the outermost hit position
Basic3DVector< float > DirectionType
T getParameter(std::string const &) const
edm::EDGetTokenT< CaloTowerCollection > tok_tower_
FreeTrajectoryState getFreeTrajectoryState(const reco::Track &tk, const MagneticField *field, int itag, bool dir)
Vector3DBase< typename PreciseFloatType< T, U >::Type, FrameTag > cross(const Vector3DBase< U, FrameTag > &v) const
float sumPt
sum-pt of tracks
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
double outerX() const
x coordinate of the outermost hit position
const HcalChannelQuality * theHcalChStatus
double outerPy() const
y coordinate of momentum vector at the outermost hit position
Sin< T >::type sin(const T &t)
ReturnType plane(const PositionType &pos, const RotationType &rot) const
std::vector< CaloTower >::const_iterator const_iterator
void produce(edm::Event &, const edm::EventSetup &) override
const HcalSeverityLevelComputer * theHcalSevLvlComputer
std::map< std::string, bool > fired
edm::EDGetTokenT< reco::TrackCollection > tok_muonsCosmic_
edm::ESGetToken< CaloGeometry, CaloGeometryRecord > tok_geom_
double outerZ() const
z coordinate of the outermost hit position
void findHOEtaPhi(int iphsect, int &ietaho, int &iphiho)
T dot(const Basic3DVector &v) const
Scalar product, or "dot" product, with a vector of same type.
Geom::Theta< T > theta() const
const Item * getValues(DetId fId, bool throwOnFail=true) const
constexpr float energy() const
GlobalPoint position() const
T getUntrackedParameter(std::string const &, T const &) const
int charge() const
track electric charge
edm::ESGetToken< HcalChannelQuality, HcalChannelQualityRcd > tok_hcalChStatus_
~AlCaHOCalibProducer() override=default
void applyRadX0Correction(bool applyRadX0Correction)
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 CaloSubdetectorGeometry *, const MagneticField &)
constexpr int ieta() const
get the cell ieta
Basic3DVector< float > RotationType
Cos< T >::type cos(const T &t)
edm::EDGetTokenT< OnlineLuminosityRecord > tok_metaData_
math::Error< 5 >::type CovarianceMatrix
Abs< T >::type abs(const T &t)
#define DEFINE_FWK_MODULE(type)
Basic3DVector< float > PositionType
uint32_t getValue() const
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
double outerPz() const
z coordinate of momentum vector at the outermost hit position
virtual DetId getClosestCell(const GlobalPoint &r) const
edm::EDGetTokenT< LumiScalersCollection > tok_lumi_
Log< level::Info, false > LogInfo
void propagate(const SteppingHelixStateInfo &ftsStart, const Surface &sDest, SteppingHelixStateInfo &out) const
Propagate to Plane given a starting point.
edm::EDGetTokenT< reco::VertexCollection > tok_vertex_
edm::EDGetTokenT< edm::View< reco::Muon > > tok_muons_
edm::Ref< TrackCollection > TrackRef
persistent reference to a Track
void add(std::string const &label, ParameterSetDescription const &psetDescription)
edm::EDGetTokenT< HORecHitCollection > tok_ho_
GlobalVector momentum() const
edm::ESGetToken< HcalSeverityLevelComputer, HcalSeverityLevelComputerRcd > tok_hcalSevLvlComputer_
AlCaHOCalibProducer(const edm::ParameterSet &)
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
constexpr HcalDetId id() const
get the id
double outerPx() const
x coordinate of momentum vector at the outermost hit position
int getSeverityLevel(const DetId &myid, const uint32_t &myflag, const uint32_t &mystatus) const
Geom::Phi< T > phi() const
const math::XYZVector & innerMomentum() const
momentum vector at the innermost hit position
Log< level::Warning, false > LogWarning
edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > tok_magField_
const math::XYZPoint & innerPosition() const
position of the innermost hit
const CaloSubdetectorGeometry * getSubdetectorGeometry(const DetId &id) const
access the subdetector geometry for the given subdetector directly
constexpr int iphi() const
get the cell iphi
void setMaterialMode(bool noMaterial)
Switch for material effects mode: no material effects if true.
edm::EDGetTokenT< HBHERecHitCollection > tok_hbhe_
math::Error< dimension >::type CovarianceMatrix
5 parameter covariance matrix
const TrackExtraRef & extra() const
reference to "extra" object
T angle(T x1, T y1, T z1, T x2, T y2, T z2)