116 #include "CLHEP/Vector/LorentzVector.h" 139 #include "CLHEP/Units/GlobalPhysicalConstants.h" 140 #include "CLHEP/Units/GlobalSystemOfUnits.h" 173 std::unique_ptr<HOCalibVariableCollection> &hostore,
174 int Noccu_old,
int indx,
178 void findHOEtaPhi(
int iphsect,
int& ietaho,
int& iphiho);
268 produces<HOCalibVariableCollection>(
"HOCalibVariableCollection").setBranchAlias(
"HOCalibVariableCollection");
275 for (
int ij=0; ij<5; ij++) {
276 sprintf(title,
"ho_occupency (>%i #sigma)", ij+2);
300 int irun = iEvent.
id().
run();
307 auto hostore = std::make_unique<HOCalibVariableCollection>();
314 tmpHOCalib.
nprim = -1;
319 muonOK = (cosmicmuon.isValid() && !cosmicmuon->empty());
322 muonOK = (collisionmuon.
isValid() && !collisionmuon->empty());
327 if (primaryVertices.
isValid()) { tmpHOCalib.
nprim = primaryVertices->size();}
335 if ( lumiScale->empty() ) {
338 tmpHOCalib.
inslumi=lumiScale->begin()->pileup();
346 int Noccu_old =
Noccu;
350 for(reco::TrackCollection::const_iterator ncosm = cosmicmuon->begin();
351 ncosm != cosmicmuon->end(); ++ncosm,++indx) {
352 if ((*ncosm).ndof() < 15)
continue;
353 if ((*ncosm).normalizedChi2() >30.0)
continue;
355 fillHOStore(tRef,tmpHOCalib,hostore,Noccu_old,indx,cosmicmuon,muon1,
359 for( muon1 = collisionmuon->begin(); muon1 < collisionmuon->end(); muon1++ ) {
360 if ((!muon1->isGlobalMuon()) || (!muon1->isTrackerMuon()))
continue;
362 fillHOStore(ncosm,tmpHOCalib,hostore,Noccu_old,0,cosmicmuon,muon1,
368 iEvent.
put(
std::move(hostore),
"HOCalibVariableCollection");
384 for (
int ij=0; ij<5; ij++) {
407 std::unique_ptr<HOCalibVariableCollection> &hostore,
408 int Noccu_old,
int indx,
425 int charge = ncosm->charge();
427 double innerr = (*ncosm).innerPosition().Perp2();
428 double outerr = (*ncosm).outerPosition().Perp2();
429 int iiner = (innerr <outerr) ? 1 : 0;
440 double posx, posy, posz;
441 double momx, momy, momz;
444 posx = (*ncosm).innerPosition().X();
445 posy = (*ncosm).innerPosition().Y();
446 posz = (*ncosm).innerPosition().Z();
448 momx = (*ncosm).innerMomentum().X();
449 momy = (*ncosm).innerMomentum().Y();
450 momz = (*ncosm).innerMomentum().Z();
453 posx = (*ncosm).outerPosition().X();
454 posy = (*ncosm).outerPosition().Y();
455 posz = (*ncosm).outerPosition().Z();
457 momx = (*ncosm).outerMomentum().X();
458 momy = (*ncosm).outerMomentum().Y();
459 momz = (*ncosm).outerMomentum().Z();
465 CLHEP::Hep3Vector tmpmuon3v(posx, posy, posz);
466 CLHEP::Hep3Vector tmpmuondir(momx, momy, momz);
468 bool samedir = (tmpmuon3v.dot(tmpmuondir) >0) ?
true :
false;
469 for (
int ij=0; ij<3; ij++) {tmpHOCalib.
caloen[ij] = 0.0;}
475 for(reco::TrackCollection::const_iterator ncosmcor=cosmicmuon->begin();
476 ncosmcor != cosmicmuon->end(); ++ncosmcor,++ind) {
477 if (indx==ind)
continue;
478 CLHEP::Hep3Vector tmpmuon3vcor;
479 CLHEP::Hep3Vector tmpmom3v;
481 tmpmuon3vcor = CLHEP::Hep3Vector((*ncosmcor).innerPosition().X(),(*ncosmcor).innerPosition().Y(),(*ncosmcor).innerPosition().Z());
482 tmpmom3v = CLHEP::Hep3Vector((*ncosmcor).innerMomentum().X(),(*ncosmcor).innerMomentum().Y(),(*ncosmcor).innerMomentum().Z());
484 tmpmuon3vcor = CLHEP::Hep3Vector((*ncosmcor).outerPosition().X(),(*ncosmcor).outerPosition().Y(),(*ncosmcor).outerPosition().Z());
485 tmpmom3v = CLHEP::Hep3Vector((*ncosmcor).outerMomentum().X(),(*ncosmcor).outerMomentum().Y(),(*ncosmcor).outerMomentum().Z());
489 if (tmpmom3v.mag()<0.2 || (*ncosmcor).ndof()<5)
continue;
491 double angle = tmpmuon3v.angle(tmpmuon3vcor);
492 if (angle < 7.5*CLHEP::deg) {inearbymuon=1;}
495 if (angle <7.5*CLHEP::deg) { tmpHOCalib.
caloen[0] +=1.;}
496 if (angle <15.0*CLHEP::deg) { tmpHOCalib.
caloen[1] +=1.;}
497 if (angle <35.0*CLHEP::deg) { tmpHOCalib.
caloen[2] +=1.;}
505 calt !=calotower->
end(); calt++) {
507 double ith = (*calt).momentum().theta();
508 double iph = (*calt).momentum().phi();
510 CLHEP::Hep3Vector calo3v(
sin(ith)*
cos(iph),
sin(ith)*
sin(iph),
cos(ith));
512 double angle = tmpmuon3v.angle(calo3v);
514 if (angle < 7.5*CLHEP::deg) {tmpHOCalib.
caloen[0] += calt->emEnergy()+calt->hadEnergy();}
515 if (angle < 15*CLHEP::deg) {tmpHOCalib.
caloen[1] += calt->emEnergy()+calt->hadEnergy();}
516 if (angle < 35*CLHEP::deg) {tmpHOCalib.
caloen[2] += calt->emEnergy()+calt->hadEnergy();}
523 double mom =
sqrt(momx*momx + momy*momy +momz*momz);
531 tmpHOCalib.
trkdr = (*ncosm).d0();
532 tmpHOCalib.
trkdz = (*ncosm).dz();
534 tmpHOCalib.
trkvx = glbpt.
x();
535 tmpHOCalib.
trkvy = glbpt.
y();
536 tmpHOCalib.
trkvz = glbpt.
z();
541 tmpHOCalib.
isect = -2;
542 tmpHOCalib.
hodx = -100;
543 tmpHOCalib.
hody = -100;
544 tmpHOCalib.
hoang = -2.0;
546 tmpHOCalib.
ndof = (inearbymuon ==0) ? (
int)(*ncosm).ndof() : -(
int)(*ncosm).ndof();
547 tmpHOCalib.
chisq = (*ncosm).normalizedChi2();
557 tmpHOCalib.
therr = 0.;
558 tmpHOCalib.
pherr = 0.;
561 tmpHOCalib.
therr = innercov(1,1);
562 tmpHOCalib.
pherr = innercov(2,2);
565 tmpHOCalib.
therr = outercov(1,1);
566 tmpHOCalib.
pherr = outercov(2,2);
574 double phiho = trkpos.
phi();
575 if (phiho<0) phiho +=CLHEP::twopi;
577 int iphisect_dt=
int(6*(phiho+10.0*CLHEP::deg)/
CLHEP::pi);
578 if (iphisect_dt>=12) iphisect_dt=0;
582 for (
int kl = 0; kl<=2; kl++) {
584 int iphisecttmp = (kl<2) ? iphisect_dt + kl : iphisect_dt - 1;
585 if (iphisecttmp <0) iphisecttmp = 11;
586 if (iphisecttmp >=12) iphisecttmp = 0;
588 double phipos = iphisecttmp*
CLHEP::pi/6.;
589 double phirot = phipos;
601 for (
int ik=1; ik>=0; ik--) {
603 double radial =
rHOL1;
604 if (ik==0) radial =
rHOL0;
609 auto aPlane2 =
new Plane(pos,rot);
614 if (steppingHelixstateinfo_.
isValid()) {
620 int ixeta = ClosestCell.
ieta();
621 int ixphi = ClosestCell.
iphi();
627 CLHEP::Hep3Vector hotrkdir2(steppingHelixstateinfo_.
momentum().
x(), steppingHelixstateinfo_.
momentum().
y(),steppingHelixstateinfo_.
momentum().
z());
631 double xx = lclvt0.x();
632 double yy = lclvt0.y();
635 if ((
std::abs(yy) < 130 && xx >-64.7 && xx <138.2)
638 iphisect = iphisecttmp;
642 if (iphisect != iphisecttmp)
continue;
653 tmpHOCalib.
momatho = hotrkdir2.mag();
654 tmpHOCalib.
hoang = CLHEP::Hep3Vector(zLocal.
x(),zLocal.
y(),zLocal.
z()).
dot(hotrkdir2.unit());
669 for (
int ij=0; ij<9; ij++) {tmpHOCalib.
hosig[ij]=-100.0;}
670 for (
int ij=0; ij<18; ij++) {tmpHOCalib.
hocorsig[ij]=-100.0;}
671 for (
int ij=0; ij<9; ij++) {tmpHOCalib.
hbhesig[ij]=-100.0;}
672 tmpHOCalib.
hocro = -100;
673 tmpHOCalib.
htime = -1000;
683 if (iphiho<0) isect -=2000000;
684 tmpHOCalib.
isect = isect;
696 if (
iring==1) {etamn=5; etamx = 10;}
697 if (
iring==2) {etamn=11; etamx = 16;}
698 if (
iring==-1){etamn=-10; etamx = -5;}
699 if (
iring==-2){etamn=-16; etamx = -11;}
704 phimx =2*
int((iphiho+1)/2.);
707 phimn = 3*
int((iphiho+1)/3.) - 1;
711 if (phimn <1) phimn +=
nphimx;
712 if (phimx >72) phimx -=
nphimx;
715 for (
int ij=0; ij<9; ij++) {tmpHOCalib.
hbhesig[ij]=-100.0;}
720 if (!(*hbheht).empty()) {
721 if((*hbheht).empty())
throw (
int)(*hbheht).size();
725 int tmpeta=
id.
ieta();
726 int tmpphi=
id.iphi();
728 int deta = tmpeta-ietaho;
729 if (tmpeta<0 && ietaho>0) deta += 1;
730 if (tmpeta>0 && ietaho<0) deta -= 1;
735 int dphi = tmpphi-iphiho;
745 float signal = (*jk).energy();
747 if (signal >-100 &&
Noccu == Noccu_old) {
748 for (
int ij=0; ij<5; ij++) {
757 if ( ipass2 ==0 )
continue;
759 float signal = (*jk).energy();
761 if (3*(deta+1)+dphi+1<9) tmpHOCalib.
hbhesig[3*(deta+1)+dphi+1] = signal;
769 if (!(*hoht).empty()) {
772 int tmpeta=
id.
ieta();
773 int tmpphi=
id.iphi();
776 if (tmpeta >=etamn && tmpeta <=etamx) {
778 ipass1 = (tmpphi >=phimn && tmpphi <=phimx ) ? 1 : 0;
780 ipass1 = (tmpphi==71 || tmpphi ==72 || tmpphi==1) ? 1 : 0;
784 int deta = tmpeta-ietaho;
785 int dphi = tmpphi -iphiho;
787 if (tmpeta<0 && ietaho>0) deta += 1;
788 if (tmpeta>0 && ietaho<0) deta -= 1;
799 float signal = (*jk).energy();
803 if (ipass1 ==0 && ipass2 ==0 )
continue;
806 int tmpdph = tmpphi-phimn;
807 if (tmpdph<0) tmpdph = 2;
809 int ilog = 2*(tmpeta-etamn)+tmpdph;
812 ilog = 3*(tmpeta-etamn)+tmpdph;
814 ilog = 3*(etamx-tmpeta)+tmpdph;
817 if (ilog>-1 && ilog<18) {
824 if (3*(deta+1)+dphi+1<9) {
825 tmpHOCalib.
hosig[3*(deta+1)+dphi+1] = signal;
829 if (deta==0 && dphi ==0) {
830 tmpHOCalib.
htime = (*jk).time();
831 tmpHOCalib.
hoflag = (*jk).flags();
836 int hitSeverity=hcalSevLvlComputer->
getSeverityLevel(
id, (*jk).flags(),theStatusValue);
837 tmpHOCalib.
hoflag = hitSeverity;
838 int crphi = tmpphi + 6;
839 if (crphi >72) crphi -=72;
844 int etacr= idcr.
ieta();
845 int phicr= idcr.
iphi();
846 if (tmpeta==etacr && crphi ==phicr) {
859 hostore->push_back(tmpHOCalib);
868 const double etalow[16]={ 0.025, 35.195, 70.625, 106.595, 141.565, 180.765, 220.235, 261.385, 304.525, 349.975, 410.025, 452.085, 506.645, 565.025, 627.725, 660.25};
869 const double etahgh[16]={ 35.145, 70.575, 106.545, 125.505, 180.715, 220.185, 261.335, 304.475, 349.925, 392.575, 452.035, 506.595, 564.975, 627.675, 661.075, 700.25};
871 const double philow[6]={-76.27, -35.11, 0.35, 35.81, 71.77, 108.93};
872 const double phihgh[6]={-35.81, -0.35, 35.11, 71.07, 108.23, 140.49};
874 const double philow00[6]={-60.27, -32.91, 0.35, 33.61, 67.37, 102.23};
875 const double phihgh00[6]={-33.61, -0.35, 32.91, 66.67, 101.53, 129.49};
877 const double philow01[6]={-64.67, -34.91, 0.35, 35.61, 71.37, 108.33};
878 const double phihgh01[6]={-35.61, -0.35, 34.91, 70.67, 107.63, 138.19};
883 for (
int ij=0; ij<
netabin; ij++) {
884 if (tmpdy >etalow[ij] && tmpdy <etahgh[ij]) {
886 float tmp1 = fabs(tmpdy-etalow[ij]);
887 float tmp2 = fabs(tmpdy-etahgh[ij]);
893 if (ij>=4 && ij<10)
iring=1;
894 if (ij>=10 && ij<netabin)
iring=2;
903 for (
int ij=0; ij<6; ij++) {
906 float tmp1 = fabs(
xhor1-philow[ij]);
907 float tmp2 = fabs(
xhor1-phihgh[ij]);
913 for (
int ij=0; ij<6; ij++) {
914 if (
xhor1 >philow01[ij] &&
xhor1 <phihgh01[ij]) {
916 float tmp1 = fabs(
xhor1-philow01[ij]);
917 float tmp2 = fabs(
xhor1-phihgh01[ij]);
923 for (
int ij=0; ij<6; ij++) {
924 if (
xhor0 >philow00[ij] &&
xhor0 <phihgh00[ij]) {
926 float tmp1 = fabs(
xhor0-philow00[ij]);
927 float tmp2 = fabs(
xhor0-phihgh00[ij]);
935 for (
int ij=0; ij<4; ij++) {
936 if (tmpdy >etalow[ij] && tmpdy <etahgh[ij]) {
937 float tmp1 = fabs(tmpdy-etalow[ij]);
938 float tmp2 = fabs(tmpdy-etahgh[ij]);
948 iphiho = 6*iphisect -2 + tmpphi;
949 if (iphiho <=0) iphiho +=
nphimx;
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
#define DEFINE_FWK_MODULE(type)
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
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)