31 m_verbosity(
false), fBeamMomentum(0.), fCrossAngleCorr(
false), fCrossingAngle(0.)
34 produces<edm::CTPPSFastTrackContainer>(
"CTPPSFastTrack");
81 m_beamlineCTPPS1 = std::unique_ptr<H_BeamLine>(
new H_BeamLine( -1, lengthctpps + 0.1 ));
82 m_beamlineCTPPS2 = std::unique_ptr<H_BeamLine>(
new H_BeamLine( 1, lengthctpps + 0.1 ));
84 m_beamlineCTPPS2->fill( b1.fullPath(), 1,
"IP5" );
86 m_beamlineCTPPS2->offsetElements( 120, 0.097 );
88 m_beamlineCTPPS2->calcMatrix();
99 det1F =std::unique_ptr<CTPPSTrkDetector>(
new CTPPSTrkDetector(fTrackerWidth,fTrackerHeight,fTrackerInsertion*fBeamXRMS_Trk1+fTrk1XOffset));
100 det2F =std::unique_ptr<CTPPSTrkDetector>(
new CTPPSTrkDetector(fTrackerWidth,fTrackerHeight,fTrackerInsertion*fBeamXRMS_Trk2+fTrk2XOffset));
101 det1B =std::unique_ptr<CTPPSTrkDetector>(
new CTPPSTrkDetector(fTrackerWidth,fTrackerHeight,fTrackerInsertion*fBeamXRMS_Trk1+fTrk1XOffset));
102 det2B =std::unique_ptr<CTPPSTrkDetector>(
new CTPPSTrkDetector(fTrackerWidth,fTrackerHeight,fTrackerInsertion*fBeamXRMS_Trk2+fTrk2XOffset));
105 std::vector<double> vToFCellWidth;
106 for (
int i = 0 ;
i < 8 ;
i++){
107 vToFCellWidth.push_back(fToFCellWidth[
i]);
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));
116 for (std::map<unsigned int,H_BeamParticle*>::iterator it =
m_beamPart.begin(); it !=
m_beamPart.end(); ++it ) {
139 output_tracks->push_back(*
i);
191 for (
unsigned int irecHits = 0; irecHits < recHits->size(); ++irecHits)
194 unsigned int detlayerId = recHitDet->
detUnitId();
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);
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));
222 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)
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.;
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);
247 std::isnan(thy) || std::isinf(thy))
return false;
249 if (-thx<-100||-thx>300)
return false;
250 if (thy<-200||thy>200)
return false;
252 if (
m_verbosity )
std::cout <<
"thx " << thx <<
" thy " << thy <<
" eloss " << eloss << std::endl;
257 double ImpPar=
sqrt(x0*x0+y0*y0);
263 double energy= fBeamEnergy*(1.-
xi);
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.;
285 if (!pps_station)
return;
291 pps_station->setPositions(x1,y1,x2,y2);
292 double energy = pps_station->getE(AM);
293 if (
std::isnan(energy)||std::isinf(energy))
return;
294 tx = -pps_station->getTXIP();
295 ty = pps_station->getTYIP();
296 eloss = pps_station->getE();
302 double microrad = 1.e-6;
303 TMatrixD tmpboost(4,4);
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_);
313 tmpboost(1,2) =
cos(alpha_)*
tan(phi_);
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_);
321 tmpboost(3,2) =
sin(alpha_)*
tan(phi_);
324 if(frame==
"LAB") tmpboost.Invert();
328 p4(1,0) = p_out.px();
329 p4(2,0) = p_out.py();
330 p4(3,0) = p_out.pz();
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));
339 for (
unsigned int i = 0 ;
i < vrecCellId.size();
i++){
340 if(cellId == vrecCellId.at(
i)) {
342 recTof = vrecTof.at(
i);
351 double xi,
t,partP,
pt,
phi,x0,y0,thx,thy,xt,yt,X1d,Y1d,X2d,Y2d;
356 std::vector<double> vToFCellWidth;
357 for (
int i = 0 ;
i < 8 ;
i++){
370 if (
SearchTrack(
i,j,Direction,xi,t,partP,pt,thx,thy,x0,y0,xt,yt,X1d,Y1d,X2d,Y2d)) {
374 bool matchCellId =
false;
375 if (Direction > 0 ) {
379 else if (Direction<0) {
383 phi = (Direction>0)?-atan2(thy,-thx):atan2(thy,thx);
386 double px = partP*
sin(theta)*
cos(phi);
387 double py = partP*
sin(theta)*
sin(phi);
388 double pz = partP*
cos(theta);
395 double pxx = p.px();
double pyy = p.py();
double pzz = p.pz();
425 double mom =
sqrt((proton->px())*(proton->px())+(proton->py())*(proton->py())+(proton->pz())*(proton->pz()));
427 double energy = proton->e();
428 double theta = (proton->pz()>0)?proton->theta():
CLHEP::pi-proton->theta();
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
virtual void beginStream(edm::StreamID) override
std::vector< double > ppsX_
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
void MatchCellId(int cellId, vector< int > vrecCellId, vector< double > vrecTof, bool &match, double &recTof)
CLHEP::HepLorentzVector LorentzVector
std::unique_ptr< CTPPSTrkDetector > det2B
int findCellId(double x, double y)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
#define DEFINE_FWK_MODULE(type)
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
void TrackerStationClear()
float tof() const
deprecated name for timeOfFlight()
std::unique_ptr< CTPPSTrkDetector > det2F
virtual void endStream() override
std::unique_ptr< H_RecRPObject > pps_stationF
std::vector< double > fToFCellWidth
void setp(const Vector &momentum)
std::vector< int > recCellId_F
CTPPSFastTrackingProducer(const edm::ParameterSet &)
std::unique_ptr< CTPPSTrkDetector > det1B
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)
Tan< T >::type tan(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
const double ProtonMassSQ
~CTPPSFastTrackingProducer()
void ProjectToToF(const double x1, const double y1, const double x2, const double y2, double &xt, double &yt)
void Get_t_and_xi(const LorentzVector *p, double &t, double &xi)
std::vector< int > recCellId_B
std::vector< double > ppsY_
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
edm::EDGetTokenT< CTPPSFastRecHitContainer > _recHitToken
Local3DPoint entryPoint() const
Entry point in the local Det frame.
std::unique_ptr< CTPPSTrkDetector > det1F
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
void LorentzBoost(LorentzVector &p_out, const string &frame)
virtual 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)