26 #include "TLorentzVector.h" 28 #include "H_Parameters.h" 29 #include "H_BeamLine.h" 30 #include "H_RecRPObject.h" 31 #include "H_BeamParticle.h" 36 m_verbosity(
false), fBeamMomentum(0.), fCrossAngleCorr(
false), fCrossingAngleBeam1(0.),fCrossingAngleBeam2(0.)
39 produces<edm::CTPPSFastTrackContainer>(
"CTPPSFastTrack");
90 det1F =std::unique_ptr<CTPPSTrkDetector>(
new CTPPSTrkDetector(fTrackerWidth,fTrackerHeight,fTrackerInsertion*fBeamXRMS_Trk1+fTrk1XOffset));
91 det2F =std::unique_ptr<CTPPSTrkDetector>(
new CTPPSTrkDetector(fTrackerWidth,fTrackerHeight,fTrackerInsertion*fBeamXRMS_Trk2+fTrk2XOffset));
92 det1B =std::unique_ptr<CTPPSTrkDetector>(
new CTPPSTrkDetector(fTrackerWidth,fTrackerHeight,fTrackerInsertion*fBeamXRMS_Trk1+fTrk1XOffset));
93 det2B =std::unique_ptr<CTPPSTrkDetector>(
new CTPPSTrkDetector(fTrackerWidth,fTrackerHeight,fTrackerInsertion*fBeamXRMS_Trk2+fTrk2XOffset));
96 std::vector<double> vToFCellWidth;
97 for (
int i = 0 ;
i < 8 ;
i++){
98 vToFCellWidth.push_back(fToFCellWidth[
i]);
100 double pos_tof = fToFInsertion*fBeamXRMS_ToF+
fToFXOffset;
101 detToF_F =std::unique_ptr<CTPPSToFDetector>(
new CTPPSToFDetector(fToFNCellX,fToFNCellY,vToFCellWidth,fToFCellHeight,fToFPitchX,fToFPitchY,pos_tof,fTimeSigma));
102 detToF_B =std::unique_ptr<CTPPSToFDetector>(
new CTPPSToFDetector(fToFNCellX,fToFNCellY,vToFCellWidth,fToFCellHeight,fToFPitchX,fToFPitchY,pos_tof,fTimeSigma));
107 for (std::map<unsigned int,H_BeamParticle*>::iterator it =
m_beamPart.begin(); it !=
m_beamPart.end(); ++it ) {
129 output_tracks->push_back(*
i);
176 for (
unsigned int irecHits = 0; irecHits < recHits->size(); ++irecHits)
179 unsigned int detlayerId = recHitDet->
detUnitId();
183 float tof = recHitDet->
tof();
184 if(detlayerId == 2014314496)
det1F->AddHit(detlayerId,x,y,z);
185 else if(detlayerId == 2014838784)
det2F->AddHit(detlayerId,x,y,z);
186 else if(detlayerId == 2031091712)
det1B->AddHit(detlayerId,x,y,z);
187 else if(detlayerId == 2031616000)
det2B->AddHit(detlayerId,x,y,z);
193 TrkStation_F = std::unique_ptr<CTPPSTrkStation>(
new std::pair<CTPPSTrkDetector,CTPPSTrkDetector>(*
det1F,*
det2F));
194 TrkStation_B = std::unique_ptr<CTPPSTrkStation>(
new std::pair<CTPPSTrkDetector,CTPPSTrkDetector>(*
det1B,*
det2B));
207 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)
211 xi = 0; t=0; partP=0; pt=0; x0=0.;y0=0.;xt =0.;yt =0.;X1d=0.;Y1d=0.;X2d=0.;Y2d=0.;
214 H_RecRPObject*
station =
nullptr;
225 double x1 = det1->
ppsX_.at(i);
double y1 = det1->
ppsY_.at(i);
226 double x2 = det2->
ppsX_.at(j);
double y2 = det2->
ppsY_.at(j);
230 ReconstructArm(station,Direction*x1,y1,Direction*x2,y2,thx,thy,eloss);
236 std::isnan(thy) || std::isinf(thy))
return false;
239 if (
m_verbosity )
LogDebug(
"CTPPSFastTrackingProducer::SearchTrack:") <<
"thx " << thx <<
" thy " << thy <<
" eloss " << eloss;
242 x0 = -Direction*station->getX0()*
um_to_cm;
244 double ImpPar=
sqrt(x0*x0+y0*y0);
251 double energy= fBeamEnergy*(1.-
xi);
255 if (xi<0.||xi>1.||t<0.||t>10.||pt<=0.) {
256 xi = 0.; t=0.; partP=0.; pt=0.; theta=0.; x0=0.;y0=0.;
273 if (!pps_station)
return;
278 pps_station->setPositions(x1,y1,x2,y2);
279 double energy = pps_station->getE(AM);
280 if (
std::isnan(energy)||std::isinf(energy))
return;
281 tx = pps_station->getTXIP();
282 ty = pps_station->getTYIP();
283 eloss = pps_station->getE();
287 for (
unsigned int i = 0 ;
i < vrecCellId.size();
i++){
288 if(cellId == vrecCellId.at(
i)) {
290 recTof = vrecTof.at(
i);
299 double xi,
t,partP,
pt,
phi,x0,y0,thx,thy,xt,yt,X1d,Y1d,X2d,Y2d;
304 std::vector<double> vToFCellWidth;
305 for (
int i = 0 ;
i < 8 ;
i++){
318 if (
SearchTrack(
i,j,Direction,xi,t,partP,pt,thx,thy,x0,y0,xt,yt,X1d,Y1d,X2d,Y2d)) {
322 bool matchCellId =
false;
323 if (Direction > 0 ) {
327 else if (Direction<0) {
331 phi = atan2(thy,thx);
333 double px = partP*
sin(theta)*
cos(phi);
334 double py = partP*
sin(theta)*
sin(phi);
335 double pz = partP*
cos(theta);
337 TLorentzVector
p(px,py,pz,e);
345 double pxx = p.Px();
double pyy = p.Py();
double pzz = p.Pz();
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
void beginStream(edm::StreamID) override
std::vector< double > ppsX_
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
std::unique_ptr< CTPPSTrkDetector > det2B
int findCellId(double x, double y)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
~CTPPSFastTrackingProducer() override
std::unique_ptr< H_BeamLine > m_beamlineCTPPS1
virtual void endEvent(edm::Event &event, const edm::EventSetup &eventSetup)
Sin< T >::type sin(const T &t)
void FastReco(int Direction, H_RecRPObject *station)
Geom::Theta< T > theta() const
void setvertex(const Point &vertex)
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< CTPPSToFDetector > detToF_F
double fCrossingAngleBeam2
void TrackerStationClear()
float tof() const
deprecated name for timeOfFlight()
std::unique_ptr< CTPPSTrkDetector > det2F
void endStream() override
std::unique_ptr< H_RecRPObject > pps_stationF
std::vector< double > fToFCellWidth
void setp(const Vector &momentum)
std::vector< int > recCellId_F
#define DEFINE_FWK_MODULE(type)
CTPPSFastTrackingProducer(const edm::ParameterSet &)
std::unique_ptr< CTPPSTrkDetector > det1B
double fCrossingAngleBeam1
std::string beam1filename
virtual void beginEvent(edm::Event &event, const edm::EventSetup &eventSetup)
std::vector< double > recTof_F
unsigned int detUnitId() const
std::unique_ptr< CTPPSTrkStation > TrkStation_B
Cos< T >::type cos(const T &t)
std::unique_ptr< CTPPSToFDetector > detToF_B
std::vector< double > recTof_B
std::map< unsigned int, H_BeamParticle * > m_beamPart
void TrackerStationStarting()
std::unique_ptr< H_BeamLine > m_beamlineCTPPS2
std::string beam2filename
void ProjectToToF(const double x1, const double y1, const double x2, const double y2, double &xt, double &yt)
std::vector< int > recCellId_B
std::vector< double > ppsY_
void MatchCellId(int cellId, std::vector< int > vrecCellId, std::vector< double > vrecTof, bool &match, double &recTof)
std::unique_ptr< CTPPSTrkStation > TrkStation_F
std::vector< CTPPSFastTrack > theCTPPSFastTrack
const GeomDet * recHitDet(const TrackingRecHit &hit, const TrackingGeometry *geom)
XYZVectorD XYZVector
spatial vector with cartesian internal representation
XYZPointD XYZPoint
point in space with cartesian internal representation
static const double um_to_cm
edm::EDGetTokenT< CTPPSFastRecHitContainer > _recHitToken
Local3DPoint entryPoint() const
Entry point in the local Det frame.
std::unique_ptr< CTPPSTrkDetector > det1F
static const double mm_to_um
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
void produce(edm::Event &, const edm::EventSetup &) override
std::vector< CTPPSFastTrack > CTPPSFastTrackContainer
void setcellid(unsigned int cellid)
void ReadRecHits(edm::Handle< CTPPSFastRecHitContainer > &)
Power< A, B >::type pow(const A &a, const B &b)
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)