116 #include "CLHEP/Vector/LorentzVector.h" 139 #include "CLHEP/Units/GlobalPhysicalConstants.h" 140 #include "CLHEP/Units/GlobalSystemOfUnits.h" 171 std::unique_ptr<HOCalibVariableCollection> &hostore,
172 int Noccu_old,
int indx,
176 void findHOEtaPhi(
int iphsect,
int& ietaho,
int& iphiho);
266 produces<HOCalibVariableCollection>(
"HOCalibVariableCollection").setBranchAlias(
"HOCalibVariableCollection");
273 for (
int ij=0; ij<5; ij++) {
274 sprintf(title,
"ho_occupency (>%i #sigma)", ij+2);
298 int irun = iEvent.
id().
run();
305 auto hostore = std::make_unique<HOCalibVariableCollection>();
312 tmpHOCalib.
nprim = -1;
317 muonOK = (cosmicmuon.isValid() && !cosmicmuon->empty());
320 muonOK = (collisionmuon.
isValid() && !collisionmuon->empty());
325 if (primaryVertices.
isValid()) { tmpHOCalib.
nprim = primaryVertices->size();}
333 if ( lumiScale->empty() ) {
336 tmpHOCalib.
inslumi=lumiScale->begin()->pileup();
344 int Noccu_old =
Noccu;
348 for(reco::TrackCollection::const_iterator ncosm = cosmicmuon->begin();
349 ncosm != cosmicmuon->end(); ++ncosm,++indx) {
350 if ((*ncosm).ndof() < 15)
continue;
351 if ((*ncosm).normalizedChi2() >30.0)
continue;
353 fillHOStore(tRef,tmpHOCalib,hostore,Noccu_old,indx,cosmicmuon,muon1,
357 for( muon1 = collisionmuon->begin(); muon1 < collisionmuon->end(); muon1++ ) {
358 if ((!muon1->isGlobalMuon()) || (!muon1->isTrackerMuon()))
continue;
360 fillHOStore(ncosm,tmpHOCalib,hostore,Noccu_old,0,cosmicmuon,muon1,
366 iEvent.
put(
std::move(hostore),
"HOCalibVariableCollection");
382 for (
int ij=0; ij<5; ij++) {
406 std::unique_ptr<HOCalibVariableCollection> &hostore,
407 int Noccu_old,
int indx,
424 int charge = ncosm->charge();
426 double innerr = (*ncosm).innerPosition().Perp2();
427 double outerr = (*ncosm).outerPosition().Perp2();
428 int iiner = (innerr <outerr) ? 1 : 0;
439 double posx, posy, posz;
440 double momx, momy, momz;
443 posx = (*ncosm).innerPosition().X();
444 posy = (*ncosm).innerPosition().Y();
445 posz = (*ncosm).innerPosition().Z();
447 momx = (*ncosm).innerMomentum().X();
448 momy = (*ncosm).innerMomentum().Y();
449 momz = (*ncosm).innerMomentum().Z();
452 posx = (*ncosm).outerPosition().X();
453 posy = (*ncosm).outerPosition().Y();
454 posz = (*ncosm).outerPosition().Z();
456 momx = (*ncosm).outerMomentum().X();
457 momy = (*ncosm).outerMomentum().Y();
458 momz = (*ncosm).outerMomentum().Z();
464 CLHEP::Hep3Vector tmpmuon3v(posx, posy, posz);
465 CLHEP::Hep3Vector tmpmuondir(momx, momy, momz);
467 bool samedir = (tmpmuon3v.dot(tmpmuondir) >0) ?
true :
false;
468 for (
int ij=0; ij<3; ij++) {tmpHOCalib.
caloen[ij] = 0.0;}
474 for(reco::TrackCollection::const_iterator ncosmcor=cosmicmuon->begin();
475 ncosmcor != cosmicmuon->end(); ++ncosmcor,++ind) {
476 if (indx==ind)
continue;
477 CLHEP::Hep3Vector tmpmuon3vcor;
478 CLHEP::Hep3Vector tmpmom3v;
480 tmpmuon3vcor = CLHEP::Hep3Vector((*ncosmcor).innerPosition().X(),(*ncosmcor).innerPosition().Y(),(*ncosmcor).innerPosition().Z());
481 tmpmom3v = CLHEP::Hep3Vector((*ncosmcor).innerMomentum().X(),(*ncosmcor).innerMomentum().Y(),(*ncosmcor).innerMomentum().Z());
483 tmpmuon3vcor = CLHEP::Hep3Vector((*ncosmcor).outerPosition().X(),(*ncosmcor).outerPosition().Y(),(*ncosmcor).outerPosition().Z());
484 tmpmom3v = CLHEP::Hep3Vector((*ncosmcor).outerMomentum().X(),(*ncosmcor).outerMomentum().Y(),(*ncosmcor).outerMomentum().Z());
488 if (tmpmom3v.mag()<0.2 || (*ncosmcor).ndof()<5)
continue;
490 double angle = tmpmuon3v.angle(tmpmuon3vcor);
491 if (angle < 7.5*CLHEP::deg) {inearbymuon=1;}
494 if (angle <7.5*CLHEP::deg) { tmpHOCalib.
caloen[0] +=1.;}
495 if (angle <15.0*CLHEP::deg) { tmpHOCalib.
caloen[1] +=1.;}
496 if (angle <35.0*CLHEP::deg) { tmpHOCalib.
caloen[2] +=1.;}
504 calt !=calotower->
end(); calt++) {
506 double ith = (*calt).momentum().theta();
507 double iph = (*calt).momentum().phi();
509 CLHEP::Hep3Vector calo3v(
sin(ith)*
cos(iph),
sin(ith)*
sin(iph),
cos(ith));
511 double angle = tmpmuon3v.angle(calo3v);
513 if (angle < 7.5*CLHEP::deg) {tmpHOCalib.
caloen[0] += calt->emEnergy()+calt->hadEnergy();}
514 if (angle < 15*CLHEP::deg) {tmpHOCalib.
caloen[1] += calt->emEnergy()+calt->hadEnergy();}
515 if (angle < 35*CLHEP::deg) {tmpHOCalib.
caloen[2] += calt->emEnergy()+calt->hadEnergy();}
522 double mom =
sqrt(momx*momx + momy*momy +momz*momz);
530 tmpHOCalib.
trkdr = (*ncosm).d0();
531 tmpHOCalib.
trkdz = (*ncosm).dz();
533 tmpHOCalib.
trkvx = glbpt.
x();
534 tmpHOCalib.
trkvy = glbpt.
y();
535 tmpHOCalib.
trkvz = glbpt.
z();
540 tmpHOCalib.
isect = -2;
541 tmpHOCalib.
hodx = -100;
542 tmpHOCalib.
hody = -100;
543 tmpHOCalib.
hoang = -2.0;
545 tmpHOCalib.
ndof = (inearbymuon ==0) ? (
int)(*ncosm).ndof() : -(
int)(*ncosm).ndof();
546 tmpHOCalib.
chisq = (*ncosm).normalizedChi2();
556 tmpHOCalib.
therr = 0.;
557 tmpHOCalib.
pherr = 0.;
560 tmpHOCalib.
therr = innercov(1,1);
561 tmpHOCalib.
pherr = innercov(2,2);
564 tmpHOCalib.
therr = outercov(1,1);
565 tmpHOCalib.
pherr = outercov(2,2);
573 double phiho = trkpos.
phi();
574 if (phiho<0) phiho +=CLHEP::twopi;
576 int iphisect_dt=
int(6*(phiho+10.0*CLHEP::deg)/
CLHEP::pi);
577 if (iphisect_dt>=12) iphisect_dt=0;
581 for (
int kl = 0; kl<=2; kl++) {
583 int iphisecttmp = (kl<2) ? iphisect_dt + kl : iphisect_dt - 1;
584 if (iphisecttmp <0) iphisecttmp = 11;
585 if (iphisecttmp >=12) iphisecttmp = 0;
587 double phipos = iphisecttmp*
CLHEP::pi/6.;
588 double phirot = phipos;
600 for (
int ik=1; ik>=0; ik--) {
602 double radial =
rHOL1;
603 if (ik==0) radial =
rHOL0;
608 auto aPlane2 =
new Plane(pos,rot);
613 if (steppingHelixstateinfo_.
isValid()) {
619 int ixeta = ClosestCell.
ieta();
620 int ixphi = ClosestCell.
iphi();
626 CLHEP::Hep3Vector hotrkdir2(steppingHelixstateinfo_.
momentum().
x(), steppingHelixstateinfo_.
momentum().
y(),steppingHelixstateinfo_.
momentum().
z());
630 double xx = lclvt0.x();
631 double yy = lclvt0.y();
634 if ((
std::abs(yy) < 130 && xx >-64.7 && xx <138.2)
637 iphisect = iphisecttmp;
641 if (iphisect != iphisecttmp)
continue;
652 tmpHOCalib.
momatho = hotrkdir2.mag();
653 tmpHOCalib.
hoang = CLHEP::Hep3Vector(zLocal.
x(),zLocal.
y(),zLocal.
z()).
dot(hotrkdir2.unit());
668 for (
int ij=0; ij<9; ij++) {tmpHOCalib.
hosig[ij]=-100.0;}
669 for (
int ij=0; ij<18; ij++) {tmpHOCalib.
hocorsig[ij]=-100.0;}
670 for (
int ij=0; ij<9; ij++) {tmpHOCalib.
hbhesig[ij]=-100.0;}
671 tmpHOCalib.
hocro = -100;
672 tmpHOCalib.
htime = -1000;
682 if (iphiho<0) isect -=2000000;
683 tmpHOCalib.
isect = isect;
695 if (
iring==1) {etamn=5; etamx = 10;}
696 if (
iring==2) {etamn=11; etamx = 16;}
697 if (
iring==-1){etamn=-10; etamx = -5;}
698 if (
iring==-2){etamn=-16; etamx = -11;}
703 phimx =2*
int((iphiho+1)/2.);
706 phimn = 3*
int((iphiho+1)/3.) - 1;
710 if (phimn <1) phimn +=
nphimx;
711 if (phimx >72) phimx -=
nphimx;
714 for (
int ij=0; ij<9; ij++) {tmpHOCalib.
hbhesig[ij]=-100.0;}
719 if (!(*hbheht).empty()) {
720 if((*hbheht).empty())
throw (
int)(*hbheht).size();
724 int tmpeta=
id.
ieta();
725 int tmpphi=
id.iphi();
727 int deta = tmpeta-ietaho;
728 if (tmpeta<0 && ietaho>0) deta += 1;
729 if (tmpeta>0 && ietaho<0) deta -= 1;
734 int dphi = tmpphi-iphiho;
744 float signal = (*jk).energy();
746 if (signal >-100 &&
Noccu == Noccu_old) {
747 for (
int ij=0; ij<5; ij++) {
756 if ( ipass2 ==0 )
continue;
758 float signal = (*jk).energy();
760 if (3*(deta+1)+dphi+1<9) tmpHOCalib.
hbhesig[3*(deta+1)+dphi+1] = signal;
768 if (!(*hoht).empty()) {
771 int tmpeta=
id.
ieta();
772 int tmpphi=
id.iphi();
775 if (tmpeta >=etamn && tmpeta <=etamx) {
777 ipass1 = (tmpphi >=phimn && tmpphi <=phimx ) ? 1 : 0;
779 ipass1 = (tmpphi==71 || tmpphi ==72 || tmpphi==1) ? 1 : 0;
783 int deta = tmpeta-ietaho;
784 int dphi = tmpphi -iphiho;
786 if (tmpeta<0 && ietaho>0) deta += 1;
787 if (tmpeta>0 && ietaho<0) deta -= 1;
798 float signal = (*jk).energy();
802 if (ipass1 ==0 && ipass2 ==0 )
continue;
805 int tmpdph = tmpphi-phimn;
806 if (tmpdph<0) tmpdph = 2;
808 int ilog = 2*(tmpeta-etamn)+tmpdph;
811 ilog = 3*(tmpeta-etamn)+tmpdph;
813 ilog = 3*(etamx-tmpeta)+tmpdph;
816 if (ilog>-1 && ilog<18) {
823 if (3*(deta+1)+dphi+1<9) {
824 tmpHOCalib.
hosig[3*(deta+1)+dphi+1] = signal;
828 if (deta==0 && dphi ==0) {
829 tmpHOCalib.
htime = (*jk).time();
830 tmpHOCalib.
hoflag = (*jk).flags();
835 int hitSeverity=hcalSevLvlComputer->
getSeverityLevel(
id, (*jk).flags(),theStatusValue);
836 tmpHOCalib.
hoflag = hitSeverity;
837 int crphi = tmpphi + 6;
838 if (crphi >72) crphi -=72;
843 int etacr= idcr.
ieta();
844 int phicr= idcr.
iphi();
845 if (tmpeta==etacr && crphi ==phicr) {
858 hostore->push_back(tmpHOCalib);
867 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};
868 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};
870 const double philow[6]={-76.27, -35.11, 0.35, 35.81, 71.77, 108.93};
871 const double phihgh[6]={-35.81, -0.35, 35.11, 71.07, 108.23, 140.49};
873 const double philow00[6]={-60.27, -32.91, 0.35, 33.61, 67.37, 102.23};
874 const double phihgh00[6]={-33.61, -0.35, 32.91, 66.67, 101.53, 129.49};
876 const double philow01[6]={-64.67, -34.91, 0.35, 35.61, 71.37, 108.33};
877 const double phihgh01[6]={-35.61, -0.35, 34.91, 70.67, 107.63, 138.19};
882 for (
int ij=0; ij<
netabin; ij++) {
883 if (tmpdy >etalow[ij] && tmpdy <etahgh[ij]) {
885 float tmp1 = fabs(tmpdy-etalow[ij]);
886 float tmp2 = fabs(tmpdy-etahgh[ij]);
892 if (ij>=4 && ij<10)
iring=1;
893 if (ij>=10 && ij<netabin)
iring=2;
902 for (
int ij=0; ij<6; ij++) {
905 float tmp1 = fabs(
xhor1-philow[ij]);
906 float tmp2 = fabs(
xhor1-phihgh[ij]);
912 for (
int ij=0; ij<6; ij++) {
913 if (
xhor1 >philow01[ij] &&
xhor1 <phihgh01[ij]) {
915 float tmp1 = fabs(
xhor1-philow01[ij]);
916 float tmp2 = fabs(
xhor1-phihgh01[ij]);
922 for (
int ij=0; ij<6; ij++) {
923 if (
xhor0 >philow00[ij] &&
xhor0 <phihgh00[ij]) {
925 float tmp1 = fabs(
xhor0-philow00[ij]);
926 float tmp2 = fabs(
xhor0-phihgh00[ij]);
934 for (
int ij=0; ij<4; ij++) {
935 if (tmpdy >etalow[ij] && tmpdy <etahgh[ij]) {
936 float tmp1 = fabs(tmpdy-etalow[ij]);
937 float tmp2 = fabs(tmpdy-etahgh[ij]);
947 iphiho = 6*iphisect -2 + tmpphi;
948 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
void beginRun(edm::Run const &, edm::EventSetup const &) override
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_
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)