101 theTrackerGeometry = tGeometryHandle.
product();
104 std::vector<float> TTStubs_x;
105 std::vector<float> TTStubs_y;
106 std::vector<float> TTStubs_z;
107 std::vector<float> TTStubs_r;
108 std::vector<float> TTStubs_eta;
109 std::vector<float> TTStubs_phi;
110 std::vector<int> TTStubs_tpId;
114 std::vector<float> v_tp_pt;
115 std::vector<float> v_tp_eta;
116 std::vector<float> v_tp_phi;
117 std::vector<float> v_tp_nLayers;
120 if ( !TTStubHandle.
isValid() )
return;
123 for (inputIter = TTStubHandle->begin(); inputIter != TTStubHandle->end();++inputIter){
124 for (contentIter = inputIter->
begin(); contentIter != inputIter->
end(); ++contentIter){
127 DetId detIdStub = theTrackerGeometry->
idToDet((tempStubRef->getClusterRef(0))->getDetId())->geographicalId();
128 const MeasurementPoint& mp = (tempStubRef->getClusterRef(0))->findAverageLocalCoordinates();
129 const GeomDet* theGeomDet = theTrackerGeometry->
idToDet(detIdStub);
134 float stubs_x = posStub.
x();
135 float stubs_y = posStub.
y();
136 float stubs_z = posStub.
z();
137 float stubs_r = posStub.
perp();
138 float stubs_eta = posStub.
eta();
139 float stubs_phi = posStub.
phi();
140 TTStubs_x.push_back(stubs_x);
141 TTStubs_y.push_back(stubs_y);
142 TTStubs_z.push_back(stubs_z);
143 TTStubs_r.push_back(stubs_r);
144 TTStubs_eta.push_back(stubs_eta);
145 TTStubs_phi.push_back(stubs_phi);
148 TTStubs_tpId.push_back(-1);
151 bool genuineStub =
false;
152 if ( MCTruthTTStubHandle.
isValid() ) {
153 genuineStub = MCTruthTTStubHandle->isGenuine(tempStubPtr);
161 float px = tpPtr->
p4().px();
162 float py = tpPtr->
p4().py();
163 float pz = tpPtr->
p4().pz();
167 for (
auto it: *trackingParticleHandle){
169 float allowedRes = 0.001;
170 if (std::fabs(it.vx()-
x)>allowedRes)
continue;
171 if (std::fabs(it.vy()-
y)>allowedRes)
continue;
172 if (std::fabs(it.vz()-
z)>allowedRes)
continue;
173 if (std::fabs(it.px()-px)>allowedRes)
continue;
174 if (std::fabs(it.py()-py)>allowedRes)
continue;
175 if (std::fabs(it.pz()-pz)>allowedRes)
continue;
179 TTStubs_tpId.back() =
idx;
187 std::vector<TpStruct> TPStructs;
188 for (
unsigned j=0;j<TTStubs_tpId.size();j++){
189 const int ID = TTStubs_tpId[j];
193 for(
auto thisStruct: TPStructs){
194 if(ID == thisStruct.TpId) {
203 int totalLayers = 11;
204 std::vector<bool> layerElement(totalLayers,
false);
205 thisTPStruct.
layer=layerElement;
206 TPStructs.push_back(thisTPStruct);
207 pos=TPStructs.size()-1;
209 int l=
Layer( TTStubs_r[j],TTStubs_z[j] );
210 if (l>=0) TPStructs[pos].layer[
l] =
true;
215 for (
auto iterTP1: *trackingParticleHandle) {
216 v_tp_pt.push_back(iterTP1.pt());
217 v_tp_eta.push_back(iterTP1.eta());
218 v_tp_phi.push_back(iterTP1.phi());
219 v_tp_nLayers.push_back(-1);
224 for (
auto thisStruct: TPStructs){
225 int id = thisStruct.TpId;
226 v_tp_nLayers.at(
id-1) = thisStruct.Nlayers();
229 for (
unsigned j=0;j<v_tp_eta.size();j++) {
230 double trkParts_eta = v_tp_eta[j];
231 double trkParts_pt = v_tp_pt[j];
232 double trkParts_phi = v_tp_phi[j];
233 double trkParts_nLayers = v_tp_nLayers[j];
236 if (std::fabs(trkParts_eta)<2.4 && trkParts_pt>2 && trkParts_nLayers>=4) {
245 std::vector<float> trkParts_eta;
246 std::vector<float> trkParts_phi;
247 std::vector<float> trkParts_pt;
248 std::vector<float> trkParts_VtxZ;
249 std::vector<float> trkParts_d0;
250 std::vector<float> trkParts_VtxR;
251 std::vector<int> trkParts_pdgId;
252 std::vector<int> trkParts_nMatch;
253 std::vector<int> trkParts_nStub;
254 std::vector<int> trkParts_eventId;
255 std::vector<float> matchTrk_pt;
256 std::vector<float> matchTrk_eta;
257 std::vector<float> matchTrk_phi;
258 std::vector<float> matchTrk_VtxZ;
259 std::vector<float> matchTrk_d0;
260 std::vector<float> matchTrk_chi2;
261 std::vector<int> matchTrk_nStub;
264 if ( !TTTrackHandle.
isValid() )
return;
269 for (
auto iterTP: *trackingParticleHandle) {
273 int tmp_eventid = iterTP.eventId().event();
274 float tmp_tp_pt = iterTP.pt();
275 float tmp_tp_phi = iterTP.phi();
276 float tmp_tp_eta = iterTP.eta();
277 float tmp_tp_vz = iterTP.vz();
278 float tmp_tp_vx = iterTP.vx();
279 float tmp_tp_vy = iterTP.vy();
280 float tmp_tp_charge = tp_ptr->
charge();
281 int tmp_tp_pdgid = iterTP.pdgId();
285 float tmp_tp_t =
tan(2.0*atan(1.0)-2.0*atan(
exp(-tmp_tp_eta)));
286 float delx = -tmp_tp_vx;
287 float dely = -tmp_tp_vy;
288 float K = 0.01*0.5696 / tmp_tp_pt * tmp_tp_charge;
289 float A = 1./(2. * K);
290 float tmp_tp_x0p = delx - A*
sin(tmp_tp_phi);
291 float tmp_tp_y0p = dely + A*
cos(tmp_tp_phi);
292 float tmp_tp_rp =
sqrt(tmp_tp_x0p*tmp_tp_x0p + tmp_tp_y0p*tmp_tp_y0p);
293 static double pi = 4.0*atan(1.0);
294 float delphi = tmp_tp_phi-atan2(-K*tmp_tp_x0p,K*tmp_tp_y0p);
295 if (delphi<-pi) delphi+=2.0*
pi;
296 if (delphi>pi) delphi-=2.0*
pi;
298 float tmp_tp_VtxZ = tmp_tp_vz+tmp_tp_t*delphi/(2.0*K);
299 float VtxR =
sqrt(tmp_tp_vx*tmp_tp_vx + tmp_tp_vy*tmp_tp_vy);
300 float tmp_tp_VtxR = VtxR;
301 float tmp_tp_d0 = tmp_tp_charge*tmp_tp_rp - (1. / (2. * K));
304 float other_d0 = -tmp_tp_vx*
sin(tmp_tp_phi)+tmp_tp_vy*
cos(tmp_tp_phi);
305 tmp_tp_d0 = tmp_tp_d0*(-1);
307 tmp_tp_d0 = other_d0;
308 tmp_tp_VtxZ = tmp_tp_vz;
311 if ( MCTruthTTStubHandle.
isValid() ) {
312 std::vector< edm::Ref< edmNew::DetSetVector< TTStub< Ref_Phase2TrackerDigi_ > >,
TTStub< Ref_Phase2TrackerDigi_ > > > theStubRefs = MCTruthTTStubHandle->findTTStubRefs(tp_ptr);
313 nStubTP = (
int) theStubRefs.size();
318 if (tmp_eventid > 0)
continue;
319 if (std::fabs(tmp_tp_eta) >
TP_maxEta)
continue;
320 if (std::fabs(tmp_tp_VtxZ) >
TP_maxVtxZ)
continue;
324 if ( MCTruthTTClusterHandle.
isValid() ) {
325 if (MCTruthTTClusterHandle->findTTClusterRefs(tp_ptr).empty())
continue;
335 if (VtxR > 1.0)
continue;
341 if ( !MCTruthTTTrackHandle.
isValid() )
continue;
342 std::vector< edm::Ptr< TTTrack< Ref_Phase2TrackerDigi_ > > > matchedTracks = MCTruthTTTrackHandle->findTTTrackPtrs(tp_ptr);
346 float i_chi2dof = 99999;
353 for (
auto thisTrack: matchedTracks) {
354 bool tmp_trk_genuine =
false;
355 if (MCTruthTTTrackHandle->isGenuine(thisTrack)) tmp_trk_genuine =
true;
356 if (!tmp_trk_genuine)
continue;
360 int tmp_trk_nstub = thisTrack->getStubRefs().size();
362 float dmatch_pt = 999;
363 float dmatch_eta = 999;
364 float dmatch_phi = 999;
368 dmatch_pt = std::fabs(my_tp->
p4().pt() - tmp_tp_pt);
369 dmatch_eta = std::fabs(my_tp->
p4().eta() - tmp_tp_eta);
370 dmatch_phi = std::fabs(my_tp->
p4().phi() - tmp_tp_phi);
371 match_id = my_tp->
pdgId();
372 float tmp_trk_chi2dof = (thisTrack->getChi2(
L1Tk_nPar)) / (2*tmp_trk_nstub -
L1Tk_nPar);
375 if (dmatch_pt<0.1 && dmatch_eta<0.1 && dmatch_phi<0.1 && tmp_tp_pdgid==match_id) {
377 if (i_track < 0 || tmp_trk_chi2dof < i_chi2dof) {
378 i_track = trkCounter;
379 i_chi2dof = tmp_trk_chi2dof;
387 float tmp_matchtrk_pt = -999;
388 float tmp_matchtrk_eta = -999;
389 float tmp_matchtrk_phi = -999;
390 float tmp_matchtrk_VtxZ = -999;
391 float tmp_matchtrk_chi2 = -999;
392 float tmp_matchtrk_chi2R = -999;
393 int tmp_matchTrk_nStub = -999;
394 float tmp_matchtrk_d0 = -999;
397 tmp_matchtrk_pt = matchedTracks[i_track]->getMomentum(
L1Tk_nPar).perp();
398 tmp_matchtrk_eta = matchedTracks[i_track]->getMomentum(
L1Tk_nPar).eta();
399 tmp_matchtrk_phi = matchedTracks[i_track]->getMomentum(
L1Tk_nPar).phi();
400 tmp_matchtrk_VtxZ = matchedTracks[i_track]->getPOCA(
L1Tk_nPar).z();
401 tmp_matchtrk_chi2 = matchedTracks[i_track]->getChi2(
L1Tk_nPar);
402 tmp_matchtrk_chi2R = matchedTracks[i_track]->getChi2Red(
L1Tk_nPar);
403 tmp_matchTrk_nStub = (
int) matchedTracks[i_track]->getStubRefs().size();
409 float tmp_matchtrk_x0 = matchedTracks[i_track]->getPOCA(
L1Tk_nPar).x();
410 float tmp_matchtrk_y0 = matchedTracks[i_track]->getPOCA(
L1Tk_nPar).y();
411 tmp_matchtrk_d0 = -tmp_matchtrk_x0*
sin(tmp_matchtrk_phi) + tmp_matchtrk_y0*
cos(tmp_matchtrk_phi);
414 trkParts_pt.push_back(tmp_tp_pt);
415 trkParts_eta.push_back(tmp_tp_eta);
416 trkParts_phi.push_back(tmp_tp_phi);
417 trkParts_d0.push_back(tmp_tp_d0);
418 trkParts_VtxZ.push_back(tmp_tp_VtxZ);
420 trkParts_pdgId.push_back(tmp_tp_pdgid);
421 trkParts_VtxR.push_back(tmp_tp_VtxR);
422 trkParts_nMatch.push_back(nMatch);
423 trkParts_nStub.push_back(nStubTP);
424 trkParts_eventId.push_back(tmp_eventid);
426 matchTrk_pt .push_back(tmp_matchtrk_pt);
427 matchTrk_eta.push_back(tmp_matchtrk_eta);
428 matchTrk_phi.push_back(tmp_matchtrk_phi);
429 matchTrk_VtxZ .push_back(tmp_matchtrk_VtxZ);
430 matchTrk_d0 .push_back(tmp_matchtrk_d0);
432 matchTrk_chi2 .push_back(tmp_matchtrk_chi2);
433 matchTrk_nStub.push_back(tmp_matchTrk_nStub);
436 for (
unsigned j=0;j<trkParts_eta.size();j++) {
437 float eta = trkParts_eta[j];
438 float pt = trkParts_pt[j];
439 float VtxR = trkParts_VtxR[j];
440 float d0 = trkParts_d0[j];
441 float VtxZ = trkParts_VtxZ[j];
442 float eventId = trkParts_eventId[j];
446 if (VtxR > 1)
continue;
447 if (pt < 2)
continue;
449 if (std::fabs(eta) >
TP_maxEta)
continue;
450 if (trkParts_nMatch[j] < 1)
continue;
454 float chi2 = matchTrk_chi2[j];
455 int ndof = 2*matchTrk_nStub[j]-4;
456 float chi2dof = (
float)chi2/ndof;
471 res_pt->
Fill(matchTrk_pt[j] - trkParts_pt[j]);
472 res_ptRel->
Fill((matchTrk_pt[j] - trkParts_pt[j])/trkParts_pt[j]);
476 float pt_res = (matchTrk_pt[j] - trkParts_pt[j])/trkParts_pt[j];
477 float eta_res = matchTrk_eta[j] - trkParts_eta[j];
478 float phi_res = matchTrk_phi[j] - trkParts_phi[j];
479 float VtxZ_res = matchTrk_VtxZ[j] - trkParts_VtxZ[j];
480 float d0_res = matchTrk_d0[j] - trkParts_d0[j];
482 float tP_eta = trkParts_eta[j];
483 float tP_pt = trkParts_pt[j];
487 if (std::fabs(tP_eta) >= 0 && std::fabs(tP_eta) < 0.7){
496 else if (std::fabs(tP_eta) >= 0.7 && std::fabs(tP_eta) < 1.0){
505 else if (std::fabs(tP_eta) >= 1.0 && std::fabs(tP_eta) < 1.2){
514 else if (std::fabs(tP_eta) >= 1.2 && std::fabs(tP_eta) < 1.6){
523 else if (std::fabs(tP_eta) >= 1.6 && std::fabs(tP_eta) < 2.0){
532 else if (std::fabs(tP_eta) >= 2.0 && std::fabs(tP_eta) <= 2.4){
550 TTStubs_tpId.clear();
554 v_tp_nLayers.clear();
556 trkParts_eta.clear();
557 trkParts_phi.clear();
559 trkParts_VtxZ.clear();
560 trkParts_VtxR.clear();
561 trkParts_pdgId.clear();
562 trkParts_nMatch.clear();
563 trkParts_nStub.clear();
564 trkParts_eventId.clear();
566 matchTrk_eta.clear();
567 matchTrk_phi.clear();
569 matchTrk_VtxZ.clear();
570 matchTrk_chi2.clear();
571 matchTrk_nStub.clear();
582 HistoName =
"trackParts_Pt";
592 HistoName =
"trackParts_Eta";
602 HistoName =
"trackParts_Phi";
614 HistoName =
"Track_MatchedChi2";
624 HistoName =
"Track_MatchedChi2Red";
645 HistoName =
"match_tp_pt";
655 HistoName =
"tp_pt_zoom";
664 HistoName =
"match_tp_pt_zoom";
674 HistoName =
"tp_eta";
683 HistoName =
"match_tp_eta";
702 HistoName =
"match_tp_d0";
712 HistoName =
"tp_VtxR";
721 HistoName =
"match_tp_VtxR";
731 HistoName =
"tp_VtxZ";
740 HistoName =
"match_tp_VtxZ";
752 HistoName =
"res_pt";
762 HistoName =
"res_eta";
772 HistoName =
"res_ptRel";
782 HistoName =
"reseta_eta0to0p7";
791 HistoName =
"reseta_eta0p7to1";
800 HistoName =
"reseta_eta1to1p2";
809 HistoName =
"reseta_eta1p2to1p6";
818 HistoName =
"reseta_eta1p6to2";
827 HistoName =
"reseta_eta2to2p4";
838 HistoName =
"respt_eta0to0p7_pt2to3";
847 HistoName =
"respt_eta0p7to1_pt2to3";
856 HistoName =
"respt_eta1to1p2_pt2to3";
865 HistoName =
"respt_eta1p2to1p6_pt2to3";
874 HistoName =
"respt_eta1p6to2_pt2to3";
883 HistoName =
"respt_eta2to2p4_pt2to3";
893 HistoName =
"respt_eta0to0p7_pt3to8";
902 HistoName =
"respt_eta0p7to1_pt3to8";
911 HistoName =
"respt_eta1to1p2_pt3to8";
920 HistoName =
"respt_eta1p2to1p6_pt3to8";
929 HistoName =
"respt_eta1p6to2_pt3to8";
938 HistoName =
"respt_eta2to2p4_pt3to8";
948 HistoName =
"respt_eta0to0p7_pt8toInf";
957 HistoName =
"respt_eta0p7to1_pt8toInf";
966 HistoName =
"respt_eta1to1p2_pt8toInf";
975 HistoName =
"respt_eta1p2to1p6_pt8toInf";
984 HistoName =
"respt_eta1p6to2_pt8toInf";
993 HistoName =
"respt_eta2to2p4_pt8toInf";
1005 HistoName =
"resphi_eta0to0p7";
1014 HistoName =
"resphi_eta0p7to1";
1023 HistoName =
"resphi_eta1to1p2";
1032 HistoName =
"resphi_eta1p2to1p6";
1041 HistoName =
"resphi_eta1p6to2";
1050 HistoName =
"resphi_eta2to2p4";
1061 HistoName =
"resVtxZ_eta0to0p7";
1070 HistoName =
"resVtxZ_eta0p7to1";
1079 HistoName =
"resVtxZ_eta1to1p2";
1088 HistoName =
"resVtxZ_eta1p2to1p6";
1097 HistoName =
"resVtxZ_eta1p6to2";
1106 HistoName =
"resVtxZ_eta2to2p4";
1117 HistoName =
"resd0_eta0to0p7";
1126 HistoName =
"resd0_eta0p7to1";
1135 HistoName =
"resd0_eta1to1p2";
1144 HistoName =
"resd0_eta1p2to1p6";
1153 HistoName =
"resd0_eta1p6to2";
1162 HistoName =
"resd0_eta2to2p4";
1174 const int sectionNum = 6;
1175 const float Rmin[sectionNum]={20.,33.,48.,65.,82.,105.};
1176 const float Rmax[sectionNum]={30.,40.,58.,75.,91.,120.};
1177 const float zMin[sectionNum]={0.,125.,145.,165.,200.,240.};
1179 for (
int i=5;
i>=0;--
i){
1180 if(std::fabs(Z_)>=zMin[
i]){
1185 if(layer==5)
for(
unsigned i=0;
i<unsigned(sectionNum); ++
i){
1186 if(R_>Rmin[
i] && R_<Rmax[
i]){
const LorentzVector & p4() const
Four-momentum Lorentz vector. Note this is taken from the first SimTrack only.
MonitorElement * resd0_eta1to1p2
MonitorElement * match_tp_d0
GlobalPoint toGlobal(const Point2DBase< Scalar, LocalTag > lp) const
T getParameter(std::string const &) const
edm::Ref< typename HandleT::element_type, typename HandleT::element_type::value_type::value_type > makeRefTo(const HandleT &iHandle, typename HandleT::element_type::value_type::const_iterator itIter)
MonitorElement * match_tp_VtxR
MonitorElement * respt_eta2to2p4_pt8toInf
const_iterator end(bool update=false) const
MonitorElement * Track_MatchedChi2
MonitorElement * resVtxZ_eta1to1p2
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
MonitorElement * resVtxZ_eta1p6to2
edm::EDGetTokenT< std::vector< TrackingParticle > > trackingParticleToken_
std::vector< TrackingParticle > TrackingParticleCollection
edm::EDGetTokenT< edmNew::DetSetVector< TTStub< Ref_Phase2TrackerDigi_ > > > ttStubToken_
edm::EDGetTokenT< TTStubAssociationMap< Ref_Phase2TrackerDigi_ > > ttStubMCTruthToken_
MonitorElement * trackParts_Phi
bool getByToken(EDGetToken token, Handle< PROD > &result) const
MonitorElement * match_tp_pt
virtual const Topology & topology() const
MonitorElement * trackParts_Pt
#define DEFINE_FWK_MODULE(type)
std::vector< bool > layer
int pdgId() const
PDG ID.
Sin< T >::type sin(const T &t)
MonitorElement * respt_eta1p6to2_pt3to8
Geom::Phi< T > phi() const
MonitorElement * match_tp_eta
MonitorElement * reseta_eta1p6to2
~OuterTrackerMonitorTrackingParticles() override
MonitorElement * resd0_eta1p6to2
int Layer(const float R_, const float Z_) const
const Plane & surface() const
The nominal surface of the GeomDet.
MonitorElement * reseta_eta1to1p2
edm::EDGetTokenT< TTTrackAssociationMap< Ref_Phase2TrackerDigi_ > > ttTrackMCTruthToken_
MonitorElement * match_tp_VtxZ
MonitorElement * tp_pt_zoom
edm::EDGetTokenT< std::vector< TTTrack< Ref_Phase2TrackerDigi_ > > > ttTrackToken_
MonitorElement * respt_eta0to0p7_pt3to8
float charge() const
Electric charge. Note this is taken from the first SimTrack only.
MonitorElement * resphi_eta0to0p7
edm::EDGetTokenT< TTClusterAssociationMap< Ref_Phase2TrackerDigi_ > > ttClusterMCTruthToken_
MonitorElement * reseta_eta2to2p4
MonitorElement * respt_eta1to1p2_pt3to8
MonitorElement * respt_eta1to1p2_pt8toInf
Cos< T >::type cos(const T &t)
MonitorElement * resd0_eta1p2to1p6
MonitorElement * book1D(Args &&...args)
Tan< T >::type tan(const T &t)
MonitorElement * respt_eta1p2to1p6_pt2to3
MonitorElement * reseta_eta1p2to1p6
MonitorElement * resphi_eta0p7to1
MonitorElement * respt_eta0p7to1_pt8toInf
MonitorElement * resd0_eta2to2p4
MonitorElement * resVtxZ_eta0p7to1
MonitorElement * resphi_eta2to2p4
Class to store the L1 Track Trigger stubs.
MonitorElement * match_tp_pt_zoom
MonitorElement * resVtxZ_eta2to2p4
MonitorElement * respt_eta0p7to1_pt3to8
MonitorElement * respt_eta2to2p4_pt2to3
MonitorElement * resVtxZ_eta0to0p7
bool isNonnull() const
Checks for non-null.
MonitorElement * respt_eta1p2to1p6_pt8toInf
MonitorElement * respt_eta1p6to2_pt2to3
MonitorElement * resphi_eta1p2to1p6
void setCurrentFolder(const std::string &fullpath)
MonitorElement * reseta_eta0to0p7
MonitorElement * respt_eta0p7to1_pt2to3
MonitorElement * reseta_eta0p7to1
MonitorElement * resVtxZ_eta1p2to1p6
virtual LocalPoint localPosition(const MeasurementPoint &) const =0
std::string topFolderName_
MonitorElement * Track_MatchedChi2Red
void analyze(const edm::Event &, const edm::EventSetup &) override
Point vertex() const
Parent vertex position.
static std::atomic< unsigned int > counter
const TrackerGeomDet * idToDet(DetId) const override
MonitorElement * respt_eta0to0p7_pt2to3
MonitorElement * respt_eta1p6to2_pt8toInf
MonitorElement * respt_eta2to2p4_pt3to8
const double Rmax[kNumberCalorimeter]
MonitorElement * resd0_eta0p7to1
MonitorElement * respt_eta1to1p2_pt2to3
OuterTrackerMonitorTrackingParticles(const edm::ParameterSet &)
MonitorElement * resphi_eta1to1p2
void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)
T const * product() const
const double Rmin[kNumberCalorimeter]
const_iterator begin(bool update=false) const
MonitorElement * respt_eta1p2to1p6_pt3to8
MonitorElement * resphi_eta1p6to2
MonitorElement * respt_eta0to0p7_pt8toInf
MonitorElement * res_ptRel
MonitorElement * trackParts_Eta
MonitorElement * resd0_eta0to0p7