123 return (b.
x() > a.
x());
126 return (b.
y() > a.
y());
128 return (a.
z() > b.
z());
204 readMoreMcTruth_(iConfig.getParameter<bool>(
"readMoreMcTruth")),
221 produces<std::vector<TTTrack<Ref_Phase2TrackerDigi_>>>(
"Level1TTTracks").setBranchAlias(
"Level1TTTracks");
239 esGetToken_ = esConsumes<trackerDTC::Setup, trackerDTC::SetupRcd, edm::Transition::BeginRun>();
269 edm::LogVerbatim(
"Tracklet") <<
"fit pattern : " << fitPatternFile.fullPath()
270 <<
"\n process modules : " << processingModulesFile.
fullPath()
271 <<
"\n memory modules : " << memoryModulesFile.
fullPath()
272 <<
"\n wires : " << wiresFile.
fullPath();
323 auto L1TkTracksForOutput = std::make_unique<std::vector<TTTrack<Ref_Phase2TrackerDigi_>>>();
336 ev.
setIP(bsPosition.x(), bsPosition.y());
353 map<edm::Ptr<TrackingParticle>,
int> translateTP;
366 for (
const auto& iterTP : *TrackingParticleHandle) {
371 if (MCTruthTTClusterHandle->findTTClusterRefs(tp_ptr).empty())
374 if (iterTP.g4Tracks().empty()) {
378 int sim_eventid = iterTP.g4Tracks().at(0).eventId().event();
379 int sim_type = iterTP.pdgId();
380 float sim_pt = iterTP.pt();
381 float sim_eta = iterTP.eta();
382 float sim_phi = iterTP.phi();
384 float vx = iterTP.vertex().x();
385 float vy = iterTP.vertex().y();
386 float vz = iterTP.vertex().z();
388 if (sim_pt < 1.0 ||
std::abs(vz) > 100.0 || hypot(vx, vy) > 50.0)
391 ev.
addL1SimTrack(sim_eventid, ntps, sim_type, sim_pt, sim_eta, sim_phi, vx, vy, vz);
393 translateTP[tp_ptr] = ntps;
405 for (
const int&
region : handleDTC->tfpRegions()) {
406 for (
const int& channel : handleDTC->tfpChannels()) {
409 static string dtcbasenames[12] = {
410 "PS10G_1",
"PS10G_2",
"PS10G_3",
"PS10G_4",
"PS_1",
"PS_2",
"2S_1",
"2S_2",
"2S_3",
"2S_4",
"2S_5",
"2S_6"};
412 string dtcname = dtcbasenames[channel % 12];
414 if (channel % 24 >= 12)
415 dtcname =
"neg" + dtcname;
417 dtcname += (channel < 24) ?
"_A" :
"_B";
423 for (
size_t stubIndex = 0; stubIndex < streamFromDTC.size(); ++stubIndex) {
426 if (stub.first.isNull()) {
433 string layerword = stub.second.to_string().substr(61, 2);
434 unsigned int layercode = 2 * (layerword[0] -
'0') + layerword[1] -
'0';
439 static int layerdisktab[12][4] = {{0, 6, 8, 10},
452 int layerdisk = layerdisktab[channel % 12][layercode];
456 constexpr
int DTCLinkWordSize = 64;
457 constexpr
int StubWordSize = 36;
458 constexpr
int LayerandStatusCodeSize = 3;
460 stub.second.to_string().substr(DTCLinkWordSize - StubWordSize - LayerandStatusCodeSize, StubWordSize);
461 string stubwordhex =
"";
464 for (
unsigned int i = 0;
i < 9;
i++) {
465 bitset<4> bits(stubword.substr(
i * 4, 4));
466 ulong
val = bits.to_ulong();
467 stubwordhex += ((val < 10) ? (
'0' + val) : (
'A' + val - 10));
472 innerCluster = stub.first->clusterRef(0);
474 outerCluster = stub.first->clusterRef(1);
480 const DetId innerDetId = innerCluster->getDetId();
482 const auto* theGeomDet_inner =
dynamic_cast<const PixelGeomDetUnit*
>(det_inner);
485 MeasurementPoint coords_inner = innerCluster->findAverageLocalCoordinatesCentered();
487 GlobalPoint posStub_inner = theGeomDet_inner->surface().toGlobal(clustlp_inner);
489 const DetId outerDetId = outerCluster->getDetId();
491 const auto* theGeomDet_outer =
dynamic_cast<const PixelGeomDetUnit*
>(det_outer);
494 MeasurementPoint coords_outer = outerCluster->findAverageLocalCoordinatesCentered();
496 GlobalPoint posStub_outer = theGeomDet_outer->surface().toGlobal(clustlp_outer);
498 bool isFlipped = (posStub_outer.
mag() < posStub_inner.
mag());
500 vector<int> assocTPs;
502 for (
unsigned int iClus = 0; iClus <= 1; iClus++) {
504 const TTClusterRef& ttClusterRef = stub.first->clusterRef(iClus);
507 vector<edm::Ptr<TrackingParticle>> vecTpPtr = MCTruthTTClusterHandle->findTrackingParticlePtrs(ttClusterRef);
510 if (translateTP.find(tpPtr) != translateTP.end()) {
512 assocTPs.push_back(translateTP.at(tpPtr));
514 assocTPs.push_back(-translateTP.at(tpPtr));
518 assocTPs.push_back(0);
523 double stubbend = stub.first->bendFE();
524 if (ttPos.
z() < -120) {
525 stubbend = -stubbend;
538 stub.first->innerClusterPosition(),
541 const trklet::L1TStub& lastStub = ev.
lastStub();
542 stubMap[lastStub] = stub.first;
561 for (
const auto&
track : tracks) {
562 if (
track.duplicate())
573 double tmp_chi2rphi =
track.chisqrphi();
574 double tmp_chi2rz =
track.chisqrz();
575 unsigned int tmp_hit =
track.hitpattern();
591 unsigned int trksector =
track.sector();
592 unsigned int trkseed = (
unsigned int)
abs(
track.seed());
594 aTrack.setPhiSector(trksector);
595 aTrack.setTrackSeedType(trkseed);
597 const vector<trklet::L1TStub>& stubptrs =
track.stubs();
598 vector<trklet::L1TStub> stubs;
600 stubs.reserve(stubptrs.size());
601 for (
const auto& stubptr : stubptrs) {
602 stubs.push_back(stubptr);
605 stubMapType::const_iterator it;
606 for (
const auto& itstubs : stubs) {
607 it = stubMap.find(itstubs);
608 if (it != stubMap.end()) {
609 aTrack.addStubRef(it->second);
616 aTrack.setStubPtConsistency(
620 aTrack.setTrackWordBits();
629 L1TkTracksForOutput->push_back(aTrack);
632 iEvent.
put(
std::move(L1TkTracksForOutput),
"Level1TTTracks");
Log< level::Info, true > LogVerbatim
void setMemoryModulesFile(std::string memoryModulesFileName)
T getUntrackedParameter(std::string const &, T const &) const
edm::InputTag MCTruthStubInputTag
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
edm::FileInPath tableTREFile
const TrackerGeomDet * idToDetUnit(DetId) const override
Return the pointer to the GeomDetUnit corresponding to a given DetId.
bool operator()(const trklet::L1TStub &a, const trklet::L1TStub &b) const
virtual LocalPoint localPosition(const MeasurementPoint &) const =0
string asciiEventOutName_
const edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > tGeomToken_
void setFitPatternFile(std::string fitPatternFileName)
unsigned int nHelixPar() const
bool getByToken(EDGetToken token, Handle< PROD > &result) const
virtual GlobalVector inTesla(const GlobalPoint &gp) const =0
Field value ad specified global point, in Tesla.
#define DEFINE_FWK_MODULE(type)
void write(std::ofstream &out)
Global3DPoint GlobalPoint
edm::InputTag MCTruthClusterInputTag
auto const & tracks
cannot be loose
trklet::TrackletEventProcessor eventProcessor
void event(SLHCEvent &ev)
std::vector< Frame > Stream
void beginRun(const edm::Run &run, const edm::EventSetup &iSetup) override
const edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > tTopoToken_
bool debugTracklet() const
GlobalPoint stubPos(bool hybrid, const TTDTC::Frame &frame, int tfpRegion, int tfpChannel) const
void setIP(double x, double y)
edm::FileInPath tableTEDFile
bool getData(T &iHolder) const
void init(Settings const &theSettings)
void produce(edm::Event &iEvent, const edm::EventSetup &iSetup) override
tuple MCTruthClusterInputTag
const edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > magneticFieldToken_
std::ofstream asciiEventOut_
const std::vector< Track > & tracks() const
edm::EDGetTokenT< TTDTC > tokenDTC_
edm::FileInPath processingModulesFile
Abs< T >::type abs(const T &t)
tuple TrackingParticleInputTag
edm::EDGetTokenT< TTClusterAssociationMap< Ref_Phase2TrackerDigi_ > > ttClusterMCTruthToken_
trklet::Settings settings
void setEventNum(int eventnum)
Class to process and provide run-time constants used by Track Trigger emulators.
Class to store the L1 Track Trigger stubs.
bool addStub(std::string DTClink, int region, int layerdisk, std::string stubword, int isPSmodule, int isFlipped, double x, double y, double z, double bend, double strip, std::vector< int > tps)
edm::EDGetTokenT< std::vector< TrackingParticle > > TrackingParticleToken_
int dtcId(int tklId) const
edm::FileInPath wiresFile
std::unique_ptr< TrackQuality > trackQualityModel_
edm::InputTag TrackingParticleInputTag
void endRun(edm::Run const &, edm::EventSetup const &) override
const edm::EDGetTokenT< reco::BeamSpot > bsToken_
std::pair< TTStubRef, BV > Frame
tuple MCTruthStubInputTag
~L1FPGATrackProducer() override
bool psModule(int dtcId) const
NOTE: this is needed even if it seems not.
XYZPointD XYZPoint
point in space with cartesian internal representation
Class to store the L1 Track Trigger tracks.
void setProcessingModulesFile(std::string processingModulesFileName)
T getParameter(std::string const &) const
TTClusterRefT< Ref_Phase2TrackerDigi_ > TTClusterRef
L1FPGATrackProducer(const edm::ParameterSet &iConfig)
Constructor/destructor.
Class to store hardware like structured TTStub Collection used by Track Trigger emulators.
edm::FileInPath memoryModulesFile
const L1TStub & lastStub() const
edm::ESGetToken< trackerDTC::Setup, trackerDTC::SetupRcd > esGetToken_
std::map< string, vector< int > > dtclayerdisk
tuple config
parse the configuration file
edm::FileInPath fitPatternFile
File path for configuration files.
void addL1SimTrack(int eventid, int trackid, int type, double pt, double eta, double phi, double vx, double vy, double vz)
void setNbitstrackletindex(unsigned int nbitstrackletindex)
void setNHelixPar(unsigned int nHelixPar)
std::string fullPath() const
void setWiresFile(std::string wiresFileName)
void setBfield(double bfield)
void setTableTREFile(std::string tableTREFileName)
edm::ParameterSet config
Containers of parameters passed by python configuration file.
void setTableTEDFile(std::string tableTEDFileName)
void setExtended(bool extended)
float getConsistency(TTTrack< Ref_Phase2TrackerDigi_ > aTrack, const TrackerGeometry *theTrackerGeom, const TrackerTopology *tTopo, double mMagneticFieldStrength, int nPar)