28 #include "Math/GenVector/VectorUtil.h"
29 #include "Math/GenVector/PxPyPzE4D.h"
59 const unsigned nLabels = pixelTracksSources_.size();
60 for (
unsigned i=0;
i != nLabels;
i++ )
61 toks_pix_.push_back(consumes<reco::TrackCollection>(pixelTracksSources_[
i]));
76 produces< reco::IsolatedPixelTrackCandidateCollection >();
89 const double rad (dynamic_cast<const EcalBarrelGeometry*>( pG->getSubdetectorGeometry(
DetId::Ecal,
EcalBarrel ))->avgRadiusXYFrontFaceCenter() ) ;
91 const double zz (dynamic_cast<const EcalEndcapGeometry*>( pG->getSubdetectorGeometry(
DetId::Ecal,
EcalEndcap ))->avgAbsZFrontFaceCenter() ) ;
103 std::vector<reco::TrackRef> pixelTrackRefs;
105 for (
unsigned int iPix=0; iPix<
toks_pix_.size(); iPix++)
109 for (reco::TrackCollection::const_iterator pit=iPixCol->begin(); pit!=iPixCol->end(); pit++)
111 pixelTrackRefs.push_back(
reco::TrackRef(iPixCol,pit-iPixCol->begin()));
121 double ptTriggered = -10;
122 double etaTriggered = -100;
123 double phiTriggered = -100;
128 std::vector< edm::Ref<l1extra::L1JetParticleCollection> > l1tauobjref;
129 std::vector< edm::Ref<l1extra::L1JetParticleCollection> > l1jetobjref;
130 std::vector< edm::Ref<l1extra::L1JetParticleCollection> > l1forjetobjref;
136 for (
unsigned int p=0;
p<l1tauobjref.size();
p++)
138 if (l1tauobjref[
p]->
pt()>ptTriggered)
140 ptTriggered = l1tauobjref[
p]->pt();
141 phiTriggered = l1tauobjref[
p]->phi();
142 etaTriggered = l1tauobjref[
p]->eta();
145 for (
unsigned int p=0;
p<l1jetobjref.size();
p++)
147 if (l1jetobjref[
p]->
pt()>ptTriggered)
149 ptTriggered = l1jetobjref[
p]->pt();
150 phiTriggered = l1jetobjref[
p]->phi();
151 etaTriggered = l1jetobjref[
p]->eta();
154 for (
unsigned int p=0;
p<l1forjetobjref.size();
p++)
156 if (l1forjetobjref[
p]->
pt()>ptTriggered)
158 ptTriggered=l1forjetobjref[
p]->pt();
159 phiTriggered=l1forjetobjref[
p]->phi();
160 etaTriggered=l1forjetobjref[
p]->eta();
170 for (
unsigned iSeed=0; iSeed<pixelTrackRefs.size(); iSeed++)
172 if(pixelTrackRefs[iSeed]->
p()<minPTrack_)
continue;
175 bool vtxMatch =
false;
178 reco::VertexCollection::const_iterator vitSel;
180 for (reco::VertexCollection::const_iterator vit=pVert->begin(); vit!=pVert->end(); vit++)
182 if (fabs(pixelTrackRefs[iSeed]->dz(vit->position()))<minDZ)
184 minDZ = fabs(pixelTrackRefs[iSeed]->dz(vit->position()));
189 if (minDZ!=100&&fabs(pixelTrackRefs[iSeed]->dxy(vitSel->position()))<
vtxCutSeed_) vtxMatch=
true;
190 if (minDZ==100) vtxMatch=
true;
193 double R=
deltaR(etaTriggered, phiTriggered, pixelTrackRefs[iSeed]->
eta(), pixelTrackRefs[iSeed]->
phi());
198 l1extra::L1JetParticleCollection::const_iterator selj;
199 for (l1extra::L1JetParticleCollection::const_iterator tj=l1eTauJets->begin(); tj!=l1eTauJets->end(); tj++)
201 if(ROOT::Math::VectorUtil::DeltaR(pixelTrackRefs[iSeed]->momentum(),tj->momentum()) > drMaxL1Track_)
continue;
207 std::pair<double,double> seedCooAtEC;
209 if (minDZ!=100) seedCooAtEC=
GetEtaPhiAtEcal(theEventSetup, pixelTrackRefs[iSeed]->
eta(), pixelTrackRefs[iSeed]->
phi(), pixelTrackRefs[iSeed]->
pt(), pixelTrackRefs[iSeed]->
charge(), vitSel->z());
211 else seedCooAtEC=
GetEtaPhiAtEcal(theEventSetup, pixelTrackRefs[iSeed]->
eta(), pixelTrackRefs[iSeed]->
phi(), pixelTrackRefs[iSeed]->
pt(), pixelTrackRefs[iSeed]->
charge(), 0);
216 for (
unsigned iSurr=0; iSurr<pixelTrackRefs.size(); iSurr++)
218 if(iSeed==iSurr)
continue;
220 if (
deltaR(seedCooAtEC.first, seedCooAtEC.second, pixelTrackRefs[iSurr]->eta(), pixelTrackRefs[iSurr]->phi())>
prelimCone_)
continue;
223 reco::VertexCollection::const_iterator vitSel2;
224 for (reco::VertexCollection::const_iterator vit=pVert->begin(); vit!=pVert->end(); vit++)
226 if (fabs(pixelTrackRefs[iSurr]->dz(vit->position()))<minDZ2)
228 minDZ2 = fabs(pixelTrackRefs[iSurr]->dz(vit->position()));
233 if (minDZ2!=100&&fabs(pixelTrackRefs[iSurr]->dxy(vitSel2->position()))>
vtxCutIsol_)
continue;
235 std::pair<double,double> cooAtEC;
237 if (minDZ2!=100) cooAtEC=
GetEtaPhiAtEcal(theEventSetup, pixelTrackRefs[iSurr]->
eta(), pixelTrackRefs[iSurr]->
phi(), pixelTrackRefs[iSurr]->
pt(), pixelTrackRefs[iSurr]->
charge(), vitSel2->z());
239 else cooAtEC=
GetEtaPhiAtEcal(theEventSetup, pixelTrackRefs[iSurr]->
eta(), pixelTrackRefs[iSurr]->
phi(), pixelTrackRefs[iSurr]->
pt(), pixelTrackRefs[iSurr]->
charge(), 0);
244 sumP+=pixelTrackRefs[iSurr]->p();
245 if(pixelTrackRefs[iSurr]->
p()>maxP) maxP=pixelTrackRefs[iSurr]->p();
249 if (tmatch||vtxMatch) good=
true;
254 trackCollection->push_back(newCandidate);
260 std::auto_ptr< reco::IsolatedPixelTrackCandidateCollection > outCollection(trackCollection);
261 theEvent.
put(outCollection);
269 double theta1=2*atan(
exp(-eta1));
270 double theta2=2*atan(
exp(-eta2));
271 if (fabs(eta1)<1.479) Rec=129;
272 else if (fabs(eta1)>1.479&&fabs(eta1)<7.0) Rec=
tan(theta1)*317;
277 if (angle<acos(-1)/2)
return fabs((Rec/
sin(theta1))*
tan(angle));
282 std::pair<double,double>
292 double bfVal=BField.
mag();
298 double Rcurv = 9999999;
299 if (bfVal!=0) Rcurv=pT*33.3*100/(bfVal*10);
301 double ecDist =
zEE_;
305 if (theta>0.5*acos(-1)) theta=acos(-1)-
theta;
308 if ((0.5*ecRad/Rcurv)>1)
315 deltaPhi =-charge*asin(0.5*ecRad/Rcurv);
316 double alpha1 = 2*asin(0.5*ecRad/Rcurv);
317 double z = ecRad/
tan(theta);
318 if (etaIP>0) zNew = z*(Rcurv*alpha1)/ecRad+vtxZ;
319 else zNew =-z*(Rcurv*alpha1)/ecRad+vtxZ;
320 double zAbs=fabs(zNew);
323 etaEC = -
log(
tan(0.5*atan(ecRad/zAbs)));
324 deltaPhi = -charge*asin(0.5*ecRad/Rcurv);
328 zAbs = (fabs(etaIP)/etaIP)*ecDist;
329 double Zflight = fabs(zAbs-vtxZ);
330 double alpha = (Zflight*ecRad)/(z*Rcurv);
331 double Rec = 2*Rcurv*
sin(alpha/2);
332 deltaPhi =-charge*alpha/2;
333 etaEC =-
log(
tan(0.5*atan(Rec/ecDist)));
339 zNew = (fabs(etaIP)/etaIP)*ecDist;
340 double Zflight = fabs(zNew-vtxZ);
341 double Rvirt = fabs(Zflight*
tan(theta));
342 double Rec = 2*Rcurv*
sin(Rvirt/(2*Rcurv));
343 deltaPhi =-(
charge)*(Rvirt/(2*Rcurv));
344 etaEC =-
log(
tan(0.5*atan(Rec/ecDist)));
347 if (zNew<0) etaEC=-etaEC;
350 if (phiEC<-acos(-1)) phiEC = 2*acos(-1)+phiEC;
351 if (phiEC>acos(-1)) phiEC =-2*acos(-1)+phiEC;
353 std::pair<double,double> retVal(etaEC,phiEC);
T getParameter(std::string const &) const
virtual void beginRun(const edm::Run &, const edm::EventSetup &) override
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Sin< T >::type sin(const T &t)
IsolatedPixelTrackCandidateProducer(const edm::ParameterSet &ps)
~IsolatedPixelTrackCandidateProducer()
Global3DPoint GlobalPoint
Geom::Theta< T > theta() const
std::vector< edm::EDGetTokenT< reco::TrackCollection > > toks_pix_
edm::EDGetTokenT< reco::VertexCollection > tok_vert_
std::vector< edm::InputTag > pixelTracksSources_
std::pair< double, double > GetEtaPhiAtEcal(const edm::EventSetup &iSetup, double etaIP, double phiIP, double pT, int charge, double vtxZ)
edm::EDGetTokenT< l1extra::L1JetParticleCollection > tok_l1_
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Cos< T >::type cos(const T &t)
Tan< T >::type tan(const T &t)
double maxPForIsolationValue_
std::vector< IsolatedPixelTrackCandidate > IsolatedPixelTrackCandidateCollection
collectin of IsolatedPixelTrackCandidate objects
GlobalVector inTesla(const GlobalPoint &g) const
Field value ad specified global point, in Tesla.
double deltaR(double eta1, double eta2, double phi1, double phi2)
double getDistInCM(double eta1, double phi1, double eta2, double phi2)
double pixelIsolationConeSizeAtEC_
virtual void produce(edm::Event &evt, const edm::EventSetup &es) override
edm::EDGetTokenT< trigger::TriggerFilterObjectWithRefs > tok_hlt_
T angle(T x1, T y1, T z1, T x2, T y2, T z2)