From cacab0a17f5e5831430a1cfe3202c668bfe0d41d Mon Sep 17 00:00:00 2001 From: Eric Cano Date: Tue, 27 Feb 2024 13:26:24 +0100 Subject: [PATCH 001/237] Removes duplicate/unneeded entries in serialization XML of test objects. --- DataFormats/PortableTestObjects/src/classes_def.xml | 8 -------- 1 file changed, 8 deletions(-) diff --git a/DataFormats/PortableTestObjects/src/classes_def.xml b/DataFormats/PortableTestObjects/src/classes_def.xml index f2bcf4311fcdf..fbcd940f37203 100644 --- a/DataFormats/PortableTestObjects/src/classes_def.xml +++ b/DataFormats/PortableTestObjects/src/classes_def.xml @@ -1,6 +1,5 @@ - @@ -8,17 +7,10 @@ - - - - - - - From 4f779dee52482f416856a50e0454ccc2e668911a Mon Sep 17 00:00:00 2001 From: Eric Cano Date: Tue, 12 Mar 2024 11:08:26 +0100 Subject: [PATCH 002/237] Removes redundant class declration for dictionary generation. --- DataFormats/PortableTestObjects/src/classes_def.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/DataFormats/PortableTestObjects/src/classes_def.xml b/DataFormats/PortableTestObjects/src/classes_def.xml index fbcd940f37203..87fbdfc447f80 100644 --- a/DataFormats/PortableTestObjects/src/classes_def.xml +++ b/DataFormats/PortableTestObjects/src/classes_def.xml @@ -1,5 +1,4 @@ - From 6ca6c2605f222246f45ae425622a24c221a8dedf Mon Sep 17 00:00:00 2001 From: mmusich Date: Wed, 17 Apr 2024 12:36:35 +0200 Subject: [PATCH 003/237] fix MC Kshort sequence --- .../python/TrackingDataMCValidation_Standalone_cff.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DQM/TrackingMonitorSource/python/TrackingDataMCValidation_Standalone_cff.py b/DQM/TrackingMonitorSource/python/TrackingDataMCValidation_Standalone_cff.py index 5dfdebb02870b..6c94d59f19fd7 100644 --- a/DQM/TrackingMonitorSource/python/TrackingDataMCValidation_Standalone_cff.py +++ b/DQM/TrackingMonitorSource/python/TrackingDataMCValidation_Standalone_cff.py @@ -178,7 +178,7 @@ * selectedPrimaryVertices * KShortEventSelector * KshortTracks - * standaloneTrackMonitorK0 + * standaloneTrackMonitorK0MC * KshortMonitor) standaloneValidationLambdas = cms.Sequence( From 5e9ff21cc6ab88c52ef3d37bd3f8cf95c65035c1 Mon Sep 17 00:00:00 2001 From: mmusich Date: Wed, 17 Apr 2024 12:36:58 +0200 Subject: [PATCH 004/237] fix sign of cosPhi3D, make code more readable --- .../plugins/StandaloneTrackMonitor.cc | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/DQM/TrackingMonitorSource/plugins/StandaloneTrackMonitor.cc b/DQM/TrackingMonitorSource/plugins/StandaloneTrackMonitor.cc index e1dc903f3443a..0f7e80a9d568e 100644 --- a/DQM/TrackingMonitorSource/plugins/StandaloneTrackMonitor.cc +++ b/DQM/TrackingMonitorSource/plugins/StandaloneTrackMonitor.cc @@ -1836,17 +1836,18 @@ void StandaloneTrackMonitor::analyze(edm::Event const& iEvent, edm::EventSetup c theMainVtx = *theClosestVertex; } if (theMainVtx.isValid()) { - const math::XYZPoint theMainVtxPos( - theMainVtx.position().x(), theMainVtx.position().y(), theMainVtx.position().z()); - const math::XYZPoint myVertex( - mumuTransientVtx.position().x(), mumuTransientVtx.position().y(), mumuTransientVtx.position().z()); - const math::XYZPoint deltaVtx( - theMainVtxPos.x() - myVertex.x(), theMainVtxPos.y() - myVertex.y(), theMainVtxPos.z() - myVertex.z()); - double cosphi3D = - (Zp.Px() * deltaVtx.x() + Zp.Py() * deltaVtx.y() + Zp.Pz() * deltaVtx.z()) / - (sqrt(Zp.Px() * Zp.Px() + Zp.Py() * Zp.Py() + Zp.Pz() * Zp.Pz()) * - sqrt(deltaVtx.x() * deltaVtx.x() + deltaVtx.y() * deltaVtx.y() + deltaVtx.z() * deltaVtx.z())); - cosPhi3DdileptonH_->Fill(cosphi3D, wfac); + const auto& mainVertexPos = theMainVtx.position(); + const auto& myVertexPos = mumuTransientVtx.position(); + + const double deltaX = myVertexPos.x() - mainVertexPos.x(); + const double deltaY = myVertexPos.y() - mainVertexPos.y(); + const double deltaZ = myVertexPos.z() - mainVertexPos.z(); + + const double deltaNorm = sqrt(deltaX * deltaX + deltaY * deltaY + deltaZ * deltaZ); + const double zpNorm = sqrt(Zp.Px() * Zp.Px() + Zp.Py() * Zp.Py() + Zp.Pz() * Zp.Pz()); + + const double cosPhi3D = (Zp.Px() * deltaX + Zp.Py() * deltaY + Zp.Pz() * deltaZ) / (zpNorm * deltaNorm); + cosPhi3DdileptonH_->Fill(cosPhi3D, wfac); } } } From 193e3b1edc6543e2be7247d9664ca3bf77b5a8d4 Mon Sep 17 00:00:00 2001 From: Junghwan John Goh Date: Fri, 3 May 2024 19:08:44 +0200 Subject: [PATCH 005/237] RPCDigisV cleanup unused validation plots, unused variables, follow naming conventions --- .../MuonRPCDigis/interface/RPCDigiValid.h | 47 +----- Validation/MuonRPCDigis/src/RPCDigiValid.cc | 158 ++---------------- 2 files changed, 20 insertions(+), 185 deletions(-) diff --git a/Validation/MuonRPCDigis/interface/RPCDigiValid.h b/Validation/MuonRPCDigis/interface/RPCDigiValid.h index 52d6ead104a0b..d6dc808dd2e77 100644 --- a/Validation/MuonRPCDigis/interface/RPCDigiValid.h +++ b/Validation/MuonRPCDigis/interface/RPCDigiValid.h @@ -20,7 +20,7 @@ class RPCDigiValid : public DQMEDAnalyzer { public: RPCDigiValid(const edm::ParameterSet &ps); - ~RPCDigiValid() override; + ~RPCDigiValid() override = default; protected: void analyze(const edm::Event &e, const edm::EventSetup &c) override; @@ -29,47 +29,9 @@ class RPCDigiValid : public DQMEDAnalyzer { private: MonitorElement *xyview; MonitorElement *rzview; - MonitorElement *Res; - MonitorElement *ResWmin2; - MonitorElement *ResWmin1; - MonitorElement *ResWzer0; - MonitorElement *ResWplu1; - MonitorElement *ResWplu2; MonitorElement *BxDist; MonitorElement *StripProf; - // barrel layers residuals - MonitorElement *ResLayer1_barrel; - MonitorElement *ResLayer2_barrel; - MonitorElement *ResLayer3_barrel; - MonitorElement *ResLayer4_barrel; - MonitorElement *ResLayer5_barrel; - MonitorElement *ResLayer6_barrel; - - // members for EndCap's disks: - MonitorElement *ResDmin1; - MonitorElement *ResDmin2; - MonitorElement *ResDmin3; - MonitorElement *ResDplu1; - MonitorElement *ResDplu2; - MonitorElement *ResDplu3; - - // endcap layters residuals - MonitorElement *Res_Endcap1_Ring2_A; - MonitorElement *Res_Endcap1_Ring2_B; - MonitorElement *Res_Endcap1_Ring2_C; - - MonitorElement *Res_Endcap23_Ring2_A; - MonitorElement *Res_Endcap23_Ring2_B; - MonitorElement *Res_Endcap23_Ring2_C; - - MonitorElement *Res_Endcap123_Ring3_A; - MonitorElement *Res_Endcap123_Ring3_B; - MonitorElement *Res_Endcap123_Ring3_C; - - // 4 endcap - MonitorElement *ResDmin4; - MonitorElement *ResDplu4; MonitorElement *BxDisc_4Plus; MonitorElement *BxDisc_4Min; MonitorElement *xyvDplu4; @@ -78,12 +40,9 @@ class RPCDigiValid : public DQMEDAnalyzer { // Timing information MonitorElement *hDigiTimeAll, *hDigiTime, *hDigiTimeIRPC, *hDigiTimeNoIRPC; - std::string outputFile_; - std::string digiLabel; - // Tokens for accessing run data. Used for passing to edm::Event. - stanislav - edm::EDGetTokenT simHitToken; - edm::EDGetTokenT rpcDigiToken; + edm::EDGetTokenT simHitToken_; + edm::EDGetTokenT rpcDigiToken_; edm::ESGetToken rpcGeomToken_; }; diff --git a/Validation/MuonRPCDigis/src/RPCDigiValid.cc b/Validation/MuonRPCDigis/src/RPCDigiValid.cc index cfac3ea4f78ad..b57cc8f004635 100644 --- a/Validation/MuonRPCDigis/src/RPCDigiValid.cc +++ b/Validation/MuonRPCDigis/src/RPCDigiValid.cc @@ -1,6 +1,7 @@ +#include "Validation/MuonRPCDigis/interface/RPCDigiValid.h" + #include "FWCore/Utilities/interface/InputTag.h" #include "SimDataFormats/CrossingFrame/interface/MixCollection.h" -#include "Validation/MuonRPCDigis/interface/RPCDigiValid.h" #include "DataFormats/GeometryVector/interface/GlobalPoint.h" #include "DataFormats/GeometryVector/interface/LocalPoint.h" @@ -19,37 +20,31 @@ RPCDigiValid::RPCDigiValid(const ParameterSet &ps) { // configuration. The second param is default value module, instance and // process labels may be passed in a single string if separated by colon ':' // (@see the edm::InputTag constructor documentation) - simHitToken = consumes( + simHitToken_ = consumes( ps.getUntrackedParameter("simHitTag", edm::InputTag("g4SimHits:MuonRPCHits"))); - rpcDigiToken = consumes( + rpcDigiToken_ = consumes( ps.getUntrackedParameter("rpcDigiTag", edm::InputTag("simMuonRPCDigis"))); - outputFile_ = ps.getUntrackedParameter("outputFile", "rpcDigiValidPlots.root"); - rpcGeomToken_ = esConsumes(); } -RPCDigiValid::~RPCDigiValid() {} - void RPCDigiValid::analyze(const Event &event, const EventSetup &eventSetup) { // Get the RPC Geometry auto rpcGeom = eventSetup.getHandle(rpcGeomToken_); - edm::Handle simHit; - edm::Handle rpcDigis; - event.getByToken(simHitToken, simHit); - event.getByToken(rpcDigiToken, rpcDigis); - - // Loop on simhits - PSimHitContainer::const_iterator simIt; + edm::Handle simHitHandle; + edm::Handle rpcDigisHandle; + event.getByToken(simHitToken_, simHitHandle); + event.getByToken(rpcDigiToken_, rpcDigisHandle); // loop over Simhit std::map> allsims; - for (simIt = simHit->begin(); simIt != simHit->end(); simIt++) { - RPCDetId Rsid = (RPCDetId)(*simIt).detUnitId(); + for (auto simIt = simHitHandle->begin(); simIt != simHitHandle->end(); ++simIt) { + RPCDetId Rsid = simIt->detUnitId(); const RPCRoll *soll = dynamic_cast(rpcGeom->roll(Rsid)); - int ptype = simIt->particleType(); + if (!soll) continue; + const int ptype = simIt->particleType(); if (ptype == 13 || ptype == -13) { std::vector buff; @@ -61,10 +56,10 @@ void RPCDigiValid::analyze(const Event &event, const EventSetup &eventSetup) { allsims[Rsid] = buff; } - GlobalPoint p = soll->toGlobal(simIt->localPosition()); + const GlobalPoint p = soll->toGlobal(simIt->localPosition()); - double sim_x = p.x(); - double sim_y = p.y(); + const double sim_x = p.x(); + const double sim_y = p.y(); xyview->Fill(sim_x, sim_y); @@ -80,8 +75,7 @@ void RPCDigiValid::analyze(const Event &event, const EventSetup &eventSetup) { rzview->Fill(p.z(), p.perp()); } // loop over Digis - RPCDigiCollection::DigiRangeIterator detUnitIt; - for (detUnitIt = rpcDigis->begin(); detUnitIt != rpcDigis->end(); ++detUnitIt) { + for (auto detUnitIt = rpcDigisHandle->begin(); detUnitIt != rpcDigisHandle->end(); ++detUnitIt) { const RPCDetId Rsid = (*detUnitIt).first; const RPCRoll *roll = dynamic_cast(rpcGeom->roll(Rsid)); @@ -91,8 +85,7 @@ void RPCDigiValid::analyze(const Event &event, const EventSetup &eventSetup) { sims = allsims[Rsid]; } - int ndigi = 0; - for (RPCDigiCollection::const_iterator digiIt = range.first; digiIt != range.second; ++digiIt) { + for (auto digiIt = range.first; digiIt != range.second; ++digiIt) { StripProf->Fill(digiIt->strip()); BxDist->Fill(digiIt->bx()); // bx for 4 endcaps @@ -115,87 +108,6 @@ void RPCDigiValid::analyze(const Event &event, const EventSetup &eventSetup) { hDigiTimeNoIRPC->Fill(digiTime); } } - - if (sims.size() == 1 && ndigi == 1) { - double dis = roll->centreOfStrip(range.first->strip()).x() - sims[0]; - Res->Fill(dis); - - if (Rsid.region() == 0) { - if (Rsid.ring() == -2) - ResWmin2->Fill(dis); - else if (Rsid.ring() == -1) - ResWmin1->Fill(dis); - else if (Rsid.ring() == 0) - ResWzer0->Fill(dis); - else if (Rsid.ring() == 1) - ResWplu1->Fill(dis); - else if (Rsid.ring() == 2) - ResWplu2->Fill(dis); - // barrel layers - if (Rsid.station() == 1 && Rsid.layer() == 1) - ResLayer1_barrel->Fill(dis); - if (Rsid.station() == 1 && Rsid.layer() == 2) - ResLayer2_barrel->Fill(dis); - if (Rsid.station() == 2 && Rsid.layer() == 1) - ResLayer3_barrel->Fill(dis); - if (Rsid.station() == 2 && Rsid.layer() == 2) - ResLayer4_barrel->Fill(dis); - if (Rsid.station() == 3) - ResLayer5_barrel->Fill(dis); - if (Rsid.station() == 4) - ResLayer6_barrel->Fill(dis); - } - // endcap layers residuals - if (Rsid.region() != 0) { - if (Rsid.ring() == 2) { - if (abs(Rsid.station()) == 1) { - if (Rsid.roll() == 1) - Res_Endcap1_Ring2_A->Fill(dis); - if (Rsid.roll() == 2) - Res_Endcap1_Ring2_B->Fill(dis); - if (Rsid.roll() == 3) - Res_Endcap1_Ring2_C->Fill(dis); - } - if (abs(Rsid.station()) == 2 || abs(Rsid.station()) == 3) { - if (Rsid.roll() == 1) - Res_Endcap23_Ring2_A->Fill(dis); - if (Rsid.roll() == 2) - Res_Endcap23_Ring2_B->Fill(dis); - if (Rsid.roll() == 3) - Res_Endcap23_Ring2_C->Fill(dis); - } - } - if (Rsid.ring() == 3) { - if (Rsid.roll() == 1) - Res_Endcap123_Ring3_A->Fill(dis); - if (Rsid.roll() == 2) - Res_Endcap123_Ring3_B->Fill(dis); - if (Rsid.roll() == 3) - Res_Endcap123_Ring3_C->Fill(dis); - } - } - - if (Rsid.region() == (+1)) { - if (Rsid.station() == 1) - ResDplu1->Fill(dis); - else if (Rsid.station() == 2) - ResDplu2->Fill(dis); - else if (Rsid.station() == 3) - ResDplu3->Fill(dis); - else if (Rsid.station() == 4) - ResDplu4->Fill(dis); - } - if (Rsid.region() == (-1)) { - if (Rsid.station() == 1) - ResDmin1->Fill(dis); - else if (Rsid.station() == 2) - ResDmin2->Fill(dis); - else if (Rsid.station() == 3) - ResDmin3->Fill(dis); - else if (Rsid.station() == 4) - ResDmin4->Fill(dis); - } - } } } @@ -208,19 +120,6 @@ void RPCDigiValid::bookHistograms(DQMStore::IBooker &booker, edm::Run const &run xyvDmin4 = booker.book2D("Dmin4_XvsY", "Dmin4_XvsY", 155, -775., 775., 155, -775., 775.); rzview = booker.book2D("R_Vs_Z_View", "R_Vs_Z_View", 216, -1080., 1080., 52, 260., 780.); - Res = booker.book1D("Digi_SimHit_difference", "Digi_SimHit_difference", 300, -8, 8); - ResWmin2 = booker.book1D("W_Min2_Residuals", "W_Min2_Residuals", 400, -8, 8); - ResWmin1 = booker.book1D("W_Min1_Residuals", "W_Min1_Residuals", 400, -8, 8); - ResWzer0 = booker.book1D("W_Zer0_Residuals", "W_Zer0_Residuals", 400, -8, 8); - ResWplu1 = booker.book1D("W_Plu1_Residuals", "W_Plu1_Residuals", 400, -8, 8); - ResWplu2 = booker.book1D("W_Plu2_Residuals", "W_Plu2_Residuals", 400, -8, 8); - - ResLayer1_barrel = booker.book1D("ResLayer1_barrel", "ResLayer1_barrel", 400, -8, 8); - ResLayer2_barrel = booker.book1D("ResLayer2_barrel", "ResLayer2_barrel", 400, -8, 8); - ResLayer3_barrel = booker.book1D("ResLayer3_barrel", "ResLayer3_barrel", 400, -8, 8); - ResLayer4_barrel = booker.book1D("ResLayer4_barrel", "ResLayer4_barrel", 400, -8, 8); - ResLayer5_barrel = booker.book1D("ResLayer5_barrel", "ResLayer5_barrel", 400, -8, 8); - ResLayer6_barrel = booker.book1D("ResLayer6_barrel", "ResLayer6_barrel", 400, -8, 8); BxDist = booker.book1D("Bunch_Crossing", "Bunch_Crossing", 20, -10., 10.); StripProf = booker.book1D("Strip_Profile", "Strip_Profile", 100, 0, 100); @@ -228,29 +127,6 @@ void RPCDigiValid::bookHistograms(DQMStore::IBooker &booker, edm::Run const &run BxDisc_4Plus = booker.book1D("BxDisc_4Plus", "BxDisc_4Plus", 20, -10., 10.); BxDisc_4Min = booker.book1D("BxDisc_4Min", "BxDisc_4Min", 20, -10., 10.); - // endcap residuals - ResDmin1 = booker.book1D("Disk_Min1_Residuals", "Disk_Min1_Residuals", 400, -8, 8); - ResDmin2 = booker.book1D("Disk_Min2_Residuals", "Disk_Min2_Residuals", 400, -8, 8); - ResDmin3 = booker.book1D("Disk_Min3_Residuals", "Disk_Min3_Residuals", 400, -8, 8); - ResDplu1 = booker.book1D("Disk_Plu1_Residuals", "Disk_Plu1_Residuals", 400, -8, 8); - ResDplu2 = booker.book1D("Disk_Plu2_Residuals", "Disk_Plu2_Residuals", 400, -8, 8); - ResDplu3 = booker.book1D("Disk_Plu3_Residuals", "Disk_Plu3_Residuals", 400, -8, 8); - - ResDmin4 = booker.book1D("Disk_Min4_Residuals", "Disk_Min4_Residuals", 400, -8, 8); - ResDplu4 = booker.book1D("Disk_Plu4_Residuals", "Disk_Plu4_Residuals", 400, -8, 8); - - Res_Endcap1_Ring2_A = booker.book1D("Res_Endcap1_Ring2_A", "Res_Endcap1_Ring2_A", 400, -8, 8); - Res_Endcap1_Ring2_B = booker.book1D("Res_Endcap1_Ring2_B", "Res_Endcap1_Ring2_B", 400, -8, 8); - Res_Endcap1_Ring2_C = booker.book1D("Res_Endcap1_Ring2_C", "Res_Endcap1_Ring2_C", 400, -8, 8); - - Res_Endcap23_Ring2_A = booker.book1D("Res_Endcap23_Ring2_A", "Res_Endcap23_Ring2_A", 400, -8, 8); - Res_Endcap23_Ring2_B = booker.book1D("Res_Endcap23_Ring2_B", "Res_Endcap23_Ring2_B", 400, -8, 8); - Res_Endcap23_Ring2_C = booker.book1D("Res_Endcap23_Ring2_C", "Res_Endcap23_Ring2_C", 400, -8, 8); - - Res_Endcap123_Ring3_A = booker.book1D("Res_Endcap123_Ring3_A", "Res_Endcap123_Ring3_A", 400, -8, 8); - Res_Endcap123_Ring3_B = booker.book1D("Res_Endcap123_Ring3_B", "Res_Endcap123_Ring3_B", 400, -8, 8); - Res_Endcap123_Ring3_C = booker.book1D("Res_Endcap123_Ring3_C", "Res_Endcap123_Ring3_C", 400, -8, 8); - // Timing informations hDigiTimeAll = booker.book1D("DigiTimeAll", "Digi time including present electronics;Digi time (ns)", 100, -12.5, 12.5); From 1ce2b6f075d26c6c5a6483b462909e5a63306a2b Mon Sep 17 00:00:00 2001 From: Junghwan John Goh Date: Fri, 3 May 2024 19:23:18 +0200 Subject: [PATCH 006/237] remove unused variable, due to removal of residual plots --- Validation/MuonRPCDigis/src/RPCDigiValid.cc | 38 ++++++--------------- 1 file changed, 10 insertions(+), 28 deletions(-) diff --git a/Validation/MuonRPCDigis/src/RPCDigiValid.cc b/Validation/MuonRPCDigis/src/RPCDigiValid.cc index b57cc8f004635..d2005263cae07 100644 --- a/Validation/MuonRPCDigis/src/RPCDigiValid.cc +++ b/Validation/MuonRPCDigis/src/RPCDigiValid.cc @@ -38,38 +38,22 @@ void RPCDigiValid::analyze(const Event &event, const EventSetup &eventSetup) { event.getByToken(rpcDigiToken_, rpcDigisHandle); // loop over Simhit - std::map> allsims; - for (auto simIt = simHitHandle->begin(); simIt != simHitHandle->end(); ++simIt) { - RPCDetId Rsid = simIt->detUnitId(); - const RPCRoll *soll = dynamic_cast(rpcGeom->roll(Rsid)); - if (!soll) continue; - const int ptype = simIt->particleType(); - - if (ptype == 13 || ptype == -13) { - std::vector buff; - if (allsims.find(Rsid) != allsims.end()) { - buff = allsims[Rsid]; - } - - buff.push_back(simIt->localPosition().x()); - - allsims[Rsid] = buff; - } - const GlobalPoint p = soll->toGlobal(simIt->localPosition()); - - const double sim_x = p.x(); - const double sim_y = p.y(); + const RPCDetId Rsid = simIt->detUnitId(); + const RPCRoll *roll = dynamic_cast(rpcGeom->roll(Rsid)); + if (!roll) + continue; - xyview->Fill(sim_x, sim_y); + const GlobalPoint p = roll->toGlobal(simIt->localPosition()); + xyview->Fill(p.x(), p.y()); if (Rsid.region() == (+1)) { if (Rsid.station() == 4) { - xyvDplu4->Fill(sim_x, sim_y); + xyvDplu4->Fill(p.x(), p.y()); } } else if (Rsid.region() == (-1)) { if (Rsid.station() == 4) { - xyvDmin4->Fill(sim_x, sim_y); + xyvDmin4->Fill(p.x(), p.y()); } } rzview->Fill(p.z(), p.perp()); @@ -78,12 +62,10 @@ void RPCDigiValid::analyze(const Event &event, const EventSetup &eventSetup) { for (auto detUnitIt = rpcDigisHandle->begin(); detUnitIt != rpcDigisHandle->end(); ++detUnitIt) { const RPCDetId Rsid = (*detUnitIt).first; const RPCRoll *roll = dynamic_cast(rpcGeom->roll(Rsid)); + if (!roll) + continue; const RPCDigiCollection::Range &range = (*detUnitIt).second; - std::vector sims; - if (allsims.find(Rsid) != allsims.end()) { - sims = allsims[Rsid]; - } for (auto digiIt = range.first; digiIt != range.second; ++digiIt) { StripProf->Fill(digiIt->strip()); From 308c88930eee9222af350a07d9ba0c677004857c Mon Sep 17 00:00:00 2001 From: Junghwan John Goh Date: Fri, 3 May 2024 20:28:48 +0200 Subject: [PATCH 007/237] add simHit position and strip profiles splited by regions --- .../MuonRPCDigis/interface/RPCDigiValid.h | 17 +++- Validation/MuonRPCDigis/src/RPCDigiValid.cc | 92 +++++++++++++------ 2 files changed, 75 insertions(+), 34 deletions(-) diff --git a/Validation/MuonRPCDigis/interface/RPCDigiValid.h b/Validation/MuonRPCDigis/interface/RPCDigiValid.h index d6dc808dd2e77..c7c41118ae3b7 100644 --- a/Validation/MuonRPCDigis/interface/RPCDigiValid.h +++ b/Validation/MuonRPCDigis/interface/RPCDigiValid.h @@ -27,15 +27,22 @@ class RPCDigiValid : public DQMEDAnalyzer { void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override; private: - MonitorElement *xyview; - MonitorElement *rzview; + // RZ and XY views + MonitorElement *hRZ_; + + MonitorElement *hXY_Barrel_; + std::map hXY_Endcap_; + + // Strip profile + MonitorElement *hStripProf; + MonitorElement *hStripProf_RB12_, *hStripProf_RB34_; + MonitorElement *hStripProf_Endcap_, *hStripProf_IRPC_; + + // Bunch crossing distributions MonitorElement *BxDist; - MonitorElement *StripProf; MonitorElement *BxDisc_4Plus; MonitorElement *BxDisc_4Min; - MonitorElement *xyvDplu4; - MonitorElement *xyvDmin4; // Timing information MonitorElement *hDigiTimeAll, *hDigiTime, *hDigiTimeIRPC, *hDigiTimeNoIRPC; diff --git a/Validation/MuonRPCDigis/src/RPCDigiValid.cc b/Validation/MuonRPCDigis/src/RPCDigiValid.cc index d2005263cae07..2d6c6a0d4ae1d 100644 --- a/Validation/MuonRPCDigis/src/RPCDigiValid.cc +++ b/Validation/MuonRPCDigis/src/RPCDigiValid.cc @@ -10,6 +10,7 @@ #include "Geometry/CommonTopologies/interface/TrapezoidalStripTopology.h" #include +#include using namespace std; using namespace edm; @@ -39,43 +40,63 @@ void RPCDigiValid::analyze(const Event &event, const EventSetup &eventSetup) { // loop over Simhit for (auto simIt = simHitHandle->begin(); simIt != simHitHandle->end(); ++simIt) { - const RPCDetId Rsid = simIt->detUnitId(); - const RPCRoll *roll = dynamic_cast(rpcGeom->roll(Rsid)); + const RPCDetId rsid = simIt->detUnitId(); + const RPCRoll *roll = dynamic_cast(rpcGeom->roll(rsid)); if (!roll) continue; - - const GlobalPoint p = roll->toGlobal(simIt->localPosition()); - xyview->Fill(p.x(), p.y()); - - if (Rsid.region() == (+1)) { - if (Rsid.station() == 4) { - xyvDplu4->Fill(p.x(), p.y()); - } - } else if (Rsid.region() == (-1)) { - if (Rsid.station() == 4) { - xyvDmin4->Fill(p.x(), p.y()); - } + const int region = rsid.region(); + const GlobalPoint gp = roll->toGlobal(simIt->localPosition()); + + hRZ_->Fill(gp.z(), gp.perp()); + + if (region == 0) { + // Barrel + hXY_Barrel_->Fill(gp.x(), gp.y()); + } else { + // Endcap + const int disk = region * rsid.station(); + auto match = hXY_Endcap_.find(disk); + if (match != hXY_Endcap_.end()) + match->second->Fill(gp.x(), gp.y()); } - rzview->Fill(p.z(), p.perp()); } // loop over Digis for (auto detUnitIt = rpcDigisHandle->begin(); detUnitIt != rpcDigisHandle->end(); ++detUnitIt) { - const RPCDetId Rsid = (*detUnitIt).first; - const RPCRoll *roll = dynamic_cast(rpcGeom->roll(Rsid)); + const RPCDetId rsid = (*detUnitIt).first; + const RPCRoll *roll = dynamic_cast(rpcGeom->roll(rsid)); if (!roll) continue; + const int region = rsid.region(); const RPCDigiCollection::Range &range = (*detUnitIt).second; for (auto digiIt = range.first; digiIt != range.second; ++digiIt) { - StripProf->Fill(digiIt->strip()); + // Strip profile + const int strip = digiIt->strip(); + hStripProf->Fill(strip); + + if (region == 0) { + // Barrel + const int station = rsid.station(); + if (station == 1 or station == 2) + hStripProf_RB12_->Fill(strip); + else if (station == 3 or station == 4) + hStripProf_RB34_->Fill(strip); + } else { + const int ring = rsid.ring(); + if (ring == 1) + hStripProf_IRPC_->Fill(strip); + else + hStripProf_Endcap_->Fill(strip); + } + BxDist->Fill(digiIt->bx()); // bx for 4 endcaps - if (Rsid.region() == (+1)) { - if (Rsid.station() == 4) + if (rsid.region() == (+1)) { + if (rsid.station() == 4) BxDisc_4Plus->Fill(digiIt->bx()); - } else if (Rsid.region() == (-1)) { - if (Rsid.station() == 4) + } else if (rsid.region() == (-1)) { + if (rsid.station() == 4) BxDisc_4Min->Fill(digiIt->bx()); } @@ -96,16 +117,29 @@ void RPCDigiValid::analyze(const Event &event, const EventSetup &eventSetup) { void RPCDigiValid::bookHistograms(DQMStore::IBooker &booker, edm::Run const &run, edm::EventSetup const &eSetup) { booker.setCurrentFolder("RPCDigisV/RPCDigis"); - xyview = booker.book2D("X_Vs_Y_View", "X_Vs_Y_View", 155, -775., 775., 155, -775., 775.); - - xyvDplu4 = booker.book2D("Dplu4_XvsY", "Dplu4_XvsY", 155, -775., 775., 155, -775., 775.); - xyvDmin4 = booker.book2D("Dmin4_XvsY", "Dmin4_XvsY", 155, -775., 775., 155, -775., 775.); + // RZ plot + hRZ_ = booker.book2D("RZ", "RZ", 220, -1100., 1100., 60, 0., 780.); + + // XY plots + const int nbinsXY = 155; + const double xmaxXY = 775; + hXY_Barrel_ = booker.book2D("XY_Barrel", "XY_Barrel", nbinsXY, -xmaxXY, xmaxXY, nbinsXY, -xmaxXY, xmaxXY); + for (int disk = 1; disk <= 4; ++disk) { + const std::string meNameP = fmt::format("XY_EndcapP{:1d}", disk); + const std::string meNameN = fmt::format("XY_EndcapN{:1d}", disk); + hXY_Endcap_[disk] = booker.book2D(meNameP, meNameP, nbinsXY, -xmaxXY, xmaxXY, nbinsXY, -xmaxXY, xmaxXY); + hXY_Endcap_[-disk] = booker.book2D(meNameN, meNameN, nbinsXY, -xmaxXY, xmaxXY, nbinsXY, -xmaxXY, xmaxXY); + } - rzview = booker.book2D("R_Vs_Z_View", "R_Vs_Z_View", 216, -1080., 1080., 52, 260., 780.); + // Strip profile + hStripProf = booker.book1D("Strip_Profile", "Strip_Profile", 100, 0, 100); + hStripProf_RB12_ = booker.book1D("Strip_Profile_RB12", "Strip Profile RB1 and RB2", 100, 0, 100); + hStripProf_RB34_ = booker.book1D("Strip_Profile_RB12", "Strip Profile RB1 and RB2", 50, 0, 50); + hStripProf_Endcap_ = booker.book1D("Strip_Profile_Endcap", "Strip Profile Endcap", 40, 0, 40); + hStripProf_IRPC_ = booker.book1D("Strip_Profile_IRPC", "Strip Profile IRPC", 100, 0, 100); + // Bunch crossing BxDist = booker.book1D("Bunch_Crossing", "Bunch_Crossing", 20, -10., 10.); - StripProf = booker.book1D("Strip_Profile", "Strip_Profile", 100, 0, 100); - BxDisc_4Plus = booker.book1D("BxDisc_4Plus", "BxDisc_4Plus", 20, -10., 10.); BxDisc_4Min = booker.book1D("BxDisc_4Min", "BxDisc_4Min", 20, -10., 10.); From 29e51f3a4f0ac8f54400ca8d45cfbdf28eb51369 Mon Sep 17 00:00:00 2001 From: Junghwan John Goh Date: Fri, 3 May 2024 20:39:30 +0200 Subject: [PATCH 008/237] rename variable to follow convention --- .../MuonRPCDigis/interface/RPCDigiValid.h | 11 +++-- Validation/MuonRPCDigis/src/RPCDigiValid.cc | 42 +++++++++---------- 2 files changed, 26 insertions(+), 27 deletions(-) diff --git a/Validation/MuonRPCDigis/interface/RPCDigiValid.h b/Validation/MuonRPCDigis/interface/RPCDigiValid.h index c7c41118ae3b7..d2810302fa83a 100644 --- a/Validation/MuonRPCDigis/interface/RPCDigiValid.h +++ b/Validation/MuonRPCDigis/interface/RPCDigiValid.h @@ -34,18 +34,17 @@ class RPCDigiValid : public DQMEDAnalyzer { std::map hXY_Endcap_; // Strip profile - MonitorElement *hStripProf; + MonitorElement *hStripProf_; MonitorElement *hStripProf_RB12_, *hStripProf_RB34_; MonitorElement *hStripProf_Endcap_, *hStripProf_IRPC_; // Bunch crossing distributions - MonitorElement *BxDist; - - MonitorElement *BxDisc_4Plus; - MonitorElement *BxDisc_4Min; + MonitorElement *hBxDist_; + MonitorElement *hBxDisc_4Plus_; + MonitorElement *hBxDisc_4Min_; // Timing information - MonitorElement *hDigiTimeAll, *hDigiTime, *hDigiTimeIRPC, *hDigiTimeNoIRPC; + MonitorElement *hDigiTimeAll_, *hDigiTime_, *hDigiTimeIRPC_, *hDigiTimeNoIRPC_; // Tokens for accessing run data. Used for passing to edm::Event. - stanislav edm::EDGetTokenT simHitToken_; diff --git a/Validation/MuonRPCDigis/src/RPCDigiValid.cc b/Validation/MuonRPCDigis/src/RPCDigiValid.cc index 2d6c6a0d4ae1d..87b2e225b1bc8 100644 --- a/Validation/MuonRPCDigis/src/RPCDigiValid.cc +++ b/Validation/MuonRPCDigis/src/RPCDigiValid.cc @@ -76,39 +76,39 @@ void RPCDigiValid::analyze(const Event &event, const EventSetup &eventSetup) { hStripProf->Fill(strip); if (region == 0) { - // Barrel const int station = rsid.station(); if (station == 1 or station == 2) hStripProf_RB12_->Fill(strip); else if (station == 3 or station == 4) hStripProf_RB34_->Fill(strip); } else { - const int ring = rsid.ring(); - if (ring == 1) + if (roll->isIRPC()) hStripProf_IRPC_->Fill(strip); else hStripProf_Endcap_->Fill(strip); } - BxDist->Fill(digiIt->bx()); + // Bunch crossing + const int bx = digiIt->bx(); + hBxDist_->Fill(bx); // bx for 4 endcaps - if (rsid.region() == (+1)) { - if (rsid.station() == 4) - BxDisc_4Plus->Fill(digiIt->bx()); - } else if (rsid.region() == (-1)) { - if (rsid.station() == 4) - BxDisc_4Min->Fill(digiIt->bx()); + if (rsid.station() == 4) { + if (region == 1) { + hBxDisc_4Plus_->Fill(bx); + } else if (region == -1) { + hBxDisc_4Min_->Fill(bx); + } } // Fill timing information const double digiTime = digiIt->hasTime() ? digiIt->time() : digiIt->bx() * 25; - hDigiTimeAll->Fill(digiTime); + hDigiTimeAll_->Fill(digiTime); if (digiIt->hasTime()) { - hDigiTime->Fill(digiTime); + hDigiTime_->Fill(digiTime); if (roll->isIRPC()) - hDigiTimeIRPC->Fill(digiTime); + hDigiTimeIRPC_->Fill(digiTime); else - hDigiTimeNoIRPC->Fill(digiTime); + hDigiTimeNoIRPC_->Fill(digiTime); } } } @@ -139,14 +139,14 @@ void RPCDigiValid::bookHistograms(DQMStore::IBooker &booker, edm::Run const &run hStripProf_IRPC_ = booker.book1D("Strip_Profile_IRPC", "Strip Profile IRPC", 100, 0, 100); // Bunch crossing - BxDist = booker.book1D("Bunch_Crossing", "Bunch_Crossing", 20, -10., 10.); - BxDisc_4Plus = booker.book1D("BxDisc_4Plus", "BxDisc_4Plus", 20, -10., 10.); - BxDisc_4Min = booker.book1D("BxDisc_4Min", "BxDisc_4Min", 20, -10., 10.); + hBxDist_ = booker.book1D("Bunch_Crossing", "Bunch_Crossing", 20, -10., 10.); + hBxDisc_4Plus_ = booker.book1D("BxDisc_4Plus", "BxDisc_4Plus", 20, -10., 10.); + hBxDisc_4Min_ = booker.book1D("BxDisc_4Min", "BxDisc_4Min", 20, -10., 10.); // Timing informations - hDigiTimeAll = + hDigiTimeAll_ = booker.book1D("DigiTimeAll", "Digi time including present electronics;Digi time (ns)", 100, -12.5, 12.5); - hDigiTime = booker.book1D("DigiTime", "Digi time only with timing information;Digi time (ns)", 100, -12.5, 12.5); - hDigiTimeIRPC = booker.book1D("DigiTimeIRPC", "IRPC Digi time;Digi time (ns)", 100, -12.5, 12.5); - hDigiTimeNoIRPC = booker.book1D("DigiTimeNoIRPC", "non-IRPC Digi time;Digi time (ns)", 100, -12.5, 12.5); + hDigiTime_ = booker.book1D("DigiTime", "Digi time only with timing information;Digi time (ns)", 100, -12.5, 12.5); + hDigiTimeIRPC_ = booker.book1D("DigiTimeIRPC", "IRPC Digi time;Digi time (ns)", 100, -12.5, 12.5); + hDigiTimeNoIRPC_ = booker.book1D("DigiTimeNoIRPC", "non-IRPC Digi time;Digi time (ns)", 100, -12.5, 12.5); } From 10e8478ccc4a367954a26c2f07d4ab846c382508 Mon Sep 17 00:00:00 2001 From: Junghwan John Goh Date: Fri, 3 May 2024 20:40:51 +0200 Subject: [PATCH 009/237] fix typo --- Validation/MuonRPCDigis/src/RPCDigiValid.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Validation/MuonRPCDigis/src/RPCDigiValid.cc b/Validation/MuonRPCDigis/src/RPCDigiValid.cc index 87b2e225b1bc8..63df420fbbc4e 100644 --- a/Validation/MuonRPCDigis/src/RPCDigiValid.cc +++ b/Validation/MuonRPCDigis/src/RPCDigiValid.cc @@ -73,7 +73,7 @@ void RPCDigiValid::analyze(const Event &event, const EventSetup &eventSetup) { for (auto digiIt = range.first; digiIt != range.second; ++digiIt) { // Strip profile const int strip = digiIt->strip(); - hStripProf->Fill(strip); + hStripProf_->Fill(strip); if (region == 0) { const int station = rsid.station(); @@ -132,7 +132,7 @@ void RPCDigiValid::bookHistograms(DQMStore::IBooker &booker, edm::Run const &run } // Strip profile - hStripProf = booker.book1D("Strip_Profile", "Strip_Profile", 100, 0, 100); + hStripProf_ = booker.book1D("Strip_Profile", "Strip_Profile", 100, 0, 100); hStripProf_RB12_ = booker.book1D("Strip_Profile_RB12", "Strip Profile RB1 and RB2", 100, 0, 100); hStripProf_RB34_ = booker.book1D("Strip_Profile_RB12", "Strip Profile RB1 and RB2", 50, 0, 50); hStripProf_Endcap_ = booker.book1D("Strip_Profile_Endcap", "Strip Profile Endcap", 40, 0, 40); From 4d3e7019800953a6c6e147c732bda4052527790c Mon Sep 17 00:00:00 2001 From: Junghwan John Goh Date: Fri, 3 May 2024 20:59:15 +0200 Subject: [PATCH 010/237] fix typo --- Validation/MuonRPCDigis/src/RPCDigiValid.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Validation/MuonRPCDigis/src/RPCDigiValid.cc b/Validation/MuonRPCDigis/src/RPCDigiValid.cc index 63df420fbbc4e..d781eef650316 100644 --- a/Validation/MuonRPCDigis/src/RPCDigiValid.cc +++ b/Validation/MuonRPCDigis/src/RPCDigiValid.cc @@ -134,7 +134,7 @@ void RPCDigiValid::bookHistograms(DQMStore::IBooker &booker, edm::Run const &run // Strip profile hStripProf_ = booker.book1D("Strip_Profile", "Strip_Profile", 100, 0, 100); hStripProf_RB12_ = booker.book1D("Strip_Profile_RB12", "Strip Profile RB1 and RB2", 100, 0, 100); - hStripProf_RB34_ = booker.book1D("Strip_Profile_RB12", "Strip Profile RB1 and RB2", 50, 0, 50); + hStripProf_RB34_ = booker.book1D("Strip_Profile_RB34", "Strip Profile RB3 and RB4", 50, 0, 50); hStripProf_Endcap_ = booker.book1D("Strip_Profile_Endcap", "Strip Profile Endcap", 40, 0, 40); hStripProf_IRPC_ = booker.book1D("Strip_Profile_IRPC", "Strip Profile IRPC", 100, 0, 100); From 32a9e7b97e4b489fe907346a6b1f1dff66d03287 Mon Sep 17 00:00:00 2001 From: Junghwan John Goh Date: Fri, 10 May 2024 15:34:45 +0200 Subject: [PATCH 011/237] add r-phi plots, refine binnings --- .../MuonRPCDigis/interface/RPCDigiValid.h | 3 +- Validation/MuonRPCDigis/src/RPCDigiValid.cc | 37 +++++++++++++++---- 2 files changed, 31 insertions(+), 9 deletions(-) diff --git a/Validation/MuonRPCDigis/interface/RPCDigiValid.h b/Validation/MuonRPCDigis/interface/RPCDigiValid.h index d2810302fa83a..a12cd30fe7934 100644 --- a/Validation/MuonRPCDigis/interface/RPCDigiValid.h +++ b/Validation/MuonRPCDigis/interface/RPCDigiValid.h @@ -31,7 +31,8 @@ class RPCDigiValid : public DQMEDAnalyzer { MonitorElement *hRZ_; MonitorElement *hXY_Barrel_; - std::map hXY_Endcap_; + std::map hXY_Endcap_; // X-Y plots for Endcap, by station + std::map hRPhi_; // R-phi plots for Barrel, by layers // Strip profile MonitorElement *hStripProf_; diff --git a/Validation/MuonRPCDigis/src/RPCDigiValid.cc b/Validation/MuonRPCDigis/src/RPCDigiValid.cc index d781eef650316..544864c136a6f 100644 --- a/Validation/MuonRPCDigis/src/RPCDigiValid.cc +++ b/Validation/MuonRPCDigis/src/RPCDigiValid.cc @@ -52,6 +52,14 @@ void RPCDigiValid::analyze(const Event &event, const EventSetup &eventSetup) { if (region == 0) { // Barrel hXY_Barrel_->Fill(gp.x(), gp.y()); + + const int station = rsid.station(); + const int layer = rsid.layer(); + const int stla = (station <= 2) ? (2 * (station - 1) + layer) : (station + 2); + + auto match = hRPhi_.find(stla); + if (match != hRPhi_.end()) + match->second->Fill(gp.z(), gp.phi()); } else { // Endcap const int disk = region * rsid.station(); @@ -117,24 +125,37 @@ void RPCDigiValid::analyze(const Event &event, const EventSetup &eventSetup) { void RPCDigiValid::bookHistograms(DQMStore::IBooker &booker, edm::Run const &run, edm::EventSetup const &eSetup) { booker.setCurrentFolder("RPCDigisV/RPCDigis"); + // Define binnings of 2D-histograms + const double maxZ = 1100; + const int nbinsZ = 220; // bin width: 10cm + const double maxXY = 800; + const int nbinsXY = 160; // bin width: 10cm + const double minR = 100, maxR = 800; + const int nbinsR = 70; // bin width: 10cm + const int nbinsPhi = 180; // bin width: 2 degree + // RZ plot - hRZ_ = booker.book2D("RZ", "RZ", 220, -1100., 1100., 60, 0., 780.); + hRZ_ = booker.book2D("RZ", "RZ", nbinsZ, -maxZ, maxZ, nbinsR, minR, maxR); // XY plots - const int nbinsXY = 155; - const double xmaxXY = 775; - hXY_Barrel_ = booker.book2D("XY_Barrel", "XY_Barrel", nbinsXY, -xmaxXY, xmaxXY, nbinsXY, -xmaxXY, xmaxXY); + hXY_Barrel_ = booker.book2D("XY_Barrel", "XY_Barrel", nbinsXY, -maxXY, maxXY, nbinsXY, -maxXY, maxXY); for (int disk = 1; disk <= 4; ++disk) { const std::string meNameP = fmt::format("XY_EndcapP{:1d}", disk); const std::string meNameN = fmt::format("XY_EndcapN{:1d}", disk); - hXY_Endcap_[disk] = booker.book2D(meNameP, meNameP, nbinsXY, -xmaxXY, xmaxXY, nbinsXY, -xmaxXY, xmaxXY); - hXY_Endcap_[-disk] = booker.book2D(meNameN, meNameN, nbinsXY, -xmaxXY, xmaxXY, nbinsXY, -xmaxXY, xmaxXY); + hXY_Endcap_[disk] = booker.book2D(meNameP, meNameP, nbinsXY, -maxXY, maxXY, nbinsXY, -maxXY, maxXY); + hXY_Endcap_[-disk] = booker.book2D(meNameN, meNameN, nbinsXY, -maxXY, maxXY, nbinsXY, -maxXY, maxXY); + } + + // Z-phi plots + for (int layer = 1; layer <= 6; ++layer) { + const std::string meName = fmt::format("RPhi_Layer{:1d}", layer); + hRPhi_[layer] = booker.book2D(meName, meName, nbinsZ, -maxZ, maxZ, nbinsPhi, 0, TMath::TwoPi()); } // Strip profile hStripProf_ = booker.book1D("Strip_Profile", "Strip_Profile", 100, 0, 100); - hStripProf_RB12_ = booker.book1D("Strip_Profile_RB12", "Strip Profile RB1 and RB2", 100, 0, 100); - hStripProf_RB34_ = booker.book1D("Strip_Profile_RB34", "Strip Profile RB3 and RB4", 50, 0, 50); + hStripProf_RB12_ = booker.book1D("Strip_Profile_RB12", "Strip Profile RB1 and RB2", 92, 0, 92); + hStripProf_RB34_ = booker.book1D("Strip_Profile_RB34", "Strip Profile RB3 and RB4", 62, 0, 62); hStripProf_Endcap_ = booker.book1D("Strip_Profile_Endcap", "Strip Profile Endcap", 40, 0, 40); hStripProf_IRPC_ = booker.book1D("Strip_Profile_IRPC", "Strip Profile IRPC", 100, 0, 100); From 26482add56976cddf3c2af28be59e33792384733 Mon Sep 17 00:00:00 2001 From: Junghwan John Goh Date: Fri, 10 May 2024 17:51:19 +0200 Subject: [PATCH 012/237] refine bin range, set axis titles --- .../MuonRPCDigis/interface/RPCDigiValid.h | 2 +- Validation/MuonRPCDigis/src/RPCDigiValid.cc | 39 +++++++++++-------- 2 files changed, 24 insertions(+), 17 deletions(-) diff --git a/Validation/MuonRPCDigis/interface/RPCDigiValid.h b/Validation/MuonRPCDigis/interface/RPCDigiValid.h index a12cd30fe7934..2b9cb52fd9c60 100644 --- a/Validation/MuonRPCDigis/interface/RPCDigiValid.h +++ b/Validation/MuonRPCDigis/interface/RPCDigiValid.h @@ -32,7 +32,7 @@ class RPCDigiValid : public DQMEDAnalyzer { MonitorElement *hXY_Barrel_; std::map hXY_Endcap_; // X-Y plots for Endcap, by station - std::map hRPhi_; // R-phi plots for Barrel, by layers + std::map hZPhi_; // R-phi plots for Barrel, by layers // Strip profile MonitorElement *hStripProf_; diff --git a/Validation/MuonRPCDigis/src/RPCDigiValid.cc b/Validation/MuonRPCDigis/src/RPCDigiValid.cc index 544864c136a6f..339da8a49f26a 100644 --- a/Validation/MuonRPCDigis/src/RPCDigiValid.cc +++ b/Validation/MuonRPCDigis/src/RPCDigiValid.cc @@ -57,9 +57,11 @@ void RPCDigiValid::analyze(const Event &event, const EventSetup &eventSetup) { const int layer = rsid.layer(); const int stla = (station <= 2) ? (2 * (station - 1) + layer) : (station + 2); - auto match = hRPhi_.find(stla); - if (match != hRPhi_.end()) - match->second->Fill(gp.z(), gp.phi()); + auto match = hZPhi_.find(stla); + if (match != hZPhi_.end()) { + const double phiInDeg = gp.phi() / TMath::Pi() * 180; + match->second->Fill(gp.z(), phiInDeg); + } } else { // Endcap const int disk = region * rsid.station(); @@ -131,36 +133,41 @@ void RPCDigiValid::bookHistograms(DQMStore::IBooker &booker, edm::Run const &run const double maxXY = 800; const int nbinsXY = 160; // bin width: 10cm const double minR = 100, maxR = 800; - const int nbinsR = 70; // bin width: 10cm - const int nbinsPhi = 180; // bin width: 2 degree + const int nbinsR = 70; // bin width: 10cm + const int nbinsPhi = 90; // bin width: 4 degree + const double maxBarrelZ = 700; + const int nbinsBarrelZ = 140; // bin width: 10cm // RZ plot - hRZ_ = booker.book2D("RZ", "RZ", nbinsZ, -maxZ, maxZ, nbinsR, minR, maxR); + hRZ_ = booker.book2D("RZ", "RZ;Z (cm);R (cm)", nbinsZ, -maxZ, maxZ, nbinsR, minR, maxR); // XY plots hXY_Barrel_ = booker.book2D("XY_Barrel", "XY_Barrel", nbinsXY, -maxXY, maxXY, nbinsXY, -maxXY, maxXY); for (int disk = 1; disk <= 4; ++disk) { const std::string meNameP = fmt::format("XY_EndcapP{:1d}", disk); const std::string meNameN = fmt::format("XY_EndcapN{:1d}", disk); - hXY_Endcap_[disk] = booker.book2D(meNameP, meNameP, nbinsXY, -maxXY, maxXY, nbinsXY, -maxXY, maxXY); - hXY_Endcap_[-disk] = booker.book2D(meNameN, meNameN, nbinsXY, -maxXY, maxXY, nbinsXY, -maxXY, maxXY); + const std::string meTitleP = fmt::format("XY view of Endcap{:+1d};X (cm);Y (cm)", disk); + const std::string meTitleN = fmt::format("XY view of Endcap{:+1d};X (cm);Y (cm)", -disk); + hXY_Endcap_[disk] = booker.book2D(meNameP, meTitleP, nbinsXY, -maxXY, maxXY, nbinsXY, -maxXY, maxXY); + hXY_Endcap_[-disk] = booker.book2D(meNameN, meTitleN, nbinsXY, -maxXY, maxXY, nbinsXY, -maxXY, maxXY); } // Z-phi plots for (int layer = 1; layer <= 6; ++layer) { - const std::string meName = fmt::format("RPhi_Layer{:1d}", layer); - hRPhi_[layer] = booker.book2D(meName, meName, nbinsZ, -maxZ, maxZ, nbinsPhi, 0, TMath::TwoPi()); + const std::string meName = fmt::format("ZPhi_Layer{:1d}", layer); + const std::string meTitle = fmt::format("Z-#phi view of Layer{:1d};Z (cm);#phi (degree)", layer); + hZPhi_[layer] = booker.book2D(meName, meName, nbinsBarrelZ, -maxBarrelZ, maxBarrelZ, nbinsPhi, -180, 180); } // Strip profile - hStripProf_ = booker.book1D("Strip_Profile", "Strip_Profile", 100, 0, 100); - hStripProf_RB12_ = booker.book1D("Strip_Profile_RB12", "Strip Profile RB1 and RB2", 92, 0, 92); - hStripProf_RB34_ = booker.book1D("Strip_Profile_RB34", "Strip Profile RB3 and RB4", 62, 0, 62); - hStripProf_Endcap_ = booker.book1D("Strip_Profile_Endcap", "Strip Profile Endcap", 40, 0, 40); - hStripProf_IRPC_ = booker.book1D("Strip_Profile_IRPC", "Strip Profile IRPC", 100, 0, 100); + hStripProf_ = booker.book1D("Strip_Profile", "Strip_Profile;Strip Number", 100, 0, 100); + hStripProf_RB12_ = booker.book1D("Strip_Profile_RB12", "Strip Profile RB1 and RB2;Strip Number", 92, 0, 92); + hStripProf_RB34_ = booker.book1D("Strip_Profile_RB34", "Strip Profile RB3 and RB4;Strip Number", 62, 0, 62); + hStripProf_Endcap_ = booker.book1D("Strip_Profile_Endcap", "Strip Profile Endcap;Strip Number", 40, 0, 40); + hStripProf_IRPC_ = booker.book1D("Strip_Profile_IRPC", "Strip Profile IRPC;Strip Number", 100, 0, 100); // Bunch crossing - hBxDist_ = booker.book1D("Bunch_Crossing", "Bunch_Crossing", 20, -10., 10.); + hBxDist_ = booker.book1D("Bunch_Crossing", "Bunch Crossing;Bunch crossing", 20, -10., 10.); hBxDisc_4Plus_ = booker.book1D("BxDisc_4Plus", "BxDisc_4Plus", 20, -10., 10.); hBxDisc_4Min_ = booker.book1D("BxDisc_4Min", "BxDisc_4Min", 20, -10., 10.); From 995cbfb999a8fedc8b38285fe2ef0e058c441367 Mon Sep 17 00:00:00 2001 From: Junghwan John Goh Date: Fri, 10 May 2024 18:30:42 +0200 Subject: [PATCH 013/237] use barePhi rather than phi for globalPoint --- Validation/MuonRPCDigis/src/RPCDigiValid.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Validation/MuonRPCDigis/src/RPCDigiValid.cc b/Validation/MuonRPCDigis/src/RPCDigiValid.cc index 339da8a49f26a..68a881e124507 100644 --- a/Validation/MuonRPCDigis/src/RPCDigiValid.cc +++ b/Validation/MuonRPCDigis/src/RPCDigiValid.cc @@ -59,7 +59,7 @@ void RPCDigiValid::analyze(const Event &event, const EventSetup &eventSetup) { auto match = hZPhi_.find(stla); if (match != hZPhi_.end()) { - const double phiInDeg = gp.phi() / TMath::Pi() * 180; + const double phiInDeg = 180. * gp.barePhi() / TMath::Pi(); match->second->Fill(gp.z(), phiInDeg); } } else { From 4fb7d015948fde5fe1250cc2efe714031ec46680 Mon Sep 17 00:00:00 2001 From: Junghwan John Goh Date: Fri, 10 May 2024 19:44:38 +0200 Subject: [PATCH 014/237] fix typo --- Validation/MuonRPCDigis/src/RPCDigiValid.cc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Validation/MuonRPCDigis/src/RPCDigiValid.cc b/Validation/MuonRPCDigis/src/RPCDigiValid.cc index 68a881e124507..9a50005c656d6 100644 --- a/Validation/MuonRPCDigis/src/RPCDigiValid.cc +++ b/Validation/MuonRPCDigis/src/RPCDigiValid.cc @@ -139,15 +139,15 @@ void RPCDigiValid::bookHistograms(DQMStore::IBooker &booker, edm::Run const &run const int nbinsBarrelZ = 140; // bin width: 10cm // RZ plot - hRZ_ = booker.book2D("RZ", "RZ;Z (cm);R (cm)", nbinsZ, -maxZ, maxZ, nbinsR, minR, maxR); + hRZ_ = booker.book2D("RZ", "R-Z view;Z (cm);R (cm)", nbinsZ, -maxZ, maxZ, nbinsR, minR, maxR); // XY plots - hXY_Barrel_ = booker.book2D("XY_Barrel", "XY_Barrel", nbinsXY, -maxXY, maxXY, nbinsXY, -maxXY, maxXY); + hXY_Barrel_ = booker.book2D("XY_Barrel", "X-Y view of Barrel", nbinsXY, -maxXY, maxXY, nbinsXY, -maxXY, maxXY); for (int disk = 1; disk <= 4; ++disk) { const std::string meNameP = fmt::format("XY_EndcapP{:1d}", disk); const std::string meNameN = fmt::format("XY_EndcapN{:1d}", disk); - const std::string meTitleP = fmt::format("XY view of Endcap{:+1d};X (cm);Y (cm)", disk); - const std::string meTitleN = fmt::format("XY view of Endcap{:+1d};X (cm);Y (cm)", -disk); + const std::string meTitleP = fmt::format("X-Y view of Endcap{:+1d};X (cm);Y (cm)", disk); + const std::string meTitleN = fmt::format("X-Y view of Endcap{:+1d};X (cm);Y (cm)", -disk); hXY_Endcap_[disk] = booker.book2D(meNameP, meTitleP, nbinsXY, -maxXY, maxXY, nbinsXY, -maxXY, maxXY); hXY_Endcap_[-disk] = booker.book2D(meNameN, meTitleN, nbinsXY, -maxXY, maxXY, nbinsXY, -maxXY, maxXY); } @@ -156,7 +156,7 @@ void RPCDigiValid::bookHistograms(DQMStore::IBooker &booker, edm::Run const &run for (int layer = 1; layer <= 6; ++layer) { const std::string meName = fmt::format("ZPhi_Layer{:1d}", layer); const std::string meTitle = fmt::format("Z-#phi view of Layer{:1d};Z (cm);#phi (degree)", layer); - hZPhi_[layer] = booker.book2D(meName, meName, nbinsBarrelZ, -maxBarrelZ, maxBarrelZ, nbinsPhi, -180, 180); + hZPhi_[layer] = booker.book2D(meName, meTitle, nbinsBarrelZ, -maxBarrelZ, maxBarrelZ, nbinsPhi, -180, 180); } // Strip profile From 9baf68e6eba4169a8004ba30d818b7ca4f57c23f Mon Sep 17 00:00:00 2001 From: Giovanni Date: Tue, 9 Apr 2024 17:24:50 +0200 Subject: [PATCH 015/237] Fix input links in Correlator Layer1 Endcap TM18 VU13P design --- .../python/l1ctLayer1_patternWriters_cff.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/L1Trigger/Phase2L1ParticleFlow/python/l1ctLayer1_patternWriters_cff.py b/L1Trigger/Phase2L1ParticleFlow/python/l1ctLayer1_patternWriters_cff.py index b71e76d8b0c51..8abd7b438ae64 100644 --- a/L1Trigger/Phase2L1ParticleFlow/python/l1ctLayer1_patternWriters_cff.py +++ b/L1Trigger/Phase2L1ParticleFlow/python/l1ctLayer1_patternWriters_cff.py @@ -222,9 +222,13 @@ inputFileName = cms.string("l1HGCalTM18-inputs-vu9p"), gttLatency = cms.uint32(167), # shorter, to fit 6 events in 1024 lines maxLinesPerInputFile = cms.uint32(1024+167), # anything beyond 986 will be nulls + gmtLink = 4*27+0, + gttLink = 4*27+3, ) hgcalWriterVU13PTM18WriterConfig = hgcalWriterVU9PTM18WriterConfig.clone( inputFileName = cms.string("l1HGCalTM18-inputs-vu13p"), + gmtLink = 4*28+0, + gttLink = 4*28+3, ) for ie in range(2): for iphi in range(9): @@ -234,7 +238,10 @@ for iphi in range(3): isec, ilink = 3*ie+iphi, 2*iphi+ie hgcalWriterVU9PTM18WriterConfig.hgcSectors[isec].hgcLinks += range(4*(12+ilink),4*(12+ilink)+4) - hgcalWriterVU13PTM18WriterConfig.hgcSectors[isec].hgcLinks += range(4*(13+ilink),4*(13+ilink)+4) + if ilink < 3: + hgcalWriterVU13PTM18WriterConfig.hgcSectors[isec].hgcLinks += range(4*(12+ilink),4*(12+ilink)+4) + else: + hgcalWriterVU13PTM18WriterConfig.hgcSectors[isec].hgcLinks += range(4*(14+ilink),4*(14+ilink)+4) hgcalTM18WriterConfigs = [ hgcalWriterOutputTM18WriterConfig, From de40c50b14ff19f84f671ee72171fbc9f3d2f029 Mon Sep 17 00:00:00 2001 From: Giovanni Date: Sat, 13 Apr 2024 15:16:31 +0200 Subject: [PATCH 016/237] Update Correlator Layer 1 pattern writers --- .../L1TCorrelatorLayer1PatternFileWriter.h | 3 +- .../middle_buffer_multififo_regionizer_ref.h | 8 +- .../python/l1ctLayer1_patternWriters_cff.py | 109 +++++++++++++----- .../L1TCorrelatorLayer1PatternFileWriter.cc | 105 ++++++++++++----- .../test/make_l1ct_binaryFiles_cfg.py | 27 ++++- 5 files changed, 181 insertions(+), 71 deletions(-) diff --git a/L1Trigger/Phase2L1ParticleFlow/interface/L1TCorrelatorLayer1PatternFileWriter.h b/L1Trigger/Phase2L1ParticleFlow/interface/L1TCorrelatorLayer1PatternFileWriter.h index 0a10bc16d4866..94c414cf91b36 100644 --- a/L1Trigger/Phase2L1ParticleFlow/interface/L1TCorrelatorLayer1PatternFileWriter.h +++ b/L1Trigger/Phase2L1ParticleFlow/interface/L1TCorrelatorLayer1PatternFileWriter.h @@ -30,10 +30,11 @@ class L1TCorrelatorLayer1PatternFileWriter { const unsigned int tfTmuxFactor_ = 18, tfLinksFactor_ = 1; // numbers not really configurable in current architecture const unsigned int hgcTmuxFactor_ = 18, hgcLinksFactor_ = 4; // not really configurable in current architecture const unsigned int gctTmuxFactor_ = 1, gctSectors_ = 3; // not really configurable in current architecture - const unsigned int gctLinksEcal_ = 1, gctLinksHad_ = 2; // could be made configurable later const unsigned int gmtTmuxFactor_ = 18, gmtLinksFactor_ = 1; // not really configurable in current architecture const unsigned int gttTmuxFactor_ = 6, gttLinksFactor_ = 1; // not really configurable in current architecture const unsigned int tfTimeslices_, hgcTimeslices_, gctTimeslices_, gmtTimeslices_, gttTimeslices_; + uint32_t gctLinksEcal_, gctLinksHad_; + bool gctSingleLink_; uint32_t gmtNumberOfMuons_; uint32_t gttNumberOfPVs_; uint32_t gttLatency_; diff --git a/L1Trigger/Phase2L1ParticleFlow/interface/regionizer/middle_buffer_multififo_regionizer_ref.h b/L1Trigger/Phase2L1ParticleFlow/interface/regionizer/middle_buffer_multififo_regionizer_ref.h index b53d34f05a6f3..74cd59ac49ae5 100644 --- a/L1Trigger/Phase2L1ParticleFlow/interface/regionizer/middle_buffer_multififo_regionizer_ref.h +++ b/L1Trigger/Phase2L1ParticleFlow/interface/regionizer/middle_buffer_multififo_regionizer_ref.h @@ -85,6 +85,10 @@ namespace l1ct { void reset(); + static void encode(const l1ct::EmCaloObjEmu& from, l1ct::HadCaloObjEmu& to); + static void encode(const l1ct::HadCaloObjEmu& from, l1ct::HadCaloObjEmu& to); + static void decode(l1ct::HadCaloObjEmu& had, l1ct::EmCaloObjEmu& em); + protected: const unsigned int NTK_SECTORS, NCALO_SECTORS; const unsigned int NTK_LINKS, HCAL_LINKS, ECAL_LINKS, NMU_LINKS; @@ -115,10 +119,6 @@ namespace l1ct { const std::vector>& had_in, std::vector& links, std::vector& valid); - - void encode(const l1ct::EmCaloObjEmu& from, l1ct::HadCaloObjEmu& to); - void encode(const l1ct::HadCaloObjEmu& from, l1ct::HadCaloObjEmu& to); - void decode(l1ct::HadCaloObjEmu& had, l1ct::EmCaloObjEmu& em); }; } // namespace l1ct diff --git a/L1Trigger/Phase2L1ParticleFlow/python/l1ctLayer1_patternWriters_cff.py b/L1Trigger/Phase2L1ParticleFlow/python/l1ctLayer1_patternWriters_cff.py index 8abd7b438ae64..876f7c2efab73 100644 --- a/L1Trigger/Phase2L1ParticleFlow/python/l1ctLayer1_patternWriters_cff.py +++ b/L1Trigger/Phase2L1ParticleFlow/python/l1ctLayer1_patternWriters_cff.py @@ -21,6 +21,8 @@ maxLinesPerOutputFile = cms.uint32(1024), eventsPerFile = cms.uint32(_eventsPerFile), tfTimeSlices = cms.VPSet(), + gctNLinksEcal = cms.uint32(1), + gctNLinksHad = cms.uint32(2), gctSectors = cms.VPSet(), gmtTimeSlices = cms.VPSet(), gmtNumberOfMuons = cms.uint32(12), @@ -51,7 +53,8 @@ outputFileName = cms.string("l1BarrelPhi1Serenity-outputs") ) barrelSerenityVU13PPhi1Config = barrelSerenityPhi1Config.clone( - gttLink = cms.int32(4*31+3), + gttLink = cms.int32(4*25+3), + gmtTimeSlices = cms.VPSet(*[cms.PSet(gmtLink = cms.int32(4*18+t)) for t in range(3)]), inputFileName = cms.string("l1BarrelPhi1Serenity-inputs-vu13p"), ) for t in range(3): @@ -65,8 +68,9 @@ for i,s in enumerate([0,1]): barrelSerenityVU9PPhi1Config.gctSectors[s].gctLinksHad = [3*i+4*18, 3*i+4*18+1] barrelSerenityVU9PPhi1Config.gctSectors[s].gctLinksEcal = [3*i+4*18+2] - barrelSerenityVU13PPhi1Config.gctSectors[s].gctLinksHad = [3*i+4*18, 3*i+4*18+1] - barrelSerenityVU13PPhi1Config.gctSectors[s].gctLinksEcal = [3*i+4*18+2] + gctLinks = list(range(4*17,4*17+4)) + list(range(4*19,4*19+2)) + barrelSerenityVU13PPhi1Config.gctSectors[s].gctLinksHad = [gctLinks[3*i], gctLinks[3*i+1]] + barrelSerenityVU13PPhi1Config.gctSectors[s].gctLinksEcal = [gctLinks[3*i+2]] barrelWriterConfigs = barrelWriterOutputOnlyPhiConfigs @@ -115,19 +119,22 @@ hgcalNegVU9PWriterConfig = _hgcalNegWriterConfig.clone() for t in range(3): hgcalPosVU9PWriterConfig.tfTimeSlices[t].tfSectors += [ cms.PSet(tfLink = cms.int32(-1)) for i in range(9) ] # neg - hgcalPosVU9PWriterConfig.tfTimeSlices[t].tfSectors += [ cms.PSet(tfLink = cms.int32(3*i+t+4*2)) for i in range(4) ] # pos, left quads - hgcalPosVU9PWriterConfig.tfTimeSlices[t].tfSectors += [ cms.PSet(tfLink = cms.int32(3*i+t+4*25)) for i in range(5) ] # pos, right quads - hgcalNegVU9PWriterConfig.tfTimeSlices[t].tfSectors += [ cms.PSet(tfLink = cms.int32(3*i+t+4*2)) for i in range(4) ] # neg, left quads - hgcalNegVU9PWriterConfig.tfTimeSlices[t].tfSectors += [ cms.PSet(tfLink = cms.int32(3*i+t+4*25)) for i in range(5) ] # neg, right quads + hgcalPosVU9PWriterConfig.tfTimeSlices[t].tfSectors += [ cms.PSet(tfLink = cms.int32(3*i+t+4*1)) for i in range(4) ] # pos, left quads + hgcalPosVU9PWriterConfig.tfTimeSlices[t].tfSectors += [ cms.PSet(tfLink = cms.int32(3*i+t+4*26)) for i in range(5) ] # pos, right quads + hgcalNegVU9PWriterConfig.tfTimeSlices[t].tfSectors += [ cms.PSet(tfLink = cms.int32(3*i+t+4*1)) for i in range(4) ] # neg, left quads + hgcalNegVU9PWriterConfig.tfTimeSlices[t].tfSectors += [ cms.PSet(tfLink = cms.int32(3*i+t+4*26)) for i in range(5) ] # neg, right quads hgcalNegVU9PWriterConfig.tfTimeSlices[t].tfSectors += [ cms.PSet(tfLink = cms.int32(-1)) for i in range(9) ] # pos - hgcalPosVU9PWriterConfig.hgcTimeSlices[t].hgcSectors += [ cms.PSet(hgcLinks = cms.vint32(-1,-1,-1,-1)) for i in range(3) ] # neg - hgcalPosVU9PWriterConfig.hgcTimeSlices[t].hgcSectors += [ cms.PSet(hgcLinks = cms.vint32(*[4*11+12*i+4*t+j for j in range(4)])) for i in range(3) ] # pos - hgcalNegVU9PWriterConfig.hgcTimeSlices[t].hgcSectors += [ cms.PSet(hgcLinks = cms.vint32(*[4*11+12*i+4*t+j for j in range(4)])) for i in range(3) ] # neg - hgcalNegVU9PWriterConfig.hgcTimeSlices[t].hgcSectors += [ cms.PSet(hgcLinks = cms.vint32(-1,-1,-1,-1)) for i in range(3) ] # pos - hgcalPosVU9PWriterConfig.gmtTimeSlices[t].gmtLink = cms.int32(4+t) - hgcalNegVU9PWriterConfig.gmtTimeSlices[t].gmtLink = cms.int32(4+t) -hgcalPosVU9PWriterConfig.gttLink = 4+3 -hgcalNegVU9PWriterConfig.gttLink = 4+3 + hgcQuads = [list(range(4*i,4*i+4)) for i in [10,11,12,13]] + hgcQuads += [[4*14+1,4*14+2,4*14+3,4*15+3]] # mixed quad + hgcQuads += [list(range(4*i,4*i+4)) for i in [16,17,18,19]] + hgcalPosVU9PWriterConfig.hgcTimeSlices[t].hgcSectors += [ cms.PSet(hgcLinks = cms.vint32(-1,-1,-1,-1)) for i in range(3) ] # neg + hgcalPosVU9PWriterConfig.hgcTimeSlices[t].hgcSectors += [ cms.PSet(hgcLinks = cms.vint32(*hgcQuads[3*i+t])) for i in range(3) ] # pos + hgcalNegVU9PWriterConfig.hgcTimeSlices[t].hgcSectors += [ cms.PSet(hgcLinks = cms.vint32(*hgcQuads[3*i+t])) for i in range(3) ] # neg + hgcalNegVU9PWriterConfig.hgcTimeSlices[t].hgcSectors += [ cms.PSet(hgcLinks = cms.vint32(-1,-1,-1,-1)) for i in range(3) ] # pos + hgcalPosVU9PWriterConfig.gmtTimeSlices[t].gmtLink = cms.int32(4*15+((t+2)%3)) + hgcalNegVU9PWriterConfig.gmtTimeSlices[t].gmtLink = cms.int32(4*15+((t+2)%3)) +hgcalPosVU9PWriterConfig.gttLink = 4*14+0 +hgcalNegVU9PWriterConfig.gttLink = 4*14+0 hgcalPosVU9PWriterConfig.inputFileName = cms.string("l1HGCalPos-inputs-vu9p") hgcalNegVU9PWriterConfig.inputFileName = cms.string("l1HGCalNeg-inputs-vu9p") ## Current configurations for VU13P @@ -140,15 +147,15 @@ hgcalNegVU13PWriterConfig.tfTimeSlices[t].tfSectors += [ cms.PSet(tfLink = cms.int32(3*i+t+4*0)) for i in range(5) ] # neg, left quads hgcalNegVU13PWriterConfig.tfTimeSlices[t].tfSectors += [ cms.PSet(tfLink = cms.int32(3*i+t+4*28)) for i in range(4) ] # neg, right quads hgcalNegVU13PWriterConfig.tfTimeSlices[t].tfSectors += [ cms.PSet(tfLink = cms.int32(-1)) for i in range(9) ] # pos + hgcQuads = [list(range(4*i,4*i+4)) for i in [12,13,14, 16,17, 19,20,21,22]] hgcalPosVU13PWriterConfig.hgcTimeSlices[t].hgcSectors += [ cms.PSet(hgcLinks = cms.vint32(-1,-1,-1,-1)) for i in range(3) ] # neg - for isec,q0 in (0,12),(1,17),(2,20): - hgcalPosVU13PWriterConfig.hgcTimeSlices[t].hgcSectors += [ cms.PSet(hgcLinks = cms.vint32(*[4*q0+4*t+j for j in range(4)])) ] # pos - hgcalNegVU13PWriterConfig.hgcTimeSlices[t].hgcSectors += [ cms.PSet(hgcLinks = cms.vint32(*[4*q0+4*t+j for j in range(4)])) ] # neg + hgcalPosVU13PWriterConfig.hgcTimeSlices[t].hgcSectors += [ cms.PSet(hgcLinks = cms.vint32(*hgcQuads[3*i+t])) for i in range(3) ] # pos + hgcalNegVU13PWriterConfig.hgcTimeSlices[t].hgcSectors += [ cms.PSet(hgcLinks = cms.vint32(*hgcQuads[3*i+t])) for i in range(3) ] # neg hgcalNegVU13PWriterConfig.hgcTimeSlices[t].hgcSectors += [ cms.PSet(hgcLinks = cms.vint32(-1,-1,-1,-1)) for i in range(3) ] # pos - hgcalPosVU13PWriterConfig.gmtTimeSlices[t].gmtLink = cms.int32(4*27+t) - hgcalNegVU13PWriterConfig.gmtTimeSlices[t].gmtLink = cms.int32(4*27+t) -hgcalPosVU13PWriterConfig.gttLink = 4*27+3 -hgcalNegVU13PWriterConfig.gttLink = 4*27+3 + hgcalPosVU13PWriterConfig.gmtTimeSlices[t].gmtLink = cms.int32(4*18+t) + hgcalNegVU13PWriterConfig.gmtTimeSlices[t].gmtLink = cms.int32(4*18+t) +hgcalPosVU13PWriterConfig.gttLink = 4*25+3 +hgcalNegVU13PWriterConfig.gttLink = 4*25+3 hgcalPosVU13PWriterConfig.inputFileName = cms.string("l1HGCalPos-inputs-vu13p") hgcalNegVU13PWriterConfig.inputFileName = cms.string("l1HGCalNeg-inputs-vu13p") @@ -190,8 +197,8 @@ hgcalNoTKVU13PWriterConfig = _hgcalNoTKWriterConfig.clone() for t in range(3): for isec in range(6): - q0 = 3*isec + 6 - hgcalNoTKVU13PWriterConfig.hgcTimeSlices[t].hgcSectors += [ cms.PSet(hgcLinks = cms.vint32(*[4*q0+4*t+j for j in range(4)])) ] # pos + q0 = 3*isec + (6 if isec < 3 else 8) + hgcalNoTKVU13PWriterConfig.hgcTimeSlices[t].hgcSectors += [ cms.PSet(hgcLinks = cms.vint32(*[4*q0+4*t+j for j in range(4)])) ] hgcalNoTKVU13PWriterConfig.inputFileName = cms.string("l1HGCalNoTK-inputs-vu13p") # vu9p uses the same cabling for now hgcalNoTKWriterConfigs = [ @@ -200,7 +207,42 @@ ] ##################################################################################################################### -## HGCal TM18 configuration +## TM18 configuration +_barrelSerenityTM18 = _barrelWriterOutputOnly.clone( + tmuxFactor = cms.uint32(18), + tfTimeSlices = None, + tfSectors = cms.VPSet(*[cms.PSet(tfLink = cms.int32(-1)) for i in range(18)]), + gmtTimeSlices = None, + gmtLink = cms.int32(4*18+0), + gttLink = 4*28+3, + eventsPerFile = 4, +) +barrelSerenityOutputTM18WriterConfig = _barrelSerenityTM18.clone( + outputRegions = cms.vuint32(*range(54)), + outputBoard = cms.int32(0), + outputFileName = cms.string("l1BarrelSerenityTM18-outputs") +) +barrelSerenityVU13PTM18WriterConfig = _barrelSerenityTM18.clone( + inputFileName = cms.string("l1BarrelSerenityTM18-inputs-vu13p"), + gttLatency = cms.uint32(167), # shorter, to fit 6 events in 1024 lines + maxLinesPerInputFile = cms.uint32(1024+167), # anything beyond 986 will be nulls + gctNLinksEcal = 1, + gctNLinksHad = 1, + gctSectors = cms.VPSet(*[cms.PSet( + gctLinksHad = cms.vint32(4*18+1+s), + gctLinksEcal = cms.vint32(4*18+1+s), + ) for s in range(3)]), +) +for ie in range(2): + for iphi in range(9): + isec = 9*ie+iphi + barrelSerenityVU13PTM18WriterConfig.tfSectors[isec].tfLink = (isec if isec < 12 else (4*30+(isec-12))) + +barrelSerenityTM18WriterConfigs = [ + barrelSerenityOutputTM18WriterConfig, + barrelSerenityVU13PTM18WriterConfig +] + _hgcalWriterTM18 = _hgcalWriterConfig.clone( tmuxFactor = cms.uint32(18), tfTimeSlices = None, @@ -210,7 +252,7 @@ gmtTimeSlices = None, gmtLink = cms.int32(4*27+0), gttLink = 4*27+3, - eventsPerFile = 6, + eventsPerFile = 4, ) hgcalWriterOutputTM18WriterConfig = _hgcalWriterTM18.clone( outputFileName = cms.string("l1HGCalTM18-outputs"), @@ -222,24 +264,29 @@ inputFileName = cms.string("l1HGCalTM18-inputs-vu9p"), gttLatency = cms.uint32(167), # shorter, to fit 6 events in 1024 lines maxLinesPerInputFile = cms.uint32(1024+167), # anything beyond 986 will be nulls - gmtLink = 4*27+0, - gttLink = 4*27+3, + gmtLink = 4*15+2, + gttLink = 0, ) hgcalWriterVU13PTM18WriterConfig = hgcalWriterVU9PTM18WriterConfig.clone( inputFileName = cms.string("l1HGCalTM18-inputs-vu13p"), - gmtLink = 4*28+0, + gmtLink = 4*18+0, gttLink = 4*28+3, ) for ie in range(2): for iphi in range(9): isec, ilink = 9*ie+iphi, 2*iphi+ie - hgcalWriterVU9PTM18WriterConfig.tfSectors[isec].tfLink = (ilink if ilink < 12 else (4*28+(ilink-12))) + hgcalWriterVU9PTM18WriterConfig.tfSectors[isec].tfLink = (ilink+2 if ilink < 10 else (4*28+(ilink-10))) hgcalWriterVU13PTM18WriterConfig.tfSectors[isec].tfLink = (ilink if ilink < 12 else (4*30+(ilink-12))) for iphi in range(3): isec, ilink = 3*ie+iphi, 2*iphi+ie - hgcalWriterVU9PTM18WriterConfig.hgcSectors[isec].hgcLinks += range(4*(12+ilink),4*(12+ilink)+4) + if ilink < 2: + hgcalWriterVU9PTM18WriterConfig.hgcSectors[isec].hgcLinks += range(4*(12+ilink),4*(12+ilink)+4) + else: + hgcalWriterVU9PTM18WriterConfig.hgcSectors[isec].hgcLinks += range(4*(14+ilink),4*(14+ilink)+4) if ilink < 3: hgcalWriterVU13PTM18WriterConfig.hgcSectors[isec].hgcLinks += range(4*(12+ilink),4*(12+ilink)+4) + elif ilink < 5: + hgcalWriterVU13PTM18WriterConfig.hgcSectors[isec].hgcLinks += range(4*(13+ilink),4*(13+ilink)+4) else: hgcalWriterVU13PTM18WriterConfig.hgcSectors[isec].hgcLinks += range(4*(14+ilink),4*(14+ilink)+4) diff --git a/L1Trigger/Phase2L1ParticleFlow/src/L1TCorrelatorLayer1PatternFileWriter.cc b/L1Trigger/Phase2L1ParticleFlow/src/L1TCorrelatorLayer1PatternFileWriter.cc index e39f86c267216..fe9c70f857ecf 100644 --- a/L1Trigger/Phase2L1ParticleFlow/src/L1TCorrelatorLayer1PatternFileWriter.cc +++ b/L1Trigger/Phase2L1ParticleFlow/src/L1TCorrelatorLayer1PatternFileWriter.cc @@ -1,4 +1,5 @@ #include "L1Trigger/Phase2L1ParticleFlow/interface/L1TCorrelatorLayer1PatternFileWriter.h" +#include "L1Trigger/Phase2L1ParticleFlow/interface/regionizer/middle_buffer_multififo_regionizer_ref.h" #include "FWCore/Utilities/interface/Exception.h" #include "FWCore/ParameterSet/interface/allowedValues.h" #include @@ -28,6 +29,10 @@ L1TCorrelatorLayer1PatternFileWriter::L1TCorrelatorLayer1PatternFileWriter(const } if (partition_ == Partition::Barrel) { auto sectorConfig = iConfig.getParameter>("gctSectors"); + gctLinksEcal_ = iConfig.getParameter("gctNLinksEcal"); + gctLinksHad_ = iConfig.getParameter("gctNLinksHad"); + gctSingleLink_ = false; + bool gctHasMultiLink = false; if (sectorConfig.size() != gctSectors_) throw cms::Exception("Configuration", "Bad number of GCT sectors"); for (unsigned int iS = 0; iS < gctSectors_; ++iS) { @@ -36,16 +41,24 @@ L1TCorrelatorLayer1PatternFileWriter::L1TCorrelatorLayer1PatternFileWriter(const if (linksEcal.size() != gctLinksEcal_ || linksHad.size() != gctLinksHad_) throw cms::Exception("Configuration", "Bad number of GCT links"); unsigned int iLink = 0; - for (unsigned int i = 0; i < gctLinksHad_; ++i, ++iLink) { - if (linksHad[i] != -1) - channelIdsInput_[l1t::demo::LinkId{"gct", iLink + 10 * iS}].push_back(linksHad[i]); - } - for (unsigned int i = 0; i < gctLinksEcal_; ++i) { - if (linksEcal[i] != -1) - channelIdsInput_[l1t::demo::LinkId{"gct", iLink + 10 * iS}].push_back(linksEcal[i]); + if (!(gctLinksEcal_ == 1 && gctLinksHad_ == 1 && linksEcal[0] == linksHad[0] && linksEcal[0] != -1)) { + for (unsigned int i = 0; i < gctLinksHad_; ++i, ++iLink) { + if (linksHad[i] != -1) + channelIdsInput_[l1t::demo::LinkId{"gct", iLink + 10 * iS}].push_back(linksHad[i]); + } + for (unsigned int i = 0; i < gctLinksEcal_; ++i) { + if (linksEcal[i] != -1) + channelIdsInput_[l1t::demo::LinkId{"gct", iLink + 10 * iS}].push_back(linksEcal[i]); + } + gctHasMultiLink = true; + } else { // single link combining ecal and hcal + channelIdsInput_[l1t::demo::LinkId{"gct", 10 * iS}].push_back(linksEcal[0]); + gctSingleLink_ = true; } channelSpecsInput_["gct"] = {tmuxFactor_ * gctTimeslices_, 0}; } + if (gctSingleLink_ && gctHasMultiLink) + throw cms::Exception("Configuration", "Some GCT sectors have a single link, others have multiple."); } if (partition_ == Partition::HGCal || partition_ == Partition::HGCalNoTk) { configTimeSlices(iConfig, "hgc", eventTemplate.raw.hgcalcluster.size(), hgcTimeslices_, hgcLinksFactor_); @@ -89,9 +102,11 @@ L1TCorrelatorLayer1PatternFileWriter::L1TCorrelatorLayer1PatternFileWriter(const nEgammaObjectsOut_ = iConfig.getParameter("nEgammaObjectsOut"); if (outputLinkEgamma_ != -1) { channelIdsOutput_[l1t::demo::LinkId{"egamma", 0}].push_back(outputLinkEgamma_); - if (partition_ == Partition::HGCal && tmuxFactor_ == 18) { - // the format is different, as we put together both endcaps - channelSpecsOutput_["egamma"] = {tmuxFactor_, nOutputFramesPerBX_ * tmuxFactor_ / 2 - 3 * nEgammaObjectsOut_}; + if (tmuxFactor_ == 18) { + // the format is different, as we put together multiple endcaps or slices + unsigned int nboards = (partition_ == Partition::Barrel) ? 3 : 2; + channelSpecsOutput_["egamma"] = {tmuxFactor_, + nOutputFramesPerBX_ * tmuxFactor_ / nboards - 3 * nEgammaObjectsOut_}; } else { outputBoard_ = iConfig.getParameter("outputBoard"); channelSpecsOutput_["egamma"] = {tmuxFactor_, nOutputFramesPerBX_ * tmuxFactor_ - 3 * nEgammaObjectsOut_}; @@ -143,7 +158,10 @@ std::unique_ptr L1TCorrelatorLayer1PatternFileWri edm::ParameterSetDescription gctSectorPSD; gctSectorPSD.add>("gctLinksEcal"); gctSectorPSD.add>("gctLinksHad"); - return std::make_unique>>("gctSectors", gctSectorPSD, true); + return std::make_unique>>( + "gctSectors", gctSectorPSD, true) and + edm::ParameterDescription("gctNLinksEcal", 1, true) and + edm::ParameterDescription("gctNLinksHad", 2, true); } std::unique_ptr L1TCorrelatorLayer1PatternFileWriter::describeHGC() { return describeTimeSlices("hgc"); @@ -360,24 +378,44 @@ void L1TCorrelatorLayer1PatternFileWriter::writeBarrelGCT(const l1ct::Event& eve continue; const auto& had = event.decoded.hadcalo[iS]; const auto& ecal = event.decoded.emcalo[iS]; - unsigned int iLink = 0, nHad = had.size(), nEcal = ecal.size(); - for (unsigned int i = 0; i < gctLinksHad_; ++i, ++iLink) { - ret.clear(); - for (unsigned int iHad = i; iHad < nHad; iHad += gctLinksHad_) { - ret.emplace_back(had[iHad].pack()); + if (!gctSingleLink_) { + unsigned int iLink = 0, nHad = had.size(), nEcal = ecal.size(); + for (unsigned int i = 0; i < gctLinksHad_; ++i, ++iLink) { + ret.clear(); + for (unsigned int iHad = i; iHad < nHad; iHad += gctLinksHad_) { + ret.emplace_back(had[iHad].pack()); + } + if (ret.empty()) + ret.emplace_back(0); + out.add(l1t::demo::LinkId{"gct", iS * 10 + iLink}, ret); } - if (ret.empty()) - ret.emplace_back(0); - out.add(l1t::demo::LinkId{"gct", iS * 10 + iLink}, ret); - } - for (unsigned int i = 0; i < gctLinksEcal_; ++i, ++iLink) { - ret.clear(); - for (unsigned int iEcal = i; iEcal < nEcal; iEcal += gctLinksEcal_) { - ret.emplace_back(ecal[iEcal].pack()); + for (unsigned int i = 0; i < gctLinksEcal_; ++i, ++iLink) { + ret.clear(); + for (unsigned int iEcal = i; iEcal < nEcal; iEcal += gctLinksEcal_) { + ret.emplace_back(ecal[iEcal].pack()); + } + if (ret.empty()) + ret.emplace_back(0); + out.add(l1t::demo::LinkId{"gct", iS * 10 + iLink}, ret); } - if (ret.empty()) - ret.emplace_back(0); - out.add(l1t::demo::LinkId{"gct", iS * 10 + iLink}, ret); + } else { + const unsigned int NCLK_EM = 54, NCLK_TOT = 3 * NCLK_EM; + l1ct::HadCaloObjEmu tmp; + ret.resize(std::min(NCLK_EM + had.size(), NCLK_TOT)); + for (unsigned int iclock = 0, nem = ecal.size(); iclock < NCLK_EM; ++iclock) { + if (iclock < nem) { + l1ct::MiddleBufferMultififoRegionizerEmulator::encode(ecal[iclock], tmp); + ret[iclock] = tmp.pack(); + } else { + ret[iclock] = 0; + } + } + for (unsigned int ihad = 0, iclock = NCLK_EM, nhad = had.size(); iclock < NCLK_TOT && ihad < nhad; + ++iclock, ++ihad) { + l1ct::MiddleBufferMultififoRegionizerEmulator::encode(had[ihad], tmp); + ret[iclock] = tmp.pack(); + } + out.add(l1t::demo::LinkId{"gct", iS * 10}, ret); } } } @@ -435,11 +473,14 @@ void L1TCorrelatorLayer1PatternFileWriter::writeEgamma(const l1ct::OutputBoard& void L1TCorrelatorLayer1PatternFileWriter::writeEgamma(const l1ct::Event& event, l1t::demo::EventData& out) { std::vector> ret; - if (partition_ == Partition::HGCal && tmuxFactor_ == 18) { - // the format is different, as we put together both endcaps - writeEgamma(event.board_out[0], ret); - ret.resize(nOutputFramesPerBX_ * tmuxFactor_ / 2, ap_uint<64>(0)); - writeEgamma(event.board_out[1], ret); + if (tmuxFactor_ == 18) { + // the format is different, as we put together all boards + unsigned int nboards = event.board_out.size(); + unsigned int npad = nOutputFramesPerBX_ * tmuxFactor_ / nboards; + for (unsigned int board = 0; board < nboards; ++board) { + ret.resize(board * npad, ap_uint<64>(0)); + writeEgamma(event.board_out[board], ret); + } } else { writeEgamma(event.board_out[outputBoard_], ret); } diff --git a/L1Trigger/Phase2L1ParticleFlow/test/make_l1ct_binaryFiles_cfg.py b/L1Trigger/Phase2L1ParticleFlow/test/make_l1ct_binaryFiles_cfg.py index 2191018d20618..c34694d6f1975 100644 --- a/L1Trigger/Phase2L1ParticleFlow/test/make_l1ct_binaryFiles_cfg.py +++ b/L1Trigger/Phase2L1ParticleFlow/test/make_l1ct_binaryFiles_cfg.py @@ -9,7 +9,8 @@ parser.add_argument("--dumpFilesOFF", help="switch on dump file production", action="store_true", default=False) parser.add_argument("--patternFilesOFF", help="switch on Layer-1 pattern file production", action="store_true", default=False) parser.add_argument("--serenity", help="use Serenity settigns as default everwhere, i.e. also for barrel", action="store_true", default=False) -parser.add_argument("--tm18", help="Add TM18 emulators for the endcaps", action="store_true", default=False) +parser.add_argument("--tm18", help="Add TM18 emulators", action="store_true", default=False) +parser.add_argument("--split18", help="Make 3 TM18 layer 1 pattern files", action="store_true", default=False) args = parser.parse_args() @@ -205,12 +206,32 @@ if not args.patternFilesOFF: process.l1tLayer1HGCalTM18.patternWriters = cms.untracked.VPSet(*hgcalTM18WriterConfigs) process.l1tLayer1HGCalNoTKTM18.patternWriters = cms.untracked.VPSet(hgcalNoTKOutputTM18WriterConfig) - process.l1tLayer1BarrelSerenityTM18.patternWriters = cms.untracked.VPSet() + process.l1tLayer1BarrelSerenityTM18.patternWriters = cms.untracked.VPSet(*barrelSerenityTM18WriterConfigs) process.l1tLayer2EGTM18.writeInPattern = True process.l1tLayer2EGTM18.writeOutPattern = True - if not args.dumpFilesOFF: for det in "HGCalTM18", "HGCalNoTKTM18", "BarrelSerenityTM18": getattr(process, 'l1tLayer1'+det).dumpFileName = cms.untracked.string("TTbar_PU200_"+det+".dump") + if args.split18 and not args.patternFilesOFF: + from FWCore.Modules.preScaler_cfi import preScaler + for tmSlice, psOffset in (0,1), (6,2), (12,0): + setattr(process, f"preTM{tmSlice}", preScaler.clone(prescaleFactor = 3, prescaleOffset = psOffset)) + for det in "HGCalTM18", "HGCalNoTKTM18", "BarrelSerenityTM18": + tsmod = getattr(process, 'l1tLayer1'+det).clone() + tsmod.dumpFileName = cms.untracked.string("") + setattr(process, f"l1tLayer1{det}TS{tmSlice}", tsmod) + setattr(process, f"Write_{det}TS{tmSlice}", cms.Path(getattr(process, f"preTM{tmSlice}")+tsmod)) + getattr(process, f'l1tLayer1HGCalTM18TS{tmSlice}').patternWriters = cms.untracked.VPSet( + hgcalWriterOutputTM18WriterConfig.clone(outputFileName = f"l1HGCalTM18-outputs-ts{tmSlice}"), + hgcalWriterVU9PTM18WriterConfig.clone(inputFileName = f"l1HGCalTM18-inputs-vu9p-ts{tmSlice}"), + hgcalWriterVU13PTM18WriterConfig.clone(inputFileName = f"l1HGCalTM18-inputs-vu13p-ts{tmSlice}") + ) + getattr(process, f'l1tLayer1HGCalNoTKTM18TS{tmSlice}').patternWriters = cms.untracked.VPSet( + hgcalNoTKOutputTM18WriterConfig.clone(outputFileName = f"l1HGCalTM18-outputs-ts{tmSlice}"), + ) + getattr(process, f'l1tLayer1BarrelSerenityTM18TS{tmSlice}').patternWriters = cms.untracked.VPSet( + barrelSerenityOutputTM18WriterConfig.clone(outputFileName = f"l1BarrelSerenityTM18-outputs-ts{tmSlice}"), + barrelSerenityVU13PTM18WriterConfig.clone(inputFileName = f"l1BarrelSerenityTM18-inputs-vu13p-ts{tmSlice}") + ) process.source.fileNames = [ '/store/cmst3/group/l1tr/cerminar/14_0_X/fpinputs_131X/v3/TTbar_PU200/inputs131X_1.root' ] From ca309a6dfd209157bd49a1fa0e03a2a53eb0bce8 Mon Sep 17 00:00:00 2001 From: Giovanni Date: Mon, 13 May 2024 09:55:56 +0200 Subject: [PATCH 017/237] Update to 1008 events to avoid incomplete pattern files after TMUXing --- .../Phase2L1ParticleFlow/test/make_l1ct_binaryFiles_cfg.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/L1Trigger/Phase2L1ParticleFlow/test/make_l1ct_binaryFiles_cfg.py b/L1Trigger/Phase2L1ParticleFlow/test/make_l1ct_binaryFiles_cfg.py index c34694d6f1975..efa54b34fd770 100644 --- a/L1Trigger/Phase2L1ParticleFlow/test/make_l1ct_binaryFiles_cfg.py +++ b/L1Trigger/Phase2L1ParticleFlow/test/make_l1ct_binaryFiles_cfg.py @@ -29,7 +29,7 @@ process.load("SimGeneral.HepPDTESSource.pythiapdt_cfi") process.load("FWCore.MessageLogger.MessageLogger_cfi") process.options = cms.untracked.PSet( wantSummary = cms.untracked.bool(True), allowUnscheduled = cms.untracked.bool(False) ) -process.maxEvents = cms.untracked.PSet( input = cms.untracked.int32(1000)) +process.maxEvents = cms.untracked.PSet( input = cms.untracked.int32(1008)) process.MessageLogger.cerr.FwkReport.reportEvery = 1 process.source = cms.Source("PoolSource", From 28b00418eb208c2987e42ebbe45a3cdd25b9cef7 Mon Sep 17 00:00:00 2001 From: Giovanni Date: Mon, 13 May 2024 12:23:53 +0200 Subject: [PATCH 018/237] Drop on input old l1tKMTFTracks --- .../Phase2L1ParticleFlow/test/make_l1ct_binaryFiles_cfg.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/L1Trigger/Phase2L1ParticleFlow/test/make_l1ct_binaryFiles_cfg.py b/L1Trigger/Phase2L1ParticleFlow/test/make_l1ct_binaryFiles_cfg.py index efa54b34fd770..f6fa74b4ddfea 100644 --- a/L1Trigger/Phase2L1ParticleFlow/test/make_l1ct_binaryFiles_cfg.py +++ b/L1Trigger/Phase2L1ParticleFlow/test/make_l1ct_binaryFiles_cfg.py @@ -38,7 +38,8 @@ "drop l1tPFClusters_*_*_*", "drop l1tPFTracks_*_*_*", "drop l1tPFCandidates_*_*_*", - "drop l1tTkPrimaryVertexs_*_*_*"), + "drop l1tTkPrimaryVertexs_*_*_*", + "drop l1tKMTFTracks_*_*_*"), skipEvents = cms.untracked.uint32(0), ) From 38b546f4fab25614bf2f9c6ea7b92823fc548ba1 Mon Sep 17 00:00:00 2001 From: Junghwan John Goh Date: Mon, 13 May 2024 12:29:36 +0200 Subject: [PATCH 019/237] reduce bins along phi-axis --- Validation/MuonRPCDigis/src/RPCDigiValid.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Validation/MuonRPCDigis/src/RPCDigiValid.cc b/Validation/MuonRPCDigis/src/RPCDigiValid.cc index 9a50005c656d6..8ede470d311f1 100644 --- a/Validation/MuonRPCDigis/src/RPCDigiValid.cc +++ b/Validation/MuonRPCDigis/src/RPCDigiValid.cc @@ -134,7 +134,7 @@ void RPCDigiValid::bookHistograms(DQMStore::IBooker &booker, edm::Run const &run const int nbinsXY = 160; // bin width: 10cm const double minR = 100, maxR = 800; const int nbinsR = 70; // bin width: 10cm - const int nbinsPhi = 90; // bin width: 4 degree + const int nbinsPhi = 72; // bin width: 5 degree const double maxBarrelZ = 700; const int nbinsBarrelZ = 140; // bin width: 10cm From d6d45f7dc045928f634d54578de7d88c7bf4f3bc Mon Sep 17 00:00:00 2001 From: Andrea Bocci Date: Thu, 16 May 2024 17:26:19 +0200 Subject: [PATCH 020/237] Enable SoA range checking by default --- DataFormats/SoATemplate/interface/SoACommon.h | 4 ++-- DataFormats/SoATemplate/interface/SoALayout.h | 8 ++++---- DataFormats/SoATemplate/interface/SoAView.h | 8 ++++---- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/DataFormats/SoATemplate/interface/SoACommon.h b/DataFormats/SoATemplate/interface/SoACommon.h index 49f5049377b44..a72dc3a32ba65 100644 --- a/DataFormats/SoATemplate/interface/SoACommon.h +++ b/DataFormats/SoATemplate/interface/SoACommon.h @@ -72,13 +72,13 @@ namespace cms::soa { namespace RestrictQualify { constexpr bool enabled = true; constexpr bool disabled = false; - constexpr bool Default = disabled; + constexpr bool Default = enabled; } // namespace RestrictQualify namespace RangeChecking { constexpr bool enabled = true; constexpr bool disabled = false; - constexpr bool Default = disabled; + constexpr bool Default = enabled; } // namespace RangeChecking template diff --git a/DataFormats/SoATemplate/interface/SoALayout.h b/DataFormats/SoATemplate/interface/SoALayout.h index 24370c189cc2d..6d1f520c38d2b 100644 --- a/DataFormats/SoATemplate/interface/SoALayout.h +++ b/DataFormats/SoATemplate/interface/SoALayout.h @@ -456,8 +456,8 @@ \ template \ + bool RESTRICT_QUALIFY = cms::soa::RestrictQualify::Default, \ + bool RANGE_CHECKING = cms::soa::RangeChecking::Default> \ struct ViewTemplateFreeParams; \ \ /* dump the SoA internal structure */ \ @@ -539,7 +539,7 @@ using ConstViewTemplate = ConstViewTemplateFreeParams; \ \ - using ConstView = ConstViewTemplate; \ + using ConstView = ConstViewTemplate; \ \ /* Generate the mutable View template */ \ _GENERATE_SOA_TRIVIAL_VIEW(CLASS, \ @@ -552,7 +552,7 @@ template \ using ViewTemplate = ViewTemplateFreeParams; \ \ - using View = ViewTemplate; \ + using View = ViewTemplate; \ \ /* Trivial constuctor */ \ CLASS() \ diff --git a/DataFormats/SoATemplate/interface/SoAView.h b/DataFormats/SoATemplate/interface/SoAView.h index f219bd137a0cc..30ced1e890e0d 100644 --- a/DataFormats/SoATemplate/interface/SoAView.h +++ b/DataFormats/SoATemplate/interface/SoAView.h @@ -492,8 +492,8 @@ namespace cms::soa { #define _GENERATE_SOA_VIEW_PART_0(CONST_VIEW, VIEW, LAYOUTS_LIST, VALUE_LIST) \ template \ + bool RESTRICT_QUALIFY = cms::soa::RestrictQualify::Default, \ + bool RANGE_CHECKING = cms::soa::RangeChecking::Default> \ struct VIEW : public CONST_VIEW { \ /* Declare the parametrized layouts as the default */ \ /*BOOST_PP_SEQ_CAT(_ITERATE_ON_ALL(_DECLARE_VIEW_LAYOUT_PARAMETRIZED_TEMPLATE, ~, LAYOUTS_LIST)) */ \ @@ -671,8 +671,8 @@ namespace cms::soa { #define _GENERATE_SOA_CONST_VIEW_PART_0(CONST_VIEW, VIEW, LAYOUTS_LIST, VALUE_LIST) \ template \ + bool RESTRICT_QUALIFY = cms::soa::RestrictQualify::Default, \ + bool RANGE_CHECKING = cms::soa::RangeChecking::Default> \ struct CONST_VIEW { \ /* these could be moved to an external type trait to free up the symbol names */ \ using self_type = CONST_VIEW; From 02825cb8b79afcca0737c758b5cd9188ea10859a Mon Sep 17 00:00:00 2001 From: Steven Date: Fri, 17 May 2024 02:01:47 +0200 Subject: [PATCH 021/237] First working version for CMSSW integration of sexaquark simulation code. --- .../data/particles_sexaq_1p5_GeV.txt | 5 + .../data/particles_sexaq_1p7_GeV.txt | 5 + .../data/particles_sexaq_1p85_GeV.txt | 5 + .../data/particles_sexaq_1p8_GeV.txt | 5 + .../data/particles_sexaq_1p9_GeV.txt | 5 + .../data/particles_sexaq_2_GeV.txt | 5 + .../data/particles_sexaq_2p1_GeV.txt | 5 + SimG4Core/CustomPhysics/interface/G4AntiSQ.h | 65 ++++ SimG4Core/CustomPhysics/interface/G4SQ.h | 28 ++ .../interface/G4SQInelasticCrossSection.h | 42 +++ .../interface/G4SQInelasticProcess.h | 46 +++ .../CustomPhysics/interface/G4SQLoopProcess.h | 48 +++ .../interface/G4SQLoopProcessDiscr.h | 54 ++++ .../interface/G4SQNeutronAnnih.h | 37 +++ .../CustomPhysics/src/CustomPhysicsList.cc | 23 ++ SimG4Core/CustomPhysics/src/G4AntiSQ.cc | 59 ++++ SimG4Core/CustomPhysics/src/G4SQ.cc | 59 ++++ .../src/G4SQInelasticCrossSection.cc | 56 ++++ .../CustomPhysics/src/G4SQInelasticProcess.cc | 293 ++++++++++++++++++ .../CustomPhysics/src/G4SQLoopProcess.cc | 64 ++++ .../CustomPhysics/src/G4SQLoopProcessDiscr.cc | 82 +++++ .../CustomPhysics/src/G4SQNeutronAnnih.cc | 281 +++++++++++++++++ .../test/Sexaquark_RunIIFall18GenSim_cfg.py | 151 +++++++++ 23 files changed, 1423 insertions(+) create mode 100644 SimG4Core/CustomPhysics/data/particles_sexaq_1p5_GeV.txt create mode 100644 SimG4Core/CustomPhysics/data/particles_sexaq_1p7_GeV.txt create mode 100644 SimG4Core/CustomPhysics/data/particles_sexaq_1p85_GeV.txt create mode 100644 SimG4Core/CustomPhysics/data/particles_sexaq_1p8_GeV.txt create mode 100644 SimG4Core/CustomPhysics/data/particles_sexaq_1p9_GeV.txt create mode 100644 SimG4Core/CustomPhysics/data/particles_sexaq_2_GeV.txt create mode 100644 SimG4Core/CustomPhysics/data/particles_sexaq_2p1_GeV.txt create mode 100644 SimG4Core/CustomPhysics/interface/G4AntiSQ.h create mode 100644 SimG4Core/CustomPhysics/interface/G4SQ.h create mode 100644 SimG4Core/CustomPhysics/interface/G4SQInelasticCrossSection.h create mode 100644 SimG4Core/CustomPhysics/interface/G4SQInelasticProcess.h create mode 100644 SimG4Core/CustomPhysics/interface/G4SQLoopProcess.h create mode 100644 SimG4Core/CustomPhysics/interface/G4SQLoopProcessDiscr.h create mode 100644 SimG4Core/CustomPhysics/interface/G4SQNeutronAnnih.h create mode 100644 SimG4Core/CustomPhysics/src/G4AntiSQ.cc create mode 100644 SimG4Core/CustomPhysics/src/G4SQ.cc create mode 100644 SimG4Core/CustomPhysics/src/G4SQInelasticCrossSection.cc create mode 100644 SimG4Core/CustomPhysics/src/G4SQInelasticProcess.cc create mode 100644 SimG4Core/CustomPhysics/src/G4SQLoopProcess.cc create mode 100644 SimG4Core/CustomPhysics/src/G4SQLoopProcessDiscr.cc create mode 100644 SimG4Core/CustomPhysics/src/G4SQNeutronAnnih.cc create mode 100644 SimG4Core/CustomPhysics/test/Sexaquark_RunIIFall18GenSim_cfg.py diff --git a/SimG4Core/CustomPhysics/data/particles_sexaq_1p5_GeV.txt b/SimG4Core/CustomPhysics/data/particles_sexaq_1p5_GeV.txt new file mode 100644 index 0000000000000..50ac2b0b97746 --- /dev/null +++ b/SimG4Core/CustomPhysics/data/particles_sexaq_1p5_GeV.txt @@ -0,0 +1,5 @@ +Block MASS # +# PDG code mass particle + 1020000020 1.5 # sexaq + -1020000020 1.5 # anti_sexaq +Block diff --git a/SimG4Core/CustomPhysics/data/particles_sexaq_1p7_GeV.txt b/SimG4Core/CustomPhysics/data/particles_sexaq_1p7_GeV.txt new file mode 100644 index 0000000000000..fa23fb09c07b8 --- /dev/null +++ b/SimG4Core/CustomPhysics/data/particles_sexaq_1p7_GeV.txt @@ -0,0 +1,5 @@ +Block MASS # +# PDG code mass particle + 1020000020 1.7 # sexaq + -1020000020 1.7 # anti_sexaq +Block diff --git a/SimG4Core/CustomPhysics/data/particles_sexaq_1p85_GeV.txt b/SimG4Core/CustomPhysics/data/particles_sexaq_1p85_GeV.txt new file mode 100644 index 0000000000000..ea95c99f27bc0 --- /dev/null +++ b/SimG4Core/CustomPhysics/data/particles_sexaq_1p85_GeV.txt @@ -0,0 +1,5 @@ +Block MASS # +# PDG code mass particle + 1020000020 1.85 # sexaq + -1020000020 1.85 # anti_sexaq +Block diff --git a/SimG4Core/CustomPhysics/data/particles_sexaq_1p8_GeV.txt b/SimG4Core/CustomPhysics/data/particles_sexaq_1p8_GeV.txt new file mode 100644 index 0000000000000..57bac395ef3d9 --- /dev/null +++ b/SimG4Core/CustomPhysics/data/particles_sexaq_1p8_GeV.txt @@ -0,0 +1,5 @@ +Block MASS # +# PDG code mass particle + 1020000020 1.8 # sexaq + -1020000020 1.8 # anti_sexaq +Block diff --git a/SimG4Core/CustomPhysics/data/particles_sexaq_1p9_GeV.txt b/SimG4Core/CustomPhysics/data/particles_sexaq_1p9_GeV.txt new file mode 100644 index 0000000000000..8695d8fbfaf79 --- /dev/null +++ b/SimG4Core/CustomPhysics/data/particles_sexaq_1p9_GeV.txt @@ -0,0 +1,5 @@ +Block MASS # +# PDG code mass particle + 1020000020 1.9 # sexaq + -1020000020 1.9 # anti_sexaq +Block diff --git a/SimG4Core/CustomPhysics/data/particles_sexaq_2_GeV.txt b/SimG4Core/CustomPhysics/data/particles_sexaq_2_GeV.txt new file mode 100644 index 0000000000000..9325990519485 --- /dev/null +++ b/SimG4Core/CustomPhysics/data/particles_sexaq_2_GeV.txt @@ -0,0 +1,5 @@ +Block MASS # +# PDG code mass particle + 1020000020 2.0 # sexaq + -1020000020 2.0 # anti_sexaq +Block diff --git a/SimG4Core/CustomPhysics/data/particles_sexaq_2p1_GeV.txt b/SimG4Core/CustomPhysics/data/particles_sexaq_2p1_GeV.txt new file mode 100644 index 0000000000000..23b308cddb3a1 --- /dev/null +++ b/SimG4Core/CustomPhysics/data/particles_sexaq_2p1_GeV.txt @@ -0,0 +1,5 @@ +Block MASS # +# PDG code mass particle + 1020000020 2.1 # sexaq + -1020000020 2.1 # anti_sexaq +Block diff --git a/SimG4Core/CustomPhysics/interface/G4AntiSQ.h b/SimG4Core/CustomPhysics/interface/G4AntiSQ.h new file mode 100644 index 0000000000000..93716063261c3 --- /dev/null +++ b/SimG4Core/CustomPhysics/interface/G4AntiSQ.h @@ -0,0 +1,65 @@ +// +// ******************************************************************** +// * License and Disclaimer * +// * * +// * The Geant4 software is copyright of the Copyright Holders of * +// * the Geant4 Collaboration. It is provided under the terms and * +// * conditions of the Geant4 Software License, included in the file * +// * LICENSE and available at http://cern.ch/geant4/license . These * +// * include a list of copyright holders. * +// * * +// * Neither the authors of this software system, nor their employing * +// * institutes,nor the agencies providing financial support for this * +// * work make any representation or warranty, express or implied, * +// * regarding this software system or assume any liability for its * +// * use. Please see the license in the file LICENSE and URL above * +// * for the full disclaimer and the limitation of liability. * +// * * +// * This code implementation is the result of the scientific and * +// * technical work of the GEANT4 collaboration. * +// * By using, copying, modifying or distributing the software (or * +// * any work based on the software) you agree to acknowledge its * +// * use in resulting scientific publications, and indicate your * +// * acceptance of all terms of the Geant4 Software license. * +// ******************************************************************** +// +// +// $Id: G4AntiSQ.hh 67971 2013-03-13 10:13:24Z gcosmo $ +// +// +// ------------------------------------------------------------ +// GEANT 4 class header file +// +// History: first implementation, based on object model of +// 4-th April 1996, G.Cosmo +// **************************************************************** +// New implementation as a utility class M.Asai, 26 July 2004 +// ---------------------------------------------------------------- + +#ifndef G4AntiSQ_h +#define G4AntiSQ_h 1 + +#include "globals.hh" +#include "G4ios.hh" +#include "G4ParticleDefinition.hh" + +// ###################################################################### +// ### ANTI-SEXAQUARK ### +// ###################################################################### + + +class G4AntiSQ : public G4ParticleDefinition { + + private: + static G4AntiSQ* theInstance; + G4AntiSQ(){} + ~G4AntiSQ(){} + + public: + static G4AntiSQ* Definition(double mass); + //static G4AntiSQ* AntiSQDefinition(double mass); + static G4AntiSQ* AntiSQ(double mass); + +}; + +#endif diff --git a/SimG4Core/CustomPhysics/interface/G4SQ.h b/SimG4Core/CustomPhysics/interface/G4SQ.h new file mode 100644 index 0000000000000..6277916684f1f --- /dev/null +++ b/SimG4Core/CustomPhysics/interface/G4SQ.h @@ -0,0 +1,28 @@ + +#ifndef G4SQ_h +#define G4SQ_h 1 + +#include "globals.hh" +#include "G4ios.hh" +#include "G4ParticleDefinition.hh" + +// ###################################################################### +// ### SEXAQUARK ### +// ###################################################################### + + +class G4SQ : public G4ParticleDefinition { + + private: + static G4SQ* theInstance; + G4SQ(){} + ~G4SQ(){} + + public: + static G4SQ* Definition(double mass); +// static G4SQ* SQDefinition(double mass); + static G4SQ* SQ(double mass); + +}; + +#endif diff --git a/SimG4Core/CustomPhysics/interface/G4SQInelasticCrossSection.h b/SimG4Core/CustomPhysics/interface/G4SQInelasticCrossSection.h new file mode 100644 index 0000000000000..2a5c5881dfba5 --- /dev/null +++ b/SimG4Core/CustomPhysics/interface/G4SQInelasticCrossSection.h @@ -0,0 +1,42 @@ + +#ifndef G4SQInelasticCrossSection_h +#define G4SQInelasticCrossSection_h + + +#include "globals.hh" +#include "G4VCrossSectionDataSet.hh" + + +class G4NistManager; +class G4SQ; +class G4AntiSQ; + + +class G4SQInelasticCrossSection : public G4VCrossSectionDataSet +{ +public: + + G4SQInelasticCrossSection(double mass); + + ~G4SQInelasticCrossSection(); + + virtual + G4bool IsElementApplicable(const G4DynamicParticle* aPart, + G4int Z, const G4Material*); + + virtual + G4double GetElementCrossSection(const G4DynamicParticle*, + G4int Z, const G4Material*); + + G4double GetSQCrossSection(G4double kineticEnergy, G4int Z); + +private: + + G4NistManager* nist; + G4SQ * theSQ; + G4AntiSQ * theAntiSQ; + +}; + +#endif + diff --git a/SimG4Core/CustomPhysics/interface/G4SQInelasticProcess.h b/SimG4Core/CustomPhysics/interface/G4SQInelasticProcess.h new file mode 100644 index 0000000000000..6530d267c16fb --- /dev/null +++ b/SimG4Core/CustomPhysics/interface/G4SQInelasticProcess.h @@ -0,0 +1,46 @@ +#ifndef SimG4Core_CustomPhysics_G4SQInelasticProcess_h +#define SimG4Core_CustomPhysics_G4SQInelasticProcess_h 1 + + +#include "G4HadronicProcess.hh" + + +class G4ParticleDefinition; + + +class G4SQInelasticProcess : public G4HadronicProcess +{ + + public: + + G4SQInelasticProcess(double mass, const G4String& processName="SQInelastic"); + + ~G4SQInelasticProcess(); + + G4bool IsApplicable(const G4ParticleDefinition& aParticleType) override; + + // generic PostStepDoIt recommended for all derived classes + virtual G4VParticleChange* PostStepDoIt(const G4Track& aTrack, + const G4Step& aStep); + + G4SQInelasticProcess& operator=(const G4SQInelasticProcess& right); + G4SQInelasticProcess(const G4SQInelasticProcess&); + + protected: + + // Check the result for catastrophic energy non-conservation + G4HadFinalState* CheckResult(const G4HadProjectile& thePro, + const G4Nucleus& targetNucleus, + G4HadFinalState* result); + + private: + + G4ParticleDefinition* theParticle; + + G4Nucleus targetNucleus; + G4HadronicInteraction* theInteraction = nullptr; + +}; + +#endif + diff --git a/SimG4Core/CustomPhysics/interface/G4SQLoopProcess.h b/SimG4Core/CustomPhysics/interface/G4SQLoopProcess.h new file mode 100644 index 0000000000000..224fb8a1b9fbf --- /dev/null +++ b/SimG4Core/CustomPhysics/interface/G4SQLoopProcess.h @@ -0,0 +1,48 @@ +#ifndef G4SQLoopProcess_h +#define G4SQLoopProcess_h 1 + +#include "G4VContinuousProcess.hh" +#include "globals.hh" +#include "G4Track.hh" +#include "G4ParticleChange.hh" + + +class G4Step; +class G4ParticleDefinition; + + +class G4SQLoopProcess : public G4VContinuousProcess { + + public: + + G4SQLoopProcess(const G4String& name = "SQLooper", + G4ProcessType type = fUserDefined); + virtual ~G4SQLoopProcess(); + + + public: + + virtual G4VParticleChange* AlongStepDoIt(const G4Track&, const G4Step&); + virtual G4double AlongStepGetPhysicalInteractionLength(const G4Track& track, G4double previousStepSize, G4double currentMinimumStep, G4double& proposedSafety, G4GPILSelection* selection); + virtual void StartTracking(G4Track * aTrack); + + protected: + + virtual G4double GetContinuousStepLimit(const G4Track& track, G4double previousStepSize, G4double currentMinimumStep, G4double& currentSafety); + + private: + + G4SQLoopProcess(G4SQLoopProcess &); + G4SQLoopProcess & operator=(const G4SQLoopProcess &right); + + protected: + + G4ParticleChange* fParticleChange; + + private: + + G4ThreeVector posini; +}; + + +#endif diff --git a/SimG4Core/CustomPhysics/interface/G4SQLoopProcessDiscr.h b/SimG4Core/CustomPhysics/interface/G4SQLoopProcessDiscr.h new file mode 100644 index 0000000000000..f7a192b24bb7a --- /dev/null +++ b/SimG4Core/CustomPhysics/interface/G4SQLoopProcessDiscr.h @@ -0,0 +1,54 @@ +#ifndef G4SQLoopProcessDiscr_h +#define G4SQLoopProcessDiscr_h 1 + +#include "G4VDiscreteProcess.hh" +#include "globals.hh" +#include "G4Track.hh" +#include "G4ParticleChange.hh" +#include "G4ParticleChangeForTransport.hh" +#include "G4SQ.h" +#include "G4AntiSQ.h" + + +class G4Step; +class G4ParticleDefinition; + + +class G4SQLoopProcessDiscr : public G4VDiscreteProcess { + + public: + + G4SQLoopProcessDiscr(double mass, + const G4String& name = "SQLooper", + G4ProcessType type = fUserDefined); + virtual ~G4SQLoopProcessDiscr(); + + + public: + + virtual G4VParticleChange* PostStepDoIt(const G4Track&, const G4Step&); + virtual G4double PostStepGetPhysicalInteractionLength(const G4Track& track, G4double previousStepSize, G4ForceCondition* condition); + virtual G4double GetMeanFreePath(const G4Track&, G4double,G4ForceCondition*); + void SetTimeLimit(G4double); + virtual void StartTracking(G4Track * aTrack); + private: + + G4SQLoopProcessDiscr(G4SQLoopProcessDiscr &); + G4SQLoopProcessDiscr & operator=(const G4SQLoopProcessDiscr &right); + + protected: + + //G4ParticleChangeForTransport* fParticleChange; + G4ParticleChange* fParticleChange; + double GenMass; + + private: + + G4ThreeVector posini; + G4double globaltimeini; + + +}; + + +#endif diff --git a/SimG4Core/CustomPhysics/interface/G4SQNeutronAnnih.h b/SimG4Core/CustomPhysics/interface/G4SQNeutronAnnih.h new file mode 100644 index 0000000000000..e565d3b490781 --- /dev/null +++ b/SimG4Core/CustomPhysics/interface/G4SQNeutronAnnih.h @@ -0,0 +1,37 @@ + +#ifndef G4SQNeutronAnnih_h +#define G4SQNeutronAnnih_h 1 + +#include "globals.hh" +#include "G4HadronicInteraction.hh" +#include "G4HadProjectile.hh" +#include "G4Nucleus.hh" +#include "G4IonTable.hh" + +class G4ParticleDefinition; + + +class G4SQNeutronAnnih : public G4HadronicInteraction { + + public: + + G4SQNeutronAnnih(double mass); + + virtual ~G4SQNeutronAnnih(); + + G4double momDistr(G4double x_in); + + virtual G4HadFinalState * ApplyYourself( + const G4HadProjectile & aTrack, + G4Nucleus & targetNucleus); + + private: + + G4ParticleDefinition* theSQ; + G4ParticleDefinition* theK0S; + G4ParticleDefinition* theAntiL; + G4ParticleDefinition* theProton; + +}; + +#endif diff --git a/SimG4Core/CustomPhysics/src/CustomPhysicsList.cc b/SimG4Core/CustomPhysics/src/CustomPhysicsList.cc index 0992e0fed1333..ed0c9b3d0db6e 100644 --- a/SimG4Core/CustomPhysics/src/CustomPhysicsList.cc +++ b/SimG4Core/CustomPhysics/src/CustomPhysicsList.cc @@ -20,6 +20,12 @@ #include "SimG4Core/CustomPhysics/interface/CMSQGSPSIMPBuilder.h" #include "SimG4Core/CustomPhysics/interface/CMSSIMPInelasticProcess.h" +#include "SimG4Core/CustomPhysics/interface/G4SQInelasticProcess.h" +#include "SimG4Core/CustomPhysics/interface/G4SQLoopProcess.h" +#include "SimG4Core/CustomPhysics/interface/G4SQLoopProcessDiscr.h" +#include "SimG4Core/CustomPhysics/interface/G4SQNeutronAnnih.h" +#include "SimG4Core/CustomPhysics/interface/G4SQInelasticCrossSection.h" + using namespace CLHEP; G4ThreadLocal std::unique_ptr CustomPhysicsList::myHelper; @@ -99,6 +105,23 @@ void CustomPhysicsList::ConstructProcess() { CMSDarkPairProductionProcess* darkGamma = new CMSDarkPairProductionProcess(dfactor); pmanager->AddDiscreteProcess(darkGamma); } + if (particle->GetParticleName() == "anti_sexaq") { + + // here the different sexaquark interactions get defined + G4SQInelasticProcess * sqInelPr = new G4SQInelasticProcess(particle->GetPDGMass()/GeV); + G4SQNeutronAnnih * sqModel = new G4SQNeutronAnnih(particle->GetPDGMass()/GeV); + sqInelPr->RegisterMe(sqModel); + G4SQInelasticCrossSection * sqInelXS = new G4SQInelasticCrossSection(particle->GetPDGMass()/GeV); + sqInelPr->AddDataSet(sqInelXS); + pmanager->AddDiscreteProcess(sqInelPr); + // add also the looping needed to simulate flat interaction probability + G4SQLoopProcess * sqLoopPr = new G4SQLoopProcess(); + pmanager->AddContinuousProcess(sqLoopPr); + G4SQLoopProcessDiscr * sqLoopPrDiscr = new G4SQLoopProcessDiscr(particle->GetPDGMass()/GeV); + pmanager->AddDiscreteProcess(sqLoopPrDiscr); + } else if (particle->GetParticleName() == "sexaq"){ + edm::LogInfo("CustomPhysics") << " No pmanager implemented for sexaq, only for anti_sexaq"; + } } } } diff --git a/SimG4Core/CustomPhysics/src/G4AntiSQ.cc b/SimG4Core/CustomPhysics/src/G4AntiSQ.cc new file mode 100644 index 0000000000000..227f34b862bb3 --- /dev/null +++ b/SimG4Core/CustomPhysics/src/G4AntiSQ.cc @@ -0,0 +1,59 @@ + +#include "SimG4Core/CustomPhysics/interface/G4AntiSQ.h" +#include "G4PhysicalConstants.hh" +#include "G4SystemOfUnits.hh" +#include "G4ParticleTable.hh" + +#include "G4PhaseSpaceDecayChannel.hh" +#include "G4DecayTable.hh" + +// ###################################################################### +// ### ANTI-SEXAQUARK ### +// ###################################################################### + +G4AntiSQ* G4AntiSQ::theInstance = 0; + +G4AntiSQ* G4AntiSQ::Definition(double mass) +{ + if (theInstance !=0) return theInstance; + const G4String name = "anti_sexaq"; + // search in particle table] + G4ParticleTable* pTable = G4ParticleTable::GetParticleTable(); + G4ParticleDefinition* anInstance = pTable->FindParticle(name); + if (anInstance ==0) + { + // create particle + // + // Arguments for constructor are as follows + // name mass width charge + // 2*spin parity C-conjugation + // 2*Isospin 2*Isospin3 G-parity + // type lepton number baryon number PDG encoding + // stable lifetime decay table + // shortlived subType anti_encoding + + anInstance = new G4ParticleDefinition( + name, mass, 0, 0.0, + 0, +1, 0, + 0, 0, 0, + "baryon", 0, -2, -1020000020, + true, -1.0, NULL, + false, "sexaq"); + + + } + theInstance = reinterpret_cast(anInstance); + return theInstance; +} + +//G4AntiSQ* G4AntiSQ::AntiSQDefinition(double mass) +//{ +// return Definition(mass); +//} + +G4AntiSQ* G4AntiSQ::AntiSQ(double mass) +{ + return Definition(mass * GeV); // will use correct mass if instance exists +} + + diff --git a/SimG4Core/CustomPhysics/src/G4SQ.cc b/SimG4Core/CustomPhysics/src/G4SQ.cc new file mode 100644 index 0000000000000..0fb963364282c --- /dev/null +++ b/SimG4Core/CustomPhysics/src/G4SQ.cc @@ -0,0 +1,59 @@ + +#include "SimG4Core/CustomPhysics/interface/G4SQ.h" +#include "G4PhysicalConstants.hh" +#include "G4SystemOfUnits.hh" +#include "G4ParticleTable.hh" + +#include "G4PhaseSpaceDecayChannel.hh" +#include "G4DecayTable.hh" + +// ###################################################################### +// ### SEXAQUARK ### +// ###################################################################### + +G4SQ* G4SQ::theInstance = 0; + +G4SQ* G4SQ::Definition(double mass) +{ + if (theInstance !=0) return theInstance; + const G4String name = "sexaq"; + // search in particle table] + G4ParticleTable* pTable = G4ParticleTable::GetParticleTable(); + G4ParticleDefinition* anInstance = pTable->FindParticle(name); + if (anInstance ==0) + { + // create particle + // + // Arguments for constructor are as follows + // name mass width charge + // 2*spin parity C-conjugation + // 2*Isospin 2*Isospin3 G-parity + // type lepton number baryon number PDG encoding + // stable lifetime decay table + // shortlived subType anti_encoding + + anInstance = new G4ParticleDefinition( + name, mass, 0, 0.0, + 0, +1, 0, + 0, 0, 0, + "baryon", 0, +2, 1020000020, + true, -1.0, NULL, + false, "sexaq"); + + + } + theInstance = reinterpret_cast(anInstance); + return theInstance; +} + +//G4SQ* G4SQ::SQDefinition(double mass) +//{ +// return Definition(mass); +//} + +G4SQ* G4SQ::SQ(double mass) +{ + return Definition(mass * GeV); // will use correct mass if instance exists +} + + diff --git a/SimG4Core/CustomPhysics/src/G4SQInelasticCrossSection.cc b/SimG4Core/CustomPhysics/src/G4SQInelasticCrossSection.cc new file mode 100644 index 0000000000000..f1f22dab3ce9d --- /dev/null +++ b/SimG4Core/CustomPhysics/src/G4SQInelasticCrossSection.cc @@ -0,0 +1,56 @@ + +#include "G4SystemOfUnits.hh" +#include "G4DynamicParticle.hh" +#include "G4NistManager.hh" + +#include "SimG4Core/CustomPhysics/interface/G4SQ.h" +#include "SimG4Core/CustomPhysics/interface/G4AntiSQ.h" +#include "SimG4Core/CustomPhysics/interface/G4SQInelasticCrossSection.h" + +G4SQInelasticCrossSection::G4SQInelasticCrossSection(double mass) + : G4VCrossSectionDataSet("SQ-neutron") +{ + nist = G4NistManager::Instance(); + theSQ = G4SQ::SQ(mass); + theAntiSQ = G4AntiSQ::AntiSQ(mass); +} + + +G4SQInelasticCrossSection::~G4SQInelasticCrossSection() +{} + + +G4bool G4SQInelasticCrossSection::IsElementApplicable( + const G4DynamicParticle* aPart, + G4int Z, const G4Material*) +{ + return ((0 < Z) && + (aPart->GetDefinition() == theSQ || + aPart->GetDefinition() == theAntiSQ) + ); +} + + +G4double G4SQInelasticCrossSection::GetElementCrossSection( + const G4DynamicParticle* aPart, + G4int Z, const G4Material*) +{ + // return zero for particle instead of antiparticle + // sexaquark interaction with matter expected really tiny + if (aPart->GetDefinition() != theAntiSQ) return 0; + + // zero crosssection for particle at rest + if(aPart->GetKineticEnergy() <= 0.0) { return 0.0; } + + //I don't want to interact on hydrogen + if(Z <= 1){return 0.0;} + + // get the atomic weight (to estimate nr neutrons) + G4double A = nist->GetAtomicMassAmu(Z); + + // put the X section low for the antiS to get a flat interaction rate, + // but also make it scale with the number of neutrons in the material + // because we are going to interact on neutrons, not on protons + return (100.*(A-(G4double)Z)/(G4double)Z)*millibarn; + +} diff --git a/SimG4Core/CustomPhysics/src/G4SQInelasticProcess.cc b/SimG4Core/CustomPhysics/src/G4SQInelasticProcess.cc new file mode 100644 index 0000000000000..62bc218335f00 --- /dev/null +++ b/SimG4Core/CustomPhysics/src/G4SQInelasticProcess.cc @@ -0,0 +1,293 @@ + +#include "SimG4Core/CustomPhysics/interface/G4SQInelasticProcess.h" +#include "SimG4Core/CustomPhysics/interface/G4SQInelasticCrossSection.h" +#include "SimG4Core/CustomPhysics/interface/G4SQ.h" + +#include "G4Types.hh" +#include "G4SystemOfUnits.hh" +#include "G4HadProjectile.hh" +#include "G4ElementVector.hh" +#include "G4Track.hh" +#include "G4Step.hh" +#include "G4Element.hh" +#include "G4ParticleChange.hh" +#include "G4NucleiProperties.hh" +#include "G4Nucleus.hh" + +#include "G4HadronicException.hh" +#include "G4HadronicProcessStore.hh" +#include "G4HadronicInteraction.hh" + +#include "G4ParticleDefinition.hh" + +#include "FWCore/MessageLogger/interface/MessageLogger.h" + + +G4SQInelasticProcess::G4SQInelasticProcess(double mass, const G4String& processName) + : G4HadronicProcess(processName, fHadronic) +{ + AddDataSet(new G4SQInelasticCrossSection(mass)); + theParticle = G4SQ::SQ(mass); +} + + +G4SQInelasticProcess::~G4SQInelasticProcess() +{ +} + + +G4bool G4SQInelasticProcess::IsApplicable(const G4ParticleDefinition& aP) +{ + return theParticle->GetParticleType() == aP.GetParticleType(); +} + + +G4VParticleChange* +G4SQInelasticProcess::PostStepDoIt(const G4Track& aTrack, const G4Step& aStep) +{ + + edm::LogInfo("G4SQInelasticProcess::PostStepDoIt") + << "Particle is going to interact at position" << aTrack.GetPosition()/cm + << " momentumdirection eta: " << aTrack.GetMomentumDirection().eta() + << " interacting in material : " << aTrack.GetMaterial() << std::endl; + + // if primary is not Alive then do nothing + theTotalResult->Clear(); + theTotalResult->Initialize(aTrack); + theTotalResult->ProposeWeight(aTrack.GetWeight()); + if(aTrack.GetTrackStatus() != fAlive) { + edm::LogInfo("G4SQInelasticProcess::PostStepDoIt") + << "No interaction because primary is not alive" << std::endl; + return theTotalResult; + } + + + edm::LogInfo("G4SQInelasticProcess::PostStepDoIt") + << "Start a possible interaction?" << std::endl; + + if(aTrack.GetPosition().rho()/centimeter < 1) { + edm::LogInfo("G4SQInelasticProcess::PostStepDoIt") + << "FYI: the rho of the track is < 1cm and it's still going to interact..." << std::endl; + } + + // Find cross section at end of step and check if <= 0 + // + G4DynamicParticle* aParticle = const_cast(aTrack.GetDynamicParticle()); + + G4Material* aMaterial = aTrack.GetMaterial(); + + const G4Element* anElement = 0; + try + { + anElement = theCrossSectionDataStore->SampleZandA(aParticle, + aMaterial, + targetNucleus); + } + catch(G4HadronicException & aR) + { + G4ExceptionDescription ed; + aR.Report(ed); + DumpState(aTrack,"SampleZandA",ed); + ed << " PostStepDoIt failed on element selection" << G4endl; + G4Exception("G4SQInelasticProcess::PostStepDoIt", "had003", FatalException, + ed); + } + + // check only for charged particles + if(aParticle->GetDefinition()->GetPDGCharge() != 0.0) { + if (GetElementCrossSection(aParticle, anElement, aMaterial) <= 0.0) { + // No interaction + return theTotalResult; + } + } + + // Next check for illegal track status + // + if (aTrack.GetTrackStatus() != fAlive && aTrack.GetTrackStatus() != fSuspend) { + if (aTrack.GetTrackStatus() == fStopAndKill || + aTrack.GetTrackStatus() == fKillTrackAndSecondaries || + aTrack.GetTrackStatus() == fPostponeToNextEvent) { + G4ExceptionDescription ed; + ed << "G4SQInelasticProcess: track in unusable state - " + << aTrack.GetTrackStatus() << G4endl; + ed << "G4SQInelasticProcess: returning unchanged track " << G4endl; + DumpState(aTrack,"PostStepDoIt",ed); + G4Exception("G4SQInelasticProcess::PostStepDoIt", "had004", JustWarning, ed); + } + // No warning for fStopButAlive which is a legal status here + return theTotalResult; + } + + // Go on to regular case + // + G4double originalEnergy = aParticle->GetKineticEnergy(); + G4double kineticEnergy = originalEnergy; + + // Get kinetic energy per nucleon for ions + if(aParticle->GetParticleDefinition()->GetBaryonNumber() > 1.5) + kineticEnergy/=aParticle->GetParticleDefinition()->GetBaryonNumber(); + + try + { + theInteraction = GetHadronicInteractionList().at(0); +// theInteraction = GetHadronicInteractionList()[0]; +// ChooseHadronicInteraction( kineticEnergy, aMaterial, anElement ); + } + catch(G4HadronicException & aE) + { + G4ExceptionDescription ed; + aE.Report(ed); + ed << "Target element "<GetName()<<" Z= " + << targetNucleus.GetZ_asInt() << " A= " + << targetNucleus.GetA_asInt() << G4endl; + DumpState(aTrack,"ChooseHadronicInteraction",ed); + ed << " No HadronicInteraction found out" << G4endl; + G4Exception("G4SQInelasticProcess::PostStepDoIt", "had005", FatalException, + ed); + } + + // Initialize the hadronic projectile from the track + thePro.Initialise(aTrack); + + G4HadFinalState* result = 0; + G4int reentryCount = 0; + + + do + { + try + { + // Call the interaction + result = theInteraction->ApplyYourself( thePro, targetNucleus); + ++reentryCount; + } + catch(G4HadronicException & aR) + { + G4ExceptionDescription ed; + aR.Report(ed); + ed << "Call for " << theInteraction->GetModelName() << G4endl; + ed << "Target element "<GetName()<<" Z= " + << targetNucleus.GetZ_asInt() + << " A= " << targetNucleus.GetA_asInt() << G4endl; + DumpState(aTrack,"ApplyYourself",ed); + ed << " ApplyYourself failed" << G4endl; + G4Exception("G4SQInelasticProcess::PostStepDoIt", "had006", FatalException, + ed); + } + + + edm::LogInfo("G4SQInelasticProcess::PostStepDoIt") + << "Call for " << theInteraction->GetModelName() + << std::endl; + edm::LogInfo("G4SQInelasticProcess::PostStepDoIt") + << "Target element "<< anElement->GetName() + << " Z=" << targetNucleus.GetZ_asInt() + << " A=" << targetNucleus.GetA_asInt() + << std::endl; + + edm::LogInfo("G4SQInelasticProcess::PostStepDoIt") + << "Nr of secondaries: " << result->GetNumberOfSecondaries() << std::endl + << "Momentum change and E deeposit: " << result->GetMomentumChange() << " " << result->GetLocalEnergyDeposit() << std::endl + << "Track position and vertex: " << aTrack.GetPosition() << " " << aTrack.GetVertexPosition() << std::endl; + + float r = aTrack.GetPosition().perp(); + float z = fabs(aTrack.GetPosition().z()); + edm::LogInfo("G4SQInelasticProcess::PostStepDoIt") + << "In tracker volume? " + << (r<(100*cm) && z<(200*cm)? " YES! " : " NO! ") + << "r=" << r/cm << " z=" << z/cm << std::endl; + + // Check the result for catastrophic energy non-conservation + result = CheckResult(thePro,targetNucleus, result); + if(reentryCount>100) { + G4ExceptionDescription ed; + ed << "Call for " << theInteraction->GetModelName() << G4endl; + ed << "Target element "<GetName()<<" Z= " + << targetNucleus.GetZ_asInt() + << " A= " << targetNucleus.GetA_asInt() << G4endl; + DumpState(aTrack,"ApplyYourself",ed); + ed << " ApplyYourself does not completed after 100 attempts" << G4endl; + G4Exception("G4SQInelasticProcess::PostStepDoIt", "had006", FatalException, + ed); + } + } + while(!result); + + edm::LogInfo("G4SQInelasticProcess::PostStepDoIt") + << "=== Anti-sexaquark interaction succeeded!" << std::endl; + result->SetTrafoToLab(thePro.GetTrafoToLab()); + + ClearNumberOfInteractionLengthLeft(); + + FillResult(result, aTrack); + + if (epReportLevel != 0) { + CheckEnergyMomentumConservation(aTrack, targetNucleus); + } + return theTotalResult; +} + + +G4HadFinalState* G4SQInelasticProcess::CheckResult(const G4HadProjectile & aPro,const G4Nucleus &aNucleus, G4HadFinalState * result) +{ + // check for catastrophic energy non-conservation, to re-sample the interaction + + G4HadronicInteraction * theModel = GetHadronicInteractionList()[0]; + + edm::LogInfo("G4SQInelasticProcess::PostStepDoIt") + << "checkresult - " << theModel << std::endl; + + G4double nuclearMass(0); + if (theModel){ + + // Compute final-state total energy + G4double finalE(0.); + G4int nSec = result->GetNumberOfSecondaries(); + + nuclearMass = G4NucleiProperties::GetNuclearMass(aNucleus.GetA_asInt(), + aNucleus.GetZ_asInt()); + if (result->GetStatusChange() != stopAndKill) { + // Interaction didn't complete, returned "do nothing" state => reset nucleus + // or the primary survived the interaction (e.g. electro-nuclear ) => keep nucleus + finalE=result->GetLocalEnergyDeposit() + + aPro.GetDefinition()->GetPDGMass() + result->GetEnergyChange(); + edm::LogInfo("G4SQInelasticProcess::PostStepDoIt") + << "checkresult - interaction not complete: " << finalE << std::endl; + if( nSec == 0 ){ + // Since there are no secondaries, there is no recoil nucleus. + // To check energy balance we must neglect the initial nucleus too. + nuclearMass=0.0; + } + } + for (G4int i = 0; i < nSec; i++) { + finalE += result->GetSecondary(i)->GetParticle()->GetTotalEnergy(); + edm::LogInfo("G4SQInelasticProcess::PostStepDoIt") + << "checkresult - secondary pdgId / E : " + << result->GetSecondary(i)->GetParticle()->GetPDGcode() << "\t" + << result->GetSecondary(i)->GetParticle()->GetTotalEnergy() / GeV + << std::endl; + } + G4double deltaE = nuclearMass + aPro.GetTotalEnergy() - finalE; + edm::LogInfo("G4SQInelasticProcess::PostStepDoIt") + << "checkresult - Total E: " << finalE / GeV << std::endl; + edm::LogInfo("G4SQInelasticProcess::PostStepDoIt") + << "checkresult - Energy balance: " << deltaE / GeV << std::endl; + + std::pair checkLevels = theModel->GetFatalEnergyCheckLevels(); // (relative, absolute) + if (std::abs(deltaE) > checkLevels.second && std::abs(deltaE) > checkLevels.first*aPro.GetKineticEnergy()){ + // do not delete result, this is a pointer to a data member; + G4ExceptionDescription desc; + desc << "Warning: Bad energy non-conservation detected, will " + << (epReportLevel<0 ? "abort the event" : "re-sample the interaction") << G4endl + << " Process / Model: " << GetProcessName()<< " / " << theModel->GetModelName() << G4endl + << " Primary: " << aPro.GetDefinition()->GetParticleName() + << " (" << aPro.GetDefinition()->GetPDGEncoding() << ")," + << " E= " << aPro.Get4Momentum().e() + << ", target nucleus (" << aNucleus.GetZ_asInt() << ","<< aNucleus.GetA_asInt() << ")" << G4endl + << " E(initial - final) = " << deltaE << " MeV." << G4endl; + G4Exception("G4SQInelasticProcess:CheckResult()", "had012", epReportLevel<0 ? EventMustBeAborted : JustWarning,desc); + } + } + return result; +} + diff --git a/SimG4Core/CustomPhysics/src/G4SQLoopProcess.cc b/SimG4Core/CustomPhysics/src/G4SQLoopProcess.cc new file mode 100644 index 0000000000000..6faee989be02f --- /dev/null +++ b/SimG4Core/CustomPhysics/src/G4SQLoopProcess.cc @@ -0,0 +1,64 @@ + +#include "SimG4Core/CustomPhysics/interface/G4SQLoopProcess.h" +#include "G4SystemOfUnits.hh" +#include "G4Step.hh" +#include "G4ParticleDefinition.hh" +#include "G4VParticleChange.hh" + +#include "FWCore/MessageLogger/interface/MessageLogger.h" + + + + +G4SQLoopProcess::G4SQLoopProcess(const G4String& name, G4ProcessType type) + : G4VContinuousProcess(name, type) +{ + fParticleChange = new G4ParticleChange(); +} + + +G4SQLoopProcess::~G4SQLoopProcess() +{ + delete fParticleChange; +} + + +G4VParticleChange* G4SQLoopProcess::AlongStepDoIt(const G4Track& track, const G4Step& step) +{ + + if(track.GetPosition()==posini) + edm::LogInfo("G4SQLoopProcess::AlongStepDoIt") + << "G4SQLoopProcess::AlongStepDoIt: G4SQLoopProcess::AlongStepDoIt MomentumDirection " << track.GetMomentumDirection().eta() << " track GetPostion " << track.GetPosition()/cm << " trackId " << track.GetTrackID() << " parentId: " << track.GetParentID() << " GlobalTime " << track.GetGlobalTime()/ns << " TotalEnergy: " << track.GetTotalEnergy()/GeV << " Velocity " << track.GetVelocity()/m/ns << std::endl; + + fParticleChange->Clear(); + fParticleChange->Initialize(track); + fParticleChange->ProposeWeight(track.GetWeight()); + //Sbar not passing the following criteria are not of interest. They will not be reconstructable. A cut like this is required otherwise you will get Sbar infinitely looping. + if(fabs(track.GetMomentumDirection().eta())>999. || fabs(track.GetPosition().z()) > 160*centimeter){ + edm::LogInfo("G4SQLoopProcess::AlongStepDoIt") + << "Particle getting killed because too large z"<< std::endl; + fParticleChange->ProposeTrackStatus(fStopAndKill); + } + + return fParticleChange; +} + + +G4double G4SQLoopProcess::AlongStepGetPhysicalInteractionLength(const G4Track& track, G4double previousStepSize, G4double currentMinimumStep, G4double& proposedSafety, G4GPILSelection* selection) +{ + return 1.*centimeter; +} + + +G4double G4SQLoopProcess::GetContinuousStepLimit(const G4Track& track, G4double , G4double , G4double& ) +{ + return 1.*centimeter; // seems irrelevant +} + + +void G4SQLoopProcess::StartTracking(G4Track * aTrack) +{ + posini = aTrack->GetPosition(); +} + + diff --git a/SimG4Core/CustomPhysics/src/G4SQLoopProcessDiscr.cc b/SimG4Core/CustomPhysics/src/G4SQLoopProcessDiscr.cc new file mode 100644 index 0000000000000..85d51fac962f1 --- /dev/null +++ b/SimG4Core/CustomPhysics/src/G4SQLoopProcessDiscr.cc @@ -0,0 +1,82 @@ + +#include "SimG4Core/CustomPhysics/interface/G4SQLoopProcessDiscr.h" +#include "G4SystemOfUnits.hh" +#include "G4Step.hh" +#include "G4ParticleDefinition.hh" +#include "G4VParticleChange.hh" + +#include "FWCore/MessageLogger/interface/MessageLogger.h" + + +G4SQLoopProcessDiscr::G4SQLoopProcessDiscr(double mass, const G4String& name, G4ProcessType type) + : G4VDiscreteProcess(name, type) +{ + fParticleChange = new G4ParticleChange(); + fParticleChange->ClearDebugFlag(); + GenMass = mass; +} + + +G4SQLoopProcessDiscr::~G4SQLoopProcessDiscr() +{ + delete fParticleChange; +} + + +G4VParticleChange* G4SQLoopProcessDiscr::PostStepDoIt(const G4Track& track, const G4Step& step) +{ + + G4Track * mytr = const_cast(&track); + mytr->SetPosition(posini); + if(mytr->GetGlobalTime()/ns>4990) + edm::LogWarning("G4SQLoopProcess::AlongStepDoIt") + << "going to loose the particle because the GlobalTime is getting close to 5000" << std::endl; + + fParticleChange->Clear(); + fParticleChange->Initialize(track); + + //adding secondary antiS + fParticleChange->SetNumberOfSecondaries(1); + G4DynamicParticle* replacementParticle= new G4DynamicParticle(G4AntiSQ::AntiSQ(GenMass), track.GetMomentumDirection(), track.GetKineticEnergy()); + fParticleChange->AddSecondary(replacementParticle,globaltimeini); + + //killing original AntiS + fParticleChange->ProposeTrackStatus(fStopAndKill); + + // note SL: this way of working makes a very long history of the track, + // which all get saved recursively in SimTracks. If the cross section + // is too low such that 10's of thousands of iterations are needed, then + // this becomes too heavy to swallow writing out this history. + // So if we ever need very small cross sections, then we really need + // to change this way of working such that we can throw away all original + // tracks and only save the one that interacted. + + return fParticleChange; +} + + +G4double G4SQLoopProcessDiscr::PostStepGetPhysicalInteractionLength(const G4Track& track, G4double previousStepSize, G4ForceCondition* condition) +{ + *condition = NotForced; + G4double intLength = DBL_MAX; //by default the interaction length is super large, only when outside tracker make it 0 to be sure it will do the reset to the original position + G4Track * mytr = const_cast(&track); + if(sqrt(pow(mytr->GetPosition().rho(),2))>2.45*centimeter){//this is an important cut for the looping: if the radius of the particle is largher than 2.45cm its interaction length becomes 0 which means it will get killed +// updated from 2.5 to 2.45 so that the Sbar does not start to hit the support of the new inner tracker which was added in 2018 + intLength = 0.0;//0 interaction length means particle will directly interact. + } + return intLength; +} + +G4double G4SQLoopProcessDiscr::GetMeanFreePath(const G4Track&,G4double, + G4ForceCondition*) +{ + return DBL_MAX; +} + + +void G4SQLoopProcessDiscr::StartTracking(G4Track * aTrack) +{ + posini = aTrack->GetPosition(); + globaltimeini = aTrack->GetGlobalTime(); + +} diff --git a/SimG4Core/CustomPhysics/src/G4SQNeutronAnnih.cc b/SimG4Core/CustomPhysics/src/G4SQNeutronAnnih.cc new file mode 100644 index 0000000000000..6ed99739e5148 --- /dev/null +++ b/SimG4Core/CustomPhysics/src/G4SQNeutronAnnih.cc @@ -0,0 +1,281 @@ + +#include "G4PhysicalConstants.hh" +#include "G4SystemOfUnits.hh" +#include "G4ParticleTable.hh" +#include "G4ParticleDefinition.hh" +#include "Randomize.hh" +#include "G4NucleiProperties.hh" +#include +#include "TMath.h" + +#include "SimG4Core/CustomPhysics/interface/G4SQNeutronAnnih.h" +#include "SimG4Core/CustomPhysics/interface/G4SQ.h" + + +G4SQNeutronAnnih::G4SQNeutronAnnih(double mass) : G4HadronicInteraction("SexaQuark-neutron annihilation") +{ + SetMinEnergy( 0.0*GeV ); + SetMaxEnergy( 100.*TeV ); + + theSQ = G4SQ::SQ(mass); + theK0S = G4KaonZeroShort::KaonZeroShort(); + theAntiL = G4AntiLambda::AntiLambda(); + theProton = G4Proton::Proton();//proton only used when the particle which the sexaquark hits is a deutereon and the neutron dissapears, so what stays behind is a proton +} + + +G4SQNeutronAnnih::~G4SQNeutronAnnih() +{} + + + +//9Be momentum distribution from Jan Ryckebusch +G4double G4SQNeutronAnnih::momDistr(G4double x_in){ + +const int n_entries = 50; + +G4double CDF_k[n_entries] = { +0, +0.1, +0.2, +0.3, +0.4, +0.5, +0.6, +0.7, +0.8, +0.9, +1, +1.1, +1.2, +1.3, +1.4, +1.5, +1.6, +1.7, +1.8, +1.9, +2, +2.1, +2.2, +2.3, +2.4, +2.5, +2.6, +2.7, +2.8, +2.9, +3, +3.1, +3.2, +3.3, +3.4, +3.5, +3.6, +3.7, +3.8, +3.9, +4., +4.1, +4.2, +4.3, +4.4, +4.5, +4.6, +4.7, +4.8, +4.9 +}; + +G4double x[n_entries] = { +0, +0.0038033182, +0.0187291764, +0.0510409777, +0.1048223609, +0.1807862863, +0.2756514534, +0.3825832103, +0.4926859745, +0.5970673837, +0.6887542272, +0.7637748784, +0.8212490273, +0.8627259608, +0.8911605331, +0.9099115186, +0.9220525854, +0.9300190818, +0.9355376091, +0.9397242185, +0.9432387722, +0.946438928, +0.9495023924, +0.9525032995, +0.9554669848, +0.9583936672, +0.9612770117, +0.9641067202, +0.9668727859, +0.9695676121, +0.9721815799, +0.9747092981, +0.9771426396, +0.9794740235, +0.9816956807, +0.9838003583, +0.9857816165, +0.9876331761, +0.9893513365, +0.9909333198, +0.992378513, +0.9936885054, +0.9948665964, +0.9959179448, +0.9968491104, +0.9976680755, +0.9983832508, +0.9990041784, +0.9995400073, +1 +}; + + //now interpolate the above points for x_in + G4double result = 9999; + for(int i = 0; i < n_entries; i++){ + if(x[i] > x_in) { + result = (CDF_k[i]-CDF_k[i-1])/(x[i]-x[i-1])*(x_in-x[i-1])+CDF_k[i-1]; + break; + } + } + //ROOT::Math::Interpolator inter(n_entries, ROOT::Math::Interpolation::kAKIMA); + //inter.SetData(n_entries,x,CDF_k); + //result = inter.Eval(x_in); + + return result; + //return 1; + +} + + + + + +G4HadFinalState* G4SQNeutronAnnih::ApplyYourself( + const G4HadProjectile& aTrack, G4Nucleus& targetNucleus) +{ + theParticleChange.Clear(); + const G4HadProjectile* aParticle = &aTrack; + G4double ekin = aParticle->GetKineticEnergy(); + + + G4int A = targetNucleus.GetA_asInt(); + G4int Z = targetNucleus.GetZ_asInt(); + + + G4double m_K0S = G4KaonZeroShort::KaonZeroShort()->GetPDGMass(); + G4double m_L = G4AntiLambda::AntiLambda()->GetPDGMass(); + + G4cout << "----> G4SQNeutronAnnih <-----" << G4endl; + + //G4double plab = aParticle->GetTotalMomentum(); + +// G4cout << "G4SQNeutronAnnih: Incident particle p (GeV), total Energy (GeV), particle name, eta =" +// << plab/GeV << " " +// << aParticle->GetTotalEnergy()/GeV << " " +// << aParticle->GetDefinition()->GetParticleName() << " " +// << aParticle->Get4Momentum() << G4endl; + + // Scattered particle referred to axis of incident particle + //const G4ParticleDefinition* theParticle = aParticle->GetDefinition(); + + //G4int projPDG = theParticle->GetPDGEncoding(); +// if (verboseLevel > 1) +// G4cout << "G4SQNeutronAnnih: for " << theParticle->GetParticleName() +// << " PDGcode= " << projPDG << " on nucleus Z= " << Z +// << " A= " << A << " N= " << N +// << G4endl; + + G4LorentzVector lv1 = aParticle->Get4Momentum(); + G4cout << "The neutron Fermi momentum (mag, x, y, z) " << targetNucleus.GetFermiMomentum().mag()/MeV << " " << targetNucleus.GetFermiMomentum().x()/MeV << " " << targetNucleus.GetFermiMomentum().y()/MeV << " " << targetNucleus.GetFermiMomentum().z()/MeV << std::endl; + + //calculate fermi momentum + + G4double k_neutron = momDistr(G4UniformRand()); + G4double momentum_neutron = 0.1973*GeV*k_neutron; + + G4double theta_neutron = TMath::ACos(2*G4UniformRand()-1); + G4double phi_neutron = 2.*TMath::Pi()*G4UniformRand(); + + G4double p_neutron_x = momentum_neutron*TMath::Sin(theta_neutron)*TMath::Cos(phi_neutron); + G4double p_neutron_y = momentum_neutron*TMath::Sin(theta_neutron)*TMath::Sin(phi_neutron); + G4double p_neutron_z = momentum_neutron*TMath::Cos(theta_neutron); + + + //G4LorentzVector lv0(targetNucleus.GetFermiMomentum(), sqrt( pow(G4Neutron::Neutron()->GetPDGMass(),2) + targetNucleus.GetFermiMomentum().mag2() ) ); + G4LorentzVector lv0(p_neutron_x, p_neutron_y, p_neutron_z, sqrt( pow(G4Neutron::Neutron()->GetPDGMass(),2) + momentum_neutron*momentum_neutron ) ); + + //const G4Nucleus* aNucleus = &targetNucleus; + G4double BENeutronInNucleus = 0; + if(A != 0)BENeutronInNucleus = G4NucleiProperties::GetBindingEnergy( A, Z)/(A); + + G4cout << "BE of nucleon in the nucleus (GeV): " << BENeutronInNucleus/GeV << G4endl; + + G4LorentzVector lvBE(0,0,0,BENeutronInNucleus/GeV); + G4LorentzVector lv = lv0 + lv1 - lvBE; + + // kinematiacally impossible ? + G4double etot = lv0.e() + lv1.e() - lvBE.e(); + if(etot < theK0S->GetPDGMass() + theAntiL->GetPDGMass()) { + theParticleChange.SetEnergyChange(ekin); + theParticleChange.SetMomentumChange(aTrack.Get4Momentum().vect().unit()); + return &theParticleChange; + } + + float newIonMass = targetNucleus.AtomicMass(A-1,Z)*931.5*MeV; ; + G4LorentzVector nlvIon(0,0,0,newIonMass); + + G4double theta_KS0_star = TMath::ACos(2*G4UniformRand()-1); + G4double phi_KS0_star = 2.*TMath::Pi()*G4UniformRand(); + + G4double p_K0S_star_x = TMath::Sin(theta_KS0_star)*TMath::Cos(phi_KS0_star); + G4double p_K0S_star_y = TMath::Sin(theta_KS0_star)*TMath::Sin(phi_KS0_star); + G4double p_K0S_star_z = TMath::Cos(theta_KS0_star); + + G4ThreeVector p(p_K0S_star_x,p_K0S_star_y,p_K0S_star_z); + double m0 = lv.m(); + double m0_2 = m0*m0; + double m1_2 = m_K0S*m_K0S; + double m2_2 = m_L*m_L; + + p *= 0.5/m0 * sqrt ( m0_2*m0_2 + m1_2*m1_2 + m2_2*m2_2 - 2*m0_2*m1_2 - 2*m0_2*m2_2 - 2*m1_2*m2_2); + double p2 = p.mag2(); + + G4LorentzVector nlvK0S( p, sqrt (p2 + m1_2)); + G4LorentzVector nlvAntiL(-p, sqrt (p2 + m2_2)); + + // Boost out of the rest frame. + nlvK0S.boost (lv.boostVector ()); + nlvAntiL.boost (lv.boostVector ()); + + // now move to implement the interaction + theParticleChange.SetStatusChange(stopAndKill); + //theParticleChange.SetEnergyChange(ekin); // was 0.0 + + + + G4DynamicParticle * aSec1 = new G4DynamicParticle(theK0S, nlvK0S); + theParticleChange.AddSecondary(aSec1); + G4DynamicParticle * aSec2 = new G4DynamicParticle(theAntiL, nlvAntiL); + theParticleChange.AddSecondary(aSec2); + + const G4ParticleDefinition* theRemainingNucleusDef = theProton; + if(A != 1) theRemainingNucleusDef = G4IonTable::GetIonTable()->GetIon(Z,A-1); + G4DynamicParticle * aSec3 = new G4DynamicParticle(theRemainingNucleusDef, nlvIon); + theParticleChange.AddSecondary(aSec3); + + // return as is; we don't care about what happens to the nucleus + return &theParticleChange; + +} + diff --git a/SimG4Core/CustomPhysics/test/Sexaquark_RunIIFall18GenSim_cfg.py b/SimG4Core/CustomPhysics/test/Sexaquark_RunIIFall18GenSim_cfg.py new file mode 100644 index 0000000000000..6b45056624f01 --- /dev/null +++ b/SimG4Core/CustomPhysics/test/Sexaquark_RunIIFall18GenSim_cfg.py @@ -0,0 +1,151 @@ +# Auto generated configuration file +# using: +# Revision: 1.19 +# Source: /local/reps/CMSSW/CMSSW/Configuration/Applications/python/ConfigBuilder.py,v +# with command line options: Configuration/GenProduction/python/BPH-RunIIFall18GS-00369-fragment.py --python_filename BPH-RunIIFall18GS-00369_1_cfg.py --eventcontent RAWSIM --datatier GEN-SIM --fileout file:BPH-RunIIFall18GS-00369.root --conditions 102X_upgrade2018_realistic_v11 --beamspot Realistic25ns13TeVEarly2018Collision --step GEN,SIM --geometry DB:Extended --era Run2_2018 --no_exec --mc -n 1000 +import FWCore.ParameterSet.Config as cms +from Configuration.StandardSequences.Eras import eras +from FWCore.ParameterSet.VarParsing import VarParsing + +process = cms.Process('SIM',eras.Run3_2023) +options = VarParsing ('analysis') +options.outputFile = 'file:sexaq_sim.root' +#options.inputFiles = 'root://cmsxrootd.hep.wisc.edu//store/user/wvetens/crmc_Sexaq/crmc/Sexaquark_13TeV_trial_4_1p8GeV/0/crmc_Sexaq_1.root' +options.inputFiles = 'file:crmc_Sexaq_1.root' +options.maxEvents= 100 +options.parseArguments() + +# import of standard configurations +process.load('Configuration.StandardSequences.Services_cff') +#process.load('SimGeneral.HepPDTESSource.pythiapdt_cfi') +process.load('FWCore.MessageService.MessageLogger_cfi') +process.load('Configuration.EventContent.EventContent_cff') +process.load('SimGeneral.MixingModule.mixNoPU_cfi') +process.load('Configuration.StandardSequences.GeometryRecoDB_cff') +process.load('Configuration.StandardSequences.GeometrySimDB_cff') +process.load('Configuration.StandardSequences.MagneticField_cff') +process.load('Configuration.StandardSequences.Generator_cff') +# Vtx Smearing done in hepmc 2 gen step +process.load('IOMC.EventVertexGenerators.VtxSmearedRealistic25ns13TeVEarly2018Collision_cfi') +#process.load('GeneratorInterface.Core.genFilterSummary_cff') +process.load('Configuration.StandardSequences.SimIdeal_cff') +process.load('Configuration.StandardSequences.EndOfProcess_cff') +process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff') +process.load('RecoVertex.BeamSpotProducer.BeamSpot_cfi') + +# Lengthy message logs - uncomment to debug +#process.MessageLogger = cms.Service("MessageLogger", +# destinations = cms.untracked.vstring('cout'), +# cout = cms.untracked.PSet( +# threshold = cms.untracked.string('INFO') +# ) +#) + +process.maxEvents = cms.untracked.PSet( + input = cms.untracked.int32(options.maxEvents) + #input = cms.untracked.int32(-1) +) + +# Input source + +#process.source = cms.Source("EmptySource") +process.source = cms.Source("PoolSource", + fileNames = cms.untracked.vstring(options.inputFiles), + skipEvents = cms.untracked.uint32(0), + duplicateCheckMode = cms.untracked.string ("noDuplicateCheck") +) + + +process.options = cms.untracked.PSet( + wantSummary = cms.untracked.bool(True) +) + +# Output definition + +process.RAWSIMoutput = cms.OutputModule("PoolOutputModule", + SelectEvents = cms.untracked.PSet( + SelectEvents = cms.vstring('generation_step') + ), + compressionAlgorithm = cms.untracked.string('LZMA'), + compressionLevel = cms.untracked.int32(1), + dataset = cms.untracked.PSet( + dataTier = cms.untracked.string('GEN-SIM'), + filterName = cms.untracked.string('') + ), + eventAutoFlushCompressedSize = cms.untracked.int32(20971520), + fileName = cms.untracked.string(options.outputFile), + outputCommands = process.RAWSIMEventContent.outputCommands, + splitLevel = cms.untracked.int32(0) +) + +# Additional output definition +process.RAWSIMoutput.outputCommands += ("keep *_genParticlesPlusGEANT_*_*",) + +# Other statements +#process.XMLFromDBSource.label = cms.string("Extended") +process.genstepfilter.triggerConditions=cms.vstring("generation_step") +from Configuration.AlCa.GlobalTag import GlobalTag +#process.GlobalTag = GlobalTag(process.GlobalTag, '102X_upgrade2018_realistic_v11', '') +#process.GlobalTag = GlobalTag(process.GlobalTag, '140X_mcRun3_2024_realistic_v14', '') +process.GlobalTag = GlobalTag(process.GlobalTag, '140X_mcRun3_2023_realistic_v3', '') +#process.GlobalTag = GlobalTag(process.GlobalTag, '140X_mcRun3_2022_realistic_v3', '') + + + +process.genParticlesPlusGEANT = cms.EDProducer("GenPlusSimParticleProducer", + src = cms.InputTag("g4SimHits"), + setStatus = cms.int32(8), # set status = 8 for GEANT GPs + particleTypes = cms.vstring(), + filter = cms.vstring(), + genParticles = cms.InputTag("genParticles") # original genParticle list +) + +from SimG4Core.CustomPhysics.CustomPhysics_cfi import customPhysicsSetup +process.g4SimHits.Physics.type = cms.string('SimG4Core/Physics/CustomPhysics') +process.g4SimHits.Physics.RHadronDummyFlip = cms.bool(False) +process.g4SimHits.Physics.Verbosity = 1 +process.g4SimHits.Physics = cms.PSet( + process.g4SimHits.Physics, #keep all default value and add others + customPhysicsSetup + ) +process.g4SimHits.Physics.particlesDef = cms.FileInPath('SimG4Core/CustomPhysics/data/particles_sexaq_1p8_GeV.txt') + + +## Vtx Smearing done in hepmc 2 gen step +process.VtxSmeared.src = cms.InputTag("source", "generator") +process.genParticles.src = cms.InputTag("generatorSmeared") +process.g4SimHits.HepMCProductLabel = cms.InputTag("generatorSmeared") +process.g4SimHits.Generator.HepMCProductLabel = cms.InputTag("generatorSmeared") + + +# Path and EndPath definitions +process.generation_step = cms.Path(process.pgen) +#moved beamspot and vtx smearing to hepmc2gen step +#process.simulation_step = cms.Path(process.offlineBeamSpot*process.generatorSmeared*process.psim*process.genParticlesPlusGEANT) +process.simulation_step = cms.Path(process.psim*process.genParticlesPlusGEANT) +#process.genfiltersummary_step = cms.EndPath(process.genFilterSummary) +process.endjob_step = cms.EndPath(process.endOfProcess) +process.RAWSIMoutput_step = cms.EndPath(process.RAWSIMoutput) + +# Schedule definition +#process.schedule = cms.Schedule(process.generation_step,process.genfiltersummary_step,process.simulation_step,process.endjob_step,process.RAWSIMoutput_step) +process.schedule = cms.Schedule(process.generation_step,process.simulation_step,process.endjob_step,process.RAWSIMoutput_step) + +from PhysicsTools.PatAlgos.tools.helpers import associatePatAlgosToolsTask +associatePatAlgosToolsTask(process) +## filter all path with the production filter sequence +#for path in process.paths: +# getattr(process,path)._seq = process.ProductionFilterSequence * getattr(process,path)._seq + +from Configuration.DataProcessing.Utils import addMonitoring +process = addMonitoring(process) + +# Customisation from command line + +# Add early deletion of temporary data products to reduce peak memory need +from Configuration.StandardSequences.earlyDeleteSettings_cff import customiseEarlyDelete +process = customiseEarlyDelete(process) + +# End adding early deletion +# For debug: +#print process.dumpPython() From 5804b9c81b64a688e6779374d104f6b55dd1ce84 Mon Sep 17 00:00:00 2001 From: Steven Date: Fri, 17 May 2024 11:24:45 +0200 Subject: [PATCH 022/237] Code cleanup after code checks --- SimG4Core/CustomPhysics/interface/G4AntiSQ.h | 23 +- SimG4Core/CustomPhysics/interface/G4SQ.h | 21 +- .../interface/G4SQInelasticCrossSection.h | 22 +- .../interface/G4SQInelasticProcess.h | 29 +- .../CustomPhysics/interface/G4SQLoopProcess.h | 61 ++-- .../interface/G4SQLoopProcessDiscr.h | 61 ++-- .../interface/G4SQNeutronAnnih.h | 27 +- .../CustomPhysics/src/CustomPhysicsList.cc | 13 +- SimG4Core/CustomPhysics/src/G4AntiSQ.cc | 47 +-- SimG4Core/CustomPhysics/src/G4SQ.cc | 47 +-- .../src/G4SQInelasticCrossSection.cc | 39 +-- .../CustomPhysics/src/G4SQInelasticProcess.cc | 270 ++++++--------- .../CustomPhysics/src/G4SQLoopProcess.cc | 55 ++-- .../CustomPhysics/src/G4SQLoopProcessDiscr.cc | 64 ++-- .../CustomPhysics/src/G4SQNeutronAnnih.cc | 311 +++++++----------- 15 files changed, 430 insertions(+), 660 deletions(-) diff --git a/SimG4Core/CustomPhysics/interface/G4AntiSQ.h b/SimG4Core/CustomPhysics/interface/G4AntiSQ.h index 93716063261c3..d131d566af6a0 100644 --- a/SimG4Core/CustomPhysics/interface/G4AntiSQ.h +++ b/SimG4Core/CustomPhysics/interface/G4AntiSQ.h @@ -26,7 +26,7 @@ // // $Id: G4AntiSQ.hh 67971 2013-03-13 10:13:24Z gcosmo $ // -// +// // ------------------------------------------------------------ // GEANT 4 class header file // @@ -47,19 +47,16 @@ // ### ANTI-SEXAQUARK ### // ###################################################################### - class G4AntiSQ : public G4ParticleDefinition { - - private: - static G4AntiSQ* theInstance; - G4AntiSQ(){} - ~G4AntiSQ(){} - - public: - static G4AntiSQ* Definition(double mass); - //static G4AntiSQ* AntiSQDefinition(double mass); - static G4AntiSQ* AntiSQ(double mass); - +private: + static G4AntiSQ* theInstance; + G4AntiSQ() {} + ~G4AntiSQ() {} + +public: + static G4AntiSQ* Definition(double mass); + //static G4AntiSQ* AntiSQDefinition(double mass); + static G4AntiSQ* AntiSQ(double mass); }; #endif diff --git a/SimG4Core/CustomPhysics/interface/G4SQ.h b/SimG4Core/CustomPhysics/interface/G4SQ.h index 6277916684f1f..e23968e0f4486 100644 --- a/SimG4Core/CustomPhysics/interface/G4SQ.h +++ b/SimG4Core/CustomPhysics/interface/G4SQ.h @@ -10,19 +10,16 @@ // ### SEXAQUARK ### // ###################################################################### - class G4SQ : public G4ParticleDefinition { - - private: - static G4SQ* theInstance; - G4SQ(){} - ~G4SQ(){} - - public: - static G4SQ* Definition(double mass); -// static G4SQ* SQDefinition(double mass); - static G4SQ* SQ(double mass); - +private: + static G4SQ* theInstance; + G4SQ() {} + ~G4SQ() {} + +public: + static G4SQ* Definition(double mass); + // static G4SQ* SQDefinition(double mass); + static G4SQ* SQ(double mass); }; #endif diff --git a/SimG4Core/CustomPhysics/interface/G4SQInelasticCrossSection.h b/SimG4Core/CustomPhysics/interface/G4SQInelasticCrossSection.h index 2a5c5881dfba5..31e1ee6f65638 100644 --- a/SimG4Core/CustomPhysics/interface/G4SQInelasticCrossSection.h +++ b/SimG4Core/CustomPhysics/interface/G4SQInelasticCrossSection.h @@ -2,41 +2,29 @@ #ifndef G4SQInelasticCrossSection_h #define G4SQInelasticCrossSection_h - #include "globals.hh" #include "G4VCrossSectionDataSet.hh" - class G4NistManager; class G4SQ; class G4AntiSQ; - -class G4SQInelasticCrossSection : public G4VCrossSectionDataSet -{ +class G4SQInelasticCrossSection : public G4VCrossSectionDataSet { public: - G4SQInelasticCrossSection(double mass); ~G4SQInelasticCrossSection(); - virtual - G4bool IsElementApplicable(const G4DynamicParticle* aPart, - G4int Z, const G4Material*); + virtual G4bool IsElementApplicable(const G4DynamicParticle* aPart, G4int Z, const G4Material*); - virtual - G4double GetElementCrossSection(const G4DynamicParticle*, - G4int Z, const G4Material*); + virtual G4double GetElementCrossSection(const G4DynamicParticle*, G4int Z, const G4Material*); G4double GetSQCrossSection(G4double kineticEnergy, G4int Z); private: - G4NistManager* nist; - G4SQ * theSQ; - G4AntiSQ * theAntiSQ; - + G4SQ* theSQ; + G4AntiSQ* theAntiSQ; }; #endif - diff --git a/SimG4Core/CustomPhysics/interface/G4SQInelasticProcess.h b/SimG4Core/CustomPhysics/interface/G4SQInelasticProcess.h index 6530d267c16fb..f3039d458c940 100644 --- a/SimG4Core/CustomPhysics/interface/G4SQInelasticProcess.h +++ b/SimG4Core/CustomPhysics/interface/G4SQInelasticProcess.h @@ -1,46 +1,33 @@ #ifndef SimG4Core_CustomPhysics_G4SQInelasticProcess_h #define SimG4Core_CustomPhysics_G4SQInelasticProcess_h 1 - - -#include "G4HadronicProcess.hh" +#include "G4HadronicProcess.hh" class G4ParticleDefinition; - -class G4SQInelasticProcess : public G4HadronicProcess -{ - - public: - - G4SQInelasticProcess(double mass, const G4String& processName="SQInelastic"); +class G4SQInelasticProcess : public G4HadronicProcess { +public: + G4SQInelasticProcess(double mass, const G4String& processName = "SQInelastic"); ~G4SQInelasticProcess(); G4bool IsApplicable(const G4ParticleDefinition& aParticleType) override; // generic PostStepDoIt recommended for all derived classes - virtual G4VParticleChange* PostStepDoIt(const G4Track& aTrack, - const G4Step& aStep); + virtual G4VParticleChange* PostStepDoIt(const G4Track& aTrack, const G4Step& aStep); G4SQInelasticProcess& operator=(const G4SQInelasticProcess& right); G4SQInelasticProcess(const G4SQInelasticProcess&); - protected: - +protected: // Check the result for catastrophic energy non-conservation - G4HadFinalState* CheckResult(const G4HadProjectile& thePro, - const G4Nucleus& targetNucleus, - G4HadFinalState* result); - - private: + G4HadFinalState* CheckResult(const G4HadProjectile& thePro, const G4Nucleus& targetNucleus, G4HadFinalState* result); +private: G4ParticleDefinition* theParticle; G4Nucleus targetNucleus; G4HadronicInteraction* theInteraction = nullptr; - }; #endif - diff --git a/SimG4Core/CustomPhysics/interface/G4SQLoopProcess.h b/SimG4Core/CustomPhysics/interface/G4SQLoopProcess.h index 224fb8a1b9fbf..737c4738584c0 100644 --- a/SimG4Core/CustomPhysics/interface/G4SQLoopProcess.h +++ b/SimG4Core/CustomPhysics/interface/G4SQLoopProcess.h @@ -6,43 +6,38 @@ #include "G4Track.hh" #include "G4ParticleChange.hh" - class G4Step; class G4ParticleDefinition; - class G4SQLoopProcess : public G4VContinuousProcess { - - public: - - G4SQLoopProcess(const G4String& name = "SQLooper", - G4ProcessType type = fUserDefined); - virtual ~G4SQLoopProcess(); - - - public: - - virtual G4VParticleChange* AlongStepDoIt(const G4Track&, const G4Step&); - virtual G4double AlongStepGetPhysicalInteractionLength(const G4Track& track, G4double previousStepSize, G4double currentMinimumStep, G4double& proposedSafety, G4GPILSelection* selection); - virtual void StartTracking(G4Track * aTrack); - - protected: - - virtual G4double GetContinuousStepLimit(const G4Track& track, G4double previousStepSize, G4double currentMinimumStep, G4double& currentSafety); - - private: - - G4SQLoopProcess(G4SQLoopProcess &); - G4SQLoopProcess & operator=(const G4SQLoopProcess &right); - - protected: - - G4ParticleChange* fParticleChange; - - private: - - G4ThreeVector posini; +public: + G4SQLoopProcess(const G4String& name = "SQLooper", G4ProcessType type = fUserDefined); + virtual ~G4SQLoopProcess(); + +public: + virtual G4VParticleChange* AlongStepDoIt(const G4Track&, const G4Step&); + virtual G4double AlongStepGetPhysicalInteractionLength(const G4Track& track, + G4double previousStepSize, + G4double currentMinimumStep, + G4double& proposedSafety, + G4GPILSelection* selection); + virtual void StartTracking(G4Track* aTrack); + +protected: + virtual G4double GetContinuousStepLimit(const G4Track& track, + G4double previousStepSize, + G4double currentMinimumStep, + G4double& currentSafety); + +private: + G4SQLoopProcess(G4SQLoopProcess&); + G4SQLoopProcess& operator=(const G4SQLoopProcess& right); + +protected: + G4ParticleChange* fParticleChange; + +private: + G4ThreeVector posini; }; - #endif diff --git a/SimG4Core/CustomPhysics/interface/G4SQLoopProcessDiscr.h b/SimG4Core/CustomPhysics/interface/G4SQLoopProcessDiscr.h index f7a192b24bb7a..25d7296cb4c8b 100644 --- a/SimG4Core/CustomPhysics/interface/G4SQLoopProcessDiscr.h +++ b/SimG4Core/CustomPhysics/interface/G4SQLoopProcessDiscr.h @@ -9,46 +9,35 @@ #include "G4SQ.h" #include "G4AntiSQ.h" - class G4Step; class G4ParticleDefinition; - class G4SQLoopProcessDiscr : public G4VDiscreteProcess { - - public: - - G4SQLoopProcessDiscr(double mass, - const G4String& name = "SQLooper", - G4ProcessType type = fUserDefined); - virtual ~G4SQLoopProcessDiscr(); - - - public: - - virtual G4VParticleChange* PostStepDoIt(const G4Track&, const G4Step&); - virtual G4double PostStepGetPhysicalInteractionLength(const G4Track& track, G4double previousStepSize, G4ForceCondition* condition); - virtual G4double GetMeanFreePath(const G4Track&, G4double,G4ForceCondition*); - void SetTimeLimit(G4double); - virtual void StartTracking(G4Track * aTrack); - private: - - G4SQLoopProcessDiscr(G4SQLoopProcessDiscr &); - G4SQLoopProcessDiscr & operator=(const G4SQLoopProcessDiscr &right); - - protected: - - //G4ParticleChangeForTransport* fParticleChange; - G4ParticleChange* fParticleChange; - double GenMass; - - private: - - G4ThreeVector posini; - G4double globaltimeini; - - +public: + G4SQLoopProcessDiscr(double mass, const G4String& name = "SQLooper", G4ProcessType type = fUserDefined); + virtual ~G4SQLoopProcessDiscr(); + +public: + virtual G4VParticleChange* PostStepDoIt(const G4Track&, const G4Step&); + virtual G4double PostStepGetPhysicalInteractionLength(const G4Track& track, + G4double previousStepSize, + G4ForceCondition* condition); + virtual G4double GetMeanFreePath(const G4Track&, G4double, G4ForceCondition*); + void SetTimeLimit(G4double); + virtual void StartTracking(G4Track* aTrack); + +private: + G4SQLoopProcessDiscr(G4SQLoopProcessDiscr&); + G4SQLoopProcessDiscr& operator=(const G4SQLoopProcessDiscr& right); + +protected: + //G4ParticleChangeForTransport* fParticleChange; + G4ParticleChange* fParticleChange; + double GenMass; + +private: + G4ThreeVector posini; + G4double globaltimeini; }; - #endif diff --git a/SimG4Core/CustomPhysics/interface/G4SQNeutronAnnih.h b/SimG4Core/CustomPhysics/interface/G4SQNeutronAnnih.h index e565d3b490781..403697305d771 100644 --- a/SimG4Core/CustomPhysics/interface/G4SQNeutronAnnih.h +++ b/SimG4Core/CustomPhysics/interface/G4SQNeutronAnnih.h @@ -10,28 +10,21 @@ class G4ParticleDefinition; - class G4SQNeutronAnnih : public G4HadronicInteraction { +public: + G4SQNeutronAnnih(double mass); - public: - - G4SQNeutronAnnih(double mass); - - virtual ~G4SQNeutronAnnih(); - - G4double momDistr(G4double x_in); - - virtual G4HadFinalState * ApplyYourself( - const G4HadProjectile & aTrack, - G4Nucleus & targetNucleus); + virtual ~G4SQNeutronAnnih(); - private: + G4double momDistr(G4double x_in); - G4ParticleDefinition* theSQ; - G4ParticleDefinition* theK0S; - G4ParticleDefinition* theAntiL; - G4ParticleDefinition* theProton; + virtual G4HadFinalState* ApplyYourself(const G4HadProjectile& aTrack, G4Nucleus& targetNucleus); +private: + G4ParticleDefinition* theSQ; + G4ParticleDefinition* theK0S; + G4ParticleDefinition* theAntiL; + G4ParticleDefinition* theProton; }; #endif diff --git a/SimG4Core/CustomPhysics/src/CustomPhysicsList.cc b/SimG4Core/CustomPhysics/src/CustomPhysicsList.cc index ed0c9b3d0db6e..983cc2045ee2d 100644 --- a/SimG4Core/CustomPhysics/src/CustomPhysicsList.cc +++ b/SimG4Core/CustomPhysics/src/CustomPhysicsList.cc @@ -106,20 +106,19 @@ void CustomPhysicsList::ConstructProcess() { pmanager->AddDiscreteProcess(darkGamma); } if (particle->GetParticleName() == "anti_sexaq") { - // here the different sexaquark interactions get defined - G4SQInelasticProcess * sqInelPr = new G4SQInelasticProcess(particle->GetPDGMass()/GeV); - G4SQNeutronAnnih * sqModel = new G4SQNeutronAnnih(particle->GetPDGMass()/GeV); + G4SQInelasticProcess* sqInelPr = new G4SQInelasticProcess(particle->GetPDGMass() / GeV); + G4SQNeutronAnnih* sqModel = new G4SQNeutronAnnih(particle->GetPDGMass() / GeV); sqInelPr->RegisterMe(sqModel); - G4SQInelasticCrossSection * sqInelXS = new G4SQInelasticCrossSection(particle->GetPDGMass()/GeV); + G4SQInelasticCrossSection* sqInelXS = new G4SQInelasticCrossSection(particle->GetPDGMass() / GeV); sqInelPr->AddDataSet(sqInelXS); pmanager->AddDiscreteProcess(sqInelPr); // add also the looping needed to simulate flat interaction probability - G4SQLoopProcess * sqLoopPr = new G4SQLoopProcess(); + G4SQLoopProcess* sqLoopPr = new G4SQLoopProcess(); pmanager->AddContinuousProcess(sqLoopPr); - G4SQLoopProcessDiscr * sqLoopPrDiscr = new G4SQLoopProcessDiscr(particle->GetPDGMass()/GeV); + G4SQLoopProcessDiscr* sqLoopPrDiscr = new G4SQLoopProcessDiscr(particle->GetPDGMass() / GeV); pmanager->AddDiscreteProcess(sqLoopPrDiscr); - } else if (particle->GetParticleName() == "sexaq"){ + } else if (particle->GetParticleName() == "sexaq") { edm::LogInfo("CustomPhysics") << " No pmanager implemented for sexaq, only for anti_sexaq"; } } diff --git a/SimG4Core/CustomPhysics/src/G4AntiSQ.cc b/SimG4Core/CustomPhysics/src/G4AntiSQ.cc index 227f34b862bb3..487f89dfb9154 100644 --- a/SimG4Core/CustomPhysics/src/G4AntiSQ.cc +++ b/SimG4Core/CustomPhysics/src/G4AntiSQ.cc @@ -13,47 +13,36 @@ G4AntiSQ* G4AntiSQ::theInstance = 0; -G4AntiSQ* G4AntiSQ::Definition(double mass) -{ - if (theInstance !=0) return theInstance; +G4AntiSQ* G4AntiSQ::Definition(double mass) { + if (theInstance != 0) + return theInstance; const G4String name = "anti_sexaq"; // search in particle table] G4ParticleTable* pTable = G4ParticleTable::GetParticleTable(); G4ParticleDefinition* anInstance = pTable->FindParticle(name); - if (anInstance ==0) - { - // create particle - // - // Arguments for constructor are as follows - // name mass width charge - // 2*spin parity C-conjugation - // 2*Isospin 2*Isospin3 G-parity - // type lepton number baryon number PDG encoding - // stable lifetime decay table - // shortlived subType anti_encoding - - anInstance = new G4ParticleDefinition( - name, mass, 0, 0.0, - 0, +1, 0, - 0, 0, 0, - "baryon", 0, -2, -1020000020, - true, -1.0, NULL, - false, "sexaq"); - + if (anInstance == 0) { + // create particle + // + // Arguments for constructor are as follows + // name mass width charge + // 2*spin parity C-conjugation + // 2*Isospin 2*Isospin3 G-parity + // type lepton number baryon number PDG encoding + // stable lifetime decay table + // shortlived subType anti_encoding + anInstance = new G4ParticleDefinition( + name, mass, 0, 0.0, 0, +1, 0, 0, 0, 0, "baryon", 0, -2, -1020000020, true, -1.0, NULL, false, "sexaq"); } theInstance = reinterpret_cast(anInstance); return theInstance; } //G4AntiSQ* G4AntiSQ::AntiSQDefinition(double mass) -//{ +//{ // return Definition(mass); //} -G4AntiSQ* G4AntiSQ::AntiSQ(double mass) -{ - return Definition(mass * GeV); // will use correct mass if instance exists +G4AntiSQ* G4AntiSQ::AntiSQ(double mass) { + return Definition(mass * GeV); // will use correct mass if instance exists } - - diff --git a/SimG4Core/CustomPhysics/src/G4SQ.cc b/SimG4Core/CustomPhysics/src/G4SQ.cc index 0fb963364282c..5f5b0f2e99657 100644 --- a/SimG4Core/CustomPhysics/src/G4SQ.cc +++ b/SimG4Core/CustomPhysics/src/G4SQ.cc @@ -13,47 +13,36 @@ G4SQ* G4SQ::theInstance = 0; -G4SQ* G4SQ::Definition(double mass) -{ - if (theInstance !=0) return theInstance; +G4SQ* G4SQ::Definition(double mass) { + if (theInstance != 0) + return theInstance; const G4String name = "sexaq"; // search in particle table] G4ParticleTable* pTable = G4ParticleTable::GetParticleTable(); G4ParticleDefinition* anInstance = pTable->FindParticle(name); - if (anInstance ==0) - { - // create particle - // - // Arguments for constructor are as follows - // name mass width charge - // 2*spin parity C-conjugation - // 2*Isospin 2*Isospin3 G-parity - // type lepton number baryon number PDG encoding - // stable lifetime decay table - // shortlived subType anti_encoding - - anInstance = new G4ParticleDefinition( - name, mass, 0, 0.0, - 0, +1, 0, - 0, 0, 0, - "baryon", 0, +2, 1020000020, - true, -1.0, NULL, - false, "sexaq"); - + if (anInstance == 0) { + // create particle + // + // Arguments for constructor are as follows + // name mass width charge + // 2*spin parity C-conjugation + // 2*Isospin 2*Isospin3 G-parity + // type lepton number baryon number PDG encoding + // stable lifetime decay table + // shortlived subType anti_encoding + anInstance = new G4ParticleDefinition( + name, mass, 0, 0.0, 0, +1, 0, 0, 0, 0, "baryon", 0, +2, 1020000020, true, -1.0, NULL, false, "sexaq"); } theInstance = reinterpret_cast(anInstance); return theInstance; } //G4SQ* G4SQ::SQDefinition(double mass) -//{ +//{ // return Definition(mass); //} -G4SQ* G4SQ::SQ(double mass) -{ - return Definition(mass * GeV); // will use correct mass if instance exists +G4SQ* G4SQ::SQ(double mass) { + return Definition(mass * GeV); // will use correct mass if instance exists } - - diff --git a/SimG4Core/CustomPhysics/src/G4SQInelasticCrossSection.cc b/SimG4Core/CustomPhysics/src/G4SQInelasticCrossSection.cc index f1f22dab3ce9d..1741c0ce2ffdb 100644 --- a/SimG4Core/CustomPhysics/src/G4SQInelasticCrossSection.cc +++ b/SimG4Core/CustomPhysics/src/G4SQInelasticCrossSection.cc @@ -7,43 +7,33 @@ #include "SimG4Core/CustomPhysics/interface/G4AntiSQ.h" #include "SimG4Core/CustomPhysics/interface/G4SQInelasticCrossSection.h" -G4SQInelasticCrossSection::G4SQInelasticCrossSection(double mass) - : G4VCrossSectionDataSet("SQ-neutron") -{ +G4SQInelasticCrossSection::G4SQInelasticCrossSection(double mass) : G4VCrossSectionDataSet("SQ-neutron") { nist = G4NistManager::Instance(); theSQ = G4SQ::SQ(mass); theAntiSQ = G4AntiSQ::AntiSQ(mass); } +G4SQInelasticCrossSection::~G4SQInelasticCrossSection() {} -G4SQInelasticCrossSection::~G4SQInelasticCrossSection() -{} - - -G4bool G4SQInelasticCrossSection::IsElementApplicable( - const G4DynamicParticle* aPart, - G4int Z, const G4Material*) -{ - return ((0 < Z) && - (aPart->GetDefinition() == theSQ || - aPart->GetDefinition() == theAntiSQ) - ); +G4bool G4SQInelasticCrossSection::IsElementApplicable(const G4DynamicParticle* aPart, G4int Z, const G4Material*) { + return ((0 < Z) && (aPart->GetDefinition() == theSQ || aPart->GetDefinition() == theAntiSQ)); } - -G4double G4SQInelasticCrossSection::GetElementCrossSection( - const G4DynamicParticle* aPart, - G4int Z, const G4Material*) -{ +G4double G4SQInelasticCrossSection::GetElementCrossSection(const G4DynamicParticle* aPart, G4int Z, const G4Material*) { // return zero for particle instead of antiparticle // sexaquark interaction with matter expected really tiny - if (aPart->GetDefinition() != theAntiSQ) return 0; + if (aPart->GetDefinition() != theAntiSQ) + return 0; // zero crosssection for particle at rest - if(aPart->GetKineticEnergy() <= 0.0) { return 0.0; } + if (aPart->GetKineticEnergy() <= 0.0) { + return 0.0; + } //I don't want to interact on hydrogen - if(Z <= 1){return 0.0;} + if (Z <= 1) { + return 0.0; + } // get the atomic weight (to estimate nr neutrons) G4double A = nist->GetAtomicMassAmu(Z); @@ -51,6 +41,5 @@ G4double G4SQInelasticCrossSection::GetElementCrossSection( // put the X section low for the antiS to get a flat interaction rate, // but also make it scale with the number of neutrons in the material // because we are going to interact on neutrons, not on protons - return (100.*(A-(G4double)Z)/(G4double)Z)*millibarn; - + return (100. * (A - (G4double)Z) / (G4double)Z) * millibarn; } diff --git a/SimG4Core/CustomPhysics/src/G4SQInelasticProcess.cc b/SimG4Core/CustomPhysics/src/G4SQInelasticProcess.cc index 62bc218335f00..3c3e1c8e152cd 100644 --- a/SimG4Core/CustomPhysics/src/G4SQInelasticProcess.cc +++ b/SimG4Core/CustomPhysics/src/G4SQInelasticProcess.cc @@ -22,79 +22,59 @@ #include "FWCore/MessageLogger/interface/MessageLogger.h" - G4SQInelasticProcess::G4SQInelasticProcess(double mass, const G4String& processName) - : G4HadronicProcess(processName, fHadronic) -{ + : G4HadronicProcess(processName, fHadronic) { AddDataSet(new G4SQInelasticCrossSection(mass)); theParticle = G4SQ::SQ(mass); } +G4SQInelasticProcess::~G4SQInelasticProcess() {} -G4SQInelasticProcess::~G4SQInelasticProcess() -{ -} - - -G4bool G4SQInelasticProcess::IsApplicable(const G4ParticleDefinition& aP) -{ - return theParticle->GetParticleType() == aP.GetParticleType(); +G4bool G4SQInelasticProcess::IsApplicable(const G4ParticleDefinition& aP) { + return theParticle->GetParticleType() == aP.GetParticleType(); } - -G4VParticleChange* -G4SQInelasticProcess::PostStepDoIt(const G4Track& aTrack, const G4Step& aStep) -{ - +G4VParticleChange* G4SQInelasticProcess::PostStepDoIt(const G4Track& aTrack, const G4Step& aStep) { edm::LogInfo("G4SQInelasticProcess::PostStepDoIt") - << "Particle is going to interact at position" << aTrack.GetPosition()/cm - << " momentumdirection eta: " << aTrack.GetMomentumDirection().eta() - << " interacting in material : " << aTrack.GetMaterial() << std::endl; + << "Particle is going to interact at position" << aTrack.GetPosition() / cm + << " momentumdirection eta: " << aTrack.GetMomentumDirection().eta() + << " interacting in material : " << aTrack.GetMaterial() << std::endl; // if primary is not Alive then do nothing theTotalResult->Clear(); theTotalResult->Initialize(aTrack); theTotalResult->ProposeWeight(aTrack.GetWeight()); - if(aTrack.GetTrackStatus() != fAlive) { - edm::LogInfo("G4SQInelasticProcess::PostStepDoIt") - << "No interaction because primary is not alive" << std::endl; + if (aTrack.GetTrackStatus() != fAlive) { + edm::LogInfo("G4SQInelasticProcess::PostStepDoIt") << "No interaction because primary is not alive" << std::endl; return theTotalResult; } + edm::LogInfo("G4SQInelasticProcess::PostStepDoIt") << "Start a possible interaction?" << std::endl; - edm::LogInfo("G4SQInelasticProcess::PostStepDoIt") - << "Start a possible interaction?" << std::endl; - - if(aTrack.GetPosition().rho()/centimeter < 1) { + if (aTrack.GetPosition().rho() / centimeter < 1) { edm::LogInfo("G4SQInelasticProcess::PostStepDoIt") - << "FYI: the rho of the track is < 1cm and it's still going to interact..." << std::endl; + << "FYI: the rho of the track is < 1cm and it's still going to interact..." << std::endl; } // Find cross section at end of step and check if <= 0 // - G4DynamicParticle* aParticle = const_cast(aTrack.GetDynamicParticle()); + G4DynamicParticle* aParticle = const_cast(aTrack.GetDynamicParticle()); G4Material* aMaterial = aTrack.GetMaterial(); const G4Element* anElement = 0; - try - { - anElement = theCrossSectionDataStore->SampleZandA(aParticle, - aMaterial, - targetNucleus); - } - catch(G4HadronicException & aR) - { + try { + anElement = theCrossSectionDataStore->SampleZandA(aParticle, aMaterial, targetNucleus); + } catch (G4HadronicException& aR) { G4ExceptionDescription ed; aR.Report(ed); - DumpState(aTrack,"SampleZandA",ed); + DumpState(aTrack, "SampleZandA", ed); ed << " PostStepDoIt failed on element selection" << G4endl; - G4Exception("G4SQInelasticProcess::PostStepDoIt", "had003", FatalException, - ed); + G4Exception("G4SQInelasticProcess::PostStepDoIt", "had003", FatalException, ed); } // check only for charged particles - if(aParticle->GetDefinition()->GetPDGCharge() != 0.0) { + if (aParticle->GetDefinition()->GetPDGCharge() != 0.0) { if (GetElementCrossSection(aParticle, anElement, aMaterial) <= 0.0) { // No interaction return theTotalResult; @@ -104,14 +84,12 @@ G4SQInelasticProcess::PostStepDoIt(const G4Track& aTrack, const G4Step& aStep) // Next check for illegal track status // if (aTrack.GetTrackStatus() != fAlive && aTrack.GetTrackStatus() != fSuspend) { - if (aTrack.GetTrackStatus() == fStopAndKill || - aTrack.GetTrackStatus() == fKillTrackAndSecondaries || + if (aTrack.GetTrackStatus() == fStopAndKill || aTrack.GetTrackStatus() == fKillTrackAndSecondaries || aTrack.GetTrackStatus() == fPostponeToNextEvent) { G4ExceptionDescription ed; - ed << "G4SQInelasticProcess: track in unusable state - " - << aTrack.GetTrackStatus() << G4endl; + ed << "G4SQInelasticProcess: track in unusable state - " << aTrack.GetTrackStatus() << G4endl; ed << "G4SQInelasticProcess: returning unchanged track " << G4endl; - DumpState(aTrack,"PostStepDoIt",ed); + DumpState(aTrack, "PostStepDoIt", ed); G4Exception("G4SQInelasticProcess::PostStepDoIt", "had004", JustWarning, ed); } // No warning for fStopButAlive which is a legal status here @@ -124,26 +102,21 @@ G4SQInelasticProcess::PostStepDoIt(const G4Track& aTrack, const G4Step& aStep) G4double kineticEnergy = originalEnergy; // Get kinetic energy per nucleon for ions - if(aParticle->GetParticleDefinition()->GetBaryonNumber() > 1.5) - kineticEnergy/=aParticle->GetParticleDefinition()->GetBaryonNumber(); + if (aParticle->GetParticleDefinition()->GetBaryonNumber() > 1.5) + kineticEnergy /= aParticle->GetParticleDefinition()->GetBaryonNumber(); - try - { + try { theInteraction = GetHadronicInteractionList().at(0); -// theInteraction = GetHadronicInteractionList()[0]; -// ChooseHadronicInteraction( kineticEnergy, aMaterial, anElement ); - } - catch(G4HadronicException & aE) - { + // theInteraction = GetHadronicInteractionList()[0]; + // ChooseHadronicInteraction( kineticEnergy, aMaterial, anElement ); + } catch (G4HadronicException& aE) { G4ExceptionDescription ed; aE.Report(ed); - ed << "Target element "<GetName()<<" Z= " - << targetNucleus.GetZ_asInt() << " A= " - << targetNucleus.GetA_asInt() << G4endl; - DumpState(aTrack,"ChooseHadronicInteraction",ed); + ed << "Target element " << anElement->GetName() << " Z= " << targetNucleus.GetZ_asInt() + << " A= " << targetNucleus.GetA_asInt() << G4endl; + DumpState(aTrack, "ChooseHadronicInteraction", ed); ed << " No HadronicInteraction found out" << G4endl; - G4Exception("G4SQInelasticProcess::PostStepDoIt", "had005", FatalException, - ed); + G4Exception("G4SQInelasticProcess::PostStepDoIt", "had005", FatalException, ed); } // Initialize the hadronic projectile from the track @@ -152,69 +125,53 @@ G4SQInelasticProcess::PostStepDoIt(const G4Track& aTrack, const G4Step& aStep) G4HadFinalState* result = 0; G4int reentryCount = 0; - - do - { - try - { + do { + try { // Call the interaction - result = theInteraction->ApplyYourself( thePro, targetNucleus); + result = theInteraction->ApplyYourself(thePro, targetNucleus); ++reentryCount; - } - catch(G4HadronicException & aR) - { + } catch (G4HadronicException& aR) { G4ExceptionDescription ed; aR.Report(ed); ed << "Call for " << theInteraction->GetModelName() << G4endl; - ed << "Target element "<GetName()<<" Z= " - << targetNucleus.GetZ_asInt() - << " A= " << targetNucleus.GetA_asInt() << G4endl; - DumpState(aTrack,"ApplyYourself",ed); + ed << "Target element " << anElement->GetName() << " Z= " << targetNucleus.GetZ_asInt() + << " A= " << targetNucleus.GetA_asInt() << G4endl; + DumpState(aTrack, "ApplyYourself", ed); ed << " ApplyYourself failed" << G4endl; - G4Exception("G4SQInelasticProcess::PostStepDoIt", "had006", FatalException, - ed); + G4Exception("G4SQInelasticProcess::PostStepDoIt", "had006", FatalException, ed); } - - edm::LogInfo("G4SQInelasticProcess::PostStepDoIt") - << "Call for " << theInteraction->GetModelName() - << std::endl; + edm::LogInfo("G4SQInelasticProcess::PostStepDoIt") << "Call for " << theInteraction->GetModelName() << std::endl; edm::LogInfo("G4SQInelasticProcess::PostStepDoIt") - << "Target element "<< anElement->GetName() - << " Z=" << targetNucleus.GetZ_asInt() - << " A=" << targetNucleus.GetA_asInt() - << std::endl; + << "Target element " << anElement->GetName() << " Z=" << targetNucleus.GetZ_asInt() + << " A=" << targetNucleus.GetA_asInt() << std::endl; edm::LogInfo("G4SQInelasticProcess::PostStepDoIt") - << "Nr of secondaries: " << result->GetNumberOfSecondaries() << std::endl - << "Momentum change and E deeposit: " << result->GetMomentumChange() << " " << result->GetLocalEnergyDeposit() << std::endl - << "Track position and vertex: " << aTrack.GetPosition() << " " << aTrack.GetVertexPosition() << std::endl; + << "Nr of secondaries: " << result->GetNumberOfSecondaries() << std::endl + << "Momentum change and E deeposit: " << result->GetMomentumChange() << " " << result->GetLocalEnergyDeposit() + << std::endl + << "Track position and vertex: " << aTrack.GetPosition() << " " << aTrack.GetVertexPosition() << std::endl; float r = aTrack.GetPosition().perp(); float z = fabs(aTrack.GetPosition().z()); edm::LogInfo("G4SQInelasticProcess::PostStepDoIt") - << "In tracker volume? " - << (r<(100*cm) && z<(200*cm)? " YES! " : " NO! ") - << "r=" << r/cm << " z=" << z/cm << std::endl; + << "In tracker volume? " << (r < (100 * cm) && z < (200 * cm) ? " YES! " : " NO! ") << "r=" << r / cm + << " z=" << z / cm << std::endl; // Check the result for catastrophic energy non-conservation - result = CheckResult(thePro,targetNucleus, result); - if(reentryCount>100) { + result = CheckResult(thePro, targetNucleus, result); + if (reentryCount > 100) { G4ExceptionDescription ed; ed << "Call for " << theInteraction->GetModelName() << G4endl; - ed << "Target element "<GetName()<<" Z= " - << targetNucleus.GetZ_asInt() - << " A= " << targetNucleus.GetA_asInt() << G4endl; - DumpState(aTrack,"ApplyYourself",ed); + ed << "Target element " << anElement->GetName() << " Z= " << targetNucleus.GetZ_asInt() + << " A= " << targetNucleus.GetA_asInt() << G4endl; + DumpState(aTrack, "ApplyYourself", ed); ed << " ApplyYourself does not completed after 100 attempts" << G4endl; - G4Exception("G4SQInelasticProcess::PostStepDoIt", "had006", FatalException, - ed); + G4Exception("G4SQInelasticProcess::PostStepDoIt", "had006", FatalException, ed); } - } - while(!result); + } while (!result); - edm::LogInfo("G4SQInelasticProcess::PostStepDoIt") - << "=== Anti-sexaquark interaction succeeded!" << std::endl; + edm::LogInfo("G4SQInelasticProcess::PostStepDoIt") << "=== Anti-sexaquark interaction succeeded!" << std::endl; result->SetTrafoToLab(thePro.GetTrafoToLab()); ClearNumberOfInteractionLengthLeft(); @@ -227,67 +184,58 @@ G4SQInelasticProcess::PostStepDoIt(const G4Track& aTrack, const G4Step& aStep) return theTotalResult; } +G4HadFinalState* G4SQInelasticProcess::CheckResult(const G4HadProjectile& aPro, + const G4Nucleus& aNucleus, + G4HadFinalState* result) { + // check for catastrophic energy non-conservation, to re-sample the interaction -G4HadFinalState* G4SQInelasticProcess::CheckResult(const G4HadProjectile & aPro,const G4Nucleus &aNucleus, G4HadFinalState * result) -{ - // check for catastrophic energy non-conservation, to re-sample the interaction - - G4HadronicInteraction * theModel = GetHadronicInteractionList()[0]; - - edm::LogInfo("G4SQInelasticProcess::PostStepDoIt") - << "checkresult - " << theModel << std::endl; - - G4double nuclearMass(0); - if (theModel){ - - // Compute final-state total energy - G4double finalE(0.); - G4int nSec = result->GetNumberOfSecondaries(); - - nuclearMass = G4NucleiProperties::GetNuclearMass(aNucleus.GetA_asInt(), - aNucleus.GetZ_asInt()); - if (result->GetStatusChange() != stopAndKill) { - // Interaction didn't complete, returned "do nothing" state => reset nucleus - // or the primary survived the interaction (e.g. electro-nuclear ) => keep nucleus - finalE=result->GetLocalEnergyDeposit() + - aPro.GetDefinition()->GetPDGMass() + result->GetEnergyChange(); - edm::LogInfo("G4SQInelasticProcess::PostStepDoIt") - << "checkresult - interaction not complete: " << finalE << std::endl; - if( nSec == 0 ){ - // Since there are no secondaries, there is no recoil nucleus. - // To check energy balance we must neglect the initial nucleus too. - nuclearMass=0.0; - } - } - for (G4int i = 0; i < nSec; i++) { - finalE += result->GetSecondary(i)->GetParticle()->GetTotalEnergy(); - edm::LogInfo("G4SQInelasticProcess::PostStepDoIt") - << "checkresult - secondary pdgId / E : " - << result->GetSecondary(i)->GetParticle()->GetPDGcode() << "\t" - << result->GetSecondary(i)->GetParticle()->GetTotalEnergy() / GeV - << std::endl; - } - G4double deltaE = nuclearMass + aPro.GetTotalEnergy() - finalE; - edm::LogInfo("G4SQInelasticProcess::PostStepDoIt") - << "checkresult - Total E: " << finalE / GeV << std::endl; + G4HadronicInteraction* theModel = GetHadronicInteractionList()[0]; + + edm::LogInfo("G4SQInelasticProcess::PostStepDoIt") << "checkresult - " << theModel << std::endl; + + G4double nuclearMass(0); + if (theModel) { + // Compute final-state total energy + G4double finalE(0.); + G4int nSec = result->GetNumberOfSecondaries(); + + nuclearMass = G4NucleiProperties::GetNuclearMass(aNucleus.GetA_asInt(), aNucleus.GetZ_asInt()); + if (result->GetStatusChange() != stopAndKill) { + // Interaction didn't complete, returned "do nothing" state => reset nucleus + // or the primary survived the interaction (e.g. electro-nuclear ) => keep nucleus + finalE = result->GetLocalEnergyDeposit() + aPro.GetDefinition()->GetPDGMass() + result->GetEnergyChange(); edm::LogInfo("G4SQInelasticProcess::PostStepDoIt") - << "checkresult - Energy balance: " << deltaE / GeV << std::endl; - - std::pair checkLevels = theModel->GetFatalEnergyCheckLevels(); // (relative, absolute) - if (std::abs(deltaE) > checkLevels.second && std::abs(deltaE) > checkLevels.first*aPro.GetKineticEnergy()){ - // do not delete result, this is a pointer to a data member; - G4ExceptionDescription desc; - desc << "Warning: Bad energy non-conservation detected, will " - << (epReportLevel<0 ? "abort the event" : "re-sample the interaction") << G4endl - << " Process / Model: " << GetProcessName()<< " / " << theModel->GetModelName() << G4endl - << " Primary: " << aPro.GetDefinition()->GetParticleName() - << " (" << aPro.GetDefinition()->GetPDGEncoding() << ")," - << " E= " << aPro.Get4Momentum().e() - << ", target nucleus (" << aNucleus.GetZ_asInt() << ","<< aNucleus.GetA_asInt() << ")" << G4endl - << " E(initial - final) = " << deltaE << " MeV." << G4endl; - G4Exception("G4SQInelasticProcess:CheckResult()", "had012", epReportLevel<0 ? EventMustBeAborted : JustWarning,desc); + << "checkresult - interaction not complete: " << finalE << std::endl; + if (nSec == 0) { + // Since there are no secondaries, there is no recoil nucleus. + // To check energy balance we must neglect the initial nucleus too. + nuclearMass = 0.0; } - } - return result; + } + for (G4int i = 0; i < nSec; i++) { + finalE += result->GetSecondary(i)->GetParticle()->GetTotalEnergy(); + edm::LogInfo("G4SQInelasticProcess::PostStepDoIt") + << "checkresult - secondary pdgId / E : " << result->GetSecondary(i)->GetParticle()->GetPDGcode() << "\t" + << result->GetSecondary(i)->GetParticle()->GetTotalEnergy() / GeV << std::endl; + } + G4double deltaE = nuclearMass + aPro.GetTotalEnergy() - finalE; + edm::LogInfo("G4SQInelasticProcess::PostStepDoIt") << "checkresult - Total E: " << finalE / GeV << std::endl; + edm::LogInfo("G4SQInelasticProcess::PostStepDoIt") << "checkresult - Energy balance: " << deltaE / GeV << std::endl; + + std::pair checkLevels = theModel->GetFatalEnergyCheckLevels(); // (relative, absolute) + if (std::abs(deltaE) > checkLevels.second && std::abs(deltaE) > checkLevels.first * aPro.GetKineticEnergy()) { + // do not delete result, this is a pointer to a data member; + G4ExceptionDescription desc; + desc << "Warning: Bad energy non-conservation detected, will " + << (epReportLevel < 0 ? "abort the event" : "re-sample the interaction") << G4endl + << " Process / Model: " << GetProcessName() << " / " << theModel->GetModelName() << G4endl + << " Primary: " << aPro.GetDefinition()->GetParticleName() << " (" << aPro.GetDefinition()->GetPDGEncoding() + << ")," + << " E= " << aPro.Get4Momentum().e() << ", target nucleus (" << aNucleus.GetZ_asInt() << "," + << aNucleus.GetA_asInt() << ")" << G4endl << " E(initial - final) = " << deltaE << " MeV." << G4endl; + G4Exception( + "G4SQInelasticProcess:CheckResult()", "had012", epReportLevel < 0 ? EventMustBeAborted : JustWarning, desc); + } + } + return result; } - diff --git a/SimG4Core/CustomPhysics/src/G4SQLoopProcess.cc b/SimG4Core/CustomPhysics/src/G4SQLoopProcess.cc index 6faee989be02f..3e9f81c26643c 100644 --- a/SimG4Core/CustomPhysics/src/G4SQLoopProcess.cc +++ b/SimG4Core/CustomPhysics/src/G4SQLoopProcess.cc @@ -7,58 +7,43 @@ #include "FWCore/MessageLogger/interface/MessageLogger.h" - - - -G4SQLoopProcess::G4SQLoopProcess(const G4String& name, G4ProcessType type) - : G4VContinuousProcess(name, type) -{ +G4SQLoopProcess::G4SQLoopProcess(const G4String& name, G4ProcessType type) : G4VContinuousProcess(name, type) { fParticleChange = new G4ParticleChange(); } +G4SQLoopProcess::~G4SQLoopProcess() { delete fParticleChange; } -G4SQLoopProcess::~G4SQLoopProcess() -{ - delete fParticleChange; -} - - -G4VParticleChange* G4SQLoopProcess::AlongStepDoIt(const G4Track& track, const G4Step& step) -{ - - if(track.GetPosition()==posini) +G4VParticleChange* G4SQLoopProcess::AlongStepDoIt(const G4Track& track, const G4Step& step) { + if (track.GetPosition() == posini) edm::LogInfo("G4SQLoopProcess::AlongStepDoIt") - << "G4SQLoopProcess::AlongStepDoIt: G4SQLoopProcess::AlongStepDoIt MomentumDirection " << track.GetMomentumDirection().eta() << " track GetPostion " << track.GetPosition()/cm << " trackId " << track.GetTrackID() << " parentId: " << track.GetParentID() << " GlobalTime " << track.GetGlobalTime()/ns << " TotalEnergy: " << track.GetTotalEnergy()/GeV << " Velocity " << track.GetVelocity()/m/ns << std::endl; + << "G4SQLoopProcess::AlongStepDoIt: G4SQLoopProcess::AlongStepDoIt MomentumDirection " + << track.GetMomentumDirection().eta() << " track GetPostion " << track.GetPosition() / cm << " trackId " + << track.GetTrackID() << " parentId: " << track.GetParentID() << " GlobalTime " << track.GetGlobalTime() / ns + << " TotalEnergy: " << track.GetTotalEnergy() / GeV << " Velocity " << track.GetVelocity() / m / ns + << std::endl; fParticleChange->Clear(); fParticleChange->Initialize(track); fParticleChange->ProposeWeight(track.GetWeight()); //Sbar not passing the following criteria are not of interest. They will not be reconstructable. A cut like this is required otherwise you will get Sbar infinitely looping. - if(fabs(track.GetMomentumDirection().eta())>999. || fabs(track.GetPosition().z()) > 160*centimeter){ - edm::LogInfo("G4SQLoopProcess::AlongStepDoIt") - << "Particle getting killed because too large z"<< std::endl; + if (fabs(track.GetMomentumDirection().eta()) > 999. || fabs(track.GetPosition().z()) > 160 * centimeter) { + edm::LogInfo("G4SQLoopProcess::AlongStepDoIt") << "Particle getting killed because too large z" << std::endl; fParticleChange->ProposeTrackStatus(fStopAndKill); } return fParticleChange; } - -G4double G4SQLoopProcess::AlongStepGetPhysicalInteractionLength(const G4Track& track, G4double previousStepSize, G4double currentMinimumStep, G4double& proposedSafety, G4GPILSelection* selection) -{ - return 1.*centimeter; +G4double G4SQLoopProcess::AlongStepGetPhysicalInteractionLength(const G4Track& track, + G4double previousStepSize, + G4double currentMinimumStep, + G4double& proposedSafety, + G4GPILSelection* selection) { + return 1. * centimeter; } - -G4double G4SQLoopProcess::GetContinuousStepLimit(const G4Track& track, G4double , G4double , G4double& ) -{ - return 1.*centimeter; // seems irrelevant +G4double G4SQLoopProcess::GetContinuousStepLimit(const G4Track& track, G4double, G4double, G4double&) { + return 1. * centimeter; // seems irrelevant } - -void G4SQLoopProcess::StartTracking(G4Track * aTrack) -{ - posini = aTrack->GetPosition(); -} - - +void G4SQLoopProcess::StartTracking(G4Track* aTrack) { posini = aTrack->GetPosition(); } diff --git a/SimG4Core/CustomPhysics/src/G4SQLoopProcessDiscr.cc b/SimG4Core/CustomPhysics/src/G4SQLoopProcessDiscr.cc index 85d51fac962f1..9e8b2fadc9714 100644 --- a/SimG4Core/CustomPhysics/src/G4SQLoopProcessDiscr.cc +++ b/SimG4Core/CustomPhysics/src/G4SQLoopProcessDiscr.cc @@ -7,38 +7,30 @@ #include "FWCore/MessageLogger/interface/MessageLogger.h" - G4SQLoopProcessDiscr::G4SQLoopProcessDiscr(double mass, const G4String& name, G4ProcessType type) - : G4VDiscreteProcess(name, type) -{ + : G4VDiscreteProcess(name, type) { fParticleChange = new G4ParticleChange(); fParticleChange->ClearDebugFlag(); GenMass = mass; } +G4SQLoopProcessDiscr::~G4SQLoopProcessDiscr() { delete fParticleChange; } -G4SQLoopProcessDiscr::~G4SQLoopProcessDiscr() -{ - delete fParticleChange; -} - - -G4VParticleChange* G4SQLoopProcessDiscr::PostStepDoIt(const G4Track& track, const G4Step& step) -{ - - G4Track * mytr = const_cast(&track); - mytr->SetPosition(posini); - if(mytr->GetGlobalTime()/ns>4990) +G4VParticleChange* G4SQLoopProcessDiscr::PostStepDoIt(const G4Track& track, const G4Step& step) { + G4Track* mytr = const_cast(&track); + mytr->SetPosition(posini); + if (mytr->GetGlobalTime() / ns > 4990) edm::LogWarning("G4SQLoopProcess::AlongStepDoIt") - << "going to loose the particle because the GlobalTime is getting close to 5000" << std::endl; + << "going to loose the particle because the GlobalTime is getting close to 5000" << std::endl; fParticleChange->Clear(); fParticleChange->Initialize(track); //adding secondary antiS - fParticleChange->SetNumberOfSecondaries(1); - G4DynamicParticle* replacementParticle= new G4DynamicParticle(G4AntiSQ::AntiSQ(GenMass), track.GetMomentumDirection(), track.GetKineticEnergy()); - fParticleChange->AddSecondary(replacementParticle,globaltimeini); + fParticleChange->SetNumberOfSecondaries(1); + G4DynamicParticle* replacementParticle = + new G4DynamicParticle(G4AntiSQ::AntiSQ(GenMass), track.GetMomentumDirection(), track.GetKineticEnergy()); + fParticleChange->AddSecondary(replacementParticle, globaltimeini); //killing original AntiS fParticleChange->ProposeTrackStatus(fStopAndKill); @@ -54,29 +46,25 @@ G4VParticleChange* G4SQLoopProcessDiscr::PostStepDoIt(const G4Track& track, cons return fParticleChange; } - -G4double G4SQLoopProcessDiscr::PostStepGetPhysicalInteractionLength(const G4Track& track, G4double previousStepSize, G4ForceCondition* condition) -{ - *condition = NotForced; - G4double intLength = DBL_MAX; //by default the interaction length is super large, only when outside tracker make it 0 to be sure it will do the reset to the original position - G4Track * mytr = const_cast(&track); - if(sqrt(pow(mytr->GetPosition().rho(),2))>2.45*centimeter){//this is an important cut for the looping: if the radius of the particle is largher than 2.45cm its interaction length becomes 0 which means it will get killed -// updated from 2.5 to 2.45 so that the Sbar does not start to hit the support of the new inner tracker which was added in 2018 - intLength = 0.0;//0 interaction length means particle will directly interact. - } +G4double G4SQLoopProcessDiscr::PostStepGetPhysicalInteractionLength(const G4Track& track, + G4double previousStepSize, + G4ForceCondition* condition) { + *condition = NotForced; + G4double intLength = + DBL_MAX; //by default the interaction length is super large, only when outside tracker make it 0 to be sure it will do the reset to the original position + G4Track* mytr = const_cast(&track); + if (sqrt(pow(mytr->GetPosition().rho(), 2)) > + 2.45 * + centimeter) { //this is an important cut for the looping: if the radius of the particle is largher than 2.45cm its interaction length becomes 0 which means it will get killed + // updated from 2.5 to 2.45 so that the Sbar does not start to hit the support of the new inner tracker which was added in 2018 + intLength = 0.0; //0 interaction length means particle will directly interact. + } return intLength; } -G4double G4SQLoopProcessDiscr::GetMeanFreePath(const G4Track&,G4double, - G4ForceCondition*) -{ - return DBL_MAX; -} +G4double G4SQLoopProcessDiscr::GetMeanFreePath(const G4Track&, G4double, G4ForceCondition*) { return DBL_MAX; } - -void G4SQLoopProcessDiscr::StartTracking(G4Track * aTrack) -{ +void G4SQLoopProcessDiscr::StartTracking(G4Track* aTrack) { posini = aTrack->GetPosition(); globaltimeini = aTrack->GetGlobalTime(); - } diff --git a/SimG4Core/CustomPhysics/src/G4SQNeutronAnnih.cc b/SimG4Core/CustomPhysics/src/G4SQNeutronAnnih.cc index 6ed99739e5148..2daa6ae26e722 100644 --- a/SimG4Core/CustomPhysics/src/G4SQNeutronAnnih.cc +++ b/SimG4Core/CustomPhysics/src/G4SQNeutronAnnih.cc @@ -11,271 +11,208 @@ #include "SimG4Core/CustomPhysics/interface/G4SQNeutronAnnih.h" #include "SimG4Core/CustomPhysics/interface/G4SQ.h" +G4SQNeutronAnnih::G4SQNeutronAnnih(double mass) : G4HadronicInteraction("SexaQuark-neutron annihilation") { + SetMinEnergy(0.0 * GeV); + SetMaxEnergy(100. * TeV); -G4SQNeutronAnnih::G4SQNeutronAnnih(double mass) : G4HadronicInteraction("SexaQuark-neutron annihilation") -{ - SetMinEnergy( 0.0*GeV ); - SetMaxEnergy( 100.*TeV ); - - theSQ = G4SQ::SQ(mass); - theK0S = G4KaonZeroShort::KaonZeroShort(); + theSQ = G4SQ::SQ(mass); + theK0S = G4KaonZeroShort::KaonZeroShort(); theAntiL = G4AntiLambda::AntiLambda(); - theProton = G4Proton::Proton();//proton only used when the particle which the sexaquark hits is a deutereon and the neutron dissapears, so what stays behind is a proton + theProton = G4Proton:: + Proton(); //proton only used when the particle which the sexaquark hits is a deutereon and the neutron dissapears, so what stays behind is a proton } - -G4SQNeutronAnnih::~G4SQNeutronAnnih() -{} - - +G4SQNeutronAnnih::~G4SQNeutronAnnih() {} //9Be momentum distribution from Jan Ryckebusch -G4double G4SQNeutronAnnih::momDistr(G4double x_in){ - -const int n_entries = 50; - -G4double CDF_k[n_entries] = { -0, -0.1, -0.2, -0.3, -0.4, -0.5, -0.6, -0.7, -0.8, -0.9, -1, -1.1, -1.2, -1.3, -1.4, -1.5, -1.6, -1.7, -1.8, -1.9, -2, -2.1, -2.2, -2.3, -2.4, -2.5, -2.6, -2.7, -2.8, -2.9, -3, -3.1, -3.2, -3.3, -3.4, -3.5, -3.6, -3.7, -3.8, -3.9, -4., -4.1, -4.2, -4.3, -4.4, -4.5, -4.6, -4.7, -4.8, -4.9 -}; - -G4double x[n_entries] = { -0, -0.0038033182, -0.0187291764, -0.0510409777, -0.1048223609, -0.1807862863, -0.2756514534, -0.3825832103, -0.4926859745, -0.5970673837, -0.6887542272, -0.7637748784, -0.8212490273, -0.8627259608, -0.8911605331, -0.9099115186, -0.9220525854, -0.9300190818, -0.9355376091, -0.9397242185, -0.9432387722, -0.946438928, -0.9495023924, -0.9525032995, -0.9554669848, -0.9583936672, -0.9612770117, -0.9641067202, -0.9668727859, -0.9695676121, -0.9721815799, -0.9747092981, -0.9771426396, -0.9794740235, -0.9816956807, -0.9838003583, -0.9857816165, -0.9876331761, -0.9893513365, -0.9909333198, -0.992378513, -0.9936885054, -0.9948665964, -0.9959179448, -0.9968491104, -0.9976680755, -0.9983832508, -0.9990041784, -0.9995400073, -1 -}; +G4double G4SQNeutronAnnih::momDistr(G4double x_in) { + const int n_entries = 50; + + G4double CDF_k[n_entries] = {0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, + 1.7, 1.8, 1.9, 2, 2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, 2.8, 2.9, 3, 3.1, 3.2, 3.3, + 3.4, 3.5, 3.6, 3.7, 3.8, 3.9, 4., 4.1, 4.2, 4.3, 4.4, 4.5, 4.6, 4.7, 4.8, 4.9}; + + G4double x[n_entries] = {0, + 0.0038033182, + 0.0187291764, + 0.0510409777, + 0.1048223609, + 0.1807862863, + 0.2756514534, + 0.3825832103, + 0.4926859745, + 0.5970673837, + 0.6887542272, + 0.7637748784, + 0.8212490273, + 0.8627259608, + 0.8911605331, + 0.9099115186, + 0.9220525854, + 0.9300190818, + 0.9355376091, + 0.9397242185, + 0.9432387722, + 0.946438928, + 0.9495023924, + 0.9525032995, + 0.9554669848, + 0.9583936672, + 0.9612770117, + 0.9641067202, + 0.9668727859, + 0.9695676121, + 0.9721815799, + 0.9747092981, + 0.9771426396, + 0.9794740235, + 0.9816956807, + 0.9838003583, + 0.9857816165, + 0.9876331761, + 0.9893513365, + 0.9909333198, + 0.992378513, + 0.9936885054, + 0.9948665964, + 0.9959179448, + 0.9968491104, + 0.9976680755, + 0.9983832508, + 0.9990041784, + 0.9995400073, + 1}; //now interpolate the above points for x_in G4double result = 9999; - for(int i = 0; i < n_entries; i++){ - if(x[i] > x_in) { - result = (CDF_k[i]-CDF_k[i-1])/(x[i]-x[i-1])*(x_in-x[i-1])+CDF_k[i-1]; - break; + for (int i = 0; i < n_entries; i++) { + if (x[i] > x_in) { + result = (CDF_k[i] - CDF_k[i - 1]) / (x[i] - x[i - 1]) * (x_in - x[i - 1]) + CDF_k[i - 1]; + break; } - } + } //ROOT::Math::Interpolator inter(n_entries, ROOT::Math::Interpolation::kAKIMA); //inter.SetData(n_entries,x,CDF_k); //result = inter.Eval(x_in); return result; //return 1; - } - - - - -G4HadFinalState* G4SQNeutronAnnih::ApplyYourself( - const G4HadProjectile& aTrack, G4Nucleus& targetNucleus) -{ +G4HadFinalState* G4SQNeutronAnnih::ApplyYourself(const G4HadProjectile& aTrack, G4Nucleus& targetNucleus) { theParticleChange.Clear(); const G4HadProjectile* aParticle = &aTrack; G4double ekin = aParticle->GetKineticEnergy(); - G4int A = targetNucleus.GetA_asInt(); G4int Z = targetNucleus.GetZ_asInt(); - G4double m_K0S = G4KaonZeroShort::KaonZeroShort()->GetPDGMass(); - G4double m_L = G4AntiLambda::AntiLambda()->GetPDGMass(); + G4double m_L = G4AntiLambda::AntiLambda()->GetPDGMass(); - G4cout << "----> G4SQNeutronAnnih <-----" << G4endl; + G4cout << "----> G4SQNeutronAnnih <-----" << G4endl; //G4double plab = aParticle->GetTotalMomentum(); -// G4cout << "G4SQNeutronAnnih: Incident particle p (GeV), total Energy (GeV), particle name, eta =" -// << plab/GeV << " " -// << aParticle->GetTotalEnergy()/GeV << " " -// << aParticle->GetDefinition()->GetParticleName() << " " -// << aParticle->Get4Momentum() << G4endl; + // G4cout << "G4SQNeutronAnnih: Incident particle p (GeV), total Energy (GeV), particle name, eta =" + // << plab/GeV << " " + // << aParticle->GetTotalEnergy()/GeV << " " + // << aParticle->GetDefinition()->GetParticleName() << " " + // << aParticle->Get4Momentum() << G4endl; // Scattered particle referred to axis of incident particle //const G4ParticleDefinition* theParticle = aParticle->GetDefinition(); //G4int projPDG = theParticle->GetPDGEncoding(); -// if (verboseLevel > 1) -// G4cout << "G4SQNeutronAnnih: for " << theParticle->GetParticleName() -// << " PDGcode= " << projPDG << " on nucleus Z= " << Z -// << " A= " << A << " N= " << N -// << G4endl; + // if (verboseLevel > 1) + // G4cout << "G4SQNeutronAnnih: for " << theParticle->GetParticleName() + // << " PDGcode= " << projPDG << " on nucleus Z= " << Z + // << " A= " << A << " N= " << N + // << G4endl; G4LorentzVector lv1 = aParticle->Get4Momentum(); - G4cout << "The neutron Fermi momentum (mag, x, y, z) " << targetNucleus.GetFermiMomentum().mag()/MeV << " " << targetNucleus.GetFermiMomentum().x()/MeV << " " << targetNucleus.GetFermiMomentum().y()/MeV << " " << targetNucleus.GetFermiMomentum().z()/MeV << std::endl; + G4cout << "The neutron Fermi momentum (mag, x, y, z) " << targetNucleus.GetFermiMomentum().mag() / MeV << " " + << targetNucleus.GetFermiMomentum().x() / MeV << " " << targetNucleus.GetFermiMomentum().y() / MeV << " " + << targetNucleus.GetFermiMomentum().z() / MeV << std::endl; //calculate fermi momentum - G4double k_neutron = momDistr(G4UniformRand()); - G4double momentum_neutron = 0.1973*GeV*k_neutron; - - G4double theta_neutron = TMath::ACos(2*G4UniformRand()-1); - G4double phi_neutron = 2.*TMath::Pi()*G4UniformRand(); + G4double k_neutron = momDistr(G4UniformRand()); + G4double momentum_neutron = 0.1973 * GeV * k_neutron; - G4double p_neutron_x = momentum_neutron*TMath::Sin(theta_neutron)*TMath::Cos(phi_neutron); - G4double p_neutron_y = momentum_neutron*TMath::Sin(theta_neutron)*TMath::Sin(phi_neutron); - G4double p_neutron_z = momentum_neutron*TMath::Cos(theta_neutron); + G4double theta_neutron = TMath::ACos(2 * G4UniformRand() - 1); + G4double phi_neutron = 2. * TMath::Pi() * G4UniformRand(); + G4double p_neutron_x = momentum_neutron * TMath::Sin(theta_neutron) * TMath::Cos(phi_neutron); + G4double p_neutron_y = momentum_neutron * TMath::Sin(theta_neutron) * TMath::Sin(phi_neutron); + G4double p_neutron_z = momentum_neutron * TMath::Cos(theta_neutron); //G4LorentzVector lv0(targetNucleus.GetFermiMomentum(), sqrt( pow(G4Neutron::Neutron()->GetPDGMass(),2) + targetNucleus.GetFermiMomentum().mag2() ) ); - G4LorentzVector lv0(p_neutron_x, p_neutron_y, p_neutron_z, sqrt( pow(G4Neutron::Neutron()->GetPDGMass(),2) + momentum_neutron*momentum_neutron ) ); + G4LorentzVector lv0(p_neutron_x, + p_neutron_y, + p_neutron_z, + sqrt(pow(G4Neutron::Neutron()->GetPDGMass(), 2) + momentum_neutron * momentum_neutron)); //const G4Nucleus* aNucleus = &targetNucleus; G4double BENeutronInNucleus = 0; - if(A != 0)BENeutronInNucleus = G4NucleiProperties::GetBindingEnergy( A, Z)/(A); + if (A != 0) + BENeutronInNucleus = G4NucleiProperties::GetBindingEnergy(A, Z) / (A); - G4cout << "BE of nucleon in the nucleus (GeV): " << BENeutronInNucleus/GeV << G4endl; + G4cout << "BE of nucleon in the nucleus (GeV): " << BENeutronInNucleus / GeV << G4endl; - G4LorentzVector lvBE(0,0,0,BENeutronInNucleus/GeV); - G4LorentzVector lv = lv0 + lv1 - lvBE; + G4LorentzVector lvBE(0, 0, 0, BENeutronInNucleus / GeV); + G4LorentzVector lv = lv0 + lv1 - lvBE; // kinematiacally impossible ? G4double etot = lv0.e() + lv1.e() - lvBE.e(); - if(etot < theK0S->GetPDGMass() + theAntiL->GetPDGMass()) { + if (etot < theK0S->GetPDGMass() + theAntiL->GetPDGMass()) { theParticleChange.SetEnergyChange(ekin); theParticleChange.SetMomentumChange(aTrack.Get4Momentum().vect().unit()); return &theParticleChange; } - float newIonMass = targetNucleus.AtomicMass(A-1,Z)*931.5*MeV; ; - G4LorentzVector nlvIon(0,0,0,newIonMass); + float newIonMass = targetNucleus.AtomicMass(A - 1, Z) * 931.5 * MeV; + ; + G4LorentzVector nlvIon(0, 0, 0, newIonMass); - G4double theta_KS0_star = TMath::ACos(2*G4UniformRand()-1); - G4double phi_KS0_star = 2.*TMath::Pi()*G4UniformRand(); + G4double theta_KS0_star = TMath::ACos(2 * G4UniformRand() - 1); + G4double phi_KS0_star = 2. * TMath::Pi() * G4UniformRand(); - G4double p_K0S_star_x = TMath::Sin(theta_KS0_star)*TMath::Cos(phi_KS0_star); - G4double p_K0S_star_y = TMath::Sin(theta_KS0_star)*TMath::Sin(phi_KS0_star); + G4double p_K0S_star_x = TMath::Sin(theta_KS0_star) * TMath::Cos(phi_KS0_star); + G4double p_K0S_star_y = TMath::Sin(theta_KS0_star) * TMath::Sin(phi_KS0_star); G4double p_K0S_star_z = TMath::Cos(theta_KS0_star); - G4ThreeVector p(p_K0S_star_x,p_K0S_star_y,p_K0S_star_z); + G4ThreeVector p(p_K0S_star_x, p_K0S_star_y, p_K0S_star_z); double m0 = lv.m(); - double m0_2 = m0*m0; - double m1_2 = m_K0S*m_K0S; - double m2_2 = m_L*m_L; + double m0_2 = m0 * m0; + double m1_2 = m_K0S * m_K0S; + double m2_2 = m_L * m_L; - p *= 0.5/m0 * sqrt ( m0_2*m0_2 + m1_2*m1_2 + m2_2*m2_2 - 2*m0_2*m1_2 - 2*m0_2*m2_2 - 2*m1_2*m2_2); + p *= 0.5 / m0 * sqrt(m0_2 * m0_2 + m1_2 * m1_2 + m2_2 * m2_2 - 2 * m0_2 * m1_2 - 2 * m0_2 * m2_2 - 2 * m1_2 * m2_2); double p2 = p.mag2(); - G4LorentzVector nlvK0S( p, sqrt (p2 + m1_2)); - G4LorentzVector nlvAntiL(-p, sqrt (p2 + m2_2)); + G4LorentzVector nlvK0S(p, sqrt(p2 + m1_2)); + G4LorentzVector nlvAntiL(-p, sqrt(p2 + m2_2)); // Boost out of the rest frame. - nlvK0S.boost (lv.boostVector ()); - nlvAntiL.boost (lv.boostVector ()); + nlvK0S.boost(lv.boostVector()); + nlvAntiL.boost(lv.boostVector()); // now move to implement the interaction theParticleChange.SetStatusChange(stopAndKill); //theParticleChange.SetEnergyChange(ekin); // was 0.0 - - - G4DynamicParticle * aSec1 = new G4DynamicParticle(theK0S, nlvK0S); + G4DynamicParticle* aSec1 = new G4DynamicParticle(theK0S, nlvK0S); theParticleChange.AddSecondary(aSec1); - G4DynamicParticle * aSec2 = new G4DynamicParticle(theAntiL, nlvAntiL); + G4DynamicParticle* aSec2 = new G4DynamicParticle(theAntiL, nlvAntiL); theParticleChange.AddSecondary(aSec2); const G4ParticleDefinition* theRemainingNucleusDef = theProton; - if(A != 1) theRemainingNucleusDef = G4IonTable::GetIonTable()->GetIon(Z,A-1); - G4DynamicParticle * aSec3 = new G4DynamicParticle(theRemainingNucleusDef, nlvIon); + if (A != 1) + theRemainingNucleusDef = G4IonTable::GetIonTable()->GetIon(Z, A - 1); + G4DynamicParticle* aSec3 = new G4DynamicParticle(theRemainingNucleusDef, nlvIon); theParticleChange.AddSecondary(aSec3); // return as is; we don't care about what happens to the nucleus return &theParticleChange; - } - From e8ae2ea8f708be19a317f4ce8872dba27601714f Mon Sep 17 00:00:00 2001 From: Andrea Bocci Date: Mon, 20 May 2024 11:13:47 +0200 Subject: [PATCH 023/237] Extend the SoA unit test to check for out-of-range access --- DataFormats/SoATemplate/test/SoAUnitTests.cc | 37 +++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/DataFormats/SoATemplate/test/SoAUnitTests.cc b/DataFormats/SoATemplate/test/SoAUnitTests.cc index b0c27f85a3322..a7f469618dfb2 100644 --- a/DataFormats/SoATemplate/test/SoAUnitTests.cc +++ b/DataFormats/SoATemplate/test/SoAUnitTests.cc @@ -2,7 +2,8 @@ #include #define CATCH_CONFIG_MAIN -#include "catch.hpp" +#include + #include "DataFormats/SoATemplate/interface/SoALayout.h" // clang-format off @@ -16,11 +17,16 @@ GENERATE_SOA_LAYOUT(SimpleLayoutTemplate, using SimpleLayout = SimpleLayoutTemplate<>; TEST_CASE("SoATemplate") { + // number of elements const std::size_t slSize = 10; + // size in bytes const std::size_t slBufferSize = SimpleLayout::computeDataSize(slSize); + // memory buffer aligned according to the layout requirements std::unique_ptr slBuffer{ reinterpret_cast(aligned_alloc(SimpleLayout::alignment, slBufferSize)), std::free}; + // SoA layout SimpleLayout sl{slBuffer.get(), slSize}; + SECTION("Row wide copies, row") { SimpleLayout::View slv{sl}; SimpleLayout::ConstView slcv{sl}; @@ -100,4 +106,33 @@ TEST_CASE("SoATemplate") { t += tx; } } + + SECTION("Range checking View") { + // Enable range checking + using View = SimpleLayout::ViewTemplate; + View slv{sl}; + int underflow = -1; + int overflow = slv.metadata().size(); + // Check for under-and overflow in the row accessor + REQUIRE_THROWS_AS(slv[underflow], std::out_of_range); + REQUIRE_THROWS_AS(slv[overflow], std::out_of_range); + // Check for under-and overflow in the element accessors + REQUIRE_THROWS_AS(slv.x(underflow), std::out_of_range); + REQUIRE_THROWS_AS(slv.x(overflow), std::out_of_range); + } + + SECTION("Range checking ConstView") { + // Enable range checking + using ConstView = + SimpleLayout::ConstViewTemplate; + ConstView slcv{sl}; + int underflow = -1; + int overflow = slcv.metadata().size(); + // Check for under-and overflow in the row accessor + REQUIRE_THROWS_AS(slcv[underflow], std::out_of_range); + REQUIRE_THROWS_AS(slcv[overflow], std::out_of_range); + // Check for under-and overflow in the element accessors + REQUIRE_THROWS_AS(slcv.x(underflow), std::out_of_range); + REQUIRE_THROWS_AS(slcv.x(overflow), std::out_of_range); + } } From 41ec1c45a18a90de5acab6986708253f5059d11e Mon Sep 17 00:00:00 2001 From: Claire Date: Tue, 21 May 2024 11:56:10 -0500 Subject: [PATCH 024/237] bin L1TQ variable --- .../L1TrackTrigger/interface/TTTrack.h | 1 + .../interface/TTTrack_TrackWord.h | 14 +- .../L1TrackTrigger/src/TTTrack_TrackWord.cc | 6 +- .../plugins/L1FPGATrackProducer.cc | 7 +- .../plugins/ProducerKFout.cc | 16 ++- .../TrackTrigger/interface/L1TrackQuality.h | 41 ++---- .../python/TrackQualityParams_cfi.py | 17 +-- L1Trigger/TrackTrigger/src/L1TrackQuality.cc | 128 ++---------------- 8 files changed, 54 insertions(+), 176 deletions(-) diff --git a/DataFormats/L1TrackTrigger/interface/TTTrack.h b/DataFormats/L1TrackTrigger/interface/TTTrack.h index 19ceec4c53453..bbc9147c134d3 100644 --- a/DataFormats/L1TrackTrigger/interface/TTTrack.h +++ b/DataFormats/L1TrackTrigger/interface/TTTrack.h @@ -372,6 +372,7 @@ double TTTrack::chi2ZRed() const { return theChi2_Z_ / (theStubRefs.size() - 2.); } +/// prompt track quality MVA template double TTTrack::trkMVA1() const { return theTrkMVA1_; diff --git a/DataFormats/L1TrackTrigger/interface/TTTrack_TrackWord.h b/DataFormats/L1TrackTrigger/interface/TTTrack_TrackWord.h index f08b0100fe1d6..e191bfd1aa79a 100644 --- a/DataFormats/L1TrackTrigger/interface/TTTrack_TrackWord.h +++ b/DataFormats/L1TrackTrigger/interface/TTTrack_TrackWord.h @@ -103,8 +103,10 @@ class TTTrack_TrackWord { {0.0, 0.5, 1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0, 4.5, 5.0, 6.0, 8.0, 10.0, 20.0, 50.0}}; static constexpr std::array bendChi2Bins = { {0.0, 0.75, 1.0, 1.5, 2.25, 3.5, 5.0, 20.0}}; - static constexpr std::array mvaQualityBins = { - {0.0, 0.125, 0.25, 0.375, 0.5, 0.625, 0.750, 0.875}}; + + // Bin edges for TQ MVA + static constexpr std::array tqMVABins = { + {0, 0.125, 0.25, 0.375, 0.5, 0.625, 0.750, 0.875}}; // Sector constants static constexpr unsigned int nSectors = 9; @@ -144,7 +146,7 @@ class TTTrack_TrackWord { double bendChi2, unsigned int hitPattern, double mvaQuality, - unsigned int mvaOther, + double mvaOther, unsigned int sector); TTTrack_TrackWord(unsigned int valid, unsigned int rInv, @@ -226,8 +228,8 @@ class TTTrack_TrackWord { double getBendChi2() const { return bendChi2Bins[getBendChi2Bits()]; } unsigned int getHitPattern() const { return getHitPatternBits(); } unsigned int getNStubs() const { return countSetBits(getHitPatternBits()); } - double getMVAQuality() const { return mvaQualityBins[getMVAQualityBits()]; } - unsigned int getMVAOther() const { return getMVAOtherBits(); } + double getMVAQuality() const { return tqMVABins[getMVAQualityBits()]; } + double getMVAOther() const { return getMVAOtherBits(); } // ----------member functions (setters) ------------ void setTrackWord(unsigned int valid, @@ -239,7 +241,7 @@ class TTTrack_TrackWord { double bendChi2, unsigned int hitPattern, double mvaQuality, - unsigned int mvaOther, + double mvaOther, unsigned int sector); void setTrackWord(unsigned int valid, diff --git a/DataFormats/L1TrackTrigger/src/TTTrack_TrackWord.cc b/DataFormats/L1TrackTrigger/src/TTTrack_TrackWord.cc index f4428e0cf8d55..c76b77a587aeb 100644 --- a/DataFormats/L1TrackTrigger/src/TTTrack_TrackWord.cc +++ b/DataFormats/L1TrackTrigger/src/TTTrack_TrackWord.cc @@ -36,7 +36,7 @@ TTTrack_TrackWord::TTTrack_TrackWord(unsigned int valid, double bendChi2, unsigned int hitPattern, double mvaQuality, - unsigned int mvaOther, + double mvaOther, unsigned int sector) { setTrackWord(valid, momentum, POCA, rInv, chi2RPhi, chi2RZ, bendChi2, hitPattern, mvaQuality, mvaOther, sector); } @@ -66,7 +66,7 @@ void TTTrack_TrackWord::setTrackWord(unsigned int valid, double bendChi2, unsigned int hitPattern, double mvaQuality, - unsigned int mvaOther, + double mvaOther, unsigned int sector) { // first, derive quantities to be packed float rPhi = localPhi(momentum.phi(), sector); // this needs to be phi relative to the center of the sector @@ -85,7 +85,7 @@ void TTTrack_TrackWord::setTrackWord(unsigned int valid, chi2rz_t chi2RZ_ = getBin(chi2RZ, chi2RZBins); bendChi2_t bendChi2_ = getBin(bendChi2, bendChi2Bins); hit_t hitPattern_ = hitPattern; - qualityMVA_t mvaQuality_ = getBin(mvaQuality, mvaQualityBins); + qualityMVA_t mvaQuality_ = getBin(mvaQuality, tqMVABins); otherMVA_t mvaOther_ = mvaOther; // pack the track word diff --git a/L1Trigger/TrackFindingTracklet/plugins/L1FPGATrackProducer.cc b/L1Trigger/TrackFindingTracklet/plugins/L1FPGATrackProducer.cc index 789ee15ba8cf1..d7fd496b1c152 100644 --- a/L1Trigger/TrackFindingTracklet/plugins/L1FPGATrackProducer.cc +++ b/L1Trigger/TrackFindingTracklet/plugins/L1FPGATrackProducer.cc @@ -739,7 +739,7 @@ void L1FPGATrackProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSe aTrack.setStubPtConsistency( StubPtConsistency::getConsistency(aTrack, theTrackerGeom, tTopo, settings_.bfield(), settings_.nHelixPar())); - // set TTTrack word first to allow Track Quality MVA to read variables: + // set track word before TQ MVA calculated which uses track word variables aTrack.setTrackWordBits(); if (trackQuality_) { @@ -751,7 +751,10 @@ void L1FPGATrackProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSe // trackQualityModel_->setBonusFeatures(hph.bonusFeatures()); // } - // set TTTrack word + // test track word + //aTrack.testTrackWordBits(); + + // set track word again to set MVA variable from TTTrack into track word aTrack.setTrackWordBits(); // test track word //aTrack.testTrackWordBits(); diff --git a/L1Trigger/TrackFindingTracklet/plugins/ProducerKFout.cc b/L1Trigger/TrackFindingTracklet/plugins/ProducerKFout.cc index 3c23f8d342d08..62c098afba9b4 100644 --- a/L1Trigger/TrackFindingTracklet/plugins/ProducerKFout.cc +++ b/L1Trigger/TrackFindingTracklet/plugins/ProducerKFout.cc @@ -78,13 +78,14 @@ namespace trklet { int partialTrackWordBits_; - // Helper function to convert floating chi2 to chi2 bin + // Helper function to convert floating value to bin template unsigned int digitise(const T& bins, double value, double factor) { unsigned int bin = 0; for (unsigned int i = 0; i < bins.size() - 1; i++) { if (value * factor > bins[i] && value * factor <= bins[i + 1]) - bin = i; + break; + bin++; } return bin; } @@ -200,7 +201,7 @@ namespace trklet { StreamsTrack outputStreamsTracks(setup_->numRegions() * setup_->tfpNumChannel()); // Setup containers for track quality - float tempTQMVA = 0.0; + float tempTQMVAPreSig = 0.0; // Due to ap_fixed implementation in CMSSW this 10,5 must be specified at compile time, TODO make this a changeable parameter std::vector> trackQuality_inputs = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}; @@ -295,10 +296,11 @@ namespace trklet { digitise(TTTrack_TrackWord::chi2RZBins, tempchi2rz, (double)setup_->kfoutchi2rzConv())}; // Run BDT emulation and package output into 3 bits - - tempTQMVA = trackQualityModel_->runEmulatedTQ(trackQuality_inputs); - tempTQMVA = std::trunc(tempTQMVA * ap_fixed_rescale); - TTBV tqMVA(digitise(tqBins_, tempTQMVA, 1.0), TTTrack_TrackWord::TrackBitWidths::kMVAQualitySize, false); + // output needs sigmoid transformation applied + tempTQMVAPreSig = trackQualityModel_->runEmulatedTQ(trackQuality_inputs); + TTBV tqMVA(digitise(L1TrackQuality::getTqMVAPreSigBins(), tempTQMVAPreSig, 1.0), + TTTrack_TrackWord::TrackBitWidths::kMVAQualitySize, + false); // Build 32 bit partial tracks for outputting in 64 bit packets // 12 + 3 + 7 + 3 + 6 diff --git a/L1Trigger/TrackTrigger/interface/L1TrackQuality.h b/L1Trigger/TrackTrigger/interface/L1TrackQuality.h index 0d697687a812f..1107ed3e74fbb 100644 --- a/L1Trigger/TrackTrigger/interface/L1TrackQuality.h +++ b/L1Trigger/TrackTrigger/interface/L1TrackQuality.h @@ -20,7 +20,6 @@ C.Brown 28/07/20 #include "DataFormats/L1TrackTrigger/interface/TTTrack.h" #include "DataFormats/L1TrackTrigger/interface/TTTrack_TrackWord.h" #include "DataFormats/L1TrackTrigger/interface/TTTypes.h" -#include "PhysicsTools/ONNXRuntime/interface/ONNXRuntime.h" #include #include "conifer.h" @@ -28,9 +27,6 @@ C.Brown 28/07/20 class L1TrackQuality { public: - // Enum class used for determining prediction behaviour in setL1TrackQuality - enum class QualityAlgorithm { Cut, GBDT, GBDT_cpp, NN, None }; - //Default Constructor L1TrackQuality(); @@ -49,36 +45,29 @@ class L1TrackQuality { // and a single output to be returned which is then used to fill the bits in the Track Word for situations // where a TTTrack datatype is unavailable to be passed to the track quality float runEmulatedTQ(std::vector> inputFeatures); - // To set private member data - void setCutParameters(std::string const& AlgorithmString, - float maxZ0, - float maxEta, - float chi2dofMax, - float bendchi2Max, - float minPt, - int nStubmin); - void setONNXModel(std::string const& AlgorithmString, - edm::FileInPath const& ONNXmodel, - std::string const& ONNXInputName, - std::vector const& featureNames); + void setModel(edm::FileInPath const& model, std::vector const& featureNames); void setBonusFeatures(std::vector bonusFeatures); + // TQ MVA bin conversions + static constexpr double invSigmoid(double value) { return -log(1. / value - 1.); } + static constexpr std::array getTqMVAPreSigBins() { + return {{-16., + invSigmoid(TTTrack_TrackWord::tqMVABins[1]), + invSigmoid(TTTrack_TrackWord::tqMVABins[2]), + invSigmoid(TTTrack_TrackWord::tqMVABins[3]), + invSigmoid(TTTrack_TrackWord::tqMVABins[4]), + invSigmoid(TTTrack_TrackWord::tqMVABins[5]), + invSigmoid(TTTrack_TrackWord::tqMVABins[6]), + invSigmoid(TTTrack_TrackWord::tqMVABins[7])}}; + } + private: // Private Member Data - QualityAlgorithm qualityAlgorithm_ = QualityAlgorithm::None; - edm::FileInPath ONNXmodel_; - std::string ONNXInputName_; + edm::FileInPath model_; std::vector featureNames_; - float maxZ0_; - float maxEta_; - float chi2dofMax_; - float bendchi2Max_; - float minPt_; - int nStubsmin_; bool useHPH_; std::vector bonusFeatures_; - std::unique_ptr runTime_; }; #endif diff --git a/L1Trigger/TrackTrigger/python/TrackQualityParams_cfi.py b/L1Trigger/TrackTrigger/python/TrackQualityParams_cfi.py index f5928d461da40..e1e8f6cdb5ec2 100644 --- a/L1Trigger/TrackTrigger/python/TrackQualityParams_cfi.py +++ b/L1Trigger/TrackTrigger/python/TrackQualityParams_cfi.py @@ -1,24 +1,11 @@ import FWCore.ParameterSet.Config as cms -TrackQualityParams = cms.PSet(qualityAlgorithm = cms.string("GBDT_cpp"), #None, Cut, NN, GBDT, GBDT_cpp - # This emulation GBDT is optimised for the HYBRID_NEWKF emulation and works with the emulation of the KF out module +TrackQualityParams = cms.PSet(# This emulation GBDT is optimised for the HYBRID_NEWKF emulation and works with the emulation of the KF out module # It is compatible with the HYBRID simulation and will give equivilant performance with this workflow - ONNXmodel = cms.FileInPath("L1Trigger/TrackTrigger/data/L1_TrackQuality_GBDT_emulation_digitized.json"), - # The ONNX model should be found at this path, if you want a local version of the model: - # git clone https://github.com/cms-data/L1Trigger-TrackTrigger.git L1Trigger/TrackTrigger/data - ONNXInputName = cms.string("feature_input"), + model = cms.FileInPath("L1Trigger/TrackTrigger/data/L1_TrackQuality_GBDT_emulation_digitized.json"), #Vector of strings of training features, in the order that the model was trained with featureNames = cms.vstring(["tanl", "z0_scaled", "bendchi2_bin", "nstub", "nlaymiss_interior", "chi2rphi_bin", "chi2rz_bin"]), - # Parameters for cut based classifier, optimized for L1 Track MET - # (Table 3.7 The Phase-2 Upgrade of the CMS Level-1 Trigger http://cds.cern.ch/record/2714892) - maxZ0 = cms.double ( 15. ) , # in cm - maxEta = cms.double ( 2.4 ) , - chi2dofMax = cms.double( 40. ), - bendchi2Max = cms.double( 2.4 ), - minPt = cms.double( 2. ), # in GeV - nStubsmin = cms.int32( 4 ), - tqemu_bins = cms.vint32( [-480, -62, -35, -16, 0, 16, 35, 62, 480] ), tqemu_TanlScale = cms.double( 128.0), tqemu_Z0Scale = cms.double( 64.0 ), ) diff --git a/L1Trigger/TrackTrigger/src/L1TrackQuality.cc b/L1Trigger/TrackTrigger/src/L1TrackQuality.cc index f3472beab34b6..7296cb385e665 100644 --- a/L1Trigger/TrackTrigger/src/L1TrackQuality.cc +++ b/L1Trigger/TrackTrigger/src/L1TrackQuality.cc @@ -10,26 +10,9 @@ C.Brown & C.Savard 07/2020 L1TrackQuality::L1TrackQuality() {} L1TrackQuality::L1TrackQuality(const edm::ParameterSet& qualityParams) : useHPH_(false), bonusFeatures_() { - std::string AlgorithmString = qualityParams.getParameter("qualityAlgorithm"); // Unpacks EDM parameter set itself to save unecessary processing within TrackProducers - if (AlgorithmString == "Cut") { - setCutParameters(AlgorithmString, - (float)qualityParams.getParameter("maxZ0"), - (float)qualityParams.getParameter("maxEta"), - (float)qualityParams.getParameter("chi2dofMax"), - (float)qualityParams.getParameter("bendchi2Max"), - (float)qualityParams.getParameter("minPt"), - qualityParams.getParameter("nStubsmin")); - } - - else { - setONNXModel(AlgorithmString, - qualityParams.getParameter("ONNXmodel"), - qualityParams.getParameter("ONNXInputName"), - qualityParams.getParameter>("featureNames")); - if ((AlgorithmString == "GBDT") || (AlgorithmString == "NN")) - runTime_ = std::make_unique(this->ONNXmodel_.fullPath()); - } + setModel(qualityParams.getParameter("model"), + qualityParams.getParameter>("featureNames")); } std::vector L1TrackQuality::featureTransform(TTTrack& aTrack, @@ -101,117 +84,28 @@ std::vector L1TrackQuality::featureTransform(TTTrack& aTrack) { - if (this->qualityAlgorithm_ == QualityAlgorithm::Cut) { - // Get Track parameters - float trk_pt = aTrack.momentum().perp(); - float trk_bend_chi2 = aTrack.stubPtConsistency(); - float trk_z0 = aTrack.z0(); - float trk_eta = aTrack.momentum().eta(); - float trk_chi2 = aTrack.chi2(); - const auto& stubRefs = aTrack.getStubRefs(); - int nStubs = stubRefs.size(); - - float classification = 0.0; // Default classification is 0 - - if (trk_pt >= this->minPt_ && abs(trk_z0) < this->maxZ0_ && abs(trk_eta) < this->maxEta_ && - trk_chi2 < this->chi2dofMax_ && trk_bend_chi2 < this->bendchi2Max_ && nStubs >= this->nStubsmin_) - classification = 1.0; - // Classification updated to 1 if conditions are met - - aTrack.settrkMVA1(classification); - } - - else if (this->qualityAlgorithm_ == QualityAlgorithm::GBDT_cpp) { - // load in bdt - conifer::BDT bdt(this->ONNXmodel_.fullPath()); - - // collect features and classify using bdt - std::vector inputs = featureTransform(aTrack, this->featureNames_); - std::vector output = bdt.decision_function(inputs); - aTrack.settrkMVA1(1. / (1. + exp(-output.at(0)))); // need logistic sigmoid fcn applied to xgb output - } - - else if ((this->qualityAlgorithm_ == QualityAlgorithm::NN) || (this->qualityAlgorithm_ == QualityAlgorithm::GBDT)) { - // Setup ONNX input and output names and arrays - std::vector ortinput_names; - std::vector ortoutput_names; - - cms::Ort::FloatArrays ortinput; - cms::Ort::FloatArrays ortoutputs; - - std::vector Transformed_features = featureTransform(aTrack, this->featureNames_); - // cms::Ort::ONNXRuntime runTime(this->ONNXmodel_.fullPath()); //Setup ONNX runtime - - ortinput_names.push_back(this->ONNXInputName_); - ortoutput_names = runTime_->getOutputNames(); - - //ONNX runtime recieves a vector of vectors of floats so push back the input - // vector of float to create a 1,1,21 ortinput - ortinput.push_back(Transformed_features); - - // batch_size 1 as only one set of transformed features is being processed - int batch_size = 1; - // Run classification - ortoutputs = runTime_->run(ortinput_names, ortinput, {}, ortoutput_names, batch_size); - - if (this->qualityAlgorithm_ == QualityAlgorithm::NN) { - aTrack.settrkMVA1(ortoutputs[0][0]); - } - - else if (this->qualityAlgorithm_ == QualityAlgorithm::GBDT) { - aTrack.settrkMVA1(ortoutputs[1][1]); - } - // Slight differences in the ONNX models of the GBDTs and NNs mean different - // indices of the ortoutput need to be accessed - } + // load in bdt + conifer::BDT bdt(this->model_.fullPath()); - else { - aTrack.settrkMVA1(-999); - } + // collect features and classify using bdt + std::vector inputs = featureTransform(aTrack, this->featureNames_); + std::vector output = bdt.decision_function(inputs); + aTrack.settrkMVA1(1. / (1. + exp(-output.at(0)))); } float L1TrackQuality::runEmulatedTQ(std::vector> inputFeatures) { // load in bdt - conifer::BDT, ap_fixed<10, 5>> bdt(this->ONNXmodel_.fullPath()); + conifer::BDT, ap_fixed<10, 5>> bdt(this->model_.fullPath()); // collect features and classify using bdt std::vector> output = bdt.decision_function(inputFeatures); return output.at(0).to_float(); // need logistic sigmoid fcn applied to xgb output } -void L1TrackQuality::setCutParameters(std::string const& AlgorithmString, - float maxZ0, - float maxEta, - float chi2dofMax, - float bendchi2Max, - float minPt, - int nStubmin) { - qualityAlgorithm_ = QualityAlgorithm::Cut; - maxZ0_ = maxZ0; - maxEta_ = maxEta; - chi2dofMax_ = chi2dofMax; - bendchi2Max_ = bendchi2Max; - minPt_ = minPt; - nStubsmin_ = nStubmin; -} - -void L1TrackQuality::setONNXModel(std::string const& AlgorithmString, - edm::FileInPath const& ONNXmodel, - std::string const& ONNXInputName, - std::vector const& featureNames) { +void L1TrackQuality::setModel(edm::FileInPath const& model, std::vector const& featureNames) { //Convert algorithm string to Enum class for track by track comparison - if (AlgorithmString == "NN") { - qualityAlgorithm_ = QualityAlgorithm::NN; - } else if (AlgorithmString == "GBDT") { - qualityAlgorithm_ = QualityAlgorithm::GBDT; - } else if (AlgorithmString == "GBDT_cpp") { - qualityAlgorithm_ = QualityAlgorithm::GBDT_cpp; - } else { - qualityAlgorithm_ = QualityAlgorithm::None; - } - ONNXmodel_ = ONNXmodel; - ONNXInputName_ = ONNXInputName; + model_ = model; featureNames_ = featureNames; } From de1c193254c5bf7e236f1282a171b499c59ee116 Mon Sep 17 00:00:00 2001 From: Sunil Dogra Date: Wed, 22 May 2024 03:14:20 +0200 Subject: [PATCH 025/237] Clean offline DQM of Photon smin triggers and adding DisplaedPhoton --- DQMOffline/Trigger/python/PhotonMonitor_cff.py | 13 +++++-------- .../analyses/hltExoticaDisplacedDiPhoton_cff.py | 1 - 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/DQMOffline/Trigger/python/PhotonMonitor_cff.py b/DQMOffline/Trigger/python/PhotonMonitor_cff.py index 9d3ccdf44c41d..339ca9585c7f9 100644 --- a/DQMOffline/Trigger/python/PhotonMonitor_cff.py +++ b/DQMOffline/Trigger/python/PhotonMonitor_cff.py @@ -51,6 +51,10 @@ numGenericTriggerEventPSet = dict(hltPaths = ["HLT_Photon60_R9Id90_CaloIdL_IsoL_DisplacedIdL_PFHT350_v*"]) ) +CscCluster50_Photon20Unseeded = hltPhotonmonitoring.clone( + FolderName = 'HLT/EGM/Photon/CscCluster50_Photon20Unseeded/', + numGenericTriggerEventPSet = dict(hltPaths = ["HLT_CscCluster50_Photon20Unseeded_v*"]) +) from DQMOffline.Trigger.ObjMonitor_cfi import hltobjmonitoring @@ -108,6 +112,7 @@ + SinglePhoton165_R9Id90_HE10_IsoM_monitoring + Photon50_R9Id90_HE10_IsoM_EBOnly_PFJetsMJJ300DEta3_PFMET50_monitoring + Photon75_R9Id90_HE10_IsoM_EBOnly_PFJetsMJJ300DEta3_monitoring + + CscCluster50_Photon20Unseeded ) @@ -157,13 +162,6 @@ numGenericTriggerEventPSet = dict(hltPaths = ["HLT_DiPhoton10Time1p4ns_v*"]), ) -DiPhoton10sminlt0p1_monitoring = hltPhotonmonitoring.clone( - FolderName = 'HLT/EXO/DiPhoton/DiPhoton10sminlt0p1/', - nphotons = 2, - photonSelection = "(pt > 10 && abs(eta)<1.4442 && hadTowOverEm<0.12 && full5x5_sigmaIetaIeta()<0.015 && full5x5_r9>.5)||(pt > 10 && abs(eta)<2.5 && abs(eta)>1.5556 && hadTowOverEm<0.12 && full5x5_sigmaIetaIeta()<0.035 && full5x5_r9>.8)", - numGenericTriggerEventPSet = dict(hltPaths = ["HLT_DiPhoton10sminlt0p1_v*"]), -) - higgsHLTDiphotonMonitoring = cms.Sequence( DiphotonMass90_monitoring +DiphotonMass95_monitoring @@ -171,5 +169,4 @@ +Diphoton3018_monitoring +Diphoton2214_monitoring +DiPhoton10Time1p4ns_monitoring - +DiPhoton10sminlt0p1_monitoring ) diff --git a/HLTriggerOffline/Exotica/python/analyses/hltExoticaDisplacedDiPhoton_cff.py b/HLTriggerOffline/Exotica/python/analyses/hltExoticaDisplacedDiPhoton_cff.py index 6c3b79309c24b..f3e2ba03f8254 100644 --- a/HLTriggerOffline/Exotica/python/analyses/hltExoticaDisplacedDiPhoton_cff.py +++ b/HLTriggerOffline/Exotica/python/analyses/hltExoticaDisplacedDiPhoton_cff.py @@ -3,7 +3,6 @@ DisplacedDiPhotonPSet = cms.PSet( hltPathsToCheck = cms.vstring( "HLT_DiPhoton10Time1p4ns_v", # New for Run3 (introduced in HLT V1.3) - "HLT_DiPhoton10sminlt0p1_v", # New for Run3 (introduced in HLT V1.3) ), recElecLabel = cms.InputTag("gedGsfElectrons"), # -- Analysis specific cuts From a1c0bf2d39ed26ce018d244bc12e010afc5e148b Mon Sep 17 00:00:00 2001 From: Sunil Dogra Date: Wed, 22 May 2024 04:37:05 +0200 Subject: [PATCH 026/237] Clean offline DQM of Photon smin triggers and adding DisplaedPhoton --- DQMOffline/Trigger/python/PhotonMonitor_cff.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DQMOffline/Trigger/python/PhotonMonitor_cff.py b/DQMOffline/Trigger/python/PhotonMonitor_cff.py index 339ca9585c7f9..47f91494fb1b8 100644 --- a/DQMOffline/Trigger/python/PhotonMonitor_cff.py +++ b/DQMOffline/Trigger/python/PhotonMonitor_cff.py @@ -52,7 +52,7 @@ ) CscCluster50_Photon20Unseeded = hltPhotonmonitoring.clone( - FolderName = 'HLT/EGM/Photon/CscCluster50_Photon20Unseeded/', + FolderName = 'HLT/EXO/DisplacedPhoton/CscCluster50_Photon20Unseeded/', numGenericTriggerEventPSet = dict(hltPaths = ["HLT_CscCluster50_Photon20Unseeded_v*"]) ) From c0077e6fee38c54565309252d4a9150f9fb9674d Mon Sep 17 00:00:00 2001 From: mmusich Date: Fri, 19 Jan 2024 17:01:26 +0100 Subject: [PATCH 027/237] add Era_Run3_2024,Era_Run3_2025, Tier0 reco scenario for 2024, and change default era in PyReleaseValidation --- .../python/Impl/ppEra_Run3_2024.py | 29 +++++++++++++++++++ .../DataProcessing/python/RecoTLR.py | 5 ++++ .../DataProcessing/test/run_CfgTest_5.sh | 2 +- .../DataProcessing/test/run_CfgTest_8.sh | 2 +- .../Eras/python/Era_Run3_2024_cff.py | 5 ++++ .../Eras/python/Era_Run3_2025_cff.py | 5 ++++ .../python/upgradeWorkflowComponents.py | 2 +- .../StandardSequences/python/Eras.py | 2 ++ 8 files changed, 49 insertions(+), 3 deletions(-) create mode 100644 Configuration/DataProcessing/python/Impl/ppEra_Run3_2024.py create mode 100644 Configuration/Eras/python/Era_Run3_2024_cff.py create mode 100644 Configuration/Eras/python/Era_Run3_2025_cff.py diff --git a/Configuration/DataProcessing/python/Impl/ppEra_Run3_2024.py b/Configuration/DataProcessing/python/Impl/ppEra_Run3_2024.py new file mode 100644 index 0000000000000..39066c53b405e --- /dev/null +++ b/Configuration/DataProcessing/python/Impl/ppEra_Run3_2024.py @@ -0,0 +1,29 @@ +#!/usr/bin/env python3 +""" +_ppEra_Run3_2024_ +Scenario supporting proton collisions for 2024 +""" + +import os +import sys + +from Configuration.DataProcessing.Reco import Reco +import FWCore.ParameterSet.Config as cms +from Configuration.Eras.Era_Run3_2024_cff import Run3_2024 + +from Configuration.DataProcessing.Impl.pp import pp + +class ppEra_Run3_2024(pp): + def __init__(self): + pp.__init__(self) + self.recoSeq='' + self.cbSc='pp' + self.eras=Run3_2024 + self.promptCustoms += [ 'Configuration/DataProcessing/RecoTLR.customisePostEra_Run3_2024' ] + self.expressCustoms += [ 'Configuration/DataProcessing/RecoTLR.customisePostEra_Run3_2024' ] + self.visCustoms += [ 'Configuration/DataProcessing/RecoTLR.customisePostEra_Run3_2024' ] + """ + _ppEra_Run3_2024_ + Implement configuration building for data processing for proton + collision data taking for Run3_2024 + """ diff --git a/Configuration/DataProcessing/python/RecoTLR.py b/Configuration/DataProcessing/python/RecoTLR.py index 4539242659b77..5eb8b3576eb1a 100644 --- a/Configuration/DataProcessing/python/RecoTLR.py +++ b/Configuration/DataProcessing/python/RecoTLR.py @@ -95,6 +95,11 @@ def customisePostEra_Run3_2023(process): customisePostEra_Run3(process) return process +def customisePostEra_Run3_2024(process): + #start with a repeat of 2023 + customisePostEra_Run3_2023(process) + return process + def customisePostEra_Run3_express_trackingOnly(process): #start with a repeat of 2018 customisePostEra_Run2_2018_express_trackingOnly(process) diff --git a/Configuration/DataProcessing/test/run_CfgTest_5.sh b/Configuration/DataProcessing/test/run_CfgTest_5.sh index 552fbf82c123f..c930630845844 100755 --- a/Configuration/DataProcessing/test/run_CfgTest_5.sh +++ b/Configuration/DataProcessing/test/run_CfgTest_5.sh @@ -10,7 +10,7 @@ function die { echo $1: status $2 ; exit $2; } function runTest { echo $1 ; python3 $1 || die "Failure for configuration: $1" $?; } -declare -a arr=("AlCaLumiPixels" "AlCaTestEnable" "cosmicsEra_Run2_2018" "hcalnzsEra_Run2_2018" "ppEra_Run2_2018" "hcalnzsEra_Run2_2018_highBetaStar" "hcalnzsEra_Run2_2018_pp_on_AA" "ppEra_Run2_2018_highBetaStar" "ppEra_Run2_2018_pp_on_AA" "cosmicsHybridEra_Run2_2018" "cosmicsEra_Run3" "hcalnzsEra_Run3" "ppEra_Run3" "AlCaLumiPixels_Run3" "AlCaPhiSymEcal_Nano" "AlCaPPS_Run3" "ppEra_Run3_pp_on_PbPb" "hcalnzsEra_Run3_pp_on_PbPb" "ppEra_Run3_pp_on_PbPb_approxSiStripClusters" "ppEra_Run3_2023" "ppEra_Run3_pp_on_PbPb_2023" "ppEra_Run3_pp_on_PbPb_approxSiStripClusters_2023") +declare -a arr=("AlCaLumiPixels" "AlCaTestEnable" "cosmicsEra_Run2_2018" "hcalnzsEra_Run2_2018" "ppEra_Run2_2018" "hcalnzsEra_Run2_2018_highBetaStar" "hcalnzsEra_Run2_2018_pp_on_AA" "ppEra_Run2_2018_highBetaStar" "ppEra_Run2_2018_pp_on_AA" "cosmicsHybridEra_Run2_2018" "cosmicsEra_Run3" "hcalnzsEra_Run3" "ppEra_Run3" "AlCaLumiPixels_Run3" "AlCaPhiSymEcal_Nano" "AlCaPPS_Run3" "ppEra_Run3_pp_on_PbPb" "hcalnzsEra_Run3_pp_on_PbPb" "ppEra_Run3_pp_on_PbPb_approxSiStripClusters" "ppEra_Run3_2023" "ppEra_Run3_pp_on_PbPb_2023" "ppEra_Run3_pp_on_PbPb_approxSiStripClusters_2023" "ppEra_Run3_2024") for scenario in "${arr[@]}" do runTest "${SCRAM_TEST_PATH}/RunPromptReco.py --scenario $scenario --reco --aod --dqmio --global-tag GLOBALTAG --lfn=/store/whatever --alcareco TkAlMinBias+SiStripCalMinBias" diff --git a/Configuration/DataProcessing/test/run_CfgTest_8.sh b/Configuration/DataProcessing/test/run_CfgTest_8.sh index afadfcac01943..62bc5c078b29b 100755 --- a/Configuration/DataProcessing/test/run_CfgTest_8.sh +++ b/Configuration/DataProcessing/test/run_CfgTest_8.sh @@ -10,7 +10,7 @@ function die { echo $1: status $2 ; exit $2; } function runTest { echo $1 ; python3 $1 || die "Failure for configuration: $1" $?; } -declare -a arr=("ppEra_Run3" "ppEra_Run3_2023" "ppEra_Run3_2023_repacked") +declare -a arr=("ppEra_Run3" "ppEra_Run3_2023" "ppEra_Run3_2023_repacked" "ppEra_Run3_2024") for scenario in "${arr[@]}" do runTest "${SCRAM_TEST_PATH}/RunPromptReco.py --scenario $scenario --reco --aod --miniaod --nanoaod --dqmio --global-tag GLOBALTAG --lfn=/store/whatever --alcareco TkAlMinBias+SiStripCalMinBias" diff --git a/Configuration/Eras/python/Era_Run3_2024_cff.py b/Configuration/Eras/python/Era_Run3_2024_cff.py new file mode 100644 index 0000000000000..2a3224b13b01c --- /dev/null +++ b/Configuration/Eras/python/Era_Run3_2024_cff.py @@ -0,0 +1,5 @@ +import FWCore.ParameterSet.Config as cms + +from Configuration.Eras.Era_Run3_2023_cff import Run3_2023 + +Run3_2024 = cms.ModifierChain(Run3_2023) diff --git a/Configuration/Eras/python/Era_Run3_2025_cff.py b/Configuration/Eras/python/Era_Run3_2025_cff.py new file mode 100644 index 0000000000000..b0a96316cd88b --- /dev/null +++ b/Configuration/Eras/python/Era_Run3_2025_cff.py @@ -0,0 +1,5 @@ +import FWCore.ParameterSet.Config as cms + +from Configuration.Eras.Era_Run3_2024_cff import Run3_2024 + +Run3_2025 = cms.ModifierChain(Run3_2024) diff --git a/Configuration/PyReleaseValidation/python/upgradeWorkflowComponents.py b/Configuration/PyReleaseValidation/python/upgradeWorkflowComponents.py index 5bec79747cba4..84bbab0aeafca 100644 --- a/Configuration/PyReleaseValidation/python/upgradeWorkflowComponents.py +++ b/Configuration/PyReleaseValidation/python/upgradeWorkflowComponents.py @@ -2856,7 +2856,7 @@ def condition(self, fragment, stepList, key, hasHarvest): 'Geom' : 'DB:Extended', 'GT' : 'auto:phase1_2024_realistic', 'HLTmenu': '@relval2024', - 'Era' : 'Run3', + 'Era' : 'Run3_2024', 'BeamSpot': 'DBrealistic', 'ScenToRun' : ['GenSim','Digi','RecoNano','HARVESTNano','ALCA'], }, diff --git a/Configuration/StandardSequences/python/Eras.py b/Configuration/StandardSequences/python/Eras.py index 52e9a364b5393..96dad3849ece6 100644 --- a/Configuration/StandardSequences/python/Eras.py +++ b/Configuration/StandardSequences/python/Eras.py @@ -35,6 +35,8 @@ def __init__(self): 'Run2_2018_noMkFit', 'Run3', 'Run3_2023', + 'Run3_2024', + 'Run3_2025', 'Run3_noMkFit', 'Run3_pp_on_PbPb', 'Run3_pp_on_PbPb_approxSiStripClusters', From 1057daa33b6f6892b757345a909d1e764c945260 Mon Sep 17 00:00:00 2001 From: mmusich Date: Sat, 20 Jan 2024 14:51:20 +0100 Subject: [PATCH 028/237] exclude era Run3_2024 from being modified by UpgradeWorkflow_DDDDB --- .../PyReleaseValidation/python/upgradeWorkflowComponents.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Configuration/PyReleaseValidation/python/upgradeWorkflowComponents.py b/Configuration/PyReleaseValidation/python/upgradeWorkflowComponents.py index 84bbab0aeafca..3f2ea70bef3e8 100644 --- a/Configuration/PyReleaseValidation/python/upgradeWorkflowComponents.py +++ b/Configuration/PyReleaseValidation/python/upgradeWorkflowComponents.py @@ -2707,7 +2707,7 @@ def condition(self, fragment, stepList, key, hasHarvest): class UpgradeWorkflow_DDDDB(UpgradeWorkflow): def setup_(self, step, stepName, stepDict, k, properties): the_era = stepDict[step][k]['--era'] - if 'Run3' in the_era and '2023' not in the_era and 'Fast' not in the_era and "Pb" not in the_era: + if 'Run3' in the_era and '2023' not in the_era and '2024' not in the_era and 'Fast' not in the_era and "Pb" not in the_era: # retain any other eras tmp_eras = the_era.split(',') tmp_eras[tmp_eras.index("Run3")] = 'Run3_DDD' From 880ab431d2d03c168d4d1128904d929822ebfca8 Mon Sep 17 00:00:00 2001 From: mmusich Date: Wed, 22 May 2024 10:13:54 +0200 Subject: [PATCH 029/237] make era and Tier0 scenarios for Run3_2024 inherit directly from Run3 --- Configuration/DataProcessing/python/RecoTLR.py | 2 +- Configuration/Eras/python/Era_Run3_2024_cff.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Configuration/DataProcessing/python/RecoTLR.py b/Configuration/DataProcessing/python/RecoTLR.py index 5eb8b3576eb1a..997fe5f31d00b 100644 --- a/Configuration/DataProcessing/python/RecoTLR.py +++ b/Configuration/DataProcessing/python/RecoTLR.py @@ -97,7 +97,7 @@ def customisePostEra_Run3_2023(process): def customisePostEra_Run3_2024(process): #start with a repeat of 2023 - customisePostEra_Run3_2023(process) + customisePostEra_Run3(process) return process def customisePostEra_Run3_express_trackingOnly(process): diff --git a/Configuration/Eras/python/Era_Run3_2024_cff.py b/Configuration/Eras/python/Era_Run3_2024_cff.py index 2a3224b13b01c..6dc5f3a1b6e03 100644 --- a/Configuration/Eras/python/Era_Run3_2024_cff.py +++ b/Configuration/Eras/python/Era_Run3_2024_cff.py @@ -1,5 +1,5 @@ import FWCore.ParameterSet.Config as cms -from Configuration.Eras.Era_Run3_2023_cff import Run3_2023 +from Configuration.Eras.Era_Run3_cff import Run3 -Run3_2024 = cms.ModifierChain(Run3_2023) +Run3_2024 = cms.ModifierChain(Run3) From 4b8a313549a76ba6931bcf27f4d1a412f01d82c8 Mon Sep 17 00:00:00 2001 From: Shahzad Malik Muzaffar Date: Thu, 23 May 2024 10:12:07 +0200 Subject: [PATCH 030/237] AMPTInterface: Fix used uninitialized warnings --- .../AMPTInterface/src/hipyset1.35.f | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/GeneratorInterface/AMPTInterface/src/hipyset1.35.f b/GeneratorInterface/AMPTInterface/src/hipyset1.35.f index bddcf5cef5e57..ffceb0ec249d2 100644 --- a/GeneratorInterface/AMPTInterface/src/hipyset1.35.f +++ b/GeneratorInterface/AMPTInterface/src/hipyset1.35.f @@ -500,6 +500,8 @@ SUBROUTINE LUPREP(IP) C...Rearrange parton shower product listing along strings: begin loop. I1=N + DO 101 J=1,5 + 101 DPC(J)=0 DO 130 MQGST=1,2 DO 120 I=MAX(1,IP),N IF(K(I,1).NE.3) GOTO 120 @@ -3459,6 +3461,11 @@ SUBROUTINE LUSHOW(IP1,IP2,QMAX) PT2MIN=MAX(0.5*PARJ(82),1.1*PARJ(81))**2 ALAMS=PARJ(81)**2 ALFM=LOG(PT2MIN/ALAMS) + DO 101 I=1,4 + ISI(I)=0 + IPA(I)=0 + KFLD(I)=0 + 101 CONTINUE C...Store positions of shower initiating partons. M3JC=0 @@ -9582,6 +9589,8 @@ SUBROUTINE PYMULT(MMUL) XI=0. YI=0. XK=0.5 + XF=1. + YF=1. IIT=0 130 IF(IIT.EQ.0) THEN XK=2.*XK @@ -9877,6 +9886,9 @@ SUBROUTINE PYMULT(MMUL) IF(RFLAV.LT.PARP(85).AND.NSTR.GE.1) THEN C....Choose relevant string pieces to place gluons on. + IST1=0 + IST2=0 + ISTM=0 DO 210 I=N+1,N+2 DMIN=1E8 DO 200 ISTR=1,NSTR @@ -11248,6 +11260,7 @@ SUBROUTINE PYWIDT(KFLR,RMAS,WDTP,WDTE) C...H0 -> gamma + gamma; quark, charged lepton and W loop contributions ETARE=0. ETAIM=0. + EJ=0. DO 150 J=1,3*MSTP(1)+1 IF(J.LE.2*MSTP(1)) THEN EJ=KCHG(J,1)/3. @@ -11289,7 +11302,9 @@ SUBROUTINE PYWIDT(KFLR,RMAS,WDTP,WDTE) ELSEIF(I.EQ.15) THEN C...H0 -> gamma + Z0; quark, charged lepton and W loop contributions ETARE=0. - ETAIM=0. + ETAIM=0. + VJ=0. + EJ=0. DO 160 J=1,3*MSTP(1)+1 IF(J.LE.2*MSTP(1)) THEN EJ=KCHG(J,1)/3. @@ -11304,7 +11319,7 @@ SUBROUTINE PYWIDT(KFLR,RMAS,WDTP,WDTE) VJ=AJ-4.*EJ*XW EPS=(2.*PMAS(10+JL,1)/RMAS)**2 EPSP=(2.*PMAS(10+JL,1)/PMAS(23,1))**2 - ELSE + ELSE EPS=(2.*PMAS(24,1)/RMAS)**2 EPSP=(2.*PMAS(24,1)/PMAS(23,1))**2 ENDIF From 080d8c6a669f3172a63481ed07cd1e811dcd17ca Mon Sep 17 00:00:00 2001 From: Vincenzo Innocente Date: Thu, 23 May 2024 10:23:48 +0200 Subject: [PATCH 031/237] add long-track bonus to CkfTrajectoryBuilder --- .../python/MuonCkfTrajectoryBuilder_cfi.py | 2 ++ .../CkfPattern/interface/CkfTrajectoryBuilder.h | 2 ++ .../CkfPattern/python/CkfTrajectoryBuilder_cfi.py | 2 ++ RecoTracker/CkfPattern/src/CkfTrajectoryBuilder.cc | 12 ++++++++++-- 4 files changed, 16 insertions(+), 2 deletions(-) diff --git a/RecoMuon/L3TrackFinder/python/MuonCkfTrajectoryBuilder_cfi.py b/RecoMuon/L3TrackFinder/python/MuonCkfTrajectoryBuilder_cfi.py index 42fce0618221a..8e54dc7fabc4d 100644 --- a/RecoMuon/L3TrackFinder/python/MuonCkfTrajectoryBuilder_cfi.py +++ b/RecoMuon/L3TrackFinder/python/MuonCkfTrajectoryBuilder_cfi.py @@ -19,6 +19,8 @@ rescaleErrorIfFail = cms.double(1.0), propagatorOpposite = cms.string('PropagatorWithMaterialOpposite'), lostHitPenalty = cms.double(30.0), + foundHitBonus = cms.double(0.0), + minHitForDoubleBonus = cms.int32(9999), #this is present in HLT config, appears to be dummy # appendToDataLabel = cms.string( "" ), #safety cone size diff --git a/RecoTracker/CkfPattern/interface/CkfTrajectoryBuilder.h b/RecoTracker/CkfPattern/interface/CkfTrajectoryBuilder.h index 209978eb9dd2d..c5d7b8e0d8df7 100644 --- a/RecoTracker/CkfPattern/interface/CkfTrajectoryBuilder.h +++ b/RecoTracker/CkfPattern/interface/CkfTrajectoryBuilder.h @@ -63,6 +63,8 @@ class CkfTrajectoryBuilder : public BaseCkfTrajectoryBuilder { int theMaxCand; /**< Maximum number of trajectory candidates to propagate to the next layer. */ float theLostHitPenalty; /**< Chi**2 Penalty for each lost hit. */ + float theFoundHitBonus; /**< Chi**2 Bonus for each found hit. */ + int theMinHitForDoubleBonus; /**< minimun number of hits to double the bonus above */ bool theIntermediateCleaning; /**< Tells whether an intermediary cleaning stage should take place during TB. */ bool theAlwaysUseInvalidHits; diff --git a/RecoTracker/CkfPattern/python/CkfTrajectoryBuilder_cfi.py b/RecoTracker/CkfPattern/python/CkfTrajectoryBuilder_cfi.py index d4df8e456eb83..8d360b9497e44 100644 --- a/RecoTracker/CkfPattern/python/CkfTrajectoryBuilder_cfi.py +++ b/RecoTracker/CkfPattern/python/CkfTrajectoryBuilder_cfi.py @@ -20,6 +20,8 @@ propagatorOpposite = cms.string('PropagatorWithMaterialOpposite'), # propagatorOpposite = cms.string('PropagatorWithMaterialParabolicMfOpposite'), lostHitPenalty = cms.double(30.0), + foundHitBonus = cms.double(10.0), + minHitForDoubleBonus = cms.int32(8), #SharedSeedCheck = cms.bool(False), seedAs5DHit = cms.bool(False) ) diff --git a/RecoTracker/CkfPattern/src/CkfTrajectoryBuilder.cc b/RecoTracker/CkfPattern/src/CkfTrajectoryBuilder.cc index 3680471fd89de..dbfb957650e29 100644 --- a/RecoTracker/CkfPattern/src/CkfTrajectoryBuilder.cc +++ b/RecoTracker/CkfPattern/src/CkfTrajectoryBuilder.cc @@ -40,6 +40,8 @@ CkfTrajectoryBuilder::CkfTrajectoryBuilder(const edm::ParameterSet& conf, : BaseCkfTrajectoryBuilder(conf, iC, std::move(filter)) { theMaxCand = conf.getParameter("maxCand"); theLostHitPenalty = conf.getParameter("lostHitPenalty"); + theFoundHitBonus = conf.getParameter("foundHitBonus"); + theMinHitForDoubleBonus = conf.getParameter("minHitForDoubleBounus"); theIntermediateCleaning = conf.getParameter("intermediateCleaning"); theAlwaysUseInvalidHits = conf.getParameter("alwaysUseInvalidHits"); } @@ -48,6 +50,8 @@ void CkfTrajectoryBuilder::fillPSetDescription(edm::ParameterSetDescription& iDe BaseCkfTrajectoryBuilder::fillPSetDescription(iDesc); iDesc.add("maxCand", 5); iDesc.add("lostHitPenalty", 30.); + iDesc.add("foundHitBonus", 10.); + iDesc.add("minHitForDoubleBounus", 8); iDesc.add("intermediateCleaning", true); iDesc.add("alwaysUseInvalidHits", true); @@ -104,10 +108,14 @@ unsigned int CkfTrajectoryBuilder::limitedCandidates(const std::shared_ptr theMinHitForDoubleBonus ? bonus : 0; + return a.chiSquared() + a.lostHits() * theLostHitPenalty - bonus * a.foundHits(); }; + auto trajCandLess = [&](TempTrajectory const& a, TempTrajectory const& b) { return score(a) < score(b); }; + while (!candidates.empty()) { newCand.clear(); bool full = 0; From eab7107f187e072d0f0f1e403c81c5ff5d4df217 Mon Sep 17 00:00:00 2001 From: Vincenzo Innocente Date: Thu, 23 May 2024 10:40:39 +0200 Subject: [PATCH 032/237] cleanup --- .../CkfPattern/plugins/TrajectoryLessByFoundHits.h | 14 -------------- .../CkfPattern/plugins/TrajectorySegmentBuilder.cc | 4 ++-- 2 files changed, 2 insertions(+), 16 deletions(-) delete mode 100644 RecoTracker/CkfPattern/plugins/TrajectoryLessByFoundHits.h diff --git a/RecoTracker/CkfPattern/plugins/TrajectoryLessByFoundHits.h b/RecoTracker/CkfPattern/plugins/TrajectoryLessByFoundHits.h deleted file mode 100644 index 77f81ba420db7..0000000000000 --- a/RecoTracker/CkfPattern/plugins/TrajectoryLessByFoundHits.h +++ /dev/null @@ -1,14 +0,0 @@ -#ifndef TrajectoryLessByFoundHits_h_ -#define TrajectoryLessByFoundHits_h_ - -#include "TrackingTools/PatternTools/interface/Trajectory.h" -#include - -inline bool lessByFoundHits(const Trajectory& a, const Trajectory& b) { return a.foundHits() < b.foundHits(); } -inline bool lessByFoundHits(const TempTrajectory& a, const TempTrajectory& b) { return a.foundHits() < b.foundHits(); } - -struct TrajectoryLessByFoundHits { - bool operator()(const Trajectory& a, const Trajectory& b) const { return a.foundHits() < b.foundHits(); } - bool operator()(const TempTrajectory& a, const TempTrajectory& b) const { return a.foundHits() < b.foundHits(); } -}; -#endif diff --git a/RecoTracker/CkfPattern/plugins/TrajectorySegmentBuilder.cc b/RecoTracker/CkfPattern/plugins/TrajectorySegmentBuilder.cc index df1d438e1f869..fc9fff86b720b 100644 --- a/RecoTracker/CkfPattern/plugins/TrajectorySegmentBuilder.cc +++ b/RecoTracker/CkfPattern/plugins/TrajectorySegmentBuilder.cc @@ -13,7 +13,6 @@ #include "TrackingTools/MeasurementDet/interface/TrajectoryMeasurementGroup.h" #include "TrackingTools/DetLayers/interface/DetGroup.h" #include "TrackingTools/DetLayers/interface/DetLayer.h" -#include "TrajectoryLessByFoundHits.h" #include "TrackingTools/PatternTools/interface/TrajectoryStateUpdator.h" #include "TrackingTools/DetLayers/interface/GeomDetCompatibilityChecker.h" #include "TrackingTools/MeasurementDet/interface/MeasurementDet.h" @@ -482,7 +481,8 @@ void TrajectorySegmentBuilder::cleanCandidates(vector& candidate int index[NC]; for (int i = 0; i != NC; ++i) index[i] = i; - std::sort(index, index + NC, [&candidates](int i, int j) { return lessByFoundHits(candidates[i], candidates[j]); }); + std::sort( + index, index + NC, [&candidates](int i, int j) { return candidates[i].foundHits() < candidates[j].foundHits(); }); // cout << "SortedCandidates.foundHits"; // for (auto i1 : index) // cout << " " << candidates[i1].foundHits(); From 9b8c5d13b1543d727a519fa3f333f33551a60519 Mon Sep 17 00:00:00 2001 From: Vincenzo Innocente Date: Thu, 23 May 2024 12:08:49 +0200 Subject: [PATCH 033/237] fix misspellings --- .../python/trajectoryBuilderForConversions_cfi.py | 2 ++ RecoTracker/CkfPattern/src/CkfTrajectoryBuilder.cc | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/RecoEgamma/EgammaPhotonProducers/python/trajectoryBuilderForConversions_cfi.py b/RecoEgamma/EgammaPhotonProducers/python/trajectoryBuilderForConversions_cfi.py index 183650f43c4b9..c8d064187a5e7 100644 --- a/RecoEgamma/EgammaPhotonProducers/python/trajectoryBuilderForConversions_cfi.py +++ b/RecoEgamma/EgammaPhotonProducers/python/trajectoryBuilderForConversions_cfi.py @@ -17,6 +17,8 @@ trajectoryFilter = dict(refToPSet_ = 'TrajectoryFilterForConversions'), maxCand = 5, lostHitPenalty = 30., + foundHitBonus = 10., + minHitForDoubleBonus = 8, intermediateCleaning = True, alwaysUseInvalidHits = True, seedAs5DHit = False diff --git a/RecoTracker/CkfPattern/src/CkfTrajectoryBuilder.cc b/RecoTracker/CkfPattern/src/CkfTrajectoryBuilder.cc index dbfb957650e29..8c8215044628a 100644 --- a/RecoTracker/CkfPattern/src/CkfTrajectoryBuilder.cc +++ b/RecoTracker/CkfPattern/src/CkfTrajectoryBuilder.cc @@ -41,7 +41,7 @@ CkfTrajectoryBuilder::CkfTrajectoryBuilder(const edm::ParameterSet& conf, theMaxCand = conf.getParameter("maxCand"); theLostHitPenalty = conf.getParameter("lostHitPenalty"); theFoundHitBonus = conf.getParameter("foundHitBonus"); - theMinHitForDoubleBonus = conf.getParameter("minHitForDoubleBounus"); + theMinHitForDoubleBonus = conf.getParameter("minHitForDoubleBonus"); theIntermediateCleaning = conf.getParameter("intermediateCleaning"); theAlwaysUseInvalidHits = conf.getParameter("alwaysUseInvalidHits"); } @@ -51,7 +51,7 @@ void CkfTrajectoryBuilder::fillPSetDescription(edm::ParameterSetDescription& iDe iDesc.add("maxCand", 5); iDesc.add("lostHitPenalty", 30.); iDesc.add("foundHitBonus", 10.); - iDesc.add("minHitForDoubleBounus", 8); + iDesc.add("minHitForDoubleBonus", 8); iDesc.add("intermediateCleaning", true); iDesc.add("alwaysUseInvalidHits", true); From 3457dcbef74177b64bf427a1258f6fd8f657f2b6 Mon Sep 17 00:00:00 2001 From: Vincenzo Innocente Date: Thu, 23 May 2024 15:13:39 +0200 Subject: [PATCH 034/237] introduce HLT modifier --- HLTrigger/Configuration/python/customizeHLTforCMSSW.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/HLTrigger/Configuration/python/customizeHLTforCMSSW.py b/HLTrigger/Configuration/python/customizeHLTforCMSSW.py index b35dfef990fec..a888039d66c0f 100644 --- a/HLTrigger/Configuration/python/customizeHLTforCMSSW.py +++ b/HLTrigger/Configuration/python/customizeHLTforCMSSW.py @@ -268,6 +268,14 @@ def customizeHLTfor44576(process): break return process + +def customizeHLTfor45023(process): + for pset in process.psets.values(): + if hasattr(pset, 'ComponentType') and pset.ComponentType == 'CkfTrajectoryBuilder': + pset.foundHitBonus = cms.double(0.0) + pset.minHitForDoubleBonus = cms.int32(9999) + return process + # CMSSW version specific customizations def customizeHLTforCMSSW(process, menuType="GRun"): @@ -278,5 +286,6 @@ def customizeHLTforCMSSW(process, menuType="GRun"): process = checkHLTfor43774(process) process = customizeHLTfor44576(process) + process = customizeHLTfor45023(process) return process From 5f5deb314a1e58404c6e094184a33578d43521e3 Mon Sep 17 00:00:00 2001 From: Junghwan John Goh Date: Thu, 23 May 2024 16:13:57 +0200 Subject: [PATCH 035/237] recover the residual plots, probably with different names --- .../MuonRPCDigis/interface/RPCDigiValid.h | 10 ++ Validation/MuonRPCDigis/src/RPCDigiValid.cc | 99 ++++++++++++++++++- 2 files changed, 107 insertions(+), 2 deletions(-) diff --git a/Validation/MuonRPCDigis/interface/RPCDigiValid.h b/Validation/MuonRPCDigis/interface/RPCDigiValid.h index 2b9cb52fd9c60..b7896a53b6c4c 100644 --- a/Validation/MuonRPCDigis/interface/RPCDigiValid.h +++ b/Validation/MuonRPCDigis/interface/RPCDigiValid.h @@ -47,6 +47,16 @@ class RPCDigiValid : public DQMEDAnalyzer { // Timing information MonitorElement *hDigiTimeAll_, *hDigiTime_, *hDigiTimeIRPC_, *hDigiTimeNoIRPC_; + // Multiplicity plots + MonitorElement *hNSimHitPerRoll_, *hNDigiPerRoll_; + + // Residual plots + MonitorElement *hRes_; + std::map hResBarrelLayers_; + std::map hResBarrelWheels_; + std::map hResEndcapDisks_; + std::map hResEndcapRings_; + // Tokens for accessing run data. Used for passing to edm::Event. - stanislav edm::EDGetTokenT simHitToken_; edm::EDGetTokenT rpcDigiToken_; diff --git a/Validation/MuonRPCDigis/src/RPCDigiValid.cc b/Validation/MuonRPCDigis/src/RPCDigiValid.cc index 8ede470d311f1..6ae4f5921d34f 100644 --- a/Validation/MuonRPCDigis/src/RPCDigiValid.cc +++ b/Validation/MuonRPCDigis/src/RPCDigiValid.cc @@ -39,11 +39,17 @@ void RPCDigiValid::analyze(const Event &event, const EventSetup &eventSetup) { event.getByToken(rpcDigiToken_, rpcDigisHandle); // loop over Simhit + std::map> detToSimHitXsMap; for (auto simIt = simHitHandle->begin(); simIt != simHitHandle->end(); ++simIt) { const RPCDetId rsid = simIt->detUnitId(); const RPCRoll *roll = dynamic_cast(rpcGeom->roll(rsid)); if (!roll) continue; + + if (detToSimHitXsMap.find(roll) == detToSimHitXsMap.end()) + detToSimHitXsMap[roll] = std::vector(); + detToSimHitXsMap[roll].push_back(simIt->localPosition().x()); + const int region = rsid.region(); const GlobalPoint gp = roll->toGlobal(simIt->localPosition()); @@ -70,7 +76,12 @@ void RPCDigiValid::analyze(const Event &event, const EventSetup &eventSetup) { match->second->Fill(gp.x(), gp.y()); } } + for (auto detToSimHitXs : detToSimHitXsMap) { + hNSimHitPerRoll_->Fill(detToSimHitXs.second.size()); + } + // loop over Digis + std::map> detToDigiXsMap; for (auto detUnitIt = rpcDigisHandle->begin(); detUnitIt != rpcDigisHandle->end(); ++detUnitIt) { const RPCDetId rsid = (*detUnitIt).first; const RPCRoll *roll = dynamic_cast(rpcGeom->roll(rsid)); @@ -120,6 +131,56 @@ void RPCDigiValid::analyze(const Event &event, const EventSetup &eventSetup) { else hDigiTimeNoIRPC_->Fill(digiTime); } + + // Keep digi position + const double digiX = roll->centreOfStrip(digiIt->strip()).x(); + if (detToDigiXsMap.find(roll) == detToDigiXsMap.end()) + detToDigiXsMap[roll] = std::vector(); + detToDigiXsMap[roll].push_back(digiX); + } + } + for (auto detToDigiXs : detToDigiXsMap) { + const auto digiXs = detToDigiXs.second; + const int nDigi = digiXs.size(); + hNDigiPerRoll_->Fill(nDigi); + + // Fill residual plots, only for nDigi==1 and nSimHit==1 + const auto roll = detToDigiXs.first; + const auto detId = roll->id(); + if (nDigi != 1) + continue; + if (detToSimHitXsMap.find(roll) == detToSimHitXsMap.end()) + continue; + + const auto simHitXs = detToSimHitXsMap[roll]; + const int nSimHit = simHitXs.size(); + if (nSimHit != 1) + continue; + + const double dx = digiXs[0] - simHitXs[0]; + hRes_->Fill(dx); + if (roll->isBarrel()) { + const int wheel = detId.ring(); // ring() is wheel number for Barrel + const int station = detId.station(); + const int layer = detId.layer(); + const int stla = (station <= 2) ? (2 * (station - 1) + layer) : (station + 2); + + auto matchLayer = hResBarrelLayers_.find(stla); + if (matchLayer != hResBarrelLayers_.end()) + matchLayer->second->Fill(dx); + + auto matchWheel = hResBarrelWheels_.find(wheel); + if (matchWheel != hResBarrelWheels_.end()) + matchWheel->second->Fill(dx); + } else { + const int disk = detId.region() * detId.station(); + auto matchDisk = hResEndcapDisks_.find(disk); + if (matchDisk != hResEndcapDisks_.end()) + matchDisk->second->Fill(dx); + + auto matchRing = hResEndcapRings_.find(detId.ring()); + if (matchRing != hResEndcapRings_.end()) + matchRing->second->Fill(dx); } } } @@ -144,8 +205,8 @@ void RPCDigiValid::bookHistograms(DQMStore::IBooker &booker, edm::Run const &run // XY plots hXY_Barrel_ = booker.book2D("XY_Barrel", "X-Y view of Barrel", nbinsXY, -maxXY, maxXY, nbinsXY, -maxXY, maxXY); for (int disk = 1; disk <= 4; ++disk) { - const std::string meNameP = fmt::format("XY_EndcapP{:1d}", disk); - const std::string meNameN = fmt::format("XY_EndcapN{:1d}", disk); + const std::string meNameP = fmt::format("XY_Endcap_p{:1d}", disk); + const std::string meNameN = fmt::format("XY_Endcap_m{:1d}", disk); const std::string meTitleP = fmt::format("X-Y view of Endcap{:+1d};X (cm);Y (cm)", disk); const std::string meTitleN = fmt::format("X-Y view of Endcap{:+1d};X (cm);Y (cm)", -disk); hXY_Endcap_[disk] = booker.book2D(meNameP, meTitleP, nbinsXY, -maxXY, maxXY, nbinsXY, -maxXY, maxXY); @@ -177,4 +238,38 @@ void RPCDigiValid::bookHistograms(DQMStore::IBooker &booker, edm::Run const &run hDigiTime_ = booker.book1D("DigiTime", "Digi time only with timing information;Digi time (ns)", 100, -12.5, 12.5); hDigiTimeIRPC_ = booker.book1D("DigiTimeIRPC", "IRPC Digi time;Digi time (ns)", 100, -12.5, 12.5); hDigiTimeNoIRPC_ = booker.book1D("DigiTimeNoIRPC", "non-IRPC Digi time;Digi time (ns)", 100, -12.5, 12.5); + + // SimHit and Digi multiplicity per roll + hNSimHitPerRoll_ = booker.book1D("NSimHitPerRoll", "SimHit multiplicity per Roll;Multiplicity", 10, 0, 10); + hNDigiPerRoll_ = booker.book1D("NDigiPerRoll", "Digi multiplicity per Roll;Multiplicity", 10, 0, 10); + + // Residual of SimHit-Digi x-position + hRes_ = booker.book1D("Digi_SimHit_Difference", "Digi-SimHit difference;dx (cm)", 100, -8, 8); + + for (int layer = 1; layer <= 6; ++layer) { + const std::string meName = fmt::format("Residual_Barrel_Layer{:1d}", layer); + const std::string meTitle = fmt::format("Residual of Barrel Layer{:1d};dx (cm)", layer); + hResBarrelLayers_[layer] = booker.book1D(meName, meTitle, 100, -8, 8); + } + + hResBarrelWheels_[-2] = booker.book1D("Residual_Barrel_Wheel_m2", "Residual of Barrel Wheel-2;dx (cm)", 100, -8, 8); + hResBarrelWheels_[-1] = booker.book1D("Residual_Barrel_Wheel_m1", "Residual of Barrel Wheel-1;dx (cm)", 100, -8, 8); + hResBarrelWheels_[+0] = booker.book1D("Residual_Barrel_Wheel_00", "Residual of Barrel Wheel 0;dx (cm)", 100, -8, 8); + hResBarrelWheels_[+1] = booker.book1D("Residual_Barrel_Wheel_p1", "Residual of Barrel Wheel+1;dx (cm)", 100, -8, 8); + hResBarrelWheels_[+2] = booker.book1D("Residual_Barrel_Wheel_p2", "Residual of Barrel Wheel+2;dx (cm)", 100, -8, 8); + + for (int disk = 1; disk <= 4; ++disk) { + const std::string meNameP = fmt::format("Residual_Endcap_Disk_p{:1d}", disk); + const std::string meNameN = fmt::format("Residual_Endcap_Disk_m{:1d}", disk); + const std::string meTitleP = fmt::format("Residual of Endcap Disk{:+1d};dx (cm)", disk); + const std::string meTitleN = fmt::format("Residual of Endcap Disk{:+1d};dx (cm)", -disk); + hResEndcapDisks_[+disk] = booker.book1D(meNameP, meTitleP, 100, -8, 8); + hResEndcapDisks_[-disk] = booker.book1D(meNameN, meTitleN, 100, -8, 8); + } + + for (int ring = 1; ring <= 3; ++ring) { + const std::string meName = fmt::format("Residual_Endcap_Ring{:1d}", ring); + const std::string meTitle = fmt::format("Residual of Endcap Ring{:1d};dx (cm)", ring); + hResEndcapRings_[ring] = booker.book1D(meName, meTitle, 100, -8, 8); + } } From 948fd546f27c1de7a31d2acc101fec20b9a89774 Mon Sep 17 00:00:00 2001 From: Karol Bunkowski Date: Thu, 23 May 2024 19:52:05 +0200 Subject: [PATCH 036/237] possibility of configuring the OMTF emulator directly from XMLs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit OMTFReconstruction.h and OMTFReconstruction.cc The possibility of configuring the OMTF emulator directly from the config XML is added. When both patternsXMLFile and configXMLFile are given from the python config of the simOmtfDigis or simOmtfPhase2Digis, the L1TMuonOverlapParams are read directly from these files, and the L1TMuonOverlapPhase1ParamsESProducer is not needed. Otherwise, the L1TMuonOverlapParams are obtained from the eventSetup (so from the DB, or from the L1TMuonOverlapPhase1ParamsESProducer - if it is defined). L1Trigger/L1TMuonOverlapPhase2/python/fakeOmtfParamsPhase2_cff.py is removed, as when it is used, the L1TMuonOverlapPhase1 gets this config as well. L1Trigger/L1TMuonOverlapPhase2/python/simOmtfPhase2Digis_extrapol_cfi.py is moved to simOmtfPhase2Digis_cfi.py, as this is the default configuration (besides, there should be only one cfi for a given module). L1Trigger/L1TMuonOverlapPhase1/src/Omtf/OMTFProcessor.cc line trackAddr[3] = myCand->getGpResultUnconstr().getPdfSumUnconstr(); is removed, as uGMT expects 3 entries in the TrackAddress (when there were 4, uGMT was generating a warning). L1Trigger/L1TMuonOverlapPhase2/test - runMuonOverlap*.py are corrected --- .../interface/Omtf/OMTFReconstruction.h | 2 + .../src/Omtf/OMTFProcessor.cc | 8 +- .../src/Omtf/OMTFReconstruction.cc | 80 ++++--- .../python/fakeOmtfParamsPhase2_cff.py | 17 -- .../python/simOmtfPhase2Digis_cfi.py | 29 +-- .../python/simOmtfPhase2Digis_extrapol_cfi.py | 57 ----- ...OverlapPatternGeneratorClassProb_phase2.py | 39 +--- ...uonOverlapPatternGenerator_displ_phase2.py | 47 +--- .../runMuonOverlapPatternGenerator_phase2.py | 216 +++++++++--------- .../expert/runMuonOverlap_NN_Regression_FP.py | 61 ++--- .../test/runMuonOverlap.py | 97 +++----- 11 files changed, 258 insertions(+), 395 deletions(-) delete mode 100644 L1Trigger/L1TMuonOverlapPhase2/python/fakeOmtfParamsPhase2_cff.py delete mode 100644 L1Trigger/L1TMuonOverlapPhase2/python/simOmtfPhase2Digis_extrapol_cfi.py diff --git a/L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/OMTFReconstruction.h b/L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/OMTFReconstruction.h index b4a1ffa0f0e87..868077a7f755a 100644 --- a/L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/OMTFReconstruction.h +++ b/L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/OMTFReconstruction.h @@ -67,6 +67,8 @@ class OMTFReconstruction { int bxMin, bxMax; ///OMTF objects + //omtfParams are created only if they are read from the xml file in beginRun(). If the params goes from eventSetup, omtfParams are null + unique_ptr omtfParams; unique_ptr omtfConfig; unique_ptr inputMaker; diff --git a/L1Trigger/L1TMuonOverlapPhase1/src/Omtf/OMTFProcessor.cc b/L1Trigger/L1TMuonOverlapPhase1/src/Omtf/OMTFProcessor.cc index 7a8b0545d3c69..cc54c465a2201 100644 --- a/L1Trigger/L1TMuonOverlapPhase1/src/Omtf/OMTFProcessor.cc +++ b/L1Trigger/L1TMuonOverlapPhase1/src/Omtf/OMTFProcessor.cc @@ -95,7 +95,6 @@ void OMTFProcessor::init(const edm::ParameterSet& edmCfg, edm edm::LogVerbatim("OMTFReconstruction") << "useFloatingPointExtrapolation " << useFloatingPointExtrapolation << std::endl; - edm::LogVerbatim("OMTFReconstruction") << "extrapolFactorsFilename " << extrapolFactorsFilename << std::endl; } template @@ -294,7 +293,6 @@ std::vector OMTFProcessor::getFinalcan //check if it matters if it needs to be here as well trackAddr[1] = myCand->getRefLayer(); trackAddr[2] = myCand->getDisc(); - trackAddr[3] = myCand->getGpResultUnconstr().getPdfSumUnconstr(); if (candidate.hwPt() > 0 || candidate.hwPtUnconstrained() > 0) { candidate.setTrackAddress(trackAddr); candidate.setTFIdentifiers(iProcessor, mtfType); @@ -909,8 +907,8 @@ void OMTFProcessor::loadExtrapolFactors(const std::string& fi int iLayer = lutNode.second.get(".Layer"); std::string keyType = lutNode.second.get(".KeyType"); - edm::LogVerbatim("OMTFReconstruction") - << "iRefLayer " << iRefLayer << " iLayer " << iLayer << " keyType " << keyType << std::endl; + LogTrace("OMTFReconstruction") << "iRefLayer " << iRefLayer << " iLayer " << iLayer << " keyType " << keyType + << std::endl; auto& valueNodes = lutNode.second; for (boost::property_tree::ptree::value_type& valueNode : valueNodes) { @@ -918,7 +916,7 @@ void OMTFProcessor::loadExtrapolFactors(const std::string& fi int key = valueNode.second.get(".key"); float value = valueNode.second.get(".value"); extrapolFactors.at(iRefLayer).at(iLayer)[key] = value; - edm::LogVerbatim("OMTFReconstruction") << "key " << key << " value " << value << std::endl; + LogTrace("OMTFReconstruction") << "key " << key << " value " << value << std::endl; } } } diff --git a/L1Trigger/L1TMuonOverlapPhase1/src/Omtf/OMTFReconstruction.cc b/L1Trigger/L1TMuonOverlapPhase1/src/Omtf/OMTFReconstruction.cc index 66bc9e0d809d2..c125f7f515648 100644 --- a/L1Trigger/L1TMuonOverlapPhase1/src/Omtf/OMTFReconstruction.cc +++ b/L1Trigger/L1TMuonOverlapPhase1/src/Omtf/OMTFReconstruction.cc @@ -64,8 +64,6 @@ void OMTFReconstruction::beginRun(edm::Run const& run, const MuonGeometryTokens& muonGeometryTokens, const edm::ESGetToken& magneticFieldEsToken, const edm::ESGetToken& propagatorEsToken) { - const L1TMuonOverlapParams* omtfParams = nullptr; - std::string processorType = "OMTFProcessor"; //GoldenPatternWithStat GoldenPattern if (edmParameterSet.exists("processorType")) { processorType = edmParameterSet.getParameter("processorType"); @@ -73,22 +71,29 @@ void OMTFReconstruction::beginRun(edm::Run const& run, bool buildPatternsFromXml = (edmParameterSet.exists("patternsXMLFile") || edmParameterSet.exists("patternsXMLFiles")); + bool readConfigFromXml = edmParameterSet.exists("configXMLFile"); + + if (buildPatternsFromXml != readConfigFromXml) + throw cms::Exception( + "OMTFReconstruction::beginRun: buildPatternsFromXml != readConfigFromXml - both patternsXMLFiles and " + "configXMLFile should be defined (or not) for the simOmtDigis or simOmtfPhase2Digis"); + edm::LogVerbatim("OMTFReconstruction") << "OMTFReconstruction::beginRun " << run.id() << " buildPatternsFromXml: " << buildPatternsFromXml << std::endl; //if the buildPatternsFromXml == false - we are making the omtfConfig and omtfProc for every run, //as the configuration my change between the runs, - //if buildPatternsFromXml == true - we assume the the entire configuration comes from phyton, - //so we do it only for the first run - if (omtfProc == nullptr || buildPatternsFromXml == false) { + if (buildPatternsFromXml == false) { if (omtfParamsRecordWatcher.check(eventSetup)) { edm::LogVerbatim("OMTFReconstruction") << "retrieving omtfParams from EventSetup" << std::endl; - omtfParams = &(eventSetup.getData(omtfParamsEsToken)); - if (!omtfParams) { - edm::LogError("OMTFReconstruction") << "Could not retrieve parameters from Event Setup" << std::endl; + const L1TMuonOverlapParams* omtfParamsFromES = &(eventSetup.getData(omtfParamsEsToken)); + if (!omtfParamsFromES) { + edm::LogError("OMTFReconstruction") << "Could not retrieve omtfParams from Event Setup" << std::endl; + throw cms::Exception("OMTFReconstruction::beginRun: Could not retrieve omtfParams from Event Setup"); } - omtfConfig->configure(omtfParams); + + omtfConfig->configure(omtfParamsFromES); //the parameters can be overwritten from the python config omtfConfig->configureFromEdmParameterSet(edmParameterSet); @@ -96,19 +101,45 @@ void OMTFReconstruction::beginRun(edm::Run const& run, inputMaker->initialize(edmParameterSet, eventSetup, muonGeometryTokens); //patterns from the edm::EventSetup are reloaded every beginRun - if (buildPatternsFromXml == false) { - edm::LogVerbatim("OMTFReconstruction") << "getting patterns from EventSetup" << std::endl; - if (processorType == "OMTFProcessor") { - omtfProc = std::make_unique >( - omtfConfig.get(), edmParameterSet, eventSetup, omtfParams); - omtfProc->printInfo(); - } + //therefore OMTFProcessor is re-created here + edm::LogVerbatim("OMTFReconstruction") << "getting patterns from EventSetup" << std::endl; + if (processorType == "OMTFProcessor") { + omtfProc = std::make_unique >( + omtfConfig.get(), edmParameterSet, eventSetup, omtfParamsFromES); + omtfProc->printInfo(); } } } - //if we read the patterns directly from the xml, we do it only once, at the beginning of the first run, not every run + //if buildPatternsFromXml == true - the entire configuration (patterns and hwToLogicLayer) comes from phyton, + //so we read it only once, at the beginning of the first run, not every run if (omtfProc == nullptr && buildPatternsFromXml) { + std::string fName = edmParameterSet.getParameter("configXMLFile").fullPath(); + + edm::LogVerbatim("OMTFReconstruction") + << "OMTFReconstruction::beginRun - reading config from file: " << fName << std::endl; + + XMLConfigReader xmlConfigReader; + xmlConfigReader.setConfigFile(fName); + + omtfParams.reset(new L1TMuonOverlapParams()); + xmlConfigReader.readConfig(omtfParams.get()); + + //getPatternsVersion() parses the entire patterns xml - si it is very inefficient + //moreover, PatternsVersion is not used anywhere + //Therefore we we dont use xmlPatternReader.getPatternsVersion(); but set patternsVersion to 0 + unsigned int patternsVersion = 0; + unsigned int fwVersion = omtfParams->fwVersion(); + omtfParams->setFwVersion((fwVersion << 16) + patternsVersion); + + omtfConfig->configure(omtfParams.get()); + + //the parameters can be overwritten from the python config + omtfConfig->configureFromEdmParameterSet(edmParameterSet); + + inputMaker->initialize(edmParameterSet, eventSetup, muonGeometryTokens); + + //reading patterns from the xml---------------------------------------------------------- std::vector patternsXMLFiles; if (edmParameterSet.exists("patternsXMLFile")) { @@ -122,8 +153,6 @@ void OMTFReconstruction::beginRun(edm::Run const& run, for (auto& patternsXMLFile : patternsXMLFiles) edm::LogVerbatim("OMTFReconstruction") << "reading patterns from " << patternsXMLFile << std::endl; - XMLConfigReader xmlReader; - std::string patternType = "GoldenPattern"; //GoldenPatternWithStat GoldenPattern if (edmParameterSet.exists("patternType")) { patternType = edmParameterSet.getParameter("patternType"); @@ -136,15 +165,14 @@ void OMTFReconstruction::beginRun(edm::Run const& run, omtfConfig.get(), edmParameterSet, eventSetup, - xmlReader.readPatterns(*omtfParams, patternsXMLFiles, false)); + xmlConfigReader.readPatterns(*omtfParams, patternsXMLFiles, false)); } else { //in principle should not happen throw cms::Exception("OMTFReconstruction::beginRun: omtfParams is nullptr"); } } - edm::LogVerbatim("OMTFReconstruction") - << "OMTFProcessor constructed. processorType " << processorType << ". GoldenPattern type: " << patternType - << " nProcessors " << omtfConfig->nProcessors() << std::endl; + edm::LogVerbatim("OMTFReconstruction") << "OMTFProcessor constructed. processorType " << processorType + << ". GoldenPattern type: " << patternType << std::endl; } else if (patternType == "GoldenPatternWithStat") { //pattern generation is only possible if the processor is constructed only once per job //PatternGenerator modifies the patterns!!! @@ -154,7 +182,7 @@ void OMTFReconstruction::beginRun(edm::Run const& run, omtfConfig.get(), edmParameterSet, eventSetup, - xmlReader.readPatterns(*omtfParams, patternsXMLFiles, false)); + xmlConfigReader.readPatterns(*omtfParams, patternsXMLFiles, false)); } else { //in principle should not happen throw cms::Exception("OMTFReconstruction::beginRun: omtfParams is nullptr"); } @@ -205,7 +233,7 @@ void OMTFReconstruction::addObservers( if (edmParameterSet.getParameter("eventCaptureDebug")) { observers.emplace_back(std::make_unique( edmParameterSet, omtfConfig.get(), candidateSimMuonMatcher, muonGeometryTokens - //, &(omtfProcGoldenPat->getPatterns() ) + //&(omtfProcGoldenPat->getPatterns() ), //watch out, will crash if the proc is re-constructed from the DB after L1TMuonOverlapParamsRcd change )); } @@ -228,7 +256,7 @@ void OMTFReconstruction::addObservers( if (edmParameterSet.getParameter("eventCaptureDebug")) { observers.emplace_back(std::make_unique( edmParameterSet, omtfConfig.get(), candidateSimMuonMatcher, muonGeometryTokens - //&(omtfProcGoldenPat->getPatterns() ) + //&(omtfProcGoldenPat->getPatterns() ), //watch out, will crash if the proc is re-constructed from the DB after L1TMuonOverlapParamsRcd change )); } diff --git a/L1Trigger/L1TMuonOverlapPhase2/python/fakeOmtfParamsPhase2_cff.py b/L1Trigger/L1TMuonOverlapPhase2/python/fakeOmtfParamsPhase2_cff.py deleted file mode 100644 index 421e4becc9d33..0000000000000 --- a/L1Trigger/L1TMuonOverlapPhase2/python/fakeOmtfParamsPhase2_cff.py +++ /dev/null @@ -1,17 +0,0 @@ -import FWCore.ParameterSet.Config as cms - -omtfParamsSource = cms.ESSource( - "EmptyESSource", - recordName = cms.string('L1TMuonOverlapParamsRcd'), - iovIsRunNotTime = cms.bool(True), - firstValid = cms.vuint32(1) -) - -###OMTF ESProducer. Fills CondFormats from XML files. -omtfParamsPhase2 = cms.ESProducer( - "L1TMuonOverlapPhase1ParamsESProducer", - patternsXMLFiles = cms.VPSet( - cms.PSet(patternsXMLFile = cms.FileInPath("L1Trigger/L1TMuon/data/omtf_config/Patterns_ExtraplMB1nadMB2DTQualAndEtaFixedP_ValueP1Scale_t20_v1_SingleMu_iPt_and_OneOverPt_classProb17_recalib2_minDP0.xml")), - ), - configXMLFile = cms.FileInPath("L1Trigger/L1TMuon/data/omtf_config/hwToLogicLayer_0x0209.xml"), -) diff --git a/L1Trigger/L1TMuonOverlapPhase2/python/simOmtfPhase2Digis_cfi.py b/L1Trigger/L1TMuonOverlapPhase2/python/simOmtfPhase2Digis_cfi.py index 4d09684bc869c..c27335f7bf28b 100644 --- a/L1Trigger/L1TMuonOverlapPhase2/python/simOmtfPhase2Digis_cfi.py +++ b/L1Trigger/L1TMuonOverlapPhase2/python/simOmtfPhase2Digis_cfi.py @@ -1,16 +1,19 @@ import FWCore.ParameterSet.Config as cms - ###OMTF emulator configuration -simOmtfPhase2Digis = cms.EDProducer("L1TMuonOverlapPhase2TrackProducer", - +simOmtfPhase2Digis = cms.EDProducer("L1TMuonOverlapPhase2TrackProducer", srcDTPh = cms.InputTag('simDtTriggerPrimitiveDigis'), srcDTTh = cms.InputTag('simDtTriggerPrimitiveDigis'), srcCSC = cms.InputTag('simCscTriggerPrimitiveDigis','MPCSORTED'), srcRPC = cms.InputTag('simMuonRPCDigis'), srcDTPhPhase2 = cms.InputTag('dtTriggerPhase2PrimitiveDigis'), - - simTracksTag = cms.InputTag('g4SimHits'), + srcDTThPhase2 = cms.InputTag('dtTriggerPhase2PrimitiveDigis'), + + ## XML / PATTERNS file: + configXMLFile = cms.FileInPath("L1Trigger/L1TMuon/data/omtf_config/hwToLogicLayer_0x0209.xml"), + patternsXMLFile = cms.FileInPath("L1Trigger/L1TMuon/data/omtf_config/Patterns_ExtraplMB1nadMB2DTQualAndEtaFixedP_ValueP1Scale_t20_v1_SingleMu_iPt_and_OneOverPt_classProb17_recalib2_minDP0.xml"), + extrapolFactorsFilename = cms.FileInPath("L1Trigger/L1TMuon/data/omtf_config/ExtrapolationFactors_ExtraplMB1nadMB2DTQual_ValueP1Scale_t20.xml"), + dumpResultToXML = cms.bool(False), dumpDetailedResultToXML = cms.bool(False), XMLDumpFileName = cms.string("TestEvents.xml"), @@ -18,7 +21,7 @@ readEventsFromXML = cms.bool(False), eventsXMLFiles = cms.vstring("TestEvents.xml"), - + dropRPCPrimitives = cms.bool(False), dropCSCPrimitives = cms.bool(False), @@ -42,13 +45,13 @@ stubEtaEncoding = cms.string("valueP1Scale"), #TODO change to valueP1Scale when InputMakerPhase2 is modifiwed - usePhiBExtrapolationFromMB1 = cms.bool(False), - usePhiBExtrapolationFromMB2 = cms.bool(False), - useStubQualInExtr = cms.bool(False), - useEndcapStubsRInExtr = cms.bool(False), + usePhiBExtrapolationFromMB1 = cms.bool(True), + usePhiBExtrapolationFromMB2 = cms.bool(True), + useStubQualInExtr = cms.bool(True), + useEndcapStubsRInExtr = cms.bool(True), useFloatingPointExtrapolation = cms.bool(False), - + sorterType = cms.string("byLLH"), - ghostBusterType = cms.string("GhostBusterPreferRefDt"), # byLLH byRefLayer GhostBusterPreferRefDt - goldenPatternResultFinalizeFunction = cms.int32(9) + ghostBusterType = cms.string("byRefLayer"), # byLLH byRefLayer GhostBusterPreferRefDt + goldenPatternResultFinalizeFunction = cms.int32(10) ) diff --git a/L1Trigger/L1TMuonOverlapPhase2/python/simOmtfPhase2Digis_extrapol_cfi.py b/L1Trigger/L1TMuonOverlapPhase2/python/simOmtfPhase2Digis_extrapol_cfi.py deleted file mode 100644 index 141fd8c3094f7..0000000000000 --- a/L1Trigger/L1TMuonOverlapPhase2/python/simOmtfPhase2Digis_extrapol_cfi.py +++ /dev/null @@ -1,57 +0,0 @@ -import FWCore.ParameterSet.Config as cms - -###OMTF emulator configuration -simOmtfPhase2Digis = cms.EDProducer("L1TMuonOverlapPhase2TrackProducer", - - srcDTPh = cms.InputTag('simDtTriggerPrimitiveDigis'), - srcDTTh = cms.InputTag('simDtTriggerPrimitiveDigis'), - srcCSC = cms.InputTag('simCscTriggerPrimitiveDigis','MPCSORTED'), - srcRPC = cms.InputTag('simMuonRPCDigis'), - srcDTPhPhase2 = cms.InputTag('dtTriggerPhase2PrimitiveDigis'), - srcDTThPhase2 = cms.InputTag('dtTriggerPhase2PrimitiveDigis'), - - dumpResultToXML = cms.bool(False), - dumpDetailedResultToXML = cms.bool(False), - XMLDumpFileName = cms.string("TestEvents.xml"), - dumpGPToXML = cms.bool(False), - readEventsFromXML = cms.bool(False), - eventsXMLFiles = cms.vstring("TestEvents.xml"), - - - dropRPCPrimitives = cms.bool(False), - dropCSCPrimitives = cms.bool(False), - - dropDTPrimitives = cms.bool(True), - usePhase2DTPrimitives = cms.bool(True), #if usePhase2DTPrimitives is True, dropDTPrimitives must be True as well - - processorType = cms.string("OMTFProcessor"), - - #if commented the default values are 0-0 - #-3 to 4 is the range of the OMTF DAQ readout, so should be used e.g. in the DQM data to emulator comparison - bxMin = cms.int32(0), - bxMax = cms.int32(0), - - noHitValueInPdf = cms.bool(True), - minDtPhiQuality = cms.int32(2), - minDtPhiBQuality = cms.int32(4), - - dtRefHitMinQuality = cms.int32(4), - - dtPhiBUnitsRad = cms.int32(1024), #2048 is the orginal phase2 scale, 512 is the phase1 scale - - stubEtaEncoding = cms.string("valueP1Scale"), #TODO change to valueP1Scale when InputMakerPhase2 is modifiwed - - usePhiBExtrapolationFromMB1 = cms.bool(True), - usePhiBExtrapolationFromMB2 = cms.bool(True), - useStubQualInExtr = cms.bool(True), - useEndcapStubsRInExtr = cms.bool(True), - useFloatingPointExtrapolation = cms.bool(False), - - ## XML / PATTERNS file: - patternsXMLFile = cms.FileInPath("L1Trigger/L1TMuon/data/omtf_config/Patterns_ExtraplMB1nadMB2DTQualAndEtaFixedP_ValueP1Scale_t20_v1_SingleMu_iPt_and_OneOverPt_classProb17_recalib2_minDP0.xml"), - extrapolFactorsFilename = cms.FileInPath("L1Trigger/L1TMuon/data/omtf_config/ExtrapolationFactors_ExtraplMB1nadMB2DTQual_ValueP1Scale_t20.xml"), - - sorterType = cms.string("byLLH"), - ghostBusterType = cms.string("byRefLayer"), # byLLH byRefLayer GhostBusterPreferRefDt - goldenPatternResultFinalizeFunction = cms.int32(10) -) diff --git a/L1Trigger/L1TMuonOverlapPhase2/test/expert/runMuonOverlapPatternGeneratorClassProb_phase2.py b/L1Trigger/L1TMuonOverlapPhase2/test/expert/runMuonOverlapPatternGeneratorClassProb_phase2.py index 26d85b1882c8d..1424f262809c4 100644 --- a/L1Trigger/L1TMuonOverlapPhase2/test/expert/runMuonOverlapPatternGeneratorClassProb_phase2.py +++ b/L1Trigger/L1TMuonOverlapPhase2/test/expert/runMuonOverlapPatternGeneratorClassProb_phase2.py @@ -11,12 +11,14 @@ verbose = True -versionIn = "ExtraplMB1nadMB2DTQualAndEtaFixedP_ValueP1Scale_t20_v1_SingleMu_iPt_and_OneOverPt" +versionIn = "ExtraplMB1nadMB2DTQualAndRFixedP_ValueP1Scale_t25c__mcWaw2023_OneOverPt_and_iPt2_mcWaw2023_OneOverPt_and_iPt2" #versionIn = "ExtraplMB1nadMB2DTQualAndEtaFixedP_ValueP1Scale_t20_SingleMu_mcWaw2023_OneOverPt" #versionIn = "ExtraplMB1nadMB2DTQualAndEtaValueP1Scale_t18" #versionIn = "0x00011_oldSample_3_30Files" -versionOut = versionIn + "_classProb17_recalib2_minDP0" +#versionOut = versionIn + "_classProb17_recalib2" #_classProb17_recalib2_minDP0 + +versionOut = "ExtraplMB1nadMB2DTQualAndRFixedP_ValueP1Scale_t25c_" + "_classProb17_recalib2" if verbose: process.MessageLogger = cms.Service("MessageLogger", @@ -50,25 +52,22 @@ #SkipEvent = cms.untracked.vstring('ProductNotFound') ) -# PostLS1 geometry used -process.load('Configuration.Geometry.GeometryExtended2015Reco_cff') -process.load('Configuration.Geometry.GeometryExtended2015_cff') +process.load('Configuration.Geometry.GeometryExtended2026D49Reco_cff') +process.load('Configuration.Geometry.GeometryExtended2026D49_cff') # import of standard configurations process.load('Configuration.StandardSequences.Services_cff') process.load('SimGeneral.HepPDTESSource.pythiapdt_cfi') process.load('Configuration.EventContent.EventContent_cff') process.load('SimGeneral.MixingModule.mixNoPU_cfi') -#process.load('Configuration.Geometry.GeometryExtended2026D41Reco_cff') -#process.load('Configuration.Geometry.GeometryExtended2026D41_cff') + process.load('Configuration.StandardSequences.MagneticField_cff') #process.load('Configuration.StandardSequences.SimL1Emulator_cff') process.load('Configuration.StandardSequences.EndOfProcess_cff') process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff') from Configuration.AlCa.GlobalTag import GlobalTag -#process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:upgradePLS3', '') -process.GlobalTag = GlobalTag(process.GlobalTag, '103X_upgrade2023_realistic_v2', '') +process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:phase2_realistic', '') path = '/eos/user/k/kbunkow/cms_data/SingleMuFullEta/721_FullEta_v4/' #old sample, but very big #path = '/eos/user/a/akalinow/Data/SingleMu/9_3_14_FullEta_v2/' #new sample, but small and more noisy @@ -112,21 +111,6 @@ process.maxEvents = cms.untracked.PSet( input = cms.untracked.int32(1)) - -####Event Setup Producer -process.load('L1Trigger.L1TMuonOverlapPhase1.fakeOmtfParams_cff') -process.omtfParams.configXMLFile = cms.FileInPath("L1Trigger/L1TMuon/data/omtf_config/hwToLogicLayer_0x0009_patGen.xml") -process.omtfParams.patternsXMLFiles = cms.VPSet( - cms.PSet(patternsXMLFile = cms.FileInPath("L1Trigger/L1TMuonOverlapPhase1/test/expert/omtf/Patterns_template.xml")), ) - -process.esProd = cms.EDAnalyzer("EventSetupRecordDataGetter", - toGet = cms.VPSet( - cms.PSet(record = cms.string('L1TMuonOverlapParamsRcd'), - data = cms.vstring('L1TMuonOverlapParams')) - ), - verbose = cms.untracked.bool(False) -) - #process.TFileService = cms.Service("TFileService", fileName = cms.string('omtfAnalysis1_1.root'), closeFileFast = cms.untracked.bool(True) ) ####OMTF Emulator @@ -138,7 +122,7 @@ process.simOmtfDigis.dumpResultToXML = cms.bool(False) process.simOmtfDigis.eventCaptureDebug = cms.bool(False) -process.simOmtfDigis.patternsXMLFile = cms.FileInPath("L1Trigger/L1TMuonOverlapPhase1/test/expert/omtf/Patterns_template.xml") +process.simOmtfDigis.patternsXMLFile = cms.FileInPath("L1Trigger/L1TMuon/data/omtf_config/Patterns_template.xml") #process.simOmtfDigis.patternsXMLFile = cms.FileInPath("L1Trigger/L1TMuonOverlapPhase1/test/expert/omtf/Patterns_0x00012_oldSample_3_30Files_grouped1_classProb1_recalib.xml") #process.simOmtfDigis.patternsXMLFile = cms.FileInPath("L1Trigger/L1TMuonOverlapPhase1/test/expert/omtf/Patterns_0x00012_oldSample_3_30Files_grouped1_classProb11_recalib2.xml") #process.simOmtfDigis.patternsXMLFile = cms.FileInPath("L1Trigger/L1TMuon/data/omtf_config/Patterns_0x0009_oldSample_3_10Files_classProb2.xml") @@ -157,7 +141,7 @@ #process.simOmtfDigis.patternsROOTFile = cms.FileInPath("L1Trigger/L1TMuonOverlapPhase1/test/expert/omtf/Patterns_0x00011_oldSample_3_30Files_layerStat.root") #process.simOmtfDigis.patternsROOTFile = cms.FileInPath("L1Trigger/L1TMuonOverlapPhase1/test/expert/omtf/Patterns_layerStat_ExtraplMB1nadMB2_t14.root") #process.simOmtfDigis.patternsROOTFile = cms.FileInPath("L1Trigger/L1TMuonOverlapPhase1/test/expert/omtf/Patterns_layerStat_ExtraplMB1nadMB2FullAlgo_t16.root") -process.simOmtfDigis.patternsROOTFile = cms.FileInPath("L1Trigger/L1TMuonOverlapPhase2/test/expert/Patterns_layerStat/Patterns_layerStat_" + versionIn + ".root") +process.simOmtfDigis.patternsROOTFile = cms.FileInPath("L1Trigger/L1TMuon/data/omtf_config/Patterns_layerStat_" + versionIn + ".root") process.simOmtfDigis.patternType = cms.string("GoldenPatternWithStat") process.simOmtfDigis.generatePatterns = cms.bool(True) @@ -179,8 +163,7 @@ #process.dumpED = cms.EDAnalyzer("EventContentAnalyzer") #process.dumpES = cms.EDAnalyzer("PrintEventSetupContent") -process.L1TMuonSeq = cms.Sequence( process.esProd - + process.simOmtfDigis +process.L1TMuonSeq = cms.Sequence( process.simOmtfDigis #+ process.dumpED #+ process.dumpES ) diff --git a/L1Trigger/L1TMuonOverlapPhase2/test/expert/runMuonOverlapPatternGenerator_displ_phase2.py b/L1Trigger/L1TMuonOverlapPhase2/test/expert/runMuonOverlapPatternGenerator_displ_phase2.py index 1088d85b80877..85e275437f247 100644 --- a/L1Trigger/L1TMuonOverlapPhase2/test/expert/runMuonOverlapPatternGenerator_displ_phase2.py +++ b/L1Trigger/L1TMuonOverlapPhase2/test/expert/runMuonOverlapPatternGenerator_displ_phase2.py @@ -52,25 +52,23 @@ #SkipEvent = cms.untracked.vstring('ProductNotFound') ) -# PostLS1 geometry used -process.load('Configuration.Geometry.GeometryExtended2026D86Reco_cff') -process.load('Configuration.Geometry.GeometryExtended2026D86_cff') - # import of standard configurations process.load('Configuration.StandardSequences.Services_cff') -process.load('SimGeneral.HepPDTESSource.pythiapdt_cfi') -process.load('Configuration.EventContent.EventContent_cff') -process.load('SimGeneral.MixingModule.mixNoPU_cfi') -#process.load('Configuration.Geometry.GeometryExtended2026D41Reco_cff') -#process.load('Configuration.Geometry.GeometryExtended2026D41_cff') +#process.load('SimGeneral.HepPDTESSource.pythiapdt_cfi') +#process.load('FWCore.MessageService.MessageLogger_cfi') +#process.load('Configuration.EventContent.EventContent_cff') +#process.load('SimGeneral.MixingModule.mixNoPU_cfi') +process.load('Configuration.Geometry.GeometryExtended2026D95Reco_cff') process.load('Configuration.StandardSequences.MagneticField_cff') +#process.load('Configuration.StandardSequences.RawToDigi_cff') #process.load('Configuration.StandardSequences.SimL1Emulator_cff') +#process.load('Configuration.StandardSequences.SimPhase2L1GlobalTriggerEmulator_cff') +#process.load('L1Trigger.Configuration.Phase2GTMenus.SeedDefinitions.prototypeSeeds') process.load('Configuration.StandardSequences.EndOfProcess_cff') process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff') from Configuration.AlCa.GlobalTag import GlobalTag -#process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:upgradePLS3', '') -process.GlobalTag = GlobalTag(process.GlobalTag, '103X_upgrade2023_realistic_v2', '') +process.GlobalTag = GlobalTag(process.GlobalTag, '131X_mcRun4_realistic_v9', '') chosenFiles = [] @@ -173,32 +171,10 @@ process.dtTriggerPhase2PrimitiveDigis.dump = False process.dtTriggerPhase2PrimitiveDigis.scenario = 0 -####Event Setup Producer -process.load('L1Trigger.L1TMuonOverlapPhase1.fakeOmtfParams_cff') -process.omtfParams.configXMLFile = cms.FileInPath("L1Trigger/L1TMuon/data/omtf_config/hwToLogicLayer_0x0209_patGen.xml") - -process.omtfParams.patternsXMLFiles = cms.VPSet( - #cms.PSet(patternsXMLFile = cms.FileInPath("L1Trigger/L1TMuon/data/omtf_config/Patterns_0x0003.xml")), - #cms.PSet(patternsXMLFile = cms.FileInPath("L1Trigger/L1TMuon/data/omtf_config/Patterns_0x0009_oldSample_3_10Files_classProb1.xml") ), - cms.PSet(patternsXMLFile = cms.FileInPath("L1Trigger/L1TMuonOverlapPhase1/test/expert/omtf/Patterns_template.xml")), - #cms.PSet(patternsXMLFile = cms.FileInPath("L1Trigger/L1TMuon/data/omtf_config/Patterns_0x00012_oldSample_3_30Files_grouped1_classProb17_recalib2.xml")), - #cms.PSet(patternsXMLFile = cms.FileInPath("L1Trigger/L1TMuonOverlapPhase1/test/expert/omtf/Patterns_layerStat_ExtraplMB1nadMB2_t10_classProb17_recalib2.xml")), - ) - - - -process.esProd = cms.EDAnalyzer("EventSetupRecordDataGetter", - toGet = cms.VPSet( - cms.PSet(record = cms.string('L1TMuonOverlapParamsRcd'), - data = cms.vstring('L1TMuonOverlapParams')) - ), - verbose = cms.untracked.bool(False) -) - #process.TFileService = cms.Service("TFileService", fileName = cms.string('omtfAnalysis1_1.root'), closeFileFast = cms.untracked.bool(True) ) ####OMTF Emulator -process.load('L1Trigger.L1TMuonOverlapPhase2.simOmtfPhase2Digis_extrapol_cfi') +process.load('L1Trigger.L1TMuonOverlapPhase2.simOmtfPhase2Digis_cfi') #needed by candidateSimMuonMatcher process.load("TrackPropagation.SteppingHelixPropagator.SteppingHelixPropagatorAlong_cfi") @@ -268,8 +244,7 @@ #process.dumpED = cms.EDAnalyzer("EventContentAnalyzer") #process.dumpES = cms.EDAnalyzer("PrintEventSetupContent") -process.L1TMuonSeq = cms.Sequence( process.esProd - + process.simOmtfPhase2Digis +process.L1TMuonSeq = cms.Sequence( process.simOmtfPhase2Digis #+ process.dumpED #+ process.dumpES ) diff --git a/L1Trigger/L1TMuonOverlapPhase2/test/expert/runMuonOverlapPatternGenerator_phase2.py b/L1Trigger/L1TMuonOverlapPhase2/test/expert/runMuonOverlapPatternGenerator_phase2.py index 418ee3886df5d..c2a761120ceb1 100644 --- a/L1Trigger/L1TMuonOverlapPhase2/test/expert/runMuonOverlapPatternGenerator_phase2.py +++ b/L1Trigger/L1TMuonOverlapPhase2/test/expert/runMuonOverlapPatternGenerator_phase2.py @@ -13,10 +13,18 @@ verbose = True -filesNameLike = sys.argv[2] +filesNameLike = sys.argv[1] -version = "ExtraplMB1nadMB2DTQualAndEtaFixedP_ValueP1Scale_t20_v1_SingleMu" +runDebug = "DEBUG" # or "INFO" DEBUG + +#version = "ExtraplMB1nadMB2DTQualAndEtaFixedP_ValueP1Scale_t20_v1_SingleMu" #version = "noExtrapl_ValueP1Scale_t18_qualConverted_min4_ipT1_deltaPhiVsPhiRef_fixedDTScale" +version = "ExtraplMB1nadMB2DTQualAndRFixedP_ValueP1Scale_DT_4_4_t25c_" + filesNameLike + +regeneratedL1DT = True + +if not regeneratedL1DT : + version = version + "_noDTReGen" if verbose: process.MessageLogger = cms.Service("MessageLogger", @@ -50,114 +58,109 @@ #SkipEvent = cms.untracked.vstring('ProductNotFound') ) -# PostLS1 geometry used -process.load('Configuration.Geometry.GeometryExtended2026D86Reco_cff') -process.load('Configuration.Geometry.GeometryExtended2026D86_cff') - # import of standard configurations process.load('Configuration.StandardSequences.Services_cff') -process.load('SimGeneral.HepPDTESSource.pythiapdt_cfi') -process.load('Configuration.EventContent.EventContent_cff') -process.load('SimGeneral.MixingModule.mixNoPU_cfi') -#process.load('Configuration.Geometry.GeometryExtended2026D41Reco_cff') -#process.load('Configuration.Geometry.GeometryExtended2026D41_cff') +#process.load('SimGeneral.HepPDTESSource.pythiapdt_cfi') +#process.load('FWCore.MessageService.MessageLogger_cfi') +#process.load('Configuration.EventContent.EventContent_cff') +#process.load('SimGeneral.MixingModule.mixNoPU_cfi') +process.load('Configuration.Geometry.GeometryExtended2026D95Reco_cff') process.load('Configuration.StandardSequences.MagneticField_cff') +#process.load('Configuration.StandardSequences.RawToDigi_cff') #process.load('Configuration.StandardSequences.SimL1Emulator_cff') +#process.load('Configuration.StandardSequences.SimPhase2L1GlobalTriggerEmulator_cff') +#process.load('L1Trigger.Configuration.Phase2GTMenus.SeedDefinitions.prototypeSeeds') process.load('Configuration.StandardSequences.EndOfProcess_cff') process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff') from Configuration.AlCa.GlobalTag import GlobalTag -#process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:upgradePLS3', '') -process.GlobalTag = GlobalTag(process.GlobalTag, '103X_upgrade2023_realistic_v2', '') +process.GlobalTag = GlobalTag(process.GlobalTag, '131X_mcRun4_realistic_v9', '') chosenFiles = [] cscBx = 8 - -if filesNameLike == 'mcWaw2023' : +fileCnt = 100000 #1000 +if filesNameLike == 'mcWaw2023_OneOverPt_and_iPt2': cscBx = 8 - - file_cnt = 100000 - for iPt in [0, 1, 2] : - for charge in [0, 2] : - path = "/eos/user/a/akalinow/Data/SingleMu/12_5_2_p1_04_04_2023/SingleMu_ch" + str(charge) + "_iPt" + str(iPt) + "_12_5_2_p1_04_04_2023/12_5_2_p1_04_04_2023/" - #path = '/eos/user/a/akalinow/Data/SingleMu/12_5_2_p1_04_04_2023/SingleMu_ch0_iPt1_12_5_2_p1_04_04_2023/12_5_2_p1_04_04_2023/230404_084317/0000/' - - root_files = [] - for root, dirs, files in os.walk(path): - for file in fnmatch.filter(files, 'SingleMu*.root'): - root_files.append(os.path.join(root, file)) - - file_num = 0 - for root_file in root_files : - if isfile(root_file) : - chosenFiles.append('file://' + root_file) - file_num += 1 - else : - print("file not found!!!!!!!: " + root_file) - - if file_num >= file_cnt : - break + matchUsingPropagation = False + paths = [ + {"path": "/eos/user/a/akalinow/Data/SingleMu/12_5_2_p1_20_04_2023/SingleMu_ch0_OneOverPt_12_5_2_p1_20_04_2023/", "fileCnt" : 500}, #500 files + {"path": "/eos/user/a/akalinow/Data/SingleMu/12_5_2_p1_20_04_2023/SingleMu_ch2_OneOverPt_12_5_2_p1_20_04_2023/", "fileCnt" : 500}, #500 files + # + {"path": "/eos/user/a/akalinow/Data/SingleMu/12_5_2_p1_14_04_2023/SingleMu_ch0_OneOverPt_12_5_2_p1_14_04_2023/", "fileCnt" : 500}, #500 files + {"path": "/eos/user/a/akalinow/Data/SingleMu/12_5_2_p1_14_04_2023/SingleMu_ch2_OneOverPt_12_5_2_p1_14_04_2023/", "fileCnt" : 500}, #500 files + # + {"path": "/eos/user/a/akalinow/Data/SingleMu/12_5_2_p1_04_04_2023/SingleMu_ch0_OneOverPt_12_5_2_p1_04_04_2023/", "fileCnt" : 500}, #500 files + {"path": "/eos/user/a/akalinow/Data/SingleMu/12_5_2_p1_04_04_2023/SingleMu_ch2_OneOverPt_12_5_2_p1_04_04_2023/", "fileCnt" : 500}, #500 files + # + {"path": "/eos/user/a/akalinow/Data/SingleMu/12_5_2_p1_22_02_2023/SingleMu_ch0_OneOverPt_12_5_2_p1_22_02_2023/", "fileCnt" : 500}, #200 files + {"path": "/eos/user/a/akalinow/Data/SingleMu/12_5_2_p1_22_02_2023/SingleMu_ch2_OneOverPt_12_5_2_p1_22_02_2023/", "fileCnt" : 500}, #200 files + # + # {"path": "/eos/user/a/akalinow/Data/SingleMu/12_5_2_p1_15_02_2023/SingleMu_ch0_OneOverPt_12_5_2_p1_15_02_2023/", "fileCnt" : 500}, ##100 files + # {"path": "/eos/user/a/akalinow/Data/SingleMu/12_5_2_p1_15_02_2023/SingleMu_ch2_OneOverPt_12_5_2_p1_15_02_2023/", "fileCnt" : 500}, ##100 files + {"path": "/eos/user/a/akalinow/Data/SingleMu/12_5_2_p1_04_04_2023/SingleMu_ch0_iPt2_12_5_2_p1_04_04_2023/", "fileCnt" : 200}, #500 files + {"path": "/eos/user/a/akalinow/Data/SingleMu/12_5_2_p1_04_04_2023/SingleMu_ch2_iPt2_12_5_2_p1_04_04_2023/", "fileCnt" : 200}, #500 files + ] + +if filesNameLike == 'mcWaw2023_iPt1': + cscBx = 8 + matchUsingPropagation = False + paths = [ + # "/eos/user/a/akalinow/Data/SingleMu/12_5_2_p1_20_04_2023/SingleMu_ch0_OneOverPt_12_5_2_p1_20_04_2023/", #500 files + # "/eos/user/a/akalinow/Data/SingleMu/12_5_2_p1_20_04_2023/SingleMu_ch2_OneOverPt_12_5_2_p1_20_04_2023/", #500 files + # + # "/eos/user/a/akalinow/Data/SingleMu/12_5_2_p1_14_04_2023/SingleMu_ch0_OneOverPt_12_5_2_p1_14_04_2023/", #500 files + # "/eos/user/a/akalinow/Data/SingleMu/12_5_2_p1_14_04_2023/SingleMu_ch2_OneOverPt_12_5_2_p1_14_04_2023/", #500 files + # + #{"path": "/eos/user/a/akalinow/Data/SingleMu/12_5_2_p1_04_04_2023/SingleMu_ch0_OneOverPt_12_5_2_p1_04_04_2023/", "fileCnt" : 500}, #500 files + #{"path": "/eos/user/a/akalinow/Data/SingleMu/12_5_2_p1_04_04_2023/SingleMu_ch2_OneOverPt_12_5_2_p1_04_04_2023/", "fileCnt" : 500}, #500 files + # + # "/eos/user/a/akalinow/Data/SingleMu/12_5_2_p1_22_02_2023/SingleMu_ch0_OneOverPt_12_5_2_p1_22_02_2023/", #200 files + # "/eos/user/a/akalinow/Data/SingleMu/12_5_2_p1_22_02_2023/SingleMu_ch2_OneOverPt_12_5_2_p1_22_02_2023/", #200 files + # + # "/eos/user/a/akalinow/Data/SingleMu/12_5_2_p1_15_02_2023/SingleMu_ch0_OneOverPt_12_5_2_p1_15_02_2023/", ##100 files + # "/eos/user/a/akalinow/Data/SingleMu/12_5_2_p1_15_02_2023/SingleMu_ch2_OneOverPt_12_5_2_p1_15_02_2023/", ##100 files + {"path": "/eos/user/a/akalinow/Data/SingleMu/12_5_2_p1_04_04_2023/SingleMu_ch0_iPt1_12_5_2_p1_04_04_2023/", "fileCnt" : 100}, #500 files + {"path": "/eos/user/a/akalinow/Data/SingleMu/12_5_2_p1_04_04_2023/SingleMu_ch2_iPt1_12_5_2_p1_04_04_2023/", "fileCnt" : 100}, #500 files + ] + + +print("input data paths", paths) + +if(runDebug == "DEBUG") : + fileCnt = 1; + +for path in paths : + root_files = [] + for root, dirs, files in os.walk(path["path"]): + for file in fnmatch.filter(files, '*.root'): + root_files.append(os.path.join(root, file)) - + file_num = 0 + for root_file in root_files : + if isfile(root_file) : + chosenFiles.append('file://' + root_file) + file_num += 1 + else : + print("file not found!!!!!!!: " + root_file) + + if file_num >= path["fileCnt"] : + break + if file_num >= fileCnt : + break - paths = ["/eos/user/a/akalinow/Data/SingleMu/12_5_2_p1_22_02_2023/SingleMu_ch0_iPt0_12_5_2_p1_22_02_2023/", - "/eos/user/a/akalinow/Data/SingleMu/12_5_2_p1_22_02_2023/SingleMu_ch2_iPt0_12_5_2_p1_22_02_2023/", - "/eos/user/a/akalinow/Data/SingleMu/12_5_2_p1_15_02_2023/SingleMu_ch0_iPt0_12_5_2_p1_15_02_2023/", - "/eos/user/a/akalinow/Data/SingleMu/12_5_2_p1_15_02_2023/SingleMu_ch2_iPt0_12_5_2_p1_15_02_2023/"] - - for path in paths : - root_files = [] - for root, dirs, files in os.walk(path): - for file in fnmatch.filter(files, 'SingleMu*.root'): - root_files.append(os.path.join(root, file)) - - file_num = 0 - for root_file in root_files : - if isfile(root_file) : - chosenFiles.append('file://' + root_file) - file_num += 1 - else : - print("file not found!!!!!!!: " + root_file) - - if file_num >= file_cnt : - break - -if filesNameLike == 'mcWaw2023_OneOverPt' : - cscBx = 8 - - file_cnt = 100000 - paths = ["/eos/user/a/akalinow/Data/SingleMu/12_5_2_p1_20_04_2023/SingleMu_ch0_OneOverPt_12_5_2_p1_20_04_2023/", - "/eos/user/a/akalinow/Data/SingleMu/12_5_2_p1_20_04_2023/SingleMu_ch2_OneOverPt_12_5_2_p1_20_04_2023/", - "/eos/user/a/akalinow/Data/SingleMu/12_5_2_p1_14_04_2023/SingleMu_ch0_OneOverPt_12_5_2_p1_14_04_2023/", - "/eos/user/a/akalinow/Data/SingleMu/12_5_2_p1_14_04_2023/SingleMu_ch2_OneOverPt_12_5_2_p1_14_04_2023/"] - - for path in paths : - root_files = [] - for root, dirs, files in os.walk(path): - for file in fnmatch.filter(files, 'SingleMu*.root'): - root_files.append(os.path.join(root, file)) - - file_num = 0 - for root_file in root_files : - if isfile(root_file) : - chosenFiles.append('file://' + root_file) - file_num += 1 - else : - print("file not found!!!!!!!: " + root_file) - - if file_num >= file_cnt : - break - print("chosenFiles") for chFile in chosenFiles: print(chFile) -print("number of chosen files:", len(chosenFiles)) + +print("chosen file count", len(chosenFiles) ) if len(chosenFiles) == 0 : - print("no files selected!!!!!!!!!!!!!!! (argumetn should be e.g. 20_p") - exit + print("no files selected!!!!!!!!!!!!!!!") + exit + +print("running version", version) # input files (up to 255 files accepted) process.source = cms.Source('PoolSource', @@ -187,24 +190,14 @@ process.dtTriggerPhase2PrimitiveDigis.dump = False process.dtTriggerPhase2PrimitiveDigis.scenario = 0 -####Event Setup Producer -process.load('L1Trigger.L1TMuonOverlapPhase1.fakeOmtfParams_cff') -process.omtfParams.configXMLFile = cms.FileInPath("L1Trigger/L1TMuon/data/omtf_config/hwToLogicLayer_0x0209_patGen.xml") -process.omtfParams.patternsXMLFiles = cms.VPSet( - cms.PSet(patternsXMLFile = cms.FileInPath("L1Trigger/L1TMuonOverlapPhase1/test/expert/omtf/Patterns_template.xml")), ) - -process.esProd = cms.EDAnalyzer("EventSetupRecordDataGetter", - toGet = cms.VPSet( - cms.PSet(record = cms.string('L1TMuonOverlapParamsRcd'), - data = cms.vstring('L1TMuonOverlapParams')) - ), - verbose = cms.untracked.bool(False) -) +# STD aelow are the defoult values +#process.dtTriggerPhase2PrimitiveDigis.algo = 0 ## initial grouping +#process.dtTriggerPhase2PrimitiveDigis.df_extended = 0 #process.TFileService = cms.Service("TFileService", fileName = cms.string('omtfAnalysis1_1.root'), closeFileFast = cms.untracked.bool(True) ) ####OMTF Emulator -process.load('L1Trigger.L1TMuonOverlapPhase2.simOmtfPhase2Digis_extrapol_cfi') +process.load('L1Trigger.L1TMuonOverlapPhase2.simOmtfPhase2Digis_cfi') #needed by candidateSimMuonMatcher process.load("TrackPropagation.SteppingHelixPropagator.SteppingHelixPropagatorAlong_cfi") @@ -223,7 +216,7 @@ process.simOmtfPhase2Digis.dumpResultToXML = cms.bool(False) process.simOmtfPhase2Digis.eventCaptureDebug = cms.bool(False) -process.simOmtfPhase2Digis.patternsXMLFile = cms.FileInPath("L1Trigger/L1TMuonOverlapPhase1/test/expert/omtf/Patterns_template.xml") +process.simOmtfPhase2Digis.patternsXMLFile = cms.FileInPath("L1Trigger/L1TMuon/data/omtf_config/Patterns_template.xml") #process.simOmtfPhase2Digis.patternsXMLFiles = cms.VPSet(cms.PSet(patternsXMLFile = cms.FileInPath("L1Trigger/L1TMuon/data/omtf_config/GPs_parametrised_plus_v1.xml")), # cms.PSet(patternsXMLFile = cms.FileInPath("L1Trigger/L1TMuon/data/omtf_config/GPs_parametrised_minus_v1.xml")) #) @@ -243,7 +236,7 @@ process.simOmtfPhase2Digis.minCSCStubRME12 = cms.int32(410) #[cm] process.simOmtfPhase2Digis.minCSCStubR = cms.int32(500) #[cm] -process.simOmtfPhase2Digis.minDtPhiQuality = cms.int32(2) +process.simOmtfPhase2Digis.minDtPhiQuality = cms.int32(4) process.simOmtfPhase2Digis.minDtPhiBQuality = cms.int32(4) process.simOmtfPhase2Digis.dtRefHitMinQuality = cms.int32(4) @@ -254,7 +247,7 @@ process.simOmtfPhase2Digis.useStubQualInExtr = cms.bool(True) process.simOmtfPhase2Digis.useEndcapStubsRInExtr = cms.bool(True) process.simOmtfPhase2Digis.useFloatingPointExtrapolation = cms.bool(False) -#process.simOmtfPhase2Digis.extrapolFactorsFilename = cms.FileInPath("ExtrapolationFactors_ExtraplMB1nadMB2DTQualAndEta_ValueP1Scale_t20_SingleMu_iPt_100files_mcWaw2023.xml") +process.simOmtfPhase2Digis.extrapolFactorsFilename = cms.FileInPath("L1Trigger/L1TMuon/data/omtf_config/ExtrapolationFactors_ExtraplMB1nadMB2DTQualAndR_EtaValueP1Scale_t25c.xml") process.simOmtfPhase2Digis.stubEtaEncoding = cms.string("valueP1Scale") @@ -263,13 +256,18 @@ #process.dumpED = cms.EDAnalyzer("EventContentAnalyzer") #process.dumpES = cms.EDAnalyzer("PrintEventSetupContent") -process.L1TMuonSeq = cms.Sequence( process.esProd - + process.simOmtfPhase2Digis +process.L1TMuonSeq = cms.Sequence( process.simOmtfPhase2Digis #+ process.dumpED #+ process.dumpES ) -process.L1TMuonPath = cms.Path(process.L1TMuonSeq) +if not regeneratedL1DT : + process.L1TMuonPath = cms.Path(process.L1TMuonSeq) ########################################<<<<< Date: Thu, 23 May 2024 09:30:02 -0500 Subject: [PATCH 037/237] Added ModuleAllocMonitor Service This uses the AllocMonitor system to monitor the memory usage done by each module as well as the source and memory released at end of event. --- PerfTools/AllocMonitor/plugins/BuildFile.xml | 1 + .../plugins/ModuleAllocMonitor.cc | 198 +++ .../AllocMonitor/plugins/ThreadAllocInfo.h | 52 + .../plugins/moduleAlloc_setupFile.cc | 1027 +++++++++++ .../plugins/moduleAlloc_setupFile.h | 37 + .../plugins/monitor_file_utilities.cc | 32 + .../plugins/monitor_file_utilities.h | 43 + .../scripts/edmModuleAllocMonitorAnalyze.py | 1524 +++++++++++++++++ PerfTools/AllocMonitor/test/BuildFile.xml | 2 + .../AllocMonitor/test/moduleAlloc_cfg.py | 50 + PerfTools/AllocMonitor/test/runModuleAlloc.sh | 52 + .../test/unittest_output/allEDModules.log | 110 ++ .../test/unittest_output/allESModules.log | 12 + .../test/unittest_output/allTransitions.log | 43 + .../unittest_output/only_ed_EDModules.log | 24 + .../unittest_output/only_ed_ESModules.log | 0 .../unittest_output/only_es_EDModules.log | 0 .../unittest_output/only_es_ESModules.log | 10 + .../unittest_output/skipEvents_EDModules.log | 48 + .../unittest_output/skipEvents_ESModules.log | 0 .../skipEvents_Transitions.log | 39 + 21 files changed, 3304 insertions(+) create mode 100644 PerfTools/AllocMonitor/plugins/ModuleAllocMonitor.cc create mode 100644 PerfTools/AllocMonitor/plugins/ThreadAllocInfo.h create mode 100644 PerfTools/AllocMonitor/plugins/moduleAlloc_setupFile.cc create mode 100644 PerfTools/AllocMonitor/plugins/moduleAlloc_setupFile.h create mode 100644 PerfTools/AllocMonitor/plugins/monitor_file_utilities.cc create mode 100644 PerfTools/AllocMonitor/plugins/monitor_file_utilities.h create mode 100644 PerfTools/AllocMonitor/scripts/edmModuleAllocMonitorAnalyze.py create mode 100644 PerfTools/AllocMonitor/test/moduleAlloc_cfg.py create mode 100755 PerfTools/AllocMonitor/test/runModuleAlloc.sh create mode 100644 PerfTools/AllocMonitor/test/unittest_output/allEDModules.log create mode 100644 PerfTools/AllocMonitor/test/unittest_output/allESModules.log create mode 100644 PerfTools/AllocMonitor/test/unittest_output/allTransitions.log create mode 100644 PerfTools/AllocMonitor/test/unittest_output/only_ed_EDModules.log create mode 100644 PerfTools/AllocMonitor/test/unittest_output/only_ed_ESModules.log create mode 100644 PerfTools/AllocMonitor/test/unittest_output/only_es_EDModules.log create mode 100644 PerfTools/AllocMonitor/test/unittest_output/only_es_ESModules.log create mode 100644 PerfTools/AllocMonitor/test/unittest_output/skipEvents_EDModules.log create mode 100644 PerfTools/AllocMonitor/test/unittest_output/skipEvents_ESModules.log create mode 100644 PerfTools/AllocMonitor/test/unittest_output/skipEvents_Transitions.log diff --git a/PerfTools/AllocMonitor/plugins/BuildFile.xml b/PerfTools/AllocMonitor/plugins/BuildFile.xml index f7306fd1ae1f7..f8e81afbfe9b6 100644 --- a/PerfTools/AllocMonitor/plugins/BuildFile.xml +++ b/PerfTools/AllocMonitor/plugins/BuildFile.xml @@ -1,3 +1,4 @@ + diff --git a/PerfTools/AllocMonitor/plugins/ModuleAllocMonitor.cc b/PerfTools/AllocMonitor/plugins/ModuleAllocMonitor.cc new file mode 100644 index 0000000000000..be3d19059847f --- /dev/null +++ b/PerfTools/AllocMonitor/plugins/ModuleAllocMonitor.cc @@ -0,0 +1,198 @@ +// -*- C++ -*- +// +// Package: PerfTools/AllocMonitor +// Class : EventProcessingAllocMonitor +// +// Implementation: +// [Notes on implementation] +// +// Original Author: Christopher Jones +// Created: Mon, 21 Aug 2023 20:31:57 GMT +// + +// system include files +#include + +// user include files +#include "PerfTools/AllocMonitor/interface/AllocMonitorBase.h" +#include "PerfTools/AllocMonitor/interface/AllocMonitorRegistry.h" +#include "FWCore/Framework/interface/ComponentDescription.h" +#include "FWCore/MessageLogger/interface/MessageLogger.h" +#include "FWCore/ServiceRegistry/interface/ServiceRegistry.h" +#include "FWCore/ServiceRegistry/interface/ServiceMaker.h" +#include "FWCore/ServiceRegistry/interface/ModuleCallingContext.h" +#include "DataFormats/Provenance/interface/ModuleDescription.h" + +#include "moduleAlloc_setupFile.h" +#include "ThreadAllocInfo.h" + +namespace { + using namespace edm::service::moduleAlloc; + class MonitorAdaptor : public cms::perftools::AllocMonitorBase { + public: + static void startOnThread() { threadAllocInfo().reset(); } + static ThreadAllocInfo const& stopOnThread() { + auto& t = threadAllocInfo(); + if (not t.active_) { + t.reset(); + } else { + t.deactivate(); + } + return t; + } + + private: + static ThreadAllocInfo& threadAllocInfo() { + thread_local ThreadAllocInfo s_info; + return s_info; + } + void allocCalled(size_t iRequested, size_t iActual) final { + auto& allocInfo = threadAllocInfo(); + if (not allocInfo.active_) { + return; + } + allocInfo.nAllocations_ += 1; + allocInfo.requested_ += iRequested; + + if (allocInfo.maxSingleAlloc_ < iRequested) { + allocInfo.maxSingleAlloc_ = iRequested; + } + + allocInfo.presentActual_ += iActual; + if (allocInfo.presentActual_ > static_cast(allocInfo.maxActual_)) { + allocInfo.maxActual_ = allocInfo.presentActual_; + } + } + void deallocCalled(size_t iActual) final { + auto& allocInfo = threadAllocInfo(); + if (not allocInfo.active_) { + return; + } + + allocInfo.nDeallocations_ += 1; + allocInfo.presentActual_ -= iActual; + if (allocInfo.presentActual_ < 0) { + if (allocInfo.minActual_ == 0 or allocInfo.minActual_ > allocInfo.presentActual_) { + allocInfo.minActual_ = allocInfo.presentActual_; + } + } + } + }; + +} // namespace + +namespace edm::service::moduleAlloc { + Filter::Filter(std::vector const* moduleIDs) : moduleIDs_{moduleIDs} {} + + bool Filter::startOnThread(int moduleID) const { + if (not globalKeep_.load()) { + return false; + } + if (keepModuleInfo(moduleID)) { + MonitorAdaptor::startOnThread(); + return true; + } + return false; + } + + const ThreadAllocInfo* Filter::stopOnThread(int moduleID) const { + if (not globalKeep_.load()) { + return nullptr; + } + + if (keepModuleInfo(moduleID)) { + return &MonitorAdaptor::stopOnThread(); + } + return nullptr; + } + + bool Filter::startOnThread() const { + if (not globalKeep_.load()) { + return false; + } + MonitorAdaptor::startOnThread(); + return true; + } + + const ThreadAllocInfo* Filter::stopOnThread() const { + if (not globalKeep_.load()) { + return nullptr; + } + return &MonitorAdaptor::stopOnThread(); + } + + void Filter::setGlobalKeep(bool iShouldKeep) { globalKeep_.store(iShouldKeep); } + + bool Filter::keepModuleInfo(int moduleID) const { + if ((nullptr == moduleIDs_) or (moduleIDs_->empty()) or + (std::binary_search(moduleIDs_->begin(), moduleIDs_->end(), moduleID))) { + return true; + } + return false; + } +} // namespace edm::service::moduleAlloc + +class ModuleAllocMonitor { +public: + ModuleAllocMonitor(edm::ParameterSet const& iPS, edm::ActivityRegistry& iAR) + : moduleNames_(iPS.getUntrackedParameter>("moduleNames")), + nEventsToSkip_(iPS.getUntrackedParameter("nEventsToSkip")), + filter_(&moduleIDs_) { + (void)cms::perftools::AllocMonitorRegistry::instance().createAndRegisterMonitor(); + + if (nEventsToSkip_ > 0) { + filter_.setGlobalKeep(false); + } + if (not moduleNames_.empty()) { + iAR.watchPreModuleConstruction([this](auto const& description) { + auto found = std::find(moduleNames_.begin(), moduleNames_.end(), description.moduleLabel()); + if (found != moduleNames_.end()) { + moduleIDs_.push_back(description.id()); + std::sort(moduleIDs_.begin(), moduleIDs_.end()); + } + }); + + iAR.watchPostESModuleRegistration([this](auto const& iDescription) { + auto label = iDescription.label_; + if (label.empty()) { + label = iDescription.type_; + } + auto found = std::find(moduleNames_.begin(), moduleNames_.end(), label); + if (found != moduleNames_.end()) { + //NOTE: we want the id to start at 1 not 0 + moduleIDs_.push_back(-1 * (iDescription.id_ + 1)); + std::sort(moduleIDs_.begin(), moduleIDs_.end()); + } + }); + } + if (nEventsToSkip_ > 0) { + iAR.watchPreSourceEvent([this](auto) { + ++nEventsStarted_; + if (nEventsStarted_ > nEventsToSkip_) { + filter_.setGlobalKeep(true); + } + }); + } + edm::service::moduleAlloc::setupFile(iPS.getUntrackedParameter("fileName"), iAR, &filter_); + } + + static void fillDescriptions(edm::ConfigurationDescriptions& iDesc) { + edm::ParameterSetDescription ps; + ps.addUntracked("fileName"); + ps.addUntracked>("moduleNames", std::vector()); + ps.addUntracked("nEventsToSkip", 0); + iDesc.addDefault(ps); + } + +private: + bool forThisModule(unsigned int iID) { + return (moduleNames_.empty() or std::binary_search(moduleIDs_.begin(), moduleIDs_.end(), iID)); + } + std::vector moduleNames_; + std::vector moduleIDs_; + unsigned int nEventsToSkip_ = 0; + std::atomic nEventsStarted_{0}; + edm::service::moduleAlloc::Filter filter_; +}; + +DEFINE_FWK_SERVICE(ModuleAllocMonitor); diff --git a/PerfTools/AllocMonitor/plugins/ThreadAllocInfo.h b/PerfTools/AllocMonitor/plugins/ThreadAllocInfo.h new file mode 100644 index 0000000000000..868cf917a37f9 --- /dev/null +++ b/PerfTools/AllocMonitor/plugins/ThreadAllocInfo.h @@ -0,0 +1,52 @@ +#ifndef PerfTools_AllocMonitor_ThreadAllocInfo_h +#define PerfTools_AllocMonitor_ThreadAllocInfo_h +// -*- C++ -*- +// +// Package: PerfTools/AllocMonitor +// Class : ThreadAllocInfo +// +/**\class ThreadAllocInfo ThreadAllocInfo.h "ThreadAllocInfo.h" + + Description: information about per module allocations + + Usage: + + +*/ +// +// Original Author: Christopher Jones +// Created: Fri, 10 May 2024 14:48:59 GMT +// + +// system include files + +// user include files + +// forward declarations + +namespace edm::service::moduleAlloc { + struct ThreadAllocInfo { + size_t requested_ = 0; + long long presentActual_ = 0; + size_t maxActual_ = 0; + long long minActual_ = 0; + size_t maxSingleAlloc_ = 0; + size_t nAllocations_ = 0; + size_t nDeallocations_ = 0; + bool active_ = false; + + void reset() { + requested_ = 0; + presentActual_ = 0; + maxActual_ = 0; + minActual_ = 0; + maxSingleAlloc_ = 0; + nAllocations_ = 0; + nDeallocations_ = 0; + active_ = true; + } + + void deactivate() { active_ = false; } + }; +} // namespace edm::service::moduleAlloc +#endif diff --git a/PerfTools/AllocMonitor/plugins/moduleAlloc_setupFile.cc b/PerfTools/AllocMonitor/plugins/moduleAlloc_setupFile.cc new file mode 100644 index 0000000000000..cd271170ac036 --- /dev/null +++ b/PerfTools/AllocMonitor/plugins/moduleAlloc_setupFile.cc @@ -0,0 +1,1027 @@ +#include "moduleAlloc_setupFile.h" +#include "monitor_file_utilities.h" + +#include + +#include +#include +#include +#include + +#include "FWCore/Concurrency/interface/ThreadSafeOutputFileStream.h" + +#include "DataFormats/Provenance/interface/EventID.h" +#include "DataFormats/Provenance/interface/LuminosityBlockID.h" +#include "DataFormats/Provenance/interface/ModuleDescription.h" +#include "DataFormats/Provenance/interface/RunID.h" +#include "DataFormats/Provenance/interface/Timestamp.h" + +#include "FWCore/ServiceRegistry/interface/GlobalContext.h" +#include "FWCore/ServiceRegistry/interface/ModuleCallingContext.h" +#include "FWCore/ServiceRegistry/interface/ESModuleCallingContext.h" +#include "FWCore/ServiceRegistry/interface/PathContext.h" +#include "FWCore/ServiceRegistry/interface/ProcessContext.h" +#include "FWCore/ServiceRegistry/interface/StreamContext.h" +#include "FWCore/ServiceRegistry/interface/ActivityRegistry.h" + +#include "FWCore/Framework/interface/IOVSyncValue.h" +#include "FWCore/Framework/interface/ESRecordsToProductResolverIndices.h" + +#include "FWCore/Utilities/interface/TimingServiceBase.h" + +#include "ThreadAllocInfo.h" + +using namespace edm::moduleAlloc::monitor_file_utilities; + +namespace { + using duration_t = std::chrono::microseconds; + using clock_t = std::chrono::steady_clock; + auto const now = clock_t::now; + + enum class Step : char { + preSourceTransition = 'S', + postSourceTransition = 's', + preModuleEventAcquire = 'A', + postModuleEventAcquire = 'a', + preModuleTransition = 'M', + preEventReadFromSource = 'R', + postEventReadFromSource = 'r', + preModuleEventDelayedGet = 'D', + postModuleEventDelayedGet = 'd', + postModuleTransition = 'm', + preESModule = 'N', + postESModule = 'n', + preESModuleAcquire = 'B', + postESModuleAcquire = 'b', + preFrameworkTransition = 'F', + postFrameworkTransition = 'f' + }; + + constexpr bool isPostTransition(Step s) { + switch (s) { + case Step::postSourceTransition: + case Step::postModuleEventAcquire: + case Step::postEventReadFromSource: + case Step::postModuleEventDelayedGet: + case Step::postModuleTransition: + case Step::postESModule: + case Step::postESModuleAcquire: + case Step::postFrameworkTransition: + return true; + default: + return false; + } + return false; + } + + enum class Phase : short { + destruction = -16, + endJob = -12, + endStream = -11, + writeProcessBlock = -10, + endProcessBlock = -9, + globalWriteRun = -7, + globalEndRun = -6, + streamEndRun = -5, + globalWriteLumi = -4, + globalEndLumi = -3, + streamEndLumi = -2, + clearEvent = -1, + Event = 0, + streamBeginLumi = 2, + globalBeginLumi = 3, + streamBeginRun = 5, + globalBeginRun = 6, + accessInputProcessBlock = 8, + beginProcessBlock = 9, + openFile = 10, + beginStream = 11, + beginJob = 12, + esSync = 13, + esSyncEnqueue = 14, + getNextTransition = 15, + construction = 16, + startTracing = 17 + }; + + std::ostream& operator<<(std::ostream& os, Step const s) { + os << static_cast>(s); + return os; + } + + std::ostream& operator<<(std::ostream& os, Phase const s) { + os << static_cast>(s); + return os; + } + + template + std::string assembleMessage(ARGS const... args) { + std::ostringstream oss; + oss << S; + concatenate(oss, args...); + oss << '\n'; + return oss.str(); + } + + template + std::string assembleAllocMessage(edm::service::moduleAlloc::ThreadAllocInfo const& info, ARGS const... args) { + std::ostringstream oss; + oss << S; + concatenate(oss, args...); + concatenate(oss, + info.nAllocations_, + info.nDeallocations_, + info.presentActual_, + info.minActual_, + info.maxActual_, + info.maxSingleAlloc_); + oss << '\n'; + return oss.str(); + } + + Phase toTransitionImpl(edm::StreamContext const& iContext) { + using namespace edm; + switch (iContext.transition()) { + case StreamContext::Transition::kBeginStream: + return Phase::beginStream; + case StreamContext::Transition::kBeginRun: + return Phase::streamBeginRun; + case StreamContext::Transition::kBeginLuminosityBlock: + return Phase::streamBeginLumi; + case StreamContext::Transition::kEvent: + return Phase::Event; + case StreamContext::Transition::kEndLuminosityBlock: + return Phase::streamEndLumi; + case StreamContext::Transition::kEndRun: + return Phase::streamEndRun; + case StreamContext::Transition::kEndStream: + return Phase::endStream; + default: + break; + } + assert(false); + return Phase::Event; + } + + auto toTransition(edm::StreamContext const& iContext) -> std::underlying_type_t { + return static_cast>(toTransitionImpl(iContext)); + } + + Phase toTransitionImpl(edm::GlobalContext const& iContext) { + using namespace edm; + switch (iContext.transition()) { + case GlobalContext::Transition::kBeginProcessBlock: + return Phase::beginProcessBlock; + case GlobalContext::Transition::kAccessInputProcessBlock: + return Phase::accessInputProcessBlock; + case GlobalContext::Transition::kBeginRun: + return Phase::globalBeginRun; + case GlobalContext::Transition::kBeginLuminosityBlock: + return Phase::globalBeginLumi; + case GlobalContext::Transition::kEndLuminosityBlock: + return Phase::globalEndLumi; + case GlobalContext::Transition::kWriteLuminosityBlock: + return Phase::globalWriteLumi; + case GlobalContext::Transition::kEndRun: + return Phase::globalEndRun; + case GlobalContext::Transition::kWriteRun: + return Phase::globalWriteRun; + case GlobalContext::Transition::kEndProcessBlock: + return Phase::endProcessBlock; + case GlobalContext::Transition::kWriteProcessBlock: + return Phase::writeProcessBlock; + default: + break; + } + assert(false); + return Phase::Event; + } + auto toTransition(edm::GlobalContext const& iContext) -> std::underlying_type_t { + return static_cast>(toTransitionImpl(iContext)); + } + + unsigned int toTransitionIndex(edm::GlobalContext const& iContext) { + if (iContext.transition() == edm::GlobalContext::Transition::kBeginProcessBlock or + iContext.transition() == edm::GlobalContext::Transition::kEndProcessBlock or + iContext.transition() == edm::GlobalContext::Transition::kWriteProcessBlock or + iContext.transition() == edm::GlobalContext::Transition::kAccessInputProcessBlock) { + return 0; + } + if (iContext.transition() == edm::GlobalContext::Transition::kBeginRun or + iContext.transition() == edm::GlobalContext::Transition::kEndRun or + iContext.transition() == edm::GlobalContext::Transition::kWriteRun) { + return iContext.runIndex(); + } + return iContext.luminosityBlockIndex(); + } + + using namespace edm::service::moduleAlloc; + + template + struct ESModuleState { + ESModuleState(std::shared_ptr logFile, + decltype(now()) beginTime, + std::shared_ptr> recordIndices, + Filter const* iFilter) + : logFile_{logFile}, recordIndices_{recordIndices}, beginTime_{beginTime}, filter_(iFilter) {} + + void operator()(edm::eventsetup::EventSetupRecordKey const& iKey, + edm::ESModuleCallingContext const& iContext) const { + using namespace edm; + auto const t = std::chrono::duration_cast(now() - beginTime_).count(); + auto top = iContext.getTopModuleCallingContext(); + short int phase = 0; + unsigned long phaseID = 0xFFFFFFFF; + if (top->type() == ParentContext::Type::kGlobal) { + auto global = top->globalContext(); + phase = toTransition(*global); + phaseID = toTransitionIndex(*global); + } else if (top->type() == ParentContext::Type::kStream) { + auto stream = top->getStreamContext(); + phase = toTransition(*stream); + phaseID = stream_id(*stream); + } else if (top->type() == ParentContext::Type::kPlaceInPath) { + auto stream = top->getStreamContext(); + phase = toTransition(*stream); + phaseID = stream_id(*stream); + } + auto recordIndex = findRecordIndices(iKey); + if constexpr (isPostTransition(S)) { + auto info = filter_->stopOnThread(-1 * (iContext.componentDescription()->id_ + 1)); + if (info) { + auto msg = assembleAllocMessage( + *info, phase, phaseID, iContext.componentDescription()->id_ + 1, recordIndex, iContext.callID(), t); + logFile_->write(std::move(msg)); + } + } else { + if (filter_->startOnThread(-1 * (iContext.componentDescription()->id_ + 1))) { + auto msg = assembleMessage( + phase, phaseID, iContext.componentDescription()->id_ + 1, recordIndex, iContext.callID(), t); + logFile_->write(std::move(msg)); + } + } + } + + private: + int findRecordIndices(edm::eventsetup::EventSetupRecordKey const& iKey) const { + auto index = std::type_index(iKey.type().value()); + auto itFind = std::find(recordIndices_->begin(), recordIndices_->end(), index); + return itFind - recordIndices_->begin(); + } + + std::shared_ptr logFile_; + std::shared_ptr> recordIndices_; + decltype(now()) beginTime_; + Filter const* filter_; + }; + + template + struct GlobalEDModuleState { + GlobalEDModuleState(std::shared_ptr logFile, + decltype(now()) beginTime, + Filter const* iFilter) + : logFile_{logFile}, beginTime_{beginTime}, filter_(iFilter) {} + + void operator()(edm::GlobalContext const& gc, edm::ModuleCallingContext const& mcc) { + using namespace edm; + auto const t = std::chrono::duration_cast(now() - beginTime_).count(); + if constexpr (isPostTransition(S)) { + auto id = module_id(mcc); + auto info = filter_->stopOnThread(id); + if (info) { + auto msg = assembleAllocMessage(*info, toTransition(gc), toTransitionIndex(gc), id, module_callid(mcc), t); + logFile_->write(std::move(msg)); + } + } else { + auto id = module_id(mcc); + if (filter_->startOnThread(id)) { + auto msg = assembleMessage(toTransition(gc), toTransitionIndex(gc), module_id(mcc), module_callid(mcc), t); + logFile_->write(std::move(msg)); + } + } + } + + private: + std::shared_ptr logFile_; + decltype(now()) beginTime_; + Filter const* filter_; + }; + + template + struct StreamEDModuleState { + StreamEDModuleState(std::shared_ptr logFile, + decltype(now()) beginTime, + Filter const* iFilter) + : logFile_{logFile}, beginTime_{beginTime}, filter_(iFilter) {} + + void operator()(edm::StreamContext const& sc, edm::ModuleCallingContext const& mcc) { + using namespace edm; + auto const t = std::chrono::duration_cast(now() - beginTime_).count(); + if constexpr (isPostTransition(S)) { + auto id = module_id(mcc); + auto info = filter_->stopOnThread(id); + if (info) { + auto msg = + assembleAllocMessage(*info, toTransition(sc), stream_id(sc), module_id(mcc), module_callid(mcc), t); + logFile_->write(std::move(msg)); + } + } else { + auto id = module_id(mcc); + if (filter_->startOnThread(id)) { + auto msg = assembleMessage(toTransition(sc), stream_id(sc), id, module_callid(mcc), t); + logFile_->write(std::move(msg)); + } + } + } + + private: + std::shared_ptr logFile_; + decltype(now()) beginTime_; + Filter const* filter_; + }; + + struct ModuleCtrDtr { + long long beginConstruction = 0; + long long endConstruction = 0; + edm::service::moduleAlloc::ThreadAllocInfo constructionAllocInfo; + long long beginDestruction = 0; + long long endDestruction = 0; + edm::service::moduleAlloc::ThreadAllocInfo destructionAllocInfo; + }; +} // namespace + +namespace edm::service::moduleAlloc { + void setupFile(std::string const& iFileName, edm::ActivityRegistry& iRegistry, Filter const* iFilter) { + auto beginModuleAlloc = now(); + using namespace std::chrono; + + if (iFileName.empty()) { + return; + } + + auto logFile = std::make_shared(iFileName); + + auto beginTime = TimingServiceBase::jobStartTime(); + + auto esModuleLabelsPtr = std::make_shared>(); + auto& esModuleLabels = *esModuleLabelsPtr; + //acquire names for all the ED and ES modules + iRegistry.watchPostESModuleRegistration([&esModuleLabels](auto const& iDescription) { + if (esModuleLabels.size() <= iDescription.id_ + 1) { + esModuleLabels.resize(iDescription.id_ + 2); + } + //NOTE: we want the id to start at 1 not 0 + if (not iDescription.label_.empty()) { + esModuleLabels[iDescription.id_ + 1] = iDescription.label_; + } else { + esModuleLabels[iDescription.id_ + 1] = iDescription.type_; + } + }); + auto moduleCtrDtrPtr = std::make_shared>(); + auto& moduleCtrDtr = *moduleCtrDtrPtr; + auto moduleLabelsPtr = std::make_shared>(); + auto& moduleLabels = *moduleLabelsPtr; + iRegistry.watchPreModuleConstruction( + [&moduleLabels, &moduleCtrDtr, beginTime, iFilter](ModuleDescription const& md) { + auto const t = duration_cast(now() - beginTime).count(); + + auto const mid = md.id(); + if (mid < moduleLabels.size()) { + moduleLabels[mid] = md.moduleLabel(); + moduleCtrDtr[mid].beginConstruction = t; + } else { + moduleLabels.resize(mid + 1); + moduleLabels.back() = md.moduleLabel(); + moduleCtrDtr.resize(mid + 1); + moduleCtrDtr.back().beginConstruction = t; + } + iFilter->startOnThread(mid); + }); + iRegistry.watchPostModuleConstruction([&moduleCtrDtr, beginTime, iFilter](auto const& md) { + auto const t = duration_cast(now() - beginTime).count(); + moduleCtrDtr[md.id()].endConstruction = t; + auto alloc = iFilter->stopOnThread(md.id()); + if (alloc) { + moduleCtrDtr[md.id()].constructionAllocInfo = *alloc; + } + }); + + auto addDataInDtr = std::make_shared(false); + iRegistry.watchPreModuleDestruction([&moduleCtrDtr, beginTime, iFilter, addDataInDtr, logFile](auto const& md) { + auto const t = duration_cast(now() - beginTime).count(); + if (*addDataInDtr) { + if (iFilter->keepModuleInfo(md.id())) { + auto bmsg = assembleMessage( + static_cast>(Phase::destruction), 0, md.id(), 0, 0, 0, t); + logFile->write(std::move(bmsg)); + } + } else { + moduleCtrDtr[md.id()].beginDestruction = t; + } + iFilter->startOnThread(md.id()); + }); + iRegistry.watchPostModuleDestruction([&moduleCtrDtr, beginTime, iFilter, addDataInDtr, logFile](auto const& md) { + auto const t = duration_cast(now() - beginTime).count(); + if (not *addDataInDtr) { + moduleCtrDtr[md.id()].endDestruction = t; + } + auto info = iFilter->stopOnThread(md.id()); + if (info) { + if (*addDataInDtr) { + if (iFilter->keepModuleInfo(md.id())) { + auto emsg = assembleAllocMessage( + *info, static_cast>(Phase::destruction), 0, md.id(), 0, 0, 0, t); + logFile->write(std::move(emsg)); + } + + } else { + moduleCtrDtr[md.id()].destructionAllocInfo = *info; + } + } + }); + + auto sourceCtrPtr = std::make_shared(); + auto& sourceCtr = *sourceCtrPtr; + iRegistry.watchPreSourceConstruction([&sourceCtr, beginTime, iFilter](auto const&) { + auto const t = duration_cast(now() - beginTime).count(); + sourceCtr.beginConstruction = t; + iFilter->startOnThread(); + }); + iRegistry.watchPostSourceConstruction([&sourceCtr, beginTime, iFilter](auto const&) { + auto const t = duration_cast(now() - beginTime).count(); + sourceCtr.endConstruction = t; + auto info = iFilter->stopOnThread(); + if (info) { + sourceCtr.constructionAllocInfo = *info; + } + }); + + auto recordIndices = std::make_shared>(); + iRegistry.watchEventSetupConfiguration( + [logFile, recordIndices](auto const& recordsToResolvers, auto const&) mutable { + std::ostringstream oss; + + auto recordKeys = recordsToResolvers.recordKeys(); + std::sort(recordKeys.begin(), recordKeys.end()); + std::vector recordNames; + //want id to start at 1 not 0 + recordNames.reserve(recordKeys.size() + 1); + recordNames.emplace_back(""); + recordIndices->reserve(recordKeys.size() + 1); + recordIndices->push_back(std::type_index(typeid(void))); + for (auto const& r : recordKeys) { + recordNames.push_back(r.name()); + recordIndices->push_back(std::type_index(r.type().value())); + } + + moduleIdToLabel(oss, recordNames, 'R', "Record ID", "Record name"); + logFile->write(oss.str()); + }); + + iRegistry.watchPreBeginJob([logFile, + iFilter, + moduleLabelsPtr, + esModuleLabelsPtr, + moduleCtrDtrPtr, + sourceCtrPtr, + beginTime, + beginModuleAlloc, + addDataInDtr](auto&, auto&) mutable { + *addDataInDtr = true; + { + std::ostringstream oss; + moduleIdToLabel(oss, *moduleLabelsPtr, 'M', "EDModule ID", "Module label"); + logFile->write(oss.str()); + moduleLabelsPtr.reset(); + } + { + std::ostringstream oss; + moduleIdToLabel(oss, *esModuleLabelsPtr, 'N', "ESModule ID", "ESModule label"); + logFile->write(oss.str()); + esModuleLabelsPtr.reset(); + } + { + auto const moduleAllocStart = duration_cast(beginModuleAlloc - beginTime).count(); + auto msg = assembleMessage( + static_cast>(Phase::startTracing), 0, 0, 0, 0, moduleAllocStart); + logFile->write(std::move(msg)); + } + if (not iFilter->globalKeep()) { + auto const t = duration_cast(now() - beginTime).count(); + auto msg = assembleMessage( + static_cast>(Phase::beginJob), 0, 0, 0, 0, t); + logFile->write(std::move(msg)); + return; + } + //NOTE: the source construction can run concurently with module construction so we need to properly + // interleave its timing in with the modules + auto srcBeginConstruction = sourceCtrPtr->beginConstruction; + auto srcEndConstruction = sourceCtrPtr->endConstruction; + auto srcAllocInfo = sourceCtrPtr->constructionAllocInfo; + sourceCtrPtr.reset(); + auto handleSource = + [&srcBeginConstruction, &srcEndConstruction, &logFile, &srcAllocInfo](long long iTime) mutable { + if (srcBeginConstruction != 0 and srcBeginConstruction < iTime) { + auto bmsg = assembleMessage( + static_cast>(Phase::construction), 0, srcBeginConstruction); + logFile->write(std::move(bmsg)); + srcBeginConstruction = 0; + } + if (srcEndConstruction != 0 and srcEndConstruction < iTime) { + auto bmsg = assembleAllocMessage( + srcAllocInfo, static_cast>(Phase::construction), 0, srcEndConstruction); + logFile->write(std::move(bmsg)); + srcEndConstruction = 0; + } + }; + { + std::sort(moduleCtrDtrPtr->begin(), moduleCtrDtrPtr->end(), [](auto const& l, auto const& r) { + return l.beginConstruction < r.beginConstruction; + }); + int id = 0; + for (auto const& ctr : *moduleCtrDtrPtr) { + if (ctr.beginConstruction != 0) { + handleSource(ctr.beginConstruction); + if (iFilter->keepModuleInfo(id)) { + auto bmsg = assembleMessage( + static_cast>(Phase::construction), 0, id, 0, ctr.beginConstruction); + logFile->write(std::move(bmsg)); + } + handleSource(ctr.endConstruction); + if (iFilter->keepModuleInfo(id)) { + auto const& allocInfo = ctr.constructionAllocInfo; + auto emsg = assembleAllocMessage( + allocInfo, + static_cast>(Phase::construction), + 0, + id, + 0, + ctr.endConstruction); + logFile->write(std::move(emsg)); + } + } + ++id; + } + id = 0; + std::sort(moduleCtrDtrPtr->begin(), moduleCtrDtrPtr->end(), [](auto const& l, auto const& r) { + return l.beginDestruction < r.beginDestruction; + }); + for (auto const& dtr : *moduleCtrDtrPtr) { + if (dtr.beginDestruction != 0) { + handleSource(dtr.beginDestruction); + if (iFilter->keepModuleInfo(id)) { + auto bmsg = assembleMessage( + static_cast>(Phase::destruction), 0, id, 0, 0, 0, dtr.beginDestruction); + logFile->write(std::move(bmsg)); + } + handleSource(dtr.endDestruction); + if (iFilter->keepModuleInfo(id)) { + auto emsg = assembleAllocMessage( + dtr.destructionAllocInfo, + static_cast>(Phase::destruction), + 0, + id, + 0, + 0, + 0, + dtr.endDestruction); + logFile->write(std::move(emsg)); + } + } + ++id; + } + moduleCtrDtrPtr.reset(); + } + auto const t = duration_cast(now() - beginTime).count(); + handleSource(t); + auto msg = assembleMessage( + static_cast>(Phase::beginJob), 0, 0, 0, 0, t); + logFile->write(std::move(msg)); + }); + iRegistry.watchPostBeginJob([logFile, beginTime]() { + auto const t = duration_cast(now() - beginTime).count(); + auto msg = assembleMessage( + static_cast>(Phase::beginJob), 0, 0, 0, 0, t); + logFile->write(std::move(msg)); + }); + + iRegistry.watchPreEndJob([logFile, beginTime]() { + auto const t = duration_cast(now() - beginTime).count(); + auto msg = assembleMessage( + static_cast>(Phase::endJob), 0, 0, 0, 0, t); + logFile->write(std::move(msg)); + }); + iRegistry.watchPostEndJob([logFile, beginTime]() { + auto const t = duration_cast(now() - beginTime).count(); + auto msg = assembleMessage( + static_cast>(Phase::endJob), 0, 0, 0, 0, t); + logFile->write(std::move(msg)); + }); + + iRegistry.watchPreEvent([logFile, beginTime](auto const& sc) { + auto const t = duration_cast(now() - beginTime).count(); + auto msg = assembleMessage(static_cast>(Phase::Event), + stream_id(sc), + sc.eventID().run(), + sc.eventID().luminosityBlock(), + sc.eventID().event(), + t); + logFile->write(std::move(msg)); + }); + iRegistry.watchPostEvent([logFile, beginTime](auto const& sc) { + auto const t = duration_cast(now() - beginTime).count(); + auto msg = + assembleMessage(static_cast>(Phase::Event), + stream_id(sc), + sc.eventID().run(), + sc.eventID().luminosityBlock(), + sc.eventID().event(), + t); + logFile->write(std::move(msg)); + }); + + iRegistry.watchPreClearEvent([logFile, beginTime, iFilter](auto const& sc) { + if (iFilter->startOnThread()) { + auto const t = duration_cast(now() - beginTime).count(); + auto msg = + assembleMessage(static_cast>(Phase::clearEvent), + stream_id(sc), + sc.eventID().run(), + sc.eventID().luminosityBlock(), + sc.eventID().event(), + t); + logFile->write(std::move(msg)); + } + }); + iRegistry.watchPostClearEvent([logFile, beginTime, iFilter](auto const& sc) { + auto info = iFilter->stopOnThread(); + if (info) { + auto const t = duration_cast(now() - beginTime).count(); + auto msg = assembleAllocMessage( + *info, + static_cast>(Phase::clearEvent), + stream_id(sc), + sc.eventID().run(), + sc.eventID().luminosityBlock(), + sc.eventID().event(), + t); + logFile->write(std::move(msg)); + } + }); + + { + auto preGlobal = [logFile, beginTime](GlobalContext const& gc) { + auto const t = duration_cast(now() - beginTime).count(); + auto msg = assembleMessage(toTransition(gc), + toTransitionIndex(gc), + gc.luminosityBlockID().run(), + gc.luminosityBlockID().luminosityBlock(), + 0, + t); + logFile->write(std::move(msg)); + }; + iRegistry.watchPreBeginProcessBlock(preGlobal); + iRegistry.watchPreEndProcessBlock(preGlobal); + iRegistry.watchPreWriteProcessBlock(preGlobal); + iRegistry.watchPreAccessInputProcessBlock(preGlobal); + iRegistry.watchPreGlobalBeginRun(preGlobal); + iRegistry.watchPreGlobalBeginLumi(preGlobal); + iRegistry.watchPreGlobalEndLumi(preGlobal); + iRegistry.watchPreGlobalWriteLumi(preGlobal); + iRegistry.watchPreGlobalEndRun(preGlobal); + iRegistry.watchPreGlobalWriteRun(preGlobal); + } + { + auto postGlobal = [logFile, beginTime](GlobalContext const& gc) { + auto const t = duration_cast(now() - beginTime).count(); + auto msg = assembleMessage(toTransition(gc), + toTransitionIndex(gc), + gc.luminosityBlockID().run(), + gc.luminosityBlockID().luminosityBlock(), + 0, + t); + logFile->write(std::move(msg)); + }; + iRegistry.watchPostBeginProcessBlock(postGlobal); + iRegistry.watchPostEndProcessBlock(postGlobal); + iRegistry.watchPostWriteProcessBlock(postGlobal); + iRegistry.watchPostAccessInputProcessBlock(postGlobal); + iRegistry.watchPostGlobalBeginRun(postGlobal); + iRegistry.watchPostGlobalBeginLumi(postGlobal); + iRegistry.watchPostGlobalEndLumi(postGlobal); + iRegistry.watchPostGlobalWriteLumi(postGlobal); + iRegistry.watchPostGlobalEndRun(postGlobal); + iRegistry.watchPostGlobalWriteRun(postGlobal); + } + { + auto preStream = [logFile, beginTime](StreamContext const& sc) { + auto const t = duration_cast(now() - beginTime).count(); + auto msg = assembleMessage( + toTransition(sc), stream_id(sc), sc.eventID().run(), sc.eventID().luminosityBlock(), 0, t); + logFile->write(std::move(msg)); + }; + iRegistry.watchPreStreamBeginRun(preStream); + iRegistry.watchPreStreamBeginLumi(preStream); + iRegistry.watchPreStreamEndLumi(preStream); + iRegistry.watchPreStreamEndRun(preStream); + } + { + auto postStream = [logFile, beginTime](StreamContext const& sc) { + auto const t = duration_cast(now() - beginTime).count(); + auto msg = assembleMessage( + toTransition(sc), stream_id(sc), sc.eventID().run(), sc.eventID().luminosityBlock(), 0, t); + logFile->write(std::move(msg)); + }; + iRegistry.watchPostStreamBeginRun(postStream); + iRegistry.watchPostStreamBeginLumi(postStream); + iRegistry.watchPostStreamEndLumi(postStream); + iRegistry.watchPostStreamEndRun(postStream); + } + { + iRegistry.watchPreOpenFile([logFile, beginTime, iFilter](std::string const&) { + if (iFilter->startOnThread()) { + auto const t = duration_cast(now() - beginTime).count(); + auto msg = assembleMessage( + static_cast>(Phase::openFile), 0, t); + logFile->write(std::move(msg)); + } + }); + iRegistry.watchPostOpenFile([logFile, beginTime, iFilter](std::string const&) { + auto info = iFilter->stopOnThread(); + if (info) { + auto const t = duration_cast(now() - beginTime).count(); + auto msg = assembleAllocMessage( + *info, static_cast>(Phase::openFile), 0, t); + logFile->write(std::move(msg)); + } + }); + iRegistry.watchPreSourceEvent([logFile, beginTime, iFilter](StreamID id) { + if (iFilter->startOnThread()) { + auto const t = duration_cast(now() - beginTime).count(); + auto msg = assembleMessage( + static_cast>(Phase::Event), id.value(), t); + logFile->write(std::move(msg)); + } + }); + iRegistry.watchPostSourceEvent([logFile, beginTime, iFilter](StreamID id) { + auto info = iFilter->stopOnThread(); + if (info) { + auto const t = duration_cast(now() - beginTime).count(); + auto msg = assembleAllocMessage( + *info, static_cast>(Phase::Event), id.value(), t); + logFile->write(std::move(msg)); + } + }); + + iRegistry.watchPreSourceRun([logFile, beginTime, iFilter](RunIndex id) { + if (iFilter->startOnThread()) { + auto const t = duration_cast(now() - beginTime).count(); + auto msg = assembleMessage( + static_cast>(Phase::globalBeginRun), id.value(), t); + logFile->write(std::move(msg)); + } + }); + iRegistry.watchPostSourceRun([logFile, beginTime, iFilter](RunIndex id) { + auto info = iFilter->stopOnThread(); + if (info) { + auto const t = duration_cast(now() - beginTime).count(); + auto msg = assembleAllocMessage( + *info, static_cast>(Phase::globalBeginRun), id.value(), t); + logFile->write(std::move(msg)); + } + }); + + iRegistry.watchPreSourceLumi([logFile, beginTime, iFilter](auto id) { + if (iFilter->startOnThread()) { + auto const t = duration_cast(now() - beginTime).count(); + auto msg = assembleMessage( + static_cast>(Phase::globalBeginLumi), id.value(), t); + logFile->write(std::move(msg)); + } + }); + iRegistry.watchPostSourceLumi([logFile, beginTime, iFilter](auto id) { + auto info = iFilter->stopOnThread(); + if (info) { + auto const t = duration_cast(now() - beginTime).count(); + auto msg = assembleAllocMessage( + *info, static_cast>(Phase::globalBeginLumi), id.value(), t); + logFile->write(std::move(msg)); + } + }); + + iRegistry.watchPreSourceNextTransition([logFile, beginTime, iFilter]() { + if (iFilter->startOnThread()) { + auto const t = duration_cast(now() - beginTime).count(); + auto msg = assembleMessage( + static_cast>(Phase::getNextTransition), t); + logFile->write(std::move(msg)); + } + }); + iRegistry.watchPostSourceNextTransition([logFile, beginTime, iFilter]() { + auto info = iFilter->stopOnThread(); + if (info) { + auto const t = duration_cast(now() - beginTime).count(); + auto msg = assembleAllocMessage( + *info, static_cast>(Phase::getNextTransition), t); + logFile->write(std::move(msg)); + } + }); + + //ED Modules + iRegistry.watchPreModuleBeginJob([logFile, beginTime, iFilter](auto const& md) { + if (iFilter->startOnThread(md.id())) { + auto const t = duration_cast(now() - beginTime).count(); + auto msg = assembleMessage( + static_cast>(Phase::beginJob), 0, md.id(), 0, t); + logFile->write(std::move(msg)); + } + }); + iRegistry.watchPostModuleBeginJob([logFile, beginTime, iFilter](auto const& md) { + auto info = iFilter->stopOnThread(md.id()); + if (info) { + auto const t = duration_cast(now() - beginTime).count(); + auto msg = assembleAllocMessage( + *info, static_cast>(Phase::beginJob), 0, md.id(), 0, t); + logFile->write(std::move(msg)); + } + }); + + iRegistry.watchPreModuleBeginStream(StreamEDModuleState(logFile, beginTime, iFilter)); + iRegistry.watchPostModuleBeginStream( + StreamEDModuleState(logFile, beginTime, iFilter)); + + iRegistry.watchPreModuleEndStream(StreamEDModuleState(logFile, beginTime, iFilter)); + iRegistry.watchPostModuleEndStream(StreamEDModuleState(logFile, beginTime, iFilter)); + + iRegistry.watchPreModuleEndJob([logFile, beginTime, iFilter](auto const& md) { + if (iFilter->startOnThread(md.id())) { + auto const t = duration_cast(now() - beginTime).count(); + auto msg = assembleMessage( + static_cast>(Phase::endJob), 0, md.id(), 0, t); + logFile->write(std::move(msg)); + } + }); + iRegistry.watchPostModuleEndJob([logFile, beginTime, iFilter](auto const& md) { + auto info = iFilter->stopOnThread(md.id()); + if (info) { + auto const t = duration_cast(now() - beginTime).count(); + auto msg = assembleAllocMessage( + *info, static_cast>(Phase::endJob), 0, md.id(), 0, t); + logFile->write(std::move(msg)); + } + }); + + iRegistry.watchPreModuleEvent(StreamEDModuleState(logFile, beginTime, iFilter)); + iRegistry.watchPostModuleEvent(StreamEDModuleState(logFile, beginTime, iFilter)); + iRegistry.watchPreModuleEventAcquire( + StreamEDModuleState(logFile, beginTime, iFilter)); + iRegistry.watchPostModuleEventAcquire( + StreamEDModuleState(logFile, beginTime, iFilter)); + iRegistry.watchPreModuleEventDelayedGet( + StreamEDModuleState(logFile, beginTime, iFilter)); + iRegistry.watchPostModuleEventDelayedGet( + StreamEDModuleState(logFile, beginTime, iFilter)); + iRegistry.watchPreEventReadFromSource( + StreamEDModuleState(logFile, beginTime, iFilter)); + iRegistry.watchPostEventReadFromSource( + StreamEDModuleState(logFile, beginTime, iFilter)); + + iRegistry.watchPreModuleTransform(StreamEDModuleState(logFile, beginTime, iFilter)); + iRegistry.watchPostModuleTransform(StreamEDModuleState(logFile, beginTime, iFilter)); + iRegistry.watchPreModuleTransformAcquiring( + StreamEDModuleState(logFile, beginTime, iFilter)); + iRegistry.watchPostModuleTransformAcquiring( + StreamEDModuleState(logFile, beginTime, iFilter)); + + iRegistry.watchPreModuleStreamBeginRun( + StreamEDModuleState(logFile, beginTime, iFilter)); + iRegistry.watchPostModuleStreamBeginRun( + StreamEDModuleState(logFile, beginTime, iFilter)); + iRegistry.watchPreModuleStreamEndRun(StreamEDModuleState(logFile, beginTime, iFilter)); + iRegistry.watchPostModuleStreamEndRun( + StreamEDModuleState(logFile, beginTime, iFilter)); + + iRegistry.watchPreModuleStreamBeginLumi( + StreamEDModuleState(logFile, beginTime, iFilter)); + iRegistry.watchPostModuleStreamBeginLumi( + StreamEDModuleState(logFile, beginTime, iFilter)); + iRegistry.watchPreModuleStreamEndLumi( + StreamEDModuleState(logFile, beginTime, iFilter)); + iRegistry.watchPostModuleStreamEndLumi( + StreamEDModuleState(logFile, beginTime, iFilter)); + + iRegistry.watchPreModuleBeginProcessBlock( + GlobalEDModuleState(logFile, beginTime, iFilter)); + iRegistry.watchPostModuleBeginProcessBlock( + GlobalEDModuleState(logFile, beginTime, iFilter)); + iRegistry.watchPreModuleAccessInputProcessBlock( + GlobalEDModuleState(logFile, beginTime, iFilter)); + iRegistry.watchPostModuleAccessInputProcessBlock( + GlobalEDModuleState(logFile, beginTime, iFilter)); + iRegistry.watchPreModuleEndProcessBlock( + GlobalEDModuleState(logFile, beginTime, iFilter)); + iRegistry.watchPostModuleEndProcessBlock( + GlobalEDModuleState(logFile, beginTime, iFilter)); + + iRegistry.watchPreModuleGlobalBeginRun( + GlobalEDModuleState(logFile, beginTime, iFilter)); + iRegistry.watchPostModuleGlobalBeginRun( + GlobalEDModuleState(logFile, beginTime, iFilter)); + iRegistry.watchPreModuleGlobalEndRun(GlobalEDModuleState(logFile, beginTime, iFilter)); + iRegistry.watchPostModuleGlobalEndRun( + GlobalEDModuleState(logFile, beginTime, iFilter)); + + iRegistry.watchPreModuleGlobalBeginLumi( + GlobalEDModuleState(logFile, beginTime, iFilter)); + iRegistry.watchPostModuleGlobalBeginLumi( + GlobalEDModuleState(logFile, beginTime, iFilter)); + iRegistry.watchPreModuleGlobalEndLumi( + GlobalEDModuleState(logFile, beginTime, iFilter)); + iRegistry.watchPostModuleGlobalEndLumi( + GlobalEDModuleState(logFile, beginTime, iFilter)); + + iRegistry.watchPreModuleWriteProcessBlock( + GlobalEDModuleState(logFile, beginTime, iFilter)); + iRegistry.watchPostModuleWriteProcessBlock( + GlobalEDModuleState(logFile, beginTime, iFilter)); + + iRegistry.watchPreModuleWriteRun(GlobalEDModuleState(logFile, beginTime, iFilter)); + iRegistry.watchPostModuleWriteRun(GlobalEDModuleState(logFile, beginTime, iFilter)); + + iRegistry.watchPreModuleWriteLumi(GlobalEDModuleState(logFile, beginTime, iFilter)); + iRegistry.watchPostModuleWriteLumi(GlobalEDModuleState(logFile, beginTime, iFilter)); + + //ES Modules + iRegistry.watchPreESModule(ESModuleState(logFile, beginTime, recordIndices, iFilter)); + iRegistry.watchPostESModule(ESModuleState(logFile, beginTime, recordIndices, iFilter)); + iRegistry.watchPreESModuleAcquire( + ESModuleState(logFile, beginTime, recordIndices, iFilter)); + iRegistry.watchPostESModuleAcquire( + ESModuleState(logFile, beginTime, recordIndices, iFilter)); + } + + std::ostringstream oss; + oss << "# Transition Type Symbol\n"; + oss << "#------------------------ ------\n"; + oss << "# startTracing " << Phase::startTracing << "\n" + << "# construction " << Phase::construction << "\n" + << "# getNextTransition " << Phase::getNextTransition << "\n" + << "# beginJob " << Phase::beginJob << "\n" + << "# beginStream " << Phase::beginStream << "\n" + << "# openFile " << Phase::openFile << "\n" + << "# beginProcessBlock " << Phase::beginProcessBlock << "\n" + << "# accessInputProcessBlock " << Phase::accessInputProcessBlock << "\n" + << "# globalBeginRun " << Phase::globalBeginRun << "\n" + << "# streamBeginRun " << Phase::streamBeginRun << "\n" + << "# globalBeginLumi " << Phase::globalBeginLumi << "\n" + << "# streamBeginLumi " << Phase::streamBeginLumi << "\n" + << "# Event " << Phase::Event << "\n" + << "# clearEvent " << Phase::clearEvent << "\n" + << "# streamEndLumi " << Phase::streamEndLumi << "\n" + << "# globalEndLumi " << Phase::globalEndLumi << "\n" + << "# globalWriteLumi " << Phase::globalWriteLumi << "\n" + << "# streamEndRun " << Phase::streamEndRun << "\n" + << "# globalEndRun " << Phase::globalEndRun << "\n" + << "# globalWriteRun " << Phase::globalWriteRun << "\n" + << "# endProcessBlock " << Phase::endProcessBlock << "\n" + << "# writeProcessBlock " << Phase::writeProcessBlock << "\n" + << "# endStream " << Phase::endStream << "\n" + << "# endJob " << Phase::endJob << "\n" + << "# destruction " << Phase::destruction << "\n\n"; + constexpr std::string_view kTransition = " "; + constexpr std::string_view kTransitionInfo = " "; + constexpr std::string_view kTime = "