25 #include "TLorentzVector.h" 27 #include "H_Parameters.h" 28 #include "H_BeamLine.h" 29 #include "H_RecRPObject.h" 30 #include "H_BeamParticle.h" 35 : m_verbosity(
false), fBeamMomentum(0.), fCrossAngleCorr(
false), fCrossingAngleBeam1(0.), fCrossingAngleBeam2(0.) {
37 produces<edm::CTPPSFastTrackContainer>(
"CTPPSFastTrack");
81 LogDebug(
"CTPPSFastTrackingProducer") <<
"CTPPSFastTrackingProducer: WARNING: lengthctpps= " <<
lengthctpps;
89 det1F = std::unique_ptr<CTPPSTrkDetector>(
90 new CTPPSTrkDetector(fTrackerWidth, fTrackerHeight, fTrackerInsertion * fBeamXRMS_Trk1 + fTrk1XOffset));
91 det2F = std::unique_ptr<CTPPSTrkDetector>(
92 new CTPPSTrkDetector(fTrackerWidth, fTrackerHeight, fTrackerInsertion * fBeamXRMS_Trk2 + fTrk2XOffset));
93 det1B = std::unique_ptr<CTPPSTrkDetector>(
94 new CTPPSTrkDetector(fTrackerWidth, fTrackerHeight, fTrackerInsertion * fBeamXRMS_Trk1 + fTrk1XOffset));
95 det2B = std::unique_ptr<CTPPSTrkDetector>(
96 new CTPPSTrkDetector(fTrackerWidth, fTrackerHeight, fTrackerInsertion * fBeamXRMS_Trk2 + fTrk2XOffset));
99 std::vector<double> vToFCellWidth;
100 for (
int i = 0;
i < 8;
i++) {
101 vToFCellWidth.push_back(fToFCellWidth[
i]);
103 double pos_tof = fToFInsertion * fBeamXRMS_ToF +
fToFXOffset;
105 fToFNCellX, fToFNCellY, vToFCellWidth, fToFCellHeight, fToFPitchX, fToFPitchY, pos_tof, fTimeSigma));
107 fToFNCellX, fToFNCellY, vToFCellWidth, fToFCellHeight, fToFPitchX, fToFPitchY, pos_tof, fTimeSigma));
111 for (std::map<unsigned int, H_BeamParticle*>::iterator it =
m_beamPart.begin(); it !=
m_beamPart.end(); ++it) {
132 output_tracks->push_back(*
i);
173 for (
unsigned int irecHits = 0; irecHits < recHits->size(); ++irecHits) {
175 unsigned int detlayerId = recHitDet->
detUnitId();
179 float tof = recHitDet->
tof();
180 if (detlayerId == 2014314496)
181 det1F->AddHit(detlayerId, x, y, z);
182 else if (detlayerId == 2014838784)
183 det2F->AddHit(detlayerId, x, y, z);
184 else if (detlayerId == 2031091712)
185 det1B->AddHit(detlayerId, x, y, z);
186 else if (detlayerId == 2031616000)
187 det2B->AddHit(detlayerId, x, y, z);
188 else if (detlayerId == 2046820352) {
192 }
else if (detlayerId == 2063597568) {
200 TrkStation_F = std::unique_ptr<CTPPSTrkStation>(
new std::pair<CTPPSTrkDetector, CTPPSTrkDetector>(*
det1F, *
det2F));
201 TrkStation_B = std::unique_ptr<CTPPSTrkStation>(
new std::pair<CTPPSTrkDetector, CTPPSTrkDetector>(*
det1B, *
det2B));
246 H_RecRPObject*
station =
nullptr;
268 station, Direction * x1, y1, Direction * x2, y2, thx, thy, eloss);
278 LogDebug(
"CTPPSFastTrackingProducer::SearchTrack:") <<
"thx " << thx <<
" thy " << thy <<
" eloss " << eloss;
281 x0 = -Direction * station->getX0() *
um_to_cm;
283 double ImpPar =
sqrt(x0 * x0 + y0 * y0);
290 theta =
sqrt(thx * thx + thy * thy) *
urad;
292 double energy = fBeamEnergy * (1. -
xi);
295 pt =
sqrt(
pow(partP * thx *
urad, 2) +
pow(partP * thy * urad, 2));
296 if (xi < 0. || xi > 1. || t < 0. || t > 10. || pt <= 0.) {
316 H_RecRPObject* pps_station,
double x1,
double y1,
double x2,
double y2,
double& tx,
double& ty,
double& eloss) {
326 pps_station->setPositions(x1, y1, x2, y2);
327 double energy = pps_station->getE(AM);
330 tx = pps_station->getTXIP();
331 ty = pps_station->getTYIP();
332 eloss = pps_station->getE();
336 int cellId, std::vector<int> vrecCellId, std::vector<double> vrecTof,
bool&
match,
double& recTof) {
337 for (
unsigned int i = 0;
i < vrecCellId.size();
i++) {
338 if (cellId == vrecCellId.at(
i)) {
340 recTof = vrecTof.at(
i);
348 double xi,
t, partP,
pt,
phi, x0, y0, thx, thy, xt, yt, X1d, Y1d, X2d, Y2d;
353 std::vector<double> vToFCellWidth;
354 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;
376 theta =
sqrt(thx * thx + thy * thy) *
urad;
378 }
else if (Direction < 0) {
382 phi = atan2(thy, thx);
384 double px = partP *
sin(theta) *
cos(phi);
385 double py = partP *
sin(theta) *
sin(phi);
386 double pz = partP *
cos(theta);
388 TLorentzVector
p(px, py, pz, e);
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
Local3DPoint entryPoint() const
Entry point in the local Det frame.
std::unique_ptr< CTPPSTrkDetector > det1F
static const double mm_to_um
edm::EDGetTokenT< CTPPSFastRecHitContainer > _recHitToken
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)