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 tmpHOCalib.
inslumi=lumiScale->begin()->pileup();
340 int Noccu_old =
Noccu;
344 for(reco::TrackCollection::const_iterator ncosm = cosmicmuon->begin();
345 ncosm != cosmicmuon->end(); ++ncosm,++indx) {
346 if ((*ncosm).ndof() < 15)
continue;
347 if ((*ncosm).normalizedChi2() >30.0)
continue;
349 fillHOStore(tRef,tmpHOCalib,hostore,Noccu_old,indx,cosmicmuon,muon1,
353 for( muon1 = collisionmuon->begin(); muon1 < collisionmuon->end(); muon1++ ) {
354 if ((!muon1->isGlobalMuon()) || (!muon1->isTrackerMuon()))
continue;
356 fillHOStore(ncosm,tmpHOCalib,hostore,Noccu_old,0,cosmicmuon,muon1,
362 iEvent.
put(
std::move(hostore),
"HOCalibVariableCollection");
378 for (
int ij=0; ij<5; ij++) {
402 std::unique_ptr<HOCalibVariableCollection> &hostore,
403 int Noccu_old,
int indx,
420 int charge = ncosm->charge();
422 double innerr = (*ncosm).innerPosition().Perp2();
423 double outerr = (*ncosm).outerPosition().Perp2();
424 int iiner = (innerr <outerr) ? 1 : 0;
435 double posx, posy, posz;
436 double momx, momy, momz;
439 posx = (*ncosm).innerPosition().X();
440 posy = (*ncosm).innerPosition().Y();
441 posz = (*ncosm).innerPosition().Z();
443 momx = (*ncosm).innerMomentum().X();
444 momy = (*ncosm).innerMomentum().Y();
445 momz = (*ncosm).innerMomentum().Z();
448 posx = (*ncosm).outerPosition().X();
449 posy = (*ncosm).outerPosition().Y();
450 posz = (*ncosm).outerPosition().Z();
452 momx = (*ncosm).outerMomentum().X();
453 momy = (*ncosm).outerMomentum().Y();
454 momz = (*ncosm).outerMomentum().Z();
460 CLHEP::Hep3Vector tmpmuon3v(posx, posy, posz);
461 CLHEP::Hep3Vector tmpmuondir(momx, momy, momz);
463 bool samedir = (tmpmuon3v.dot(tmpmuondir) >0) ?
true :
false;
464 for (
int ij=0; ij<3; ij++) {tmpHOCalib.
caloen[ij] = 0.0;}
470 for(reco::TrackCollection::const_iterator ncosmcor=cosmicmuon->begin();
471 ncosmcor != cosmicmuon->end(); ++ncosmcor,++ind) {
472 if (indx==ind)
continue;
473 CLHEP::Hep3Vector tmpmuon3vcor;
474 CLHEP::Hep3Vector tmpmom3v;
476 tmpmuon3vcor = CLHEP::Hep3Vector((*ncosmcor).innerPosition().X(),(*ncosmcor).innerPosition().Y(),(*ncosmcor).innerPosition().Z());
477 tmpmom3v = CLHEP::Hep3Vector((*ncosmcor).innerMomentum().X(),(*ncosmcor).innerMomentum().Y(),(*ncosmcor).innerMomentum().Z());
479 tmpmuon3vcor = CLHEP::Hep3Vector((*ncosmcor).outerPosition().X(),(*ncosmcor).outerPosition().Y(),(*ncosmcor).outerPosition().Z());
480 tmpmom3v = CLHEP::Hep3Vector((*ncosmcor).outerMomentum().X(),(*ncosmcor).outerMomentum().Y(),(*ncosmcor).outerMomentum().Z());
484 if (tmpmom3v.mag()<0.2 || (*ncosmcor).ndof()<5)
continue;
486 double angle = tmpmuon3v.angle(tmpmuon3vcor);
487 if (angle < 7.5*CLHEP::deg) {inearbymuon=1;}
490 if (angle <7.5*CLHEP::deg) { tmpHOCalib.
caloen[0] +=1.;}
491 if (angle <15.0*CLHEP::deg) { tmpHOCalib.
caloen[1] +=1.;}
492 if (angle <35.0*CLHEP::deg) { tmpHOCalib.
caloen[2] +=1.;}
500 calt !=calotower->
end(); calt++) {
502 double ith = (*calt).momentum().theta();
503 double iph = (*calt).momentum().phi();
505 CLHEP::Hep3Vector calo3v(
sin(ith)*
cos(iph),
sin(ith)*
sin(iph),
cos(ith));
507 double angle = tmpmuon3v.angle(calo3v);
509 if (angle < 7.5*CLHEP::deg) {tmpHOCalib.
caloen[0] += calt->emEnergy()+calt->hadEnergy();}
510 if (angle < 15*CLHEP::deg) {tmpHOCalib.
caloen[1] += calt->emEnergy()+calt->hadEnergy();}
511 if (angle < 35*CLHEP::deg) {tmpHOCalib.
caloen[2] += calt->emEnergy()+calt->hadEnergy();}
518 double mom =
sqrt(momx*momx + momy*momy +momz*momz);
526 tmpHOCalib.
trkdr = (*ncosm).d0();
527 tmpHOCalib.
trkdz = (*ncosm).dz();
529 tmpHOCalib.
trkvx = glbpt.
x();
530 tmpHOCalib.
trkvy = glbpt.
y();
531 tmpHOCalib.
trkvz = glbpt.
z();
536 tmpHOCalib.
isect = -2;
537 tmpHOCalib.
hodx = -100;
538 tmpHOCalib.
hody = -100;
539 tmpHOCalib.
hoang = -2.0;
541 tmpHOCalib.
ndof = (inearbymuon ==0) ? (
int)(*ncosm).ndof() : -(
int)(*ncosm).ndof();
542 tmpHOCalib.
chisq = (*ncosm).normalizedChi2();
552 tmpHOCalib.
therr = 0.;
553 tmpHOCalib.
pherr = 0.;
556 tmpHOCalib.
therr = innercov(1,1);
557 tmpHOCalib.
pherr = innercov(2,2);
560 tmpHOCalib.
therr = outercov(1,1);
561 tmpHOCalib.
pherr = outercov(2,2);
569 double phiho = trkpos.
phi();
570 if (phiho<0) phiho +=CLHEP::twopi;
572 int iphisect_dt=
int(6*(phiho+10.0*CLHEP::deg)/
CLHEP::pi);
573 if (iphisect_dt>=12) iphisect_dt=0;
577 for (
int kl = 0; kl<=2; kl++) {
579 int iphisecttmp = (kl<2) ? iphisect_dt + kl : iphisect_dt - 1;
580 if (iphisecttmp <0) iphisecttmp = 11;
581 if (iphisecttmp >=12) iphisecttmp = 0;
583 double phipos = iphisecttmp*
CLHEP::pi/6.;
584 double phirot = phipos;
596 for (
int ik=1; ik>=0; ik--) {
598 double radial =
rHOL1;
599 if (ik==0) radial =
rHOL0;
604 auto aPlane2 =
new Plane(pos,rot);
609 if (steppingHelixstateinfo_.
isValid()) {
615 int ixeta = ClosestCell.
ieta();
616 int ixphi = ClosestCell.
iphi();
622 CLHEP::Hep3Vector hotrkdir2(steppingHelixstateinfo_.
momentum().
x(), steppingHelixstateinfo_.
momentum().
y(),steppingHelixstateinfo_.
momentum().
z());
626 double xx = lclvt0.x();
627 double yy = lclvt0.y();
630 if ((
std::abs(yy) < 130 && xx >-64.7 && xx <138.2)
633 iphisect = iphisecttmp;
637 if (iphisect != iphisecttmp)
continue;
648 tmpHOCalib.
momatho = hotrkdir2.mag();
649 tmpHOCalib.
hoang = CLHEP::Hep3Vector(zLocal.
x(),zLocal.
y(),zLocal.
z()).
dot(hotrkdir2.unit());
664 for (
int ij=0; ij<9; ij++) {tmpHOCalib.
hosig[ij]=-100.0;}
665 for (
int ij=0; ij<18; ij++) {tmpHOCalib.
hocorsig[ij]=-100.0;}
666 for (
int ij=0; ij<9; ij++) {tmpHOCalib.
hbhesig[ij]=-100.0;}
667 tmpHOCalib.
hocro = -100;
668 tmpHOCalib.
htime = -1000;
678 if (iphiho<0) isect -=2000000;
679 tmpHOCalib.
isect = isect;
691 if (
iring==1) {etamn=5; etamx = 10;}
692 if (
iring==2) {etamn=11; etamx = 16;}
693 if (
iring==-1){etamn=-10; etamx = -5;}
694 if (
iring==-2){etamn=-16; etamx = -11;}
699 phimx =2*
int((iphiho+1)/2.);
702 phimn = 3*
int((iphiho+1)/3.) - 1;
706 if (phimn <1) phimn +=
nphimx;
707 if (phimx >72) phimx -=
nphimx;
710 for (
int ij=0; ij<9; ij++) {tmpHOCalib.
hbhesig[ij]=-100.0;}
715 if (!(*hbheht).empty()) {
716 if((*hbheht).empty())
throw (
int)(*hbheht).size();
720 int tmpeta=
id.
ieta();
721 int tmpphi=
id.iphi();
723 int deta = tmpeta-ietaho;
724 if (tmpeta<0 && ietaho>0) deta += 1;
725 if (tmpeta>0 && ietaho<0) deta -= 1;
730 int dphi = tmpphi-iphiho;
740 float signal = (*jk).energy();
742 if (signal >-100 &&
Noccu == Noccu_old) {
743 for (
int ij=0; ij<5; ij++) {
752 if ( ipass2 ==0 )
continue;
754 float signal = (*jk).energy();
756 if (3*(deta+1)+dphi+1<9) tmpHOCalib.
hbhesig[3*(deta+1)+dphi+1] = signal;
764 if (!(*hoht).empty()) {
767 int tmpeta=
id.
ieta();
768 int tmpphi=
id.iphi();
771 if (tmpeta >=etamn && tmpeta <=etamx) {
773 ipass1 = (tmpphi >=phimn && tmpphi <=phimx ) ? 1 : 0;
775 ipass1 = (tmpphi==71 || tmpphi ==72 || tmpphi==1) ? 1 : 0;
779 int deta = tmpeta-ietaho;
780 int dphi = tmpphi -iphiho;
782 if (tmpeta<0 && ietaho>0) deta += 1;
783 if (tmpeta>0 && ietaho<0) deta -= 1;
794 float signal = (*jk).energy();
798 if (ipass1 ==0 && ipass2 ==0 )
continue;
801 int tmpdph = tmpphi-phimn;
802 if (tmpdph<0) tmpdph = 2;
804 int ilog = 2*(tmpeta-etamn)+tmpdph;
807 ilog = 3*(tmpeta-etamn)+tmpdph;
809 ilog = 3*(etamx-tmpeta)+tmpdph;
812 if (ilog>-1 && ilog<18) {
819 if (3*(deta+1)+dphi+1<9) {
820 tmpHOCalib.
hosig[3*(deta+1)+dphi+1] = signal;
824 if (deta==0 && dphi ==0) {
825 tmpHOCalib.
htime = (*jk).time();
826 tmpHOCalib.
hoflag = (*jk).flags();
831 int hitSeverity=hcalSevLvlComputer->
getSeverityLevel(
id, (*jk).flags(),theStatusValue);
832 tmpHOCalib.
hoflag = hitSeverity;
833 int crphi = tmpphi + 6;
834 if (crphi >72) crphi -=72;
839 int etacr= idcr.
ieta();
840 int phicr= idcr.
iphi();
841 if (tmpeta==etacr && crphi ==phicr) {
854 hostore->push_back(tmpHOCalib);
863 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};
864 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};
866 const double philow[6]={-76.27, -35.11, 0.35, 35.81, 71.77, 108.93};
867 const double phihgh[6]={-35.81, -0.35, 35.11, 71.07, 108.23, 140.49};
869 const double philow00[6]={-60.27, -32.91, 0.35, 33.61, 67.37, 102.23};
870 const double phihgh00[6]={-33.61, -0.35, 32.91, 66.67, 101.53, 129.49};
872 const double philow01[6]={-64.67, -34.91, 0.35, 35.61, 71.37, 108.33};
873 const double phihgh01[6]={-35.61, -0.35, 34.91, 70.67, 107.63, 138.19};
878 for (
int ij=0; ij<
netabin; ij++) {
879 if (tmpdy >etalow[ij] && tmpdy <etahgh[ij]) {
881 float tmp1 = fabs(tmpdy-etalow[ij]);
882 float tmp2 = fabs(tmpdy-etahgh[ij]);
888 if (ij>=4 && ij<10)
iring=1;
889 if (ij>=10 && ij<netabin)
iring=2;
898 for (
int ij=0; ij<6; ij++) {
901 float tmp1 = fabs(
xhor1-philow[ij]);
902 float tmp2 = fabs(
xhor1-phihgh[ij]);
908 for (
int ij=0; ij<6; ij++) {
909 if (
xhor1 >philow01[ij] &&
xhor1 <phihgh01[ij]) {
911 float tmp1 = fabs(
xhor1-philow01[ij]);
912 float tmp2 = fabs(
xhor1-phihgh01[ij]);
918 for (
int ij=0; ij<6; ij++) {
919 if (
xhor0 >philow00[ij] &&
xhor0 <phihgh00[ij]) {
921 float tmp1 = fabs(
xhor0-philow00[ij]);
922 float tmp2 = fabs(
xhor0-phihgh00[ij]);
930 for (
int ij=0; ij<4; ij++) {
931 if (tmpdy >etalow[ij] && tmpdy <etahgh[ij]) {
932 float tmp1 = fabs(tmpdy-etalow[ij]);
933 float tmp2 = fabs(tmpdy-etahgh[ij]);
943 iphiho = 6*iphisect -2 + tmpphi;
944 if (iphiho <=0) iphiho +=
nphimx;
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)