CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Private Types | Private Member Functions | Private Attributes
CTPPSFastTrackingProducer Class Reference

#include <FastSimulation/CTPPSFastTrackingProducer/plugins/CTPPSFastTrackingProducer.cc>

Inheritance diagram for CTPPSFastTrackingProducer:
edm::stream::EDProducer<>

Public Types

typedef CLHEP::HepLorentzVector LorentzVector
 
- Public Types inherited from edm::stream::EDProducer<>
typedef CacheContexts< T... > CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T... > HasAbility
 
typedef CacheTypes::LuminosityBlockCache LuminosityBlockCache
 
typedef LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 

Public Member Functions

 CTPPSFastTrackingProducer (const edm::ParameterSet &)
 
 ~CTPPSFastTrackingProducer () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
bool hasAbilityToProduceInLumis () const final
 
bool hasAbilityToProduceInRuns () const final
 

Private Types

typedef std::vector< CTPPSFastRecHitCTPPSFastRecHitContainer
 

Private Member Functions

virtual void beginEvent (edm::Event &event, const edm::EventSetup &eventSetup)
 
void beginStream (edm::StreamID) override
 
virtual void endEvent (edm::Event &event, const edm::EventSetup &eventSetup)
 
void endStream () override
 
void FastReco (int Direction, H_RecRPObject *station)
 
void Get_t_and_xi (const LorentzVector *p, double &t, double &xi)
 
void LorentzBoost (LorentzVector &p_out, const string &frame)
 
void MatchCellId (int cellId, vector< int > vrecCellId, vector< double > vrecTof, bool &match, double &recTof)
 
void produce (edm::Event &, const edm::EventSetup &) override
 
void ProjectToToF (const double x1, const double y1, const double x2, const double y2, double &xt, double &yt)
 
void ReadRecHits (edm::Handle< CTPPSFastRecHitContainer > &)
 
void ReconstructArm (H_RecRPObject *pps_station, double x1, double y1, double x2, double y2, double &tx, double &ty, double &eloss)
 
void Reconstruction ()
 
bool SearchTrack (int, int, int Direction, double &xi, double &t, double &partP, double &pt, double &thx, double &thy, double &x0, double &y0, double &xt, double &yt, double &X1d, double &Y1d, double &X2d, double &Y2d)
 
void TrackerStationClear ()
 
void TrackerStationStarting ()
 

Private Attributes

edm::EDGetTokenT< CTPPSFastRecHitContainer_recHitToken
 
string beam1filename
 
string beam2filename
 
std::unique_ptr< CTPPSTrkDetectordet1B
 
std::unique_ptr< CTPPSTrkDetectordet1F
 
std::unique_ptr< CTPPSTrkDetectordet2B
 
std::unique_ptr< CTPPSTrkDetectordet2F
 
std::unique_ptr< CTPPSToFDetectordetToF_B
 
std::unique_ptr< CTPPSToFDetectordetToF_F
 
double fBeamEnergy
 
double fBeamMomentum
 
double fBeamXRMS_ToF
 
double fBeamXRMS_Trk1
 
double fBeamXRMS_Trk2
 
bool fCrossAngleCorr
 
double fCrossingAngle
 
double fImpParcut
 
double fTimeSigma
 
double fToFCellHeight
 
std::vector< double > fToFCellWidth
 
double fToFInsertion
 
int fToFNCellX
 
int fToFNCellY
 
double fToFPitchX
 
double fToFPitchY
 
double fToFXOffset
 
double fTrackerHeight
 
double fTrackerInsertion
 
double fTrackerWidth
 
double fTrk1XOffset
 
double fTrk2XOffset
 
double fz_timing
 
double fz_tracker1
 
double fz_tracker2
 
double lengthctpps
 
std::unique_ptr< H_BeamLine > m_beamlineCTPPS1
 
std::unique_ptr< H_BeamLine > m_beamlineCTPPS2
 
std::map< unsigned int, H_BeamParticle * > m_beamPart
 
bool m_verbosity
 
std::unique_ptr< H_RecRPObject > pps_stationB
 
std::unique_ptr< H_RecRPObject > pps_stationF
 
std::vector< int > recCellId_B
 
std::vector< int > recCellId_F
 
std::vector< double > recTof_B
 
std::vector< double > recTof_F
 
std::vector< CTPPSFastTracktheCTPPSFastTrack
 
CTPPSFastTrack track
 
std::unique_ptr< CTPPSTrkStationTrkStation_B
 
std::unique_ptr< CTPPSTrkStationTrkStation_F
 

Detailed Description

Description: [one line class summary]

Implementation: [Notes on implementation]

Definition at line 63 of file CTPPSFastTrackingProducer.h.

Member Typedef Documentation

Definition at line 79 of file CTPPSFastTrackingProducer.h.

typedef CLHEP::HepLorentzVector CTPPSFastTrackingProducer::LorentzVector

Definition at line 67 of file CTPPSFastTrackingProducer.h.

Constructor & Destructor Documentation

CTPPSFastTrackingProducer::CTPPSFastTrackingProducer ( const edm::ParameterSet iConfig)
explicit

Definition at line 30 of file CTPPSFastTrackingProducer.cc.

References _recHitToken, beam1filename, beam2filename, det1B, det1F, det2B, det2F, detToF_B, detToF_F, fBeamEnergy, fBeamMomentum, fBeamXRMS_ToF, fBeamXRMS_Trk1, fBeamXRMS_Trk2, fCrossAngleCorr, fCrossingAngle, fImpParcut, fTimeSigma, fToFCellHeight, fToFCellWidth, fToFInsertion, fToFNCellX, fToFNCellY, fToFPitchX, fToFPitchY, fToFXOffset, fTrackerHeight, fTrackerInsertion, fTrackerWidth, fTrk1XOffset, fTrk2XOffset, fz_timing, fz_tracker1, fz_tracker2, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), mps_fire::i, lengthctpps, LogDebug, m_beamlineCTPPS1, m_beamlineCTPPS2, m_verbosity, pps_stationB, pps_stationF, ProtonMassSQ, and mathSSE::sqrt().

30  :
32 {
33  //register your products
34  produces<edm::CTPPSFastTrackContainer>("CTPPSFastTrack");
35  using namespace edm;
36  _recHitToken = consumes<CTPPSFastRecHitContainer>(iConfig.getParameter<edm::InputTag>("recHitTag"));
37  m_verbosity = iConfig.getParameter<bool>("Verbosity");
38  // User definitons
39 
40  // Read beam parameters needed for Hector reconstruction
41  lengthctpps = iConfig.getParameter<double>("BeamLineLengthCTPPS" );
42  beam1filename = iConfig.getParameter<string>("Beam1");
43  beam2filename = iConfig.getParameter<string>("Beam2");
44  fBeamEnergy = iConfig.getParameter<double>("BeamEnergy"); // beam energy in GeV
46  fCrossAngleCorr = iConfig.getParameter<bool>("CrossAngleCorr");
47  fCrossingAngle = iConfig.getParameter<double>("CrossingAngle");
48 
49  //Read detectors positions and parameters
50 
51  fz_tracker1 = iConfig.getParameter<double>("Z_Tracker1");
52  fz_tracker2 = iConfig.getParameter<double>("Z_Tracker2");
53  fz_timing = iConfig.getParameter<double>("Z_Timing");
54  //
55  fTrackerWidth = iConfig.getParameter<double>("TrackerWidth");
56  fTrackerHeight = iConfig.getParameter<double>("TrackerHeight");
57  fTrackerInsertion = iConfig.getParameter<double>("TrackerInsertion");
58  fBeamXRMS_Trk1 = iConfig.getParameter<double>("BeamXRMS_Trk1");
59  fBeamXRMS_Trk2 = iConfig.getParameter<double>("BeamXRMS_Trk2");
60  fTrk1XOffset = iConfig.getParameter<double>("Trk1XOffset");
61  fTrk2XOffset = iConfig.getParameter<double>("Trk2XOffset");
62  fToFCellWidth = iConfig.getUntrackedParameter<std::vector<double> >("ToFCellWidth");
63  fToFCellHeight = iConfig.getParameter<double>("ToFCellHeight");
64  fToFPitchX = iConfig.getParameter<double>("ToFPitchX");
65  fToFPitchY = iConfig.getParameter<double>("ToFPitchY");
66  fToFNCellX = iConfig.getParameter<int>("ToFNCellX");
67  fToFNCellY = iConfig.getParameter<int>("ToFNCellY");
68  fToFInsertion = iConfig.getParameter<double>("ToFInsertion");
69  fBeamXRMS_ToF = iConfig.getParameter<double>("BeamXRMS_ToF");
70  fToFXOffset = iConfig.getParameter<double>("ToFXOffset");
71  fTimeSigma = iConfig.getParameter<double>("TimeSigma");
72  fImpParcut = iConfig.getParameter<double>("ImpParcut");
73 
74 
75 
76  // reading beamlines
77  FileInPath b1(beam1filename.c_str());
78  FileInPath b2(beam2filename.c_str());
79  //
80  if(lengthctpps>0. ) {
81  m_beamlineCTPPS1 = std::unique_ptr<H_BeamLine>(new H_BeamLine( -1, lengthctpps + 0.1 )); // (direction, length)
82  m_beamlineCTPPS2 = std::unique_ptr<H_BeamLine>(new H_BeamLine( 1, lengthctpps + 0.1 )); //
83  m_beamlineCTPPS1->fill( b2.fullPath(), 1, "IP5" );
84  m_beamlineCTPPS2->fill( b1.fullPath(), 1, "IP5" );
85  m_beamlineCTPPS1->offsetElements( 120, 0.097 );
86  m_beamlineCTPPS2->offsetElements( 120, 0.097 );
87  m_beamlineCTPPS1->calcMatrix();
88  m_beamlineCTPPS2->calcMatrix();
89  } else {
90  if ( m_verbosity ) LogDebug("CTPPSFastTrackingProducer") << "CTPPSFastTrackingProducer: WARNING: lengthctpps= " << lengthctpps;
91  }
92 
93  // Create a particle to get the beam energy from the beam file
94  // Take care: the z inside the station is in meters
95  pps_stationF = std::unique_ptr<H_RecRPObject>(new H_RecRPObject(fz_tracker1,fz_tracker2,*m_beamlineCTPPS1));
96  pps_stationB = std::unique_ptr<H_RecRPObject>(new H_RecRPObject(fz_tracker1,fz_tracker2,*m_beamlineCTPPS2));
97  //
98  //Tracker Detector Description
103 
104  //Timing Detector Description
105  std::vector<double> vToFCellWidth;
106  for (int i = 0 ; i < 8 ; i++){
107  vToFCellWidth.push_back(fToFCellWidth[i]);
108  }
109  double pos_tof = fToFInsertion*fBeamXRMS_ToF+fToFXOffset;
110  detToF_F =std::unique_ptr<CTPPSToFDetector>(new CTPPSToFDetector(fToFNCellX,fToFNCellY,vToFCellWidth,fToFCellHeight,fToFPitchX,fToFPitchY,pos_tof,fTimeSigma));
111  detToF_B =std::unique_ptr<CTPPSToFDetector>(new CTPPSToFDetector(fToFNCellX,fToFNCellY,vToFCellWidth,fToFCellHeight,fToFPitchX,fToFPitchY,pos_tof,fTimeSigma));
112 
113 }
#define LogDebug(id)
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
std::unique_ptr< CTPPSTrkDetector > det2B
std::unique_ptr< H_BeamLine > m_beamlineCTPPS1
std::unique_ptr< H_RecRPObject > pps_stationB
std::unique_ptr< CTPPSToFDetector > detToF_F
std::unique_ptr< CTPPSTrkDetector > det2F
std::unique_ptr< H_RecRPObject > pps_stationF
std::unique_ptr< CTPPSTrkDetector > det1B
T sqrt(T t)
Definition: SSEVec.h:18
std::unique_ptr< CTPPSToFDetector > detToF_B
std::unique_ptr< H_BeamLine > m_beamlineCTPPS2
const double ProtonMassSQ
edm::EDGetTokenT< CTPPSFastRecHitContainer > _recHitToken
std::unique_ptr< CTPPSTrkDetector > det1F
HLT enums.
CTPPSFastTrackingProducer::~CTPPSFastTrackingProducer ( )
override

Definition at line 114 of file CTPPSFastTrackingProducer.cc.

References m_beamPart.

115 {
116  for (std::map<unsigned int,H_BeamParticle*>::iterator it = m_beamPart.begin(); it != m_beamPart.end(); ++it ) {
117  delete (*it).second;
118  }
119 }
std::map< unsigned int, H_BeamParticle * > m_beamPart

Member Function Documentation

void CTPPSFastTrackingProducer::beginEvent ( edm::Event event,
const edm::EventSetup eventSetup 
)
privatevirtual

Definition at line 146 of file CTPPSFastTrackingProducer.cc.

References TrackerStationStarting().

147 {
148 
150 
151 }
void CTPPSFastTrackingProducer::beginStream ( edm::StreamID  )
overrideprivate

Definition at line 435 of file CTPPSFastTrackingProducer.cc.

436 {
437 }
void CTPPSFastTrackingProducer::endEvent ( edm::Event event,
const edm::EventSetup eventSetup 
)
privatevirtual

Definition at line 153 of file CTPPSFastTrackingProducer.cc.

References TrackerStationClear().

154 {
156 
157 }
void CTPPSFastTrackingProducer::endStream ( )
overrideprivate

Definition at line 441 of file CTPPSFastTrackingProducer.cc.

References DEFINE_FWK_MODULE.

442 {
443 }
void CTPPSFastTrackingProducer::FastReco ( int  Direction,
H_RecRPObject *  station 
)
private

Definition at line 348 of file CTPPSFastTrackingProducer.cc.

References funct::cos(), MillePedeFileConverter_cfg::e, fBeamXRMS_ToF, fCrossAngleCorr, CTPPSToFDetector::findCellId(), fTimeSigma, fToFCellHeight, fToFCellWidth, fToFInsertion, fToFNCellX, fToFNCellY, fToFPitchX, fToFPitchY, fToFXOffset, Get_t_and_xi(), mps_fire::i, createfilelist::int, LorentzBoost(), MatchCellId(), AlCaHLTBitMon_ParallelJobs::p, phi, pi, CTPPSTrkDetector::ppsNHits_, ProtonMassSQ, EnergyCorrector::pt, recCellId_B, recCellId_F, recTof_B, recTof_F, SearchTrack(), CTPPSFastTrack::setcellid(), CTPPSFastTrack::setp(), CTPPSFastTrack::sett(), CTPPSFastTrack::settof(), CTPPSFastTrack::setvertex(), CTPPSFastTrack::setx1(), CTPPSFastTrack::setx2(), CTPPSFastTrack::setxi(), CTPPSFastTrack::sety1(), CTPPSFastTrack::sety2(), funct::sin(), mathSSE::sqrt(), lumiQTWidget::t, theCTPPSFastTrack, theta(), track, TrkStation_B, TrkStation_F, urad, and hybridSuperClusters_cfi::xi.

Referenced by Reconstruction().

349 {
350  double theta = 0.;
351  double xi,t,partP,pt,phi,x0,y0,thx,thy,xt,yt,X1d,Y1d,X2d,Y2d;
352  CTPPSTrkDetector* Trk1 = nullptr;
353  CTPPSTrkDetector* Trk2 = nullptr;
354  double pos_tof = fToFInsertion*fBeamXRMS_ToF+fToFXOffset;
355  int cellId = 0;
356  std::vector<double> vToFCellWidth;
357  for (int i = 0 ; i < 8 ; i++){
358  vToFCellWidth.push_back(fToFCellWidth[i]);
359  }
361  if (Direction>0) {
362  Trk1=&(TrkStation_F->first);Trk2=&(TrkStation_F->second);
363  } else {
364  Trk1=&(TrkStation_B->first);Trk2=&(TrkStation_B->second);
365  }
366  // Make a track from EVERY pair of hits combining Tracker1 and Tracker2.
367  // The tracks may not be independent as 1 hit may belong to more than 1 track.
368  for(int i=0;i<(int)Trk1->ppsNHits_;i++) {
369  for(int j=0;j<(int)Trk2->ppsNHits_;j++){
370  if (SearchTrack(i,j,Direction,xi,t,partP,pt,thx,thy,x0,y0,xt,yt,X1d,Y1d,X2d,Y2d)) {
371  // Check if the hitted timing cell matches the reconstructed track
372  cellId = ToF->findCellId(xt,yt);
373  double recTof = 0.;
374  bool matchCellId = false;
375  if (Direction > 0 ) {
376  theta = sqrt(thx*thx+thy*thy)*urad;
377  MatchCellId(cellId, recCellId_F, recTof_F, matchCellId, recTof);
378  }
379  else if (Direction<0) {
380  theta = CLHEP::pi - sqrt(thx*thx+thy*thy)*urad;
381  MatchCellId(cellId, recCellId_B, recTof_B, matchCellId, recTof);
382  }
383  phi = (Direction>0)?-atan2(thy,-thx):atan2(thy,thx); // defined according to the positive direction
384 
385 
386  double px = partP*sin(theta)*cos(phi);
387  double py = partP*sin(theta)*sin(phi);
388  double pz = partP*cos(theta);
389  double e = sqrt(partP*partP+ProtonMassSQ);
390  LorentzVector p(px,py,pz,e);
391  // Invert the Lorentz boost made to take into account the crossing angle during simulation
392  if (fCrossAngleCorr) LorentzBoost(p,"MC");
393  //Getting the Xi and t (squared four momentum transferred) of the reconstructed track
394  Get_t_and_xi(const_cast<LorentzVector*>(&p),t,xi);
395  double pxx = p.px(); double pyy = p.py(); double pzz = p.pz(); //double ee = p.E();
396  math::XYZVector momentum (pxx,pyy,pzz);
397  math::XYZPoint vertex (x0,y0,0);
398 
399  track.setp(momentum);
400  track.setvertex(vertex);
401  track.sett(t);
402  track.setxi(xi);
403  track.setx1(X1d);
404  track.sety1(Y1d);
405  track.setx2(X2d);
406  track.sety2(Y2d);
407  if (matchCellId) {
408  track.setcellid(cellId);
409  track.settof(recTof);
410  }
411  else {
412  track.setcellid(0);
413  track.settof(0.);
414  }
415  theCTPPSFastTrack.push_back(track);
416  }
417  }
418  }
419 }//end FastReco
void sett(float t)
void MatchCellId(int cellId, vector< int > vrecCellId, vector< double > vrecTof, bool &match, double &recTof)
int findCellId(double x, double y)
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
Geom::Theta< T > theta() const
void setvertex(const Point &vertex)
void sety1(float y1)
void setx2(float x2)
const Double_t pi
void setp(const Vector &momentum)
void setx1(float x1)
T sqrt(T t)
Definition: SSEVec.h:18
std::unique_ptr< CTPPSTrkStation > TrkStation_B
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
void setxi(float xi)
math::XYZTLorentzVector LorentzVector
const double ProtonMassSQ
void Get_t_and_xi(const LorentzVector *p, double &t, double &xi)
std::unique_ptr< CTPPSTrkStation > TrkStation_F
std::vector< CTPPSFastTrack > theCTPPSFastTrack
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:30
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
void settof(float tof)
void sety2(float y2)
void LorentzBoost(LorentzVector &p_out, const string &frame)
const double urad
void setcellid(unsigned int cellid)
bool SearchTrack(int, int, int Direction, double &xi, double &t, double &partP, double &pt, double &thx, double &thy, double &x0, double &y0, double &xt, double &yt, double &X1d, double &Y1d, double &X2d, double &Y2d)
void CTPPSFastTrackingProducer::Get_t_and_xi ( const LorentzVector p,
double &  t,
double &  xi 
)
private

Definition at line 421 of file CTPPSFastTrackingProducer.cc.

References funct::cos(), fBeamEnergy, fBeamMomentum, pi, ProtonMassSQ, mathSSE::sqrt(), and theta().

Referenced by FastReco().

421  {
422  t = 0.;
423  xi = -1.;
424  if (!proton) return;
425  double mom = sqrt((proton->px())*(proton->px())+(proton->py())*(proton->py())+(proton->pz())*(proton->pz()));
426  if (mom>fBeamMomentum) mom=fBeamMomentum;
427  double energy = proton->e();
428  double theta = (proton->pz()>0)?proton->theta():CLHEP::pi-proton->theta();
429  t = -2.*(ProtonMassSQ-fBeamEnergy*energy+fBeamMomentum*mom*cos(theta));
430  xi = (1.0-energy/fBeamEnergy);
431 }
Geom::Theta< T > theta() const
const Double_t pi
T sqrt(T t)
Definition: SSEVec.h:18
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
const double ProtonMassSQ
void CTPPSFastTrackingProducer::LorentzBoost ( LorentzVector p_out,
const string &  frame 
)
private

Definition at line 299 of file CTPPSFastTrackingProducer.cc.

References funct::cos(), fCrossingAngle, p4, funct::sin(), and funct::tan().

Referenced by FastReco().

300 {
301  // Use a matrix
302  double microrad = 1.e-6;
303  TMatrixD tmpboost(4,4);
304  double alpha_ = 0.;
305  double phi_ = fCrossingAngle*microrad;
306  if (p_out.pz()<0) phi_*=-1;
307  tmpboost(0,0) = 1./cos(phi_);
308  tmpboost(0,1) = - cos(alpha_)*sin(phi_);
309  tmpboost(0,2) = - tan(phi_)*sin(phi_);
310  tmpboost(0,3) = - sin(alpha_)*sin(phi_);
311  tmpboost(1,0) = - cos(alpha_)*tan(phi_);
312  tmpboost(1,1) = 1.;
313  tmpboost(1,2) = cos(alpha_)*tan(phi_);
314  tmpboost(1,3) = 0.;
315  tmpboost(2,0) = 0.;
316  tmpboost(2,1) = - cos(alpha_)*sin(phi_);
317  tmpboost(2,2) = cos(phi_);
318  tmpboost(2,3) = - sin(alpha_)*sin(phi_);
319  tmpboost(3,0) = - sin(alpha_)*tan(phi_);
320  tmpboost(3,1) = 0.;
321  tmpboost(3,2) = sin(alpha_)*tan(phi_);
322  tmpboost(3,3) = 1.;
323 
324  if(frame=="LAB") tmpboost.Invert();
325 
326  TMatrixD p4(4,1);
327  p4(0,0) = p_out.e();
328  p4(1,0) = p_out.px();
329  p4(2,0) = p_out.py();
330  p4(3,0) = p_out.pz();
331  TMatrixD p4lab(4,1);
332  p4lab = tmpboost * p4;
333  p_out.setPx(p4lab(1,0));
334  p_out.setPy(p4lab(2,0));
335  p_out.setPz(p4lab(3,0));
336  p_out.setE(p4lab(0,0));
337 }
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
double p4[4]
Definition: TauolaWrapper.h:92
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
void CTPPSFastTrackingProducer::MatchCellId ( int  cellId,
vector< int >  vrecCellId,
vector< double >  vrecTof,
bool &  match,
double &  recTof 
)
private

Definition at line 338 of file CTPPSFastTrackingProducer.cc.

References mps_fire::i.

Referenced by FastReco().

338  {
339  for (unsigned int i = 0 ; i < vrecCellId.size(); i++){
340  if(cellId == vrecCellId.at(i)) {
341  match = true;
342  recTof = vrecTof.at(i);
343  continue;
344  }
345  }
346 }
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
Definition: Utils.h:10
void CTPPSFastTrackingProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivate

Definition at line 122 of file CTPPSFastTrackingProducer.cc.

References _recHitToken, edm::Event::getByToken(), mps_fire::i, eostools::move(), gen::n, edm::Event::put(), ReadRecHits(), recCellId_B, recCellId_F, Reconstruction(), recTof_B, recTof_F, theCTPPSFastTrack, TrackerStationClear(), and TrackerStationStarting().

Referenced by JSONExport.JsonExport::export(), HTMLExport.HTMLExport::export(), and HTMLExport.HTMLExportStatic::export().

123 {
124  using namespace edm;
125  //using namespace std;
128  iEvent.getByToken( _recHitToken,recHits);
129  recCellId_F.clear(); recCellId_B.clear();
130  recTof_F.clear(); recTof_B.clear();
131  ReadRecHits(recHits);
132  Reconstruction();
134 
135  std::unique_ptr<CTPPSFastTrackContainer> output_tracks(new CTPPSFastTrackContainer);
136  int n = 0;
137  for ( std::vector<CTPPSFastTrack>::const_iterator i = theCTPPSFastTrack.begin();
138  i != theCTPPSFastTrack.end(); i++ ) {
139  output_tracks->push_back(*i);
140  n += 1;
141  }
142 
143  iEvent.put(std::move(output_tracks),"CTPPSFastTrack");
144 
145 }//end
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:137
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:579
std::vector< CTPPSFastTrack > theCTPPSFastTrack
edm::EDGetTokenT< CTPPSFastRecHitContainer > _recHitToken
HLT enums.
std::vector< CTPPSFastTrack > CTPPSFastTrackContainer
void ReadRecHits(edm::Handle< CTPPSFastRecHitContainer > &)
def move(src, dest)
Definition: eostools.py:511
void CTPPSFastTrackingProducer::ProjectToToF ( const double  x1,
const double  y1,
const double  x2,
const double  y2,
double &  xt,
double &  yt 
)
inlineprivate
void CTPPSFastTrackingProducer::ReadRecHits ( edm::Handle< CTPPSFastRecHitContainer > &  recHits)
private

Definition at line 181 of file CTPPSFastTrackingProducer.cc.

References det1B, det1F, det2B, det2F, detToF_B, detToF_F, CTPPSFastRecHit::detUnitId(), CTPPSFastRecHit::entryPoint(), recCellId_B, recCellId_F, recHitDet(), recTof_B, recTof_F, CTPPSFastRecHit::tof(), TrkStation_B, TrkStation_F, x, PV3DBase< T, PVType, FrameType >::x(), y, PV3DBase< T, PVType, FrameType >::y(), z, and PV3DBase< T, PVType, FrameType >::z().

Referenced by produce().

182 {
183  // DetId codification for PSimHit taken from CTPPSPixel- It will be replaced by CTPPSDetId
184  // 2014314496 -> Tracker1 zPositive
185  // 2014838784 -> Tracker2 zPositive
186  // 2046820352 -> Timing zPositive
187  // 2031091712 -> Tracker1 zNegative
188  // 2031616000 -> Tracker2 zNegative
189  // 2063597568 -> Timing zNegative
190 
191  for (unsigned int irecHits = 0; irecHits < recHits->size(); ++irecHits)
192  {
193  const CTPPSFastRecHit* recHitDet = &(*recHits)[irecHits];
194  unsigned int detlayerId = recHitDet->detUnitId();
195  double x = recHitDet->entryPoint().x();
196  double y = recHitDet->entryPoint().y();
197  double z = recHitDet->entryPoint().z();
198  float tof = recHitDet->tof();
199  if(detlayerId == 2014314496) det1F->AddHit(detlayerId,x,y,z);
200  else if(detlayerId == 2014838784) det2F->AddHit(detlayerId,x,y,z);
201  else if(detlayerId == 2031091712) det1B->AddHit(detlayerId,x,y,z);
202  else if(detlayerId == 2031616000) det2B->AddHit(detlayerId,x,y,z);
203  else if(detlayerId == 2046820352) { detToF_F->AddHit(x,y,tof); recCellId_F.push_back(detToF_F->findCellId(x,y)); recTof_F.push_back(tof); }
204  else if(detlayerId == 2063597568) { detToF_B->AddHit(x,y,tof); recCellId_B.push_back(detToF_B->findCellId(x,y)); recTof_B.push_back(tof); }
205 
206  }//LOOP TRK
207  //creating Stations
208  TrkStation_F = std::unique_ptr<CTPPSTrkStation>(new std::pair<CTPPSTrkDetector,CTPPSTrkDetector>(*det1F,*det2F));
209  TrkStation_B = std::unique_ptr<CTPPSTrkStation>(new std::pair<CTPPSTrkDetector,CTPPSTrkDetector>(*det1B,*det2B));
210 } // end function
std::unique_ptr< CTPPSTrkDetector > det2B
T y() const
Definition: PV3DBase.h:63
std::unique_ptr< CTPPSToFDetector > detToF_F
float tof() const
deprecated name for timeOfFlight()
std::unique_ptr< CTPPSTrkDetector > det2F
std::unique_ptr< CTPPSTrkDetector > det1B
unsigned int detUnitId() const
T z() const
Definition: PV3DBase.h:64
std::unique_ptr< CTPPSTrkStation > TrkStation_B
std::unique_ptr< CTPPSToFDetector > detToF_B
std::unique_ptr< CTPPSTrkStation > TrkStation_F
const GeomDet * recHitDet(const TrackingRecHit &hit, const TrackingGeometry *geom)
Local3DPoint entryPoint() const
Entry point in the local Det frame.
std::unique_ptr< CTPPSTrkDetector > det1F
T x() const
Definition: PV3DBase.h:62
void CTPPSFastTrackingProducer::ReconstructArm ( H_RecRPObject *  pps_station,
double  x1,
double  y1,
double  x2,
double  y2,
double &  tx,
double &  ty,
double &  eloss 
)
private

Definition at line 280 of file CTPPSFastTrackingProducer.cc.

References edm::detail::isnan(), and mm_to_um.

Referenced by SearchTrack().

281 {
282  tx=0.;
283  ty=0.;
284  eloss=0.;
285  if (!pps_station) return;
286  // Change the orientation and units according to Hector and LHC coordinates
287  x1*=-mm_to_um;
288  x2*=-mm_to_um;
289  y1*= mm_to_um;
290  y2*= mm_to_um;
291  pps_station->setPositions(x1,y1,x2,y2);
292  double energy = pps_station->getE(AM); // dummy call needed to calculate some Hector internal parameter
293  if (std::isnan(energy)||std::isinf(energy)) return;
294  tx = -pps_station->getTXIP(); // change orientation to CMS
295  ty = pps_station->getTYIP();
296  eloss = pps_station->getE();
297 }
bool isnan(float x)
Definition: math.h:13
const double mm_to_um
void CTPPSFastTrackingProducer::Reconstruction ( )
private

Definition at line 212 of file CTPPSFastTrackingProducer.cc.

References FastReco(), pps_stationB, pps_stationF, and theCTPPSFastTrack.

Referenced by produce().

213 {
214  theCTPPSFastTrack.clear();
215  int Direction;
216  Direction=1; //cms positive Z / forward
217  FastReco(Direction,&*pps_stationF);
218  Direction=-1; //cms negative Z / backward
219  FastReco(Direction,&*pps_stationB);
220 }//end Reconstruction
void FastReco(int Direction, H_RecRPObject *station)
std::unique_ptr< H_RecRPObject > pps_stationB
std::unique_ptr< H_RecRPObject > pps_stationF
std::vector< CTPPSFastTrack > theCTPPSFastTrack
bool CTPPSFastTrackingProducer::SearchTrack ( int  i,
int  j,
int  Direction,
double &  xi,
double &  t,
double &  partP,
double &  pt,
double &  thx,
double &  thy,
double &  x0,
double &  y0,
double &  xt,
double &  yt,
double &  X1d,
double &  Y1d,
double &  X2d,
double &  Y2d 
)
private

Definition at line 222 of file CTPPSFastTrackingProducer.cc.

References funct::cos(), gather_cfg::cout, fBeamEnergy, fBeamMomentum, fImpParcut, edm::detail::isnan(), m_verbosity, funct::pow(), pps_stationB, pps_stationF, CTPPSTrkDetector::ppsNHits_, CTPPSTrkDetector::ppsX_, CTPPSTrkDetector::ppsY_, ProjectToToF(), ProtonMassSQ, ReconstructArm(), mathSSE::sqrt(), relativeConstraints::station, theta(), TrkStation_B, TrkStation_F, um_to_cm, urad, globals_cff::x1, globals_cff::x2, and hybridSuperClusters_cfi::xi.

Referenced by FastReco().

223 {
224  // Given 1 hit in Tracker1 and 1 hit in Tracker2 try to make a track with Hector
225  double theta=0.;
226  xi = 0; t=0; partP=0; pt=0; x0=0.;y0=0.;xt =0.;yt =0.;X1d=0.;Y1d=0.;X2d=0.;Y2d=0.;
227  CTPPSTrkDetector* det1 = nullptr;
228  CTPPSTrkDetector* det2 = nullptr;
229  H_RecRPObject* station = nullptr;
230  // Separate in forward and backward stations according to direction
231  if (Direction>0) {
232  det1=&(TrkStation_F->first);det2=&(TrkStation_F->second);
233  station = &*pps_stationF;
234  } else {
235  det1=&(TrkStation_B->first);det2=&(TrkStation_B->second);
236  station = &*pps_stationB;
237  }
238  if (det1->ppsNHits_<=i||det2->ppsNHits_<=j) return false;
239  double x1 = det1->ppsX_.at(i); double y1 = det1->ppsY_.at(i);
240  double x2 = det2->ppsX_.at(j); double y2 = det2->ppsY_.at(j);
241  double eloss;
242  //thx and thy are returned in microrad
243  ReconstructArm(station,x1,y1,x2,y2,thx,thy,eloss);
244  // Protect for unphysical results
245  if (std::isnan(eloss)||std::isinf(eloss)||
246  std::isnan(thx) || std::isinf(thx) ||
247  std::isnan(thy) || std::isinf(thy)) return false;
248  //
249  if (-thx<-100||-thx>300) return false;
250  if (thy<-200||thy>200) return false;
251  //
252  if ( m_verbosity ) std::cout << "thx " << thx << " thy " << thy << " eloss " << eloss << std::endl;
253 
254  // Get the start point of the reconstructed track near the origin made by Hector
255  x0 = -station->getX0()*um_to_cm;
256  y0 = station->getY0()*um_to_cm;
257  double ImpPar=sqrt(x0*x0+y0*y0);
258  if (ImpPar>fImpParcut) return false;
259  if (eloss<0.||eloss>fBeamEnergy) return false;
260  // Calculate the reconstructed track parameters
261  theta = sqrt(thx*thx+thy*thy)*urad;
262  xi = eloss/fBeamEnergy;
263  double energy= fBeamEnergy*(1.-xi);
264  partP = sqrt(energy*energy-ProtonMassSQ);
265  t = -2.*(ProtonMassSQ - fBeamEnergy*energy + fBeamMomentum*partP*cos(theta));
266  pt = sqrt(pow(partP*thx*urad,2)+pow(partP*thy*urad,2));
267  if (xi<0.||xi>1.||t<0.||t>10.||pt<=0.) {
268  xi = 0.; t=0.; partP=0.; pt=0.; theta=0.; x0=0.;y0=0.;
269  return false; // unphysical values
270  }
271  //Try to include the timing detector in the track
272  ProjectToToF(x1, y1, x2, y2, xt, yt);
273  X1d = x1;
274  Y1d = y1;
275  X2d = x2;
276  Y2d = y2;
277  return true;
278 }//end SearchTrack
std::vector< double > ppsX_
Geom::Theta< T > theta() const
void ReconstructArm(H_RecRPObject *pps_station, double x1, double y1, double x2, double y2, double &tx, double &ty, double &eloss)
std::unique_ptr< H_RecRPObject > pps_stationB
std::unique_ptr< H_RecRPObject > pps_stationF
const double um_to_cm
bool isnan(float x)
Definition: math.h:13
T sqrt(T t)
Definition: SSEVec.h:18
std::unique_ptr< CTPPSTrkStation > TrkStation_B
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
const double ProtonMassSQ
void ProjectToToF(const double x1, const double y1, const double x2, const double y2, double &xt, double &yt)
std::vector< double > ppsY_
std::unique_ptr< CTPPSTrkStation > TrkStation_F
const double urad
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
void CTPPSFastTrackingProducer::TrackerStationClear ( )
private

Definition at line 160 of file CTPPSFastTrackingProducer.cc.

References TrkStation_B, and TrkStation_F.

Referenced by endEvent(), and produce().

160  {
161 
162  TrkStation_F->first.clear(); TrkStation_F->second.clear();
163  TrkStation_B->first.clear(); TrkStation_B->second.clear();
164 
165 
166 }
std::unique_ptr< CTPPSTrkStation > TrkStation_B
std::unique_ptr< CTPPSTrkStation > TrkStation_F
void CTPPSFastTrackingProducer::TrackerStationStarting ( )
private

Definition at line 168 of file CTPPSFastTrackingProducer.cc.

References det1B, det1F, det2B, det2F, detToF_B, and detToF_F.

Referenced by beginEvent(), and produce().

168  {
169  det1F->clear();
170  det1B->clear();
171  det2F->clear();
172  det2B->clear();
173  detToF_F->clear();
174  detToF_B->clear();
175 
176 }
std::unique_ptr< CTPPSTrkDetector > det2B
std::unique_ptr< CTPPSToFDetector > detToF_F
std::unique_ptr< CTPPSTrkDetector > det2F
std::unique_ptr< CTPPSTrkDetector > det1B
std::unique_ptr< CTPPSToFDetector > detToF_B
std::unique_ptr< CTPPSTrkDetector > det1F

Member Data Documentation

edm::EDGetTokenT< CTPPSFastRecHitContainer > CTPPSFastTrackingProducer::_recHitToken
private

Definition at line 80 of file CTPPSFastTrackingProducer.h.

Referenced by CTPPSFastTrackingProducer(), and produce().

string CTPPSFastTrackingProducer::beam1filename
private

Definition at line 104 of file CTPPSFastTrackingProducer.h.

Referenced by CTPPSFastTrackingProducer().

string CTPPSFastTrackingProducer::beam2filename
private

Definition at line 105 of file CTPPSFastTrackingProducer.h.

Referenced by CTPPSFastTrackingProducer().

std::unique_ptr<CTPPSTrkDetector> CTPPSFastTrackingProducer::det1B
private
std::unique_ptr<CTPPSTrkDetector> CTPPSFastTrackingProducer::det1F
private
std::unique_ptr<CTPPSTrkDetector> CTPPSFastTrackingProducer::det2B
private
std::unique_ptr<CTPPSTrkDetector> CTPPSFastTrackingProducer::det2F
private
std::unique_ptr<CTPPSToFDetector> CTPPSFastTrackingProducer::detToF_B
private
std::unique_ptr<CTPPSToFDetector> CTPPSFastTrackingProducer::detToF_F
private
double CTPPSFastTrackingProducer::fBeamEnergy
private
double CTPPSFastTrackingProducer::fBeamMomentum
private
double CTPPSFastTrackingProducer::fBeamXRMS_ToF
private

Definition at line 136 of file CTPPSFastTrackingProducer.h.

Referenced by CTPPSFastTrackingProducer(), and FastReco().

double CTPPSFastTrackingProducer::fBeamXRMS_Trk1
private

Definition at line 132 of file CTPPSFastTrackingProducer.h.

Referenced by CTPPSFastTrackingProducer().

double CTPPSFastTrackingProducer::fBeamXRMS_Trk2
private

Definition at line 132 of file CTPPSFastTrackingProducer.h.

Referenced by CTPPSFastTrackingProducer().

bool CTPPSFastTrackingProducer::fCrossAngleCorr
private

Definition at line 112 of file CTPPSFastTrackingProducer.h.

Referenced by CTPPSFastTrackingProducer(), and FastReco().

double CTPPSFastTrackingProducer::fCrossingAngle
private

Definition at line 113 of file CTPPSFastTrackingProducer.h.

Referenced by CTPPSFastTrackingProducer(), and LorentzBoost().

double CTPPSFastTrackingProducer::fImpParcut
private

Definition at line 136 of file CTPPSFastTrackingProducer.h.

Referenced by CTPPSFastTrackingProducer(), and SearchTrack().

double CTPPSFastTrackingProducer::fTimeSigma
private

Definition at line 136 of file CTPPSFastTrackingProducer.h.

Referenced by CTPPSFastTrackingProducer(), and FastReco().

double CTPPSFastTrackingProducer::fToFCellHeight
private

Definition at line 134 of file CTPPSFastTrackingProducer.h.

Referenced by CTPPSFastTrackingProducer(), and FastReco().

std::vector<double> CTPPSFastTrackingProducer::fToFCellWidth
private

Definition at line 133 of file CTPPSFastTrackingProducer.h.

Referenced by CTPPSFastTrackingProducer(), and FastReco().

double CTPPSFastTrackingProducer::fToFInsertion
private

Definition at line 136 of file CTPPSFastTrackingProducer.h.

Referenced by CTPPSFastTrackingProducer(), and FastReco().

int CTPPSFastTrackingProducer::fToFNCellX
private

Definition at line 135 of file CTPPSFastTrackingProducer.h.

Referenced by CTPPSFastTrackingProducer(), and FastReco().

int CTPPSFastTrackingProducer::fToFNCellY
private

Definition at line 135 of file CTPPSFastTrackingProducer.h.

Referenced by CTPPSFastTrackingProducer(), and FastReco().

double CTPPSFastTrackingProducer::fToFPitchX
private

Definition at line 134 of file CTPPSFastTrackingProducer.h.

Referenced by CTPPSFastTrackingProducer(), and FastReco().

double CTPPSFastTrackingProducer::fToFPitchY
private

Definition at line 134 of file CTPPSFastTrackingProducer.h.

Referenced by CTPPSFastTrackingProducer(), and FastReco().

double CTPPSFastTrackingProducer::fToFXOffset
private

Definition at line 136 of file CTPPSFastTrackingProducer.h.

Referenced by CTPPSFastTrackingProducer(), and FastReco().

double CTPPSFastTrackingProducer::fTrackerHeight
private

Definition at line 132 of file CTPPSFastTrackingProducer.h.

Referenced by CTPPSFastTrackingProducer().

double CTPPSFastTrackingProducer::fTrackerInsertion
private

Definition at line 132 of file CTPPSFastTrackingProducer.h.

Referenced by CTPPSFastTrackingProducer().

double CTPPSFastTrackingProducer::fTrackerWidth
private

Definition at line 132 of file CTPPSFastTrackingProducer.h.

Referenced by CTPPSFastTrackingProducer().

double CTPPSFastTrackingProducer::fTrk1XOffset
private

Definition at line 132 of file CTPPSFastTrackingProducer.h.

Referenced by CTPPSFastTrackingProducer().

double CTPPSFastTrackingProducer::fTrk2XOffset
private

Definition at line 132 of file CTPPSFastTrackingProducer.h.

Referenced by CTPPSFastTrackingProducer().

double CTPPSFastTrackingProducer::fz_timing
private

Definition at line 131 of file CTPPSFastTrackingProducer.h.

Referenced by CTPPSFastTrackingProducer(), and ProjectToToF().

double CTPPSFastTrackingProducer::fz_tracker1
private

Definition at line 131 of file CTPPSFastTrackingProducer.h.

Referenced by CTPPSFastTrackingProducer(), and ProjectToToF().

double CTPPSFastTrackingProducer::fz_tracker2
private

Definition at line 131 of file CTPPSFastTrackingProducer.h.

Referenced by CTPPSFastTrackingProducer(), and ProjectToToF().

double CTPPSFastTrackingProducer::lengthctpps
private

Definition at line 108 of file CTPPSFastTrackingProducer.h.

Referenced by CTPPSFastTrackingProducer().

std::unique_ptr<H_BeamLine> CTPPSFastTrackingProducer::m_beamlineCTPPS1
private

Definition at line 98 of file CTPPSFastTrackingProducer.h.

Referenced by CTPPSFastTrackingProducer().

std::unique_ptr<H_BeamLine> CTPPSFastTrackingProducer::m_beamlineCTPPS2
private

Definition at line 99 of file CTPPSFastTrackingProducer.h.

Referenced by CTPPSFastTrackingProducer().

std::map<unsigned int, H_BeamParticle*> CTPPSFastTrackingProducer::m_beamPart
private

Definition at line 94 of file CTPPSFastTrackingProducer.h.

Referenced by ~CTPPSFastTrackingProducer().

bool CTPPSFastTrackingProducer::m_verbosity
private

Definition at line 109 of file CTPPSFastTrackingProducer.h.

Referenced by CTPPSFastTrackingProducer(), and SearchTrack().

std::unique_ptr<H_RecRPObject> CTPPSFastTrackingProducer::pps_stationB
private
std::unique_ptr<H_RecRPObject> CTPPSFastTrackingProducer::pps_stationF
private
std::vector<int> CTPPSFastTrackingProducer::recCellId_B
private

Definition at line 128 of file CTPPSFastTrackingProducer.h.

Referenced by FastReco(), produce(), and ReadRecHits().

std::vector<int> CTPPSFastTrackingProducer::recCellId_F
private

Definition at line 128 of file CTPPSFastTrackingProducer.h.

Referenced by FastReco(), produce(), and ReadRecHits().

std::vector<double> CTPPSFastTrackingProducer::recTof_B
private

Definition at line 129 of file CTPPSFastTrackingProducer.h.

Referenced by FastReco(), produce(), and ReadRecHits().

std::vector<double> CTPPSFastTrackingProducer::recTof_F
private

Definition at line 129 of file CTPPSFastTrackingProducer.h.

Referenced by FastReco(), produce(), and ReadRecHits().

std::vector<CTPPSFastTrack> CTPPSFastTrackingProducer::theCTPPSFastTrack
private

Definition at line 124 of file CTPPSFastTrackingProducer.h.

Referenced by FastReco(), produce(), and Reconstruction().

CTPPSFastTrack CTPPSFastTrackingProducer::track
private

Definition at line 126 of file CTPPSFastTrackingProducer.h.

Referenced by FastReco().

std::unique_ptr<CTPPSTrkStation> CTPPSFastTrackingProducer::TrkStation_B
private
std::unique_ptr<CTPPSTrkStation> CTPPSFastTrackingProducer::TrkStation_F
private