diff --git a/.gitignore b/.gitignore index 18c3a131a44a04ba6c2bfc2f3ab0ea16a78dd01f..5d79697f5fe4b8747f2ad0993e82ddba10c0406f 100644 --- a/.gitignore +++ b/.gitignore @@ -32,7 +32,32 @@ DoxyWarnings.log .pydevproject .eclipse/ -# CMT tempoary files +# Environment files (VSCode) +**/.vscode +.env + +# Jupyter Notebook +.ipynb_checkpoints + +# IPython +profile_default/ +ipython_config.py + +# pytest byproducts +.pytest_cache/ + +# QMTest byproducts +*.new +**/tests/qmtest/*.* +!**/tests/qmtest/*.qms +!**/tests/qmtest/*.qmt + +# Sphinx by-products +doc/_env* +doc/_build +doc/graphviz +doc/selection/ + build.*.log Makefile NMake @@ -48,3 +73,4 @@ i686-winxp-vc9-dbg/ .*-slc[56]-*.d/ .i686-winxp-vc9-dbg.d/ .clang-format + diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 83f96c657269b6376de76ec82bf359117432f7ca..174752d69440a6f765ce4b24ecba27c779c9f64c 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -42,3 +42,7 @@ python-linting: # Lint a single file because much of the code in Analysis is yet to be checked whether it will be kept for run 3. # This one file has been updated to pass the linter checks! - flake8 --exclude '*.opts.py' --select=F,E71,E9,W1,W6 $(find Phys/FunTuple -name '*.py') + +include: + - project: 'lhcb-rta/reference-update-bot' + file: 'templates/ref-bot-ci-trigger-template.yml' diff --git a/AnalysisSys/tests/refs/configurables.ref b/AnalysisSys/tests/refs/configurables.ref deleted file mode 100644 index 5177c46377918c8a31656ad0bebc0241317b3c18..0000000000000000000000000000000000000000 --- a/AnalysisSys/tests/refs/configurables.ref +++ /dev/null @@ -1 +0,0 @@ -{'DaVinciTrackRefitting': {'RefitParticleTracks': True, 'ParticleRefitter': True, 'TracksFromParticles': True}, 'JetTagging': {'LoKi__MuonTag': True, 'LoKi__SVTag': True, 'LoKi__ElectronTag': True, 'LoKi__TopoTag': True, 'LoKi__TopoTagDir': True, 'LoKi__JetTagTruthNew': True, 'LoKi__JetTagTruthMCPart': True, 'LoKi__SeedFinderNTrks': True, 'LoKi__JetTagTruth': True, 'LoKi__NNBTag': True, 'FilterJet': True, 'LoKi__IPTag': True}, 'DecayTreeTupleDalitz': {'TupleToolDalitz': True, 'MCTupleToolDalitz': True}, 'ParticleMakerChecker': {'ParticleEffPurMoni': True}, 'DecayTreeTupleMuonCalib': {'TupleToolMuonPid': True, 'TupleToolMuonIDCalib': True}, 'DaVinciAssociators': {'ChargedPP2MC': True, 'Particle2MCChi2': True, 'NeutralPP2MC': True, 'CompositeParticle2MCLinks': True, 'Particle2MCWithChi2': True, 'Particle2MCLinks': True, 'TestLinker': True}, 'RichPIDQC': {'JPsiMuMuConf': True, 'KshortPiPiConf': True, 'LambdaToProtonPionConf': True, 'DsToPhiPiConf': True, 'DstarToDzeroPiConf': True, 'RichPIDQCConf': True}, 'DecayTreeTupleBase': {'EventTuple': True, 'MCDecayTreeTuple': True, 'DecayTreeTuple': True, 'TupleToolDecay': True}, 'DaVinciMCTools': {'FilterEventByMCDecay': True, 'MCPrimVertexMaker': True, 'BackgroundCategoryViaRelations': True, 'MCReconstructed': True, 'DaVinciSmartAssociator': True, 'MCParticleMaker': True, 'FilterToFixOppositeBFractions': True, 'MCParticleLinkerMaker': True, 'IsBEvent': True, 'P2MCPFromProtoP': True, 'DumpParticle': True, 'BackgroundCategory': True, 'DaVinciAssociatorsWrapper': True, 'MCParticleArrayFilterAlg': True, 'Particle2BackgroundCategoryRelationsAlg': True, 'PrintDecayTreeTool': True, 'FilterMCParticleArrayByDecay': True}, 'MicroDSTTools': {'CaloHypoCloner': True, 'WeightsVectorCloner': True, 'ParticleCloner': True, 'SwimmingReportCloner': True, 'VertexBaseFromRecVertexCloner': True, 'MuonPIDCloner': True, 'FlavourTagCloner': True, 'VertexBaseFromRecVertexClonerNoTracks': True, 'RecVertexClonerWithTracks': True, 'VertexBaseFromRecVertexClonerWithTracks': True, 'FlavourTagDeepCloner': True, 'MCVertexCloner': True, 'ProtoParticleCloner': True, 'VertexCloner': True, 'TrackCloner': True, 'RecVertexClonerNoTracks': True, 'MCParticleCloner': True, 'RecVertexCloner': True, 'CaloClusterCloner': True}, 'DecayTreeTuple': {'TupleToolVeto': True, 'TupleToolPi0Info': True, 'TupleToolParticleStats': True, 'TupleToolTagging': True, 'TupleToolSubMass': True, 'TupleToolMassHypo': True, 'TupleToolDira': True, 'TupleToolAngles': True, 'TupleToolGeometry': True, 'TupleToolPropertime': True, 'TupleToolDecayTreeFitter': True, 'TupleToolPid': True, 'TupleToolPhotonInfo': True, 'TupleToolP2VV': True, 'TupleToolBremInfo': True, 'TupleToolSelResults': True, 'TupleToolNeutrinoReco': True, 'TupleToolParticleReFit': True, 'TupleToolIsolationTwoBody': True, 'TupleToolVtxIsoln': True, 'TupleToolSwimmingInfo': True, 'TupleToolCaloHypo': True, 'TupleToolKinematic': True}, 'DaVinciTrackScaling': {'TrackSmearState': True, 'OldTrackSmearState': True, 'TrackScaleState': True}, 'Particle2MCTruth': {'MCMatchObjP2MCRelator': True, 'P2MCRelatorAlg': True}, 'DaVinciAngleCalculators': {'P2VVAngleCalculator': True, 'Bs2JpsiPhiAngleCalculator': True, 'Bd2KstarMuMuAngleCalculator': True, 'MCBs2JpsiPhiAngleCalculator': True, 'MCBd2KstarMuMuAngleCalculator': True}, 'LoKiPhysMC': {'LoKi__HepMCParticleMaker': True, 'LoKi__PV2MC': True, 'LoKi__Hybrid__MCTupleTool': True, 'LoKi__PV2MCAlg': True, 'LoKi__P2MCW': True, 'LoKi__Track2MC': True, 'LoKi__P2MC': True}, 'LoKiGenMC': {'LoKi__MC2GenCollisionAlg': True, 'LoKi__HepMC2MC': True, 'LoKi__HepMC2MCAlg': True, 'LoKi__MC2GenCollision': True}, 'VertexFitCheck': {'VtxChecker': True, 'ProperTimeChecker': True, 'CheatedPVReFitter': True, 'PhotonChecker': True, 'PVChecker': True}, 'DecayTreeTupleReco': {'TupleToolPrimaries': True, 'TupleToolTrackInfo': True, 'TupleToolRICHPid': True, 'TupleToolCPU': True, 'TupleToolProtoPData': True, 'TupleToolRecoStats': True}, 'DisplVerticesMC': {'SaveParticlesFrom': True, 'MCDisplVertices': True}, 'Analysis': {'DummyAnalysisAlg': True}, 'FlavourTaggingChecker': {'CheatedSelection': True, 'BDecayTool': True, 'BTaggingInclusive': True, 'BOppositeMonitoring': True, 'BTaggingAnalysis': True, 'TaggingUtilsChecker': True, 'BTaggingChecker': True}, 'HltSelChecker': {'HltCorrelations': True, 'HltBackgroundCategory': True, 'Hlt2Statistics': True, 'FilterTrueTracks': True, 'ReadHltReport': True}, 'DaVinciMonitors': {'ANNPIDTool': True, 'MuonPlotTool': True, 'ParticleMonitor': True, 'MomentumPlotTool': True, 'MassPlotTool': True, 'CombinedPidPlotTool': True, 'MuIDMonitor': True, 'CaloPlotTool': True, 'SimplePlots': True, 'MuEffMonitor': True, 'RichPlotTool': True}, 'DecayTreeTupleANNPID': {'TupleToolANNPIDTraining': True, 'TupleToolANNPID': True}, 'JetAccessoriesMC': {'LoKi__HepMCJets2HepMCJets': True, 'LoKi__HEPMCJetMaker': True, 'LoKi__ParticleMaker': True, 'LoKi__HepMCJets2Jets': True, 'LoKi__HepMCJets2JetsDeltaR': True, 'LoKi__MCJetMaker': True, 'LoKi__MCJets2Jets': True, 'WZPlusJetHepMCSelector': True, 'LoKi__MCPartBHadronSeed': True, 'MCJets2JetsAlg': True, 'LoKi__PartonicJets2HepMCJets': True, 'ZPlusJetHepMCSelector': True}, 'LoKiAlgoMC': {'LoKi__DecayTruth': True, 'LoKi__Hybrid__MCParticleArrayFilter': True}, 'LoKiExample': {'LoKi__Bs2PsiPhi': True, 'LoKi__CCTest': True, 'LoKi__Phi_Makers': True, 'LoKi__Fitters': True, 'LoKi__PhiMC': True, 'LoKi__DecayDescriptor': True, 'LoKi__MCMergedPi0s': True, 'LoKi__Phi': True, 'LoKi__SelectParticles': True, 'LoKi__MemFun': True, 'LoKi__SelectTracks': True, 'LoKi__TestHybrid': True, 'LoKi__GenDecayDescriptor': True, 'LoKi__MCMuons': True, 'LoKi__Track2MCEx': True, 'LoKi__MCSelect': True, 'LoKi__CheckMC_Bs2PsiPhi': True, 'LoKi__PhiK_Dalitz': True, 'LoKi__IPCheck': True, 'LoKi__Example__PV2MCEx': True, 'LoKi__MCDecayDescriptor': True, 'LoKi__TestFunctor': True, 'LoKi__DCCheck': True, 'LoKi__HelloWorld': True, 'LoKi__Bs2PsiPhi_NoMC': True}, 'DecayTreeTupleTracking': {'TupleToolVELOClusters': True, 'TupleToolTrackKink': True, 'TupleToolVeloTrackClusterInfo': True, 'TupleToolVeloTrackMatch': True, 'TupleToolDEDX': True, 'TupleToolTrackIsolation': True, 'TupleToolTrackPosition': True}, 'DecayTreeTupleTrigger': {'TupleToolTISTOS': True, 'TupleToolL0Data': True, 'TupleToolTrigger': True, 'TupleToolStripping': True, 'TupleToolTriggerRecoStats': True, 'TupleToolL0Calo': True, 'TupleToolEventInfo': True}, 'DSTWriters': {'SelDSTWriter': True, 'FixInputCopyStream': True, 'StripDSTWriter': True, 'MicroDSTWriter': True}, 'DecayTreeTupleMC': {'MCTupleToolInteractions': True, 'MCTupleToolPrimaries': True, 'MCTupleToolPID': True, 'MCTupleToolReconstructed': True, 'MCTupleToolPrompt': True, 'MCTupleToolDecayType': True, 'MCTupleToolAngles': True, 'TupleToolGeneration': True, 'TupleToolMCTruth': True, 'TupleToolMCBackgroundInfo': True, 'MCTupleToolKinematic': True, 'MCTupleToolEventType': True, 'MCTupleToolHierarchy': True, 'MCTupleToolP2VV': True}, 'DecayTreeTupleJets': {'TupleToolWZJets': True, 'TupleToolJetTag': True, 'TupleToolJets': True, 'TupleToolJetRelations': True}, 'MicroDSTAlgorithm': {'CopyParticle2TPRelations': True, 'CopySwimmingReports': True, 'CopyParticle2LHCbIDs': True, 'CopyParticle2BackgroundCategory': True, 'CopyGaudiNumbers': True, 'CopyMCHeader': True, 'CopyRecSummary': True, 'CopyPrimaryVertices': True, 'CopyParticle2PVWeightedRelations': True, 'CopyODIN': True, 'CopyParticle2RelatedInfo': True, 'CopyFlavourTag': True, 'CopyParticle2MCRelations': True, 'CopyParticle2PVRelations': True, 'CopyL0DUReport': True, 'CopyParticles': True, 'CopyParticle2TisTosDecisions': True, 'CopyParticle2PVMap': True, 'CopyRecHeader': True, 'CopyMCParticles': True, 'MoveDataObject': True, 'CopyProtoParticles': True, 'CopyPVWeights': True, 'CopyHltDecReports': True}, 'TrackSmearing': {'TrackSmeared': True, 'IpImprover': True}} diff --git a/CMakeLists.txt b/CMakeLists.txt index 78f0da63afacd43190c7f700e37c3ac565801836..53abf9b5250791570334f4ca42c85e31663b686d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,7 +11,7 @@ cmake_minimum_required(VERSION 3.15) -project(Analysis VERSION 34.0 +project(Analysis VERSION 34.1 LANGUAGES CXX) # Enable testing with CTest/CDash @@ -39,26 +39,12 @@ lhcb_add_subdirectories( Phys/DaVinciDecayFinder Phys/DaVinciMCTools Phys/DaVinciTools - Phys/DaVinciTrackRefitting Phys/DaVinciTrackScaling - Phys/DecayTreeTuple - Phys/DecayTreeTupleANNPID - Phys/DecayTreeTupleBase - Phys/DecayTreeTupleDalitz - Phys/DecayTreeTupleHerschel - Phys/DecayTreeTupleJets - Phys/DecayTreeTupleMC - Phys/DecayTreeTupleMuonCalib - Phys/DecayTreeTupleReco - Phys/DecayTreeTupleTracking - Phys/DecayTreeTupleTrigger Phys/DSTWriters Phys/FunTuple Phys/LoKiAlgoMC Phys/LoKiPhysMC Phys/Particle2MCTruth - Phys/ParticleMakerChecker - Rich/RichPIDQC ) lhcb_finalize_configuration() diff --git a/Phys/DSTWriters/CMakeLists.txt b/Phys/DSTWriters/CMakeLists.txt index 573821799cb0e516279144778baeb40c158187df..c9e59590f4d22f57c46c9528bb7667536d748304 100644 --- a/Phys/DSTWriters/CMakeLists.txt +++ b/Phys/DSTWriters/CMakeLists.txt @@ -23,3 +23,8 @@ gaudi_add_module(DSTWriters gaudi_install(PYTHON) gaudi_generate_confuserdb() +lhcb_add_confuser_dependencies( + GaudiAlg:GaudiAlg + GaudiCommonSvc:GaudiCommonSvc + GaudiCoreSvc:GaudiCoreSvc +) diff --git a/Phys/DSTWriters/python/DSTWriters/microdstelements.py b/Phys/DSTWriters/python/DSTWriters/microdstelements.py index 3e57651bea3c2449356778c8175351f223bbe0d7..c6064101fbfaf25512bb917c71f96ba731547a38 100644 --- a/Phys/DSTWriters/python/DSTWriters/microdstelements.py +++ b/Phys/DSTWriters/python/DSTWriters/microdstelements.py @@ -664,10 +664,10 @@ class PackRecObjects(MicroDSTElement): ] # CALO Clusters - from Configurables import DataPacking__Pack_LHCb__CaloClusterPacker_ as PackCaloClusters + from Configurables import CaloClusterPacker for type in ['EcalClusters', 'HcalClusters', 'EcalSplitClusters']: algs += [ - PackCaloClusters( + CaloClusterPacker( name=self.personaliseName(sel, "Pack" + type), AlwaysCreateOutput=False, DeleteInput=deleteInput, @@ -677,10 +677,10 @@ class PackRecObjects(MicroDSTElement): ] # CALO Digits - from Configurables import DataPacking__Pack_LHCb__CaloDigitPacker_ as PackCaloDigits + from Configurables import CaloDigitPacker for type in ["Ecal", "Prs", "Spd"]: algs += [ - PackCaloDigits( + CaloDigitPacker( name=self.personaliseName(sel, "PackCalo" + type + "Digits"), AlwaysCreateOutput=False, @@ -691,10 +691,10 @@ class PackRecObjects(MicroDSTElement): ] # CALO ADCs - from Configurables import DataPacking__Pack_LHCb__CaloAdcPacker_ as PackCaloADCs + from Configurables import CaloAdcPacker for type in ["Ecal", "Prs"]: algs += [ - PackCaloADCs( + CaloAdcPacker( name=self.personaliseName(sel, "PackCalo" + type + "ADCs"), AlwaysCreateOutput=False, DeleteInput=deleteInput, @@ -704,9 +704,9 @@ class PackRecObjects(MicroDSTElement): ] # RICH PIDs - from Configurables import DataPacking__Pack_LHCb__RichPIDPacker_ as PackRichPIDs + from Configurables import RichPIDPacker algs += [ - PackRichPIDs( + RichPIDPacker( name=self.personaliseName(sel, "PackRichPIDs"), AlwaysCreateOutput=False, DeleteInput=deleteInput, @@ -716,9 +716,9 @@ class PackRecObjects(MicroDSTElement): ] # MUON PIDs - from Configurables import DataPacking__Pack_LHCb__MuonPIDPacker_ as PackMuonPIDs + from Configurables import MuonPIDPacker algs += [ - PackMuonPIDs( + MuonPIDPacker( name=self.personaliseName(sel, "PackMuonPIDs"), AlwaysCreateOutput=False, DeleteInput=deleteInput, diff --git a/Phys/DaVinciAssociators/src/TestLinker.cpp b/Phys/DaVinciAssociators/src/TestLinker.cpp index dd1d7c6670312b750dc5fc11d54238554d8aa94c..64a1dfc1c98224a53499e1dd539aabd3600afbbb 100755 --- a/Phys/DaVinciAssociators/src/TestLinker.cpp +++ b/Phys/DaVinciAssociators/src/TestLinker.cpp @@ -400,11 +400,11 @@ int TestLinker::trType( const Track* tr ) { // int type = 0; if ( tr ) { - if ( tr->checkHistory( Track::History::PatForward ) ) type = 1; - if ( tr->checkHistory( Track::History::TrackMatching ) ) type = 2; - if ( tr->checkHistory( Track::History::PatVelo ) ) type = 3; - if ( tr->checkHistory( Track::History::TrackSeeding ) ) type = 4; - if ( tr->checkHistory( Track::History::PatKShort ) ) type = 5; + if ( tr->checkHistory( Track::History::PrForward ) ) type = 1; + if ( tr->checkHistory( Track::History::PrMatch ) ) type = 2; + if ( tr->checkHistory( Track::History::PrPixel ) ) type = 3; + if ( tr->checkHistory( Track::History::PrSeeding ) ) type = 4; + if ( tr->checkHistory( Track::History::PrDownstream ) ) type = 5; } return type; } diff --git a/Phys/DaVinciMCTools/src/MCReconstructed.cpp b/Phys/DaVinciMCTools/src/MCReconstructed.cpp index 3f0ee72a5124babe380491d5e5f1119da7ffe409..a368d84423c9e6e2f4247856a2b4b2fab6887006 100755 --- a/Phys/DaVinciMCTools/src/MCReconstructed.cpp +++ b/Phys/DaVinciMCTools/src/MCReconstructed.cpp @@ -110,9 +110,8 @@ IMCReconstructed::RecCategory MCReconstructed::reconstructed( const LHCb::MCPart break; // Other enum values not covered by the original logic - case LHCb::Track::Types::TypeUnknown: + case LHCb::Track::Types::Unknown: case LHCb::Track::Types::Velo: - case LHCb::Track::Types::VeloR: case LHCb::Track::Types::Ttrack: case LHCb::Track::Types::Muon: default: diff --git a/Phys/DaVinciTrackRefitting/doc/release.notes b/Phys/DaVinciTrackRefitting/doc/release.notes deleted file mode 100755 index a6fb52e3a735a2a8e1d963f3189c8e4e37a9b6ad..0000000000000000000000000000000000000000 --- a/Phys/DaVinciTrackRefitting/doc/release.notes +++ /dev/null @@ -1,98 +0,0 @@ -!----------------------------------------------------------------------------- -! Package : Phys/DaVinciTrackRefitting -! Responsible : Matthew.Needham@cern.ch -! Purpose : Provide tools for refitting on DST -!----------------------------------------------------------------------------- - -!=================== DaVinciTrackRefitting v2r5 2016-03-04 =================== - -! 2016-02-28 - Paul Seyfert - - Bugfix for ghost probability configuration as in Reco14 - -!=================== DaVinciTrackRefitting v2r4 2016-02-08 =================== - -! 2016-02-08 - Eduardo Rodrigues - - Removed the QMTest tests/qmtest/davincitrackrefitting.qms/ as it required - DaVinci (at least in its present form), which caused the test to fail. - For now moved to a new directory under the DaVinciTests package. - The necessary options file under options/ remains here. Can always be changed. - -! 2016-01-25 - Paul Seyfert - - added proof of principle of qmtest for track refitting - (running on Stripping 23 DST) - to be done: S23 MDST, other strippings, integration test - -! 2016-01-21 - Paul Seyfert - - added functionality for integration and qm test to refitter - - configure ghost probability to run in DaVinci - -> requires Tr/TrackTools r200091 or later - -!=================== DaVinciTrackRefitting v2r3 2015-12-04 =================== - -! 2015-12-04 - Paul Seyfert - - pack refitter into python function - -!=================== DaVinciTrackRefitting v2r2 2015-10-19 =================== - -! 2015-09-06 - Paul Seyfert - - refitting instruction updated + fixes after testrun - -!=================== DaVinciTrackRefitting v2r1 2015-07-24 =================== - -! 2015-06-22 - Paul Seyfert - - bugfix for event initialisation of RefitParticleTracks with latest - GhostProbability interface - -!=================== DaVinciTrackRefitting v2r0 2015-06-03 =================== - -! 2015-06-02 - Paul Seyfert - - Adapt RefitParticleTracks to change of GhostProbability interface - -!=================== DaVinciTrackRefitting v1r5 2015-01-16 =================== - -! 2015-01-16 - Eduardo Rodrigues - - Added python/DaVinciTrackRefitting/__init__.py to please CMake. - -!========================= DaVinciTrackRefitting v1r4p1 2013-10-29 ========================= - -! 2013-10-23 - Paul Seyfert - - Fixed off-by-one error in RefitParticleTracks with ReplaceTracks = False - (caused segfault) - -!========================= DaVinciTrackRefitting v1r4 2013-05-07 ========================= - -! 2013-04-15 - Paul Seyfert - - cleanup of example script - - add missing StatusCode checks - -!========================= DaVinciTrackRefitting v1r3 2013-04-05 ========================= - -! 2013-02-27 - Chris Jones - - Fix -pedantic compilation warnings - -! 2013-02-22 - Paul Seyfert - - Added ParticleRefitter algorithm to update existing Particles in case their - tracks were manipulated (limited functionality, no individual vertex - fitters for individual decays) - - Added python module ParticleRefitterSeq to wrap ParticleRefitter and apply - momentum scale calibration in one go - -!========================= DaVinciTrackRefitting v1r2 2013-02-20 ========================= - -! 2012-12-19 - Paul Seyfert - - Fixed memory leak in RefitParticleTracks and implement missing - functionality - -!========================= DaVinciTrackRefitting v1r1 2012-11-30 ========================= - -! 2012-11-29 - Marco Clemencic - - Added CMake configuration file. - -! 2012-11-25 - Paul Seyfert - - Converted TracksFromParticles from DVAlgorithm to DaVinciAlgorithm - - Added RefitParticleTracks algorithm and example file in options - -!=================== DaVinciTrackRefitting v1r0 2012-05-03 =================== - -! 2012-27-04 - M Needham - - First import diff --git a/Phys/DaVinciTrackRefitting/options/candidate_track_refitting_example.py b/Phys/DaVinciTrackRefitting/options/candidate_track_refitting_example.py deleted file mode 100644 index c2a770de56917b6f4946c8ca60b5c8634ae59b71..0000000000000000000000000000000000000000 --- a/Phys/DaVinciTrackRefitting/options/candidate_track_refitting_example.py +++ /dev/null @@ -1,112 +0,0 @@ -############################################################################### -# (c) Copyright 2000-2018 CERN for the benefit of the LHCb Collaboration # -# # -# This software is distributed under the terms of the GNU General Public # -# Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". # -# # -# In applying this licence, CERN does not waive the privileges and immunities # -# granted to it by virtue of its status as an Intergovernmental Organization # -# or submit itself to any jurisdiction. # -############################################################################### -from Gaudi.Configuration import * - -MessageSvc().Format = "% F%90W%S%7W%R%T %0W%M" -##### Stream CONFIGURATION -MyStream = "Dimuon" -MDST = False -readingStripping23 = True -fitAsInEM2015 = False -fitAsIn2015 = True -fitAsInReco14 = False - -##### DAVINCI CONFIGURATION - -from Configurables import DaVinci, RefitParticleTracks -DaVinci().EvtMax = 400 -DaVinci().PrintFreq = 400 -DaVinci().DataType = "2015" -if MDST: - DaVinci().InputType = "MDST" - DaVinci().RootInTES = MyStream -else: - DaVinci().InputType = "DST" -DaVinci().Simulation = False -DaVinci().SkipEvents = 0 - -##### FIT CONFIGURATION - -from Configurables import TrackInitFit, TrackMasterFitter -from TrackFitter.ConfiguredFitters import ConfiguredMasterFitter -from Configurables import TrackBestTrackCreator, TrackMasterFitter, TrackStateInitTool, FastVeloFitLHCbIDs - - -def giveitafit(thething): - thething.addTool(TrackInitFit, "TrackInitFit") - thething.TrackInitFit.addTool(TrackMasterFitter, name="Fit") - thething.TrackInitFit.addTool(TrackStateInitTool, name="Init") - thething.TrackInitFit.Init.UseFastMomentumEstimate = True - - if fitAsInEM2015: - ConfiguredMasterFitter( - getattr(thething.TrackInitFit, "Fit"), - SimplifiedGeometry=True, - LiteClusters=True, - MSRossiAndGreisen=False) - if fitAsIn2015: - ConfiguredMasterFitter( - getattr(thething.TrackInitFit, "Fit"), - SimplifiedGeometry=True, - LiteClusters=True, - MSRossiAndGreisen=True) - if fitAsInReco14: - ConfiguredMasterFitter( - getattr(thething.TrackInitFit, "Fit"), - SimplifiedGeometry=False, - LiteClusters=False, - MSRossiAndGreisen=False) - thething.TrackInitFit.Init.VeloFitterName = "FastVeloFitLHCbIDs" - thething.TrackInitFit.Init.addTool( - FastVeloFitLHCbIDs, name="FastVeloFitLHCbIDs") - if DaVinci().InputType == "MDST" or readingStripping23: - thething.TrackInitFit.RootInTES = MyStream - thething.TrackInitFit.Fit.RootInTES = MyStream - thething.TrackInitFit.Init.RootInTES = MyStream - thething.TrackInitFit.Init.FastVeloFitLHCbIDs.RootInTES = MyStream - - -###### TRACKING IN DAVINCI - -from STTools import STOfflineConf -STOfflineConf.DefaultConf().configureTools() -from Configurables import OTRawBankDecoder, PatSeedFit, Tf__OTHitCreator, FastVeloHitManager, Tf__DefaultVeloPhiHitManager, Tf__DefaultVeloRHitManager -ToolSvc().addTool(OTRawBankDecoder()) -ToolSvc().addTool(PatSeedFit()) -ToolSvc().addTool(Tf__OTHitCreator("OTHitCreator")) -ToolSvc().addTool(FastVeloHitManager("FastVeloHitManager")) -ToolSvc().addTool(Tf__DefaultVeloPhiHitManager("DefaultVeloPhiHitManager")) -ToolSvc().addTool(Tf__DefaultVeloRHitManager("DefaultVeloRHitManager")) -if "MDST" == DaVinci().InputType or readingStripping23: - ToolSvc().OTRawBankDecoder.RootInTES = '/Event/' + MyStream - ToolSvc().PatSeedFit.RootInTES = '/Event/' + MyStream - ToolSvc().OTHitCreator.RootInTES = '/Event/' + MyStream - ToolSvc().FastVeloHitManager.RootInTES = '/Event/' + MyStream - ToolSvc().DefaultVeloPhiHitManager.RootInTES = '/Event/' + MyStream - ToolSvc().DefaultVeloRHitManager.RootInTES = '/Event/' + MyStream - -#### the actual algorithm -from Configurables import RefitParticleTracks -refitter = RefitParticleTracks() -refitter.Inputs = [ - 'Phys/StdLooseKsLL/Particles', 'Phys/StdLooseKsDD/Particles' -] -giveitafit(refitter) -DaVinci().UserAlgorithms = [RefitParticleTracks()] - -###### INPUTDATA - -from Gaudi.Configuration import * -from GaudiConf import IOHelper -IOHelper('ROOT').inputFiles([ - 'root://eoslhcb.cern.ch//eos/lhcb/grid/prod/lhcb/LHCb/Collision15/DIMUON.DST/00048460/0000/00048460_00000415_1.dimuon.dst' -], - clear=True) diff --git a/Phys/DaVinciTrackRefitting/options/check_2015mdst.py b/Phys/DaVinciTrackRefitting/options/check_2015mdst.py deleted file mode 100644 index b7b3f12ffe399ad1581232af77aa7d8cbc4a80da..0000000000000000000000000000000000000000 --- a/Phys/DaVinciTrackRefitting/options/check_2015mdst.py +++ /dev/null @@ -1,49 +0,0 @@ -############################################################################### -# (c) Copyright 2000-2018 CERN for the benefit of the LHCb Collaboration # -# # -# This software is distributed under the terms of the GNU General Public # -# Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". # -# # -# In applying this licence, CERN does not waive the privileges and immunities # -# granted to it by virtue of its status as an Intergovernmental Organization # -# or submit itself to any jurisdiction. # -############################################################################### -from Configurables import DaVinci -##### Stream CONFIGURATION -MyStream = "Leptonic" -is2015 = True -fitasin = "2015" # "2015","EM2015","Reco14" -DaVinci().InputType = "MDST" -inputs = ['Phys/B2XMuMu_Line/Particles'] - -DaVinci().DDDBtag = "dddb-20150724" -DaVinci().CondDBtag = "cond-20150828" - -##### DAVINCI CONFIGURATION - -from Configurables import DaVinci, RefitParticleTracks -DaVinci().EvtMax = 10000 -DaVinci().PrintFreq = 1 -if is2015: - DaVinci().DataType = "2015" -else: - DaVinci().DataType = "2012" -if DaVinci().InputType == "MDST": - DaVinci().RootInTES = MyStream -DaVinci().Simulation = False -DaVinci().SkipEvents = 0 - -#### the actual algorithm -from DaVinciTrackRefitting import TrackRefitting -from Configurables import GaudiSequencer -refitter = TrackRefitting.TrackRefitting( - "refittingalg", - fitAsIn=fitasin, - Stripping23=is2015, - RootInTES=MyStream, # Also needed on FullDST! - Inputs=inputs, - ValidationMode=True, - UpdateProbability=True, - DoProbability=True, - Manipulator="Run2GhostId").fitter() -DaVinci().UserAlgorithms += [refitter] diff --git a/Phys/DaVinciTrackRefitting/options/new_candidate_track_refitting_example.py b/Phys/DaVinciTrackRefitting/options/new_candidate_track_refitting_example.py deleted file mode 100644 index 6d3df3f1a499d79d970fd870cc5dab229f4236f2..0000000000000000000000000000000000000000 --- a/Phys/DaVinciTrackRefitting/options/new_candidate_track_refitting_example.py +++ /dev/null @@ -1,60 +0,0 @@ -############################################################################### -# (c) Copyright 2000-2018 CERN for the benefit of the LHCb Collaboration # -# # -# This software is distributed under the terms of the GNU General Public # -# Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". # -# # -# In applying this licence, CERN does not waive the privileges and immunities # -# granted to it by virtue of its status as an Intergovernmental Organization # -# or submit itself to any jurisdiction. # -############################################################################### -##### Stream CONFIGURATION -MyStream = "Leptonic" -is2015 = True -fitasin = "2015" # "2015","EM2015","Reco14" -DaVinci().InputType = "MDST" -inputs = ['Phys/B2XMuMu_Line/Particles'] - - - -##### DAVINCI CONFIGURATION - -from Configurables import DaVinci, RefitParticleTracks -DaVinci().EvtMax = 600 -DaVinci().PrintFreq = 200 -if is2015: - DaVinci().DataType = "2015" -else: - DaVinci().DataType = "2012" -if DaVinci().InputType = "MDST": - DaVinci().RootInTES = MyStream -DaVinci().Simulation = False -DaVinci().SkipEvents = 0 - -#### the actual algorithm -from DaVinciTrackRefitting import TrackRefitting -refitter = TrackRefitting.TrackRefitting("refittingalg", - fitAsIn=fitasin, - Stripping23=is2015, - RootInTES = MyStream, # Also needed on FullDST! - Inputs = inputs - ).fitter() - -DaVinci().UserAlgorithms += [ refitter ] -# add your ntuple after the refitter - - -###### INPUTDATA - - -from Gaudi.Configuration import * -from GaudiConf import IOHelper -IOHelper('ROOT').inputFiles([ -#'root://eoslhcb.cern.ch//eos/lhcb/grid/prod/lhcb/LHCb/Collision15/DIMUON.DST/00048460/0000/00048460_00000415_1.dimuon.dst' -'root://eoslhcb.cern.ch//eos/lhcb/grid/prod/lhcb/LHCb/Collision15/LEPTONIC.MDST/00048279/0000/00048279_00001457_1.leptonic.mdst' ## 'Phys/B2XMuMu_Line/Particles' -#'root://eoslhcb.cern.ch//eos/lhcb/grid/prod/lhcb/LHCb/Collision12/SEMILEPTONIC.DST/00041834/0000/00041834_00000332_1.semileptonic.dst' ## 'Phys/PiforB2DMuNuX/Particles','Semileptonic/Phys/B2XuMuNuBs2KLine/Particles' -#'root://eoslhcb.cern.ch//eos/lhcb/grid/prod/lhcb/LHCb/Collision12/CHARM.MDST/00041834/0000/00041834_00000774_1.charm.mdst' ## 'Phys/DstarPromptWithD02HHHHLine/Particles' -], clear=True) - - - diff --git a/Phys/DaVinciTrackRefitting/python/DaVinciTrackRefitting/ParticleRefitter.py b/Phys/DaVinciTrackRefitting/python/DaVinciTrackRefitting/ParticleRefitter.py deleted file mode 100644 index 5315a450aa0fa1b8c4de66001cd3c607ff49a57b..0000000000000000000000000000000000000000 --- a/Phys/DaVinciTrackRefitting/python/DaVinciTrackRefitting/ParticleRefitter.py +++ /dev/null @@ -1,40 +0,0 @@ -############################################################################### -# (c) Copyright 2000-2020 CERN for the benefit of the LHCb Collaboration # -# # -# This software is distributed under the terms of the GNU General Public # -# Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". # -# # -# In applying this licence, CERN does not waive the privileges and immunities # -# granted to it by virtue of its status as an Intergovernmental Organization # -# or submit itself to any jurisdiction. # -############################################################################### -# @brief: provides a GaudiSequencer with a track momentum scaler and an update algorithm for the candidate particles on TES. -# @author: Paul Seyfert -# @date: 2013-02-21 -# idea mainly by V. Belyaev - -from __future__ import print_function -import six - - -def ParticleRefitterSeq(inputs=[], rootInTES="/Event", scale=True): - from Configurables import GaudiSequencer - from Configurables import TrackScaleState as SCALER - from Configurables import ParticleRefitter - scaler = SCALER("Scaler", RootInTES=rootInTES) - seq = GaudiSequencer("ParticleRefitterSeq") - if scale: - seq.Members = [scaler] - else: - seq.Members = [] - refitter = ParticleRefitter() - if isinstance(inputs, six.string_types): - refitter.Inputs = [inputs] - else: - refitter.Inputs = inputs - refitter.RootInTES = rootInTES - print("ParticleRefitterSeq is applied to the following inputs:") - for i in refitter.Inputs: - print(" - on of the inputs is ", i) - seq.Members += [refitter] - return seq diff --git a/Phys/DaVinciTrackRefitting/python/DaVinciTrackRefitting/TrackRefitting.py b/Phys/DaVinciTrackRefitting/python/DaVinciTrackRefitting/TrackRefitting.py deleted file mode 100644 index f2ca9ca4b5ea01452b9987b88be1981c45a25115..0000000000000000000000000000000000000000 --- a/Phys/DaVinciTrackRefitting/python/DaVinciTrackRefitting/TrackRefitting.py +++ /dev/null @@ -1,223 +0,0 @@ -############################################################################### -# (c) Copyright 2000-2018 CERN for the benefit of the LHCb Collaboration # -# # -# This software is distributed under the terms of the GNU General Public # -# Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". # -# # -# In applying this licence, CERN does not waive the privileges and immunities # -# granted to it by virtue of its status as an Intergovernmental Organization # -# or submit itself to any jurisdiction. # -############################################################################### -## @class TrackRefitting -# Wrapper to configure tools for the RefitParticleTracks -# @author Paul Seyfert -# @data 26/11/2015 - -__author__ = "Paul Seyfert " - -from LHCbKernel.Configuration import * -from Gaudi.Configuration import appendPostConfigAction -from Gaudi.Configuration import * -from Configurables import TrackInitFit, TrackMasterFitter -from TrackFitter.ConfiguredFitters import ConfiguredMasterFitter -from Configurables import TrackMasterFitter, TrackStateInitTool, FastVeloFitLHCbIDs - -from AnalysisPython.Logger import getLogger -log = getLogger('TrackRefitting') - - -def ConfigureFitter(fituser, fitAsIn="2015", EnergyLossFactor=1.0): - ''' - provide a configured TrackInitFit for a DaVinciAlgorithm (or tool) - - Keyword arguments: - fituser -- the Tool/Algorithm which uses a TrackInitFit - fitAsIn -- which reconstruction should be mimiced, possible values ['2015','EM2015','Reco14'] - EnergyLossFactor -- modify dE/dx in the material to assess the momentum uncertainty due to the uncertainty on the material budget - ''' - fituser.addTool(TrackInitFit, "TrackInitFit") - fituser.TrackInitFit.addTool(TrackMasterFitter, name="Fit") - fituser.TrackInitFit.addTool(TrackStateInitTool, name="Init") - fituser.TrackInitFit.Init.UseFastMomentumEstimate = True - - if fitAsIn == 'EM2015': - ConfiguredMasterFitter( - getattr(fituser.TrackInitFit, "Fit"), - SimplifiedGeometry=True, - LiteClusters=True, - MSRossiAndGreisen=False) - log.warning( - "cannot compute the early measurements ghost probability. I'll give you the tuning from later in 2015." - ) - elif fitAsIn == '2015': - ConfiguredMasterFitter( - getattr(fituser.TrackInitFit, "Fit"), - SimplifiedGeometry=True, - LiteClusters=True, - MSRossiAndGreisen=True) - from Configurables import Run2GhostId - fituser.addTool(Run2GhostId("Run2GhostId"), name="Run2GhostId") - fituser.Run2GhostId.InDaVinci = True - elif fitAsIn == 'Reco14': - raise ValueError('Reco14 was dropped') - else: - log.warning( - "no known fit configuration, falling back to TrackFitter.ConfiguredFitters.ConfiguredMasterFitter default" - ) - ConfiguredMasterFitter(getattr(fituser.TrackInitFit, "Fit")) - - from Configurables import StateDetailedBetheBlochEnergyCorrectionTool - fituser.TrackInitFit.Fit.MaterialLocator.addTool( - StateDetailedBetheBlochEnergyCorrectionTool, name="GeneralDedxTool") - fituser.TrackInitFit.Fit.MaterialLocator.GeneralDedxTool.EnergyLossFactor = EnergyLossFactor - fituser.TrackInitFit.Fit.Extrapolator.MaterialLocator.addTool( - StateDetailedBetheBlochEnergyCorrectionTool, name="GeneralDedxTool") - fituser.TrackInitFit.Fit.Extrapolator.MaterialLocator.GeneralDedxTool.EnergyLossFactor = EnergyLossFactor - - -def ProvideRootInTES(fituser, streamname): - ''' - set RootInTES for something using a TrackInitFit - - Keyword arguments: - fituser -- the Tool/Algorithm which uses a TrackInitFit - streamname -- the usual RootInTES - ''' - fituser.TrackInitFit.Init.VeloFitterName = "FastVeloFitLHCbIDs" - fituser.TrackInitFit.Init.addTool( - FastVeloFitLHCbIDs, name="FastVeloFitLHCbIDs") - fituser.TrackInitFit.RootInTES = streamname - fituser.TrackInitFit.Fit.RootInTES = streamname - fituser.TrackInitFit.Init.RootInTES = streamname - fituser.TrackInitFit.Init.FastVeloFitLHCbIDs.RootInTES = streamname - - -from Configurables import RefitParticleTracks - - -class TrackRefitting(object): - ''' - wrapper around RefitParticleTracks with tool configuration included and automatic trigger of setting RootInTES for the tool chain - - TODO: determine InputType, Stripping version and RootInTES in a more automatic way - ''' - - def __init__(self, - name="TrackRefitting", - fitAsIn="2015", - RootInTES="", - Stripping23=False, - EnergyLossFactor=1.0, - *args, - **kwargs): - ''' - Keyword arguments: - name -- the standard name of an Algorithm in Gaudi - fitAsIn -- which reconstruction should be mimiced, possible values ['2015','EM2015','Reco14'] - RootInTES -- the usual RootInTES (cannot be caught from DaVinci since Stripping23) - EnergyLossFactor -- to study the impact of the material uncertainty, tune the energy loss when propagating through material - Stripping23 -- since stripping23, the hit managers need to know about the stream (RootInTES) also on fullDST - args,kwargs -- arguments to be forwarded to TrackRefitting - ''' - self._refitter = RefitParticleTracks(name, *args, **kwargs) - self._fitAsIn = fitAsIn - self._EnergyLossFactor = EnergyLossFactor - ConfigureFitter( - self._refitter, fitAsIn=fitAsIn, EnergyLossFactor=EnergyLossFactor) - self.Stripping23 = Stripping23 - self.RootInTES = RootInTES - - def postconfig(): - self.__apply_configuration() - - appendPostConfigAction(postconfig) - - # allow fitAsIn to be set after instantiation of TrackRefitting - # fitter gets reconfigured when TrackRefitting.fitAsIn is set by the user - def get_EnergyLossFactor(self): - return self._EnergyLossFactor - - def set_EnergyLossFactor(self, value): - self._EnergyLossFactor = value - ConfigureFitter( - self._refitter, - fitAsIn=self._fitAsIn, - EnergyLossFactor=self._EnergyLossFactor) - - EnergyLossFactor = property(get_EnergyLossFactor, set_EnergyLossFactor) - - def get_fitAsIn(self): - return self._fitAsIn - - def set_fitAsIn(self, value): - self._fitAsIn = value - ConfigureFitter(self._refitter, fitAsIn=value) - - fitAsIn = property(get_fitAsIn, set_fitAsIn) - - def fitter(self): - return self._refitter - - def __apply_configuration(self): - ''' - not to be called by users, PLEASE - will be automatically called through appendPostConfigAction - - - NB: http://stackoverflow.com/questions/610883/how-to-know-if-an-object-has-an-attribute-in-python - --> i don't use hasattr but catch the exception instead - ''' - from Configurables import DaVinci - log.info("calling __apply_configuration") - log.info("DaVinci().InputType is " + DaVinci().InputType) - try: - self._refitter.RootInTES = DaVinci().RootInTES - except AttributeError: - pass - try: - inputtype = DaVinci().InputType - except AttributeError: - log.fatal( - "DaVinci().InputType is not yet specified, but I need to know it now! (sorry)" - ) - raise - if self.Stripping23 or DaVinci().InputType == "MDST": - rit = self.RootInTES - if DaVinci().InputType == "MDST": - try: - rit_ref = DaVinci().RootInTES - except AttributeError: - log.warning( - "DaVinci().InputType is set to MDST, but RootInTES is not specified! (yet?)" - ) - else: - if rit != rit_ref: - log.warning( - "TrackRefitting.RootInTES and DaVinci().RootInTES don't agree, although you're running on MDST" - ) - log.warning("please check!") - ProvideRootInTES(self._refitter, rit) - from Configurables import OTRawBankDecoder, PatSeedFit, Tf__OTHitCreator, FastVeloHitManager, Tf__DefaultVeloPhiHitManager, Tf__DefaultVeloRHitManager - ToolSvc().addTool(OTRawBankDecoder()) - ToolSvc().addTool(PatSeedFit()) - ToolSvc().addTool(Tf__OTHitCreator("OTHitCreator")) - ToolSvc().addTool(FastVeloHitManager("FastVeloHitManager")) - ToolSvc().addTool( - Tf__DefaultVeloPhiHitManager("DefaultVeloPhiHitManager")) - ToolSvc().addTool( - Tf__DefaultVeloRHitManager("DefaultVeloRHitManager")) - ToolSvc().OTRawBankDecoder.RootInTES = rit - ToolSvc().PatSeedFit.RootInTES = rit - ToolSvc().OTHitCreator.RootInTES = rit - ToolSvc().FastVeloHitManager.RootInTES = rit - ToolSvc().DefaultVeloPhiHitManager.RootInTES = rit - ToolSvc().DefaultVeloRHitManager.RootInTES = rit - - # using as property is not needed at the moment - def get_RootInTES(self): - return self._RootInTES - - def set_RootInTES(self, value): - self._RootInTES = value - - RootInTES = property(get_RootInTES, set_RootInTES) diff --git a/Phys/DaVinciTrackRefitting/python/DaVinciTrackRefitting/__init__.py b/Phys/DaVinciTrackRefitting/python/DaVinciTrackRefitting/__init__.py deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/Phys/DaVinciTrackRefitting/src/ParticleRefitter.cpp b/Phys/DaVinciTrackRefitting/src/ParticleRefitter.cpp deleted file mode 100644 index e3a87156509e34167e67f121d1ffbc4910d5cdc2..0000000000000000000000000000000000000000 --- a/Phys/DaVinciTrackRefitting/src/ParticleRefitter.cpp +++ /dev/null @@ -1,124 +0,0 @@ -/*****************************************************************************\ -* (c) Copyright 2000-2018 CERN for the benefit of the LHCb Collaboration * -* * -* This software is distributed under the terms of the GNU General Public * -* Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". * -* * -* In applying this licence, CERN does not waive the privileges and immunities * -* granted to it by virtue of its status as an Intergovernmental Organization * -* or submit itself to any jurisdiction. * -\*****************************************************************************/ - -#include "Kernel/DaVinciAlgorithm.h" -#include "Kernel/IParticle2State.h" -#include "Kernel/IVertexFit.h" - -#include "DetDesc/IDetectorElement.h" - -/** - * @class ParticleRefitter ParticleRefitter.h - * @brief update LHCb::Particles to collect updates to their LHCb::Track objects - * mainly copied from preliminary work by Christian Voss - * - * @author Paul Seyfert - * @date 2013-02-19 - */ -class ParticleRefitter : public DaVinciAlgorithm { - -public: - ParticleRefitter( const std::string& name, ISvcLocator* pSvcLocator ); - StatusCode initialize() override; - StatusCode execute() override; - -protected: - virtual StatusCode execute( LHCb::Particle* ); - -private: - IParticle2State* m_stateToParticle; - std::string m_trktoolname, m_fittoolname; - IVertexFit* m_fit; - std::vector m_vt; // @todo: keeping vertices like this in the storage isn't exactly good practice (use - // TES instead) -}; - -DECLARE_COMPONENT( ParticleRefitter ) - -//============================================================================= -// Standard constructor, initializes variables -//============================================================================= -ParticleRefitter::ParticleRefitter( const std::string& name, ISvcLocator* pSvcLocator ) - : DaVinciAlgorithm( name, pSvcLocator ) { - declareProperty( "FitTool", m_fittoolname = "OfflineVertexFitter" ); -} - -//============================================================================= -// Initialization -//============================================================================= -StatusCode ParticleRefitter::initialize() { - StatusCode sc = DaVinciAlgorithm::initialize(); - if ( sc.isFailure() ) return sc; - - if ( msgLevel( MSG::DEBUG ) ) debug() << "==> Initialize" << endmsg; - - m_stateToParticle = tool( "Particle2State", this ); - m_fit = tool( m_fittoolname, this ); - - return StatusCode::SUCCESS; -} - -//============================================================================= -// Main execution -//============================================================================= -StatusCode ParticleRefitter::execute() { - for ( unsigned k = 0; k < m_vt.size(); ++k ) { delete m_vt[k]; } - m_vt.clear(); - setFilterPassed( false ); - if ( msgLevel( MSG::DEBUG ) ) debug() << "==> Execute" << endmsg; - - const LHCb::Particle::Range inputParticles = particles(); - - if ( msgLevel( MSG::DEBUG ) ) verbose() << inputParticles.size() << "input particles" << endmsg; - - if ( 0 == inputParticles.size() ) return StatusCode::SUCCESS; - - LHCb::Particle::Range::iterator Piter = inputParticles.begin(); - - StatusCode sc( StatusCode::SUCCESS ); - for ( ; inputParticles.end() != Piter; ++Piter ) { - sc = execute( const_cast( *Piter ) ); - if ( sc.isFailure() ) { - return Warning( - "Particle Refitting failed, aborting event. (still returning SUCCESS, but not setting FilterPassed true)", - StatusCode::SUCCESS, 30 ); - } - } - - setFilterPassed( true ); - return StatusCode::SUCCESS; -} - -StatusCode ParticleRefitter::execute( LHCb::Particle* part ) { - StatusCode mainsc( StatusCode::SUCCESS ); - StatusCode subsc( StatusCode::SUCCESS ); - if ( part->proto() && part->proto()->track() ) { - mainsc = m_stateToParticle->state2Particle( part->proto()->track()->firstState(), *part ); - } else { - // Get the default geometry FIXME, use functional framework - auto lhcb = getDet( m_standardGeometry_address ); - if ( !lhcb ) { throw GaudiException( "Could not load geometry", name(), StatusCode::FAILURE ); } - LHCb::Particle::ConstVector daughters = part->daughtersVector(); - part->clearDaughters(); - LHCb::Particle::ConstVector::iterator dau_iter; - for ( dau_iter = daughters.begin(); dau_iter != daughters.end(); ++dau_iter ) { - subsc = ParticleRefitter::execute( const_cast( *dau_iter ) ); - part->addToDaughters( *dau_iter ); - if ( subsc.isFailure() ) mainsc = subsc; - } - LHCb::Vertex* Vtx = new LHCb::Vertex(); // @todo: leave them on TES in future versions - subsc = m_fit->fit( daughters, *Vtx, *part, *lhcb->geometry() ); - if ( subsc.isFailure() ) mainsc = subsc; - m_vt.push_back( Vtx ); - } - - return mainsc; -} diff --git a/Phys/DaVinciTrackRefitting/src/RefitParticleTracks.cpp b/Phys/DaVinciTrackRefitting/src/RefitParticleTracks.cpp deleted file mode 100644 index 3c2aa53b1c8a00197e5e931da6df53172a3f2f78..0000000000000000000000000000000000000000 --- a/Phys/DaVinciTrackRefitting/src/RefitParticleTracks.cpp +++ /dev/null @@ -1,308 +0,0 @@ -/*****************************************************************************\ -* (c) Copyright 2000-2018 CERN for the benefit of the LHCb Collaboration * -* * -* This software is distributed under the terms of the GNU General Public * -* Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". * -* * -* In applying this licence, CERN does not waive the privileges and immunities * -* granted to it by virtue of its status as an Intergovernmental Organization * -* or submit itself to any jurisdiction. * -\*****************************************************************************/ - -#include "TrackInterfaces/IGhostProbability.h" -#include "TrackInterfaces/ITrackFitter.h" - -#include "LoKi/PhysExtract.h" - -#include "Kernel/DaVinciAlgorithm.h" - -#include "DetDesc/IDetectorElement.h" - -#include "Event/Track.h" - -/** - * @brief do some easy tracking tasks to all tracks in a decay chain. - * - * DoFit: does fitting. otherwise perform remaining tasks on unREfitted tracks - * DoProbability: reevaluate probabilities (like track likelihood or ghostprobability) - * ReplaceTracks: replace candidate tracks by refitted tracks - * UpdateProbability: keep original tracks (fit parameters) but overwrite likelihood - * - * UpdateProbability ! UpdateProbability - * ReplaceTracks ! ReplaceTracks ReplaceTracks ! ReplaceTracks - * - * DoFit DoProbability okay[3] okay[a] not okay[2] okay - * !DoProbability not okay[1] not okay[1,a] okay okay - * - * !DoFit DoProbability okay[3] same as left not okay[2] okay - * !DoProbability not okay[1] not okay[1] waste of time use TracksFromParticles - * - * @author Paul Seyfert - * @date 2012-11-23 - */ -class RefitParticleTracks : public DaVinciAlgorithm { - -public: - RefitParticleTracks( const std::string& name, ISvcLocator* pSvcLocator ); - StatusCode initialize() override; - StatusCode execute() override; - -protected: - virtual StatusCode fit( std::vector* vec, IGeometryInfo const& geometry ); - virtual StatusCode manipulate( std::vector* vec ); - -private: - ITrackFitter* m_trackFitter; - IGhostProbability* m_ghostprobability; - bool m_overwrite; - bool m_fit; - bool m_manipulate; - bool m_update; - bool m_writeOutput; - bool m_validationmode; - std::string m_fittername; - std::string m_manipulatorname; -}; - -DECLARE_COMPONENT( RefitParticleTracks ) - -//============================================================================= -// Standard constructor, initializes variables -//============================================================================= -RefitParticleTracks::RefitParticleTracks( const std::string& name, ISvcLocator* pSvcLocator ) - : DaVinciAlgorithm( name, pSvcLocator ) { - declareProperty( "DoFit", m_fit = true ); - declareProperty( "DoProbability", m_manipulate = false ); - declareProperty( "WriteToTES", m_writeOutput = false ); - declareProperty( "UpdateProbability", m_update = false ); - declareProperty( "ReplaceTracks", m_overwrite = true ); - declareProperty( "Fitter", m_fittername = "TrackInitFit" ); - declareProperty( "Manipulator", m_manipulatorname = "Run2GhostId" ); - declareProperty( "ValidationMode", m_validationmode = false ); -} - -//============================================================================= -// Initialization -//============================================================================= -StatusCode RefitParticleTracks::initialize() { - StatusCode sc = DaVinciAlgorithm::initialize(); // must be executed first - if ( sc.isFailure() ) return sc; // error printed already by DaVinciAlgorithm - - if ( !m_overwrite && !m_update && !m_writeOutput ) { - Warning( "Neither output nor overwriting/updating specified. Don't know what to do." ).ignore(); - } - if ( m_overwrite || m_update ) { - Warning( "Don't run this option in the Stripping! (UpdateProbability or ReplaceTracks are evil there.) Please copy " - "your tracks somewhere." ) - .ignore(); - } - if ( !m_manipulate && m_update ) { - return Warning( "Not implemented combination (UpdateProbability w/o DoProbability) [1]", StatusCode::FAILURE ); - } - if ( m_overwrite && m_manipulate && !m_update ) { - return Warning( "Sorry, I thought about this combination but didn't want to implement it (ReplaceTracks and " - "DoProbability w/o UpdateProbability[2]", - StatusCode::FAILURE ); - } - if ( m_overwrite && m_manipulate && m_update ) { - m_update = false; // sorry for this hack. I here attempt to keep the code more readable.[3] - } - - if ( msgLevel( MSG::DEBUG ) ) { - debug() << "==> Initialize" << endmsg; - debug() << "DoFit = " << m_fit << endmsg; - debug() << "DoProbability = " << m_manipulate << endmsg; - debug() << "WriteToTES = " << m_writeOutput << endmsg; - debug() << "UpdateProbability = " << m_update << endmsg; - debug() << "ReplaceTracks = " << m_overwrite << endmsg; - } - - m_trackFitter = tool( m_fittername, this ); - m_ghostprobability = tool( m_manipulatorname, this ); - - return StatusCode::SUCCESS; -} - -//============================================================================= -// Main execution -//============================================================================= -StatusCode RefitParticleTracks::execute() { - setFilterPassed( false ); - if ( msgLevel( MSG::DEBUG ) ) debug() << "==> Execute" << endmsg; - - const LHCb::Particle::Range inputParticles = particles(); - - if ( 0 == inputParticles.size() ) return StatusCode::SUCCESS; - if ( msgLevel( MSG::DEBUG ) ) verbose() << inputParticles.size() << "input particles" << endmsg; - - std::vector alltracks; - std::vector::const_iterator iterT; - std::vector::const_iterator itercT; - LoKi::Extract::getTracks( inputParticles.begin(), inputParticles.end(), std::back_inserter( alltracks ) ); - - LHCb::Tracks uniqueTracks; - if ( msgLevel( MSG::DEBUG ) && inputParticles.size() > 0 && 0 == alltracks.size() ) - verbose() << "no tracks from " << inputParticles.size() << " particles " << endmsg; - - itercT = alltracks.begin(); - uniqueTracks.reserve( alltracks.size() ); - for ( ; alltracks.end() != itercT; ++itercT ) { - if ( !uniqueTracks.object( ( *itercT )->key() ) ) { - uniqueTracks.add( const_cast( *itercT ) ); ///@todo: this is evil - } - } - - std::vector incasts; - std::vector copies; - incasts.clear(); - copies.clear(); - - std::vector* toworkwith; - - incasts.reserve( uniqueTracks.size() ); - // if (m_overwrite || m_update) - for ( auto track : uniqueTracks ) { - incasts.push_back( track ); - if ( !m_overwrite ) { - copies.push_back( new LHCb::Track( *track, track->key() ) ); - if ( incasts.back()->key() != copies.back()->key() ) { - fatal() << "SEVERE PROBLEM. DATA WILL BE CORRUPTED!" << endmsg; - } - } - } - - if ( m_overwrite ) { - toworkwith = &incasts; - } else { - if ( copies.size() != incasts.size() ) { fatal() << "FAILED SANITY CHECK! WILL LIKELY SEGFAULT SOON!" << endmsg; } - toworkwith = &copies; - } - - // Get the default geometry FIXME, use functional framework - auto lhcb = getDet( m_standardGeometry_address ); - if ( !lhcb ) { throw GaudiException( "Could not load geometry", name(), StatusCode::FAILURE ); } - - if ( m_fit ) fit( toworkwith, *lhcb->geometry() ).ignore( /* AUTOMATICALLY ADDED FOR gaudi/Gaudi!763 */ ); - if ( m_manipulate ) manipulate( toworkwith ).ignore( /* AUTOMATICALLY ADDED FOR gaudi/Gaudi!763 */ ); - if ( msgLevel( MSG::DEBUG ) ) debug() << " manipulations done " << endmsg; - - if ( m_update ) { /// if we anyhow overwrite, the property has been switched off in initialize() [3] - /// for better text editor support I add the following line as a comment: - /// if (m_overwrite = false) - std::vector::const_iterator iterFrom = copies.begin(); - std::vector::const_iterator iterTo = incasts.begin(); - for ( ; copies.end() != iterFrom; ++iterFrom ) { - ( *iterTo )->setGhostProbability( ( *iterFrom )->ghostProbability() ); - ///@todo: what about more general updates? - ++iterTo; // do this only at the very end of the loop - } - } - if ( msgLevel( MSG::DEBUG ) ) debug() << " updates done " << endmsg; - - if ( m_writeOutput ) { - LHCb::Tracks* outtracks = new LHCb::Tracks(); - iterT = toworkwith->begin(); - for ( ; toworkwith->end() != iterT; ++iterT ) { outtracks->add( *iterT ); } - put( outtracks, outputLocation() ); - if ( msgLevel( MSG::DEBUG ) ) debug() << "put to TES" << endmsg; - } else { - while ( copies.size() ) { - delete copies.back(); - copies.pop_back(); - } - } - - setFilterPassed( true ); - return StatusCode::SUCCESS; -} - -StatusCode RefitParticleTracks::fit( std::vector* vec, IGeometryInfo const& geometry ) { - if ( msgLevel( MSG::DEBUG ) ) debug() << "==> FITTING " << vec->size() << " tracks" << endmsg; - - std::vector::iterator iterT = vec->begin(); - for ( ; vec->end() != iterT; ++iterT ) { - double vchi_old, tchi_old, mchi_old, chi_old, vdof_old, tdof_old, p_old; - double vchi_new, tchi_new, mchi_new, chi_new, vdof_new, tdof_new, p_new; - if ( m_validationmode ) { - vchi_old = ( *iterT )->info( LHCb::Track::AdditionalInfo::FitVeloChi2, -99. ); - tchi_old = ( *iterT )->info( LHCb::Track::AdditionalInfo::FitTChi2, -99. ); - mchi_old = ( *iterT )->info( LHCb::Track::AdditionalInfo::FitMatchChi2, -99. ); - chi_old = ( *iterT )->chi2(); - vdof_old = ( *iterT )->info( LHCb::Track::AdditionalInfo::FitVeloNDoF, -99. ); - tdof_old = ( *iterT )->info( LHCb::Track::AdditionalInfo::FitTNDoF, -99. ); - p_old = ( *iterT )->p(); - } - m_trackFitter->operator()( *( *iterT ), geometry ).ignore(); - if ( m_validationmode ) { - vchi_new = ( *iterT )->info( LHCb::Track::AdditionalInfo::FitVeloChi2, -99. ); - tchi_new = ( *iterT )->info( LHCb::Track::AdditionalInfo::FitTChi2, -99. ); - mchi_new = ( *iterT )->info( LHCb::Track::AdditionalInfo::FitMatchChi2, -99. ); - chi_new = ( *iterT )->chi2(); - vdof_new = ( *iterT )->info( LHCb::Track::AdditionalInfo::FitVeloNDoF, -99. ); - tdof_new = ( *iterT )->info( LHCb::Track::AdditionalInfo::FitTNDoF, -99. ); - p_new = ( *iterT )->p(); - -/// https://stackoverflow.com/questions/28166565/detect-gcc-as-opposed-to-msvc-clang-with-macro -#ifndef __clang__ -/// http://stackoverflow.com/questions/3378560/how-to-disable-gcc-warnings-for-a-few-lines-of-code -# pragma GCC diagnostic push -# pragma GCC diagnostic ignored "-Wmaybe-uninitialized" -#else -# pragma GCC diagnostic push -# pragma GCC diagnostic ignored "-Wuninitialized" - /// all these chi^2, p, ndof should be != 0 anyway, so no FPE (or something about which i actually want to get - /// warned, so FPE, come at me! -#endif - if ( 1e-4 < fabs( ( vchi_old - vchi_new ) / vchi_new ) ) - fatal() << "DaVinci Track fit did not reproduce Brunel result in variable vchi:" - << fabs( ( vchi_old - vchi_new ) / vchi_new ) << endmsg; - if ( 1e-4 < fabs( ( tchi_old - tchi_new ) / tchi_new ) ) - fatal() << "DaVinci Track fit did not reproduce Brunel result in variable tchi:" - << fabs( ( tchi_old - tchi_new ) / tchi_new ) << endmsg; - if ( 1e-4 < fabs( ( mchi_old - mchi_new ) / mchi_new ) ) - fatal() << "DaVinci Track fit did not reproduce Brunel result in variable mchi:" - << fabs( ( mchi_old - mchi_new ) / mchi_new ) << endmsg; - if ( 1e-4 < fabs( ( chi_old - chi_new ) / chi_new ) ) - fatal() << "DaVinci Track fit did not reproduce Brunel result in variable chi:" - << fabs( ( chi_old - chi_new ) / chi_new ) << endmsg; - if ( 1e-4 < fabs( ( vdof_old - vdof_new ) / vdof_new ) ) - fatal() << "DaVinci Track fit did not reproduce Brunel result in variable vdof:" - << fabs( ( vdof_old - vdof_new ) / vdof_new ) << endmsg; - if ( 1e-4 < fabs( ( tdof_old - tdof_new ) / tdof_new ) ) - fatal() << "DaVinci Track fit did not reproduce Brunel result in variable tdof:" - << fabs( ( tdof_old - tdof_new ) / tdof_new ) << endmsg; - if ( 1e-4 < fabs( ( p_old - p_new ) / p_new ) ) - fatal() << "DaVinci Track fit did not reproduce Brunel result in variable p:" - << fabs( ( p_old - p_new ) / p_new ) << endmsg; -#pragma GCC diagnostic pop - } - } - return StatusCode::SUCCESS; -} - -StatusCode RefitParticleTracks::manipulate( std::vector* vec ) { - if ( msgLevel( MSG::DEBUG ) ) debug() << "==> MANIPULATING" << endmsg; - std::vector::iterator iterT = vec->begin(); - for ( ; vec->end() != iterT; ++iterT ) { - double gp_old, gp_new; - if ( m_validationmode ) { gp_old = ( *iterT )->ghostProbability(); } - m_ghostprobability->execute( *( *iterT ) ).ignore(); - if ( m_validationmode ) { - gp_new = ( *iterT )->ghostProbability(); -#ifndef __clang__ -# pragma GCC diagnostic push -# pragma GCC diagnostic ignored "-Wmaybe-uninitialized" -#else -# pragma GCC diagnostic push -# pragma GCC diagnostic ignored "-Wuninitialized" -#endif - /// avoid division by zero here. gp is on a 0...1 scale anyway - if ( 1e-8 < fabs( gp_old - gp_new ) ) { - fatal() << "DaVinci ghost probability did not reproduce Brunel result" << endmsg; - fatal() << " old = " << gp_old << "\t\tnew = " << gp_new << endmsg; - } -#pragma GCC diagnostic pop - } - } - return StatusCode::SUCCESS; -} diff --git a/Phys/DaVinciTrackRefitting/src/TracksFromParticles.cpp b/Phys/DaVinciTrackRefitting/src/TracksFromParticles.cpp deleted file mode 100644 index b207344a68bef8a50cefec99077a2d94cc161967..0000000000000000000000000000000000000000 --- a/Phys/DaVinciTrackRefitting/src/TracksFromParticles.cpp +++ /dev/null @@ -1,54 +0,0 @@ -/*****************************************************************************\ -* (c) Copyright 2000-2018 CERN for the benefit of the LHCb Collaboration * -* * -* This software is distributed under the terms of the GNU General Public * -* Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". * -* * -* In applying this licence, CERN does not waive the privileges and immunities * -* granted to it by virtue of its status as an Intergovernmental Organization * -* or submit itself to any jurisdiction. * -\*****************************************************************************/ -#include "TracksFromParticles.h" -#include "Event/Particle.h" -#include "Event/Track.h" -#include "LoKi/PhysExtract.h" - -//----------------------------------------------------------------------------- -// Implementation file for class : TracksFromParticles -// -// 2012-10-27 : Matthew Needham -//----------------------------------------------------------------------------- - -DECLARE_COMPONENT( TracksFromParticles ) - -TracksFromParticles::TracksFromParticles( const std::string& name, ISvcLocator* pSvc ) - : DaVinciAlgorithm( name, pSvc ) { - declareProperty( "inputLocation", m_outputLocation = "/Event/Rec/MyTracks" ); - ///@fixme: "inputLocation" as property for m_outputLocation ??? -} - -StatusCode TracksFromParticles::execute() { - - // get the input particles - const LHCb::Particle::Range inputParticles = particles(); - std::vector tracks; - LoKi::Extract::getTracks( inputParticles.begin(), inputParticles.end(), std::back_inserter( tracks ) ); - - if ( msgLevel( MSG::VERBOSE ) ) { verbose() << " Found " << tracks.size() << endmsg; } - - // now clone the tracks and output - LHCb::Tracks* outputCont = new LHCb::Tracks(); - for ( auto track : tracks ) { - if ( !outputCont->object( track->key() ) ) { - // clone track only if it's not a duplicate from another candidate - LHCb::Track* newTrack = new LHCb::Track( *track, track->key() ); - outputCont->insert( newTrack ); - } - } - - put( outputCont, m_outputLocation ); - - setFilterPassed( true ); - - return StatusCode::SUCCESS; -} diff --git a/Phys/DaVinciTrackRefitting/src/TracksFromParticles.h b/Phys/DaVinciTrackRefitting/src/TracksFromParticles.h deleted file mode 100644 index 4d927cfaeb543d265d685f1556cea393c9b814eb..0000000000000000000000000000000000000000 --- a/Phys/DaVinciTrackRefitting/src/TracksFromParticles.h +++ /dev/null @@ -1,39 +0,0 @@ -/*****************************************************************************\ -* (c) Copyright 2000-2018 CERN for the benefit of the LHCb Collaboration * -* * -* This software is distributed under the terms of the GNU General Public * -* Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". * -* * -* In applying this licence, CERN does not waive the privileges and immunities * -* granted to it by virtue of its status as an Intergovernmental Organization * -* or submit itself to any jurisdiction. * -\*****************************************************************************/ -#ifndef TracksFromParticles_H_ -#define TracksFromParticles_H_ - -#include "Event/Track.h" -#include "Event/TrackTypes.h" -#include "Kernel/DaVinciAlgorithm.h" - -/** @class TracksFromParticles TracksFromParticles.h - * - * Algorithm to create Tracks from Particles object - * - * @author M. Needham - * @date 2012-04-27 - */ - -class TracksFromParticles : public DaVinciAlgorithm { - -public: - /// constructor - TracksFromParticles( const std::string& name, ISvcLocator* pSvc ); - - /// execute - StatusCode execute() override; - -private: - std::string m_outputLocation; -}; - -#endif diff --git a/Phys/DecayTreeTuple/CMakeLists.txt b/Phys/DecayTreeTuple/CMakeLists.txt deleted file mode 100644 index 8e0053909d410889af1ef0d2ecde818524838838..0000000000000000000000000000000000000000 --- a/Phys/DecayTreeTuple/CMakeLists.txt +++ /dev/null @@ -1,82 +0,0 @@ -############################################################################### -# (c) Copyright 2000-2021 CERN for the benefit of the LHCb Collaboration # -# # -# This software is distributed under the terms of the GNU General Public # -# Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". # -# # -# In applying this licence, CERN does not waive the privileges and immunities # -# granted to it by virtue of its status as an Intergovernmental Organization # -# or submit itself to any jurisdiction. # -############################################################################### -#[=======================================================================[.rst: -Phys/DecayTreeTuple -------------------- -#]=======================================================================] - -gaudi_add_module(DecayTreeTuple - SOURCES - src/TupleToolAllTracks.cpp - src/TupleToolAngles.cpp - src/TupleToolBeamSpot.cpp - src/TupleToolBremInfo.cpp - src/TupleToolCaloDigits.cpp - src/TupleToolCorrectedMass.cpp - src/TupleToolDecayTreeFitter.cpp - src/TupleToolDira.cpp - src/TupleToolGeometry.cpp - src/TupleToolHOP.cpp - src/TupleToolIsolationTwoBody.cpp - src/TupleToolKinematic.cpp - src/TupleToolMassHypo.cpp - src/TupleToolNeutrinoReco.cpp - src/TupleToolParticleReFit.cpp - src/TupleToolParticleStats.cpp - src/TupleToolPhotonInfo.cpp - src/TupleToolPi0Info.cpp - src/TupleToolPid.cpp - src/TupleToolPropertime.cpp - src/TupleToolRadUpDownAsym.cpp - src/TupleToolSubMass.cpp - src/TupleToolTagging.cpp - src/TupleToolVeto.cpp - src/TupleToolVtxDaughters.cpp - src/TupleToolVtxIsoln.cpp - LINK - Analysis::DecayTreeTupleBaseLib - Boost::headers - Gaudi::GaudiAlgLib - Gaudi::GaudiKernel - GSL::gsl - LHCb::CaloDetLib - LHCb::CaloUtils - LHCb::DAQEventLib - LHCb::DigiEvent - LHCb::GenEvent - LHCb::LHCbKernel - LHCb::LoKiCoreLib - LHCb::MCAssociators - LHCb::MCEvent - LHCb::MuonDetLib - LHCb::PartPropLib - LHCb::PhysEvent - LHCb::PhysInterfacesLib - LHCb::RecEvent - LHCb::RelationsLib - LHCb::TrackEvent - Phys::DaVinciInterfacesLib - Phys::DaVinciKernelLib - Phys::DaVinciMCKernelLib - Phys::DecayTreeFitter - Phys::LoKiLib - Phys::LoKiPhysLib - Phys::LoKiUtils - Rec::TrackInterfacesLib - ROOT::GenVector - ROOT::MathCore - ROOT::Physics - ROOT::TMVA -) - -gaudi_install(PYTHON) - -gaudi_add_tests(QMTest) diff --git a/Phys/DecayTreeTuple/doc/release.notes b/Phys/DecayTreeTuple/doc/release.notes deleted file mode 100755 index 127e04e28ab94291ac222f3bde3b14a198de7aee..0000000000000000000000000000000000000000 --- a/Phys/DecayTreeTuple/doc/release.notes +++ /dev/null @@ -1,1673 +0,0 @@ -!----------------------------------------------------------------------------- -! Package : Phys/DecayTreeTuple -! Responsible : Patrick Koppenburg & The WGs -! Purpose : Option-steered tuples. -!----------------------------------------------------------------------------- - -! 2017-08-03 - Ricardo Vazquez Gomez - - add new correlated chi2 to the MuonPID - -! 2017-06-14 - Albert Puig - - Modernized TupleToolHOP. - -! 2016-11-09 - Olli Lupton - - Add setDescriptorTemplate() helper for DecayTreeTuple. This uses python - template strings to produce a decay descriptor and branches from one string. - -!====================== DecayTreeTuple v5r7 2016-06-13 ======================= - -! 2016-06-08 - Marian Stahl - - Improvements in TupleToolAllTracks: - - implemented possibility to add particles to head of chain - - added VertexMode variable to steer vertexing of target and added particle - - improved documentation and added warnings for conflicting choices of configurables - -!================ DecayTreeTuple v5r6 2016-03-31 ================== - -! 2016-03-31 - Matthew Rudolph - - Fix bug in TupleToolAllTracks by moving MINIPCHI2 cut before adding the value to output - -!======================= DecayTreeTuple v5r5 2016-02-04 ====================== - -! 2016-01-20 - Matthew Rudolph - - Fix string in TupleToolAllTracks to retrieve LoKi::PVReFitter tool - -!======================= DecayTreeTuple v5r4 2015-12-02 ====================== - -! 2015-12-01 - Marco Cattaneo - - Fix forward declaration broken in Gaudi HEAD build - - Remove obsolete Gaudi includes - -! 2015-11-20 - Lucio Anderlini - - Fixed CMakeLists.txt (hopefully) - -! 2015-11-17 - Lucio Anderlini - - Moved the Matching magic in TeslaToolTwoParticleMatching to the - general tool TeslaMatcher (released under Phys/TeslaTools). - Warning: this may break existing scripts running on MicroDST since - the RootInTes property is not propagated to tools. - -!======================= DecayTreeTuple v5r3 2015-10-19 ====================== - -! 2015-10-14 - Marian Stahl - - Added TupleToolAllTracks for isolation studies and/or adding particles - to an existing chain. More details are given in the header - -! 2015-10-05 - Pieter David - - add TupleToolBeamSpot, an event tupletool which fills the beamspot x and y - position - -! 2015-10-05 - Gerhard Raven - - fix out-of-bounds error in TupleToolCaloDigits - - replace endreq with endmsg - -!======================= DecayTreeTuple v5r2 2015-08-06 ===================== - -! 2015-07-27 - Marco Pappagallo - - Bug fix in TupleToolNeutrinoReco. - -!======================= DecayTreeTuple v5r1 2015-07-24 ===================== - -! 2015-06-15 - Ricardo Vazquez Gomez - - Add the IsMuonTight variable to the TupleToolPid.cpp - -! 2015-06-09 - Lucio Anderlini - - Fixed a bug in TupleToolTwoParticleMatching: matching was achieved with - positive particles only. If statement is now removed. - -!======================= DecayTreeTuple v5r0 2015-06-03 ===================== - -! 2015-06-03 - Lucio Anderlini - - Updated TupleToolTwoParticleMatching: - . added property "ToolList" which will replace "TupleTools", for conformity - with other tools as a requirement for a future implementation of - the addTupleTool syntax - . added property "MatchLocations" which replaces "MatchWith" (still present - for backward compatibility). MatchLocations takes a dictionary (in C++ - converted to map) where the first string is a particle - name (present in LHCb Particle Database), and the second is the match - location. An example is reported in the updated doxygen documentation. - -! 2015-05-11 - Eduardo Rodrigues - - Removed warning in compilation of TupleToolTwoParticleMatching. - -!======================= DecayTreeTuple v4r14 2015-04-22 ===================== - -! 2015-04-13 - Olivier Deschamps - - TupleToolCaloHypo : add basic CaloHypo::CaloPosition() information - - TupleToolSubMass : add vertex information for all final-stat particle combination - -! 2015-03-20 - Komarov Ilya - - Added TupleToolTwoParticleMatching tool (.cpp and .h) - This tool allows to match candidates from different locations in dst - (Originally was developed for matching of Tesla and stripping candidates) - . Match candidates basing on track similarity - . Fills tuple with output of chosen tuple tools form matched candidates - . Not all tools are supported yet - -! 2015-03-20 - Eduardo Rodrigues - - Fixed trivial typo in TupleToolGeometry.cpp. - -! 2015-03-19 - Eduardo Rodrigues - - TupleToolGeometry: refitter algo. made configurable property, set to - LoKi::PVReFitter by default, and a public instance by default. - -!======================= DecayTreeTuple v4r13 2015-01-16 ===================== - -! 2015-01-16 - Eduardo Rodrigues - - Added python/DecayTreeTuple/__init__.py to please CMake. - -!========================= DecayTreeTuple v4r12 2014-12-15 ========================= - -! 2014-12-10 - Olli Lupton - - More changes to TupleToolSwimmingInfo: - . Handle events where multiple candidates were swum. This is more complicated - because there is no longer a 1:1 mapping from tracks to swimming reports. - . Write the generic 'extra' information stored in TPs to the tuple. - . Remove properties 'ReportsLocation', 'UseExtraLocation' and 'ExtraLocation'. - Replace with 'RelationsLocation'. With the new multiple-candidate-aware - Phys/Swimming version then the 'ExtraLocation' hack is redundant. - . General cleaning up. - -!========================= DecayTreeTuple v4r11 2014-10-30 ========================= - -! 2014-10-03 - Olivier Deschamps - - TupleToolBremInfo : Fix issue in case of non converted photon in the decay - -! 2014-10-02 - Olivier Deschamps - - TupleToolBremInfo : add DiElectron brem info for gamma->ee - - TupleToolSubMass : fix problem in decay sorting for some rare configuration - -! 2014-09-08 - Chris Jones - - Update TupleToolPropertime and TupleToolParticleReFit to access vertex - fitters and propertime fitters via the IDVAlgorithm interface, instead - of defining their own types. - -!========================= DecayTreeTuple v4r10 2014-07-25 ========================= - -! 2014-07-03 - O. Deschamps - - TupleToolPi0Info : Add 'daughters' info in case of merged pi0 - - TupleToolBremInfo : Adapt to change in DaVinciTools. Brem multiplicity is - now reliable even on microDST. - -!========================= DecayTreeTuple v4r9 2014-05-19 ========================= - -! 2014-05-12 - Olli Lupton - - Overhaul TupleToolSwimmingInfo: - . Fill 0 TPs for events which were not swum, rather than returning an error code. - . Tweak logic for dealing with multiple candidates in ExtraLocation. - . Match composite particles to their TPs by comparing their daughters, rather than - comparing them directly. Copes better when the same candidate is tagged as both - flavours. - . Only write per-(trigger|stripping)-line TP decision branches if there are more - than one of them (i.e. don't duplicate ..._DEC to ..._DEC_linename if there's - only one line, as there typically is for the Stripping) - . Fix typo (?) where one of .._Stripping_nTP and .._Trigger_nTP got duplicated as - .._nTP - . Increase maximum number of turning points from 100 to 1000 (some KSHH candidates - get >100) - -! 2014-04-09 - Albert Puig - - Cleanup of TupleToolVtxIsoln (removed unneeded vars and properties). - - Improved documentation in TupleToolVtxIsoln. - -!========================= DecayTreeTuple v4r8 2014-04-02 ========================= - -! 2014-04-01 - Chris Jones - - Add DecayTreeTupleANNPID to package list. - -!========================= DecayTreeTuple v4r7 2014-02-20 ========================= - -! 2014-01-31 - Chris Jones - - Fix a couple of minor bugs in TupleToolDecayTreeFitter :- - . Invalid check for verbose printout level - . Seg. fault when attempting for get the TES location for an object not in - the TES. - -! 2014-01-21 - Stefania Vecchi - - Added a protection on null pointers - - Enabled writing of SSpionBDT - -!========================= DecayTreeTuple v4r6 2013-12-18 ========================= - -! 2013-12-11 - Alex Shires - - TupleToolBremInfo - Add the HasBremAdded flag (the BremMultiplicity is not - correct on uDSTs). - -! 2013-12-10 - Stefania Vecchi - - TupleToolTagging: Add info on the chisquare of the vertex fit B+particle. - -! 2013-12-09 - Stefania Vecchi - - TupleToolTagging: Add Igor's code to save tagger informations - (IP,p,pT,IP_B...) if StoreTaggersInfo = True. - -! 2013-11-30 - Stefania Vecchi - - TupleToolTagging: Add OS_Charm and SS_Proton taggers in the list of active - taggers to save. - -!========================= DecayTreeTuple v4r5 2013-10-29 ========================= - -! 2013-10-16 - Patrick Koppenburg - - TupleToolDecayTreeFitter: Fix bug https://savannah.cern.ch/bugs/index.php?102869 - Now there's a protection against non functional substitutions and against - mass constraining particles not in the decay tree. - -! 2013-10-09 - Patrick Koppenburg - - TupleToolGeometry: Fix bug https://savannah.cern.ch/bugs/index.php?102616 - Now issue an error when a composite particle without a vertex is given, - like a rho+. - -!========================= DecayTreeTuple v4r4 2013-10-02 ========================= - -! 2013-08-16 - Albert Puig - - New version of TupleToolVtxIsoln that makes use of the VertexIsolation tool. - -!========================= DecayTreeTuple v4r3 2013-08-01 ========================= - -! 2013-07-23 - Chris Jones - - Update previous commit to check once during initialize() instead of - during every call to fill(...). - -! 2013-07-10 - Patrick Koppenburg - - TupleToolDecayTreeFitter: Bug #102007 : Always require an instance name. - -! 2013-07-07 - Stefania Vecchi - - TupleToolTagging.cpp: no more filling of the Tagging Category - Requires Event/PhysEvent 159384 - -!========================= DecayTreeTuple v4r2 2013-06-13 ========================= - -! 2013-05-17 - Antonio Falabella - - TupleToolTagging.cpp: Changed in order to retrieve the flavour tagging - informations if they are present (for uDST/DST persistency). - -!========================= DecayTreeTuple v4r1 2013-04-05 ========================= - -! 2013-03-21 - Patrick Koppenburg - - TupleToolDecayTreeFitter: Allow for NULL PVs in PV comparison method. - Fixes bug https://savannah.cern.ch/bugs/?100933. - -! 2013-03-07 - Chris Jones - - Change the way the tuple names for stable particles in - TupleToolDecayTreeFitter to fix a problem where different types where being - mixed in the same tuple branches. - - Prefer boost::lexical_cast over static_cast to char - - Fix a few minor performance issues related to not using references where - appropriate. - -! 2013-03-04 - Patrick Koppenburg - - New flag FilMultiPV for TupleToolGeometry (that's becoming a monster) - -! 2013-02-26 - Chris Jones - - Fix -pedantic compilation warnings - -! 2013-02-25 Kazu Akiba - - Adding TupleToolParticleStats. this tool only counts the number of particles - reconstructed, located in a particular location. By default it counts - the number of photons, but locations can be set to count any kind of particle. - -!========================= DecayTreeTuple v4r0p1 2013-02-20 ========================= - -! 2013-01-18 - Chris Jones - - Small clean up and optimisation of TupleToolGeometry - -!========================= DecayTreeTuple v4r0 2012-11-30 ========================= - -! 2012-11-29 - Marco Clemencic - - Added CMake configuration file. - - Modified requirements to simplify auto conversion to CMake. - -! 2012-11-22 - Chris Jones - - Major restructuring. - + Move the base classes and core components to a new package called - Phys/DecayTreeTupleBase. - + Move some components to various seperate new packages - . DecayTreeTupleDalitz - 'Dalitz' tools - . DecayTreeTupleJets - Jet tools - . DecayTreeTupleMC - MC tools - . DecayTreeTupleMuonCalib - Muon PID calibration - . DecayTreeTupleReco - Reconstruction information tools - . DecayTreeTupleTrigger - Trigger and stripping tools - -! 2012-11-19 - Chris Jones - - Protect MCTupleToolKinematic against an empty MCVertex container and also - NULL MCVertex pointers - -! 2012-11-16 - Chris Jones - - Minor clean up of TupleToolDira and TupleToolPrimaries - - Standardise the Trigger/TISTOS variable names with the rest of the tools - to start with _ - -! 2012-10-29 - Wouter Hulsbergen - - Make sure TTDecayTreeFitter uses TrackStateProvider to improve Ks tracks - in 2012 dsts. - -! 2012-10-26 - Maurizio Martinelli - - Added a flag in TupleToolDecayTreeFitter to store the refitted tracks - momentum. - -! 2012-10-24 - Alexandra Martin Sanchez - - Added TupleToolL0Calo.cpp, TupleToolL0Calo.h to compute - L0 trigger efficiencies from decay tree tuple. - -! 2012-10-16 - Patrick Koppenburg - - Move MaxPV property to TupleToolBase. Use it in TupleToolDecayTreeFitter, - TupleToolPrimaries and TupleToolGeometry - - TupleToolGeometry: new fields (verbose) AllIP and and AllIPchi2. - -!========================= DecayTreeTuple v3r26 2012-10-04 ========================= - -! 2012-09-11 - Chris Jones - - Clean up base classes, making things private that have no reason to be protected - - Rework printout so it uses MsgStream and doesn't send any "\n" characters that - screw up Message Service indenting. - - Update various tools to use getIfExists - - Remove nPVs from TupleToolEventInfo. Implementation would not work on a uDST, - variable is available from TupleToolRecoStats (where it is better at home anyway) - in a way that is uDST friendly. - -!========================= DecayTreeTuple v3r25 2012-08-31 ========================= - -! 2012-08-08 - Patrick Koppenburg - - src/TupleToolDecaytreeFitter : remove warning about the bug that was just fixed. - -! 2012-08-08 - Patrick Koppenburg - - src/TupleToolDecaytreeFitter : do not store original PV if refitted version is - already included. - bug #89749: TupleToolDecayTreeFitter stores the chain wrt best PV twice when - PV is refitted - -! 2012-0806 - Patrick Koppenburg - - src/TupleToolTriggerBase: complain when trailing Decision is missing. - -! 2012-07-31 - Patrick Koppenburg - - Backward incompatible changes (i.e. some variables will change) - . src/MCTupleToolKinematic.cpp : store OSCIL flag in Verbose mode only - . src/TupleToolDecayTreeFitter : rename chi2_B to chi2 - - Backward compatible changes: - . src/DecayTreeTupleBase.* : inherit from DaVinciTupleAlg - . src/TupleToolTrackInfo.cpp : add prefix+"_TRACK_FirstMeasurementX,Y,Z in Verbose mode - -!========================= DecayTreeTuple v3r24p1 2012-07-26 ========================= - -! 2012-07-26 - Chris Jones - - Minor CPU optimisation. - -!========================= DecayTreeTuple v3r24 2012-07-09 ========================= - -! 2012-07-02 - Chris Jones - - Remove all usage of the OnOfflineTool - -! 2012-06-30 - Chris Jones - - Fix 32bit compilation warnings from TupleToolBremInfo - -! 2012-06-29 - Chris Jones - - Use a public instance of LoKi::DistanceCalculator in TupleToolIsolationTwoBody - -!========================= DecayTreeTuple v3r23 2012-06-28 ========================= - -! 2012-06-23 - Olivier Deschamps - - Add new tool TupleToolBremInfo : provide multiplicity/momentum/origin of brem - for electron particles - -! 2012-06-22 - Chris Jones - - Use getIDVAlgorithm instead of getDVAlgorithm, in preparation of a future - change to the DaVinci base classes. - -! 2012-06-15 - Albert Bursche - - Prevent TupleToolDalitz from running on jets. It leads to segfaults otherwise. - -! 2012-06-15 - Chris Jones - - Fix a compilation warning in TupleToolVeto + some minor optimsations. - -! 2012-06-15 - Fatima Soomro -- Added the functionality in TupleToolTISTOS to specify a list of PIDs, - that IF specified will direct the tool to fill trigger info only for those - particles, like tuple.TupleToolTISTOS.PIDList = [413, 211, 421, 333, 22, 321] - If no list is specified the tool behaves as it used to previously, - i.e. fill trigger info for all the particles in the decay descriptor -- Added _CaloSpdE and _CaloPrsE to TupleToolPid - -! 2012-06-14 - Olivier Deschamps - - TupleToolSubMass : fix problem with tree ordering for some charged B decays - - TupleToolStripping : fix problem with DecReports structure changing between - different events, due to null reports being suppressed - to save space on the (m)DSTs. - ==> the list of stripping lines must now be set explicitely via the - StrippingList property (or equivalently TriggerList inherited from - TupleToolTriggerBase) - -! 2012-06-12 - Olivier Deschamps - - TupleToolSubMass : new tool producing the invariant masses for all n-body - combinations in N-body decays (n=2,N) - . The PID subtitution can be configured - -! 2012-06-06 - Marc Grabalosa - - TupleToolTagging : New and consitstent default tag decision and omega (0, 0.5) - -! 2012-06-05 - Patrick Koppenburg - - TupleToolTrackInfo: - . Add Track likelihood - . Move Match chi2 to non verbose mode as this is the suggested chi2 to cut on - . Buglet in VELO_UTID - -! 2012-05-15 - Patrick Koppenburg - - Add some verbose printout in TupelToolDecayTreeFitter to link to bug - . https://savannah.cern.ch/bugs/?89749 - -! 2012-05-09 - Rob Lambert - - throw NameError in addBranches if the branch name contains whitespace - . fixes bug #94449 - -!========================= DecayTreeTuple v3r22p1 2012-05-08 ========================= - -! 2012-05-08 - Patrick Koppenburg - - Protect TupleToolDalitz against NULL ParticleProperties. - See Bug https://savannah.cern.ch/bugs/?94383 - - Do so as well in TupleToolWZJets - -!========================= DecayTreeTuple v3r22 2012-05-03 ========================= - -! 2012-05-02 - Fatima Soomro - - Added TupleToolIsolationTwoBody - + Based on Giampi's isolation tool which should go into DVTools at some - point... After that it will be a matter of a few lines to get isolation - extract the isolation variable for a track. There are many parameters which - can be tuned, see Giampi's talk on this in Dec 2011. - - Added TupleToolMuonIDCalib - + The latter is used for Muon (mis)ID studies, particularly for Bs-> mumu. - An example of how to configure this tool can be found at - http://svnweb.cern.ch/world/wsvn/lhcb/Erasmus/trunk/Phys/LNFNTuples/scripts/muID_mdst_March2012.py - -! 2012-04-27 - Olivier Deschamps - - Add a new tool TupleToolVeto that flag a particle when already used to build - another particle in a given container (relies on DaVinciTools/ParticleVeto) - - TupleToolL0Data : fix default setting - -! 2012-04-04 - V. Gligorov - - Add options to TupleToolSwimmingInfo to allow it to grab particles by hand - from a specified location, in order to solve (hack) problem with the - D*->D0pi chain in which the D0 linked to from the D* is not the same D0 - linking to the swimming reports. - - Currently only works for one candidate per event. - -! 2012-04-02 - Chris Jones - - Suppress the numerous icc11 compiler remarks and warnings. - -!========================= DecayTreeTuple v3r21 2012-03-29 ========================= - -! 2012-03-23 - Jibo He - - TupleToolTISTOS - . Added Hlt1Phys Hlt2Phys - -! 2012-03-21 - Chris Jones - - Some fixes for running on uDSTs, in TupleToolTrigger and TupleToolStripping. - - If HltRoutingBits are missing, catch the exception that is thrown in - TupleToolTrigger, so the processing does not terminate. - -! 2012-03-20 - Patrick Koppenburg - - Fix warning about unsigned long - -! 2012-03-20 - Patrick Koppenburg - - DecayTreeTupleTemplates.icpp: Ignore TupleToolDecay when initialising tools. - This avoids the red herring - ERROR DecayTreeTuple:: Can't get the tool 'TupleToolDecay/B', check your syntax - StatusCode=FAILURE - -! 2012-03-20 - Patrick Koppenburg - - TupleToolGeometry: Fix misleading message - ERROR TupleToolGeometry:: Can't retrieve the end vertex for piminus StatusCode=FAILURE - Introduced on 2012-03-14 - -! 2012-03-19 - Roel Aaij - - TupleToolSwimmingInfo: replace "/" with "_" in decision branch names. - -! 2012-03-14 - Patrick Koppenburg - - TupleToolGeometry: do things in slightly different order - -!========================= DecayTreeTuple v3r20 2012-02-09 ========================= - -! 2012-02-09 - Patrick Koppenburg - - TupleToolGeometry : fill MINIP only in verbose (allows to switch it - off for microDST) - -! 2012-02-09 - Patrick Koppenburg - - Fix bug #91350 : do not follow pv is there isn't any. - - Move sumPT method to TupleToolPrimaries - -! 2012-02-07 - Cedric Potterat - - Update TupleToolJetsBase according to the developpement of LoKiJetMakerAlg - (Phys/LoKiJets) - -! 2012-01-26 - Chris Jones - - Remove hack in TupleToolEventInfo to save event number and GPS time as - doubles. Gaudi v23r0 supports saving these natively as ulonglong. - -! 2011-12-23 - Rob Lambert - - Switch to TrackStateProvider in TupleToolTrackPosition - -! 2011-12-18 - Chris Jones - - Extend the TupleToolPid to include all of the main sub-detector PID - variables when in verbose mode. - -! 2011-12-17 - Chris Jones - - Add RICHDLLbt to variables saved by the TupleToolRICHPid - - Explicitly store the above-threshold flag for each PID hypothese, regardless - of the Particle type. - -!========================= DecayTreeTuple v3r19 2011-12-15 ========================= - -! 2011-12-14 - Chris Jones - - Extend TupleToolMCBackgroundInfo to use a list of background category - tools. Allows for out-the-box running on both DSTs and uDSTs. - - Extend TupleToolMCTruth to use a list of MC associators instead of a - single one. Allows (almost) for out-the-box running on both DSTs and uDSTs. - A few warnings/errors need to be squash when running on uDSTs. - -! 2011-12-07 - Patrick Koppenburg - - Task #24643: - . src/TupleToolDecayTreeFitter : use new Tool SubstitutePIDTool - These changes need Phys/DaVinciInterfaces r132662 and - Phys/DaVinciTools r132663 - -! 2011-12-05 - Patrick Koppenburg - - First working version of PID-changing decaytreefitter. Task #24643 - . TODO : extract functionality in a tool that can be shared with - SubstututePID. Now there's a lot of code duplication. - -! 2011-12-03 - Chris Jones - - General tidy up - - Reimplement TupleToolRecoStats to only use information from the - RecSummary object. Makes the tool compatible with uDSTs. - - Add a temporary hack to TupleToolEventInfo to split the 64bit event Number - and GPS time into two 32 bit ints and store these. Allows the full 64 bit - variable to be reconstructed later on if required. - Temporary hack until Gaudi fully supports 64bit variables in Tuples (v23r0). - -! 2011-11-29 - Chris Jones - - Remove some redundant messages from initialisation of DecayTreeTuple - -! 2011-11-24 - Patrick Koppenburg - - TupleToolTrackInfo : add match chi2 - -! 2011-11-23 - Tomasz Skwarnicki - - Make TupleToolEventInfo, TupleToolTrigger try info location with and - without RootInTES - -! 2011-11-23 - Chris Jones - - Fix various gcc 4.6 compilation warnings and errors - -! 2011-11-21 - Andrew Powell - - TupleToolMuonPid: Added LHCb::ProtoParticle::InAccMuon to tuple - -! 2011-11-15 - Chris Jones - - Tidy up the TisTos tool a bit - -! 2011-11-11 - Patrick Koppenburg - - TupleToolDecayTreeFitter : more verbose printout - -! 2011-11-11 - Chris Jones - - Update TupleToolMCBackgroundInfo to always load the Background category - tool using the same runtime name. - -!=================== DecayTreeTuple v3r18 2011-11-10 ========================= - -! 2011-11-10 - Patrick Koppenburg - - TupleToolDecayTreeFitter : Fix bug 88702 - -! 2011-11-10 - Roel Aaij - - Remove spurious include from TupleToolSwimmingInfo. - -! 2011-11-01 - Patrick Koppenburg - - TupleToolDecayTreeFitter : Fix bug 88365 - -! 2011-10-17 - Roel Aaij - - Update TupleToolSwimmingInfo to fill false everywhere if the global Hlt or - stripping decision is false. - -! 2011-10-15 - V. Gligorov - - First commit of TupleToolSwimmingInfo for holding acceptance - information from the swimming code. - -! 2011-10-05 - Patrick Koppenburg - - TupleToolDecayTree: add mass for intermediate states when Verbose is True - -! 2011-10-03 - Chris Jones - - Fix the incorrect usage of std::unique to remove duplicates - -! 2011-09-27 - Marco Gersabeck - - TupleToolPropertime: add option FitToPV to allow measuring proper time w.r.t. - their best PV for all particles - -!=================== DecayTreeTuple v3r17 2011-09-15 ========================= -! 2011-09-07 - Patrick Koppenburg - - TupleToolEventInfo : add field polarity - - TupleToolMuonPid: comment out unused IsMuonTight. Causes a warning. - -! 2011-09-01 - Albert Bursche - - added TupleToolJets a trivial tool derrived from TupleToolJetsBase - -! 2011-09-01- Kazu Akiba - -Changed TupleToolMuonPid. added few vairables. - -! 2011-09-01- Kazu Akiba - - Adding TupleToolMuonPid. simple tuple tool based on tupletoolpid with, - but with a small selection of the muon variables - - -! 2011-08-17 - Rob Lambert - - Add Stripping TisTos ability to TUpleToolTISTOS, - . requires .TriggerTisTosName = "TESTisTos" - . .FillXXX=False - . .FillStripping=True - -! 2011-08-10 - Patrick Koppenburg - - TupleToolEventInfo : - . store event number as double to fix Bug #84257 - . Add trigger type in verbose mode. - -!========================= DecayTreeTuple v3r16 2011-07-28 ========================= -! 2011-07-27 - Albert Bursche - Overhaul of the TupleToolJets family - - added support for 'ExtraWeights' to TupleToolJetRelations - - fixed missing TupleToolJetsBase::initialize in TupleToolJetRelations - - improved handling of non-basic particles in TupleToolWZJets - - -! 2011-07-04 - Patrick Koppenburg - - TupleToolassHypo: Fix bug 83621 - New behaviour: Now the tool does cc by default. - -!========================= DecayTreeTuple v3r15 2011-06-29 ========================= -! 2011-06-24 - Patrick Koppenburg - - src/TupleToolRecoStats.cpp : more stuff - - src/TupleToolDecayTreeFitter.h : better (?) doc - -! 2011-06-24 - Olivier Deschamps - - restore doc/release.notes - - TupleToolProtoPData : fix info() verbosity - - TupleToolCaloHypo : change default properties (neutral only by default) - -! 2011-06-17 - Andrew Powell - - TupleToolRICHPid: Added track (x,y,z) and (rho,phi) entrance coordinates for each radiator - -! 2011-06-17 - Olivier Deschamps - - NEW TupleToolProtoData: tuple ProtoP Info (from property list) - require CaloUtils v9r1 - - -! 2011-06-14 - Olivier Deschamps - - TupleToolBase.h : new method isPureNeutralCalo() based on CaloUtils/CaloParticle.h : detect neutral calo particles (gamma, pi0, eta->gg, ...) - NEEDED to treat gamma->e+e- as a standard vertexed particle. - -> adapted tools : TupleToolDira, TupleToolGeometry, TupleToolPID, TupleToolRichPID, TupleToolVtxIsoln (previously gamma/pi0 filtering was based on particleID) - - TupleToolRecoStats : add multiplicity in long tracks with Chi2 < threshold (default threshold = 9) - - TupleToolPi0Info : add CL - - NEW TupleToolL0Data : tuple L0Data (from property list) and emulated L0Decision (for L0TCK list) - - NEW TupleToolCaloHypo : tuple data (from property list) from CaloHypoEstimator for particle->proto()->calo() - - NEW TupleToolDira (Fatima Soomro) : tuple dira and error - - -! 2011-06-13 - Philip Hunt - - Added MCTupleToolPrompt which flags whether a particle originates from a prompt charm - decay based on the true lifetime of the ancestors. - -!========================= DecayTreeTuple v3r14p2 2011-05-24 ========================= -! 2011-05-23 - Albert Bursche - - Fixed segfault in TuplToolJetRelations. - Dummy entries were not properly named. - -! 2011-05-20 - Albert Bursche - - Added TuplToolJetRelations and fixed segfault in TupleToolWZJets - which was due to shadowing of m_Tuple variable in TupleToolJetsBase. - - -!========================= DecayTreeTuple v3r14p1 2011-05-20 ========================= -! 2011-05-20 - Rob Lambert - - Revert bad behaviour of TupleToolGeometry with respect to refitting PVs. - Introduced in previous version "2011-04-04 - Yuehong Xie" - bug #82482 - Broke TupleToolGeometry on MicroDSTs and falls outside the established - refitting framework. - For the moment only refit if an option is set to true. - In the future this should be linked with Juan's refitting framework. - - -! 2011-05-17 - Albert Bursche - - Added TuplToolJetsBase and transferred much of the funtionality from TupleToolWZJets to it. - This is done in order to ease adding of more Jet related TupleTools in the near future. - -!========================== DecayTreeTuple v3r14 2011-04-29 ================= -! 2011-04-26 - Patrick Koppenburg - - TupleToolKinematic::preFitMass: fix bug 81455 - -! 2011-04-14 - Patrick Koppenburg - - TupleToolDecayTreeTuple : pass reference to fitter - -! 2011-04-08 - Juan Palacios - - TupleToolTriggerbase - . Remove unused data member. - - TupleToolDecayTreeTuple - . Fix memory leaks, avoid some newed pointers. - -! 2011-04-06 - Patrick Koppenburg - - TupleToolDecayTreeTuple : add PV key and coordinates wehn isVerbose() is on - - TupleToolBase : inline methods should be const - . Move Number.icpp into TupleToolBase - - Adpat TupleTool*RecoStats accordingly - -! 2011-04-04 - Yuehong Xie - - TupleToolGeometry: - . explicit call the PV refitter when filling variable "_MINIP, _MINIPCHI2, - _MINIPNEXTBEST, _MINIPCHI2NEXTBEST". Lack of this feature caused a problem - in the B->JpsiX analysis. - -! 2011-04-01 - Patrick Koppenburg - - Second part of TupleToolDecayTreeFitter : - . Loop over PVs and fill one entry per PV. The best PV always comes first. - . TODO : take only PVs related to candidate once task https://savannah.cern.ch/task/?19817 - is complete - -! 2011-04-01 - Patrick Koppenburg - - TupleToolDecayTreeFitter : - . Full re-implementation following suggestion https://savannah.cern.ch/bugs/?80317 - . WARNING: This is bacward-incompatible with previous configurations. Example: - -decay = "B0 -> (^J/psi(1S) -> ^mu+ ^mu-) (^KS0 -> ^pi+ ^pi-)" -bh = 'B0' -tuple.Decay = decay -tuple = DecayTreeTuple("MyTuple") -tuple.ToolList += ["TupleToolGeometry", "TupleToolKinematic", "TupleToolPrimaries", "TupleToolEventInfo" ] -tuple.Branches = { "B" : "["+bh+"]cc : "+decay.replace("^","") } -from Configurables import TupleToolDecayTreeFitter -tuple.B.ToolList += [ "TupleToolDecayTreeFitter/Fit", # just a refit - "TupleToolDecayTreeFitter/PVFit", # fit with PV constraint - "TupleToolDecayTreeFitter/MassFit", # fit with J/psi mass constraint - "TupleToolDecayTreeFitter/FullFit" ] # fit with all constraints I can think of - -tuple.B.addTool(TupleToolDecayTreeFitter("PVFit")) -tuple.B.PVFit.Verbose = True -tuple.B.PVFit.constrainToOriginVertex = True -tuple.B.PVFit.daughtersToConstrain = [ "J/psi(1S)" ] - -tuple.B.addTool(TupleToolDecayTreeFitter("MassFit")) -tuple.B.MassFit.constrainToOriginVertex = False -tuple.B.MassFit.daughtersToConstrain = [ "J/psi(1S)" ] - -tuple.B.addTool(TupleToolDecayTreeFitter("FullFit")) -tuple.B.FullFit.Verbose = True -tuple.B.FullFit.constrainToOriginVertex = True -tuple.B.FullFit.daughtersToConstrain = [ bh, "J/psi(1S)" ] - - . This will produce the following columns for the B (from this tool): - - B_Fit_status B_Fit_nDOF B_Fit_chi2_B B_Fit_nIter B_Fit_M B_Fit_MERR B_Fit_P B_Fit_PERR - - B_PVFit_PERR B_PVFit_ctau B_PVFit_ctauErr B_PVFit_decayLength B_PVFit_decayLengthErr B_PVFit_J_psi_1S_ctau - B_PVFit_J_psi_1S_ctauErr B_PVFit_J_psi_1S_decayLength B_PVFit_J_psi_1S_decayLengthErr B_PVFit_KS0_ctau - B_PVFit_KS0_ctauErr B_PVFit_KS0_decayLength B_PVFit_KS0_decayLengthErr - - B_MassFit_status B_MassFit_nDOF B_MassFit_chi2_B B_MassFit_nIter B_MassFit_M B_MassFit_MERR B_MassFit_P - B_MassFit_PERR B_PVFit_status B_PVFit_nDOF B_PVFit_chi2_B B_PVFit_nIter B_PVFit_M B_PVFit_MERR B_PVFit_P - - B_FullFit_status B_FullFit_nDOF B_FullFit_chi2_B B_FullFit_nIter B_FullFit_M - B_FullFit_MERR B_FullFit_P B_FullFit_PERR - B_FullFit_ctau B_FullFit_ctauErr B_FullFit_decayLength B_FullFit_decayLengthErr - B_FullFit_J_psi_1S_ctau B_FullFit_J_psi_1S_ctauErr B_FullFit_J_psi_1S_decayLength B_FullFit_J_psi_1S_decayLengthErr - B_FullFit_KS0_ctau B_FullFit_KS0_ctauErr B_FullFit_KS0_decayLength B_FullFit_KS0_decayLengthErr - - - src/TupleToolTISTOS.h : remove unsused pointer to IPaticleDescedants tool - -!========================== DecayTreeTuple v3r13 2011-03-10 ================= - -! 2011-03-09 - Yasmine Amhis - - - TupleToolDecayTreeFitter - . Move comment from .cpp to .h -! 2011-03-09 - Yasmine Amhis - - TupleToolDecayTreeFitter - . add doc and comments - -! 2011-03-08 - Albert Bursche - - Some code cleanup in TupleToolWZJets. - Added some meaning to 'Verbose' flag. - Results with Verbose = True should be equal to those calculated before. - -! 2011-03-08 - Rob Lambert - - Fixed TupleToolTagging to allow multiple different tagging tools, - each with different options as required, see bug #79090 - -! 2011-03-04 - Patrick Koppenburg - - TupleToolVtxIsoln : Change info to debug - -! 2011-03-01 - Yasmine Amhis - - TupleToolDecayTreeFitter - . minor bug fix - -! 2011-02-22 - Patrick Koppenburg - - TupleToolVtxIsoln: - . Remove useless limitation to pid 511 - . Remoev IP and IPS options (that were'n working anyway) - . Change default chi2 and DeltaChi2 cuts to 9 (so they do something) - . Add tuple variables _SMALLESTCHI2, _SMALLESTDELTACHI2 - . Fixed doxygen - . Fix bug 78611 - -!========================== DecayTreeTuple v3r12 2011-02-20 ================= - -! 2011-02-15 - Chris Jones - - Initialise m_ppSvc in TupleToolWZJets during initialize() method and - not the Constructor. - -! 2011-02-13 - Chris Jones - - Add missing use statement in requirements file for HltEvent - -! 2011-02-11 - Albert Bursche - - New tool TypleToolWZJets that adds jets to particles and writes - jets infos in the tuple (and jets to TES) - -! 2011-02-11 - Patrick Koppenburg - - New tool TypleToolMassHypo that adds masses iunder otrher pid hypotheses. - May have some limitations... - -! 2011-02-01 - Rob Lambert - - Removed AutomaticList and CollateTriggerList from TupleToolTriggerBase, - Now if you specify Verbose you have to give a list. - To find out the list, talk to the other members of your group - or run ReadHltReport in your sequence - -!========================== DecayTreeTuple v3r11p1 2011-01-21 =============== - -! 2011-01-21 - Juan Palacios - - Make compatible with DaVinci v26 series. - - Increase to v3r11p1. - -! 2011-01-20 - Rob Lambert - - Fixed a bug in the addTupleTool wrapper if an instance was supplied - in this case splitName seems to give odd results, and the __class__ - must be called to find the true tool name - -! 2011-01-20 - Rob Lambert - - Added TupleToolTrackPosition, propagates tracks to the given Z - Stores X and Y - -!========================== DecayTreeTuple v3r11 2011-01-19 ================= - -! 2011-01-17 - Marc Grabalosa - - Add OS combination tagcat, omega and decision in TupleToolTagging.cpp - -! 2011-01-14 - Rob Lambert - - Add python directory and a Configuration.py to dress-up the configurables - Functions: addTupleTool and addBranches defined to simplify life a lot. - Currently one must replace "from Configurables import DecayTreeTuple" - with "from DecayTreeTuple.Configuration import *" - -! 2011-01-14 - Juan Palacios - - DVAlgorithm::bestPV -> DVAlgorithm::i_bestVertex. - -! 2011-01-12 - Chris Jones - - Add LHCb::ProtoParticle::ProbNNghost to variables stored by TupleToolPid - -! 2011-01-11 - Rob Lambert - - Protect against null pointer resolution in TupleToolNeutrinoReco - -! 2011-01-04 - Juan Palacios - - Replace all calls to desktop() by new DVAlgorithm equivalents. - - Increase to v3r11. - - REQUIRES Phys/DaVinciKernel v9r0 OR HIGHER!!! - -!========================== DecayTreeTuple v3r10 2010-12-20 ================= - -! 2010-12-09 - Rob Lambert - - Add mass-dependence in TupleToolNeutrinoReco - - Fix bug in calculation of 'X' - - Update documentation to suit - -! 2010-12-01 - Juan Palacios - - Add property IBackgroundCategoryType to TupleToolMCBackgroundInfo. Controls - the implementation of IBackgroundCategory to be used. Default is "BackgroundCategory" - -! 2010-12-01 - Rob Lambert - - Add new tool TupleToolNeutrinoReco - Calculates the variables required to reconstruct a missing neutrino - Includes detailed instructions on what to do with the calculated vars - -! 2010-11-17 - Emilie Maurice - - TupleToolGeometry: add 2 variables to obtain the min IP and the min chi2 wrt the 2nd best primary vertex - -! 2010-11-16 - Patrick Koppenburg - - TupleToolTriggerBase: Bug fix. Verbose didn't get into fillVerbose - if none of VerboseXXX is set. Consequently one could nto get the - roiuting bits alone - - TupleToolEventInfo can now fill the mu of a run. See doxygen. - -! 2010-11-15 - V. Gligorov - - Add NeuroBayes based PID probabilities to TupleToolPid. There is one - probability per "stable" hypothesis (e,mu,k,p,pi) - -! 2010-11-05 - Michel De Cian - - TupleToolTrackIsolation: Bugfix, changed "partMomentum.Phi() - trackMomentum.Phi()" to "fabs( partMomentum.Phi() - trackMomentum.Phi() )" in method coneP - -! 2010-11-06 - Olivier Deschamps - - TupleToolKinematics : add specific protection in case of merged pi0 (basic particles with measured mass). Potential bug when both resolved pi0 and merged pi0 where run simultaneously as _MM column appear or not depending on the first pi0 type seen. - -! 2010-11-02 - Andrew Powell - - New Tuple Tool: TupleToolRICHPid - - Stores informartion associated with the RichPid object. To be used within - the RICH PID calibration package. - -!========================== DecayTreeTuple v3r9 2010-11-02 ================== - -! 2010-11-01 Yasmine Amhis - - TupleToolDecayTreeFitter - . Remove warning - -! 2010-10-30 - Yasmine Amhis - - TupleToolDecayTreeFitter - . New Algo to get many DTF with many configurations in one job. - -! 2010-10-30 - Ailsa Sparkes - - TupleToolGeometry: Added protection against crashes for Eta - -! 2010-10-27 - Tomasz Skwarnicki - - TupleToolTISTOS: make it possible to use non-standard TriggerTisTos tools - -! 2010-10-22 - Olivier Deschamps - - TupleToolPhotonInfo : add photon->ConfLevel() info - -!========================== DecayTreeTuple v3r8 2010-10-10 ================== - -! 2010-09-24 - Patrick Koppenburg - - Restore ReoutingBits in TupleToolTrigger. They got lost somehow. - -! 2010-09-09 - Patrick Koppenburg - - Add VeloLiteClusters to TupleToolRecoStats - -!========================== DecayTreeTuple v3r7 2010-08-20 ================== - -! 2010-08-19 - Patrick Koppenburg - - TupleToolRecoStats: add a protection against no velo tracks in the event - (happens every 100000 events or so) - - TupleToolCPU : store memory and CPU time - -! 2010-08-11 - Jibo He - - TupleToolRecoStats.h - Use boost::bind instead of boost::lambda::bind to get neater compilaton. - -! 2010-08-11 - Jibo He - - TupleToolRecoStats - . Add protection from empty track container so that it works also - for SDST, as reported by Stefano Perazzini in the mailing list. - -! 2010-07-28 - Patrick Koppenburg - - TupleToolRecoStats: add quantitites we use to discard huge events. - Code by Fatima Soomro and Jibo He. - -!========================== DecayTreeTuple v3r6 2010-07-08 ================== - -! 2010-07-03 - Tomasz Skwarnicki - - change TriggerTupleBase to treat L0 same way as Hlt1,Hlt2 - change TupleToolTrigger to use HltlikeL0 DecReports and line names - change TuplrToolTISTOS to use L0TriggerTisTos tool for L0, - now Hlt1L0 lines appear under their own rather then L0 names - -!========================== DecayTreeTuple v3r5p1 2010-06-24 ================ - -! 2010-06-24 - Rob Lambert - - MCTupleToolReconstructed bugfix bug #67537 - . not all entries filled if mcp was not stable. - -! 2010-06-08 - Patrick Koppenburg - - TupleToolTriggerBase : reduce printout - -! 2010-06-03 - Juan Palacios - - TupleToolVtxIsoln - . Remove useless include of deprecated Kernel/IGeomDispCalculator.h. - . Move IVertexFit include to .cpp. - -! 2010-06-02 - Patrick Koppenburg - - Remove useless stuff from TupleToolPrimaries - - New tool TupleToolDebug for bug #68232 - - TupleToolEventInfo : store number of PVs - -! 2010-06-02 - Patrick Koppenburg - - Bug 68234 : Strore origin vertex for stable MC particles as well. - -!========================== DecayTreeTuple v3r5 2010-05-24 ================ - -! 2010-04-28 - Olivier Deschamps - - new tuple tool : TupleToolPhotonInfo : with Spd/Prs/track-matching/ClusterMoment/... info - -! 2010-05-19 - Patrick Koppenburg - - More printout in TupleToolPrimaries - -! 2010-05-18 - Rob Lambert - - rewrite TupleToolPrimaries to make more sense to me - -! 2010-05-12 Juan Palacios - - src/TupleToolGeometry.cpp - . Adapt to new DVAlgorithm::primaryVertices() signature. - - cmt/requirements - . Increase version to v3r5. - -! 2010-05-09 - V. Gligorov - - TupleToolTriggerRecoStats - update for new HLT2 reconstruction. - -!========================== DecayTreeTuple v3r4 2010-04-30 ================ - -! 2010-04-28 - Patrick Koppenburg - - TupleToolEventInfo : add BX type and GPS time - -! 2010-04-26 - Patrick Koppenburg - - New tool TupleToolStripping that reads the stripping decisions from - DecReports. - -! 2010-04-23 - Jibo He - - TupleToolTrackInfo - Track->key() added to help check whether several candidates in one event - share the same track. - -! 2010-04-23 - Patrick Koppenburg - - TupleToolPropertime, MCTupleToolKinematic : Store _TAU as nanoseconds and - not picoseconds. Nanoseconds is the Gaudi convention. - WARNING : Backward incompatible with previous Tuples. - -! 2010-04-21 - Rob Lambert - - TupleToolTrackInfo: Added VELO_UTID, the double obtained from multiplying - all the velo hit IDs on the track together. - -! 2010-04-20 - Rob Lambert - - Fixed DecayTreeTuples such that the tuple is not created unless the - given decay was seen, savannah bug #65947 - -!========================== DecayTreeTuple v3r3 2010-04-12 ================ - -! 2010-04-12 - Rob Lambert - - Removed MM from basic particles in TupleToolKinematic - -! 2010-04-08 - Juan Palacios - - cmt/requirements - . Increased to v3r3 - -! 2010-03-31 - Rob Lambert - - Added a single '.' to TupleToolTriggerBase as suggested by Johannes - -! 2010-03-16 - Yuehong Xie - - Added Verbose momentum information at origin vertex position for basic particles - in TupleToolKinematic. - -! 2010-03-16 - Rob Lambert - - Fixed missed commit in TupleToolTriggerBase and TupleToolTrigger - TupleToolTriggerBase: Initialize, compile triggerList to look for - TupleToolTrigger: fill '-1' if requested trigger is not in reports - -!========================== DecayTreeTuple v3r2 2010-03-08 ================ - -! 2010-03-04 - Yuehong Xie -- TupleToolPID : Add hasRich, hasCalo, hasMuona nd isMuon - - -! 2010-03-03 - Patrick Koppenburg - - Add head_PreFitMass in vebose mode (task #14256) - -! 2010-03-01 - Rob Lambert - - TupleToolPrimaries : never get PVs from DVAlg, fixes #14187 - - DecayTreeTupleBase : Finalise TupleToolDecay instances, fixes #63124 - -!========================== DecayTreeTuple v3r1 2010-02-22 ================ - -! 2010-02-09 - Patrick Koppenburg - - TupleToolPrimaries : get PVs from DVAlgorithm by default. Fixes #62588. - - TupleToolPID : Add Ecal and Calo energies - -! 2010-02-06 - V. Gligorov - - TupleToolEventInfo : add L0, HLT, ODIN TCK information - -! 2010-02-06 - V. Gligorov - - TupleToolTISTOS,TupleToolTriggerBase : eliminate duplication of L0 - tistos information between the L0 and Hlt1L0 triggers - -!========================== DecayTreeTuple v3r0p1 2010-02-05 ================ - -! 2010-02-04 - Rob Lambert - - Minor Fix TupleTool Base - . Fix for slc5 warning returning const in return by value, see bug 62360 - -!========================== DecayTreeTuple v3r0 2010-01-27 ================== - -! 2010-01-27 - Rob Lambert - - Minor fixes: - . added forgotten baseclasses into the cvs - - TupleToolTagging: - . Verbose mode now gives decision and probability for all ActiveTaggers - -! 2010-01-26 - Rob Lambert - - Major changes: - . All TupleTools now inherit from TupleToolBase. - - defines the Verbose property for all Tools, which can be - checked with isVerbose() - - defines the ExtraName property for all Tools, which is used - to add a prefix to the name of every variable - This lets you have more than one copy of the same tool. - fullName() is cleverly used to construct the prefix. - - . TupleToolTrigger and TupleToolTISTOS now inherit from a common class - - TupleToolTriggerBase, allows the user to circumvent automatic - lists of trigger contents, to make sure the ntuple can be filled - from real data, where the trigger changes continuously. - - . The Verbose mode of TupleToolBase is now propagated to all tools, - only the most common/mandatory entries will be filled if !isVerbose(). - - - These changes have been tested and verified for - all the tools which changed a lot - - - The savannah bugs:61744,61672,61644 and task: 13423 should be consulted - -!========================== DecayTreeTuple v2r11 2010-01-26 =================== - -! 2010-01-20 Basem Khanji - - TupleToolTagging : Added the probability per tagger variables. - -!========================== DecayTreeTuple v2r10 2010-01-19 ================== -! 2010-01-19 - Patrick Koppenburg - - TupleToolGeometry : protect against no PV locations - -! 2010-01-13 - Patrick Koppenburg - - Remove IPhysDesktop inclusion everywhere - -! 2010-01-11 - V. Gligorov - - TupleToolTISTOS : use the ANNDispatchSvc to retreive the Hlt selection - IDs to names mapping. - -! 2010-01-05 - V. Gligorov - - TupleToolTrigger : use the ANNDispatchSvc to retreive the Hlt selection - IDs to names mapping. - -!========================== DecayTreeTuple v2r9 2009-12-16 ================== - -! 2009-12-08 - V. Gligorov - - TupleToolEventInfo : store the bunch crossing ID - - Tag gligorov_20091209 - -! 2009-12-08 - Patrick Koppenburg - - TupleToolGeometry : Do not skip candidates that have no best PV - - Increment to v2r9 - - Tag pkoppenb_20091208 - -!========================== DecayTreeTuple v2r8 2009-11-30 ================== - -! 2009-11-27 - Olivier Deschamps - - TupleToolPi0Info : set default RequireMCTruth to false and add Warning("deprecated tool") when set to true - - TupleToolVtxIsoln : add protection for merged pi0 (daughter but no endVertex) - -! 2009-11-25 - Patrick Koppenburg - - Fix compilation problem in TupleToolDalitz.icpp - -! 2009-11-24 - Patrick Koppenburg - - (MC)TupleToolDalitz.* : do not revert all PIDs, but revert daughters if - mother is an antiparticle. Was getting strange results for CP-conjugate - decays like D->KsPiPi. - - Correct warnings in TupleToolPi0Info - - v2r8 - -! 2009-11-19 - Rob Lambert - - src/MCTupleToolPID.{h,cpp} new. Add MC PID. - - src/MCTupleToolKinematic.{h,cpp} fix doxygen - -!========================== DecayTreeTuple v2r7 2009-11-17 ================== - -! 2009-11-17 - Patrick Koppenburg - - src/MCTupleToolPrimaries : new - - src/TupleToolPrimaries : get PV location from OnOfflineTool, not from dva. - This prevented using it in EventTuple. - -! 2009-11-16 - Juan Palacios - - src/TupleToolTagging.cpp - . Remove unused variables. - -! 2009-11-12 - Juan Palacios - - TupleToolGeometry.cpp - - TupleToolGeometry.h - - TupleToolPrimaries.cpp - - TupleToolPrimaries.h - - TupleToolPropertime.cpp - - TupleToolPropertime.h - - TupleToolTagging.cpp - - TupleToolTagging.h - - TupleToolVtxIsoln.cpp - - TupleToolVtxIsoln.h - . Remove use of ContextTool and replace by use of parent DVAlgoritm. - -! 2009-11-06 - Patrick Koppenburg - - Moved implementation of Hlt routing bits reading to HltInterfaces - -! 2009-11-05 - Patrick Koppenburg - - TupleToolTrigger: - . Do not fill Hlt1Global and Hlt2Global anymore (by default). They are confusing. - . Fill Hlt routing bits - - v2r7 - -!========================== DecayTreeTuple v2r6 2009-10-28 ================== - -! 2009-10-21 - Tomasz Skwarnicki - - undo use of HltDecReports to clean up trigger list in TupleToolTISTOS - since cannot be done consistently. Make sure the list does not mutate. - Verbose properties to control tistossing of individual triggers. - -! 2009-10-14 - Juan PALACIOS - - src/TupleToolMCTruth{.h, .cpp} - . Add property IP2MCPAssociatorType to allow to switch implementation of - IParticle2MCAssociator to be used. Default: DaVinciSmartAssociator. - . Remove unnecessary includes. - . Minor clean-up. - -! 2009-10-08 - Patrick Koppenburg - - Number.icpp : avoid triggering of data on demand service when - counting numbers - - v2r6 - -!========================== DecayTreeTuple v2r5 2009-10-01 ================== - -! 2009-09-28 - Patrick Koppenburg for Aurélien Martens - - TupleToolPid : Pi0 ID is 111 - -! 2009-09-11 - Tomasz Skwarnicki - - clean-up the list of individual triggers in TupleToolTISTOS by checking - for their presence in HltDecReport - -! 2009-09-10 - Tomasz Skwarnicki - - adopt TupleToolTISTOS to new way of wild character matching in trigger names - -! 2009-09-06 - Greig Cowan - - Minor bug fixes to TupleToolP2VV to check pointers before dereferencing. - -! 2009-09-04 - Rob Lambert - - TupleToolAngles bugfix. bug 55236 - Angles now calculated with respect to mother. - To revert to old behavior set WRTMother=False - -! 2009-08-20 - Vanya BELYAEV - - - src/TupleToolVtxIsoln.cpp - - fix for new signature of IVertexFit interface - - -! 2009-08-14 - Rob Lambert - - Fixed minor bug in TupleToolGeometry - -! 2009-08-13 - Rob Lambert - - Added vertex position information into TupleToolGeometry - - Added TupleToolTrackIsolation, Fills information about the number - of tracks within a particular cone angle of the track - -! 2009-08-05 - Stephanie Hansmann-Menzemer - ! -- remove filling of track-extra info, according to changes in Track.xml class - -!========================== DecayTreeTuple v2r4 2009-08-07 ================== - -! 2009-07-30 - Patrick Koppenburg - - Added TupleToolTriggerRecoStats that fills some stats about number - of particles - - Outsourced TupleToolRecoStats' Number method to a Number.icpp file - - Increment to v2r4 - -!========================== DecayTreeTuple v2r3p4 2009-07-24 ================ - -! 2009-07-13 - Rob Lambert - - Bugfix: MCDecayTreeTuple - Corrected default tool list - -! 2009-07-07 - Rob Lambert - - BugFix: TupleToolGeneration, savannah bug 52751 - - To clarify situation wrt MC Association, association is performed by: - - TupleToolMCTruth - Most tools will use the associates found here - - TupleToolBackgroundInfo - It would be nice if there was no duplication here - - TupleToolPi0Info - Necessary as the Pi0 assosciation is different - -!========================== DecayTreeTuple v2r3p3 2009-07-03 ================ -! 2009-07-03 - Patrick Koppenburg - - Remove test file. Use $DAVINCISYSROOT/tests/options/DVTestDecayTreeTuple.py - for tests. - -! 2009-07-03 - Juan Palacios - - cmt/requirements - . Use DecFiles v18r* - -!========================== DecayTreeTuple v2r3p2 2009-06-23 ================ -! 2009-06-18 - Patrick Koppenburg - - Remove stupid warning. - - Increment to v2r3p2 - -!======================= DecayTreeTuple v2r3p1 2009-06-12 ===================== -! 2009-06-12 - Patrick Koppenburg - - More debugging - -! 2009-06-11 - Rob Lambert - - Fixed a bug in MCTupleToolKinematic - -!======================== DecayTreeTuple v2r3 2009-06-03 ===================== - -! 2009-06-04 - Rob Lambert - - More documentation in MCTupleToolEventType/MCTupleToolDecayType - -! 2009-06-03 - Rob Lambert - - Major changes. Modified TupleToolMCTruth to take a list - of MCParticleTupleTools. - TupleToolMCTruth is now the only place assosciation occurs - Altered all TupleToolMC to inherit from MCParticleTupleTool - Renamed all things needing MC to MCTupleTool* - Renamed MCTupleToolMCTruth to MCTupleToolKinematic - - -! 2009-06-01 - Patrick Koppenburg - - More debugging - -! 2009-05-22 - Patrick Koppenburg - - MCTupleToolMCTruth.cpp : add oscillation flag - -! 2009-05-15 - Rob Lambert - - TupleToolMCInteractions : Fixed bug which was causing warnings. - bug caused by new genHeader() entries being unsigned ints, and - not handled correctly by the tool. - -! 2009-05-14 - Patrick Koppenburg - - MCTupleToolMCTruth : protect against stable particles - - MCTupleToolReconstructed : ProtoParticles different for various particles. - . Add DLL info and track chi2 - -! 2009-05-13 - Patrick Koppenburg - - (MC)DecayTreeTuple new option RevertToPositiveID : make True default. - -!======================== DecayTreeTuple v2r2 2009-05-11 ===================== - -! 2009-05-08 - Rob Lambert - - Modified TupleToolMCInteractions, added some more functionality - -! 2009-04-29 - Rob Lambert - - Added TupleToolMCInteractions - Allows simple scaling of one set of interactions to another. - -! 2009-04-15 - V. Gligorov - - TupleToolMCTruth.{h,cpp} minor fix to remove compilation warning. - -! 2009-04-09 - V. Gligorov - - TupleToolMCTruth.{h,cpp} - . Use DaVinciSmartAssociator for charged&neutral "stables" - - TupleToolKinematic.{h,cpp} - . Store mass as well as measured mass. - -!======================== DecayTreeTuple v2r1 2009-04-08 ===================== - -! 2009-03-27 - Patrick Koppenburg - - MCDecayTreeTuple : treat oscillated Bs properly. - -! 2009-03-06 - Rob Lambert - - Two new tuple tools. - MCEventType, for searching for Event Types in the MCTruth - MCDecayType for classifying the decay of an MCParticle - See the Sim/SimComponents/EventTypeFinder tool - -! 2009-03-03 - Patrick Koppenburg - - DecayTreeTupleTemplates : fix a crash happening only in VERBOSE - -!======================== DecayTreeTuple v2r0 2009-03-01 ===================== - -! 2009-02-20 - Patrick Koppenburg - - (MC)DecayTreeTuple new option RevertToPositiveID : Revert all PID - if mother ID is positive. - -! 2009-02-19 - Patrick Koppenburg - - (MC)DecayTreeTuple : more debugging. - - TupleToolDecay : fix bug in decay descriptor return - - The main method fillTuple can also be templated - - Interesting addition : store the number of candidates as well. - -> This allows to get weight fo candidates without - reverse-looping. - - Also store event number. Note that this is the number - of times execute has been called. Signification may vary - with place in sequencer. - -! 2009-02-18 - Patrick Koppenburg - - TupleToolDalitz : get svc only once - -! 2009-02-17 - V. Gligorov - - Fixed TupleToolMCTruth for the case of MC2008 data where - the MCParticle has no endVertex. Now returns -9999. for all - vertex coordinates and for the true proper time of the - MCParticle. - -! 2009-02-17 - Patrick Koppenburg - - Added (MC)TupleToolDalitz.{cpp,h,icpp} - -! 2009-02-17 - Patrick Koppenburg - - Protect against absence of decay head - -! 2009-02-11 - Patrick Koppenburg - - Added TupleToolRecoStats and TupleToolSelResults - - EventTuple : Can now save ETC. See examples in DaVinci. - - Increment to v2r0 - -! 2009-02-09 - Patrick Koppenburg - - TupleToolEventInfo : remove inactive options to make ETC - -! 2009-02-03 - Patrick Koppenburg - - TupleToolDecay : trivial fix for gcc4.3 - -! 2009-01-26 - Patrick Koppenburg - - Removed HltSummaryTool from ITupleToolTrigger - -! 2009-01-23 - Patrick Koppenburg - - Added TupleToolAngles, same as MCTupleToolAngles - -! 2009-01-22 - Patrick Koppenburg - - Use the fact that all Hlt1 selections are called XxxDecision to - consider only those (except if AllIntermediateSteps is set to true.) - - src/MCTupleToolAngles.cpp : new tool - -! 2009-01-22 - Patrick Koppenburg - - First working version of MCDecayTreeTuple - . Moved all templated methods to DecayTreeTupleBaseTemplates.icpp - . Added MCDecayTreeTuple to test options - . Fill momentum by default in MCTupleToolMCTruth - - New Tool MCTupleToolReconstructed that links to protoparticles - -! 2009-01-21 - Patrick Koppenburg - - Slight change of strategy: put as much as possible in DecayTreeTupleBase. - All functionality goes there. - - The first release of MCDecayTreeTuple : completely untested, but it compiles. - -! 2009-01-20 - Patrick Koppenburg - ## - # The plan is to get a shared base for DecayTreeTuple and MCDecayTreeTuple. - # The differences are (MC)Particle, (MC)DecayFinder, I(MC)ParticleTools. - # Some can be addressed by templates. - ## - - Extracted class OnePart from DecayTreeTuple. - . Added MCTools - . Moved fill method to DecayTreeTupleBase -> removes dependency on Particle, Tuple and parent - - Split DecayTreeTuple in DecayTreeTuple and Base - . Template as much as possible in DecayTreeTupleBase - . Move the rest to DecayTreeTuple - - Increment to v2r0 - -! 2009-01-19 - Tomasz Skwarnicki - - adopt TupleToolTISTOS to new ways of tistossing L0 trigger - -! 2009-01-19 - Patrick Koppenburg - - Add MCTupleToolP2VV and MCTupleToolMCTruth using MCParticle as input - - call the from TupleToolMCTruth - -! 2009-01-17 - Chris Jones - - Fix OSX/gcc4 warning in TupleToolVtxIsoln - -!======================== DecayTreeTuple v1r10 2009-01-15 ==================== - -! 2008-12-22 - Patrick Koppenburg - - Adapt options to DaVinci v22r0 configurable. Not backward compatible. - -! 2008-12-19 - Patrick Koppenburg - - TupleToolGeometry : More variables. Now IP and FD come in three flavours - . Best PV - . Best PV of mother - . Origin (i.e. mother) vertex - - options/DVTestDecayTreeTuple.py - . Adapt to DaVinci() - -! 2008-12-17 - Patrick Koppenburg - - TupleToolGeometry : Added a method to fill IPs wrt to best PV for - intermediates and finals as well. - -! 2008-12-09 - Patrick Koppenburg - - Move escape method to a function in namespace Decays in DaVinciKernel. - -! 2008-12-06 - Vanya BELYAEV - - minor fix for new particle properties - verison increment to v1r10 - -! 2008-12-01 - Vanya BELYAEV - - src/DecayTreeTuple.cpp - add '#include "boost/lexical_cast.hpp"' line - - cmt/requirements - verison increment to v1r9p1 - -!======================== DecayTreeTuple v1r9 2008-11-27 =================== -! 2008-11-27 - Marco Cattaneo - - Fix compilation on Windows - -! 2008-11-18 - Patrick Koppenburg - - TupleToolTrigger : fill all selections in first. Else the Tuple writing - tends to crash. - -! 2008-11-14 - Tomasz Skwarnicki - - TupleTollTISTOS.cpp adopt to the new ITriggerTisTos tool interface - -! 2008-11-13 - Sean Brisbane - - TupleToolVtxIsoln Bug fixes for composites with granddaughters - -! 2008-11-11 - Sean Brisbane - - TupleToolTrackInfo: Protected against tracks with empty DOF from the track fit - -! 2008-11-11 - Patrick Koppenburg for YasmineTrèsCalme - - TupleToolPID, TupleToolGeometry: Special protection against crashes for pi0 - - TupleToolPi0Info : New tool dedicated to Pi0s - -! 2008-11-09 - V. Gligorov - - TupleToolTISTOS : rewritten to get the triggers in the same order - -! 2008-10-28 - Juan PALACIOS - - src/TupleToolGeometry.cpp, src/TupleToolPrimaries.cpp - . Adapt to new IPhysDesktop::primaryVertices() method - -! 2008-10-16 - Patrick Koppenburg - - Count number of selections in trigger - -! 2008-10-13 - Patrick Koppenburg - - Add a warning when HltDecReports are not here - -!======================== DecayTreeTuple v1r8 2008-10-06 =================== -! 2008-10-06 - Patrick Koppenburg - - Added minimum IP on all PVs in TupleToolGeometry. This is what one actually - cuts on when requiring (MIPCHI2DV(PRIMARY)>4) - - Increment to v1r8 - -!======================== DecayTreeTuple v1r7p1 2008-10-06 =================== - -- 2008-10-02 - Adlene Hicheur - - Fix bug in true angular information ntuple filling (from Conor) - -!========================== DecayTreeTuple v1r7 2008-10-02 =================== -! 2008-10-02 - Tomasz Skwarnicki - - TupleToolTISTOS: proper fix for L0 and Hlt2 new trigger names - -! 2008-09-28 - V. Gligorov - - TupleToolTISTOS : get L0 triggers coprrectly - -- 2008-09-25 - Adlene Hicheur - - Add true angular information in TupleToolMCTruth -! 2008-09-16 - Patrick Koppenburg - - TupleToolTrigger : use HltDecReport - - Test options : Run HltDecReport maker. - - Increment to v1r7 - -!========================== DecayTreeTuple v1r6 2008-09-10 =================== -! 2008-09-10 - Patrick Koppenburg - - Change L0 and HLT again. - -! 2008-09-01 - Patrick Koppenburg - - DVTest...py : Change L0 and Hlt options - -!========================== DecayTreeTuple v1r5 2008-08-05 =================== -! 2008-07-15 - V. Gligorov - - Fixed initialization issues in TupleToolMCHierachy and TupleToolMCBackgroundInfo. - -! 2008-07-11 - Patrick Koppenburg - - TupleTool* : Do not use IGeomDispCalculator but IDistanceCalculator - -! 2008-07-10 - Patrick Koppenburg for Mitesh Patel - - TupleToolTrackInfo : added chi2 probability - -! 2008-07-08 - Stephane Poss - - Fixed use of associators in TupleToolMCHierachy to use the new associators - wrapper. - -! 2008-07-04 - V. Gligorov - - Fixed use of associators in TupleToolMCTruth to use the new associators - wrapper. - -!===================== DecayTreeTuple v1r4 2008-07-07 ============================== -! 2008-07-03 - Patrick Koppenburg for Tom Blake - - P2VV : allow to choose calcualtor tool (Calculator options) and angular basis. - -! 2008-07-01 - Patrick Koppenburg - - New algorithm EventTuple which only fills event-variables - - New tool TupleToolgeneration reading GenHeader - -! 2008-06-27 - Patrick Koppenburg - - Add test file - -! 2008-06-25 - Patrick Koppenburg - - TupleToolTrigger : Use IANNSvc - - Increment to v1r4 - -! 2008-06-23 - V. Gligorov - - Fixed use of associators in TupleToolMCTruth - -! 2008-06-18 - Patrick Koppenburg - - Depend on HltInterfaces - - Increment to v1r4 - -!===================== DecayTreeTuple v1r3 2008-06-09 ======================= - -! 2008-05-04 - V. Gligorov - - TupleToolTrigger.{cpp,h}: Added options to allow users to save only the L0 - information, or only the HLT information. Default is to save all. - -! 2008-04-28 - Patrick Koppenburg for Mitesh Patel - - TupleToolVtxIsolation: new tool for isolation - - Increment to v1r3 - -!===================== DecayTreeTuple v1r2 2008-04-24 ======================= - -! 2008-04-21 - Patrick Koppenburg - - Hlt enums name change - -! 2008-04-09 - V. Gligorov - - TupleToolTISTOS: bugfix, extra documentation. - -! 2008-04-09 - V. Gligorov - - Added TupleToolTISTOS.{h,cpp} to save TISTOS status of each composite particle - - TupleToolGeometry - . Added saving of flight distance to PV for particles - -! 2008-03-27 - Patrick Koppenburg - - DecayTreeTuple: fix an unchecked StatusCode - - Increment to v1r2 - -! 2008-03-17 - Stephane Poss - - TupleToolPrimaries - . Correct documentation (was TupleTooEventInfo documentation) - - TupleToolTagging - . Add tagger type number - - TupleToolMCHierarchy - . Gives MC mother, MC grand mother and MC grand grand mother IDs - for particles, useful as complement to Background Category Tool - - TupleToolTrackInfo - . Track chi2 and track ndof for basic particles - -!===================== DecayTreeTuple v1r1p1 2008-03-06 ===================== - -! 2008-02-20 - Patrick Koppenburg - - Include physical constants - -! 2008-02-12 - Juan PALACIOS - - cmt/requirements - . Increase version to v1r1p1 - - src/TupleToolMCTruth.cpp - . Replace calls to deprecated Particle2MCLinker single-location - constructor to calls to one with vector of locations. - -!===================== DecayTreeTuple v1r1 2008-02-05 ======================= - -! 2008-01-31 - Patrick Koppenburg - - TupleToolTrigger: Implemented. - -! 2008-01-31 - Patrick Koppenburg for Jeremie Borel - - Removed TupleToolMCPid.h and TupleToolMCPid.cpp - -! 2008-01-28 - Patrick Koppenburg - - Bug fix in Truth tool. Thanks to Marco Gersabeck for spotting it. - -! 2008-01-07 - Patrick Koppenburg for Jeremie Borel - - Some changes in interfaces - -! 2007-12-18 - Patrick Koppenburg - - Added a TupleToolP2VV for B->mumuK* and friends - - Removed TupleToolKinetic which is a duplicate of TupleToolKinematic - -! 2007-12-18 - Patrick Koppenburg - - Move interfaces to DaVinciKernel - - Increment to v1r1 - -!===================== DecayTreeTuple v1r0 2007-12-13 ======================= - -! 2007-12-12 - Patrick Koppenburg - - First import. Read doxygen for more information diff --git a/Phys/DecayTreeTuple/python/DecayTreeTuple/Configuration.py b/Phys/DecayTreeTuple/python/DecayTreeTuple/Configuration.py deleted file mode 100644 index 132cf90a3ecae3faeee255d53ef15a43da6b89ab..0000000000000000000000000000000000000000 --- a/Phys/DecayTreeTuple/python/DecayTreeTuple/Configuration.py +++ /dev/null @@ -1,254 +0,0 @@ -############################################################################### -# (c) Copyright 2000-2020 CERN for the benefit of the LHCb Collaboration # -# # -# This software is distributed under the terms of the GNU General Public # -# Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". # -# # -# In applying this licence, CERN does not waive the privileges and immunities # -# granted to it by virtue of its status as an Intergovernmental Organization # -# or submit itself to any jurisdiction. # -############################################################################### -""" -Decorators for DecayTreeTuples, to simplify life somewhat -""" -import string -import re -import six - -from Gaudi.Configuration import * -from Configurables import (DecayTreeTuple, EventTuple, MCDecayTreeTuple, - TupleToolDecay, TupleToolMCTruth) - - -def __splitname__(self, tool): - '''parse the string into the configurable and instance name''' - name = None - if '/' in tool: - name = tool.split('/')[-1] - tool = tool.split('/')[0] - while ('::') in tool: - tool = tool.replace('::', '__') - if name is not None: - while ('::') in name: - name = name.replace('::', '__') - return tool, name - - -def addTupleTool(self, tool, name=None): - """Correctly adds a TupleTool to a DecayTreeTuple or Branch instance, so that the user doesn't need to do the logic themselves - tool can be any TupleTool, either the bare class, instance, string with '::' or string with '__' - name must be a string - examples: - mytuple.addTupleTool('LoKi::Hybrid::TupleTool/LoKi_J') - mytuple.addTupleTool('LoKi::Hybrid::TupleTool') - mytuple.addTupleTool(LoKi__Hybrid__TupleTool) - mytuple.addTupleTool('LoKi__Hybrid__TupleTool') - mytuple.addTupleTool(LoKi__Hybrid__TupleTool,'LoKi_J') - mytuple.addTupleTool(LoKi__Hybrid__TupleTool('Shared_J')) - """ - - ############## Step 1: check you're not doing something stupid ###################### - import operator - if name is not None: - if not isinstance(name, six.string_types): - raise TypeError('expected string for name, got ' + - str(type(name)) + ' instead') - - if not isinstance(tool, six.string_types) and not callable(tool): - if 'getFullName' not in dir(tool): - raise TypeError( - 'tool instance must be a string or configurable, got ' + - str(type(tool)) + ' instead') - mother, atype, aname = tool.splitName() - if aname == atype and tool.__class__.__name__ == aname and tool.isPublic( - ): - raise TypeError( - 'You are trying to add a default public tool-configurable to your ntuple: ' - + tool.getFullName() + - ' This is dangerous so not allowed with addTTool.' + - ' Either add it yourself manually, or, better, supply an instance name' - ) - if not isinstance(tool, six.string_types) and callable(tool): - import GaudiKernel - if type(tool) is not GaudiKernel.ConfigurableMeta.ConfigurableMeta: - raise TypeError("Expected a bare configurable, got a " + - str(type(tool)) + " instead") - #will fail here if you haven't supplied an ntuple! - if 'ToolList' not in dir(self): - raise TypeError( - "You are calling addTupleTool to something which hasn't got the ability to own TupleTools " - + str(type(self))) - - if not isinstance( - tool, - six.string_types) and not callable(tool) and name is not None: - mother, atype, aname = tool.splitName() - if aname != name: - raise NameError( - 'You have supplied an instance, but also specified a different name ' - + atype + ' ' + name + ' ' + aname + - '. Supply the bare class or strings instead if an instance.') - name = None - if isinstance(tool, six.string_types) and name is not None and '/' in tool: - tool, name2 = self.__splitname__(tool) - if name2 != name: - raise NameError('You have supplied two different names for ' + - tool + ' ' + name + ' ' + name2) - name = None - - config = None - if self.ToolList is None: - self.ToolList = [] - - tooltype = '' - toolname = '' - toolinstance = '' - - ################# Step 2: retrieve the configurable for the tool in question ############ - if isinstance(tool, six.string_types): - tool, name2 = self.__splitname__(tool) - if name2 is not None: - name = name2 - #will fail here if the configurable doesn't exist - try: - import Configurables - config = getattr(Configurables, tool) - except ImportError: - raise ImportError('The TupleTool ' + tool + - ' does not exist, check the name and try again') - else: - config = tool - - ################# Step 3: add to Self ################################################### - if name is None: self.addTool(config) - else: self.addTool(config, name) - - ################# Step 4: add to ToolList and return the instance of the configurable ### - instance = None - - if not isinstance(tool, six.string_types) and not callable(config): - #if a configurable was supplied I need to find its name twice ... - mother, tool, name = config.splitName() - if (tool == name): tool = config.__class__.__name__ - - if not isinstance(tool, six.string_types) and callable(config): - #if a bare configurable was supplied I need to change the type to a string.. not easy to do that! - import GaudiKernel - tool = GaudiKernel.ConfigurableMeta.ConfigurableMeta.__repr__(tool) - tool = tool.split("'")[-2] - tool = tool.split(".")[-1] - - instance = getattr(self, name or tool) - - #mother,tool,name=instance.splitName() - - if instance.getFullName() in self.ToolList: - raise AttributeError( - 'The tool ' + instance.getFullName() + - ' was already added to the ToolList, remove and try again') - elif instance.getFullName().split('/')[0] == instance.getFullName().split( - '/')[-1] and instance.getFullName().split('/')[0] in self.ToolList: - raise AttributeError( - 'The tool ' + instance.getFullName().split('/')[-1] + - ' was already added to the ToolList, remove and try again') - #elif (tool==name and name in self.ToolList): - # raise AttributeError, ('The tool '+tool+' was already added to the ToolList, remove and try again') - - if instance.getFullName().split('/')[0] == instance.getFullName().split( - '/')[-1]: - self.ToolList.append(instance.getFullName().split('/')[0]) - else: - self.ToolList.append(instance.getFullName()) - - return instance - - -def addBranches(self, branches): - """Simplified adding of branches a little bit - takes a dictionary of {branch: decay descriptor}, returns a dictionary of {branch: configurable instances}""" - if 'Branches' not in dir(self): - raise TypeError( - "you're trying to add branches to something which doesn't support branching, " - + str(type(self))) - if not isinstance(branches, dict): - raise TypeError("expected a dictionary of branches, got a " + - str(type(branches)) + " instead") - - if self.Branches is None: - self.Branches = {} - - instances = {} - for branch in branches: - #check for whitespace - for char in string.whitespace: - if char in branch: - raise NameError( - "You have tried to add a branch named '" + branch + - "',which contains whitespace. This is not permitted.") - self.Branches[branch] = branches[branch] - self.addTool(TupleToolDecay, branch) - instances[branch] = getattr(self, branch) - - return instances - - -# Bored of typing decay descriptors and adding carat symbols? -# Use some python string template magic to set your decay descriptor -# and define your branches all in one go without excess typing! -def setDescriptorTemplate(self, template): - if 'Decay' not in dir(self): - raise TypeError( - "You're trying to set the decay descriptor of something that doesn't have one, " - + str(type(self))) - if 'Branches' not in dir(self): - raise TypeError( - "You're trying to define branches on something that doesn't support them, " - + str(type(self))) - - from string import Template - # The argument 'template' is a Python string template - # e.g. "[${D}D0 -> ${kaon}K- ${pion}pi+]CC" - # Here ["D", "kaon", "pion"] are the branch names you want - dd = Template(template) - - # This parses the temlate to get the list of branch names, - # i.e. ["D", "kaon", "pion"] - particles = [ - y[1] if len(y[1]) else y[2] for y in dd.pattern.findall(dd.template) - if len(y[1]) or len(y[2]) - ] - - # To form the decay descriptor, we need to mark all the particles - # except for the top-level particle - mapping = {p: '^' if particles.index(p) != 0 else '' for p in particles} - clean = dd.template.replace(' ', '') - for i, o in enumerate(re.findall("(\[\$|\$)", clean)): - if o == '[$': mapping[particles[i]] = '' - - # Make the descriptor - # "[D0 -> ^K- ^pi+]CC" - self.Decay = dd.substitute(mapping) - - # Now make the branches - branches = {} - for p in particles: - # Need a version of the descriptor where particle 'p' is marked but nothing else is. - # Use mapping to ensure the parent particle is never marked. - branches[p] = dd.substitute( - {q: mapping[p] if p == q else '' - for q in particles}) - - # Finally, add the branches to the DecayTreeTuple - return self.addBranches(branches) - - -for config in [ - DecayTreeTuple, EventTuple, MCDecayTreeTuple, TupleToolDecay, - TupleToolMCTruth -]: - config.__splitname__ = __splitname__ - config.addTupleTool = addTupleTool - -for config in [DecayTreeTuple, EventTuple, MCDecayTreeTuple]: - config.addBranches = addBranches - config.setDescriptorTemplate = setDescriptorTemplate diff --git a/Phys/DecayTreeTuple/python/DecayTreeTuple/DecayTreeTupleTruthUtils.py b/Phys/DecayTreeTuple/python/DecayTreeTuple/DecayTreeTupleTruthUtils.py deleted file mode 100644 index 9f033f6244ce402eea6b3fa4c25378c81ebd2eeb..0000000000000000000000000000000000000000 --- a/Phys/DecayTreeTuple/python/DecayTreeTuple/DecayTreeTupleTruthUtils.py +++ /dev/null @@ -1,108 +0,0 @@ -############################################################################### -# (c) Copyright 2000-2021 CERN for the benefit of the LHCb Collaboration # -# # -# This software is distributed under the terms of the GNU General Public # -# Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". # -# # -# In applying this licence, CERN does not waive the privileges and immunities # -# granted to it by virtue of its status as an Intergovernmental Organization # -# or submit itself to any jurisdiction. # -############################################################################### -# Functions to help with truth matching on Tesla output -# NOTE: ONLY WORKS ON XDSTS !!!!! -# Usage: -# -# from DecayTreeTuple import DecayTreeTupleTruthUtils -# seq = DecayTreeTupleTruthUtils.associateSequence("Tesla",False) -# relations = DecayTreeTupleTruthUtils.getRelLoc("Tesla") -# DecayTreeTupleTruthUtils.makeTruth(tuple, relations, [ "MCTupleToolKinematic" , "MCTupleToolHierarchy" , "MCTupleToolPID" ]) -# -# where "Tesla" was the prefix used on the TES output location -# when Tesla was ran -# -# This was moved from the obsolete package TeslaTools by P. Koppenburg -# - - -def getRelLoc(prefix): - protos = prefix + "Protos" - relloc = "/Event/Turbo/Relations/Turbo/" + protos - return relloc - - -def getRelLocs(): - """Relations table locations for 2017-and-beyond Turbo MC.""" - return [ - 'Relations/Turbo/Long/Protos', 'Relations/Turbo/Downstream/Protos', - 'Relations/Turbo/NeutralPP2MC' - ] - - -def getPRRelLoc(): - relloc = "/Event/Turbo/Relations/Rec/ProtoP/Charged" - return relloc - - -def getNeutralRelLoc(): - return "/Event/Turbo/Relations/Turbo/NeutralPP2MC" - - -def associateSequence(prefix, debug): - from Gaudi.Configuration import GaudiSequencer - from Configurables import TrackAssociator, ChargedPP2MC - base = "/Event/Turbo/" - protos = prefix + "Protos" - tracks = prefix + "Tracks" - protocont = base + protos - trackcont = base + tracks - relloc = "Relations/Turbo/" + protos - assoctr = TrackAssociator(prefix + "AssocTr") - assoctr.TracksInContainer = trackcont - assocpp = ChargedPP2MC(prefix + "ProtoAssocPP") - assocpp.RootInTES = base - assocpp.TrackLocations = [trackcont] - assocpp.InputData = [protocont] - assocpp.OutputTable = relloc - if debug == True: - assocpp.OutputLevel = 2 - assoctr.OutputLevel = 2 - # Add it to a selection sequence - seq = GaudiSequencer(prefix + 'SeqP2MC') - seq.Members += [assoctr, assocpp] - return seq - - -def makeTruth(input, rels, toollist, stream="/Event"): - """Configure MC association algorithms on the `input` DecayTreeTuple. - - The `stream` argument defines the TES prefix (`RootInTES`) under which both - the MC particles and the relations tables live. - """ - from Configurables import TupleToolMCTruth, DaVinciSmartAssociator, P2MCPFromProtoP - from Configurables import MCMatchObjP2MCRelator, TupleToolMCBackgroundInfo, BackgroundCategory - MCTruth = TupleToolMCTruth() - MCTruth.ToolList = toollist - - #MCTruth.OutputLevel = 1 - - input.addTool(MCTruth) - input.TupleToolMCTruth.addTool(DaVinciSmartAssociator) - input.TupleToolMCTruth.DaVinciSmartAssociator.RootInTES = stream - input.TupleToolMCTruth.DaVinciSmartAssociator.RedoNeutral = False - input.TupleToolMCTruth.DaVinciSmartAssociator.addTool(P2MCPFromProtoP) - input.TupleToolMCTruth.DaVinciSmartAssociator.P2MCPFromProtoP.Locations = rels - input.TupleToolMCTruth.addTool(MCMatchObjP2MCRelator) - input.TupleToolMCTruth.MCMatchObjP2MCRelator.RelTableLocations = rels - - input.TupleToolMCTruth.DaVinciSmartAssociator.addTool(BackgroundCategory) - input.TupleToolMCTruth.DaVinciSmartAssociator.BackgroundCategory.addTool( - P2MCPFromProtoP) - input.TupleToolMCTruth.DaVinciSmartAssociator.BackgroundCategory.vetoNeutralRedo = True - input.TupleToolMCTruth.DaVinciSmartAssociator.BackgroundCategory.P2MCPFromProtoP.Locations = rels - - input.addTool(TupleToolMCBackgroundInfo) - input.TupleToolMCBackgroundInfo.addTool(BackgroundCategory) - input.TupleToolMCBackgroundInfo.BackgroundCategory.RootInTES = stream - input.TupleToolMCBackgroundInfo.BackgroundCategory.vetoNeutralRedo = True - input.TupleToolMCBackgroundInfo.BackgroundCategory.addTool(P2MCPFromProtoP) - input.TupleToolMCBackgroundInfo.BackgroundCategory.P2MCPFromProtoP.Locations = rels diff --git a/Phys/DecayTreeTuple/python/DecayTreeTuple/__init__.py b/Phys/DecayTreeTuple/python/DecayTreeTuple/__init__.py deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/Phys/DecayTreeTuple/src/TupleToolAllTracks.cpp b/Phys/DecayTreeTuple/src/TupleToolAllTracks.cpp deleted file mode 100644 index e0eb72a8ac7d7ad4a53d1b9dcf2db5ddee587299..0000000000000000000000000000000000000000 --- a/Phys/DecayTreeTuple/src/TupleToolAllTracks.cpp +++ /dev/null @@ -1,781 +0,0 @@ -/*****************************************************************************\ -* (c) Copyright 2000-2018 CERN for the benefit of the LHCb Collaboration * -* * -* This software is distributed under the terms of the GNU General Public * -* Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". * -* * -* In applying this licence, CERN does not waive the privileges and immunities * -* granted to it by virtue of its status as an Intergovernmental Organization * -* or submit itself to any jurisdiction. * -\*****************************************************************************/ - -#include "DecayTreeTupleBase/TupleToolBase.h" -#include "TrackInterfaces/ITrackVertexer.h" - -#include "LoKi/ParticleProperties.h" - -#include "Kernel/GetIDVAlgorithm.h" -#include "Kernel/IDVAlgorithm.h" -#include "Kernel/IDistanceCalculator.h" -#include "Kernel/IPVReFitter.h" -#include "Kernel/IParticleDescendants.h" -#include "Kernel/IParticleTupleTool.h" -#include "Kernel/IVertexFit.h" - -#include "Event/Particle.h" -#include "Event/Vertex.h" - -#include "GaudiAlg/Tuple.h" -#include "GaudiAlg/TupleObj.h" -#include "GaudiKernel/Transform3DTypes.h" - -#include "boost/algorithm/string/replace.hpp" - -using namespace LHCb; - -/** - @brief Isolation tool based on TupleToolVtxIsoln by Mitesh Patel, Patrick Koppenburg, using ideas from -TupleToolSLTools The idea is to add particles, passing a selection that is set by configurable parameters, from given -TES location(s) to a (configurable) target particle in the decay chain and provide information that can be used to -isolate the specific decay, or to simply provide the information needed to study a new exclusive decay chain. - - In a pyton options-file, use e.g.: - @code - from Configurables import TupleToolAllTracks - AllTracks=TupleToolAllTracks("AllTracks") - locations = [] - loations.append('Phys/StdAllNoPIDsPions/Particles') - locations.append("Phys/StdLoosePi02gg/Particles") - locations.append("Phys/StdLooseAllPhotons/Particles") - AllTracks.VertexMode = 0 - AllTracks.ANNPIDCut = 0.3 #ProbNNPID cut on input particle of type PID - AllTracks.GhostProb = 0.5 - AllTracks.Theta = 0.012 #Cut on theta angle (less than) of the added input particle - AllTracks.DeltaPhi = 0.005 #Cut on the difference between phi angles (abs value less than) of target and added -particle AllTracks.NewVertexChi2 = 6 AllTracks.MHi = 7000 AllTracks.ImprovedVertex = 4 #new vertex chi^2 / ndof should -not be worse than 4 AllTracks.PVIPchi2 = 25 AllTracks.CorrectedMass = True AllTracks.InputParticles = locations - AllTracks.Target = Lambda_c+ #has to be defined in decay descriptor - @endcode - then add the tool to the head(!) of your chain. - If a cut is not explicitly given in the config file, no cut will be made. - - The VertexMode option takes values 0,1,2 describing the following scenarios: - - the new particle should be added to the target's mother (e.g. Lb -> (Sc->Lc {pi}) mu nu, where Sc is strongly -decaying to the target and a pion we want to add) - - the new particle should be added directly to the target decay vertex (e.g. {psi(2S)?} -> (J/psi -> mu mu) {pi} -{pi}, where the two pions are directly added to the dimuon vertex, because of the short J/psi lifetime) - - the new particle and the target form a new vertex (e.g. {B?} -> D0 {pi}, where D0 is target, pi is added particle. -Since the D0 decay vertex will be upstream of the B vertex due to it's lifetime, we need to make a new vertex) - - For a preselection of the added particles, one can use e.g. a FilterDesktop: - @code - pionFilter = FilterDesktop("PionFilter") - pionFilter.Code = "(P > 2.*GeV) & (P < 200.*GeV)" \ - "& (PT < 10.*GeV)" \ - "& (TRCHI2DOF < 3)" - SelStdNoPIDsPions = DataOnDemand(Location='Phys/StdAllNoPIDsPions/Particles') - - PifromB = Selection("SelPifromB", - Algorithm = pionFilter, - RequiredSelections = [SelStdNoPIDsPions]) - SeqPifromB = SelectionSequence("SeqPifromB", TopSelection = PifromB) - @endcode - and pass the outputlocation to the tool (if locations is your list of TES locations) - @code - locations.append(SeqPifromB.outputLocation()) - @endcode - - @note - The calculation of the corrected mass and it's error has not been cross-checked with existing algorithms yet. Use at -own risk! - - @date 2015-10-08 - @version v1r1 2016-06-08 : implemented VertexMode & possibility to add particles to head - @author Greg Ciezarek, Marco Fiore, Marian Stahl - -**/ -class TupleToolAllTracks : public TupleToolBase, virtual public IParticleTupleTool { -public: - // Standard constructor - TupleToolAllTracks( const std::string& type, const std::string& name, const IInterface* parent ); - virtual ~TupleToolAllTracks() {} - StatusCode initialize() override; - StatusCode fill( const Particle*, const Particle*, const std::string&, Tuples::Tuple&, - IGeometryInfo const& geometry ) override; - -private: - // Tools - IDVAlgorithm* m_dva; - IDistanceCalculator* m_dist; - const IVertexFit* m_pVertexFit; - IPVReFitter* m_pvReFitter; - std::string m_typeVertexFit; - IParticleDescendants* m_particleDescendants; - - // functions - bool isTrackInDecay( const Particle* particle, const Particle* mother ); - std::pair> getminipchi( const Particle* particle, IGeometryInfo const& geometry ); - std::vector getcorrm( const RecVertex* PV, const Vertex* SV, const Gaudi::LorentzVector& new_mother ); - - // member variables - std::vector m_InputParticles; - std::string m_TargetParticle; - int m_VModedummy; - enum class VMode { ToMother = 0, ToTarget, NewVertex }; - VMode m_VertexMode; - float m_ANNPIDCut; - float m_theta; - float m_deltaphi; - float m_GhostProb; - float m_DLLPIDCut; - float m_VertexChi2Cut; - float m_ipchi2Cut; - float m_PVipchi2Cut; - float m_improvedVertex; - float m_HiMassCut; - unsigned long m_mult; - bool m_addpxpypz; - bool m_addcorrm; -}; - -DECLARE_COMPONENT( TupleToolAllTracks ) - -//============================================================================= -// Standard constructor, initializes variables -//============================================================================= -TupleToolAllTracks::TupleToolAllTracks( const std::string& type, const std::string& name, const IInterface* parent ) - : TupleToolBase( type, name, parent ), m_dva( 0 ), m_dist( 0 ), m_pVertexFit( 0 ), m_particleDescendants( 0 ) { - declareInterface( this ); - - declareProperty( "InputParticles", m_InputParticles = {"Phys/StdAllNoPIDsPions/Particles"}, - "List of input Particles" ); - declareProperty( "Target", m_TargetParticle = "Charm", "Particle to add Particles to" ); - declareProperty( "VertexMode", m_VModedummy = 0, "Decay vertex to which the particle is added" ); - declareProperty( "ANNPID", m_ANNPIDCut = -1.f, - "Cut on ProbNN of added input particle type" ); // NB: if -1, no cut is placed - declareProperty( "Theta", m_theta = -1.f, - "Cut on theta angle of the added input particle" ); // NB: if -1, no cut is placed - declareProperty( "DeltaPhi", m_deltaphi = -1.f, - "Cut on the difference between phi angles of target and added particle" ); // NB: if -1, no cut is - // placed - declareProperty( "GhostProb", m_GhostProb = 1.f, - "Cut on the added input particle ghost probability" ); // NB: if -1, no cut is placed - declareProperty( "DLLPID", m_DLLPIDCut = -9999.f, "Cut on DLL of added input particle type" ); // NB: PIDPi == -PIDK! - declareProperty( "NewVertexChi2", m_VertexChi2Cut = -1.f, - "Cut on Vertex chi2/ndof with added particle" ); // NB: if -1, no cut is placed - declareProperty( "ImprovedVertex", m_improvedVertex = -1.f, - "Cut on Vertex chi2/ndof w added particle - Vertex chi2/ndof w/o added particle" ); // NB: if -1, no - // cut is placed - declareProperty( "IPchi2", m_ipchi2Cut = -1.f, - "Cut on IPchi2 of added particle w.r.t. new vertex" ); // NB: if -1, no cut is placed - declareProperty( "PVIPchi2", m_PVipchi2Cut = -1.f, - "Cut on IPchi2 of added particle w.r.t. closest primary vertex" ); // NB: if -1, no cut is placed - declareProperty( "MHi", m_HiMassCut = -1.f * Gaudi::Units::MeV, - "Cut on invariant mass of Target+input particles" ); // NB: if -1, no cut is placed - declareProperty( "AddMax", m_mult = 200, "Maximal number of added particles" ); - declareProperty( "WritePXPYPZ", m_addpxpypz = false, - "Write PX, PY, PZ of added particle alone and target+particle combination" ); - declareProperty( "CorrectedMass", m_addcorrm = false, - "Write corrected mass and it's error of mother+added particle" ); -} - -StatusCode TupleToolAllTracks::initialize() { - if ( !TupleToolBase::initialize() ) return StatusCode::FAILURE; - - for ( auto location = m_InputParticles.begin(); location != m_InputParticles.end(); location++ ) { - info() << "Adding particles from " << *location << " to a " << m_TargetParticle << endmsg; - if ( !exist( *location ) ) { - if ( msgLevel( MSG::WARNING ) ) - warning() << "No particles at " << *location << "! Skipping this TES location!" << endmsg; - m_InputParticles.erase( location ); - } - } - if ( m_InputParticles.empty() ) return StatusCode::FAILURE; - - // declareProperty can't deal with enums(?) - m_VertexMode = static_cast( m_VModedummy ); - - if ( m_addcorrm && m_VertexMode != VMode::ToMother && msgLevel( MSG::WARNING ) ) - warning() << "Writing the corrected mass is only implemented for VertexMode = 0.\n" - "No corrected mass output will be written to the tuple!" - << endmsg; - - if ( m_improvedVertex != -1 && m_VertexMode == VMode::NewVertex && msgLevel( MSG::WARNING ) ) - warning() << "Requested an improved vertex cut, but running in mode where a new vertex is made.\n" - "This cut will have no effect!" - << endmsg; - - // get tools - m_dva = Gaudi::Utils::getIDVAlgorithm( contextSvc() ); - m_dist = tool( "LoKi::DistanceCalculator", this ); - m_pvReFitter = tool( "LoKi::PVReFitter:PUBLIC", this ); - m_pVertexFit = m_dva->vertexFitter(); - m_particleDescendants = tool( "ParticleDescendants" ); - if ( !m_dva ) return Error( "Couldn't get parent DVAlgorithm", StatusCode::FAILURE ); - if ( !m_dist ) return Error( "Unable to retrieve the IDistanceCalculator tool", StatusCode::FAILURE ); - if ( !m_pvReFitter ) return Error( "Unable to retrieve the LoKi::PVReFitter", StatusCode::FAILURE ); - if ( !m_pVertexFit ) return Error( "Unable to retrieve the IVertexFit tool", StatusCode::FAILURE ); - if ( !m_particleDescendants ) return Error( "Unable to retrieve the ParticleDescendants tool", StatusCode::FAILURE ); - - return StatusCode::SUCCESS; -} - -StatusCode TupleToolAllTracks::fill( const Particle* mother, const Particle* Mother, const std::string& head, - Tuples::Tuple& tuple, IGeometryInfo const& geometry ) { - const std::string prefix = fullName( head ) + "_Added"; - Assert( Mother && mother && m_dist, "This should not happen, you are inside TupleToolAllTracks.cpp :(" ); - - // set test true. It will be the StatusCode that is returned - bool test = true; - const auto pion_mass = 139.57 * Gaudi::Units::MeV; - const auto kaon_mass = 493.68 * Gaudi::Units::MeV; - const auto proton_mass = 938.272 * Gaudi::Units::MeV; - - // declare variables that will be written to the tuple - std::vector h_oldip, h_oldipchi2, h_newip, h_newipchi2, h_minipchi2; - std::vector h_opening, h_fdchi2_new, h_fdchi2_old, h_fd_new, h_fd_old; - std::vector h_vertexchi2_new, h_vertexchi2_old; - std::vector h_trackchi2, h_ghost; - std::vector h_tracktype; - std::vector h_PIDk, h_PIDe, h_PIDmu, h_PIDp, h_ProbNNp, h_ProbNNk, h_ProbNNe, h_ProbNNpi, h_ProbNNmu; - std::vector h_PT, h_ETA, h_PHI, h_THETA, h_DELPHI, h_PX, h_PY, h_PZ; - std::vector h_PID, h_ProbNNPID; - std::vector T_plus_h_M, M_h_CorrM, M_h_Delta_CorrM, T_plus_h_M_pion, M_h_CorrM_pion, M_h_Delta_CorrM_pion; - std::vector T_plus_h_M_proton, M_h_CorrM_proton, M_h_Delta_CorrM_proton, T_plus_h_M_kaon, M_h_CorrM_kaon, - M_h_Delta_CorrM_kaon; - std::vector T_plus_h_PT, T_plus_h_ETA, T_plus_h_PHI, T_plus_h_PX, T_plus_h_PY, T_plus_h_PZ; - std::vector VRFS; - std::vector newvertex_x, newvertex_y, newvertex_z, newPVx, newPVy, newPVz; - std::vector vertexcov_new, pvcov_new; - - Particle* Target = nullptr; - - // check if mother is target - auto mother_is_target = - !m_TargetParticle.compare( "Mother" ) //==0 means strings are equal - || Mother->particleID().abspid() == ( LoKi::Particles::pidFromName( m_TargetParticle ) ).abspid(); - if ( mother_is_target ) { - Target = const_cast( Mother ); - } else { - for ( auto tmpDaughter : Mother->daughtersVector() ) { - // tmp daughter is charm meson or baryon - bool default_charm = - ( ( 400 < tmpDaughter->particleID().abspid() && tmpDaughter->particleID().abspid() < 500 ) | - ( 4000 < tmpDaughter->particleID().abspid() && tmpDaughter->particleID().abspid() < 5000 ) ); - // declare particles in the decay chain as target - if ( !m_TargetParticle.compare( "Charm" ) ) { - if ( default_charm ) - Target = const_cast( tmpDaughter ); - else - continue; - } else if ( tmpDaughter->particleID().abspid() == ( LoKi::Particles::pidFromName( m_TargetParticle ) ).abspid() ) - Target = const_cast( tmpDaughter ); - else - continue; - } - } - - // If no target was found, or the mother is a basic particle, go to the next event - if ( Target == nullptr ) return StatusCode( test ); - if ( Mother->isBasicParticle() ) return StatusCode( test ); - - // get the vertex from the decay described in the DecayDescriptor (old vertex) - // here we have 3 different scenarios: - // - the new particle should be added to the target's mother - // (e.g. Lb -> (Sc->Lc {pi}) mu nu, where Sc is strongly decaying to the target and a pion we want to add) - // - the new particle should be added directly to the target decay vertex - // (e.g. {psi(2S)?} -> (J/psi -> mu mu) {pi} {pi}, where the two pions are directly added to the dimuon vertex, - // because of the short J/psi lifetime) - // - the new particle and the target form a new vertex - // (e.g. {B?} -> D0 {pi}, where D0 is target, pi is added particle. Since the D0 decay vertex will be upstream of - // the B vertex due to it's lifetime, we need to make a new vertex) contrary to the first 2 scenarios, it makes no - // sense to compare vertices in this case, since the vertex didn't exist before. - Vertex v; - Particle::ConstVector parts2Vertex; - if ( m_VertexMode == VMode::ToMother ) - parts2Vertex = Mother->daughtersVector(); - else if ( m_VertexMode == VMode::ToTarget ) - parts2Vertex = Target->daughtersVector(); - else - parts2Vertex.push_back( Target ); - if ( m_VertexMode != VMode::NewVertex ) - m_pVertexFit->fit( v, parts2Vertex, geometry ).ignore( /* AUTOMATICALLY ADDED FOR gaudi/Gaudi!763 */ ); - - // for all input particle locations - for ( auto location : m_InputParticles ) { - // get particles parts - auto parts = get( location ); - if ( msgLevel( MSG::DEBUG ) ) - debug() << "Getting particles from " << location << " with " << ( parts ).size() << " particles" << endmsg; - for ( auto* part : parts ) { - if ( !part ) { - info() << "particle to be added not found" << endmsg; - continue; - } - - auto PID = part->particleID().pid(); - // is basic or not one of the other basic particles that don't have a prototrack... (is there a query if a - // particle has a protoparticle?) - bool proto_exits = - part->isBasicParticle() && std::abs( PID ) != 22 && std::abs( PID ) != 111 && std::abs( PID ) != 221; - - // cut on track types includes Velo, VeloR, Long, Upstream and Downstream tracks - // skip tracks if they are already in the decay chain - if ( proto_exits && ( ( part->proto()->track()->type() < Track::Types::Velo || - part->proto()->track()->type() > Track::Types::Downstream ) || - isTrackInDecay( part, Mother ) ) ) - continue; - - auto pidK = -999.f, pide = -999.f, pidmu = -999.f, pidP = -999.f; - auto probNNe = -1.f, probNNk = -1.f, probNNp = -1.f, probNNpi = -1.f, probNNmu = -1.f, ghprob = -1.f; - auto ProbNNPID = 0, sign_long = 0, tracktype = 0; - - if ( proto_exits ) { - tracktype = part->proto()->track()->type(); - pidK = part->proto()->info( ProtoParticle::CombDLLk, -999 ); - pide = part->proto()->info( ProtoParticle::CombDLLe, -999 ); - pidmu = part->proto()->info( ProtoParticle::CombDLLmu, -999 ); - pidP = part->proto()->info( ProtoParticle::CombDLLp, -999 ); - std::vector probNNs; - probNNpi = part->proto()->info( ProtoParticle::ProbNNpi, -1 ); - probNNs.push_back( probNNpi ); - probNNmu = part->proto()->info( ProtoParticle::ProbNNmu, -1 ); - probNNs.push_back( probNNmu ); - probNNk = part->proto()->info( ProtoParticle::ProbNNk, -1 ); - probNNs.push_back( probNNk ); - probNNp = part->proto()->info( ProtoParticle::ProbNNp, -1 ); - probNNs.push_back( probNNp ); - probNNe = part->proto()->info( ProtoParticle::ProbNNe, -1 ); - probNNs.push_back( probNNe ); - ghprob = part->proto()->track()->ghostProbability(); - // get PID according most probable ProbNN value of the track - auto itelPID = std::distance( probNNs.begin(), std::max_element( probNNs.begin(), probNNs.end() ) ); - part->particleID().pid() < 0 ? sign_long = -1 : sign_long = 1; - auto PIDfromProbNN = [=]() { - if ( itelPID == 0 ) - return sign_long * 211; - else if ( itelPID == 1 ) - return -sign_long * 13; - else if ( itelPID == 2 ) - return sign_long * 321; - else if ( itelPID == 3 ) - return sign_long * 2212; - else if ( itelPID == 4 ) - return -sign_long * 11; - else - return -1; - }; - ProbNNPID = PIDfromProbNN(); - } - // Ghost Probability cut - if ( ghprob > m_GhostProb ) continue; - - // get PID variables for the input particle type and make the desired cut - auto PIDVariables_underPIDHypothesis = [=]() -> std::pair { - if ( std::abs( PID ) == 211 ) - return {probNNpi, -pidK}; - else if ( std::abs( PID ) == 321 ) - return {probNNk, pidK}; - else if ( std::abs( PID ) == 2212 ) - return {probNNp, pidP}; - else if ( std::abs( PID ) == 13 ) - return {probNNmu, pidmu}; - else if ( std::abs( PID ) == 11 ) - return {probNNe, pide}; - else - return {1.f, 100.f}; - }; - if ( PIDVariables_underPIDHypothesis().first < m_ANNPIDCut || - PIDVariables_underPIDHypothesis().second < m_DLLPIDCut ) - continue; - - // calculate the Target+particle mass and make the desired cut - const auto TH = Gaudi::LorentzVector( Target->momentum() + part->momentum() ); - auto Th_mass = TH.M(); - if ( m_HiMassCut != -1 * Gaudi::Units::MeV && Th_mass > m_HiMassCut ) continue; - // Theta angle - float theta_part = part->momentum().theta(); - if ( theta_part < m_theta ) continue; - - float Delta_phi = Target->momentum().phi() - part->momentum().phi(); - if ( std::fabs( Delta_phi ) < m_deltaphi ) continue; - - // PV min ipchi2 - auto PVinfo = getminipchi( part, geometry ); - if ( m_PVipchi2Cut != -1 && PVinfo.first < m_PVipchi2Cut ) continue; - - // Fit a vertex with the added particle - bool VertexRefit = true; - Vertex vtxWithExtraTrack; - Particle* tmp_part = new Particle( *part ); - parts2Vertex.push_back( tmp_part ); - VertexRefit &= m_pVertexFit->fit( vtxWithExtraTrack, parts2Vertex, geometry ); - parts2Vertex.pop_back(); - delete tmp_part; - - double oldip = 0, oldipchi2 = 0, newip, newipchi2, oldfd = 0, oldfdchi2 = 0, newfd, newfdchi2; - // Vertex chi2's - auto newvertchi2 = vtxWithExtraTrack.chi2PerDoF(); - if ( m_VertexChi2Cut != -1 && ( newvertchi2 > m_VertexChi2Cut || newvertchi2 < 0 ) ) continue; - auto oldvertchi2 = m_VertexMode != VMode::NewVertex ? v.chi2PerDoF() : 0.f; - if ( m_improvedVertex != -1 && m_VertexMode != VMode::NewVertex && - ( newvertchi2 > oldvertchi2 + m_improvedVertex || newvertchi2 < 0 ) ) - continue; - // Vertex IP's - m_dist->distance( part, &vtxWithExtraTrack, newip, newipchi2, geometry ) - .ignore( /* AUTOMATICALLY ADDED FOR gaudi/Gaudi!763 */ ); - if ( newipchi2 < 0 || ( m_ipchi2Cut != -1 && newipchi2 > m_ipchi2Cut ) ) continue; - if ( m_VertexMode != VMode::NewVertex ) { - m_dist->distance( part, &v, oldip, oldipchi2, geometry ) - .ignore( /* AUTOMATICALLY ADDED FOR gaudi/Gaudi!763 */ ); - if ( oldipchi2 < 0 ) continue; - } - - h_minipchi2.push_back( PVinfo.first ); - - // FD's - m_dist->distance( PVinfo.second.get(), &vtxWithExtraTrack, newfd, newfdchi2 ) - .ignore( /* AUTOMATICALLY ADDED FOR gaudi/Gaudi!763 */ ); - if ( m_VertexMode != VMode::NewVertex ) - m_dist->distance( PVinfo.second.get(), &v, oldfd, oldfdchi2 ) - .ignore( /* AUTOMATICALLY ADDED FOR gaudi/Gaudi!763 */ ); - - // opening angle between added particle and mother - h_opening.push_back( Mother->momentum().Dot( part->momentum() ) / - sqrt( Mother->momentum().mag2() * part->momentum().mag2() ) ); - - // Masses and corrected masses - std::vector tmp_vec; - ROOT::Math::PxPyPzM4D Tg, h; - Tg.SetPxPyPzE( Target->momentum().px(), Target->momentum().py(), Target->momentum().pz(), - Target->momentum().E() ); - h.SetPxPyPzE( part->momentum().px(), part->momentum().py(), part->momentum().pz(), part->momentum().E() ); - - T_plus_h_M.push_back( Th_mass ); - if ( m_addcorrm && m_VertexMode == VMode::ToMother ) { - tmp_vec = getcorrm( PVinfo.second.get(), &vtxWithExtraTrack, ( Mother->momentum() + part->momentum() ) ); - M_h_CorrM.push_back( tmp_vec.at( 0 ) ); - M_h_Delta_CorrM.push_back( tmp_vec.at( 1 ) ); - } - - h.SetM( pion_mass ); - T_plus_h_M_pion.push_back( - ( static_cast( Tg ) + static_cast( h ) ).M() ); - if ( m_addcorrm && m_VertexMode == VMode::ToMother ) { - tmp_vec = getcorrm( PVinfo.second.get(), &vtxWithExtraTrack, - ( Mother->momentum() + static_cast( h ) ) ); - M_h_CorrM_pion.push_back( tmp_vec.at( 0 ) ); - M_h_Delta_CorrM_pion.push_back( tmp_vec.at( 1 ) ); - } - - h.SetM( kaon_mass ); - T_plus_h_M_kaon.push_back( - ( static_cast( Tg ) + static_cast( h ) ).M() ); - if ( m_addcorrm && m_VertexMode == VMode::ToMother ) { - tmp_vec = getcorrm( PVinfo.second.get(), &vtxWithExtraTrack, - ( Mother->momentum() + static_cast( h ) ) ); - M_h_CorrM_kaon.push_back( tmp_vec.at( 0 ) ); - M_h_Delta_CorrM_kaon.push_back( tmp_vec.at( 1 ) ); - } - - h.SetM( proton_mass ); - T_plus_h_M_proton.push_back( - ( static_cast( Tg ) + static_cast( h ) ).M() ); - if ( m_addcorrm && m_VertexMode == VMode::ToMother ) { - tmp_vec = getcorrm( PVinfo.second.get(), &vtxWithExtraTrack, - ( Mother->momentum() + static_cast( h ) ) ); - M_h_CorrM_proton.push_back( tmp_vec.at( 0 ) ); - M_h_Delta_CorrM_proton.push_back( tmp_vec.at( 1 ) ); - } - - T_plus_h_PT.push_back( TH.pt() ); - T_plus_h_ETA.push_back( TH.eta() ); - T_plus_h_PHI.push_back( TH.phi() ); - if ( m_addpxpypz ) { - T_plus_h_PX.push_back( TH.px() ); - T_plus_h_PY.push_back( TH.py() ); - T_plus_h_PZ.push_back( TH.pz() ); - h_PX.push_back( part->momentum().px() ); - h_PY.push_back( part->momentum().py() ); - h_PZ.push_back( part->momentum().pz() ); - } - h_PT.push_back( part->momentum().pt() ); - h_ETA.push_back( part->momentum().eta() ); - h_PHI.push_back( part->momentum().phi() ); - h_THETA.push_back( theta_part ); - h_DELPHI.push_back( Delta_phi ); - if ( m_VertexMode != VMode::NewVertex ) { - h_oldip.push_back( (float)oldip ); - h_oldipchi2.push_back( (float)oldipchi2 ); - h_fdchi2_old.push_back( (float)oldfdchi2 ); - h_fd_old.push_back( (float)oldfd ); - h_vertexchi2_old.push_back( oldvertchi2 ); - } - h_newip.push_back( (float)newip ); - h_newipchi2.push_back( (float)newipchi2 ); - h_fdchi2_new.push_back( (float)newfd ); - h_fd_new.push_back( (float)newfdchi2 ); - h_vertexchi2_new.push_back( newvertchi2 ); - if ( proto_exits ) { - h_PIDk.push_back( pidK ); - h_PIDe.push_back( pide ); - h_PIDp.push_back( pidP ); - h_PIDmu.push_back( pidmu ); - h_ProbNNpi.push_back( probNNpi ); - h_ProbNNp.push_back( probNNp ); - h_ProbNNe.push_back( probNNe ); - h_ProbNNk.push_back( probNNk ); - h_ProbNNmu.push_back( probNNmu ); - h_ghost.push_back( ghprob ); - h_trackchi2.push_back( part->proto()->track()->chi2PerDoF() ); - h_tracktype.push_back( tracktype ); - h_ProbNNPID.push_back( ProbNNPID ); - } - h_PID.push_back( PID ); - VRFS.push_back( VertexRefit ); - newvertex_x.push_back( vtxWithExtraTrack.position().X() ); - newvertex_y.push_back( vtxWithExtraTrack.position().Y() ); - newvertex_z.push_back( vtxWithExtraTrack.position().Z() ); - newPVx.push_back( PVinfo.second->position().X() ); - newPVy.push_back( PVinfo.second->position().Y() ); - newPVz.push_back( PVinfo.second->position().Z() ); - vertexcov_new.push_back( vtxWithExtraTrack.covMatrix() ); - pvcov_new.push_back( PVinfo.second->covMatrix() ); - } - } - - auto target_tup_name = m_TargetParticle; - boost::algorithm::replace_all( target_tup_name, "*", "St" ); - boost::algorithm::replace_all( target_tup_name, "-", "m" ); - boost::algorithm::replace_all( target_tup_name, "+", "p" ); - boost::algorithm::replace_all( target_tup_name, "~", "bar" ); - boost::algorithm::replace_all( target_tup_name, "'", "prime" ); - boost::algorithm::replace_all( target_tup_name, "(", "_" ); - boost::algorithm::replace_all( target_tup_name, ")", "_" ); - - // If array is bigger than m_mult entries per mother, we are still safe with the StatusCode, because farray will only - // throw a warning and not a bad status code in this case - test &= tuple->farray( prefix + "_" + target_tup_name + "H_M", T_plus_h_M.begin(), T_plus_h_M.end(), - prefix + "_n_Particles", m_mult ); - test &= tuple->farray( prefix + "_" + target_tup_name + "H_M_pion", T_plus_h_M_pion.begin(), T_plus_h_M_pion.end(), - prefix + "_n_Particles", m_mult ); - test &= tuple->farray( prefix + "_" + target_tup_name + "H_M_kaon", T_plus_h_M_kaon.begin(), T_plus_h_M_kaon.end(), - prefix + "_n_Particles", m_mult ); - test &= tuple->farray( prefix + "_" + target_tup_name + "H_M_proton", T_plus_h_M_proton.begin(), - T_plus_h_M_proton.end(), prefix + "_n_Particles", m_mult ); - if ( m_addcorrm && m_VertexMode == VMode::ToMother ) { - test &= tuple->farray( fullName( head ) + "_dauH_CorrM", M_h_CorrM.begin(), M_h_CorrM.end(), - prefix + "_n_Particles", m_mult ); - test &= tuple->farray( fullName( head ) + "_dauH_CorrM_pion", M_h_CorrM_pion.begin(), M_h_CorrM_pion.end(), - prefix + "_n_Particles", m_mult ); - test &= tuple->farray( fullName( head ) + "_dauH_CorrM_kaon", M_h_CorrM_kaon.begin(), M_h_CorrM_kaon.end(), - prefix + "_n_Particles", m_mult ); - test &= tuple->farray( fullName( head ) + "_dauH_CorrM_proton", M_h_CorrM_proton.begin(), M_h_CorrM_proton.end(), - prefix + "_n_Particles", m_mult ); - test &= tuple->farray( fullName( head ) + "_dauH_CorrMErr", M_h_Delta_CorrM.begin(), M_h_Delta_CorrM.end(), - prefix + "_n_Particles", m_mult ); - test &= tuple->farray( fullName( head ) + "_dauH_CorrMErr_pion", M_h_Delta_CorrM_pion.begin(), - M_h_Delta_CorrM_pion.end(), prefix + "_n_Particles", m_mult ); - test &= tuple->farray( fullName( head ) + "_dauH_CorrMErr_kaon", M_h_Delta_CorrM_kaon.begin(), - M_h_Delta_CorrM_kaon.end(), prefix + "_n_Particles", m_mult ); - test &= tuple->farray( fullName( head ) + "_dauH_CorrMErr_proton", M_h_Delta_CorrM_proton.begin(), - M_h_Delta_CorrM_proton.end(), prefix + "_n_Particles", m_mult ); - } - test &= tuple->farray( prefix + "_" + target_tup_name + "H_PT", T_plus_h_PT.begin(), T_plus_h_PT.end(), - prefix + "_n_Particles", m_mult ); - test &= tuple->farray( prefix + "_" + target_tup_name + "H_ETA", T_plus_h_ETA.begin(), T_plus_h_ETA.end(), - prefix + "_n_Particles", m_mult ); - test &= tuple->farray( prefix + "_" + target_tup_name + "H_PHI", T_plus_h_PHI.begin(), T_plus_h_PHI.end(), - prefix + "_n_Particles", m_mult ); - if ( m_addpxpypz ) { - test &= tuple->farray( prefix + "_" + target_tup_name + "H_PX", T_plus_h_PX.begin(), T_plus_h_PX.end(), - prefix + "_n_Particles", m_mult ); - test &= tuple->farray( prefix + "_" + target_tup_name + "H_PY", T_plus_h_PY.begin(), T_plus_h_PY.end(), - prefix + "_n_Particles", m_mult ); - test &= tuple->farray( prefix + "_" + target_tup_name + "H_PZ", T_plus_h_PZ.begin(), T_plus_h_PZ.end(), - prefix + "_n_Particles", m_mult ); - } - if ( m_VertexMode != VMode::NewVertex ) - test &= tuple->farray( prefix + "_" + target_tup_name + "H_FDCHI2_OLD", h_fdchi2_old.begin(), h_fdchi2_old.end(), - prefix + "_n_Particles", m_mult ); - test &= tuple->farray( prefix + "_" + target_tup_name + "H_FDCHI2_NEW", h_fdchi2_new.begin(), h_fdchi2_new.end(), - prefix + "_n_Particles", m_mult ); - if ( m_VertexMode != VMode::NewVertex ) - test &= tuple->farray( prefix + "_" + target_tup_name + "H_FD_OLD", h_fd_old.begin(), h_fd_old.end(), - prefix + "_n_Particles", m_mult ); - test &= tuple->farray( prefix + "_" + target_tup_name + "H_FD_NEW", h_fd_new.begin(), h_fd_new.end(), - prefix + "_n_Particles", m_mult ); - if ( m_VertexMode != VMode::NewVertex ) - test &= tuple->farray( prefix + "_" + target_tup_name + "H_VERTEXCHI2_OLD", h_vertexchi2_old.begin(), - h_vertexchi2_old.end(), prefix + "_n_Particles", m_mult ); - test &= tuple->farray( prefix + "_" + target_tup_name + "H_VERTEXCHI2_NEW", h_vertexchi2_new.begin(), - h_vertexchi2_new.end(), prefix + "_n_Particles", m_mult ); - test &= tuple->farray( prefix + "_" + target_tup_name + "H_VERTEX_X_NEW", newvertex_x.begin(), newvertex_x.end(), - prefix + "_n_Particles", m_mult ); - test &= tuple->farray( prefix + "_" + target_tup_name + "H_VERTEX_Y_NEW", newvertex_y.begin(), newvertex_y.end(), - prefix + "_n_Particles", m_mult ); - test &= tuple->farray( prefix + "_" + target_tup_name + "H_VERTEX_Z_NEW", newvertex_z.begin(), newvertex_z.end(), - prefix + "_n_Particles", m_mult ); - test &= tuple->farray( prefix + "_" + target_tup_name + "H_PV_X_NEW", newPVx.begin(), newPVx.end(), - prefix + "_n_Particles", m_mult ); - test &= tuple->farray( prefix + "_" + target_tup_name + "H_PV_Y_NEW", newPVy.begin(), newPVy.end(), - prefix + "_n_Particles", m_mult ); - test &= tuple->farray( prefix + "_" + target_tup_name + "H_PV_Z_NEW", newPVz.begin(), newPVz.end(), - prefix + "_n_Particles", m_mult ); - - // The following line doesn't work with that type, so write the individual components to the tuple - // test &= tuple -> put ( prefix + "_H_VERTEX_COV_NEW", - // const_cast*>(&h_vertexcov_new)); - std::vector xyz = {"X", "Y", "Z"}; - for ( unsigned int i = 0; i < 3; i++ ) { - for ( unsigned int j = i; j < 3; j++ ) { - std::vector tmp_cov_vec, tmp_pv_cov; - for ( unsigned int k = 0; k < vertexcov_new.size(); k++ ) { - tmp_cov_vec.push_back( vertexcov_new.at( k ).At( i, j ) ); - tmp_pv_cov.push_back( pvcov_new.at( k ).At( i, j ) ); - } - test &= tuple->farray( prefix + "_" + target_tup_name + "H_VERTEX_COV_" + xyz.at( i ) + xyz.at( j ), - tmp_cov_vec.begin(), tmp_cov_vec.end(), prefix + "_n_Particles", m_mult ); - test &= tuple->farray( prefix + "_" + target_tup_name + "H_PV_COV_" + xyz.at( i ) + xyz.at( j ), - tmp_pv_cov.begin(), tmp_pv_cov.end(), prefix + "_n_Particles", m_mult ); - } - } - - test &= tuple->farray( prefix + "_" + target_tup_name + "H_VertexRefitStatus", VRFS.begin(), VRFS.end(), - prefix + "_n_Particles", m_mult ); - if ( m_VertexMode != VMode::NewVertex ) { - test &= tuple->farray( prefix + "_" + target_tup_name + "H_IPCHI2_OLD", h_oldipchi2.begin(), h_oldipchi2.end(), - prefix + "_n_Particles", m_mult ); - test &= tuple->farray( prefix + "_" + target_tup_name + "H_IP_OLD", h_oldip.begin(), h_oldip.end(), - prefix + "_n_Particles", m_mult ); - } - test &= tuple->farray( prefix + "_" + target_tup_name + "H_IPCHI2_NEW", h_newipchi2.begin(), h_newipchi2.end(), - prefix + "_n_Particles", m_mult ); - test &= tuple->farray( prefix + "_" + target_tup_name + "H_IP_NEW", h_newip.begin(), h_newip.end(), - prefix + "_n_Particles", m_mult ); - test &= tuple->farray( prefix + "_" + target_tup_name + "H_MINIPCHI2", h_minipchi2.begin(), h_minipchi2.end(), - prefix + "_n_Particles", m_mult ); - test &= tuple->farray( fullName( head ) + "_H_OPENING", h_opening.begin(), h_opening.end(), prefix + "_n_Particles", - m_mult ); - if ( m_addpxpypz ) { - test &= tuple->farray( prefix + "_H_PX", h_PX.begin(), h_PX.end(), prefix + "_n_Particles", m_mult ); - test &= tuple->farray( prefix + "_H_PY", h_PY.begin(), h_PY.end(), prefix + "_n_Particles", m_mult ); - test &= tuple->farray( prefix + "_H_PZ", h_PZ.begin(), h_PZ.end(), prefix + "_n_Particles", m_mult ); - } - test &= tuple->farray( prefix + "_H_PT", h_PT.begin(), h_PT.end(), prefix + "_n_Particles", m_mult ); - test &= tuple->farray( prefix + "_H_ETA", h_ETA.begin(), h_ETA.end(), prefix + "_n_Particles", m_mult ); - test &= tuple->farray( prefix + "_H_PHI", h_PHI.begin(), h_PHI.end(), prefix + "_n_Particles", m_mult ); - test &= tuple->farray( prefix + "_H_THETA", h_THETA.begin(), h_THETA.end(), prefix + "_n_Particles", m_mult ); - test &= tuple->farray( prefix + "_H_DELTAPHI", h_DELPHI.begin(), h_DELPHI.end(), prefix + "_n_Particles", m_mult ); - test &= tuple->farray( prefix + "_H_PID", h_PID.begin(), h_PID.end(), prefix + "_n_Particles", m_mult ); - test &= - tuple->farray( prefix + "_H_PROBNNPID", h_ProbNNPID.begin(), h_ProbNNPID.end(), prefix + "_n_Tracks", m_mult ); - test &= tuple->farray( prefix + "_H_GHOST", h_ghost.begin(), h_ghost.end(), prefix + "_n_Tracks", m_mult ); - test &= - tuple->farray( prefix + "_H_TRACKCHI2", h_trackchi2.begin(), h_trackchi2.end(), prefix + "_n_Tracks", m_mult ); - test &= - tuple->farray( prefix + "_H_TRACKTYPE", h_tracktype.begin(), h_tracktype.end(), prefix + "_n_Tracks", m_mult ); - test &= tuple->farray( prefix + "_H_PIDe", h_PIDe.begin(), h_PIDe.end(), prefix + "_n_Tracks", m_mult ); - test &= tuple->farray( prefix + "_H_PIDK", h_PIDk.begin(), h_PIDk.end(), prefix + "_n_Tracks", m_mult ); - test &= tuple->farray( prefix + "_H_PIDmu", h_PIDmu.begin(), h_PIDmu.end(), prefix + "_n_Tracks", m_mult ); - test &= tuple->farray( prefix + "_H_PIDp", h_PIDp.begin(), h_PIDp.end(), prefix + "_n_Tracks", m_mult ); - test &= tuple->farray( prefix + "_H_ProbNNpi", h_ProbNNpi.begin(), h_ProbNNpi.end(), prefix + "_n_Tracks", m_mult ); - test &= tuple->farray( prefix + "_H_ProbNNk", h_ProbNNk.begin(), h_ProbNNk.end(), prefix + "_n_Tracks", m_mult ); - test &= tuple->farray( prefix + "_H_ProbNNp", h_ProbNNp.begin(), h_ProbNNp.end(), prefix + "_n_Tracks", m_mult ); - test &= tuple->farray( prefix + "_H_ProbNNe", h_ProbNNe.begin(), h_ProbNNe.end(), prefix + "_n_Tracks", m_mult ); - test &= tuple->farray( prefix + "_H_ProbNNmu", h_ProbNNmu.begin(), h_ProbNNmu.end(), prefix + "_n_Tracks", m_mult ); - - return StatusCode( test ); -} - -//============================================================================= -// Check if the track is already in the decay -//============================================================================= -bool TupleToolAllTracks::isTrackInDecay( const Particle* particle, const Particle* mother ) { - bool isInDecay = false; - // loop over daughters - auto stable_daughters = m_particleDescendants->finalStates( mother ); - if ( stable_daughters.empty() ) return isInDecay; - for ( auto* it : stable_daughters ) { - if ( std::abs( it->particleID().pid() ) != 22 && std::abs( it->particleID().pid() ) != 111 && - std::abs( it->particleID().pid() ) != 221 ) { - if ( it->proto()->track() == particle->proto()->track() ) { - if ( msgLevel( MSG::DEBUG ) ) debug() << "Track is in decay, skipping it" << endmsg; - isInDecay = true; - break; - } - } - } - return isInDecay; -} - -//============================================================================= -// MINIPCHI2 for a Particle | Thanks to Roel for correcting this part of code! -//============================================================================= -std::pair> TupleToolAllTracks::getminipchi( const Particle* particle, - IGeometryInfo const& geometry ) { - float minchi2 = -1.f; - RecVertex* bestPV = nullptr; - auto PV = m_dva->primaryVertices(); - if ( PV.empty() ) return {minchi2, nullptr}; - for ( auto pv : PV ) { - double ip, chi2; - m_dist->distance( particle, pv, ip, chi2, geometry ).ignore( /* AUTOMATICALLY ADDED FOR gaudi/Gaudi!763 */ ); - if ( ( chi2 < minchi2 ) || ( minchi2 < 0.0 ) ) { - RecVertex* newPV = pv->clone(); - // remove particle refit vertex - m_pvReFitter->remove( particle, newPV, geometry ).ignore( /* AUTOMATICALLY ADDED FOR gaudi/Gaudi!763 */ ); - m_dist->distance( particle, newPV, ip, chi2, geometry ).ignore( /* AUTOMATICALLY ADDED FOR gaudi/Gaudi!763 */ ); - minchi2 = chi2; - delete bestPV; - bestPV = newPV; - } - } - return {minchi2, std::unique_ptr( bestPV )}; -} - -//============================================================================= -// Corrected mass for mother + additional particle -//============================================================================= -std::vector TupleToolAllTracks::getcorrm( const RecVertex* PV, const Vertex* SV, - const Gaudi::LorentzVector& new_mother ) { - // Calculations taken from Lb -> p mu nu note: https://cds.cern.ch/record/1694339/files/LHCb-ANA-2014-048.pdf - auto dir = SV->position() - PV->position(); - auto mom = new_mother.Vect(); - auto dmag2 = dir.Mag2(); - auto longit_norm = 0.f; - if ( 0.f != dmag2 ) longit_norm = mom.Dot( dir ) / dmag2; - auto ptprime = mom - dir * longit_norm; - float CorrM = (float)sqrt( pow( new_mother.M(), 2 ) + ptprime.Mag2() ) + sqrt( ptprime.Mag2() ); - - // calculate derivatives of longit_norm - auto dlon_dx = ( 2 * dir.x() * mom.Dot( dir ) - mom.x() * dmag2 ) / ( pow( dmag2, 2 ) ); - auto dlon_dy = ( 2 * dir.y() * mom.Dot( dir ) - mom.y() * dmag2 ) / ( pow( dmag2, 2 ) ); - auto dlon_dz = ( 2 * dir.z() * mom.Dot( dir ) - mom.z() * dmag2 ) / ( pow( dmag2, 2 ) ); - - // derivatives of pt (from Michael Kolpin) - std::vector pt_derivatives; - if ( ptprime.Mag2() == 0.f ) return {CorrM, -1.f}; - pt_derivatives.push_back( ( longit_norm * ptprime.x() - dlon_dx * ( ptprime.x() + ptprime.y() + ptprime.z() ) ) / - sqrt( ptprime.Mag2() ) ); - pt_derivatives.push_back( ( longit_norm * ptprime.y() - dlon_dy * ( ptprime.x() + ptprime.y() + ptprime.z() ) ) / - sqrt( ptprime.Mag2() ) ); - pt_derivatives.push_back( ( longit_norm * ptprime.z() - dlon_dz * ( ptprime.x() + ptprime.y() + ptprime.z() ) ) / - sqrt( ptprime.Mag2() ) ); - - // uncertainty of pt - auto PV_cov = PV->covMatrix(); - auto SV_cov = SV->covMatrix(); - auto delta_ptprime2 = 0.f; - for ( auto i = 0; i < 3; i++ ) { - for ( auto j = 0; j < 3; j++ ) { - delta_ptprime2 += pt_derivatives.at( i ) * pt_derivatives.at( j ) * ( PV_cov.At( i, j ) + SV_cov.At( i, j ) ); - if ( i != j ) delta_ptprime2 *= 2; - } - } - // uncertainty on m_corr - float delta_Corr_M = (float)( sqrt( ptprime.Mag2() ) / sqrt( pow( new_mother.M(), 2 ) + ptprime.Mag2() ) + 1.0 ) * - sqrt( delta_ptprime2 ); - - return {CorrM, delta_Corr_M}; -} diff --git a/Phys/DecayTreeTuple/src/TupleToolAngles.cpp b/Phys/DecayTreeTuple/src/TupleToolAngles.cpp deleted file mode 100644 index ed95efbf41e811b0a2cb7d13a7ff323e1761cd13..0000000000000000000000000000000000000000 --- a/Phys/DecayTreeTuple/src/TupleToolAngles.cpp +++ /dev/null @@ -1,124 +0,0 @@ -/*****************************************************************************\ -* (c) Copyright 2000-2018 CERN for the benefit of the LHCb Collaboration * -* * -* This software is distributed under the terms of the GNU General Public * -* Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". * -* * -* In applying this licence, CERN does not waive the privileges and immunities * -* granted to it by virtue of its status as an Intergovernmental Organization * -* or submit itself to any jurisdiction. * -\*****************************************************************************/ - -#include "DecayTreeTupleBase/TupleToolBase.h" - -#include "Event/Particle.h" - -#include "Kernel/IParticleTupleTool.h" // Interface - -#include "GaudiAlg/Tuple.h" -#include "GaudiAlg/TupleObj.h" -#include "GaudiKernel/PhysicalConstants.h" -#include "GaudiKernel/Vector3DTypes.h" -#include "GaudiKernel/Vector4DTypes.h" - -#include "Math/Boost.h" - -#include "gsl/gsl_sys.h" - -/** - * Fill MC Particle with decay angle in mother frame - * - * - head_CosTheta : angle in mother's frame - * - if WRTMother is false, will calculate angle in frame of top of tree - * - * \sa MCTupleToolAngles, DecayTreeTuple, MCDecayTreeTuple - * - * @author Patrick Koppenburg - * @date 2009-01-21 - * @author R. Lambert - * @date 2009-09-04 - */ - -class TupleToolAngles : public TupleToolBase, virtual public IParticleTupleTool { - -public: - TupleToolAngles( const std::string& type, const std::string& name, const IInterface* parent ); - StatusCode fill( const LHCb::Particle*, const LHCb::Particle*, const std::string&, Tuples::Tuple&, - IGeometryInfo const& ) override; - -private: - inline double cosTheta( const Gaudi::LorentzVector& mother, const Gaudi::LorentzVector& mcp ) { - ROOT::Math::Boost boost( mother.BoostToCM() ); - const Gaudi::XYZVector boostedParticle = ( boost( mcp ) ).Vect().unit(); - const Gaudi::XYZVector boostedMother = mother.Vect().unit(); - double cosT = boostedParticle.Dot( boostedMother ); - if ( msgLevel( MSG::VERBOSE ) ) - verbose() << mother << " " << mcp << " " << boostedMother << " " << boostedParticle << " " << cosT << endmsg; - return cosT; - } - - const LHCb::Particle* findMother( const LHCb::Particle* top, const LHCb::Particle* P ) const; - - bool m_wrtMother; -}; - -using namespace LHCb; - -// Declaration of the Tool Factory -DECLARE_COMPONENT( TupleToolAngles ) - -//============================================================================= -// Standard constructor, initializes variables -//============================================================================= -TupleToolAngles::TupleToolAngles( const std::string& type, const std::string& name, const IInterface* parent ) - : TupleToolBase( type, name, parent ), m_wrtMother( 0 ) { - declareInterface( this ); - declareProperty( "WRTMother", m_wrtMother = true, "Turn false to fill angles with respect to top of tree" ); -} - -//============================================================================= -// Fill -//============================================================================= -StatusCode TupleToolAngles::fill( const LHCb::Particle* top, const LHCb::Particle* part, const std::string& head, - Tuples::Tuple& tuple, IGeometryInfo const& ) { - const std::string prefix = fullName( head ); - - bool test = true; - const LHCb::Particle* mother = top; - if ( m_wrtMother ) mother = findMother( top, part ); - if ( 0 == part || 0 == mother || part == mother ) return StatusCode::SUCCESS; - double cosT = cosTheta( mother->momentum(), part->momentum() ); - // fill the tuple: - test &= tuple->column( prefix + "_CosTheta", cosT ); - if ( isVerbose() ) test &= tuple->column( prefix + "_Theta", acos( cosT ) ); - if ( msgLevel( MSG::DEBUG ) ) - debug() << mother->particleID().pid() << " " << mother->momentum() << " " << part->particleID().pid() << " " - << part->momentum() << endmsg; - return StatusCode( test ); -} -//============================================================================= -// Fill -//============================================================================= - -const LHCb::Particle* TupleToolAngles::findMother( const LHCb::Particle* top, const Particle* P ) const { - if ( top == P || top->isBasicParticle() ) return 0; - - const SmartRefVector& dau = top->daughters(); - if ( dau.empty() ) return 0; - - SmartRefVector::const_iterator it; - for ( it = dau.begin(); dau.end() != it; ++it ) { - if ( P == *it ) { // I found the daughter - return top; - } - } - - // vertex not yet found, get deeper in the decay: - for ( it = dau.begin(); dau.end() != it; ++it ) { - if ( P != *it && !( *it )->isBasicParticle() ) { - const LHCb::Particle* tm = findMother( *it, P ); - if ( tm ) return tm; - } - } - return 0; -} diff --git a/Phys/DecayTreeTuple/src/TupleToolBeamSpot.cpp b/Phys/DecayTreeTuple/src/TupleToolBeamSpot.cpp deleted file mode 100644 index 1231c05853b0d5004e7354b4cd134b8252305420..0000000000000000000000000000000000000000 --- a/Phys/DecayTreeTuple/src/TupleToolBeamSpot.cpp +++ /dev/null @@ -1,60 +0,0 @@ -/*****************************************************************************\ -* (c) Copyright 2000-2018 CERN for the benefit of the LHCb Collaboration * -* * -* This software is distributed under the terms of the GNU General Public * -* Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". * -* * -* In applying this licence, CERN does not waive the privileges and immunities * -* granted to it by virtue of its status as an Intergovernmental Organization * -* or submit itself to any jurisdiction. * -\*****************************************************************************/ -//----------------------------------------------------------------------------- -// Implementation for class: TupleToolBeamSpot -// -// 2015-07-10 : TupleToolBeamSpot -//----------------------------------------------------------------------------- - -#include "TupleToolBeamSpot.h" - -// Declaration of the Algorithm Factory -DECLARE_COMPONENT( TupleToolBeamSpot ) - -TupleToolBeamSpot::TupleToolBeamSpot( const std::string& type, const std::string& name, const IInterface* parent ) - : TupleToolBase( type, name, parent ) { - declareInterface( this ); - - declareProperty( "Bound", m_bound = 10., "Bound to pass to beamspot constructor" ); -} - -TupleToolBeamSpot::~TupleToolBeamSpot() {} - -StatusCode TupleToolBeamSpot::initialize() { - StatusCode sc = TupleToolBase::initialize(); - if ( !sc.isSuccess() ) { return sc; } - - if ( msgLevel( MSG::DEBUG ) ) { debug() << "=> Initialize" << endmsg; } - - svc( "LoKiSvc", true ); - - m_beamspot = std::unique_ptr{new LoKi::BeamSpot( m_bound )}; - if ( !m_beamspot ) { return Error( "Could not get the beamspot" ); } - - return StatusCode::SUCCESS; -} - -StatusCode TupleToolBeamSpot::finalize() { - if ( msgLevel( MSG::DEBUG ) ) { debug() << "=> Finalize" << endmsg; } - - m_beamspot.reset(); - - return TupleToolBase::finalize(); -} - -StatusCode TupleToolBeamSpot::fill( Tuples::Tuple& tuple ) { - std::string prefix = fullName(); - - tuple->column( prefix + "BeamX", m_beamspot->x() ).ignore( /* AUTOMATICALLY ADDED FOR gaudi/Gaudi!763 */ ); - tuple->column( prefix + "BeamY", m_beamspot->y() ).ignore( /* AUTOMATICALLY ADDED FOR gaudi/Gaudi!763 */ ); - - return StatusCode::SUCCESS; -} diff --git a/Phys/DecayTreeTuple/src/TupleToolBeamSpot.h b/Phys/DecayTreeTuple/src/TupleToolBeamSpot.h deleted file mode 100644 index 8016090adc5317f1d838295307862e53ac29cac2..0000000000000000000000000000000000000000 --- a/Phys/DecayTreeTuple/src/TupleToolBeamSpot.h +++ /dev/null @@ -1,48 +0,0 @@ -/*****************************************************************************\ -* (c) Copyright 2000-2018 CERN for the benefit of the LHCb Collaboration * -* * -* This software is distributed under the terms of the GNU General Public * -* Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". * -* * -* In applying this licence, CERN does not waive the privileges and immunities * -* granted to it by virtue of its status as an Intergovernmental Organization * -* or submit itself to any jurisdiction. * -\*****************************************************************************/ -// Include files - -// from LHCb -#include "DecayTreeTupleBase/TupleToolBase.h" -#include "Kernel/IEventTupleTool.h" - -#include "LoKi/BeamSpot.h" - -/** @class TupleToolBeamSpot DecayTreeTuple/TupleToolBeamSpot.cpp - * - * Add beamspot position (from the Velo resolver position) - * - * Tuple columns: - * - BeamX - * - BeamY - * - * @see LoKi::BeamSpot - * - * @author Pieter David - * @date 2015-07-10 - */ -class TupleToolBeamSpot : public TupleToolBase, virtual public IEventTupleTool { -public: - /// Standard constructor - TupleToolBeamSpot( const std::string& type, const std::string& name, const IInterface* parent ); - - virtual ~TupleToolBeamSpot(); ///< Destructor - - StatusCode initialize() override; - StatusCode finalize() override; - - // Interface methods - StatusCode fill( Tuples::Tuple& tuple ) override; - -private: - double m_bound; - std::unique_ptr m_beamspot; -}; diff --git a/Phys/DecayTreeTuple/src/TupleToolBremInfo.cpp b/Phys/DecayTreeTuple/src/TupleToolBremInfo.cpp deleted file mode 100644 index 224dd0dac5a95050e8b153dc98461b67aabd16da..0000000000000000000000000000000000000000 --- a/Phys/DecayTreeTuple/src/TupleToolBremInfo.cpp +++ /dev/null @@ -1,172 +0,0 @@ -/*****************************************************************************\ -* (c) Copyright 2000-2018 CERN for the benefit of the LHCb Collaboration * -* * -* This software is distributed under the terms of the GNU General Public * -* Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". * -* * -* In applying this licence, CERN does not waive the privileges and immunities * -* granted to it by virtue of its status as an Intergovernmental Organization * -* or submit itself to any jurisdiction. * -\*****************************************************************************/ - -#include "DecayTreeTupleBase/TupleToolBase.h" - -#include "CaloUtils/CaloMomentum.h" -#include "Event/Particle.h" - -#include "Kernel/IBremAdder.h" -#include "Kernel/IParticlePropertySvc.h" -#include "Kernel/IParticleTupleTool.h" -#include "Kernel/ParticleProperty.h" - -#include "GaudiAlg/Tuple.h" -#include "GaudiAlg/TupleObj.h" -#include "GaudiKernel/IRegistry.h" - -#include - -#include - -class TupleToolBremInfo : public TupleToolBase, virtual public IParticleTupleTool { - -public: - TupleToolBremInfo( const std::string& type, const std::string& name, const IInterface* parent ); - StatusCode initialize() override; - StatusCode fill( const LHCb::Particle*, const LHCb::Particle*, const std::string&, Tuples::Tuple&, - IGeometryInfo const& geometry ) override; - -private: - const LHCb::ParticleProperty* property( const LHCb::ParticleID pid ) { - return ( m_ppsvc ) ? m_ppsvc->find( pid ) : NULL; - }; - LHCb::IParticlePropertySvc* m_ppsvc; - IBremAdder* m_adder; - std::vector m_parts; - std::vector m_pids; - bool m_dst; -}; - -using namespace Gaudi; -using namespace LHCb; - -TupleToolBremInfo::TupleToolBremInfo( const std::string& type, const std::string& name, const IInterface* parent ) - : TupleToolBase( type, name, parent ), m_parts(), m_pids() { - declareInterface( this ); - declareProperty( "Particle", m_parts ); - declareProperty( "fullDST", m_dst = true ); // to switch off/on information not available on microDST - m_parts.push_back( "e+" ); - m_parts.push_back( "gamma" ); // for gamma->e+e- -} - -StatusCode TupleToolBremInfo::initialize() { - const StatusCode sc = TupleToolBase::initialize(); - if ( sc.isFailure() ) return sc; - - m_adder = tool( "BremAdder", "BremAdder", this ); - - m_ppsvc = svc( "LHCb::ParticlePropertySvc", true ); - if ( !m_parts.empty() ) { - for ( std::vector::const_iterator p = m_parts.begin(); m_parts.end() != p; ++p ) { - const LHCb::ParticleProperty* pp = m_ppsvc->find( *p ); - if ( pp ) { m_pids.push_back( pp->pdgID().abspid() ); } - } - } - - return sc; -} - -StatusCode TupleToolBremInfo::fill( const Particle*, const Particle* P, const std::string& head, Tuples::Tuple& tuple, - IGeometryInfo const& geometry ) { - if ( !P ) return StatusCode::SUCCESS; - - const std::string prefix = fullName( head ); - - bool ok = false; - for ( std::vector::const_iterator pid = m_pids.begin(); m_pids.end() != pid; ++pid ) { - if ( P->particleID().abspid() == *pid ) { - ok = true; - break; - } - } - if ( !ok ) return StatusCode::SUCCESS; - - bool filltuple = true; - if ( P->isBasicParticle() && P->proto() != NULL && P->proto()->track() != NULL ) { - LHCb::CaloMomentum brem = m_adder->bremMomentum( P, geometry ); - if ( msgLevel( MSG::VERBOSE ) ) { // https://its.cern.ch/jira/browse/LHCBPS-598 - verbose() << "Multi : " << brem.multiplicity() << endmsg; - verbose() << " Brem P : " << brem.momentum() << endmsg; - verbose() << " Origin : " << brem.referencePoint() << endmsg; - } - - // brem info from the particle (from creation) - filltuple &= tuple->column( prefix + "_HasBremAdded", P->info( LHCb::Particle::HasBremAdded, 0. ) > 0 ); - filltuple &= tuple->column( prefix + "_BremMultiplicity", - P->info( LHCb::Particle::HasBremAdded, 0. ) ); // replace the multiplicity() method that - // need fullDST - // brem info from rerunning the BremAdder, looking at the photons - // This is not correct when running on an mDST - you look at a subset of the total photons in the event. - if ( (int)P->info( LHCb::Particle::HasBremAdded, 0. ) != (int)brem.multiplicity() && m_dst ) - Warning( "TupleToolBremInfo requires fullDST - BremP and BremOrigin might not be reliable (Multiplicity is OK)", - StatusCode::SUCCESS, 5 ) - .ignore( /* AUTOMATICALLY ADDED FOR gaudi/Gaudi!763 */ ); - if ( m_dst ) filltuple &= tuple->column( prefix + "_BremP", brem.momentum() ); // need fullDST - if ( m_dst ) filltuple &= tuple->column( prefix + "_BremOrigin", brem.referencePoint() ); // need fullDST - - } else { - // e.g. diElectron - LHCb::Particle::ConstVector daughters = P->daughtersVector(); - if ( daughters.size() != 2 ) return StatusCode( filltuple ); - - const LHCb::Particle* p1 = NULL; - const LHCb::Particle* p2 = NULL; - int k = 0; - for ( LHCb::Particle::ConstVector::const_iterator itmp = daughters.begin(); itmp != daughters.end(); itmp++ ) { - const LHCb::Particle* p = *itmp; - if ( p1 == NULL ) - p1 = p; - else - p2 = p; - for ( std::vector::const_iterator pid = m_pids.begin(); m_pids.end() != pid; ++pid ) { - if ( p->particleID().abspid() == *pid ) { - k++; - break; - } - } - } - if ( k != 2 || p1 == NULL || p2 == NULL ) return StatusCode( filltuple ); - // OK let's evaluate the brem for (p1,p2) system - - double mult = p1->info( LHCb::Particle::HasBremAdded, 0. ) + p2->info( LHCb::Particle::HasBremAdded, 0. ); - const std::pair brems = m_adder->bremMomenta( p1, p2, geometry ); - LHCb::CaloMomentum b1 = brems.first; - LHCb::CaloMomentum b2 = brems.second; - filltuple &= tuple->column( prefix + "_DiEBremMultiplicity", mult ); - if ( m_dst ) filltuple &= tuple->column( prefix + "_DiEBremP", b1.momentum() + b2.momentum() ); - std::string name1 = property( p1->particleID() )->name(); - std::string name2 = property( p2->particleID() )->name(); - boost::replace_all( name1, "+", "plus" ); - boost::replace_all( name1, "-", "minus" ); - boost::replace_all( name2, "+", "plus" ); - boost::replace_all( name2, "-", "minus" ); - filltuple &= - tuple->column( prefix + "_" + name1 + "_DiEBremMultiplicity", p1->info( LHCb::Particle::HasBremAdded, 0. ) ); - if ( m_dst ) filltuple &= tuple->column( prefix + "_" + name1 + "_DiEBremP", b1.momentum() ); - filltuple &= - tuple->column( prefix + "_" + name2 + "_DiEBremMultiplicity", p2->info( LHCb::Particle::HasBremAdded, 0. ) ); - if ( m_dst ) filltuple &= tuple->column( prefix + "_" + name2 + "_DiEBremP", b2.momentum() ); - - // standalone evaluation - if ( m_dst ) { - LHCb::CaloMomentum sb1 = m_adder->bremMomentum( p1, geometry ); - LHCb::CaloMomentum sb2 = m_adder->bremMomentum( p2, geometry ); - filltuple &= tuple->column( prefix + "_" + name1 + "_StandaloneBremMultiplicity", sb1.multiplicity() ); - filltuple &= tuple->column( prefix + "_" + name2 + "_StandaloneBremMultiplicity", sb2.multiplicity() ); - } - } - - return StatusCode( filltuple ); -} - -// Declaration of the Tool Factory -DECLARE_COMPONENT( TupleToolBremInfo ) diff --git a/Phys/DecayTreeTuple/src/TupleToolCaloDigits.cpp b/Phys/DecayTreeTuple/src/TupleToolCaloDigits.cpp deleted file mode 100644 index 0e7959c2b8cb43937f2cbae93ef6aa2cc51bc5f3..0000000000000000000000000000000000000000 --- a/Phys/DecayTreeTuple/src/TupleToolCaloDigits.cpp +++ /dev/null @@ -1,162 +0,0 @@ -/*****************************************************************************\ -* (c) Copyright 2000-2018 CERN for the benefit of the LHCb Collaboration * -* * -* This software is distributed under the terms of the GNU General Public * -* Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". * -* * -* In applying this licence, CERN does not waive the privileges and immunities * -* granted to it by virtue of its status as an Intergovernmental Organization * -* or submit itself to any jurisdiction. * -\*****************************************************************************/ -// Include files - -// local -#include "TupleToolCaloDigits.h" - -#include "GaudiAlg/ITupleTool.h" -#include "GaudiAlg/Tuple.h" - -#include "Event/CaloDigit.h" - -#include "GaudiKernel/IRegistry.h" // IOpaqueAddress - -#include "CaloDet/DeCalorimeter.h" - -//----------------------------------------------------------------------------- -// Implementation file for class : TupleToolCaloDigits -// -// 2015-08-05 Albert Bursche -//----------------------------------------------------------------------------- - -// Declaration of the Tool Factory -DECLARE_COMPONENT( TupleToolCaloDigits ) - -//============================================================================= -// Standard constructor, initializes variables -//============================================================================= -TupleToolCaloDigits::TupleToolCaloDigits( const std::string& type, const std::string& name, const IInterface* parent ) - : TupleToolBase( type, name, parent ) { - declareInterface( this ); - declareProperty( "DigitLocation", m_DigitLocation ); - declareProperty( "CaloName", m_CaloName ); - declareProperty( "CaloLocation", m_CaloLocation ); - declareProperty( "MaxDigits", m_maxSize ); - declareProperty( "AutoConfigure", m_auto_configure ); -} -//============================================================================= - -StatusCode TupleToolCaloDigits::initialize() { - if ( m_auto_configure ) { - if ( m_CaloName.compare( "Spd" ) == 0 ) { - m_CaloLocation = DeCalorimeterLocation::Spd; - m_DigitLocation = LHCb::CaloDigitLocation::Spd; - return StatusCode::SUCCESS; - } - if ( m_CaloName.compare( "Prs" ) == 0 ) { - m_CaloLocation = DeCalorimeterLocation::Prs; - m_DigitLocation = LHCb::CaloDigitLocation::Prs; - return StatusCode::SUCCESS; - } - if ( m_CaloName.compare( "Ecal" ) == 0 ) { - m_CaloLocation = DeCalorimeterLocation::Ecal; - m_DigitLocation = LHCb::CaloDigitLocation::Ecal; - return StatusCode::SUCCESS; - } - if ( m_CaloName.compare( "Hcal" ) == 0 ) { - m_CaloLocation = DeCalorimeterLocation::Hcal; - m_DigitLocation = LHCb::CaloDigitLocation::Hcal; - return StatusCode::SUCCESS; - } - // Feel free to add more locations from Event/CaloDigit.h - fatal() << "Invalid CaloName. Mus be one of Spd,Prs,Ecal,Hcal if AutoConfigure is used (i.e. true)" << endmsg; - return StatusCode::FAILURE; - } - return StatusCode::SUCCESS; -} -StatusCode TupleToolCaloDigits::finalize() { return StatusCode::SUCCESS; } -StatusCode TupleToolCaloDigits::fill( Tuples::Tuple& tuple ) { - const std::string prefix = fullName(); - LHCb::CaloDigits* digits = getIfExists( m_DigitLocation ); - if ( !digits ) return StatusCode::SUCCESS; - DeCalorimeter* calo = getDet( m_CaloLocation ); - for ( const auto& digit : *digits ) { - const LHCb::CaloCellID cellID = digit->cellID(); - m_index.push_back( cellID.index() ); - m_calo.push_back( cellID.calo() ); - m_area.push_back( cellID.area() ); - m_row.push_back( cellID.row() ); - m_column.push_back( cellID.col() ); - - auto p = calo->cellCenter( cellID ); - m_xs.push_back( p.X() ); - m_ys.push_back( p.Y() ); - m_zs.push_back( p.Z() ); - m_es.push_back( digit->e() ); - double sinTheta = sqrt( p.X() * p.X() + p.Y() * p.Y() ) / sqrt( p.X() * p.X() + p.Y() * p.Y() + p.Z() * p.Z() ); - m_ets.push_back( digit->e() * sinTheta ); - if ( msgLevel( MSG::DEBUG ) ) debug() << cellID << " has an energy of " << m_es.back() << " \n"; - } - if ( msgLevel( MSG::DEBUG ) ) - debug() << " saved " << m_index.size() << " digits to n tuple " + m_CaloName + "Digit." << endmsg; - if ( m_verbose ) { - tuple - ->farray( m_extraName + m_CaloName + "DigitIndex", std::begin( m_index ), std::end( m_index ), - m_extraName + m_CaloName + "DigitNi", m_maxSize ) - .ignore( /* AUTOMATICALLY ADDED FOR gaudi/Gaudi!763 */ ); - tuple - ->farray( m_extraName + m_CaloName + "DigitCalo", std::begin( m_calo ), std::end( m_calo ), - m_extraName + m_CaloName + "DigitNc", m_maxSize ) - .ignore( /* AUTOMATICALLY ADDED FOR gaudi/Gaudi!763 */ ); - tuple - ->farray( m_extraName + m_CaloName + "DigitArea", std::begin( m_area ), std::end( m_area ), - m_extraName + m_CaloName + "DigitNa", m_maxSize ) - .ignore( /* AUTOMATICALLY ADDED FOR gaudi/Gaudi!763 */ ); - tuple - ->farray( m_extraName + m_CaloName + "DigitRow", std::begin( m_row ), std::end( m_row ), - m_extraName + m_CaloName + "DigitNr", m_maxSize ) - .ignore( /* AUTOMATICALLY ADDED FOR gaudi/Gaudi!763 */ ); - tuple - ->farray( m_extraName + m_CaloName + "DigitColumn", std::begin( m_column ), std::end( m_column ), - m_extraName + m_CaloName + "DigitNco", m_maxSize ) - .ignore( /* AUTOMATICALLY ADDED FOR gaudi/Gaudi!763 */ ); - tuple - ->farray( m_extraName + m_CaloName + "Digit_X", std::begin( m_xs ), std::end( m_xs ), - m_extraName + m_CaloName + "DigitNx", m_maxSize ) - .ignore( /* AUTOMATICALLY ADDED FOR gaudi/Gaudi!763 */ ); - tuple - ->farray( m_extraName + m_CaloName + "Digit_Y", std::begin( m_ys ), std::end( m_ys ), - m_extraName + m_CaloName + "DigitNy", m_maxSize ) - .ignore( /* AUTOMATICALLY ADDED FOR gaudi/Gaudi!763 */ ); - tuple - ->farray( m_extraName + m_CaloName + "Digit_Z", std::begin( m_zs ), std::end( m_zs ), - m_extraName + m_CaloName + "DigitNz", m_maxSize ) - .ignore( /* AUTOMATICALLY ADDED FOR gaudi/Gaudi!763 */ ); - tuple - ->farray( m_extraName + m_CaloName + "DigitEnergy", std::begin( m_es ), std::end( m_es ), - m_extraName + m_CaloName + "DigitNe", m_maxSize ) - .ignore( /* AUTOMATICALLY ADDED FOR gaudi/Gaudi!763 */ ); - tuple - ->farray( m_extraName + m_CaloName + "DigitTransverseEnergy", std::begin( m_ets ), std::end( m_ets ), - m_extraName + m_CaloName + "DigitNe", m_maxSize ) - .ignore( /* AUTOMATICALLY ADDED FOR gaudi/Gaudi!763 */ ); - } - tuple - ->column( m_extraName + m_CaloName + "DigitEnergySum", - std::accumulate( std::begin( m_es ), std::end( m_es ), 0.0 ) ) - .ignore( /* AUTOMATICALLY ADDED FOR gaudi/Gaudi!763 */ ); - tuple - ->column( m_extraName + m_CaloName + "DigitTransverseEnergySum", - std::accumulate( std::begin( m_ets ), std::end( m_ets ), 0.0 ) ) - .ignore( /* AUTOMATICALLY ADDED FOR gaudi/Gaudi!763 */ ); - m_index.clear(); - m_calo.clear(); - m_area.clear(); - m_row.clear(); - m_column.clear(); - m_xs.clear(); - m_ys.clear(); - m_zs.clear(); - m_es.clear(); - - return StatusCode::SUCCESS; -} diff --git a/Phys/DecayTreeTuple/src/TupleToolCaloDigits.h b/Phys/DecayTreeTuple/src/TupleToolCaloDigits.h deleted file mode 100755 index 707d66d5b6892d07c635e9984351f517a0fabaa9..0000000000000000000000000000000000000000 --- a/Phys/DecayTreeTuple/src/TupleToolCaloDigits.h +++ /dev/null @@ -1,64 +0,0 @@ -/*****************************************************************************\ -* (c) Copyright 2000-2018 CERN for the benefit of the LHCb Collaboration * -* * -* This software is distributed under the terms of the GNU General Public * -* Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". * -* * -* In applying this licence, CERN does not waive the privileges and immunities * -* granted to it by virtue of its status as an Intergovernmental Organization * -* or submit itself to any jurisdiction. * -\*****************************************************************************/ -#ifndef TUPLETOOLCALODIGITS_H -#define TUPLETOOLCALODIGITS_H 1 - -// Include files -// from Gaudi -#include "CaloDet/DeCalorimeter.h" -#include "DecayTreeTupleBase/TupleToolBase.h" -#include "Kernel/IEventTupleTool.h" // Interface -#include "TupleToolCaloDigits.h" -class ITupleTool; - -/** @class TupleToolCaloDigits TupleToolCaloDigits.h - * - * \brief Add Calorimter digits to DecayTreeTuple - * - * Tuple columns: - * - Digit energy - * - Cell ID - * - Cell area, column and row - * \sa DecayTreeTuple - * @author Albert Bursche - * @date 2015-08-05 - */ -class TupleToolCaloDigits : public TupleToolBase, virtual public IEventTupleTool { -public: - /// Standard constructor - TupleToolCaloDigits( const std::string& type, const std::string& name, const IInterface* parent ); - - ~TupleToolCaloDigits() override = default; ///< Destructor - - StatusCode fill( Tuples::Tuple& ) override; - StatusCode initialize() override; - StatusCode finalize() override; - -private: - std::string m_DigitLocation = LHCb::CaloDigitLocation::Spd; - std::string m_CaloName = "Spd"; - std::string m_CaloLocation = DeCalorimeterLocation::Spd; - - std::vector m_index; - std::vector m_calo; - std::vector m_area; - std::vector m_row; - std::vector m_column; - std::vector m_xs; - std::vector m_ys; - std::vector m_zs; - std::vector m_es; - std::vector m_ets; - - unsigned long m_maxSize = 4096; - bool m_auto_configure = false; -}; -#endif // diff --git a/Phys/DecayTreeTuple/src/TupleToolCorrectedMass.cpp b/Phys/DecayTreeTuple/src/TupleToolCorrectedMass.cpp deleted file mode 100644 index 5b073fd65ac9a7aee8df448bae4938c9ea34ff4f..0000000000000000000000000000000000000000 --- a/Phys/DecayTreeTuple/src/TupleToolCorrectedMass.cpp +++ /dev/null @@ -1,246 +0,0 @@ -/*****************************************************************************\ -* (c) Copyright 2000-2018 CERN for the benefit of the LHCb Collaboration * -* * -* This software is distributed under the terms of the GNU General Public * -* Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". * -* * -* In applying this licence, CERN does not waive the privileges and immunities * -* granted to it by virtue of its status as an Intergovernmental Organization * -* or submit itself to any jurisdiction. * -\*****************************************************************************/ - -#include "DecayTreeTupleBase/TupleToolBase.h" - -#include "Event/Particle.h" - -#include "Kernel/GetIDVAlgorithm.h" -#include "Kernel/IDVAlgorithm.h" -#include "Kernel/IParticleTupleTool.h" // Interface - -#include "GaudiAlg/Tuple.h" -#include "GaudiAlg/TupleObj.h" - -#include "TVector3.h" - -/** - * \brief Fill corrected mass (m_corr = sqrt( m_vis² + pT² ) + pT) and error on corrected mass - * - * - head_MCORR: corrected mass - * - head_MCORRERR : error on corrected mass - * - head_MCORRVERTEXERR: error on corrected mass, only taking the uncertainties on the vertices into account - * - * \sa DecayTreeTuple - * - * @author Michel De Cian (based on Will Sutcliffe's version) - * @date 2018-03-21 - */ -class TupleToolCorrectedMass : public TupleToolBase, virtual public IParticleTupleTool { - -public: - TupleToolCorrectedMass( const std::string& type, const std::string& name, const IInterface* parent ); - virtual StatusCode initialize() override; - StatusCode fill( const LHCb::Particle*, const LHCb::Particle*, const std::string&, Tuples::Tuple&, - IGeometryInfo const& ) override; - -private: - double mCorr( const Gaudi::LorentzVector p, const TVector3 flightDir ) const; - double dPTdx( const double dAdx, const double dBdx, const double PT, const double A, const double B ) const; - std::pair mCorrErrors( const TVector3 sv, const TVector3 pv, const Gaudi::LorentzVector p, - const Gaudi::SymMatrix7x7 covP, const Gaudi::SymMatrix3x3 covPV ) const; - - IDVAlgorithm* m_dva; -}; - -using namespace LHCb; -using namespace Gaudi::Units; -using namespace ROOT::Math; - -DECLARE_COMPONENT( TupleToolCorrectedMass ) -//============================================================================= -// Standard constructor, initializes variables -//============================================================================= -TupleToolCorrectedMass::TupleToolCorrectedMass( const std::string& type, const std::string& name, - const IInterface* parent ) - : TupleToolBase( type, name, parent ), m_dva( nullptr ) { - declareInterface( this ); -} -//============================================================================= -// -- Initialize -//============================================================================= -StatusCode TupleToolCorrectedMass::initialize() { - const StatusCode sc = TupleToolBase::initialize(); - if ( sc.isFailure() ) return sc; - - m_dva = Gaudi::Utils::getIDVAlgorithm( contextSvc(), this ); - if ( !m_dva ) return Error( "Couldn't get parent DVAlgorithm", StatusCode::FAILURE ); - - return sc; -} -//============================================================================= -// -- The main method -//============================================================================= -StatusCode TupleToolCorrectedMass::fill( const Particle* mother, const Particle* P, const std::string& head, - Tuples::Tuple& tuple, IGeometryInfo const& geometry ) { - - const std::string prefix = fullName( head ); - Assert( P && mother, "This should not happen, you are inside TupleToolCorrectedMass.cpp :(" ); - if ( !P ) return StatusCode::FAILURE; - if ( !( P->particleID().hasBottom() ) ) return StatusCode::SUCCESS; - - const LHCb::Vertex* BEndVertex = P->endVertex(); - const LHCb::VertexBase* primaryVertex = m_dva->bestVertex( P, geometry ); - - const Gaudi::LorentzVector pMother = P->momentum(); - - const TVector3 PV( primaryVertex->position().X(), primaryVertex->position().Y(), primaryVertex->position().Z() ); - const TVector3 SV( BEndVertex->position().X(), BEndVertex->position().Y(), BEndVertex->position().Z() ); - const TVector3 flightDir = ( SV - PV ).Unit(); - - const double MCorr = mCorr( pMother, flightDir ); - const std::pair MCorrErrors = - mCorrErrors( SV, PV, pMother, P->covMatrix(), primaryVertex->covMatrix() ); - - bool test = true; - test &= tuple->column( prefix + "_MCORR", MCorr ); - test &= tuple->column( prefix + "_MCORRERR", MCorrErrors.second ); - test &= tuple->column( prefix + "_MCORRVERTEXERR", MCorrErrors.first ); // only errors on vertices - - // -- the pT relative to the flight direction - const TVector3 pVec( pMother.Px(), pMother.Py(), pMother.Pz() ); - const double PT = pVec.Perp( flightDir ); - test &= tuple->column( prefix + "_PTREL", PT ); - - return StatusCode( test ); -} -//========================================================================= -// -- Calculate the corrected mass: m_corr = sqrt( m_vis² + pT² ) + pT -//========================================================================= -double TupleToolCorrectedMass::mCorr( const Gaudi::LorentzVector p, const TVector3 flightDir ) const { - const TVector3 pVec( p.Px(), p.Py(), p.Pz() ); - const double PT = pVec.Perp( flightDir ); - return std::sqrt( p.M2() + PT * PT ) + PT; -} -//========================================================================= -// -- Helper calculation for mCorrErrors -//========================================================================= -double TupleToolCorrectedMass::dPTdx( const double dAdx, const double dBdx, const double PT, const double A, - const double B ) const { - - return 1 / PT * -0.5 * ( 2 * A * B * dAdx - A * A * dBdx ) / ( B * B ); -} -//========================================================================= -// -- Calculate the corrected mass error -//========================================================================= -std::pair TupleToolCorrectedMass::mCorrErrors( const TVector3 sv, const TVector3 pv, - const Gaudi::LorentzVector p, - const Gaudi::SymMatrix7x7 covP, - const Gaudi::SymMatrix3x3 covPV ) const { - // -- - // -- m_corr = sqrt( m_vis² + pT² ) + pT - // -- - // -- To transform the errors on the vertices and the momentum to the corrected mass, one essentially needs to do - // -- mcorr_err² = Sum_i,j( d(m_corr)/dx_i d(m_corr)/dx_j M_ij )_PV + Sum_n,m( d(m_corr)/dx_n d(m_corr)/dx_m M_nm )_SV - // -- where M_ij is the covariance matrix of the PV, and M_nm the covariance matrix of the SV, including uncertainties - // of the momenta - // -- of the particles that formed the SV. - // -- - // -- For the vertex coordinates: - // -- d(m_corr) / dx = d(m_corr)/dpT * dpT/dx - // -- d(m_corr)/dpT = 1/2 * 1/std::sqrt( m_vis² + pT² ) * 2 * pT + 1; - // -- pT = sqrt( (p_vec - (x_SV_vec - x_PV_vec) * A/B)² ) - // -- with A = px(x_SV - x_PV) + py(y_SV - y_PV) + pz(z_SV - z_PV) - // -- and B = (x_SV - x_PV)² + (y_SV - y_PV)² + (z_SV - z_PV)², or the magnitude squared of x_SV_vec - x_PV_vec - // -- - // -- For the momentum coordinates: - // -- m_vis² = E² - (px² + py² + pz²) - // -- d(m_corr) / dpx = 1/2 * 1 / sqrt( m_vis² + pT²) * ( -2A/B(x_SV-x_PV) ) + 1/pT * ( px - 2A/B(x_SV - x_PV) ) - // -- d(m_corr) / dE = 1/2 * / sqrt( m_vis² + pT²) * 2E - - const double x_SV = sv.Px(); // SV - const double y_SV = sv.Py(); // SV - const double z_SV = sv.Pz(); // SV - const double x_PV = pv.Px(); // PV - const double y_PV = pv.Py(); // PV - const double z_PV = pv.Pz(); // PV - const double px = p.Px(); - const double py = p.Py(); - const double pz = p.Pz(); - const double E = p.E(); - - const TVector3 pVec( p.Px(), p.Py(), p.Pz() ); - const double PT = pVec.Perp( ( sv - pv ) ); - const double A = px * ( x_SV - x_PV ) + py * ( y_SV - y_PV ) + pz * ( z_SV - z_PV ); - const double B = ( sv - pv ).Mag2(); - - const double invSqrtMassPT = 1 / std::sqrt( p.M2() + PT * PT ); - const double dMcorrdPT = 0.5 * invSqrtMassPT * 2 * PT + 1; - - // -- First let's calculate the derivates of 'A' and 'B' - // -- A - const double dAdx_SV = px; - const double dAdy_SV = py; - const double dAdz_SV = pz; - - const double dAdx_PV = -px; - const double dAdy_PV = -py; - const double dAdz_PV = -pz; - - const double dAdpx = x_SV - x_PV; - const double dAdpy = y_SV - y_PV; - const double dAdpz = z_SV - z_PV; - - // -- B - const double dBdx_SV = 2 * ( x_SV - x_PV ); - const double dBdy_SV = 2 * ( y_SV - y_PV ); - const double dBdz_SV = 2 * ( z_SV - z_PV ); - - const double dBdx_PV = -2 * ( x_SV - x_PV ); - const double dBdy_PV = -2 * ( y_SV - y_PV ); - const double dBdz_PV = -2 * ( z_SV - z_PV ); - - // -- the vertices - const double dMcdx_SV = dMcorrdPT * dPTdx( dAdx_SV, dBdx_SV, PT, A, B ); - const double dMcdy_SV = dMcorrdPT * dPTdx( dAdy_SV, dBdy_SV, PT, A, B ); - const double dMcdz_SV = dMcorrdPT * dPTdx( dAdz_SV, dBdz_SV, PT, A, B ); - - const double dMcdx_PV = dMcorrdPT * dPTdx( dAdx_PV, dBdx_PV, PT, A, B ); - const double dMcdy_PV = dMcorrdPT * dPTdx( dAdy_PV, dBdy_PV, PT, A, B ); - const double dMcdz_PV = dMcorrdPT * dPTdx( dAdz_PV, dBdz_PV, PT, A, B ); - - // -- the momentum - const double dMcdpx = -1 * invSqrtMassPT * A / B * dAdpx + 1 / PT * ( px - A / B * dAdpx ); - const double dMcdpy = -1 * invSqrtMassPT * A / B * dAdpy + 1 / PT * ( py - A / B * dAdpy ); - const double dMcdpz = -1 * invSqrtMassPT * A / B * dAdpz + 1 / PT * ( pz - A / B * dAdpz ); - const double dMcdE = invSqrtMassPT * E; - - // -- the errors on the vertices - const double errsqVertex = - // -- the diagonal for SV - covP( 0, 0 ) * dMcdx_SV * dMcdx_SV + covP( 1, 1 ) * dMcdy_SV * dMcdy_SV + covP( 2, 2 ) * dMcdz_SV * dMcdz_SV + - // -- the diagonal for PV - covPV( 0, 0 ) * dMcdx_PV * dMcdx_PV + covPV( 1, 1 ) * dMcdy_PV * dMcdy_PV + covPV( 2, 2 ) * dMcdz_PV * dMcdz_PV + - // -- the cross terms for SV - covP( 0, 1 ) * 2. * dMcdx_SV * dMcdy_SV + covP( 0, 2 ) * 2. * dMcdx_SV * dMcdz_SV + - covP( 1, 2 ) * 2. * dMcdy_SV * dMcdz_SV + - // -- the cross terms for PV - covPV( 0, 1 ) * 2. * dMcdx_PV * dMcdy_PV + covPV( 0, 2 ) * 2. * dMcdx_PV * dMcdz_PV + - covPV( 1, 2 ) * 2. * dMcdy_PV * dMcdz_PV; - - // -- the errors on the momentum x vertex - const double errsqMom = - // -- the diagonal for the momentum - covP( 3, 3 ) * dMcdpx * dMcdpx + covP( 4, 4 ) * dMcdpy * dMcdpy + covP( 5, 5 ) * dMcdpz * dMcdpz + - covP( 6, 6 ) * dMcdE * dMcdE + - // -- momentum x momomentum cross terms - covP( 3, 4 ) * 2. * dMcdpx * dMcdpy + covP( 3, 5 ) * 2. * dMcdpx * dMcdpz + covP( 3, 6 ) * 2. * dMcdpx * dMcdE + - covP( 4, 5 ) * 2. * dMcdpy * dMcdpz + covP( 4, 6 ) * 2. * dMcdpy * dMcdE + covP( 5, 6 ) * 2. * dMcdpz * dMcdE + - // -- momentum x position terms - covP( 0, 3 ) * 2. * dMcdx_SV * dMcdpx + covP( 1, 3 ) * 2. * dMcdy_SV * dMcdpx + - covP( 2, 3 ) * 2. * dMcdz_SV * dMcdpx + covP( 0, 4 ) * 2. * dMcdx_SV * dMcdpy + - covP( 1, 4 ) * 2. * dMcdy_SV * dMcdpy + covP( 2, 4 ) * 2. * dMcdz_SV * dMcdpy + - covP( 0, 5 ) * 2. * dMcdx_SV * dMcdpz + covP( 1, 5 ) * 2. * dMcdy_SV * dMcdpz + - covP( 2, 5 ) * 2. * dMcdz_SV * dMcdpz + covP( 0, 6 ) * 2. * dMcdx_SV * dMcdE + - covP( 1, 6 ) * 2. * dMcdy_SV * dMcdE + covP( 2, 6 ) * 2. * dMcdz_SV * dMcdE; - - return std::make_pair( std::sqrt( errsqVertex ), std::sqrt( errsqVertex + errsqMom ) ); -} diff --git a/Phys/DecayTreeTuple/src/TupleToolDecayTreeFitter.cpp b/Phys/DecayTreeTuple/src/TupleToolDecayTreeFitter.cpp deleted file mode 100644 index e77172384412d073ddce23e2b6fa3f8348471523..0000000000000000000000000000000000000000 --- a/Phys/DecayTreeTuple/src/TupleToolDecayTreeFitter.cpp +++ /dev/null @@ -1,802 +0,0 @@ -/*****************************************************************************\ -* (c) Copyright 2000-2018 CERN for the benefit of the LHCb Collaboration * -* * -* This software is distributed under the terms of the GNU General Public * -* Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". * -* * -* In applying this licence, CERN does not waive the privileges and immunities * -* granted to it by virtue of its status as an Intergovernmental Organization * -* or submit itself to any jurisdiction. * -\*****************************************************************************/ - -#include "DecayTreeTupleBase/TupleToolBase.h" - -#include "Kernel/Escape.h" -#include "Kernel/GetIDVAlgorithm.h" -#include "Kernel/IDVAlgorithm.h" -#include "Kernel/IParticleDescendants.h" -#include "Kernel/IParticlePropertySvc.h" -#include "Kernel/IParticleTupleTool.h" -#include "Kernel/ISubstitutePID.h" -#include "Kernel/ParticleProperty.h" - -#include "TrackInterfaces/ITrackStateProvider.h" - -#include "DecayTreeFitter/Fitter.h" - -#include "Event/Particle.h" -#include "Event/RecVertex.h" - -#include "LoKi/ParticleProperties.h" - -#include "GaudiAlg/GaudiTool.h" -#include "GaudiAlg/Tuple.h" -#include "GaudiAlg/TupleObj.h" -#include "GaudiKernel/ToolHandle.h" - -#include -#include - -#include -#include -#include -#include - -/** - * - History : this tool was written during the study of the b->JpsiX lifetimes. It was not very generic. - * This re-implmentation is hopefully more generic, although it requires several instances of the tool - * to achive the same result. - * - Advice : Most of the output of this code could be saved via the LoKi style lines. - - * - Usage : One can plug this Tool in DecayTreeTuple. It is advised to give it to a branch and not to try to run - * it on all the tree. To get full functionality use several instances. - * Always give it an instance name which will be used as prefix. See example. - * - Configuration : - @code - constrainToOriginVertex = False # save a fit to compute the lifetime. - particlesToConstrain = ["J/psi(1S)"] # chose the particles to mass to constrain. - ExtraName = "" # Additional Prefix (will replace instance name) (inherited from - TupleToolBase) Verbose = False # Fill Lifetime for daughters. (inherited from TupleToolBase) - @endcode - * - * - Outputs: for each fit is saved: - - The status, the chi2, the number of degres of freedom of the fit. - - The fitted mass, mass error for example : Lambda_b0_massConAllDaughters_M ... - - The fitted lifetime, and error : Lambda_b0_taufit_ctau (ctau is given in mm). - * - * - Example: - @code - decay = "B0 -> (^J/psi(1S) -> ^mu+ ^mu-) (^KS0 -> ^pi+ ^pi-)" - bh = 'B0' - tuple.Decay = decay - tuple = DecayTreeTuple("MyTuple") - tuple.ToolList += ["TupleToolGeometry", "TupleToolKinematic", "TupleToolPrimaries", "TupleToolEventInfo" ] - tuple.Branches = { "B" : "["+bh+"]cc : "+decay.replace("^","") } - from Configurables import TupleToolDecayTreeFitter - tuple.B.ToolList += [ "TupleToolDecayTreeFitter/Fit", # just a refit - "TupleToolDecayTreeFitter/MassFit", # fit with J/psi mass constraint - "TupleToolDecayTreeFitter/PVFit" ] # fit with all constraints I can think of - - tuple.B.addTool(TupleToolDecayTreeFitter("MassFit")) - tuple.B.MassFit.constrainToOriginVertex = False - tuple.B.MassFit.daughtersToConstrain = [ "J/psi(1S)" ] - - tuple.B.addTool(TupleToolDecayTreeFitter("PVFit")) - tuple.B.PVFit.Verbose = True - tuple.B.PVFit.constrainToOriginVertex = True - tuple.B.PVFit.daughtersToConstrain = [ "J/psi(1S)", "KS0" ] - - # now two that check for reflections - tuple.B.ToolList += ["TupleToolDecayTreeFitter/SubLambda", "TupleToolDecayTreeFitter/SubLambdabar" ] - subDTF = TupleToolDecayTreeFitter("SubLambda", Verbose=True, - daughtersToConstrain = [ "J/psi(1S)" ], - constrainToOriginVertex=True, - Substitutions={ 'Beauty -> Meson (Strange -> ^pi+ pi-)': 'p+' }) - tuple.B.addTool(subDTF) - tuple.B.addTool(subDTF.clone("SubLambdabar",Substitutions={ 'Beauty -> Meson (Strange -> pi+ ^pi-)': 'p-' })) - - @endcode - * - * - This will produce the following columns for the B (from this tool): - * - B_Fit_status B_Fit_nDOF B_Fit_chi2_B B_Fit_nIter B_Fit_M B_Fit_MERR B_Fit_P B_Fit_PERR - * - B_MassFit_status B_MassFit_nDOF B_MassFit_chi2_B B_MassFit_nIter B_MassFit_M B_MassFit_MERR B_MassFit_P - * B_MassFit_PERR B_PVFit_status B_PVFit_nDOF B_PVFit_chi2_B B_PVFit_nIter B_PVFit_M B_PVFit_MERR B_PVFit_P - * - B_PVFit_PERR B_PVFit_ctau B_PVFit_ctauErr B_PVFit_decayLength B_PVFit_decayLengthErr B_PVFit_J_psi_1S_ctau - * B_PVFit_J_psi_1S_ctauErr B_PVFit_J_psi_1S_decayLength B_PVFit_J_psi_1S_decayLengthErr B_PVFit_KS0_ctau - * B_PVFit_KS0_ctauErr B_PVFit_KS0_decayLength B_PVFit_KS0_decayLengthErr - * - * - One can also hange the PID of some particles in the chain, using the same syntax as SubstitutePID - * - * \sa SubstitutePID - * - * \sa DecayTreeTuple - * - * @author Yasmine Amhis, Matt Needham (original authors), Patrick Koppenburg (re-implementation) - * @date 2010-10-30, 2011-04-01 - * - **/ -class TupleToolDecayTreeFitter : public TupleToolBase, virtual public IParticleTupleTool { - -private: - typedef std::map SubstitutionMap; - typedef std::map> TupleMap; ///< temporary storage of tuple data - -public: - TupleToolDecayTreeFitter( const std::string& type, const std::string& name, const IInterface* parent ); - StatusCode initialize() override; - StatusCode finalize() override; - StatusCode fill( const LHCb::Particle*, const LHCb::Particle*, const std::string&, Tuples::Tuple&, - IGeometryInfo const& ) override; - -private: - /// Fill inforation for a given origin vertex - StatusCode fit( DecayTreeFitter::Fitter& fitter, const LHCb::Particle* P, const LHCb::VertexBase* pv, - const std::string& prefix, TupleMap& tMap, IGeometryInfo const& geometry ) const; - - /// Fill lifetime information - /// Fill fit inforation for top decay - StatusCode fillDecay( const DecayTreeFitter::Fitter& fitter, const std::string& prefix, TupleMap& tMap ) const; - - /// Fill lifetime information - StatusCode fillLT( const DecayTreeFitter::Fitter& fitter, const LHCb::Particle* P, const std::string& prefix, - TupleMap& tMap ) const; - - /// Fill momentum and mass information - StatusCode fillMomentum( const DecayTreeFitter::Fitter& fitter, const LHCb::Particle* P, const std::string& prefix, - TupleMap& tMap ) const; - - /// Fill PV information - StatusCode fillPV( const LHCb::VertexBase* pv, const std::string& prefix, TupleMap& tMap ) const; - - /// Fill lifetime information for non stable daughters - StatusCode fillDaughters( const DecayTreeFitter::Fitter& fitter, const LHCb::Particle* P, const std::string& prefix, - TupleMap& tMap ) const; - - /// Fill lifetime information for non stable daughters - StatusCode fillStableDaughters( const DecayTreeFitter::Fitter& fitter, const LHCb::Particle* P, - const std::string& prefix, TupleMap& tMap ) const; - - /// Fill updated tracks momentum - StatusCode fillTracksMomentum( const DecayTreeFitter::Fitter& fitter, const LHCb::Particle* P, - const std::string& prefix, TupleMap& tMap ) const; - - /// actual filling of tuple - StatusCode fillTuple( TupleMap& tMap, Tuples::Tuple& tuple, const std::string& prefix ); - - /// insert helper method - StatusCode insert( const std::string& leaf, const double val, TupleMap& tMap ) const; - - std::string getName( const int id ) const; ///< name of particle - - /// origin vertex - std::vector originVertex( const LHCb::Particle*, const LHCb::Particle*, - IGeometryInfo const& ) const; - - /// same PV? - bool samePV( const LHCb::VertexBase*, const LHCb::VertexBase* ) const; - - /// sort tracks into a set - std::set sortedTracks( const LHCb::VertexBase* ) const; - - /// substitutions - StatusCode substitute( LHCb::DecayTree& tree ); - - /// checkMassConstraints - StatusCode checkMassConstraints( const LHCb::DecayTree& tree ); - - /// Get the TES location for a data object - template - inline std::string tesLocation( const TYPE* obj ) const { - return ( obj && obj->parent() && obj->parent()->registry() ? obj->parent()->registry()->identifier() : "NotInTES" ); - } - - /// Test if a given PID code is veto'ed - inline bool isVetoed( const int id ) const { - return ( !m_vetoPIDs.empty() && std::find( m_vetoPIDs.begin(), m_vetoPIDs.end(), id ) != m_vetoPIDs.end() ); - } - - /// Compare two maps - inline bool checkTupleKeys( const TupleMap& r ) { - bool OK = true; - if ( m_firstTupleKeys.size() != r.size() ) { - Error( "Maps have different sizes" ).ignore(); - OK = false; - } - auto i = m_firstTupleKeys.begin(); - auto j = r.begin(); - for ( ; j != r.end(); ++i, ++j ) { - // compare key names - if ( *i != j->first ) { - std::ostringstream mess; - mess << "Tuple entry error : " << *i << " != " << j->first; - Error( mess.str() ).ignore(); - OK = false; - } - } - return OK; - } - -private: - std::string m_pvLocation; ///< PV location to be used. If empty, take context-dependent default - - IDVAlgorithm* m_dva = nullptr; - - std::vector m_massConstraints; - std::vector m_massConstraintsPids; - - bool m_constrainToOriginVertex; ///< Constrain to Origin Vertex for lifetime - - LHCb::IParticlePropertySvc* m_ppSvc = nullptr; - IParticleDescendants* m_particleDescendants = nullptr; - - /// mapping : { 'decay-component' : "new-pid" } (property) - ISubstitutePID::SubstitutionMap m_map; // mapping : { 'decay-component' : "new-pid" } - /// Substitute Tool - ISubstitutePID* m_substitute = nullptr; - bool m_storeAnyway; ///< Store PV even if a refitted version is already the best PV (i.e store twice) - bool m_updateDaughters; ///< Store updated momenta of tracks in the decay tree - ToolHandle m_stateprovider{"TrackStateProvider"}; - bool m_first{true}; ///< This is the first candidate - bool m_firstTupleFill{true}; ///< Flag for the first tuple filling - - std::vector m_firstTupleKeys; ///< cache the keys for the first tuple map - - /// List of PID codes to veto filling for - std::vector m_vetoPIDs; - - /// Use full decay tree in branch names - bool m_useFullTreeInName; -}; - -using namespace LHCb; - -//============================================================================= -// Standard constructor, initializes variables -//============================================================================= -TupleToolDecayTreeFitter::TupleToolDecayTreeFitter( const std::string& type, const std::string& name, - const IInterface* parent ) - : TupleToolBase( type, name, parent ) { - declareProperty( "daughtersToConstrain", m_massConstraints, "List of particles to contrain to mass" ); - declareProperty( "constrainToOriginVertex", m_constrainToOriginVertex = false, - "Do a refit constraining to Origin Vertex (could be PV)" ); - declareProperty( "Substitutions", m_map, "PID-substitutions : { ' decay-component' : 'new-pid' }" ); - declareProperty( "StoreRefittedPVsTwice", m_storeAnyway = false, - "Store PV even if a refitted version is already the best PV (i.e store twice)." ); - declareProperty( "UpdateDaughters", m_updateDaughters = false, "Store updated momenta of tracks in the decay tree." ); - declareProperty( "StateProvider", m_stateprovider ); - declareProperty( "VetoPIDs", m_vetoPIDs, "An optional list of PDG particle codes to skip when filling the tuple." ); - declareProperty( "UseFullTreeInName", m_useFullTreeInName = false, - "Use an improved branch naming scheme that includes a full history of the " - "parents and grand-parents for each particle. Makes it easier to identify " - "cases where the same particle type appears at different levels in the decay tree." ); - declareInterface( this ); -} - -//============================================================================= -StatusCode TupleToolDecayTreeFitter::initialize() { - StatusCode sc = TupleToolBase::initialize(); - if ( sc.isFailure() ) return sc; - - // convert the list of names to a list of pids - m_ppSvc = svc( "LHCb::ParticlePropertySvc", true ); - for ( const auto& S : m_massConstraints ) { - const auto prop = m_ppSvc->find( S ); - if ( !prop ) Exception( "Unknown PID" ); - m_massConstraintsPids.push_back( prop->pdgID() ); - } - - m_dva = Gaudi::Utils::getIDVAlgorithm( contextSvc(), this ); - if ( !m_dva ) return Error( "Couldn't get parent IDVAlgorithm", StatusCode::FAILURE ); - - m_particleDescendants = tool( "ParticleDescendants" ); - - if ( !m_stateprovider.empty() ) { - sc = m_stateprovider.retrieve(); - if ( sc.isFailure() ) return sc; - } - - if ( m_extraName.empty() ) { - const auto en = name(); // use tool name as prepended name - const auto d = en.find_last_of( "." ); - m_extraName = en.substr( d + 1, en.size() - 1 ); // from d to end - if ( "TupleToolDecayTreeFitter" == m_extraName ) m_extraName = ""; // user has not chanegd instance name - info() << "All fields will be prepended with ``" << m_extraName << "''" << endmsg; - } - - if ( m_extraName.empty() ) { - return Error( "Extraname is empty. Always give an instance name " - "to TupleToolDecayTreeFitter! See doxygen." ); - } - - if ( !m_map.empty() ) { - m_substitute = tool( "SubstitutePIDTool", this ); - sc = m_substitute->decodeCode( m_map ); - } - - if ( !m_vetoPIDs.empty() ) { info() << "Will veto PIDs " << m_vetoPIDs << " from filling" << endmsg; } - - if ( m_useFullTreeInName ) { info() << "Will use the full decay tree as part of branch names" << endmsg; } - - return sc; -} - -StatusCode TupleToolDecayTreeFitter::finalize() { - StatusCode sc = StatusCode::SUCCESS; - if ( !m_stateprovider.empty() ) { sc = m_stateprovider.release(); } - return StatusCode{TupleToolBase::finalize() && sc}; -} - -//============================================================================= -// The fill method implementation -//============================================================================= -StatusCode TupleToolDecayTreeFitter::fill( const LHCb::Particle* mother, const LHCb::Particle* P, - const std::string& head, Tuples::Tuple& tuple, - IGeometryInfo const& geometry ) { - if ( !P ) return StatusCode::FAILURE; - if ( P->isBasicParticle() ) { - return Error( "Do not call TupleToolDecayTreeFitter for basic particles. Use Branches. See doxygen." ); - } - const std::string prefix = fullName( head ); - if ( msgLevel( MSG::DEBUG ) ) - debug() << "head ''" << head << "'' prefix ''" << prefix << "'' extraname ''" << m_extraName << "''" << endmsg; - - const auto stateprovider = ( m_stateprovider.empty() ? nullptr : &( *m_stateprovider ) ); - - LHCb::DecayTree tree( *P ); - // substitute - if ( m_substitute && !substitute( tree ) ) return StatusCode::FAILURE; - if ( !m_massConstraintsPids.empty() && !checkMassConstraints( tree ) ) return StatusCode::FAILURE; - - // get origin vertices - std::vector originVtx; - TupleMap tMap; // the temporary data map - - if ( m_constrainToOriginVertex ) { - if ( msgLevel( MSG::DEBUG ) ) { debug() << "Constrain the origin vertex" << endmsg; } - // check for origin vertex - originVtx = originVertex( mother, P, geometry ); - if ( originVtx.empty() ) { return Error( "Can't get an origin vertex" ); } - if ( msgLevel( MSG::DEBUG ) ) debug() << "PVs: " << originVtx.size() << endmsg; - for ( const auto& v : originVtx ) { - if ( msgLevel( MSG::DEBUG ) ) debug() << "Creating DecayTreeFitter on " << tree.head() << " " << v << endmsg; - DecayTreeFitter::Fitter fitter( *( tree.head() ), *v, stateprovider ); - if ( msgLevel( MSG::DEBUG ) ) debug() << "Created DecayTreeFitter" << endmsg; - if ( !fit( fitter, tree.head(), v, prefix, tMap, geometry ) ) return StatusCode::FAILURE; - } - } else { - if ( msgLevel( MSG::DEBUG ) ) debug() << "Do not constrain the origin vertex" << endmsg; - // Get the fitter - DecayTreeFitter::Fitter fitter( *( tree.head() ), stateprovider ); - if ( !fit( fitter, tree.head(), 0, prefix, tMap, geometry ) ) return StatusCode::FAILURE; - } - - return fillTuple( tMap, tuple, prefix ); // the actual filling -} -//============================================================================= -// do filling for a given vertex -//============================================================================= -StatusCode TupleToolDecayTreeFitter::fit( DecayTreeFitter::Fitter& fitter, const LHCb::Particle* P, - const LHCb::VertexBase* pv, const std::string& prefix, TupleMap& tMap, - IGeometryInfo const& geometry ) const { - if ( msgLevel( MSG::VERBOSE ) ) verbose() << "fit " << P << " " << pv << " " << prefix << endmsg; - bool test = true; - // add mass contraints - if ( !m_massConstraintsPids.empty() ) { - for ( const auto& C : m_massConstraintsPids ) { fitter.setMassConstraint( C ); } - } - // fit - if ( msgLevel( MSG::VERBOSE ) ) verbose() << "calling Fit" << endmsg; - fitter.fit( geometry ); - if ( msgLevel( MSG::VERBOSE ) ) verbose() << "called Fit" << endmsg; - // fill the fit result - fillDecay( fitter, prefix, tMap ).ignore( /* AUTOMATICALLY ADDED FOR gaudi/Gaudi!763 */ ); - fillMomentum( fitter, P, prefix, tMap ).ignore( /* AUTOMATICALLY ADDED FOR gaudi/Gaudi!763 */ ); - if ( m_constrainToOriginVertex ) { - test &= fillPV( pv, prefix, tMap ); - test &= fillLT( fitter, P, prefix, tMap ); - } - if ( isVerbose() ) { test &= fillDaughters( fitter, P, prefix, tMap ); } - if ( m_updateDaughters ) { test &= fillStableDaughters( fitter, P, prefix, tMap ); } - - return StatusCode( test ); -} -//============================================================================= -// Fill standard stuff -//============================================================================= -StatusCode TupleToolDecayTreeFitter::fillPV( const LHCb::VertexBase* pv, const std::string& prefix, - TupleMap& tMap ) const { - bool test = true; - if ( msgLevel( MSG::VERBOSE ) ) verbose() << "FillPV " << prefix << endmsg; - if ( !pv ) Exception( "Null PVs cannot happen with ConstrainToOriginVertex!" ); - test &= insert( prefix + "_PV_key", pv->key(), tMap ); - if ( isVerbose() ) { - test &= insert( prefix + "_PV_X", pv->position().X(), tMap ); - test &= insert( prefix + "_PV_Y", pv->position().Y(), tMap ); - test &= insert( prefix + "_PV_Z", pv->position().Z(), tMap ); - } - return StatusCode( test ); -} -//============================================================================= -// Fill standard stuff -//============================================================================= -StatusCode TupleToolDecayTreeFitter::fillDecay( const DecayTreeFitter::Fitter& fitter, const std::string& prefix, - TupleMap& tMap ) const { - bool test = true; - if ( msgLevel( MSG::VERBOSE ) ) verbose() << "FillDecay " << prefix << endmsg; - - test &= insert( prefix + "_status", fitter.status(), tMap ); - test &= insert( prefix + "_nDOF", fitter.nDof(), tMap ); - test &= insert( prefix + "_chi2", fitter.chiSquare(), tMap ); - test &= insert( prefix + "_nIter", fitter.nIter(), tMap ); - - return StatusCode( test ); -} -//============================================================================= -// Fill momentum and mass information -//============================================================================= -StatusCode TupleToolDecayTreeFitter::fillMomentum( const DecayTreeFitter::Fitter& fitter, const Particle* P, - const std::string& prefix, TupleMap& tMap ) const { - bool test = true; - - if ( isVetoed( P->particleID().pid() ) ) { return StatusCode( test ); } - - if ( msgLevel( MSG::VERBOSE ) ) verbose() << "FillMomentum " << prefix << endmsg; - // Get the fit parameters - const auto params = fitter.fitParams( P ); - const auto& momentum = params->momentum(); - - test &= insert( prefix + "_M", momentum.m().value(), tMap ); - test &= insert( prefix + "_MERR", momentum.m().error(), tMap ); - test &= insert( prefix + "_P", momentum.p().value(), tMap ); - test &= insert( prefix + "_PERR", momentum.p().error(), tMap ); // MeV - - return StatusCode( test ); -} -//============================================================================= -// Fill lifetime information -//============================================================================= -StatusCode TupleToolDecayTreeFitter::fillLT( const DecayTreeFitter::Fitter& fitter, const Particle* P, - const std::string& prefix, TupleMap& tMap ) const { - bool test = true; - - if ( isVetoed( P->particleID().pid() ) ) { return StatusCode( test ); } - - if ( msgLevel( MSG::VERBOSE ) ) verbose() << "FillLT " << prefix << endmsg; - const auto tParams = fitter.fitParams( P ); - const auto& decayLength = tParams->decayLength(); - const auto& ctau = tParams->ctau(); - test &= insert( prefix + "_ctau", ctau.value(), tMap ); - test &= insert( prefix + "_ctauErr", ctau.error(), tMap ); - test &= insert( prefix + "_decayLength", decayLength.value(), tMap ); - test &= insert( prefix + "_decayLengthErr", decayLength.error(), tMap ); - - return StatusCode( test ); -} -//============================================================================= -// Fill lifetime information for non stable daughters -//============================================================================= -StatusCode TupleToolDecayTreeFitter::fillDaughters( const DecayTreeFitter::Fitter& fitter, const LHCb::Particle* P, - const std::string& prefix, TupleMap& tMap ) const { - bool test = true; - - if ( msgLevel( MSG::VERBOSE ) ) verbose() << "FillDaughters " << prefix << endmsg; - const auto& daughters = ( m_useFullTreeInName ? P->daughtersVector() : m_particleDescendants->descendants( P ) ); - if ( msgLevel( MSG::DEBUG ) ) - debug() << "for id " << P->particleID().pid() << " daughter size is " << daughters.size() << endmsg; - if ( daughters.empty() ) return StatusCode( test ); - std::set usedNames; - unsigned int add = 0; - for ( const auto& particle : daughters ) { - if ( particle->isBasicParticle() ) continue; - const auto pid = abs( particle->particleID().pid() ); - const auto pidName = getName( pid ); - auto name = prefix + "_" + pidName; - bool renamed = false; - while ( usedNames.find( name ) != usedNames.end() ) { // fix to bug 88702 - renamed = true; - if ( msgLevel( MSG::VERBOSE ) ) verbose() << "Found already name " << name << " trying next " << endmsg; - name = prefix + "_" + pidName + "_" + boost::lexical_cast( add ); - ++add; - } - if ( renamed ) - Info( "Renaming duplicate to " + name, StatusCode::SUCCESS, 1 ) - .ignore( /* AUTOMATICALLY ADDED FOR gaudi/Gaudi!763 */ ); - usedNames.insert( name ); - test &= fillMomentum( fitter, particle, name, tMap ); - test &= fillLT( fitter, particle, name, tMap ); - if ( m_useFullTreeInName ) { - fillDaughters( fitter, particle, name, tMap ).ignore( /* AUTOMATICALLY ADDED FOR gaudi/Gaudi!763 */ ); - } - } - return StatusCode( test ); -} -//============================================================================= -// Fill lifetime information for stable daughters -//============================================================================= -StatusCode TupleToolDecayTreeFitter::fillStableDaughters( const DecayTreeFitter::Fitter& fitter, - const LHCb::Particle* P, const std::string& prefix, - TupleMap& tMap ) const { - bool test = true; - - if ( msgLevel( MSG::VERBOSE ) ) verbose() << "FillStableDaughters " << prefix << endmsg; - const LHCb::Particle::ConstVector& daughters = P->daughtersVector(); - if ( msgLevel( MSG::DEBUG ) ) - debug() << "for id " << P->particleID().pid() << " daughter size is " << daughters.size() << endmsg; - if ( daughters.empty() ) return StatusCode( test ); - std::set usedNames; - unsigned int add = 0; - for ( const auto& particle : daughters ) { - if ( !particle->isBasicParticle() ) { - const auto pid = abs( particle->particleID().pid() ); - const auto pidName = getName( pid ); - auto name = prefix + "_" + pidName; - bool renamed = false; - while ( usedNames.find( name ) != usedNames.end() ) { // fix to bug 88702 - if ( msgLevel( MSG::VERBOSE ) ) verbose() << "Found already name " << name << " trying next " << endmsg; - renamed = true; - name = prefix + "_" + pidName + boost::lexical_cast( add ); - ++add; - } - if ( renamed ) - Info( "Renaming duplicate to " + name, StatusCode::SUCCESS, 1 ) - .ignore( /* AUTOMATICALLY ADDED FOR gaudi/Gaudi!763 */ ); - usedNames.insert( name ); - test &= fillStableDaughters( fitter, particle, name, tMap ); - } else { - // const int pid = particle->particleID().pid(); - const auto pid = abs( particle->particleID().pid() ); - const auto pidName = getName( pid ); - auto name = prefix + "_" + pidName; - bool renamed = false; - while ( usedNames.find( name ) != usedNames.end() ) { // fix to bug 88702 - if ( msgLevel( MSG::VERBOSE ) ) verbose() << "Found already name " << name << " trying next " << endmsg; - renamed = true; - name = prefix + "_" + pidName + "_" + boost::lexical_cast( add ); - ++add; - } - if ( renamed ) - Info( "Renaming duplicate to " + name, StatusCode::SUCCESS, 1 ) - .ignore( /* AUTOMATICALLY ADDED FOR gaudi/Gaudi!763 */ ); - usedNames.insert( name ); - test &= fillTracksMomentum( fitter, particle, name, tMap ); - } - } - return StatusCode( test ); -} - -//============================================================================= -// Fill updated tracks momentum -//============================================================================= -StatusCode TupleToolDecayTreeFitter::fillTracksMomentum( const DecayTreeFitter::Fitter& fitter, const Particle* P, - const std::string& prefix, TupleMap& tMap ) const { - bool test = true; - - if ( isVetoed( P->particleID().pid() ) ) { return StatusCode( test ); } - - if ( msgLevel( MSG::VERBOSE ) ) verbose() << "FillTracksMomentum " << prefix << endmsg; - - // Get the fit parameters - const auto params = fitter.fitParams( P ); - const auto& momentum = params->momentum(); - - test &= insert( prefix + "_ID", P->particleID().pid(), tMap ); - test &= insert( prefix + "_PX", momentum.Px(), tMap ); - test &= insert( prefix + "_PY", momentum.Py(), tMap ); - test &= insert( prefix + "_PZ", momentum.Pz(), tMap ); - test &= insert( prefix + "_PE", momentum.E(), tMap ); // MeV - - return StatusCode( test ); -} - -//============================================================================= -// append data to TupleMap -//============================================================================= -StatusCode TupleToolDecayTreeFitter::insert( const std::string& leaf, const double val, TupleMap& tMap ) const { - auto l = tMap.find( leaf ); - if ( l == tMap.end() ) { /// first time this is seen. Create - std::vector vals; - vals.push_back( val ); - tMap.insert( std::make_pair( leaf, vals ) ); - } else { - l->second.push_back( val ); /// append a to vector - } - if ( msgLevel( MSG::VERBOSE ) ) - verbose() << "insert " << leaf << " " << val << " size " << l->second.size() << endmsg; - return StatusCode::SUCCESS; -} - -//============================================================================= -// actual filling of the Tuple -//============================================================================= -StatusCode TupleToolDecayTreeFitter::fillTuple( TupleMap& tMap, Tuples::Tuple& tuple, const std::string& prefix ) { - bool test = true; - - if ( m_firstTupleFill ) { - // Save the list of keys in the given order for future comparisons - m_firstTupleKeys.clear(); - m_firstTupleKeys.reserve( tMap.size() ); - for ( const auto& i : tMap ) { m_firstTupleKeys.emplace_back( i.first ); } - // flag having saved the keys - m_firstTupleFill = false; - } else { - // test against the first set of keys - test = checkTupleKeys( tMap ); - } - - // if OK, save and continue - if ( test ) { - for ( const auto& t : tMap ) { - const auto& leaf = t.first; - const auto& data = t.second; - if ( msgLevel( MSG::DEBUG ) ) - debug() << "Filling leaf ``" << leaf << "'' with vector of size " << data.size() << endmsg; - if ( m_maxPV < data.size() ) Exception( "Seeing data with too many PVs. Have you set MaxPVs?" ); - test &= tuple->farray( leaf, data, prefix + "_nPV", m_maxPV ); - } - } - - return StatusCode( test ); -} - -//============================================================================= -// Sort Tracks -//============================================================================= -std::set TupleToolDecayTreeFitter::sortedTracks( const LHCb::VertexBase* vb ) const { - const LHCb::RecVertex* pv = dynamic_cast( vb ); - if ( !pv ) Exception( "Failed to cast PV" ); - std::set st; - for ( const auto& t : pv->tracks() ) { st.insert( t ); } - return st; -} - -//============================================================================= -// Compare PVs, check that one PV's tracks is a subset of the other -//============================================================================= -bool TupleToolDecayTreeFitter::samePV( const LHCb::VertexBase* vb1, const LHCb::VertexBase* vb2 ) const { - // exception checking. See bug https://savannah.cern.ch/bugs/?100933 - if ( !vb1 && !vb2 ) { - Warning( "samePV method called with 2 NULL PVs. " - "The answer is obviously true, but you may want to check the meaning of the question.", - StatusCode::SUCCESS, 1 ) - .ignore( /* AUTOMATICALLY ADDED FOR gaudi/Gaudi!763 */ ); - return true; - } else if ( !vb1 || !vb2 ) { - Warning( "samePV method called with 1 NULL PV. " - "The answer is obviously false, but you may want to check the meaning of the question.", - StatusCode::SUCCESS, 1 ) - .ignore( /* AUTOMATICALLY ADDED FOR gaudi/Gaudi!763 */ ); - return false; - } - - if ( !( vb1->isPrimary() ) || !( vb2->isPrimary() ) ) { - Warning( "Non PV VertexBase is being used as PV", StatusCode::SUCCESS, 1 ).ignore(); - return false; - } - - const auto st1 = sortedTracks( vb1 ); - const auto st2 = sortedTracks( vb2 ); - - const bool inc = std::includes( st1.begin(), st1.end(), st2.begin(), st2.end() ); - if ( msgLevel( MSG::VERBOSE ) ) { - verbose() << "PV 2 of size " << st2.size() << " is "; - if ( !inc ) verbose() << "not "; - verbose() << "included in PV 1 of size " << st1.size() << endmsg; - } - return inc; -} - -//============================================================================= -// get origin vertex -//============================================================================= -std::vector TupleToolDecayTreeFitter::originVertex( const Particle* mother, const Particle* P, - IGeometryInfo const& geometry ) const { - std::vector oriVx; - if ( mother == P ) { // the origin vertex is the primary. - const auto bpv = m_dva->bestVertex( P, geometry ); - if ( bpv ) { - oriVx.push_back( bpv ); - if ( msgLevel( MSG::VERBOSE ) ) - verbose() << "Pushed back bpv " << bpv << " from " << tesLocation( bpv ) << " at " << bpv->position() << endmsg; - } else if ( m_constrainToOriginVertex ) { - Warning( "NULL bestPV while constraining to origin vertex. Fit will be ignored.", StatusCode::SUCCESS, 0 ) - .ignore(); - } - // all the other ones - /// @todo : keep only the related ones - for ( const auto& pv : m_dva->primaryVertices() ) { - if ( m_storeAnyway || !samePV( pv, bpv ) ) { - oriVx.push_back( pv ); - if ( msgLevel( MSG::VERBOSE ) ) - verbose() << "Pushed back pv " << pv << " from " << tesLocation( pv ) << " at " << pv->position() << endmsg; - } - if ( oriVx.size() >= m_maxPV ) { - Warning( "Truncated number of PVs", StatusCode::FAILURE, 0 ).ignore(); - break; - } - } - } else { - const auto& dau = mother->daughters(); - if ( dau.empty() ) return oriVx; - - for ( const auto& d : dau ) { - if ( P == d ) { - oriVx.push_back( mother->endVertex() ); - return oriVx; - } - } - - // vertex not yet found, get deeper in the decay: - for ( const auto& d : dau ) { - if ( P != d && !d->isBasicParticle() ) { - oriVx = originVertex( d, P, geometry ); - if ( !oriVx.empty() ) { - return oriVx; // found - } - } - } - } - return oriVx; -} - -//============================================================================= -// Convert pid number in names -//============================================================================= -std::string TupleToolDecayTreeFitter::getName( const int id ) const { - const auto* prop = m_ppSvc->find( LHCb::ParticleID( id ) ); - if ( !prop ) Exception( "Unknown PID" ); - // if (msgLevel(MSG::VERBOSE)) verbose() << "ID " << id << " gets name " - // << Decays::escape(prop->name()) << endmsg ; - return Decays::escape( prop->name() ); -} - -//============================================================================= -// Substitute -//============================================================================= -StatusCode TupleToolDecayTreeFitter::substitute( LHCb::DecayTree& tree ) { - if ( msgLevel( MSG::DEBUG ) ) debug() << "Calling substitute" << endmsg; - const auto substituted = m_substitute->substitute( tree.head() ); - // debugging - if ( msgLevel( MSG::VERBOSE ) || 0 == substituted ) { - const auto mp = tree.cloneMap(); - for ( const auto& i : mp ) { - if ( i.first->particleID().pid() == i.second->particleID().pid() ) { - info() << "A " << getName( i.first->particleID().pid() ) << " remains unchanged" << endmsg; - } else { - info() << "A " << getName( i.first->particleID().pid() ) << " is substituted by a " - << getName( i.second->particleID().pid() ) << endmsg; - } - } - } - if ( 0 == substituted ) { return Error( "No particles have been substituted. Check your substitution options." ); } - return StatusCode::SUCCESS; -} - -//============================================================================= -// Check Mass Constraints -//============================================================================= -StatusCode TupleToolDecayTreeFitter::checkMassConstraints( const LHCb::DecayTree& tree ) { - if ( !m_first ) return StatusCode::SUCCESS; // do that only once - m_first = false; - const auto mp = tree.cloneMap(); - for ( const auto& m : m_massConstraintsPids ) { - bool found = false; - for ( const auto& i : mp ) { - if ( m.abspid() == i.second->particleID().abspid() ) { - found = true; - break; - } - } - if ( found && msgLevel( MSG::VERBOSE ) ) - verbose() << "Constraint " << getName( m.pid() ) << " was found in tree" << endmsg; - if ( !found ) { - std::ostringstream mess; - mess << "Constraint " << getName( m.pid() ) - << " was not found in tree. Check your options. Maybe also the substitution options."; - return Error( mess.str() ); - } - } - return StatusCode::SUCCESS; -} - -// Declaration of the Tool Factory -DECLARE_COMPONENT( TupleToolDecayTreeFitter ) diff --git a/Phys/DecayTreeTuple/src/TupleToolDecayTreeFitter.h b/Phys/DecayTreeTuple/src/TupleToolDecayTreeFitter.h deleted file mode 100644 index 887527a9ef2660241bea7490217a2c9d24476c02..0000000000000000000000000000000000000000 --- a/Phys/DecayTreeTuple/src/TupleToolDecayTreeFitter.h +++ /dev/null @@ -1,278 +0,0 @@ -/*****************************************************************************\ -* (c) Copyright 2000-2018 CERN for the benefit of the LHCb Collaboration * -* * -* This software is distributed under the terms of the GNU General Public * -* Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". * -* * -* In applying this licence, CERN does not waive the privileges and immunities * -* granted to it by virtue of its status as an Intergovernmental Organization * -* or submit itself to any jurisdiction. * -\*****************************************************************************/ -#pragma once - -/**@class TupleToolDecayTreeFitter - * - History : this tool was written during the study of the b->JpsiX lifetimes. It was not very generic. - * This re-implmentation is hopefully more generic, although it requires several instances of the tool - * to achive the same result. - * - Advice : Most of the output of this code could be saved via the LoKi style lines. - - * - Usage : One can plug this Tool in DecayTreeTuple. It is advised to give it to a branch and not to try to run - * it on all the tree. To get full functionality use several instances. - * Always give it an instance name which will be used as prefix. See example. - * - Configuration : - @code - constrainToOriginVertex = False # save a fit to compute the lifetime. - particlesToConstrain = ["J/psi(1S)"] # chose the particles to mass to constrain. - ExtraName = "" # Additional Prefix (will replace instance name) (inherited from - TupleToolBase) Verbose = False # Fill Lifetime for daughters. (inherited from TupleToolBase) - @endcode - * - * - Outputs: for each fit is saved: - - The status, the chi2, the number of degres of freedom of the fit. - - The fitted mass, mass error for example : Lambda_b0_massConAllDaughters_M ... - - The fitted lifetime, and error : Lambda_b0_taufit_ctau (ctau is given in mm). - * - * - Example: - @code - decay = "B0 -> (^J/psi(1S) -> ^mu+ ^mu-) (^KS0 -> ^pi+ ^pi-)" - bh = 'B0' - tuple.Decay = decay - tuple = DecayTreeTuple("MyTuple") - tuple.ToolList += ["TupleToolGeometry", "TupleToolKinematic", "TupleToolPrimaries", "TupleToolEventInfo" ] - tuple.Branches = { "B" : "["+bh+"]cc : "+decay.replace("^","") } - from Configurables import TupleToolDecayTreeFitter - tuple.B.ToolList += [ "TupleToolDecayTreeFitter/Fit", # just a refit - "TupleToolDecayTreeFitter/MassFit", # fit with J/psi mass constraint - "TupleToolDecayTreeFitter/PVFit" ] # fit with all constraints I can think of - - tuple.B.addTool(TupleToolDecayTreeFitter("MassFit")) - tuple.B.MassFit.constrainToOriginVertex = False - tuple.B.MassFit.daughtersToConstrain = [ "J/psi(1S)" ] - - tuple.B.addTool(TupleToolDecayTreeFitter("PVFit")) - tuple.B.PVFit.Verbose = True - tuple.B.PVFit.constrainToOriginVertex = True - tuple.B.PVFit.daughtersToConstrain = [ "J/psi(1S)", "KS0" ] - - # now two that check for reflections - tuple.B.ToolList += ["TupleToolDecayTreeFitter/SubLambda", "TupleToolDecayTreeFitter/SubLambdabar" ] - subDTF = TupleToolDecayTreeFitter("SubLambda", Verbose=True, - daughtersToConstrain = [ "J/psi(1S)" ], - constrainToOriginVertex=True, - Substitutions={ 'Beauty -> Meson (Strange -> ^pi+ pi-)': 'p+' }) - tuple.B.addTool(subDTF) - tuple.B.addTool(subDTF.clone("SubLambdabar",Substitutions={ 'Beauty -> Meson (Strange -> pi+ ^pi-)': 'p-' })) - - @endcode - * - * - This will produce the following columns for the B (from this tool): - * - B_Fit_status B_Fit_nDOF B_Fit_chi2_B B_Fit_nIter B_Fit_M B_Fit_MERR B_Fit_P B_Fit_PERR - * - B_MassFit_status B_MassFit_nDOF B_MassFit_chi2_B B_MassFit_nIter B_MassFit_M B_MassFit_MERR B_MassFit_P - * B_MassFit_PERR B_PVFit_status B_PVFit_nDOF B_PVFit_chi2_B B_PVFit_nIter B_PVFit_M B_PVFit_MERR B_PVFit_P - * - B_PVFit_PERR B_PVFit_ctau B_PVFit_ctauErr B_PVFit_decayLength B_PVFit_decayLengthErr B_PVFit_J_psi_1S_ctau - * B_PVFit_J_psi_1S_ctauErr B_PVFit_J_psi_1S_decayLength B_PVFit_J_psi_1S_decayLengthErr B_PVFit_KS0_ctau - * B_PVFit_KS0_ctauErr B_PVFit_KS0_decayLength B_PVFit_KS0_decayLengthErr - * - * - One can also hange the PID of some particles in the chain, using the same syntax as SubstitutePID - * - * \sa SubstitutePID - * - * \sa DecayTreeTuple - * - * @author Yasmine Amhis, Matt Needham (original authors), Patrick Koppenburg (re-implementation) - * @date 2010-10-30, 2011-04-01 - * - **/ - -// from Gaudi -#include "GaudiAlg/GaudiTool.h" -#include "GaudiAlg/Tuple.h" -#include "GaudiAlg/TupleObj.h" -#include "GaudiKernel/ToolHandle.h" - -#include "DecayTreeTupleBase/TupleToolBase.h" - -#include "Kernel/Escape.h" -#include "Kernel/GetIDVAlgorithm.h" -#include "Kernel/IDVAlgorithm.h" -#include "Kernel/IParticleDescendants.h" -#include "Kernel/IParticlePropertySvc.h" -#include "Kernel/IParticleTupleTool.h" -#include "Kernel/ISubstitutePID.h" -#include "Kernel/ParticleProperty.h" - -#include "TrackInterfaces/ITrackStateProvider.h" - -#include "DecayTreeFitter/Fitter.h" - -#include "Event/Particle.h" -#include "Event/RecVertex.h" - -#include "LoKi/ParticleProperties.h" - -// boost -#include -#include - -// STL -#include -#include -#include -#include - -struct IParticleDescendants; - -namespace LHCb { - class ParticleID; - class IParticlePropertySvc; - class VertexBase; - class Particle; - class RecVertex; - class DecayTree; -} // namespace LHCb -namespace DecayTreeFitter { - class Fitter; -} - -struct IDVAlgorithm; -/** @class TupleToolDecayTreeFitter TupleToolDecayTreeFitter.h - * - * Yasmine Amhis and Matt Needham - * 30-10-10 - */ -class TupleToolDecayTreeFitter : public TupleToolBase, virtual public IParticleTupleTool { - -private: - typedef std::map SubstitutionMap; - typedef std::map> TupleMap; ///< temporary storage of tuple data - -public: - /// Standard constructor - TupleToolDecayTreeFitter( const std::string& type, const std::string& name, const IInterface* parent ); - - ~TupleToolDecayTreeFitter() = default; ///< Destructor - - StatusCode initialize() override; - - StatusCode finalize() override; - - StatusCode fill( const LHCb::Particle*, const LHCb::Particle*, const std::string&, Tuples::Tuple& ) override; - -private: - /// Fill inforation for a given origin vertex - StatusCode fit( DecayTreeFitter::Fitter& fitter, const LHCb::Particle* P, const LHCb::VertexBase* pv, - const std::string& prefix, TupleMap& tMap ) const; - - /// Fill lifetime information - /// Fill fit inforation for top decay - StatusCode fillDecay( const DecayTreeFitter::Fitter& fitter, const std::string& prefix, TupleMap& tMap ) const; - - /// Fill lifetime information - StatusCode fillLT( const DecayTreeFitter::Fitter& fitter, const LHCb::Particle* P, const std::string& prefix, - TupleMap& tMap ) const; - - /// Fill momentum and mass information - StatusCode fillMomentum( const DecayTreeFitter::Fitter& fitter, const LHCb::Particle* P, const std::string& prefix, - TupleMap& tMap ) const; - - /// Fill PV information - StatusCode fillPV( const LHCb::VertexBase* pv, const std::string& prefix, TupleMap& tMap ) const; - - /// Fill lifetime information for non stable daughters - StatusCode fillDaughters( const DecayTreeFitter::Fitter& fitter, const LHCb::Particle* P, const std::string& prefix, - TupleMap& tMap ) const; - - /// Fill lifetime information for non stable daughters - StatusCode fillStableDaughters( const DecayTreeFitter::Fitter& fitter, const LHCb::Particle* P, - const std::string& prefix, TupleMap& tMap ) const; - - /// Fill updated tracks momentum - StatusCode fillTracksMomentum( const DecayTreeFitter::Fitter& fitter, const LHCb::Particle* P, - const std::string& prefix, TupleMap& tMap ) const; - - /// actual filling of tuple - StatusCode fillTuple( TupleMap& tMap, Tuples::Tuple& tuple, const std::string& prefix ); - - /// insert helper method - StatusCode insert( const std::string& leaf, const double val, TupleMap& tMap ) const; - - std::string getName( const int id ) const; ///< name of particle - - /// origin vertex - std::vector originVertex( const LHCb::Particle*, const LHCb::Particle* ) const; - - /// same PV? - bool samePV( const LHCb::VertexBase*, const LHCb::VertexBase* ) const; - - /// sort tracks into a set - std::set sortedTracks( const LHCb::VertexBase* ) const; - - /// substitutions - StatusCode substitute( LHCb::DecayTree& tree ); - - /// checkMassConstraints - StatusCode checkMassConstraints( const LHCb::DecayTree& tree ); - - /// Get the TES location for a data object - template - inline std::string tesLocation( const TYPE* obj ) const { - return ( obj && obj->parent() && obj->parent()->registry() ? obj->parent()->registry()->identifier() : "NotInTES" ); - } - - /// Test if a given PID code is veto'ed - inline bool isVetoed( const int id ) const { - return ( !m_vetoPIDs.empty() && std::find( m_vetoPIDs.begin(), m_vetoPIDs.end(), id ) != m_vetoPIDs.end() ); - } - - /// Compare two maps - inline bool checkTupleKeys( const TupleMap& r ) { - bool OK = true; - if ( m_firstTupleKeys.size() != r.size() ) { - Error( "Maps have different sizes" ).ignore(); - OK = false; - } - auto i = m_firstTupleKeys.begin(); - auto j = r.begin(); - for ( ; j != r.end(); ++i, ++j ) { - // compare key names - if ( *i != j->first ) { - std::ostringstream mess; - mess << "Tuple entry error : " << *i << " != " << j->first; - Error( mess.str() ).ignore(); - OK = false; - } - } - return OK; - } - -private: - std::string m_pvLocation; ///< PV location to be used. If empty, take context-dependent default - - IDVAlgorithm* m_dva = nullptr; - - std::vector m_massConstraints; - std::vector m_massConstraintsPids; - - bool m_constrainToOriginVertex; ///< Constrain to Origin Vertex for lifetime - - LHCb::IParticlePropertySvc* m_ppSvc = nullptr; - IParticleDescendants* m_particleDescendants = nullptr; - - /// mapping : { 'decay-component' : "new-pid" } (property) - ISubstitutePID::SubstitutionMap m_map; // mapping : { 'decay-component' : "new-pid" } - /// Substitute Tool - ISubstitutePID* m_substitute = nullptr; - bool m_storeAnyway; ///< Store PV even if a refitted version is already the best PV (i.e store twice) - bool m_updateDaughters; ///< Store updated momenta of tracks in the decay tree - ToolHandle m_stateprovider{"TrackStateProvider"}; - bool m_first{true}; ///< This is the first candidate - bool m_firstTupleFill{true}; ///< Flag for the first tuple filling - - std::vector m_firstTupleKeys; ///< cache the keys for the first tuple map - - /// List of PID codes to veto filling for - std::vector m_vetoPIDs; - - /// Use full decay tree in branch names - bool m_useFullTreeInName; -}; diff --git a/Phys/DecayTreeTuple/src/TupleToolDira.cpp b/Phys/DecayTreeTuple/src/TupleToolDira.cpp deleted file mode 100755 index 2d4b9ded4b600ff095c5bd05426466ffd069f1d1..0000000000000000000000000000000000000000 --- a/Phys/DecayTreeTuple/src/TupleToolDira.cpp +++ /dev/null @@ -1,171 +0,0 @@ -/*****************************************************************************\ -* (c) Copyright 2000-2018 CERN for the benefit of the LHCb Collaboration * -* * -* This software is distributed under the terms of the GNU General Public * -* Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". * -* * -* In applying this licence, CERN does not waive the privileges and immunities * -* granted to it by virtue of its status as an Intergovernmental Organization * -* or submit itself to any jurisdiction. * -\*****************************************************************************/ - -#include "DecayTreeTupleBase/TupleToolBase.h" - -#include "Kernel/IParticleTupleTool.h" // Interface -#include -#include -#include - -#include "Event/Particle.h" -#include "Event/RecVertex.h" -#include "Event/Vertex.h" - -#include "GaudiAlg/Tuple.h" -#include "GaudiAlg/TupleObj.h" - -#include "Math/SMatrix.h" - -/* - * 2010-09-06 : Fatima Soomro - */ -class TupleToolDira : public TupleToolBase, virtual public IParticleTupleTool { - -private: - typedef ROOT::Math::SMatrix> SymMatrix10x10; - -public: - /// Standard constructor - TupleToolDira( const std::string& type, const std::string& name, const IInterface* parent ); - - virtual ~TupleToolDira(){}; ///< Destructor - - StatusCode initialize() override; - - StatusCode fill( const LHCb::Particle*, const LHCb::Particle*, const std::string&, Tuples::Tuple&, - IGeometryInfo const& ) override; - -private: - StatusCode fillDIRAError( const LHCb::VertexBase* primVtx, const LHCb::Particle* P, const std::string head, - Tuples::Tuple& tuple ) const; - void calculateDIRAError( const LHCb::Particle*, const LHCb::VertexBase*, double&, double& ) const; - - // IContextTool* m_context; - IDVAlgorithm* m_context; -}; - -using namespace LHCb; - -//============================================================================= -// Standard constructor, initializes variables -//============================================================================= -TupleToolDira::TupleToolDira( const std::string& type, const std::string& name, const IInterface* parent ) - : TupleToolBase( type, name, parent ) - -{ - declareInterface( this ); -} - -StatusCode TupleToolDira::initialize() { - const StatusCode sc = TupleToolBase::initialize(); - if ( sc.isFailure() ) return sc; - - m_context = Gaudi::Utils::getIDVAlgorithm( contextSvc(), this ); - if ( !m_context ) return Error( "Could not get parent DVAlgorithm", StatusCode::FAILURE ); - - return sc; -} - -StatusCode TupleToolDira::fill( const Particle* mother, const Particle* P, const std::string& head, - Tuples::Tuple& tuple, IGeometryInfo const& geometry ) { - Assert( P && mother && m_context, "This should not happen, you are inside TupleToolDira.cpp :(" ); - - if ( isPureNeutralCalo( P ) ) - return Warning( "Will not fill geometry tuple for calo neutrals. No worry.", StatusCode::SUCCESS, 10 ); - if ( mother != P || P->isBasicParticle() ) return StatusCode::SUCCESS; - - const VertexBase* motherPV = m_context->bestVertex( mother, geometry ); - if ( !motherPV ) { return Warning( "Could not find related PV" ); } - - return fillDIRAError( motherPV, mother, head, tuple ); -} - -//========================================================================= -// fill vertex stuff -//========================================================================= -StatusCode TupleToolDira::fillDIRAError( const VertexBase* primVtx, const Particle* P, const std::string head, - Tuples::Tuple& tuple ) const { - - const VertexBase* evtx = P->endVertex(); - - if ( !evtx ) { return Error( "Cannot retrieve the end vertex for " + head ); } - - double diraerr( 0 ), dira( 0 ); - calculateDIRAError( P, primVtx, dira, diraerr ); - - bool test = true; - test &= tuple->column( head + "_DiraAngleError", diraerr / ( std::sqrt( 1 - dira * dira ) ) ); - test &= tuple->column( head + "_DiraCosError", diraerr ); - test &= tuple->column( head + "_DiraAngle", std::acos( dira ) ); - test &= tuple->column( head + "_DiraCos", dira ); - - return StatusCode( test ); -} - -void TupleToolDira::calculateDIRAError( const Particle* P, const VertexBase* primVtx, double& dira, - double& diraerr ) const { - - const Gaudi::SymMatrix7x7& covMother = P->covMatrix(); - const Gaudi::SymMatrix3x3& covPrim = primVtx->covMatrix(); - SymMatrix10x10 Cov; - - for ( int i = 0; i < 7; ++i ) { - for ( int j = 0; j < 7; ++j ) { Cov( i, j ) = covMother( i, j ); } - } - - for ( int i = 7; i < 10; ++i ) { - for ( int j = 7; j < 10; ++j ) { Cov( i, j ) = covPrim( i - 7, j - 7 ); } - } - - for ( int i = 7; i < 10; ++i ) { - for ( int j = 0; j < 7; ++j ) { - Cov( i, j ) = 0.0; - Cov( j, i ) = 0.0; - } - } - - const Gaudi::XYZVector vectord = P->endVertex()->position() - primVtx->position(); - const Gaudi::XYZVector& vectorp = P->momentum().Vect(); - - double vecd[3] = {vectord.x(), vectord.y(), vectord.z()}; - double vecp[3] = {vectorp.x(), vectorp.y(), vectorp.z()}; - - const double magd = std::sqrt( vectord.Mag2() ); - const double magp = std::sqrt( vectorp.Mag2() ); - - ROOT::Math::SMatrix gradVec; - gradVec( 6, 0 ) = 0.0; - - for ( int i = 0; i < 3; ++i ) { - double gp = vecd[i] * magp * magp; - double gd = vecp[i] * magd * magd; - - for ( int j = 0; j < 3; ++j ) { - gp -= vecd[j] * vecp[j] * vecp[i]; - gd -= vecp[j] * vecd[j] * vecd[i]; - } - gradVec( i + 3, 0 ) = gp / ( magd * magp * magp * magp ); - gradVec( i, 0 ) = gd / ( magp * magd * magd * magd ); - gradVec( i + 7, 0 ) = -gd / ( magp * magd * magd * magd ); - } - - const Gaudi::SymMatrix1x1 diraErrSq = ROOT::Math::SimilarityT( gradVec, Cov ); - - diraerr = std::sqrt( diraErrSq( 0, 0 ) ); - - dira = ( vectord.Dot( vectorp ) ) / ( magp * magd ); - - return; -} - -// Declaration of the Tool Factory -DECLARE_COMPONENT( TupleToolDira ) diff --git a/Phys/DecayTreeTuple/src/TupleToolGeometry.cpp b/Phys/DecayTreeTuple/src/TupleToolGeometry.cpp deleted file mode 100644 index e1ebbc2b260a94404df42dc20aa2177ff77fbad9..0000000000000000000000000000000000000000 --- a/Phys/DecayTreeTuple/src/TupleToolGeometry.cpp +++ /dev/null @@ -1,497 +0,0 @@ -/*****************************************************************************\ -* (c) Copyright 2000-2020 CERN for the benefit of the LHCb Collaboration * -* * -* This software is distributed under the terms of the GNU General Public * -* Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". * -* * -* In applying this licence, CERN does not waive the privileges and immunities * -* granted to it by virtue of its status as an Intergovernmental Organization * -* or submit itself to any jurisdiction. * -\*****************************************************************************/ - -#include "DecayTreeTupleBase/TupleToolBase.h" - -#include "Kernel/GetIDVAlgorithm.h" -#include "Kernel/IDVAlgorithm.h" -#include "Kernel/IDistanceCalculator.h" -#include "Kernel/IPVReFitter.h" -#include "Kernel/IParticleTupleTool.h" - -#include "Event/Particle.h" - -#include "GaudiAlg/Tuple.h" -#include "GaudiAlg/TupleObj.h" - -/** - * \brief Fill geometry related information for DecayTreeTuple - * - * - head_MINIP : minimum impact parameter on any PV - * - head_MINIPCHI2 : minimum chi2 IP on all PVs - * - head_ENDVERTEX_[X|Y|Z] : decay vertex position for composite particles - * - head_ENDVERTEX_[X|Y|Z]ERR : decay vertex position error estimate for composite particles - * - head_ENDVERTEX_CHI2 : decay vertex chi2 - * - head_ENDVERTEX_NDOF : decay vertex nDoF - * - head_OWNPV_[X|Y|Z] : related primary vertex position - * - head_OWNPV_[X|Y|Z]ERR : related primary vertex position error estimate for composite particles - * - head_OWNPV_CHI2 : related primary vertex chi2 - * - head_OWNPV_NDOF : related primary vertex nDoF - * - head_IP_OWNPV : impact parameter with respect to the PhysDesktop::relatedVertex() considered particle - * - head_IPCHI2_OWNPV : impact parameter chi2 with respect to the relatedVertex() considered particle - * - head_FD_OWNPV : flight distance of composite particle wrt. the relatedVertex() considered particle - * - head_FDCHI2_OWNPV : flight distance significance in units of chi2 wrt. the relatedVertex() considered particle - * - head_DIRA_OWNPV : direction angle wrt. the PhysDesktop::relatedVertex() considered particle - * - * If Verbose is true: - * - * - head_TOPPV_[X|Y|Z] : PhysDesktop::relatedVertex() of the top of decay chain position - * - head_TOPPV_[X|Y|Z]ERR : PhysDesktop::relatedVertex() of the top of decay chain position error estimate - * - head_TOPPV_CHI2 : PhysDesktop::relatedVertex() of the top of decay chain chi2 - * - head_TOPPV_NDOF : PhysDesktop::relatedVertex() of the top of decay chain nDoF - * - head_IP_TOPPV : impact parameter with respect to the PhysDesktop::relatedVertex() of the top of decay chain - * - head_IPCHI2_TOPPV : impact parameter chi2 with respect to the relatedVertex() of the top of decay chain - * - head_FD_TOPPV : flight distance of composite particle wrt. the relatedVertex() of the top of decay chain - * - head_FDCHI2_TOPPV : flight distance significance in units of chi2 wrt. - * the PhysDesktop::relatedVertex() of the top of decay chain - * - head_DIRA_TOPPV : direction angle wrt. the relatedVertex() of the top of decay chain - * - * - head_ORIVX_[X|Y|Z] : ancestor's related primary vertex position (when applicable) - * - head_ORIVX_[X|Y|Z]ERR : ancestor's related primary vertex position error estimate (when applicable) - * - head_ORIVX_CHI2 : ancestor's related primary vertex chi2 (when applicable) - * - head_ORIVX_NDOF : ancestor's related primary vertex nDoF (when applicable) - * - head_IP_ORIVX : impact parameter with respect to the ancestor's vertex (when applicable) - * - head_IPCHI2_ORIVX : impact parameter chi2 with respect to the ancestor's vertex (when applicable) - * - head_FD_ORIVX : flight distance of composite particle wrt. the ancestor's vertex (when applicable) - * - head_FDCHI2_ORIVX : flight distance significance in units of chi2 wrt. ancestor's vertex (when applicable) - * - head_DIRA_ORIVX : direction angle wrt. ancestor's vertex (when applicable) - * - * Finally some arrays with FillMultiPV - * - head_AllIP : IP wrt to all PVs - * - head_AllIPchi2 : IPchi2 wrt to all Vs - * - head_AllDIRA : DIRA wrt to all PVs - * - * \sa DecayTreeTuple - * - * @author Jeremie Borel - * @date 2007-11-07 - */ -class TupleToolGeometry : public TupleToolBase, virtual public IParticleTupleTool { - -public: - /// Standard constructor - TupleToolGeometry( const std::string& type, const std::string& name, const IInterface* parent ); - - StatusCode initialize() override; - - StatusCode fill( const LHCb::Particle*, const LHCb::Particle*, const std::string&, Tuples::Tuple&, - IGeometryInfo const& ) override; - -private: - /// fill end vertex stuff - StatusCode fillVertexFull( const LHCb::VertexBase* vtx, const LHCb::Particle* P, const std::string& head, - const std::string& vtx_name, Tuples::Tuple&, IGeometryInfo const& geometry ) const; - - /// origin vertex - const LHCb::VertexBase* originVertex( const LHCb::Particle* top, const LHCb::Particle* P ) const; - /// fill related pV stuff - StatusCode fillBPV( const LHCb::VertexBase* primVtx, const LHCb::Particle* P, const std::string& prefix, - Tuples::Tuple& tuple, IGeometryInfo const& geometry, const std::string& trail = "" ) const; - - /// fill min IP - StatusCode fillMinIP( const LHCb::Particle* P, const std::string& prefix, Tuples::Tuple& tuple, - IGeometryInfo const& geometry ) const; - - /// fill end vertex stuff - StatusCode fillVertex( const LHCb::VertexBase* vtx, const std::string& vtx_name, Tuples::Tuple& ) const; - - /// fill flight - StatusCode fillFlight( const LHCb::VertexBase* oriVtx, const LHCb::Particle* P, const std::string& prefix, - Tuples::Tuple& tuple, const std::string& trail = "" ) const; - - /// Compute DIRA - double dira( const LHCb::VertexBase* oriVtx, const LHCb::Particle* P ) const; - -private: - const IDistanceCalculator* m_dist = nullptr; - - bool m_refitPVs; - bool m_fillMultiPV; ///< fill multiPV variables - - // bool m_fillMother; - - IDVAlgorithm* m_dva = nullptr; - - IPVReFitter* m_pvReFitter = nullptr; - std::string m_pvReFitterName; -}; - -using namespace LHCb; - -// Declaration of the Tool Factory -// actually acts as a using namespace TupleTool -DECLARE_COMPONENT( TupleToolGeometry ) - -//============================================================================= -// Standard constructor, initializes variables -//============================================================================= -TupleToolGeometry::TupleToolGeometry( const std::string& type, const std::string& name, const IInterface* parent ) - : TupleToolBase( type, name, parent ) { - declareInterface( this ); - declareProperty( "RefitPVs", m_refitPVs = false, "Refit PVs when doing next best PV checks" ); - declareProperty( "PVReFitter", m_pvReFitterName = "LoKi::PVReFitter:PUBLIC", - "PV refitter algorithm name (':PUBLIC' at end of algo name makes sure a public instance is used)" ); - declareProperty( "FillMultiPV", m_fillMultiPV = false, "Fill Multi PV arrays" ); - - // declareProperty("FillMother",m_fillMother=true, - // "Turn false if the mother is expected to be NULL, will not fill mother PV info"); - // replaced by Verbose - - // setProperty( "OutputLevel", 1 ); -} - -//============================================================================= - -StatusCode TupleToolGeometry::initialize() { - const StatusCode sc = TupleToolBase::initialize(); - if ( sc.isFailure() ) return sc; - - m_dva = Gaudi::Utils::getIDVAlgorithm( contextSvc(), this ); - if ( !m_dva ) return Error( "Couldn't get parent DVAlgorithm" ); - - m_dist = m_dva->distanceCalculator(); - if ( !m_dist ) { return Error( "Unable to retrieve the IDistanceCalculator tool" ); } - - m_pvReFitter = tool( m_pvReFitterName, this ); - if ( !m_pvReFitter ) { return Error( "Unable to retrieve IPVReFitter instance" ); } - - return sc; -} - -//============================================================================= -StatusCode TupleToolGeometry::fill( const Particle* mother, const Particle* P, const std::string& head, - Tuples::Tuple& tuple, IGeometryInfo const& geometry ) { - const auto prefix = fullName( head ); - - StatusCode sc = StatusCode::SUCCESS; - - Assert( P && m_dist && m_dva, "No mother or particle, or tools misconfigured." ); - - if ( isPureNeutralCalo( P ) ) - return Warning( "Will not fill geometry tuple for neutral Calo particles. No worry", StatusCode::SUCCESS, 10 ); - if ( msgLevel( MSG::VERBOSE ) ) - verbose() << "TupleToolGeometry::fill " << mother << " " << P << " " << prefix << endmsg; - - // fill min IP - if ( isVerbose() || m_fillMultiPV ) { - sc = fillMinIP( P, prefix, tuple, geometry ); - if ( sc.isFailure() ) { return Warning( "Could not fill minimum IP", StatusCode::FAILURE, 1 ); } - } - //========================================================================= - // fill end vertex info - //========================================================================= - if ( P->isBasicParticle() ) { - if ( msgLevel( MSG::VERBOSE ) ) verbose() << "No need to look for endVertex of " << prefix << endmsg; - } else { - //========================================================================= - if ( msgLevel( MSG::VERBOSE ) && P->endVertex() ) { // https://its.cern.ch/jira/browse/LHCBPS-598 - verbose() << "Before cast : " << P->endVertex() << endmsg; - verbose() << "Container " << P->endVertex()->parent()->registry()->identifier() << " key " - << P->endVertex()->key() << endmsg; - } - - const auto evtx = P->endVertex(); - if ( !evtx ) { - fatal() << "Can't retrieve the end vertex for " << prefix - << ". TupleToolGeometry cannot act on such a particle. Define a branch" << endmsg; - fatal() << "See https://twiki.cern.ch/twiki/bin/view/LHCb/DaVinciTutorial7#Branches" << endmsg; - return StatusCode::FAILURE; - } - - if ( msgLevel( MSG::VERBOSE ) ) { // https://its.cern.ch/jira/browse/LHCBPS-598 - verbose() << "End Vertex : " << *evtx << endmsg; - verbose() << "Container " << evtx->parent()->registry()->identifier() << " key " << evtx->key() << endmsg; - } - // end vertex - sc = fillVertex( evtx, prefix + "_ENDVERTEX", tuple ); - if ( sc.isFailure() ) { return Warning( "Could not fill Endvertex " + prefix, sc, 1 ); } - } - - const VertexBase* aPV = nullptr; - - //========================================================================= - // fill IP for Particles's Own BPV.. if it isn't the mother! - //========================================================================= - if ( true ) { - aPV = m_dva->bestVertex( P, geometry ); - if ( aPV && msgLevel( MSG::VERBOSE ) ) verbose() << "Got best PV of particle : " << *aPV << endmsg; - sc = fillVertexFull( aPV, P, prefix, "_OWNPV", tuple, geometry ); - if ( sc.isFailure() ) { return Warning( "Could not fill best PV", sc, 1 ); } - } - //========================================================================= - // fill IP for head of chain's own BPV - //========================================================================= - if ( mother && isVerbose() ) { - aPV = m_dva->bestVertex( mother, geometry ); - if ( aPV && msgLevel( MSG::VERBOSE ) ) verbose() << "Got best PV of mother : " << *aPV << endmsg; - sc = fillVertexFull( aPV, P, prefix, "_TOPPV", tuple, geometry ); - if ( sc.isFailure() ) { return Warning( "Could not fill TOP PV", sc, 1 ); } - } - //========================================================================= - // fill IP wrt Mother's decay vertex, if it isn't the mother! - //========================================================================= - if ( mother && mother != P ) { - aPV = originVertex( mother, P ); - if ( aPV && msgLevel( MSG::VERBOSE ) ) verbose() << "Got originVertex of mother : " << *aPV << endmsg; - if ( isVerbose() ) { - sc = fillVertexFull( aPV, P, prefix, "_ORIVX", tuple, geometry ); - if ( sc.isFailure() ) { return Warning( "Could not fill VertexFull " + prefix, sc, 1 ); } - } else { - sc = fillVertex( aPV, prefix + "_ORIVX", tuple ); - if ( sc.isFailure() ) { return Warning( "Could not fill ORIVX", sc, 1 ); } - if ( !P->isBasicParticle() ) sc = fillFlight( aPV, P, prefix, tuple, "_ORIVX" ); - if ( sc.isFailure() ) { return Warning( "Could not fill Flight", sc, 1 ); } - } - - if ( sc.isFailure() ) return sc; - } - //========================================================================= - - return sc; -} - -//========================================================================= -// Fill Everything for this vertex for related PV -//========================================================================= -StatusCode TupleToolGeometry::fillVertexFull( const LHCb::VertexBase* vtx, const LHCb::Particle* P, - const std::string& prefix, const std::string& vtx_name, - Tuples::Tuple& tuple, IGeometryInfo const& geometry ) const { - if ( !vtx ) ++counter( "Can't retrieve the " + vtx_name + " vertex for " + prefix ); - auto sc = fillVertex( vtx, prefix + vtx_name, tuple ); - if ( sc.isFailure() ) { return Warning( "Could not fill Endvertex " + prefix, sc, 1 ); } - sc = fillBPV( vtx, P, prefix, tuple, geometry, vtx_name ); - if ( sc.isFailure() ) { return Warning( "Could not fillBPV " + prefix, sc, 1 ); } - if ( !P->isBasicParticle() ) { - sc = fillFlight( vtx, P, prefix, tuple, vtx_name ); - if ( sc.isFailure() ) Warning( "Error in fillFlight " + prefix, StatusCode::SUCCESS, 1 ).ignore(); - } - return sc; -} - -//========================================================================= -// Fill PV for related PV -//========================================================================= -StatusCode TupleToolGeometry::fillBPV( const VertexBase* primVtx, const Particle* P, const std::string& prefix, - Tuples::Tuple& tuple, IGeometryInfo const& geometry, - const std::string& trail ) const { - bool test = true; - - double ip{-999}, chi2{-999}; - - if ( !primVtx ) { - ++counter( "No BPV for " + prefix ); - } else { - auto distance_ok = true; - distance_ok &= m_dist->distance( P, primVtx, ip, chi2, geometry ); - if ( !distance_ok ) { - Warning( "Could not compute distance for " + prefix ).ignore(); - ip = chi2 = -1; - } - } - - test &= tuple->column( prefix + "_IP" + trail, ip ); - test &= tuple->column( prefix + "_IPCHI2" + trail, chi2 ); - - if ( !test ) Warning( "Error in fillBPV " + prefix, StatusCode::SUCCESS, 1 ).ignore(); - return StatusCode( test ); -} -//========================================================================= -// Fill PV for all PV -//========================================================================= -StatusCode TupleToolGeometry::fillMinIP( const Particle* P, const std::string& prefix, Tuples::Tuple& tuple, - IGeometryInfo const& geometry ) const { - bool test = true; - // minimum IP - double ipmin = -1; - double minchi2 = -1; - - double ipminnextbest = -1; - double minchi2nextbest = -1; - - if ( msgLevel( MSG::VERBOSE ) ) verbose() << "Looking for Min IP" << endmsg; - const auto PVS = m_dva->primaryVertices(); - if ( msgLevel( MSG::VERBOSE ) ) verbose() << "PV size: " << PVS.size() << endmsg; - - std::vector ips, ipchi2s, diras; - if ( !PVS.empty() ) { - if ( msgLevel( MSG::VERBOSE ) ) - verbose() << "Filling IP " << prefix + "_MINIP : " << P << " PVs:" << PVS.size() << endmsg; - - for ( const auto& pv : PVS ) { - RecVertex newPV( *pv ); - if ( m_refitPVs ) { - - StatusCode scfit = m_pvReFitter->remove( P, &newPV, geometry ); - if ( !scfit ) { - Warning( "ReFitter fails!", StatusCode::SUCCESS, 10 ).ignore(); - continue; - } - } - - double ip{0}, chi2{0}; - - auto newPVPtr = (LHCb::VertexBase*)&newPV; - const auto test2 = m_dist->distance( P, newPVPtr, ip, chi2, geometry ); - ips.push_back( ip ); - ipchi2s.push_back( chi2 ); - if ( P->endVertex() ) - diras.push_back( dira( newPVPtr, P ) ); - else - diras.push_back( -999. ); - if ( test2 && isVerbose() ) { - if ( ip < ipmin || ipmin < 0. ) { - ipminnextbest = ipmin; - ipmin = ip; - } else { - if ( ip < ipminnextbest || ipminnextbest < 0 ) { ipminnextbest = ip; } - } - - if ( chi2 < minchi2 || minchi2 < 0. ) { - minchi2nextbest = minchi2; - minchi2 = chi2; - } else { - if ( chi2 < minchi2nextbest || minchi2nextbest < 0 ) { minchi2nextbest = chi2; } - } - } - } - } - if ( isVerbose() ) { - if ( msgLevel( MSG::VERBOSE ) ) { - verbose() << "Filling IP " << prefix + "_MINIP " << ipmin << " at " << minchi2 << endmsg; - verbose() << "Filling IP next best " << prefix + "_MINIP " << ipminnextbest << " at " << minchi2nextbest - << endmsg; - } - test &= tuple->column( prefix + "_MINIP", ipmin ); - test &= tuple->column( prefix + "_MINIPCHI2", minchi2 ); - - test &= tuple->column( prefix + "_MINIPNEXTBEST", ipminnextbest ); - test &= tuple->column( prefix + "_MINIPCHI2NEXTBEST", minchi2nextbest ); - } - if ( m_fillMultiPV ) { - if ( msgLevel( MSG::VERBOSE ) ) verbose() << "Flling AllIP with " << ips.size() << " PVS" << endmsg; - test &= tuple->farray( prefix + "_AllIP", ips, "nPV", m_maxPV ); - test &= tuple->farray( prefix + "_AllIPchi2", ipchi2s, "nPV", m_maxPV ); - test &= tuple->farray( prefix + "_AllDIRA", diras, "nPV", m_maxPV ); - // -------------------------------------------------- - } - - if ( msgLevel( MSG::VERBOSE ) ) verbose() << "Return from fillMinIP: " << prefix << " " << test << endmsg; - if ( !test ) - Warning( "Error in fillMinIP", StatusCode::FAILURE, 1 ).ignore( /* AUTOMATICALLY ADDED FOR gaudi/Gaudi!763 */ ); - return StatusCode( test ); -} -//========================================================================= -// fill vertex stuff -//========================================================================= -StatusCode TupleToolGeometry::fillVertex( const LHCb::VertexBase* vtx, const std::string& vtx_name, - Tuples::Tuple& tuple ) const { - bool test = true; - - // decay vertex information: - if ( !vtx ) { - Gaudi::XYZPoint pt( -999., -999., -999. ); // arbitrary point - test &= tuple->column( vtx_name + "_", pt ); - test &= tuple->column( vtx_name + "_XERR", -999. ); - test &= tuple->column( vtx_name + "_YERR", -999. ); - test &= tuple->column( vtx_name + "_ZERR", -999. ); - test &= tuple->column( vtx_name + "_CHI2", -999. ); - test &= tuple->column( vtx_name + "_NDOF", -1 ); - test &= tuple->matrix( vtx_name + "_COV_", Gaudi::SymMatrix3x3() ); - } else { - const auto& m = vtx->covMatrix(); - test &= tuple->column( vtx_name + "_", vtx->position() ); - test &= tuple->column( vtx_name + "_XERR", std::sqrt( m( 0, 0 ) ) ); - test &= tuple->column( vtx_name + "_YERR", std::sqrt( m( 1, 1 ) ) ); - test &= tuple->column( vtx_name + "_ZERR", std::sqrt( m( 2, 2 ) ) ); - test &= tuple->column( vtx_name + "_CHI2", vtx->chi2() ); - test &= tuple->column( vtx_name + "_NDOF", vtx->nDoF() ); - test &= tuple->matrix( vtx_name + "_COV_", m ); - } - - // -------------------------------------------------- - if ( !test ) Warning( "Error in fillVertex " + vtx_name, StatusCode::SUCCESS, 1 ).ignore(); - return StatusCode( test ); -} -//========================================================================= -// fill flight distance, angle... -//========================================================================= -StatusCode TupleToolGeometry::fillFlight( const VertexBase* oriVtx, const Particle* P, const std::string& prefix, - Tuples::Tuple& tuple, const std::string& trail ) const { - bool test = true; - // -------------------------------------------------- - if ( !oriVtx ) { - test &= tuple->column( prefix + "_FD" + trail, -999. ); - test &= tuple->column( prefix + "_FDCHI2" + trail, -999. ); - test &= tuple->column( prefix + "_DIRA" + trail, -999. ); - } else { - - // flight distance - double dist{0}, chi2{0}; - const StatusCode sc = m_dist->distance( oriVtx, P->endVertex(), dist, chi2 ); - - // always fill variables to make sure branches do not change ... - test &= tuple->column( prefix + "_FD" + trail, sc ? dist : -999 ); - test &= tuple->column( prefix + "_FDCHI2" + trail, sc ? chi2 : -999 ); - // -------------------------------------------------- - // cosine of (flight distance) dot (momentum): - // find the origin vertex. Either the primary or the origin in the - // decay - test &= tuple->column( prefix + "_DIRA" + trail, sc ? dira( oriVtx, P ) : -999 ); - - if ( sc.isFailure() ) Warning( "Could not compute FD/DIRA for " + prefix ).ignore(); - } - - if ( !test ) Warning( "Error in fillFlight " + prefix, StatusCode::SUCCESS, 1 ).ignore(); - return StatusCode( test ); -} -// ===================================================== -// find origin vertex in the decay chain -// ===================================================== -const VertexBase* TupleToolGeometry::originVertex( const Particle* top, const Particle* P ) const { - // this used to pass back zero if P was a basic particle. - // I don't think that's necessary. R Lambert 2009-08-14 - if ( top == P || top->isBasicParticle() ) return nullptr; - - const auto& dau = top->daughters(); - if ( dau.empty() ) return nullptr; - - for ( const auto& d : dau ) { - if ( P == d ) { // I found the daughter - if ( msgLevel( MSG::VERBOSE ) ) verbose() << "It's a daughter, retrning mother's endvertex : " << endmsg; - return top->endVertex(); - } - } - - // vertex not yet found, get deeper in the decay: - for ( const auto& d : dau ) { - if ( P != d && !d->isBasicParticle() ) { - const auto vv = originVertex( d, P ); - if ( msgLevel( MSG::VERBOSE ) ) verbose() << "Went up : " << vv << endmsg; - if ( vv ) return vv; - } - } - return nullptr; -} - -double TupleToolGeometry::dira( const LHCb::VertexBase* oriVtx, const LHCb::Particle* P ) const { - if ( !P || !oriVtx ) { - Exception( "Wrong use of dira" ); - return -1501.; - } - const auto evtx = P->endVertex(); - if ( !evtx ) { - Warning( "Cannot find end vertex", StatusCode::SUCCESS, 1 ).ignore(); - return -999.; - } - const auto A = P->momentum().Vect(); - const auto B = evtx->position() - oriVtx->position(); - return A.Dot( B ) / std::sqrt( A.Mag2() * B.Mag2() ); -} diff --git a/Phys/DecayTreeTuple/src/TupleToolHOP.cpp b/Phys/DecayTreeTuple/src/TupleToolHOP.cpp deleted file mode 100644 index 4b68e324cda5a6b6685a06b778968d277f784b21..0000000000000000000000000000000000000000 --- a/Phys/DecayTreeTuple/src/TupleToolHOP.cpp +++ /dev/null @@ -1,531 +0,0 @@ -/*****************************************************************************\ -* (c) Copyright 2000-2018 CERN for the benefit of the LHCb Collaboration * -* * -* This software is distributed under the terms of the GNU General Public * -* Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". * -* * -* In applying this licence, CERN does not waive the privileges and immunities * -* granted to it by virtue of its status as an Intergovernmental Organization * -* or submit itself to any jurisdiction. * -\*****************************************************************************/ - -#include "DecayTreeTupleBase/TupleToolBase.h" - -#include "Kernel/GetIDVAlgorithm.h" -#include "Kernel/IDVAlgorithm.h" -#include "Kernel/IParticlePropertySvc.h" -#include "Kernel/IParticleTupleTool.h" -#include "Kernel/ParticleProperty.h" - -#include "Event/Particle.h" - -#include "GaudiAlg/Tuple.h" -#include "GaudiAlg/TupleObj.h" - -/** - * \brief Fill geometry related information for DecayTreeTuple - * - * - mother_HOP : HOP correction, the ratio between the Pt (with respecto to the mothers direction of flight) of - * electrons and non-electrons - * - mother_HOP_MASS : Mother mass obtained by scalling the electrons P by the hop factor - * - mother_ELECTRON_MASS : Mass obtained by summing the four-momenta of all electrons - * - * \sa DecayTreeTuple - * - * Implementation file for class : HOPTupleTool - * - * 2016-05-20 : Carla Marin Benito, Vinicius Franco Lima - * - * - * This Tool Implements the variables described in LHCb Note: LHCb-INT-2015-037 - * see https://cds.cern.ch/record/2102345 - * - * The HOP variables are conceived to exploit the kinematic characteristics of B - * decays into final states involving electrons. - * - * The general idea is to use the fact that the decay particles should have total - * pt with respect to the B flight direction of 0. Using this fact we can re-weight - * the electron momentum using the non-electron parts of the decay. - * - * It is important to note the way this tool works: It applies the momentum - * correction to the electrons in the decay and calculates the HOP mass from there, - * not correcting intermediate state momenta, but final state particles. - * We do, however take into account the intermediate ressonance momentum measurement - * in order to calculate the HOP correction itself. - * - * This tool is comprised of 3 methods: - * - * TupleTooHOP::ClassifyParticles: gets the top particle and two particle containers as - * input and loops over the decay chain classifying basic children in electron and non-electron - * type. When all the children of a composite particle belong to the same type, the composite - * particle receives the same type and it is itself – instead of each children – stored in the - * appropiate container. This is done in order not to loose presicion, since when the children - * are afterwards combined to obtain the mother’s corrected mass no fit but a simple addition - * of momenta is used. - * - * TupleToolHOP::HOPProjectMomentum: takes two particles as input, the first one is assumed - * to be the top of the decay. The direction of flight of this particle is obtained taking the best - * interaction vertex associated to it and its decay vertex. Then the transverse momentum of - * the second particle with respect to this direction is computed and returned. - * - * TupleToolHOP::fill: gets the top particle, the particles for which the variables should be - * computed, a string with the head name that will be used for the names of the variables that - * will be written to the ntuple and the ntuple itself as input. It first checks that the particle - * for which the variables should be computed is the same as the top of the chain. Since our - * algorithm is recursive on all the decay chain we only need to run it once from the top of it. - * Then the daughters are classified using the TupleToolHOP::ClassifyParticles function - * and their transverse momentum with respect to the direction of flight of the top particle - * obtained with the TupleToolHOP::HOPProjectMomentum. The transverse momentum for - * all electron and non-electron particles are added up separately and the HOP ratio is - * computed. This value is stored in the ntuple in the variable head HOP. Afterwards, it is - * used to correct the 4-momentum of each particle in the electron container. Finally, all the - * 4-momenta of the electron particles are sumed together and added to the 4-momentum - * of the non-electron particles. The mother’s corrected mass is obtained from this total - * corrected 4-momentum and stored in the ntuple with the name head HOP MASS. The - * electron corrected mass is also obtained from the corrected 4-momentum of all the electron - * particles added together and is saved as head HOP ELECTRON MASS. - * - * @author Vinicius Franco, Carla Marin Benito - * @date 2016-29-06 - */ -class TupleToolHOP : public extends { - -public: - using base_class::base_class; - StatusCode initialize() override; - StatusCode fill( const LHCb::Particle*, const LHCb::Particle*, const std::string&, Tuples::Tuple&, - IGeometryInfo const& ) override; - -private: - float HOPProjectMomentum( const LHCb::Particle* top, const Gaudi::LorentzVector* part_four_mom, - IGeometryInfo const& geometry ) const; - - int encodeTuple( int isElectron, int hasSameChildren ) const { return ( isElectron << 2 ) | hasSameChildren; } - int isElectron( int tuple ) const { return tuple >> 2; }; - int hasSameChildren( int tuple ) const { return tuple & 3; }; - - int ClassifyParticles( const LHCb::Particle& top, SmartRefVector& electronContainer, - SmartRefVector& nonElectronContainer ) const; - - int ClassifyParticles_Merge( const SmartRefVector& dau, std::vector& t_list, bool are_equal, - SmartRefVector& electronContainer, - SmartRefVector& nonElectronContainer ) const; - - IDVAlgorithm* m_dva = nullptr; - LHCb::IParticlePropertySvc* m_ppSvc = nullptr; - float m_electronMassSquared = 0.0; -}; - -using namespace LHCb; - -// Declaration of the Tool Factory -DECLARE_COMPONENT( TupleToolHOP ) - -StatusCode TupleToolHOP::initialize() { - const StatusCode sc = TupleToolBase::initialize(); - if ( sc.isFailure() ) return sc; - - m_dva = Gaudi::Utils::getIDVAlgorithm( contextSvc(), this ); - if ( !m_dva ) return Error( "Couldn't get parent DVAlgorithm" ); - - m_ppSvc = svc( "LHCb::ParticlePropertySvc", true ); - if ( !m_ppSvc ) return Error( "Couldn't get ParticlePropertySvc" ); - m_electronMassSquared = std::pow( m_ppSvc->find( "e+" )->mass() / Gaudi::Units::MeV, 2 ); - - if ( msgLevel( MSG::VERBOSE ) ) - verbose() << "TupleToolHOP::initialize " - << "Done" << endmsg; - - return sc; -} - -StatusCode TupleToolHOP::fill( const Particle* mother, const Particle* P, const std::string& head, Tuples::Tuple& tuple, - IGeometryInfo const& geometry ) { - StatusCode sc = StatusCode::SUCCESS; - if ( msgLevel( MSG::VERBOSE ) ) verbose() << "TupleToolHOP::fill " << endmsg; - - if ( mother == P ) { - if ( msgLevel( MSG::VERBOSE ) ) - verbose() << "TupleToolHOP::fill " - << ": " - << "particle is mother, let's run " << endmsg; - - bool test = true; - const std::string prefix = fullName( head ); - - SmartRefVector electronContainer; - SmartRefVector nonElectronContainer; - if ( msgLevel( MSG::VERBOSE ) ) - verbose() << "TupleToolHOP::fill " - << ": " - << "start ClassifyParticles " << endmsg; - - ClassifyParticles( *P, electronContainer, nonElectronContainer ); - - if ( msgLevel( MSG::VERBOSE ) ) { - verbose() << "TupleToolHOP::fill " - << ": " - << "electrons found: " << electronContainer << endmsg; - verbose() << "TupleToolHOP::fill " - << ": " - << "non-electrons found: " << nonElectronContainer << endmsg; - } - - // Get pt wrt mother direction of flight - float total_pt_e = 0, total_pt_non_e = 0; - Gaudi::LorentzVector total_4p_e = Gaudi::LorentzVector( 0, 0, 0, 0 ); - Gaudi::LorentzVector total_4p_non_e = Gaudi::LorentzVector( 0, 0, 0, 0 ); - - if ( msgLevel( MSG::VERBOSE ) ) - verbose() << "TupleToolHOP::fill " - << ": " - << "loop on electrons " << endmsg; - for ( auto& e : electronContainer ) { - if ( msgLevel( MSG::VERBOSE ) ) { - verbose() << "TupleToolHOP::fill " - << ": " - << "electron is " << e << endmsg; - verbose() << "TupleToolHOP::fill " - << ": " - << "start HOPProjectMomentum " << endmsg; - } - total_4p_e += e->momentum(); - total_pt_e = HOPProjectMomentum( P, &total_4p_e, geometry ); - } - - if ( msgLevel( MSG::VERBOSE ) ) - verbose() << "TupleToolHOP::fill " - << ": " - << "loop on non-electrons " << endmsg; - - for ( auto& noE : nonElectronContainer ) { - if ( msgLevel( MSG::VERBOSE ) ) { - verbose() << "TupleToolHOP::fill " - << ": " - << "non-electron is " << noE << endmsg; - verbose() << "TupleToolHOP::fill " - << ": " - << "start HOPProjectMomentum " << endmsg; - } - total_4p_non_e += noE->momentum(); - total_pt_non_e = HOPProjectMomentum( P, &total_4p_non_e, geometry ); - } - - if ( msgLevel( MSG::VERBOSE ) ) { - verbose() << "TupleToolHOP::fill " - << ": " - << "Total ptElectron: " << total_pt_e << endmsg; - verbose() << "TupleToolHOP::fill " - << ": " - << "Total pt non-Electron: " << total_pt_non_e << endmsg; - verbose() << "TupleToolHOP::fill " - << ": " - << "Total 4p non-Electron: " << total_4p_non_e << endmsg; - } - - // Compute HOP correction - double hop = 0; - if ( total_pt_e != 0 ) hop = total_pt_non_e / total_pt_e; - if ( msgLevel( MSG::VERBOSE ) ) - verbose() << "TupleToolHOP::fill " - << ": " - << "hop: " << hop << endmsg; - - // Fill tuple with HOP correction - test &= tuple->column( prefix + "_HOP", hop ); - if ( msgLevel( MSG::VERBOSE ) ) - verbose() << "TupleToolHOP::fill " - << ": " - << "hop written to ntuple" << endmsg; - - // Correct elec momenta with HOP value - Gaudi::LorentzVector sumCorrected = Gaudi::LorentzVector( 0, 0, 0, 0 ); - - if ( msgLevel( MSG::VERBOSE ) ) - verbose() << "TupleToolHOP::fill " - << ": " - << "Electron mass squared in MeV^2 : " << m_electronMassSquared << endmsg; - - for ( auto& e2 : electronContainer ) { - if ( e2->isBasicParticle() ) // directly correct elec momenta - { - Gaudi::LorentzVector correctedMomentum = Gaudi::LorentzVector( - ( e2->momentum().Px() ) * hop, ( e2->momentum().Py() ) * hop, ( e2->momentum().Pz() ) * hop, - sqrt( ( std::pow( e2->momentum().Px(), 2 ) + std::pow( e2->momentum().Py(), 2 ) + - std::pow( e2->momentum().Pz(), 2 ) ) * - std::pow( hop, 2 ) + - std::pow( m_ppSvc->find( e2->particleID() )->mass() / Gaudi::Units::MeV, 2 ) ) ); - if ( msgLevel( MSG::VERBOSE ) ) { - verbose() << "TupleToolHOP::fill " - << ": " - << "Electron PX: " << e2->momentum().Px() << ", Corrected PX: " << e2->momentum().Px() * hop - << endmsg; - verbose() << "TupleToolHOP::fill " - << ": " - << "Electron PY: " << e2->momentum().Py() << ", Corrected PY: " << e2->momentum().Py() * hop - << endmsg; - verbose() << "TupleToolHOP::fill " - << ": " - << "Electron PZ: " << e2->momentum().Pz() << ", Corrected PZ: " << e2->momentum().Pz() * hop - << endmsg; - verbose() << "TupleToolHOP::fill " - << ": " - << "Electron E: " << e2->momentum().E() << ", Corrected E: " - << sqrt( ( std::pow( e2->momentum().Px(), 2 ) + std::pow( e2->momentum().Py(), 2 ) + - std::pow( e2->momentum().Pz(), 2 ) ) * - std::pow( hop, 2 ) + - std::pow( m_ppSvc->find( e2->particleID() )->mass() / Gaudi::Units::MeV, 2 ) ) - << endmsg; - } - sumCorrected += correctedMomentum; - if ( msgLevel( MSG::VERBOSE ) ) - verbose() << "TupleToolHOP::fill " - << ": " - << "Electron Corrected mass: " << correctedMomentum.M() << endmsg; - } - - else // correct momenta of each children separately and add them up. Is this what we want?? - { - const auto& dau = e2->daughters(); - for ( const auto& idaughter3 : dau ) { - Gaudi::LorentzVector correctedMomentum = Gaudi::LorentzVector( - ( idaughter3->momentum().Px() ) * hop, ( idaughter3->momentum().Py() ) * hop, - ( idaughter3->momentum().Pz() ) * hop, - sqrt( ( std::pow( idaughter3->momentum().Px(), 2 ) + std::pow( idaughter3->momentum().Py(), 2 ) + - std::pow( idaughter3->momentum().Pz(), 2 ) ) * - std::pow( hop, 2 ) + - std::pow( m_ppSvc->find( idaughter3->particleID() )->mass() / Gaudi::Units::MeV, 2 ) ) ); - sumCorrected += correctedMomentum; - } - } - } - - if ( msgLevel( MSG::VERBOSE ) ) { - verbose() << "TupleToolHOP::fill " - << ": " - << "Total Electron Corrected mass: " << ( sumCorrected ).M() << endmsg; - verbose() << "TupleToolHOP::fill " - << ": " - << "Non Electron mass: " << ( total_4p_non_e ).M() << endmsg; - verbose() << "TupleToolHOP::fill " - << ": " - << "hop mass: " << ( total_4p_non_e + sumCorrected ).M() << endmsg; - verbose() << "TupleToolHOP::fill " - << ": " - << "hop mass calculated: " - << sqrt( pow( ( total_4p_non_e + sumCorrected ).E(), 2 ) - - pow( ( total_4p_non_e + sumCorrected ).P(), 2 ) ) - << endmsg; - } - - // Fill HOP_MASS and HOP_ELECTRON_MASS - test &= tuple->column( prefix + "_HOP_MASS", ( total_4p_non_e + sumCorrected ).M() ); - test &= tuple->column( prefix + "_HOP_ELECTRON_MASS", ( sumCorrected ).M() ); - if ( msgLevel( MSG::VERBOSE ) ) - verbose() << "TupleToolHOP::fill " - << ": " - << "hop mass written to ntuple" << endmsg; - - return StatusCode( test ); - } - - return sc; -} - -// ===================================================== -// Classify particles in electron type and others -// ===================================================== -int TupleToolHOP::ClassifyParticles( const LHCb::Particle& top, SmartRefVector& electronContainer, - SmartRefVector& nonElectronContainer ) const { - if ( msgLevel( MSG::VERBOSE ) ) verbose() << "TupleToolHOP::ClassifyParticles " << endmsg; - - // Base case: basic particle - if ( top.isBasicParticle() ) { - if ( msgLevel( MSG::VERBOSE ) ) - verbose() << "TupleToolHOP::ClassifyParticles: " << top.particleID().pid() << " is basic" << endmsg; - - int p_isElectron = ( top.particleID().abspid() == 11 ) ? 1 : 0; - int p_hasSameChildren = 2; // has no children since it is basic - - if ( msgLevel( MSG::VERBOSE ) ) - verbose() << "TupleToolHOP::ClassifyParticles: " << top.particleID().pid() << " is electron: " << p_isElectron - << endmsg; - - return encodeTuple( p_isElectron, p_hasSameChildren ); - } - // Complex Case ( Intermediate particles in the decay, need to figure out how to correctly classify them) - else { - if ( msgLevel( MSG::VERBOSE ) ) { - verbose() << "TupleToolHOP::ClassifyParticles: " << top.particleID().pid() << " is NOT basic" << endmsg; - verbose() << "TupleToolHOP::ClassifyParticles: " - << "start loop on daughters" << endmsg; - } - - const auto& dau = top.daughters(); - - std::vector t_list; - int dau_type = 3; // means only first children beeing checked - bool are_equal = true; - for ( const auto& idaughter : dau ) { - int dt = ClassifyParticles( *idaughter, electronContainer, nonElectronContainer ); - t_list.push_back( dt ); - // check if all daughters are of same type - if ( dau_type == 3 ) // first children, get only its type - dau_type = isElectron( dt ); - else // other childrens, compare to previous - { - if ( dau_type != isElectron( dt ) ) are_equal = false; - } - if ( msgLevel( MSG::VERBOSE ) ) { - verbose() << "TupleToolHOP::ClassifyParticles: " << idaughter->particleID().pid() - << " electron: " << isElectron( dt ) << endmsg; - verbose() << "TupleToolHOP::ClassifyParticles: " << idaughter->particleID().pid() - << " same child: " << hasSameChildren( dt ) << endmsg; - } - } - if ( msgLevel( MSG::VERBOSE ) ) { - verbose() << "TupleToolHOP::ClassifyParticles: " << top.particleID().pid() << " daughters: " << dau << endmsg; - // verbose() << "TupleToolHOP::ClassifyParticles: " << top.particleID().pid() << " t_list: " << t_list << endmsg; - verbose() << "TupleToolHOP::ClassifyParticles: " << top.particleID().pid() << " equal dau: " << are_equal - << endmsg; - } - - int t = ClassifyParticles_Merge( dau, t_list, are_equal, electronContainer, nonElectronContainer ); - - if ( msgLevel( MSG::VERBOSE ) ) { - verbose() << "TupleToolHOP::ClassifyParticles: " << top.particleID().pid() << " electron: " << isElectron( t ) - << endmsg; - verbose() << "TupleToolHOP::ClassifyParticles: " << top.particleID().pid() - << " same child: " << hasSameChildren( t ) << endmsg; - } - - return t; - } -} - -// ===================================================== -// Merge function for ClassifyParticles -// ===================================================== -int TupleToolHOP::ClassifyParticles_Merge( const SmartRefVector& dau, std::vector& t_list, - bool are_equal, SmartRefVector& electronContainer, - SmartRefVector& nonElectronContainer ) const { - - if ( msgLevel( MSG::VERBOSE ) ) verbose() << "TupleToolHOP::ClassifyParticlesMerge " << endmsg; - - int t_mother_isElectron = 0; - int t_mother_hasSameChildren = 0; - if ( are_equal ) { - t_mother_hasSameChildren = 1; - t_mother_isElectron = isElectron( t_list[0] ); // inherits children type - if ( msgLevel( MSG::VERBOSE ) ) { - verbose() << "TupleToolHOP::ClassifyParticlesMerge: " - << "equal dau" << endmsg; - verbose() << "TupleToolHOP::ClassifyParticlesMerge: " - << "don't save children" << endmsg; - } - } - - else { - t_mother_hasSameChildren = 0; - t_mother_isElectron = 2; // mother has "no type" - - if ( msgLevel( MSG::VERBOSE ) ) { - verbose() << "TupleToolHOP::ClassifyParticlesMerge: " - << "diff dau" << endmsg; - verbose() << "TupleToolHOP::ClassifyParticlesMerge: " - << "save children if not yet done" << endmsg; - } - - // SmartRefVector::const_iterator it = t_list.begin(); - int i = 0; - for ( const auto& idaughter : dau ) { - int it = t_list[i]; - if ( msgLevel( MSG::VERBOSE ) ) - verbose() << "TupleToolHOP::ClassifyParticlesMerge: " << idaughter->particleID().pid() - << " same child: " << hasSameChildren( it ) << endmsg; - - if ( hasSameChildren( it ) == 1 || hasSameChildren( it ) == 2 ) { - if ( msgLevel( MSG::VERBOSE ) ) { - verbose() << "TupleToolHOP::ClassifyParticlesMerge: " << idaughter->particleID().pid() - << " has same or no children" << endmsg; - verbose() << "TupleToolHOP::ClassifyParticlesMerge: " << idaughter->particleID().pid() << " will be saved" - << endmsg; - verbose() << "TupleToolHOP::ClassifyParticlesMerge: " << idaughter->particleID().pid() - << " is e: " << isElectron( it ) << endmsg; - } - - if ( isElectron( it ) == 1 ) { - electronContainer.push_back( idaughter ); - if ( msgLevel( MSG::VERBOSE ) ) - verbose() << "TupleToolHOP::ClassifyParticlesMerge: " << idaughter->particleID().pid() - << " saved as electron" << endmsg; - } - - else { - nonElectronContainer.push_back( idaughter ); - if ( msgLevel( MSG::VERBOSE ) ) - verbose() << "TupleToolHOP::ClassifyParticlesMerge: " << idaughter->particleID().pid() - << " saved as no electron" << endmsg; - } - } - i++; - } - } - - if ( msgLevel( MSG::VERBOSE ) ) { - verbose() << "TupleToolHOP::ClassifyParticlesMerge: " - << "mother is e: " << t_mother_isElectron << endmsg; - verbose() << "TupleToolHOP::ClassifyParticlesMerge: " - << "mother has equal childs: " << t_mother_hasSameChildren << endmsg; - } - - return encodeTuple( t_mother_isElectron, t_mother_hasSameChildren ); -} - -// ===================================================== -// PT recalculation -// ===================================================== -float TupleToolHOP::HOPProjectMomentum( const LHCb::Particle* top, const Gaudi::LorentzVector* part_four_mom, - IGeometryInfo const& geometry ) const { - if ( msgLevel( MSG::VERBOSE ) ) - verbose() << "TupleToolHOP::HOPProjectMomentum" - << ": " << endmsg; - - const LHCb::VertexBase* PV; - const LHCb::VertexBase* SV; - ROOT::Math::DisplacementVector3D> bFlightVector, bFlightVectorUnit; - PV = m_dva->bestVertex( top, geometry ); - SV = top->endVertex(); - bFlightVector = SV->position() - PV->position(); - - bFlightVectorUnit = ( SV->position() - PV->position() ).Unit(); - double pInBFlightDir = ( part_four_mom->Px() * bFlightVectorUnit.X() + part_four_mom->Py() * bFlightVectorUnit.Y() + - part_four_mom->Pz() * bFlightVectorUnit.Z() ); - double cosAngle = pInBFlightDir / part_four_mom->P(); - double ptInBFlightDir = part_four_mom->P() * sqrt( 1 - std::pow( cosAngle, 2 ) ); - - if ( msgLevel( MSG::VERBOSE ) ) { - verbose() << "TupleToolHOP::HOPProjectMomentum" - << ": " - << " PV: " << PV->position() << endmsg; - verbose() << "TupleToolHOP::HOPProjectMomentum" - << ": " - << " SV: " << SV->position() << endmsg; - verbose() << "TupleToolHOP::HOPProjectMomentum" - << ": " - << " b Flight vector: " << bFlightVector << endmsg; - verbose() << "TupleToolHOP::HOPProjectMomentum" - << ": " - << " particle 4-momentum: " << part_four_mom << endmsg; - verbose() << "TupleToolHOP::HOPProjectMomentum" - << ": " - << " Momentum Magnitude in bFlight direction: " << pInBFlightDir << endmsg; - verbose() << "TupleToolHOP::HOPProjectMomentum" - << ": " - << " Cosine of angle: " << cosAngle << endmsg; - verbose() << "TupleToolHOP::HOPProjectMomentum" - << ": " - << " Pt wrt B flight direction: " << ptInBFlightDir << endmsg; - } - return ptInBFlightDir; -} diff --git a/Phys/DecayTreeTuple/src/TupleToolIsolationTwoBody.cpp b/Phys/DecayTreeTuple/src/TupleToolIsolationTwoBody.cpp deleted file mode 100644 index d45f66048d1657be512392efee718ee88682d034..0000000000000000000000000000000000000000 --- a/Phys/DecayTreeTuple/src/TupleToolIsolationTwoBody.cpp +++ /dev/null @@ -1,794 +0,0 @@ -/*****************************************************************************\ -* (c) Copyright 2000-2018 CERN for the benefit of the LHCb Collaboration * -* * -* This software is distributed under the terms of the GNU General Public * -* Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". * -* * -* In applying this licence, CERN does not waive the privileges and immunities * -* granted to it by virtue of its status as an Intergovernmental Organization * -* or submit itself to any jurisdiction. * -\*****************************************************************************/ - -#include "DecayTreeTupleBase/TupleToolBase.h" - -#include "Kernel/GetIDVAlgorithm.h" -#include "Kernel/IDVAlgorithm.h" -#include "Kernel/IDistanceCalculator.h" -#include "Kernel/IPVReFitter.h" -#include "Kernel/IParticle2MCAssociator.h" -#include "Kernel/IParticleCombiner.h" -#include "Kernel/IParticleTupleTool.h" -#include "Kernel/IRelatedPVFinder.h" -#include "Kernel/Particle2MCLinker.h" - -#include "LoKi/Combiner.h" -#include "LoKi/CoreCuts.h" -#include "LoKi/Functor.h" -#include "LoKi/LoKi.h" -#include "LoKi/PhysTypes.h" - -#include "Event/GenHeader.h" -#include "Event/MCHeader.h" -#include "Event/Particle.h" -#include "Event/ProtoParticle.h" -#include "Event/RecVertex.h" -#include "Event/VertexBase.h" - -#include "MuonDet/DeMuonDetector.h" -#include "MuonDet/MuonBasicGeometry.h" - -#include "GaudiAlg/Tuple.h" -#include "GaudiAlg/TupleObj.h" -#include "GaudiKernel/PhysicalConstants.h" - -#include "TMath.h" - -#include -#include -#include - -/** - * Implementation for a "Particle Isolation" tool for particles from - * twobody decays. - * It return the degree of isolation of two particles with a common mother. - * - * Currently it returns the numbers of non-isolating particles associated - * with each of the input particles. - * - * @author Fatima Soomro, based on the code by Giampiero Mancinelli giampi@cppm.in2p3.fr in DaVinciTools - * @date 2012-03-17 - */ -class TupleToolIsolationTwoBody : public TupleToolBase, public virtual IParticleTupleTool { - -public: - TupleToolIsolationTwoBody( const std::string& type, const std::string& name, const IInterface* parent ); - StatusCode initialize() override; - - StatusCode fill( const LHCb::Particle*, const LHCb::Particle*, const std::string& head, Tuples::Tuple& tuple, - IGeometryInfo const& geometry ) override; - -private: - /** The method for the evaluation of the degree of isolation ("number - * of non-isolating tracks") of the input set of particles. - * - * @code - * - * // get the tool - * const IParticleIsolation* tool = ...; - * Particle::ConstVector vdaugh = ... ; - * int iso[2] = ... ; - * --> for new (#5) definition (see LHCb-INT-2010-011) - * --> other criteria defined in the same note are not yet implemented - * float massiso[2] = invariant mass of non-isolating particles - * float chi2iso[2] = chi2 of particle made with non-isolating particles - * const RecVertex* PV = ...; - * const RecVertex* SV = ...; - * - * // use the tool to evaluate the degrees of isolation - * StatusCode sc = tool ->getIso(vdaugh,iso,massiso,chi2iso,PV,SV); - * - * @endcode - * - * @param vdaugh (input) pointer to the input set particles (2 particles) - * @param iso (output) number(s) of non-isolating particles (2 isolations) - * @param massiso (output) invariant mass of non-isolating particles - * @param chi2iso (output) chi2 of particle made with non-isolating particles - * @param PV (input) (optional) primary vertex - * @param SV (input) (optional) secondary vertex (of mother) - * - * @return status code - */ - StatusCode getIso( const LHCb::Particle*, std::string, Tuples::Tuple&, IGeometryInfo const& geometry ); - - StatusCode MuChi2( const LHCb::Particle* P, const std::string& head, Tuples::Tuple& tuple ); - - /** Defines whether or not a particle is not isolating according to the - BsMuMu Roadmap, using an Hlt criterium - */ - void IsHltGood( Gaudi::XYZPoint o, Gaudi::XYZVector p, Gaudi::XYZPoint o_mu, Gaudi::XYZVector p_mu, - Gaudi::XYZPoint PV, int& hltgood, double& fc ) const; - /** given two tracks returns the closest point, the doca and the angle - between the tracks - */ - void InCone( Gaudi::XYZPoint o1, Gaudi::XYZVector p1, Gaudi::XYZPoint o2, Gaudi::XYZVector p2, Gaudi::XYZPoint& vtx, - double& doca, double& angle ) const; - /** given two particles and the vector between the PV and vertex defined - * by them, it returns : - * fc=\frac{\left|\vec{P_{\mu}}+\vec{P_{tr}}\right|\cdot\alpha^{\mu+tr,PV}} - * {\left|\vec{P_{\mu}}+\vec{P_{tr}}\right|\cdot\alpha^{\mu+tr,PV}+P_{T\mu} - * +P_{Ttr}} - * where $P_{T\mu}$ and $P_{Ttr}$ are the transverse momenta (with respect - * to the beam line) of the two tracks. - */ - double pointer( Gaudi::XYZVector vtx, Gaudi::XYZVector P_tr, Gaudi::XYZVector P_mu ) const; - - /// return the arcosine between two vectors - double arcosine( Gaudi::XYZVector p1, Gaudi::XYZVector p2 ) const; - - /** given two vectors and two application points finds for the two relevant - * straight lines the closest points along the lines and the middle one - * between the such points - */ - void closest_point( Gaudi::XYZPoint o, Gaudi::XYZVector p, Gaudi::XYZPoint o_mu, Gaudi::XYZVector p_mu, - Gaudi::XYZPoint& close1, Gaudi::XYZPoint& close2, Gaudi::XYZPoint& vertex, bool& fail ) const; - - const LHCb::MCParticle* ancestor( const LHCb::MCParticle* ) const; - -private: - const IDistanceCalculator* m_Geom; - std::string m_ParticlePath; - - bool m_MuChi2; - /// cut on opening angle between tracks - double m_angle; - /// cut on pointing (hlt) (see LHCb-INT-2010-011) - double m_fc; - /// cut on distance of closest approach of tracks - double m_doca; - /// cut on particles minimum impact parameter with respect to PV - double m_ips; - /// cut on distance (low) between two track vertex and and the mother SV - double m_svdis; - /// cut on distance (high) between two track vertex and and the mother SV - double m_svdis_h; - /// cut on distance (low) between two track vertex and and the mother PV - double m_pvdis; - /// cut on distance (high) between two track vertex and and the mother PV - double m_pvdis_h; - /// cut on ghost probability - double m_ghost; - /// cut on clone probability - double m_clone; - /// cut on trk chi2 - double m_trchi2; - /// cut on hltgood - double m_hltgood; - int m_tracktype; - std::string m_PVInputLocation; - double ratio( double p1, double p2 ) const; - - // bool m_tuple; - bool m_isMC; - IParticle2MCAssociator* m_p2mcAssoc; - const IParticleCombiner* m_combiner; - IDVAlgorithm* m_dva; - - std::string m_p2mcAssocType; -}; - -// Declaration of the Tool Factory -DECLARE_COMPONENT( TupleToolIsolationTwoBody ) - -using namespace LHCb; -using namespace std; - -//============================================================================= -// Standard constructor, initializes variables -//============================================================================= -TupleToolIsolationTwoBody::TupleToolIsolationTwoBody( const std::string& type, const std::string& name, - const IInterface* parent ) - : TupleToolBase( type, name, parent ) - , m_Geom( 0 ) - , m_angle( 0 ) - , m_fc( 0 ) - , m_doca( 0 ) - , m_ips( 0 ) - , m_svdis( 0 ) - , m_svdis_h( 0 ) - , m_pvdis( 0 ) - , m_pvdis_h( 0 ) - , m_ghost( 0 ) - , m_clone( 0 ) - , m_trchi2( 0 ) - , m_hltgood( 0 ) - , m_tracktype( 0 ) - , m_PVInputLocation( LHCb::RecVertexLocation::Primary ) - , m_p2mcAssoc( 0 ) - , m_dva( 0 ) - , m_p2mcAssocType( "DaVinciSmartAssociator" ) { - declareInterface( this ); - declareProperty( "ParticlePath", m_ParticlePath = "/Event/Phys/StdAllNoPIDsPions/Particles" ); - declareProperty( "angle", m_angle = 0.27 ); // - declareProperty( "fc", m_fc = 0.60 ); // - declareProperty( "doca", m_doca = 0.13 ); // - declareProperty( "ips", m_ips = 3.0 ); // - declareProperty( "svdis", m_svdis = -0.15 ); // - declareProperty( "svdis_h", m_svdis_h = 30. ); // - declareProperty( "pvdis", m_pvdis = 0.5 ); // - declareProperty( "pvdis_h", m_pvdis_h = 40. ); // - declareProperty( "ghost", m_ghost = 1000000. ); // - declareProperty( "clone", m_clone = -1000000. ); // - declareProperty( "trchi2", m_trchi2 = 1000000. ); // - declareProperty( "tracktype", m_tracktype = 3 ); // - declareProperty( "hltgood", m_hltgood = -10 ); // - declareProperty( "PVInputLocation", m_PVInputLocation ); - declareProperty( "MuChi2", m_MuChi2 = true ); - declareProperty( "isMC", m_isMC = false ); - - declareProperty( "IP2MCPAssociatorType", m_p2mcAssocType ); -} - -//============================================================================= -// Initialize -//============================================================================= -StatusCode TupleToolIsolationTwoBody::initialize() { - const StatusCode sc = TupleToolBase::initialize(); - if ( sc.isFailure() ) return sc; - - m_dva = Gaudi::Utils::getIDVAlgorithm( contextSvc(), this ); - if ( !m_dva ) { return Error( "Couldn't get parent DVAlgorithm", StatusCode::FAILURE ); } - - m_p2mcAssoc = tool( m_p2mcAssocType, this ); - m_combiner = m_dva->particleCombiner(); - m_Geom = m_dva->distanceCalculator(); - - return sc; -} - -//============================================================================= -// Fill -//============================================================================= -StatusCode TupleToolIsolationTwoBody::fill( const LHCb::Particle* /* top */, const LHCb::Particle* part, - const std::string& head, Tuples::Tuple& tuple, - IGeometryInfo const& geometry ) { - - const std::string prefix = fullName( head ); - - if ( msgLevel( MSG::DEBUG ) ) debug() << "filling tuple for " << prefix << endmsg; - - StatusCode sc; - if ( part->isBasicParticle() && m_MuChi2 ) { sc = MuChi2( part, prefix, tuple ); } - - if ( part->isBasicParticle() || part->daughtersVector().size() != 2 ) { - - if ( msgLevel( MSG::DEBUG ) ) debug() << "not filling for " << fullName( head ) << endmsg; - return StatusCode::SUCCESS; - } else { - - bool shdBeTrue = true; - const LHCb::Particle::ConstVector& parts = part->daughtersVector(); - - for ( Particle::ConstVector::const_iterator ip_part = parts.begin(); ip_part != parts.end(); ip_part++ ) { - if ( !( ( *ip_part )->isBasicParticle() ) ) shdBeTrue = false; - if ( !shdBeTrue && msgLevel( MSG::DEBUG ) ) - debug() << "Found compositle particle " << ( *ip_part )->particleID().pid() << " in the daughters of" - << fullName( head ) << endmsg; - } - - if ( !shdBeTrue ) return StatusCode::SUCCESS; - } - - // float* massiso; float* chi2iso; int*iso; - - // const LHCb::VertexBase* PV = m_dva->bestPV(part); - // const LHCb::VertexBase* SV = part->endVertex(); - if ( msgLevel( MSG::DEBUG ) ) debug() << " calling getiso " << endmsg; - sc = getIso( part, prefix, tuple, geometry ); - - // sc &= tuple->column( prefix+"_test", massiso[0]); - - return sc; -} - -//============================================================================= -// F.Soomro, 9 March 12 -// Fill MuonChi2DOF for the track, for Walter -//============================================================================= -StatusCode TupleToolIsolationTwoBody::MuChi2( const LHCb::Particle* P, const std::string& prefix, - Tuples::Tuple& tuple ) { - // const std::string prefix=fullName(head); - - bool test = true; - if ( !P ) return StatusCode::FAILURE; - - // first just return if the particle isn't supposed to have a track - if ( !P->isBasicParticle() ) return StatusCode::SUCCESS; - - const LHCb::ProtoParticle* protop = P->proto(); - if ( !protop ) return StatusCode::SUCCESS; - const LHCb::Track* track = protop->track(); - if ( !track ) return StatusCode::SUCCESS; - - // double muchi2 = track->info(LHCb::Track::AdditionalInfo::MuonChi2perDoF , -1); - // test += tuple->column( prefix+"_MuonChi2DOF", muchi2); - - double muchi2 = -1; - - if ( msgLevel( MSG::DEBUG ) ) debug() << "checking for muonpids at " << LHCb::MuonPIDLocation::Default << endmsg; - LHCb::MuonPIDs* pMuids = NULL; - if ( exist( LHCb::MuonPIDLocation::Default ) ) - pMuids = get( LHCb::MuonPIDLocation::Default ); - if ( !pMuids ) { - error() << " Failed to get pMuids" << LHCb::MuonPIDLocation::Default << endmsg; - return StatusCode::FAILURE; - } - - if ( msgLevel( MSG::DEBUG ) ) debug() << " found it, the size is " << pMuids->size() << endmsg; - const LHCb::Track* mutrack = NULL; - LHCb::MuonPIDs::const_iterator ip; - for ( ip = pMuids->begin(); ip != pMuids->end(); ip++ ) { - if ( ( *ip )->idTrack() == track ) { - mutrack = ( *ip )->muonTrack(); - if ( !mutrack ) continue; - if ( msgLevel( MSG::DEBUG ) ) debug() << "found a mutrack " << endmsg; - } - } // end of muonIDs loop - - if ( mutrack ) { - muchi2 = mutrack->info( LHCb::Track::AdditionalInfo::MuonChi2perDoF, -1 ); - } - - else { - if ( msgLevel( MSG::DEBUG ) ) debug() << "didnt find any mutrack! " << endmsg; - } - - if ( msgLevel( MSG::DEBUG ) ) debug() << "muchi2 was " << muchi2 << endmsg; - test += tuple->column( prefix + "_MuonChi2DOF", muchi2 ).getCode(); - - // here test is always true!!! - return test ? StatusCode::SUCCESS : StatusCode::FAILURE; -} - -//============================================================================= -// End of Fill MuonChi2DOF -//============================================================================= - -//============================================================================= -// get the Isolation -//============================================================================= - -StatusCode TupleToolIsolationTwoBody::getIso( const LHCb::Particle* P, const std::string prefix, Tuples::Tuple& tuple, - IGeometryInfo const& geometry ) { - - if ( msgLevel( MSG::DEBUG ) ) debug() << "Now get the Isolation level" << endmsg; - - const LHCb::Particle::ConstVector& parts = P->daughtersVector(); - if ( msgLevel( MSG::DEBUG ) ) debug() << "daughters vector " << endmsg; - float massiso[2]; - float chi2iso[2]; - // int iso[2]; - if ( msgLevel( MSG::DEBUG ) ) debug() << "the floats " << endmsg; - const LHCb::VertexBase* PV = m_dva->bestVertex( P, geometry ); - const LHCb::VertexBase* SV = P->endVertex(); - if ( msgLevel( MSG::DEBUG ) ) debug() << " PV and SV " << endmsg; - - LHCb::Particles* allparts = get( m_ParticlePath ); - if ( !allparts ) { - error() << " Failed to get particles container " << m_ParticlePath << endmsg; - return StatusCode::SUCCESS; - } - - if ( msgLevel( MSG::DEBUG ) ) debug() << " have all_parts with size " << allparts->size() << endmsg; - - Assert( m_p2mcAssoc, "The DaVinci smart associator hasn't been initialized!" ); - /* - Particle2MCLinker* m_linkLinks(0); - if (m_isMC){ - - m_linkLinks = new Particle2MCLinker( this, - //Particle2MCMethod::Chi2, - Particle2MCMethod::Links, - m_ParticlePath); - if( !m_linkLinks ) { - fatal() << "Unable to retrieve Link Associator tool"<position(); - const Gaudi::XYZPoint& PosSV = SV->position(); - if ( msgLevel( MSG::DEBUG ) ) debug() << " PV and SV position " << endmsg; - - int i = 0; - ROOT::Math::SVector iso5; - iso5[0] = 0; - iso5[1] = 0; - ROOT::Math::SMatrix o_mu; - ROOT::Math::SMatrix p_mu; - ROOT::Math::SVector ptmu; - int storeCharge[2]; - // Loop over input particles, get their simple kinematics - Particle::ConstVector::const_iterator ip_part; - - if ( msgLevel( MSG::DEBUG ) ) debug() << "=========== 1" << endmsg; - // IParticle2MCAssociator* m_p2mcAssoc; - Particle::ConstVector iso_parts_0; - Particle::ConstVector iso_parts_1; - // const MCParticle* mclink1 = 0; - // const MCParticle* mclink2 = 0; - - // thats where you decide which daughter is at [0] and [1] of the arrays - for ( ip_part = parts.begin(); ip_part != parts.end(); ip_part++ ) { - const LHCb::Particle* part = *( ip_part ); - // if (m_isMC) { - // if (i==0) mclink1 = m_p2mcAssoc->relatedMCP(part); - // if (i==1) mclink2 = m_p2mcAssoc->relatedMCP(part); - //} - - if ( i == 0 ) iso_parts_0.push_back( part ); - if ( i == 1 ) iso_parts_1.push_back( part ); - const LHCb::ProtoParticle* proto = ( *ip_part )->proto(); - const LHCb::Track* track = proto->track(); - storeCharge[i] = part->charge(); - - o_mu( 0, i ) = track->position().x(); - o_mu( 1, i ) = track->position().y(); - o_mu( 2, i ) = track->position().z(); - p_mu( 0, i ) = track->momentum().x(); - p_mu( 1, i ) = track->momentum().y(); - p_mu( 2, i ) = track->momentum().z(); - ptmu[i] = std::sqrt( std::pow( p_mu( 0, i ), 2 ) + std::pow( p_mu( 1, i ), 2 ) ); - ++i; - - } // ip_part - int j = 0; - - float doca2[2]; - doca2[0] = 10000.; - doca2[1] = 10000.; - float bestdoca[2]; - bestdoca[0] = 10000.; - bestdoca[1] = 10000.; - LHCb::Particle* bestpart_0( 0 ); - LHCb::Particle* bestpart_1( 0 ); - - if ( msgLevel( MSG::DEBUG ) ) debug() << "=========== 2" << endmsg; - // Loop over all particles - LHCb::Particles::const_iterator ip; - for ( ip = allparts->begin(); ip != allparts->end(); ++ip ) { - - if ( msgLevel( MSG::DEBUG ) ) debug() << " looping over all parts " << endmsg; - j++; - const LHCb::ProtoParticle* proto = ( *ip )->proto(); - const LHCb::Track* track = proto->track(); - LHCb::Particle* cand = ( *ip ); - Gaudi::XYZPoint o( track->position() ); - Gaudi::XYZVector p( track->momentum() ); - bool isInList = 0; - double pt = p.Rho(); - // double ptot = p.R(); - - // skip if other particle is in input list - if ( msgLevel( MSG::DEBUG ) ) debug() << " check isInList " << endmsg; - if ( ratio( pt, ptmu[0] ) < 0.0001 || ratio( pt, ptmu[1] ) < 0.0001 ) { - isInList = 1; - if ( msgLevel( MSG::DEBUG ) ) debug() << "isInList is found to be " << isInList << endmsg; - } - - if ( !isInList ) { - if ( msgLevel( MSG::DEBUG ) ) debug() << "part inNOTinlist" << endmsg; - - int i2 = 0; - // bool fromB = false; - // bool fromD = false; - // float MCID(0); - // float MCmothID(0); - const MCParticle* mclink = 0; - - if ( msgLevel( MSG::DEBUG ) ) { - debug() << "=========== 3" << endmsg; - if ( m_isMC ) { - debug() << "=========== 4" << endmsg; - debug() << "=========== 4a" << endmsg; - mclink = m_p2mcAssoc->relatedMCP( cand ); - if ( mclink ) { - debug() << "=========== 5" << endmsg; - // fromB = ancestor(mclink)->particleID().hasBottom(); - // fromD = ancestor(mclink)->particleID().hasCharm(); - // MCID = mclink->particleID().pid(); - debug() << "=========== 6" << endmsg; - const MCParticle* mc_mom = mclink->mother(); - if ( mc_mom ) { - debug() << "=========== 7" << endmsg; - // MCmothID = mc_mom->particleID().pid(); - } - } - debug() << "=========== 4b" << endmsg; - } - } - - // Loop over input particles (2) - for ( i2 = 0; i2 < 2; i2++ ) { - - // bool isolating = false; - // if (m_isMC) { - // if (i2 == 0 && mclink && mclink1) isolating = ancestor(mclink)==ancestor(mclink1); - // if (i2 == 1 && mclink && mclink2) isolating = ancestor(mclink)==ancestor(mclink2); - //} - - int hltgood = -1; - double fc = 0.; - Gaudi::XYZPoint omu( o_mu( 0, i2 ), o_mu( 1, i2 ), o_mu( 2, i2 ) ); - Gaudi::XYZVector pmu( p_mu( 0, i2 ), p_mu( 1, i2 ), p_mu( 2, i2 ) ); - // find roadmap isolation (only long tracks) - IsHltGood( o, p, omu, pmu, PosPV, hltgood, fc ); - if ( msgLevel( MSG::DEBUG ) ) debug() << "=========== 8" << endmsg; - - // find doca and angle between input and other tracks - Gaudi::XYZPoint vtx( 0., 0., 0. ); - double doca( -1. ); - double angle( -1. ); - InCone( omu, pmu, o, p, vtx, doca, angle ); - // find impact parameters, distances from secondary and primary vertex - doca2[i2] = doca; - if ( doca2[i2] < bestdoca[i2] ) { - if ( i2 == 0 ) bestpart_0 = cand; - if ( i2 == 1 ) bestpart_1 = cand; - bestdoca[i2] = doca2[i2]; - } - double imp = 0.; - double impchi2 = 0.; - double ips, pvdis, svdis; - ips = 100000.; - RecVertex::Container::const_iterator iv; - RecVertex::Container* verts = NULL; - if ( exist( m_PVInputLocation ) ) { - verts = get( m_PVInputLocation ); - } - for ( iv = verts->begin(); iv != verts->end(); iv++ ) { - m_Geom->distance( &( *cand ), ( *iv ), imp, impchi2, geometry ) - .ignore( /* AUTOMATICALLY ADDED FOR gaudi/Gaudi!763 */ ); - if ( impchi2 < ips ) ips = impchi2; - } - ips = std::sqrt( ips ); - if ( msgLevel( MSG::DEBUG ) ) debug() << "=========== 9" << endmsg; - - // double deltaZvtx = (vtx.z()-PosPV.z()); - - pvdis = ( vtx.z() - PosPV.z() ) / fabs( vtx.z() - PosPV.z() ) * ( vtx - PosPV ).R(); - svdis = ( vtx.z() - PosSV.z() ) / fabs( vtx.z() - PosSV.z() ) * ( vtx - PosSV ).R(); - - // bool is_iso5 = false; - - float clone = proto->track()->info( LHCb::Track::AdditionalInfo::CloneDist, 100000 ); - float ghost = proto->track()->ghostProbability(); - double trchi2 = proto->track()->chi2() / proto->track()->nDoF(); - // non-isolating criteria #5 - if ( angle < m_angle && fc < m_fc && doca < m_doca && ips > m_ips && svdis > m_svdis && svdis < m_svdis_h && - pvdis > m_pvdis && pvdis < m_pvdis_h && clone > m_clone && ghost < m_ghost && - track->type() == m_tracktype && trchi2 < m_trchi2 && hltgood > m_hltgood ) { - // is_iso5 = true; - if ( i2 == 0 ) iso_parts_0.push_back( cand ); - if ( i2 == 1 ) iso_parts_1.push_back( cand ); - iso5[i2] += 1; - if ( msgLevel( MSG::DEBUG ) ) debug() << "isiso " << i2 << iso5[i2] << endmsg; - } - - } // i<2 - - } // (!isInList) - } // allparts - - massiso[0] = 0.; - chi2iso[0] = -100.; - massiso[1] = 0.; - chi2iso[1] = -100.; - - LHCb::Vertex vertex0; - LHCb::Particle mother0; - LHCb::Vertex vertex1; - LHCb::Particle mother1; - if ( msgLevel( MSG::DEBUG ) ) debug() << "=========== 11" << endmsg; - - if ( iso_parts_0.size() > 1 ) { - - StatusCode sc0 = StatusCode::SUCCESS; - sc0 = m_combiner->combine( iso_parts_0, mother0, vertex0, geometry ); - if ( sc0 == StatusCode::SUCCESS ) { - massiso[0] = mother0.measuredMass(); - chi2iso[0] = mother0.endVertex()->chi2(); - chi2iso[0] = chi2iso[0] / mother0.endVertex()->nDoF(); - } - } - - else { - iso_parts_0.push_back( bestpart_0 ); - if ( msgLevel( MSG::DEBUG ) ) debug() << "trying to get to this stage " << endmsg; - StatusCode sc0a = StatusCode::SUCCESS; - sc0a = m_combiner->combine( iso_parts_0, mother0, vertex0, geometry ); - if ( sc0a == StatusCode::SUCCESS ) { - chi2iso[0] = mother0.endVertex()->chi2(); - chi2iso[0] = chi2iso[0] / mother0.endVertex()->nDoF(); - } - } - - if ( iso_parts_1.size() > 1 ) { - StatusCode sc1 = StatusCode::SUCCESS; - sc1 = m_combiner->combine( iso_parts_1, mother1, vertex1, geometry ); - if ( sc1 == StatusCode::SUCCESS ) { - massiso[1] = mother1.measuredMass(); - chi2iso[1] = mother1.endVertex()->chi2(); - chi2iso[1] = chi2iso[1] / mother1.endVertex()->nDoF(); - } - } - - else { - iso_parts_1.push_back( bestpart_1 ); - StatusCode sc1a = StatusCode::SUCCESS; - sc1a = m_combiner->combine( iso_parts_1, mother1, vertex1, geometry ); - if ( sc1a == StatusCode::SUCCESS ) { - chi2iso[1] = mother1.endVertex()->chi2(); - chi2iso[1] = chi2iso[1] / mother1.endVertex()->nDoF(); - } - } - - if ( msgLevel( MSG::DEBUG ) ) debug() << "NTRACKS " << j << endmsg; - - // this is idiotic, but oh well... - - // iso[0] = iso5[0]; - // iso[1] = iso5[1]; - - // fatima, fill here - if ( msgLevel( MSG::DEBUG ) ) { - debug() << "massiso " << massiso[0] << " " << massiso[1] << " chi2iso " << chi2iso[0] << " " << chi2iso[1] - << endmsg; - debug() << " Usual iso5 " << iso5[0] << " " << iso5[1] << endmsg; - } - - bool test = tuple->column( prefix + "_P1_massiso", massiso[0] ).isSuccess(); - test &= tuple->column( prefix + "_P2_massiso", massiso[1] ); - - test &= tuple->column( prefix + "_P1_Q", storeCharge[0] ); - test &= tuple->column( prefix + "_P2_Q", storeCharge[1] ); - - test &= tuple->column( prefix + "_P1_chi2iso", chi2iso[0] ); - test &= tuple->column( prefix + "_P2_chi2iso", chi2iso[1] ); - - test &= tuple->column( prefix + "_P1_iso5", iso5[0] ); - test &= tuple->column( prefix + "_P2_iso5", iso5[1] ); - - if ( test ) - return StatusCode::SUCCESS; - else - return StatusCode::FAILURE; -} - -//============================================================================= -// -//============================================================================= -void TupleToolIsolationTwoBody::IsHltGood( Gaudi::XYZPoint o, Gaudi::XYZVector p, Gaudi::XYZPoint o_mu, - Gaudi::XYZVector p_mu, Gaudi::XYZPoint PV, int& hltgood, double& fc ) const { - - Gaudi::XYZVector rv; - Gaudi::XYZPoint vtx; - Gaudi::XYZPoint close; - Gaudi::XYZPoint close_mu; - bool fail( false ); - closest_point( o, p, o_mu, p_mu, close, close_mu, vtx, fail ); - if ( fail ) { - fc = -1.; - hltgood = -1; - } else { - double pete = p.Rho(); - rv = vtx - PV; - double DOCA_b = ( close - close_mu ).R(); - double ZZ = rv.z(); - fc = pointer( rv, p, p_mu ); - if ( ( DOCA_b < 0.2 ) && ( ZZ > 0. ) && ( ZZ < 30. ) && ( fc < 0.4 ) && ( pete > 2. ) ) hltgood = 1; - } -} - -//============================================================================= -// -//============================================================================= -void TupleToolIsolationTwoBody::InCone( Gaudi::XYZPoint o1, Gaudi::XYZVector p1, Gaudi::XYZPoint o2, - Gaudi::XYZVector p2, Gaudi::XYZPoint& vtx, double& doca, double& angle ) const { - Gaudi::XYZPoint rv; - Gaudi::XYZPoint close; - Gaudi::XYZPoint close_mu; - bool fail( false ); - closest_point( o1, p1, o2, p2, close, close_mu, vtx, fail ); - if ( fail ) { - doca = -1.; - angle = -1.; - } else { - doca = ( close - close_mu ).R(); - angle = arcosine( p1, p2 ); - } -} - -//============================================================================= -// -//============================================================================= -double TupleToolIsolationTwoBody::pointer( Gaudi::XYZVector vertex, Gaudi::XYZVector p, Gaudi::XYZVector p_mu ) const { - double pt = p.Rho() + p_mu.Rho(); - Gaudi::XYZVector ptot( p + p_mu ); - double num = ptot.R() * sin( arcosine( vertex, ptot ) ); - double den = ( num + pt ); - double fc = num / den; - return fc; -} - -//============================================================================= -// -//============================================================================= -double TupleToolIsolationTwoBody::ratio( double p1, double p2 ) const { - return TMath::Abs( p1 - p2 ) * ( 1. / TMath::Abs( p1 + p2 ) ); -} - -//============================================================================= -// -//============================================================================= - -double TupleToolIsolationTwoBody::arcosine( Gaudi::XYZVector p1, Gaudi::XYZVector p2 ) const { - - double num = ( p1.Cross( p2 ) ).R(); - double den = p1.R() * p2.R(); - double seno = num / den; - double coseno = p1.Dot( p2 ) / den; - double alpha = asin( fabs( seno ) ); - if ( coseno < 0 ) { alpha = ROOT::Math::Pi() - alpha; } - return alpha; -} - -//============================================================================= -// -//============================================================================= -void TupleToolIsolationTwoBody::closest_point( Gaudi::XYZPoint o, Gaudi::XYZVector p, Gaudi::XYZPoint o_mu, - Gaudi::XYZVector p_mu, Gaudi::XYZPoint& close1, Gaudi::XYZPoint& close2, - Gaudi::XYZPoint& vertex, bool& fail ) const { - Gaudi::XYZVector v0( o - o_mu ); - Gaudi::XYZVector v1( p.unit() ); - Gaudi::XYZVector v2( p_mu.unit() ); - Gaudi::XYZPoint temp1( 0., 0., 0. ); - Gaudi::XYZPoint temp2( 0., 0., 0. ); - fail = false; - - double d02 = v0.Dot( v2 ); - double d21 = v2.Dot( v1 ); - double d01 = v0.Dot( v1 ); - double d22 = v2.Dot( v2 ); - double d11 = v1.Dot( v1 ); - double denom = d11 * d22 - d21 * d21; - if ( fabs( denom ) <= 0. ) { - close1 = temp1; - close2 = temp2; - fail = true; - } else { - double numer = d02 * d21 - d01 * d22; - double mu1 = numer / denom; - double mu2 = ( d02 + d21 * mu1 ) / d22; - close1 = o + v1 * mu1; - close2 = o_mu + v2 * mu2; - } - vertex = ( close1 + ( close2 - close1 ) * 0.5 ); -} - -//============================================================================= -// -//============================================================================= -const LHCb::MCParticle* TupleToolIsolationTwoBody::ancestor( const LHCb::MCParticle* imc ) const { - if ( imc->mother() ) { - const LHCb::MCParticle* mc_mom = imc->mother(); - if ( msgLevel( MSG::DEBUG ) ) { - debug() << "iso c " << mc_mom << endmsg; - debug() << "iso c " << mc_mom->momentum() << endmsg; - debug() << "iso c " << mc_mom->particleID() << endmsg; - debug() << "iso c " << mc_mom->mother() << endmsg; - } - return ancestor( mc_mom ); - } else { - return imc; - } -} diff --git a/Phys/DecayTreeTuple/src/TupleToolKinematic.cpp b/Phys/DecayTreeTuple/src/TupleToolKinematic.cpp deleted file mode 100644 index 386022ae5521f8c36f383f13769fcd1c480f3643..0000000000000000000000000000000000000000 --- a/Phys/DecayTreeTuple/src/TupleToolKinematic.cpp +++ /dev/null @@ -1,182 +0,0 @@ -/*****************************************************************************\ -* (c) Copyright 2000-2018 CERN for the benefit of the LHCb Collaboration * -* * -* This software is distributed under the terms of the GNU General Public * -* Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". * -* * -* In applying this licence, CERN does not waive the privileges and immunities * -* granted to it by virtue of its status as an Intergovernmental Organization * -* or submit itself to any jurisdiction. * -\*****************************************************************************/ - -#include "DecayTreeTupleBase/TupleToolBase.h" - -#include "Event/Particle.h" - -#include "Kernel/IParticleTransporter.h" -#include "Kernel/IParticleTupleTool.h" - -#include "GaudiAlg/Tuple.h" -#include "GaudiAlg/TupleObj.h" - -/** - * \brief Fill kinematic information for DecayTreeTuple - * - * - head_P : momentum's amplitude - * - head_PT : transverse momentum - * - head_P[E|X|Y|Z] : four vector momentum - * - head_MM : measured mass (or assigned mass in case of 'basic' particle - * - head_M : mass calculated from momentum four-vector - * - head_MMERR : error on the measured mass (only for non-basic parts) - * - * if Verbose: - * - * - head_REFP[X|Y|Z]: one point the particle momentum extrapolation - goes through - * - head_PreFitMass: Mass of 4-vectors of daughters, not yet extrapolated - * to the head decay vertex (only for composites). This is the quantity - * used in ADAMASS or AM in CombineParticles.CombinationCut - * - prefix_AtVtx_P[X|Y|Z]: momentum information of basic particles at - * origin vertex position - * - * \sa DecayTreeTuple - * - * @author Jeremie Borel - * @date 2007-11-07 - */ -class TupleToolKinematic : public TupleToolBase, virtual public IParticleTupleTool { -public: - /// Standard constructor - TupleToolKinematic( const std::string& type, const std::string& name, const IInterface* parent ); - - StatusCode fill( const LHCb::Particle*, const LHCb::Particle*, const std::string&, Tuples::Tuple&, - IGeometryInfo const& geometry ) override; - - double preFitMass( const LHCb::Particle* ) const; - - const LHCb::Vertex* originVertex( const LHCb::Particle* top, const LHCb::Particle* P ) const; - - StatusCode initialize() override; - -private: - IParticleTransporter* m_transporter; - std::string m_transporterName; -}; - -// Declaration of the Tool Factory -// actually acts as a using namespace TupleTool -DECLARE_COMPONENT( TupleToolKinematic ) - -//============================================================================= -// Standard constructor, initializes variables -//============================================================================= -TupleToolKinematic::TupleToolKinematic( const std::string& type, const std::string& name, const IInterface* parent ) - : TupleToolBase( type, name, parent ), m_transporter(), m_transporterName( "ParticleTransporter:PUBLIC" ) { - declareInterface( this ); - - declareProperty( "Transporter", m_transporterName ); -} - -StatusCode TupleToolKinematic::initialize() { - const StatusCode sc = TupleToolBase::initialize(); - if ( sc.isFailure() ) return sc; - - m_transporter = tool( m_transporterName, this ); - - return sc; -} - -StatusCode TupleToolKinematic::fill( const LHCb::Particle* mother, const LHCb::Particle* P, const std::string& head, - Tuples::Tuple& tuple, IGeometryInfo const& geometry ) { - const std::string prefix = fullName( head ); - - bool test = true; - if ( P ) { - test &= tuple->column( prefix + "_P", P->p() ); - test &= tuple->column( prefix + "_PT", P->pt() ); - - // momentum components - test &= tuple->column( prefix + "_P", P->momentum() ); - - // reference point: - if ( isVerbose() ) test &= tuple->column( prefix + "_REFP", P->referencePoint() ); - // mass before fit (what CombinationCut cuts on) - // if(isVerbose() && !(P->isBasicParticle()) ) test &= tuple->column( prefix+"_PreFitMass", preFitMass(P) ); - - if ( !P->isBasicParticle() || P->particleID().pid() == 111 ) - test &= tuple->column( prefix + "_MM", P->measuredMass() ); - if ( !P->isBasicParticle() || P->particleID().pid() == 111 ) - test &= tuple->column( prefix + "_MMERR", P->measuredMassErr() ); - test &= tuple->column( prefix + "_M", P->momentum().M() ); - - // Compute momentum at origin vertex - if ( isVerbose() && mother && P->isBasicParticle() && P->charge() != 0 ) { - const LHCb::Vertex* originvtx = originVertex( mother, P ); - if ( originvtx ) { - double zvtx = originvtx->position().Z(); - - LHCb::Particle transParticle; - if ( !m_transporter ) - Error( "null pointer m_transporter !!!!" ).ignore( /* AUTOMATICALLY ADDED FOR gaudi/Gaudi!763 */ ); - test &= m_transporter->transport( P, zvtx, transParticle, geometry ); - - test &= tuple->column( prefix + "_AtVtx_P", transParticle.momentum() ); - test &= tuple->column( prefix + "_AtVtx_P", transParticle.p() ); - test &= tuple->column( prefix + "_AtVtx_PT", transParticle.pt() ); - } - - // Compute momentum at Secondary Vertex - const LHCb::Vertex* SV = mother->endVertex(); - if ( SV ) { - double zSV = SV->position().Z(); - - LHCb::Particle transParticle_SV; - if ( !m_transporter ) - Error( "null pointer m_transporter !!!!" ).ignore( /* AUTOMATICALLY ADDED FOR gaudi/Gaudi!763 */ ); - test &= m_transporter->transport( P, zSV, transParticle_SV, geometry ); - - test &= tuple->column( prefix + "_AtSV_P", transParticle_SV.momentum() ); - test &= tuple->column( prefix + "_AtSV_P", transParticle_SV.p() ); - test &= tuple->column( prefix + "_AtSV_PT", transParticle_SV.pt() ); - } - } - } else { - return StatusCode::FAILURE; - } - return StatusCode( test ); -} - -double TupleToolKinematic::preFitMass( const LHCb::Particle* p ) const { - Gaudi::LorentzVector Mom; - for ( SmartRefVector::const_iterator d = p->daughters().begin(); d != p->daughters().end(); ++d ) { - Mom += ( *d )->momentum(); - } - return Mom.M(); -} - -// ===================================================== -// find origin vertex in the decay chain -// ===================================================== -const LHCb::Vertex* TupleToolKinematic::originVertex( const LHCb::Particle* top, const LHCb::Particle* P ) const { - // this used to pass back zero if P was a basic particle. - if ( top == P || top->isBasicParticle() ) return nullptr; - - const auto& dau = top->daughters(); - if ( dau.empty() ) return nullptr; - - for ( const auto& d : dau ) { - if ( P == d ) { // I found the daughter - if ( msgLevel( MSG::VERBOSE ) ) verbose() << "It's a daughter, returning mother's endvertex : " << endmsg; - return top->endVertex(); - } - } - - // vertex not yet found, get deeper in the decay: - for ( const auto& d : dau ) { - const auto vv = originVertex( d, P ); - if ( !vv ) continue; - if ( msgLevel( MSG::VERBOSE ) ) verbose() << "Went up : " << vv << endmsg; - return vv; - } - return nullptr; -} diff --git a/Phys/DecayTreeTuple/src/TupleToolMassHypo.cpp b/Phys/DecayTreeTuple/src/TupleToolMassHypo.cpp deleted file mode 100644 index 958fcedfb7ec2ef943320550aa9cc3fac89b5df7..0000000000000000000000000000000000000000 --- a/Phys/DecayTreeTuple/src/TupleToolMassHypo.cpp +++ /dev/null @@ -1,249 +0,0 @@ -/*****************************************************************************\ -* (c) Copyright 2000-2018 CERN for the benefit of the LHCb Collaboration * -* * -* This software is distributed under the terms of the GNU General Public * -* Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". * -* * -* In applying this licence, CERN does not waive the privileges and immunities * -* granted to it by virtue of its status as an Intergovernmental Organization * -* or submit itself to any jurisdiction. * -\*****************************************************************************/ - -#include "DecayTreeTupleBase/TupleToolBase.h" - -#include "Kernel/Escape.h" -#include "Kernel/IParticlePropertySvc.h" -#include "Kernel/IParticleTransporter.h" -#include "Kernel/IParticleTupleTool.h" // Interface -#include "Kernel/ParticleProperty.h" - -#include "Event/Particle.h" - -#include "GaudiAlg/Tuple.h" -#include "GaudiAlg/TupleObj.h" - -typedef std::pair possPair; -typedef std::vector possDecay; // not a std::map -typedef std::vector possDecayVec; - -/** @class TupleToolMassHypo TupleToolMassHypo.h jborel/TupleToolMassHypo.h - * - * \brief Return mass of composite under another PID hypothesis - * - * An example for Ks0: - * \verbatim - from configurables import TupleToolMassHypo - Tuple.addTool(TupleToolMassHypo) - Tuple.TupleToolMassHypo.PIDReplacements = { "pi+" : "p+" } - Tuple.TupleToolMassHypo.CC = True - \endverbatim - * - * will create 4 new entries in the nTuple called KS0_M_with_piplus_piminus, - * KS0_M_with_piplus_p~minus, KS0_M_with_pplus_piminus, KS0_M_with_pplus_p~minus. - * - * Cases with 3 or more daughters are possible but not tested. - * - * Warnings: - * - * 1) PIDReplacement is a python dictionary. To test two mass hypthesis replacements - * for the same daughter you must used 2 tool instances. - * - * 2) When CC = True (default), PIDReplacements implies cc. - * - * \sa DecayTreeTuple - * - * @author Patrick Koppenburg - * @date 2011-02-10 - */ -class TupleToolMassHypo : public TupleToolBase, virtual public IParticleTupleTool { -public: - TupleToolMassHypo( const std::string& type, const std::string& name, const IInterface* parent ); - StatusCode initialize() override; - StatusCode fill( const LHCb::Particle*, const LHCb::Particle*, const std::string&, Tuples::Tuple&, - IGeometryInfo const& ) override; - -private: - double recalculateMass( const possDecay&, const Gaudi::XYZPoint&, std::string& combname, - IGeometryInfo const& geometry ); - possDecayVec getPossibilities( const LHCb::Particle::ConstVector& ); - possDecayVec increaseVector( const LHCb::Particle*, possDecayVec& ); - void addPossPair( const LHCb::Particle*, int pid, possDecay& ); - void printVec( const possDecayVec& ); - std::map m_replace; ///< the PIDs to replace - std::map m_replacePDG; ///< the PIDs to replace (as PDG codes) - bool m_revert; ///< revert to positive PDG codes (default) - bool m_first; - IParticleTransporter* m_transporter; - std::map m_massMap; - std::map m_nameMap; -}; - -// Declaration of the Tool Factory -// actually acts as a using namespace TupleTool -DECLARE_COMPONENT( TupleToolMassHypo ) - -//============================================================================= -// Standard constructor, initializes variables -//============================================================================= -TupleToolMassHypo::TupleToolMassHypo( const std::string& type, const std::string& name, const IInterface* parent ) - : TupleToolBase( type, name, parent ), m_first( true ), m_transporter() { - declareInterface( this ); - declareProperty( "PIDReplacements", m_replace, "List of PID replacements as dictionary of strings" ); - declareProperty( "CC", m_revert = true, "Do cc by default" ); -} - -StatusCode TupleToolMassHypo::initialize() { - const StatusCode sc = TupleToolBase::initialize(); - if ( sc.isFailure() ) return sc; - - LHCb::IParticlePropertySvc* ppsvc = svc( "LHCb::ParticlePropertySvc", true ); - - if ( m_revert ) info() << "Will apply cc on all replacement pairs" << endmsg; - - for ( std::map::const_iterator iterS = m_replace.begin(); iterS != m_replace.end(); - ++iterS ) { - const LHCb::ParticleProperty* prop1 = ppsvc->find( iterS->first ); - const LHCb::ParticleProperty* prop2 = ppsvc->find( iterS->second ); - if ( !prop1 || !prop2 ) { - err() << "one of " << iterS->first << " " << iterS->second << " does nor exist" << endmsg; - return StatusCode::FAILURE; - } - int pid = prop1->pdgID().pid(); - if ( m_revert ) pid = abs( pid ); - m_massMap.insert( std::pair( pid, prop1->mass() ) ); - m_massMap.insert( std::pair( prop2->pdgID().pid(), prop2->mass() ) ); - m_nameMap.insert( std::pair( pid, Decays::escape( prop1->name() ) ) ); - if ( msgLevel( MSG::VERBOSE ) ) - verbose() << "Inserted name ``" << Decays::escape( prop1->name() ) << "''" << endmsg; - m_nameMap.insert( std::pair( prop2->pdgID().pid(), Decays::escape( prop2->name() ) ) ); - if ( msgLevel( MSG::VERBOSE ) ) - verbose() << "Inserted name ``" << Decays::escape( prop2->name() ) << "''" << endmsg; - m_replacePDG.insert( std::pair( pid, prop2->pdgID().pid() ) ); - if ( msgLevel( MSG::VERBOSE ) ) - verbose() << "Inserted PID pair ``" << pid << "," << prop2->pdgID().pid() << "''" << endmsg; - } // iterS - m_transporter = tool( "ParticleTransporter:PUBLIC", this ); - - return sc; -} - -//============================================================================= -StatusCode TupleToolMassHypo::fill( const LHCb::Particle*, const LHCb::Particle* P, const std::string& head, - Tuples::Tuple& tuple, IGeometryInfo const& geometry ) { - if ( !P ) return StatusCode::FAILURE; - if ( P->isBasicParticle() ) return StatusCode::SUCCESS; - if ( msgLevel( MSG::VERBOSE ) ) verbose() << "Entering with a " << P->particleID().pid() << endmsg; - const std::string prefix = fullName( head ); - bool test = true; - - // first just return if the particle is a final state - LHCb::Particle::ConstVector dv = P->daughtersVector(); - - possDecayVec possibilities = getPossibilities( dv ); - if ( possibilities.size() == 1 ) { - Warning( "The decay of this particle does not contain the declared PIDs.", StatusCode::SUCCESS, 1 ) - .ignore( /* AUTOMATICALLY ADDED FOR gaudi/Gaudi!763 */ ); - return StatusCode::SUCCESS; // ignore cases where nothing is to be done - } - - for ( possDecayVec::const_iterator p = possibilities.begin(); p != possibilities.end(); ++p ) { - std::string combname; - if ( msgLevel( MSG::VERBOSE ) ) verbose() << "Old mass " << P->measuredMass() << endmsg; - double mass = recalculateMass( *p, P->referencePoint(), combname, geometry ); - test &= tuple->column( prefix + "_M_with" + combname, mass ); - if ( msgLevel( MSG::VERBOSE ) ) - verbose() << "Filled column ``" << prefix + "_M_with" + combname << "'' with mass " << mass << endmsg; - } // - - return StatusCode( test ); -} -//============================================================================= -double TupleToolMassHypo::recalculateMass( const possDecay& pd, const Gaudi::XYZPoint& pt, std::string& combname, - IGeometryInfo const& geometry ) { - Gaudi::LorentzVector newM; - for ( possDecay::const_iterator p = pd.begin(); p != pd.end(); ++p ) { - if ( msgLevel( MSG::VERBOSE ) ) verbose() << "Loop ``" << combname << "'' pid : ``" << p->second << "''" << endmsg; - const LHCb::Particle* P = p->first; - if ( m_nameMap.find( p->second ) != m_nameMap.end() ) combname += "_" + m_nameMap[p->second]; - LHCb::Particle transParticle; - m_transporter->transport( P, pt.z(), transParticle, geometry ) - .ignore( /* AUTOMATICALLY ADDED FOR gaudi/Gaudi!763 */ ); - Gaudi::LorentzVector mom = transParticle.momentum(); - if ( P->particleID().pid() != p->second || ( m_revert && P->particleID().pid() != -p->second ) ) { - double mm = m_massMap[p->second]; - if ( msgLevel( MSG::VERBOSE ) ) verbose() << "Momentum is " << mom << " new mass = " << mm << endmsg; - mom.SetE( sqrt( mom.P2() + ( mm * mm ) ) ); - if ( msgLevel( MSG::VERBOSE ) ) verbose() << "New Momentum is " << mom << endmsg; - } - newM += mom; - if ( msgLevel( MSG::VERBOSE ) ) verbose() << "Total Momentum is now " << newM << endmsg; - } - if ( msgLevel( MSG::VERBOSE ) ) verbose() << "New mass with " << combname << " is " << newM.M() << endmsg; - return newM.M(); -} -//============================================================================= -possDecayVec TupleToolMassHypo::getPossibilities( const LHCb::Particle::ConstVector& dv ) { - possDecayVec possibilities; - // loop over daghters - for ( LHCb::Particle::ConstVector::const_iterator d1 = dv.begin(); d1 != dv.end(); ++d1 ) { - if ( msgLevel( MSG::VERBOSE ) ) - verbose() << "getPossibilities Looping over " << ( *d1 )->particleID().pid() << endmsg; - possibilities = increaseVector( *d1, possibilities ); - if ( msgLevel( MSG::VERBOSE ) ) - verbose() << "getPossibilities Size of possibilities " << possibilities.size() << endmsg; - } - if ( ( possibilities.size() > 1 ) && ( msgLevel( MSG::DEBUG ) || m_first ) ) printVec( possibilities ); - if ( m_first ) m_first = false; - return possibilities; -} -//============================================================================= -void TupleToolMassHypo::addPossPair( const LHCb::Particle* d, int pid, possDecay& pm ) { - pm.push_back( possPair( d, pid ) ); - if ( msgLevel( MSG::VERBOSE ) ) verbose() << "addPossPair Added " << pid << " size: " << pm.size() << endmsg; -} - -//============================================================================= -// multiplies the vector -possDecayVec TupleToolMassHypo::increaseVector( const LHCb::Particle* d, possDecayVec& poss ) { - int pid = d->particleID().pid(); - if ( m_revert ) pid = abs( pid ); - if ( msgLevel( MSG::VERBOSE ) ) - verbose() << "increaseVector seeing a " << d->particleID().pid() << " treated as " << pid << endmsg; - possDecayVec tmp; - if ( poss.empty() ) { - possDecay pm; - addPossPair( d, pid, pm ); - tmp.push_back( pm ); - if ( m_replacePDG.find( pid ) != m_replacePDG.end() ) { - possDecay pm2; - addPossPair( d, m_replacePDG[pid], pm2 ); - tmp.push_back( pm2 ); - } - } else { - if ( msgLevel( MSG::VERBOSE ) ) verbose() << "increaseVector with poss size " << poss.size() << endmsg; - for ( possDecayVec::const_iterator i = poss.begin(); i != poss.end(); ++i ) { - possDecay pm = *i; - addPossPair( d, pid, pm ); - tmp.push_back( pm ); - if ( m_replacePDG.find( pid ) != m_replacePDG.end() ) { - int pid2 = m_replacePDG[pid]; - possDecay pm2 = *i; - addPossPair( d, pid2, pm2 ); - tmp.push_back( pm2 ); - } - } - } - if ( msgLevel( MSG::VERBOSE ) ) printVec( tmp ); - return tmp; -} - -//============================================================================= -void TupleToolMassHypo::printVec( const possDecayVec& possibilities ) { - for ( possDecayVec::const_iterator i = possibilities.begin(); i != possibilities.end(); ++i ) { - info() << "Combination: "; - for ( possDecay::const_iterator j = i->begin(); j != i->end(); ++j ) { - info() << j->first->particleID().pid() << ": " << j->second << ", "; - } - info() << endmsg; - } -} diff --git a/Phys/DecayTreeTuple/src/TupleToolNeutrinoReco.cpp b/Phys/DecayTreeTuple/src/TupleToolNeutrinoReco.cpp deleted file mode 100755 index fe29c71da7d5dbadef7e02964625158ded637cb2..0000000000000000000000000000000000000000 --- a/Phys/DecayTreeTuple/src/TupleToolNeutrinoReco.cpp +++ /dev/null @@ -1,255 +0,0 @@ -/*****************************************************************************\ -* (c) Copyright 2000-2018 CERN for the benefit of the LHCb Collaboration * -* * -* This software is distributed under the terms of the GNU General Public * -* Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". * -* * -* In applying this licence, CERN does not waive the privileges and immunities * -* granted to it by virtue of its status as an Intergovernmental Organization * -* or submit itself to any jurisdiction. * -\*****************************************************************************/ - -#include "DecayTreeTupleBase/TupleToolBase.h" - -#include "Kernel/GetIDVAlgorithm.h" -#include "Kernel/IDVAlgorithm.h" -#include "Kernel/IParticleTupleTool.h" - -#include "Event/Particle.h" - -#include "GaudiAlg/Tuple.h" -#include "GaudiAlg/TupleObj.h" - -/** @class TupleToolNeutrinoReco TupleToolNeutrinoReco.h - * - * \brief Fill neutrino reconstruction variables - * - * Assuming a particle of zero-mass has gone undetected, we can calculate - * the corrected momentum for the true moteh particle, if we know its mass. - * - * Firstly PT and P|| are the momenta perp and parl to the direction of flight. - * - * 0 = aP(neutrino)^2+bP(neutrino)+c - * a = 4(PT^2+M^2) - * b = 4P||(2PT^2 - mB^2 + M^2) = X - 4P||*mB^2 - * c = 4PT^2(P||^2 + mB^2) -(mB^2 - M^2)^2 = Y + 4PT ^2*mB*2 - (mB^2 - M^2)^2 - * - * P*(neutrino)= [-b +/- sqrt(b^2 - 4ac)]/(2a) - * - * With two ambiguous solutions - * - * PB=P||+P(neutrino) - * - * Option: - * - MotherMass: double: PDG Mass of the mother particle - * - * If no mother particle mass is set the following are filled: - * - * - head_Nu_Parl : momentum of the input particle paralell to the direction of flight - * - head_Nu_Perp : momentum of the input particle perpendicular to the direction of flight - * - * If a non-zero mother mass is set, the two solutions will be calculated - * - head_Nu_Hi : the B-momentum with the positive sqrt solution - * - head_Nu_Lo : the B-momentum with the negative sqrt solution - * - * If the verbose flag is set, the intemediate working will also be stored - * - head_Nu_a : a in the above equation - * - head_Nu_X : X in the above equation, 4P||(2PT^2 + M^2) - * - head_Nu_Y : Y in the above equation, 4PT^2*P||^2 - * - * It can be useful to store these variables, since they are the part of the - * equation which does not depend on the mass of the mother particle, in case an - * overall mass rescaling is required the remaining calculation can be done as follows: - * - * Note that the solution is given by the quadratic formula, - * Note also that -b/2a simplifies to: - * - * -b/2a = - P|| [ 1 - (mB^2 - PT^2)/(PT^2+M^2) ] / 2 - * - * So, with 'head' replaced by something like 'B0', and mB being the PDG mass: - * - * b = B0_Nu_X - 4*B0_Nu_Parl*mB*mB - * c = B0_Nu_Y + 4*B0_Nu_Perp*B0_Nu_Perp*mB*mB - (mB*mB - B0_MM*B0_MM)*(mB*mB - B0_MM*B0_MM) - * - * pb = -B0_Nu_Parl*( 1 - (mB*mB-B0_Nu_Perp*B0_Nu_Perp)/(B0_Nu_Perp*B0_Nu_Perp + B0_MM*B0_MM) )/2 - * pd = sqrt(b*b - 4*B0_Nu_a*c)/(2*B0_Nu_a) - * - * B0_Nu_Lo = B0_Nu_Parl+pb-pd - * B0_Nu_Hi = B0_Nu_Parl+pb+pd - * - * Are the two B-momentum solutions - * - * \sa DecayTreeTuple - * - * @author Rob Lambert - * @date 2010-11-30 - */ -class TupleToolNeutrinoReco : public TupleToolBase, virtual public IParticleTupleTool { - -public: - TupleToolNeutrinoReco( const std::string& type, const std::string& name, const IInterface* parent ); - - StatusCode initialize() override; - - StatusCode fill( const LHCb::Particle*, const LHCb::Particle*, const std::string&, Tuples::Tuple&, - IGeometryInfo const& ) override; - - double MomentumParallel( const LHCb::VertexBase*, const LHCb::Particle*, - const ROOT::Math::LorentzVector>* ); - - double MomentumPerpendicular( const LHCb::VertexBase*, const LHCb::Particle*, - const ROOT::Math::LorentzVector>* ); - - double MomentumQuadratic( const double, const double, const double ); - - double MomentumSqrt( const double, const double, const double ); - -private: - IDVAlgorithm* m_dva = nullptr; - double m_motherMass; -}; - -// Declaration of the Tool Factory -// actually acts as a using namespace TupleTool -DECLARE_COMPONENT( TupleToolNeutrinoReco ) - -//============================================================================= -// Standard constructor, initializes variables -//============================================================================= -TupleToolNeutrinoReco::TupleToolNeutrinoReco( const std::string& type, const std::string& name, - const IInterface* parent ) - : TupleToolBase( type, name, parent ) { - declareInterface( this ); - - declareProperty( "MotherMass", m_motherMass = 0. ); -} - -//============================================================================= - -StatusCode TupleToolNeutrinoReco::initialize() { - if ( !TupleToolBase::initialize() ) return StatusCode::FAILURE; - - m_dva = Gaudi::Utils::getIDVAlgorithm( contextSvc(), this ); - - if ( !m_dva ) return Error( "Couldn't get parent DVAlgorithm", StatusCode::FAILURE ); - - return StatusCode::SUCCESS; -} - -//============================================================================= - -StatusCode TupleToolNeutrinoReco::fill( const LHCb::Particle*, const LHCb::Particle* P, const std::string& head, - Tuples::Tuple& tuple, IGeometryInfo const& geometry ) { - const std::string prefix = fullName( head ); - - bool test = true; - if ( P ) { - const LHCb::VertexBase* aPV = m_dva->bestVertex( P, geometry ); - // Parallel and Perpendicular Momentum of the particle - // releative to the flight direction - double Nu_Parl = MomentumParallel( aPV, P, &P->momentum() ); - double Nu_Perp = MomentumPerpendicular( aPV, P, &P->momentum() ); - - if ( isVerbose() || m_motherMass == 0. ) { - - test &= tuple->column( prefix + "_Nu_Parl", Nu_Parl ); - test &= tuple->column( prefix + "_Nu_Perp", Nu_Perp ); - } - - if ( isVerbose() ) { - // intermediate steps, - // all that do not require the mother mass - - double a = 4. * ( Nu_Perp * Nu_Perp + P->measuredMass() * P->measuredMass() ); - double X = 4. * Nu_Parl * ( 2 * Nu_Perp * Nu_Perp + P->measuredMass() * P->measuredMass() ); - double Y = 4. * Nu_Perp * Nu_Perp * Nu_Parl * Nu_Parl; - test &= tuple->column( prefix + "_Nu_a", a ); - test &= tuple->column( prefix + "_Nu_X", X ); - test &= tuple->column( prefix + "_Nu_Y", Y ); - } - - if ( m_motherMass != 0. ) { - double pb = MomentumQuadratic( Nu_Parl, Nu_Perp, P->measuredMass() ); - double pd = MomentumSqrt( Nu_Parl, Nu_Perp, P->measuredMass() ); - - if ( isVerbose() ) { - test &= tuple->column( prefix + "_Nu_pb", pb ); - test &= tuple->column( prefix + "_Nu_pd", pd ); - } - - double P_Hi = Nu_Parl + pb + pd; - double P_Lo = Nu_Parl + pb - pd; - - test &= tuple->column( prefix + "_Nu_Hi", P_Hi ); - test &= tuple->column( prefix + "_Nu_Lo", P_Lo ); - } - - } else { - return StatusCode::FAILURE; - } - return StatusCode( test ); -} -double TupleToolNeutrinoReco::MomentumParallel( const LHCb::VertexBase* pv, const LHCb::Particle* b, - const ROOT::Math::LorentzVector>* mv ) { - - // fd means flight distance - if ( b->endVertex() == NULL || pv == NULL ) return 0.; - - double fd_x = b->endVertex()->position().X() - pv->position().X(); - double fd_y = b->endVertex()->position().Y() - pv->position().Y(); - double fd_z = b->endVertex()->position().Z() - pv->position().Z(); - - double fd = sqrt( fd_x * fd_x + fd_y * fd_y + fd_z * fd_z ); - - fd_x = fd_x / fd; - fd_y = fd_y / fd; - fd_z = fd_z / fd; - - // return the dot product of the flight distance unit vector - // with the momentum - return mv->Px() * fd_x + mv->Py() * fd_y + mv->Pz() * fd_z; -} - -double -TupleToolNeutrinoReco::MomentumPerpendicular( const LHCb::VertexBase* pv, const LHCb::Particle* b, - const ROOT::Math::LorentzVector>* mv ) { - if ( b->endVertex() == NULL || pv == NULL ) return 0.; - double fd_x = b->endVertex()->position().X() - pv->position().X(); - double fd_y = b->endVertex()->position().Y() - pv->position().Y(); - double fd_z = b->endVertex()->position().Z() - pv->position().Z(); - - double fd = sqrt( fd_x * fd_x + fd_y * fd_y + fd_z * fd_z ); - - fd_x = fd_x / fd; - fd_y = fd_y / fd; - fd_z = fd_z / fd; - - double P_Pa = mv->Px() * fd_x + mv->Py() * fd_y + mv->Pz() * fd_z; - - double P_Pa_x = fd_x * P_Pa; - double P_Pa_y = fd_y * P_Pa; - double P_Pa_z = fd_z * P_Pa; - - double P_Pe_x = mv->Px() - P_Pa_x; - double P_Pe_y = mv->Py() - P_Pa_y; - double P_Pe_z = mv->Pz() - P_Pa_z; - - return sqrt( P_Pe_x * P_Pe_x + P_Pe_y * P_Pe_y + P_Pe_z * P_Pe_z ); -} - -double TupleToolNeutrinoReco::MomentumQuadratic( const double Parl, const double Perp, const double Mass ) { - return -0.5 * Parl * ( 1. - ( m_motherMass * m_motherMass - Perp * Perp ) / ( Perp * Perp + Mass * Mass ) ); -} - -double TupleToolNeutrinoReco::MomentumSqrt( const double Parl, const double Perp, const double Mass ) { - double a = 4. * ( Perp * Perp + Mass * Mass ); - double b = 4. * Parl * ( 2. * Perp * Perp - m_motherMass * m_motherMass + Mass * Mass ); - double c = 4. * Perp * Perp * ( Parl * Parl + m_motherMass * m_motherMass ) - - ( m_motherMass * m_motherMass - Mass * Mass ) * ( m_motherMass * m_motherMass - Mass * Mass ); - - double d = b * b - 4. * a * c; - if ( d > 0. ) - return std::sqrt( d ) / ( 2. * a ); - else - return 0; -} diff --git a/Phys/DecayTreeTuple/src/TupleToolParticleReFit.cpp b/Phys/DecayTreeTuple/src/TupleToolParticleReFit.cpp deleted file mode 100755 index 9d5902ee887527c4b31184768b48ab685f90a0af..0000000000000000000000000000000000000000 --- a/Phys/DecayTreeTuple/src/TupleToolParticleReFit.cpp +++ /dev/null @@ -1,181 +0,0 @@ -/*****************************************************************************\ -* (c) Copyright 2000-2018 CERN for the benefit of the LHCb Collaboration * -* * -* This software is distributed under the terms of the GNU General Public * -* Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". * -* * -* In applying this licence, CERN does not waive the privileges and immunities * -* granted to it by virtue of its status as an Intergovernmental Organization * -* or submit itself to any jurisdiction. * -\*****************************************************************************/ - -#include "DecayTreeTupleBase/TupleToolBase.h" - -#include "Kernel/GetIDVAlgorithm.h" -#include "Kernel/IDVAlgorithm.h" -#include "Kernel/ILifetimeFitter.h" -#include "Kernel/IParticleTupleTool.h" -#include "Kernel/IVertexFit.h" - -#include "Event/Particle.h" -#include "Event/Vertex.h" - -#include "GaudiAlg/Tuple.h" -#include "GaudiAlg/TupleObj.h" -#include "GaudiKernel/SmartIF.h" - -/** - * \brief Use a standard vertex fitter to refit head of a decay chain and fill DecayTreeTuple - * - * Columns filled: - * - head_OVrefit_status - * - head_OVrefit_ENDVERTEX_NDOF - * - head_OVrefit_ENDVERTEX_CHI2 - * - head_OVrefit_MM - * - head_OVrefit_MMERR - * - head_OVrefit_P - * - head_OVrefit_PT - * - head_OVrefit_P[E|X|Y|Z] - * - head_OVrefit_TAU - * - head_OVrefit_TAUERR - * - head_OVrefit_TAUCHI2 - * - * The middle name "OV" standard for "OfflineVertexFitter" and can be changed - * by setting the "ExtraName" property. - * - * The main purpose of the tool is to get the MM and TAU varibales after - * refitting the B particle with or without a certain daughter mass cosntraint. - * - * Example 1: refit in order to apply daughter mass cosntraint - * tuple.addTool(TupleToolParticleReFit()) - * tuple.TupleToolParticleReFit.addTool(OfflineVertexFitter()) - * tuple.TupleToolParticleReFit.OfflineVertexFitter.useResonanceVertex = True - * tuple.TupleToolParticleReFit.OfflineVertexFitter.applyDauMassConstraint = True - * - * Example 2: refit in order to get rid of already applied daughter mass cosntraint - * tuple.TupleToolParticleReFit.OfflineVertexFitter.useResonanceVertex = False - * - * \sa DecayTreeTuple - * - * @author Yuehong Xie - * @date 2010-11-2 - */ -class TupleToolParticleReFit : public TupleToolBase, virtual public IParticleTupleTool { - -public: - TupleToolParticleReFit( const std::string& type, const std::string& name, const IInterface* parent ); - StatusCode initialize() override; - StatusCode fill( const LHCb::Particle*, const LHCb::Particle*, const std::string&, Tuples::Tuple&, - IGeometryInfo const& ) override; - -private: - IDVAlgorithm* m_dva = nullptr; - const ILifetimeFitter* m_timefitter = nullptr; - const IVertexFit* m_vtxfitter = nullptr; -}; - -using namespace LHCb; - -// Declaration of the Tool Factory -// actually acts as a using namespace TupleTool -DECLARE_COMPONENT( TupleToolParticleReFit ) - -//============================================================================= -// Standard constructor, initializes variables -//============================================================================= -TupleToolParticleReFit::TupleToolParticleReFit( const std::string& type, const std::string& name, - const IInterface* parent ) - : TupleToolBase( type, name, parent ) { - declareInterface( this ); -} - -StatusCode TupleToolParticleReFit::initialize() { - const StatusCode sc = TupleToolBase::initialize(); - if ( sc.isFailure() ) return sc; - - m_dva = Gaudi::Utils::getIDVAlgorithm( contextSvc(), this ); - if ( 0 == m_dva ) return Error( "Couldn't get parent DVAlgorithm", StatusCode::FAILURE ); - - m_timefitter = m_dva->lifetimeFitter(); - if ( !m_timefitter ) { return Error( "Unable to retrieve the ILifetimeFitter tool" ); } - - m_vtxfitter = m_dva->vertexFitter(); - if ( !m_vtxfitter ) { return Error( "Unable to retrieve the IVertexFit tool" ); } - - return sc; -} - -StatusCode TupleToolParticleReFit::fill( const Particle* mother, const Particle* P, const std::string& head, - Tuples::Tuple& tuple, IGeometryInfo const& geometry ) { - - std::string prefix = fullName( head ); - if ( m_extraName == "" ) prefix = prefix + "_OVrefit"; - - Assert( m_timefitter && m_vtxfitter && P, "Should not happen, you are inside TupleToolParticleReFit.cpp" ); - - // no proper-time for basic parts. - if ( P->isBasicParticle() ) return StatusCode::SUCCESS; - - // only head of a decay chain - if ( P != mother ) return StatusCode::SUCCESS; - - const VertexBase* originVtx = m_dva->bestVertex( mother, geometry ); - - if ( originVtx ) { - } // I'm happy - else { - return Error( "Can't get the origin vertex", StatusCode::FAILURE ); - } - - int refit_status = 0; - int refit_ndof = -100; - double refit_chi2 = -100; - - double refit_mass = -100; - double refit_massErr = -100; - - double refit_p = -100; - double refit_pt = -100; - - double time = -100; - double timeErr = -100; - double timeChi2 = -100; - - LHCb::Particle O( *P ); - StatusCode sc = m_vtxfitter->reFit( O, geometry ); - - if ( sc.isSuccess() ) { - refit_status = 1; - refit_ndof = O.endVertex()->nDoF(); - refit_chi2 = O.endVertex()->chi2(); - refit_p = O.p(); - refit_pt = O.pt(); - refit_mass = O.measuredMass(); - refit_massErr = O.measuredMassErr(); - - sc = m_timefitter->fit( *originVtx, O, time, timeErr, timeChi2, geometry ); - if ( !sc ) { - Warning( "The propertime fit failed in TupleToolParticleReFit" ).ignore(); - time = -100; - timeErr = -100; - timeChi2 = -100; - } - } - - bool test = true; - test &= tuple->column( prefix + "_status", refit_status ); - test &= tuple->column( prefix + "_ENDVERTEX_NDOF", refit_ndof ); - test &= tuple->column( prefix + "_ENDVERTEX_CHI2", refit_chi2 ); - test &= tuple->column( prefix + "_MM", refit_mass ); - test &= tuple->column( prefix + "_MMERR", refit_massErr ); - test &= tuple->column( prefix + "_P", refit_p ); - test &= tuple->column( prefix + "_PT", refit_pt ); - - test &= tuple->column( prefix + "_P", O.momentum() ); - - test &= tuple->column( prefix + "_TAU", time ); // nanoseconds - test &= tuple->column( prefix + "_TAUERR", timeErr ); - test &= tuple->column( prefix + "_TAUCHI2", timeChi2 ); - - return StatusCode( test ); -} diff --git a/Phys/DecayTreeTuple/src/TupleToolParticleStats.cpp b/Phys/DecayTreeTuple/src/TupleToolParticleStats.cpp deleted file mode 100644 index 2d2389a259e2410dbafdbc39157542d29cd4da33..0000000000000000000000000000000000000000 --- a/Phys/DecayTreeTuple/src/TupleToolParticleStats.cpp +++ /dev/null @@ -1,62 +0,0 @@ -/*****************************************************************************\ -* (c) Copyright 2000-2018 CERN for the benefit of the LHCb Collaboration * -* * -* This software is distributed under the terms of the GNU General Public * -* Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". * -* * -* In applying this licence, CERN does not waive the privileges and immunities * -* granted to it by virtue of its status as an Intergovernmental Organization * -* or submit itself to any jurisdiction. * -\*****************************************************************************/ -// Include files - -// from Gaudi -#include "TupleToolParticleStats.h" -#include "Event/ODIN.h" -#include "Event/Track.h" -#include "Event/VeloCluster.h" - -// local -#include "TupleToolParticleStats.h" - -//----------------------------------------------------------------------------- -// Implementation file for class : TupleToolParticleStats -// -// 2009-02-11 : Patrick Koppenburg -//----------------------------------------------------------------------------- - -//============================================================================= -// Standard constructor, initializes variables -//============================================================================= -TupleToolParticleStats::TupleToolParticleStats( const std::string& type, const std::string& name, - const IInterface* parent ) - : TupleToolBase( type, name, parent ), m_locations() { - declareInterface( this ); - declareProperty( "InputLocations", m_locations, "Locations to look at" ); - m_locations.push_back( "StdLooseAllPhotons" ); -} - -//============================================================================= -// Destructor -//============================================================================= -TupleToolParticleStats::~TupleToolParticleStats() {} -//============================================================================= - -//============================================================================= -StatusCode TupleToolParticleStats::fill( Tuples::Tuple& tup ) { - const std::string prefix = fullName(); - bool test = true; - for ( std::vector::const_iterator l = m_locations.begin(); l != m_locations.end(); ++l ) { - if ( !( exist( "/Event/Phys/" + *l + "/Particles" ) ) ) { - error() << " your configuration is problematic, tthe location you requested: " << endmsg; - error() << " >>> " << ( "/Event/Phys/" + *l + "/Particles" ) << " <<< doesnt seem to have been filled." - << endmsg; - continue; - } - test &= tup->column( prefix + "NumberOf" + *l, number( "/Event/Phys/" + *l + "/Particles" ) ); - } - return StatusCode( test ); -} - -// Declaration of the Tool Factory -DECLARE_COMPONENT( TupleToolParticleStats ) diff --git a/Phys/DecayTreeTuple/src/TupleToolParticleStats.h b/Phys/DecayTreeTuple/src/TupleToolParticleStats.h deleted file mode 100644 index 7cc97e105e73ea8dde32f740750d9d8cf4af0a8d..0000000000000000000000000000000000000000 --- a/Phys/DecayTreeTuple/src/TupleToolParticleStats.h +++ /dev/null @@ -1,42 +0,0 @@ -/*****************************************************************************\ -* (c) Copyright 2000-2018 CERN for the benefit of the LHCb Collaboration * -* * -* This software is distributed under the terms of the GNU General Public * -* Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". * -* * -* In applying this licence, CERN does not waive the privileges and immunities * -* granted to it by virtue of its status as an Intergovernmental Organization * -* or submit itself to any jurisdiction. * -\*****************************************************************************/ -#ifndef TUPLETOOLRECOSTATS_H -#define TUPLETOOLRECOSTATS_H 1 - -// Include files -// from Gaudi -#include "DecayTreeTupleBase/TupleToolBase.h" -#include "Kernel/IEventTupleTool.h" // Interface - -#include "Event/RecSummary.h" -#include "Event/Track.h" - -/** @class TupleToolParticleStats TupleToolParticleStats.h - * - * Fills Reco stats, from RecSummary - * - * @author Patrick Koppenburg, Fatima Soomro, Jibo He - * @date 2009-02-11 - */ -class TupleToolParticleStats : public TupleToolBase, virtual public IEventTupleTool { - -public: - /// Standard constructor - TupleToolParticleStats( const std::string& type, const std::string& name, const IInterface* parent ); - - virtual ~TupleToolParticleStats(); ///< Destructor - StatusCode fill( Tuples::Tuple& ) override; ///< Fill tuple - // int unusedVelo(); -private: - std::vector m_locations; ///< Hlt locations to look at -}; - -#endif // TUPLETOOLRECOSTATS_H diff --git a/Phys/DecayTreeTuple/src/TupleToolPhotonInfo.cpp b/Phys/DecayTreeTuple/src/TupleToolPhotonInfo.cpp deleted file mode 100755 index a968499962213f848900bb2b0fd7b680b6a866a3..0000000000000000000000000000000000000000 --- a/Phys/DecayTreeTuple/src/TupleToolPhotonInfo.cpp +++ /dev/null @@ -1,82 +0,0 @@ -/*****************************************************************************\ -* (c) Copyright 2000-2018 CERN for the benefit of the LHCb Collaboration * -* * -* This software is distributed under the terms of the GNU General Public * -* Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". * -* * -* In applying this licence, CERN does not waive the privileges and immunities * -* granted to it by virtue of its status as an Intergovernmental Organization * -* or submit itself to any jurisdiction. * -\*****************************************************************************/ - -#include "DecayTreeTupleBase/TupleToolBase.h" - -#include "CaloUtils/CaloParticle.h" - -#include "Event/Particle.h" - -#include "Kernel/IParticleTupleTool.h" - -#include "GaudiAlg/Tuple.h" -#include "GaudiAlg/TupleObj.h" -#include "GaudiKernel/IRegistry.h" - -/** - * @date 2008-10-31 - * @author Yasmine Amhis - */ -class TupleToolPhotonInfo : public TupleToolBase, virtual public IParticleTupleTool { -public: - TupleToolPhotonInfo( const std::string& type, const std::string& name, const IInterface* parent ); - StatusCode fill( const LHCb::Particle*, const LHCb::Particle*, const std::string&, Tuples::Tuple&, - IGeometryInfo const& ) override; - -private: - int m_PhotonID; -}; - -using namespace Gaudi; -using namespace LHCb; - -// Declaration of the Tool Factory -DECLARE_COMPONENT( TupleToolPhotonInfo ) - -//============================================================================= -// Standard constructor, initializes variables -//============================================================================= -TupleToolPhotonInfo::TupleToolPhotonInfo( const std::string& type, const std::string& name, const IInterface* parent ) - : TupleToolBase( type, name, parent ), m_PhotonID( 22 ) { - declareInterface( this ); -} - -//============================================================================= - -StatusCode TupleToolPhotonInfo::fill( const Particle*, const Particle* P, const std::string& head, Tuples::Tuple& tuple, - IGeometryInfo const& ) { - const std::string prefix = fullName( head ); - - bool filltuple = true; - if ( P ) { - if ( P->particleID().pid() == m_PhotonID && isPureNeutralCalo( P ) ) { - - const LHCb::ProtoParticle* proto = P->proto(); - if ( NULL == proto ) return StatusCode::SUCCESS; - - double match = proto->info( LHCb::ProtoParticle::CaloTrMatch, 9999. ); - double pid = proto->info( LHCb::ProtoParticle::PhotonID, 0. ); - double cnv = ( proto->info( LHCb::ProtoParticle::CaloDepositID, 0. ) < 0 ) ? 1 : 0; - double prs = proto->info( LHCb::ProtoParticle::CaloNeutralPrs, 0. ); - double shape = proto->info( LHCb::ProtoParticle::ShowerShape, 0. ); - - filltuple &= tuple->column( prefix + "_Converted", cnv ); - filltuple &= tuple->column( prefix + "_Prs", prs ); - filltuple &= tuple->column( prefix + "_Matching", match ); - filltuple &= tuple->column( prefix + "_PID", pid ); - filltuple &= tuple->column( prefix + "_CL", P->confLevel() ); - filltuple &= tuple->column( prefix + "_ShowerShape", shape ); - - } // this is a photon - } // get the particle - - return StatusCode( filltuple ); -} diff --git a/Phys/DecayTreeTuple/src/TupleToolPi0Info.cpp b/Phys/DecayTreeTuple/src/TupleToolPi0Info.cpp deleted file mode 100755 index f5bc10df1eefc054e7d6d2ec254c63a8efdcf797..0000000000000000000000000000000000000000 --- a/Phys/DecayTreeTuple/src/TupleToolPi0Info.cpp +++ /dev/null @@ -1,283 +0,0 @@ -/*****************************************************************************\ -* (c) Copyright 2000-2018 CERN for the benefit of the LHCb Collaboration * -* * -* This software is distributed under the terms of the GNU General Public * -* Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". * -* * -* In applying this licence, CERN does not waive the privileges and immunities * -* granted to it by virtue of its status as an Intergovernmental Organization * -* or submit itself to any jurisdiction. * -\*****************************************************************************/ - -#include "DecayTreeTupleBase/TupleToolBase.h" - -#include "Relations/RelationWeighted1D.h" - -#include "CaloUtils/Calo2MC.h" -#include "CaloUtils/CaloMomentum.h" -#include "CaloUtils/CaloParticle.h" - -#include "Kernel/IDaVinciAssociatorsWrapper.h" -#include "Kernel/IParticleTupleTool.h" -#include "Kernel/PP2MCLocation.h" -#include "Kernel/Particle2MCLinker.h" - -#include "Event/Particle.h" - -#include "GaudiAlg/Tuple.h" -#include "GaudiAlg/TupleObj.h" -#include "GaudiKernel/IRegistry.h" - -/** - *"pi0s are special creatures they should to be treated in a special way....." - * - * - *----- This Tool returns the MC particle associated to a Pi0( id and key) - * and its whole family - *----- The association is done via the relation table between the ProtoParticle and the MC - *----- The pi0 type (resolved or merged) is taken into account - *----- This tool runs in the HltContext do not forget to switch it on - * using HltContext = True from your DaVinci Python Script - *This is Obviously heavily inspired from Olivier Deschamps codes for B2PiPiPi0 - * - * - * \sa DecayTreeTuple - * @author Amhis Yasmine - * @date 2008-10-31 - */ -class TupleToolPi0Info : public TupleToolBase, virtual public IParticleTupleTool { -public: - TupleToolPi0Info( const std::string& type, const std::string& name, const IInterface* parent ); - StatusCode fill( const LHCb::Particle*, const LHCb::Particle*, const std::string&, Tuples::Tuple&, - IGeometryInfo const& ) override; - -private: - const LHCb::MCParticle* getMCPi0( const LHCb::Particle* part, double& weight ); - const LHCb::MCParticle* getMCGamma( const LHCb::Particle* part, double& weight ); - - typedef IRelationWeighted mcTable; - typedef mcTable::Range mcRange; - mcRange getRange( const LHCb::Particle* part ); - mcRange getRange( const LHCb::ProtoParticle* proto ); - - bool m_RequireMCTruth; - int m_Pi0ID{111}; - std::vector m_assocInputs; -}; - -using namespace Gaudi; -using namespace LHCb; - -// Declaration of the Tool Factory -DECLARE_COMPONENT( TupleToolPi0Info ) - -//============================================================================= -// Standard constructor, initializes variables -//============================================================================= -TupleToolPi0Info::TupleToolPi0Info( const std::string& type, const std::string& name, const IInterface* parent ) - : TupleToolBase( type, name, parent ) { - declareInterface( this ); - declareProperty( "RequireMCTruth", m_RequireMCTruth = false ); -} - -//============================================================================= -StatusCode TupleToolPi0Info::fill( const Particle*, const Particle* P, const std::string& head, Tuples::Tuple& tuple, - IGeometryInfo const& ) { - const std::string prefix = fullName( head ); - - bool filltuple = true; - if ( P ) { - if ( P->particleID().pid() == m_Pi0ID && isPureNeutralCalo( P ) ) { - if ( msgLevel( MSG::DEBUG ) ) { - debug() << " Make the special case for the pi0 " << P->particleID().pid() << endmsg; - debug() << " The pi0s has : " << P->daughters().size() << " daughters " << endmsg; - } - const int Type = ( !P->daughters().empty() ? 2 : 1 ); - // 2 = resolved, 1 = merged. - - filltuple &= tuple->column( prefix + "_Type", Type ); - filltuple &= tuple->column( prefix + "_CL", P->confLevel() ); - - // daughter info in case of merged pi0 - if ( Type == 1 ) { - const auto hypo = P->proto()->calo().front(); - if ( LHCb::CaloHypo::Pi0Merged != hypo->hypothesis() ) { - // == extract SplitPhotons hypos - const auto& hypos = hypo->hypos(); - if ( hypos.size() > 1 ) { - const auto g1 = *( hypos.begin() ); - const auto g2 = *( hypos.begin() + 1 ); - filltuple &= tuple->column( prefix + "_gamma0_PT", LHCb::CaloMomentum( g1 ).pt() ); - filltuple &= tuple->column( prefix + "_gamma1_PT", LHCb::CaloMomentum( g2 ).pt() ); - } - } - } - - if ( m_RequireMCTruth ) { - Warning( "MC association with TupleToolPi0Info is deprecated - please use the standard TupleToolMCTruth", - StatusCode::SUCCESS ) - .ignore(); - if ( msgLevel( MSG::DEBUG ) ) debug() << "Get the association done for a pi0 " << endmsg; - const MCParticle* MCPi0 = nullptr; - const MCParticle* MCPi0Mother = nullptr; - const MCParticle* MCPi0GrandMother = nullptr; - const MCParticle* MCPi0GrandGrandMother = nullptr; - - int MCPi0_id = 0; - int MCPi0Mother_id = 0; - int MCPi0GrandMother_id = 0; - int MCPi0GrandGrandMother_id = 0; - int MCPi0_key = 0; - int MCPi0Mother_key = 0; - int MCPi0GrandMother_key = 0; - int MCPi0GrandGrandMother_key = 0; - double weight = 1; - - MCPi0 = getMCPi0( P, weight ); - if ( MCPi0 ) { - MCPi0_id = MCPi0->particleID().pid(); - MCPi0_key = MCPi0->key(); - MCPi0Mother = MCPi0->mother(); - } // particleMC info - if ( MCPi0Mother ) { - MCPi0Mother_id = MCPi0Mother->particleID().pid(); - MCPi0Mother_key = MCPi0Mother->key(); - MCPi0GrandMother = MCPi0Mother->mother(); - } // particle mother MC info - - if ( MCPi0GrandMother ) { - MCPi0GrandMother_id = MCPi0GrandMother->particleID().pid(); - MCPi0GrandMother_key = MCPi0GrandMother->key(); - MCPi0GrandGrandMother = MCPi0GrandMother->mother(); - } - if ( MCPi0GrandGrandMother ) { - MCPi0GrandGrandMother_key = MCPi0GrandGrandMother->key(); - MCPi0GrandGrandMother_id = MCPi0GrandGrandMother->particleID().pid(); - } - - filltuple &= tuple->column( prefix + "_MCPi0_id", MCPi0_id ); - filltuple &= tuple->column( prefix + "_MCPi0_key", MCPi0_key ); - - filltuple &= tuple->column( prefix + "_MCPi0Mother_id", MCPi0Mother_id ); - filltuple &= tuple->column( prefix + "_MCPi0Mother_key", MCPi0Mother_key ); - - filltuple &= tuple->column( prefix + "_MCPi0GrandMother_id", MCPi0GrandMother_id ); - filltuple &= tuple->column( prefix + "_MCPi0GrandMother_key", MCPi0GrandMother_key ); - - filltuple &= tuple->column( prefix + "_MCPi0GrandGrandMother_id", MCPi0GrandGrandMother_id ); - filltuple &= tuple->column( prefix + "_MCPi0GrandGrandMother_key", MCPi0GrandGrandMother_key ); - if ( msgLevel( MSG::DEBUG ) ) - debug() << "This is the MC part associated to your pi0 --> " << MCPi0_id << " and its mother -->" - << MCPi0Mother_id << endmsg; - } // require MC truth - } // this is a pi0 - } // get the particle - - return StatusCode( filltuple ); -} - -//================================================================================ -// Here you get the protoparticle corresponding to your pi0 candidate -//================================================================================ -TupleToolPi0Info::mcRange TupleToolPi0Info::getRange( const LHCb::Particle* part ) { - const auto* proto = ( part ? part->proto() : nullptr ); - return ( proto ? getRange( proto ) : mcRange() ); -} - -//================================================================================ -// Here you get the relation table between the protoparticles and the MC particles -//================================================================================ -TupleToolPi0Info::mcRange TupleToolPi0Info::getRange( const LHCb::ProtoParticle* proto ) { - if ( !proto ) return mcRange(); - std::string locationhard; - if ( 0 == proto->charge() ) { - if ( context() == "HLT" ) { - debug() << " You are running in the Hlt context " << context() << endmsg; - locationhard = "Relations/Hlt/ProtoP/Neutrals"; - } else { - debug() << "You are running in the Offline context " << context() << endmsg; - locationhard = "Relations/Rec/ProtoP/Neutrals"; - } - } // check neutral - const mcTable* table = get( locationhard ); - // create protoP<->MC output relation table - if ( msgLevel( MSG::DEBUG ) ) debug() << "ProtoP<->MC output relation table " << table << endmsg; - return ( table ? table->relations( proto ) : mcRange() ); -} -//======================================================================================= - -const LHCb::MCParticle* TupleToolPi0Info::getMCPi0( const LHCb::Particle* part, double& weight ) { - // Return the highest-weighted matching MCPart WITH THE SAME particleID than part->ID - // if not the highest-weighted among ALL matching MCPart then weight = -weight - // If not found return the highest-weighted matching MCPART (irrespective of part->ID) - - weight = 0; - if ( !part ) return nullptr; - - double weightMax = -99999; - double weightPart = -99999; - LHCb::MCParticle* mcBest = nullptr; - LHCb::MCParticle* mcPart = nullptr; - - if ( !part->daughters().empty() ) { - //============================== - // special case of ResolvedPi0s - //============================== - const auto& daughters = part->daughters(); - auto ig1 = daughters.begin(); - auto ig2 = ig1 + 1; - auto range1 = getRange( *ig1 ); - auto range2 = getRange( *ig2 ); - if ( range1.empty() || range2.empty() ) return nullptr; - for ( const auto& r1 : range1 ) { - for ( const auto& r2 : range2 ) { - auto w = r1.weight(); - if ( r2.weight() > r1.weight() ) w = r2.weight(); - if ( r1.to() == r2.to() ) w = r1.weight() + r2.weight(); - if ( w > weightMax ) { - weightMax = w; - mcBest = r1.to(); - if ( r2.weight() > r1.weight() ) mcBest = r2.to(); - } - if ( m_Pi0ID == abs( r1.to()->particleID().pid() ) && r1.to() == r2.to() ) { - if ( w > weightPart ) { - mcPart = r1.to(); - weightPart = w; - } - } - } - } - } else { - //============== - // Pi0 merged - //============== - auto range = getRange( part ); - if ( range.empty() ) return nullptr; - for ( const auto& r : range ) { - auto w = r.weight(); - if ( w > weightMax ) { - weightMax = w; - mcBest = r.to(); - } - if ( m_Pi0ID == abs( r.to()->particleID().pid() ) ) { - if ( w > weightPart ) { - mcPart = r.to(); - weightPart = w; - } - } - } - } - // - if ( mcPart ) { - weight = weightPart; - if ( weightPart < weightMax ) weight = -weightPart; - return mcPart; - } else if ( mcBest ) { - weight = weightMax; - return mcBest; - } else { - weight = 0; - return nullptr; - } -} -//================================================================================================== diff --git a/Phys/DecayTreeTuple/src/TupleToolPid.cpp b/Phys/DecayTreeTuple/src/TupleToolPid.cpp deleted file mode 100755 index 8bfeefbdac45baf67e38be4a021433fd7302770d..0000000000000000000000000000000000000000 --- a/Phys/DecayTreeTuple/src/TupleToolPid.cpp +++ /dev/null @@ -1,165 +0,0 @@ -/*****************************************************************************\ -* (c) Copyright 2000-2018 CERN for the benefit of the LHCb Collaboration * -* * -* This software is distributed under the terms of the GNU General Public * -* Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". * -* * -* In applying this licence, CERN does not waive the privileges and immunities * -* granted to it by virtue of its status as an Intergovernmental Organization * -* or submit itself to any jurisdiction. * -\*****************************************************************************/ - -#include "DecayTreeTupleBase/TupleToolBase.h" - -#include "Kernel/IParticleTupleTool.h" // Interface - -#include "Event/Particle.h" - -#include "GaudiAlg/Tuple.h" -#include "GaudiAlg/TupleObj.h" - -/** - * @brief DLL and PID information to be stored in a Tuple - * - * \sa DecayTreeTuple - * - * For all particles: - * - head_ID : particleID().pid(); - * - * For the long lived particles (isBasicParticle()). - * - head_PIDe : LHCb::ProtoParticle::CombDLLe - * - head_PIDmu : LHCb::ProtoParticle::CombDLLmu - * - head_PIDK : LHCb::ProtoParticle::CombDLLk - * - head_PIDp : LHCb::ProtoParticle::CombDLLp - * - * @author Jeremie Borel - * @date 2007-11-07 - * - * Add more info: - * -hasRich: proto->richPID()!=0 - * -hasCalo: proto->calo().size()>0 - * -hasMuon: proto->muonPID()!=0 - * -isMuon: proto->muonPID->IsMuon() - * - * @date 2010-03-04 - */ -struct TupleToolPid : TupleToolBase, virtual IParticleTupleTool { - - TupleToolPid( const std::string& type, const std::string& name, const IInterface* parent ); - StatusCode fill( const LHCb::Particle*, const LHCb::Particle*, const std::string&, Tuples::Tuple&, - IGeometryInfo const& ) override; -}; - -using namespace LHCb; - -//============================================================================= -// Standard constructor, initializes variables -//============================================================================= -TupleToolPid::TupleToolPid( const std::string& type, const std::string& name, const IInterface* parent ) - : TupleToolBase( type, name, parent ) { - declareInterface( this ); -} - -StatusCode TupleToolPid::fill( const Particle*, const Particle* P, const std::string& head, Tuples::Tuple& tuple, - IGeometryInfo const& ) { - if ( P ) { - const std::string prefix = fullName( head ); - - bool test = true; - test &= tuple->column( prefix + "_ID", P->particleID().pid() ); - - if ( !P->isBasicParticle() ) return StatusCode( test ); // no PID info for composite! - if ( isPureNeutralCalo( P ) ) return StatusCode( test ); // no PID information for calo neutrals - - const ProtoParticle* proto = P->proto(); - if ( proto ) { - - // Combined DLLs - test &= tuple->column( prefix + "_PIDe", proto->info( LHCb::ProtoParticle::CombDLLe, -1000 ) ); - test &= tuple->column( prefix + "_PIDmu", proto->info( LHCb::ProtoParticle::CombDLLmu, -1000 ) ); - test &= tuple->column( prefix + "_PIDK", proto->info( LHCb::ProtoParticle::CombDLLk, -1000 ) ); - test &= tuple->column( prefix + "_PIDp", proto->info( LHCb::ProtoParticle::CombDLLp, -1000 ) ); - test &= tuple->column( prefix + "_PIDd", proto->info( LHCb::ProtoParticle::CombDLLd, -1000 ) ); - - // The MVA probabilities - // There is one for each hypothesis - test &= tuple->column( prefix + "_ProbNNe", proto->info( LHCb::ProtoParticle::ProbNNe, -1000 ) ); - test &= tuple->column( prefix + "_ProbNNk", proto->info( LHCb::ProtoParticle::ProbNNk, -1000 ) ); - test &= tuple->column( prefix + "_ProbNNp", proto->info( LHCb::ProtoParticle::ProbNNp, -1000 ) ); - test &= tuple->column( prefix + "_ProbNNpi", proto->info( LHCb::ProtoParticle::ProbNNpi, -1000 ) ); - test &= tuple->column( prefix + "_ProbNNmu", proto->info( LHCb::ProtoParticle::ProbNNmu, -1000 ) ); - test &= tuple->column( prefix + "_ProbNNd", proto->info( LHCb::ProtoParticle::ProbNNd, -1000 ) ); - test &= tuple->column( prefix + "_ProbNNghost", proto->info( LHCb::ProtoParticle::ProbNNghost, -1000 ) ); - - // Muon - const MuonPID* muonPID = proto->muonPID(); - test &= tuple->column( prefix + "_hasMuon", muonPID != NULL ); - test &= tuple->column( prefix + "_isMuon", muonPID ? muonPID->IsMuon() : false ); - - // RICH - const RichPID* richPID = proto->richPID(); - test &= tuple->column( prefix + "_hasRich", richPID != NULL ); - // Moved some RICH information variables to default since they are useful to determine - // how the PID information has been obtained. - test &= tuple->column( prefix + "_UsedRichAerogel", richPID ? richPID->usedAerogel() : false ); - test &= tuple->column( prefix + "_UsedRich1Gas", richPID ? richPID->usedRich1Gas() : false ); - test &= tuple->column( prefix + "_UsedRich2Gas", richPID ? richPID->usedRich2Gas() : false ); - test &= tuple->column( prefix + "_RichAboveElThres", richPID ? richPID->electronHypoAboveThres() : false ); - test &= tuple->column( prefix + "_RichAboveMuThres", richPID ? richPID->muonHypoAboveThres() : false ); - test &= tuple->column( prefix + "_RichAbovePiThres", richPID ? richPID->pionHypoAboveThres() : false ); - test &= tuple->column( prefix + "_RichAboveKaThres", richPID ? richPID->kaonHypoAboveThres() : false ); - test &= tuple->column( prefix + "_RichAbovePrThres", richPID ? richPID->protonHypoAboveThres() : false ); - - // CALO - test &= tuple->column( prefix + "_hasCalo", !proto->calo().empty() ); - - // The kitchen sink ... - if ( isVerbose() ) { - - // RICH variables - test &= tuple->column( prefix + "_RichDLLe", proto->info( LHCb::ProtoParticle::RichDLLe, -1000 ) ); - test &= tuple->column( prefix + "_RichDLLmu", proto->info( LHCb::ProtoParticle::RichDLLmu, -1000 ) ); - test &= tuple->column( prefix + "_RichDLLpi", proto->info( LHCb::ProtoParticle::RichDLLpi, -1000 ) ); - test &= tuple->column( prefix + "_RichDLLk", proto->info( LHCb::ProtoParticle::RichDLLk, -1000 ) ); - test &= tuple->column( prefix + "_RichDLLp", proto->info( LHCb::ProtoParticle::RichDLLp, -1000 ) ); - test &= tuple->column( prefix + "_RichDLLd", proto->info( LHCb::ProtoParticle::RichDLLd, -1000 ) ); - test &= tuple->column( prefix + "_RichDLLbt", proto->info( LHCb::ProtoParticle::RichDLLbt, -1000 ) ); - - // Muon variables - test &= tuple->column( prefix + "_InAccMuon", proto->info( LHCb::ProtoParticle::InAccMuon, false ) > 0.5 ); - test &= tuple->column( prefix + "_isMuonLoose", muonPID ? muonPID->IsMuonLoose() : false ); - test &= tuple->column( prefix + "_isMuonTight", muonPID ? muonPID->IsMuonTight() : false ); - test &= tuple->column( prefix + "_MuonMuLL", muonPID ? muonPID->MuonLLMu() : -1000 ); - test &= tuple->column( prefix + "_MuonBkgLL", muonPID ? muonPID->MuonLLBg() : -1000 ); - test &= tuple->column( prefix + "_MuonNShared", muonPID ? muonPID->nShared() : -1 ); - test &= tuple->column( prefix + "_MuonChi2Corr", muonPID ? muonPID->chi2Corr() : -1. ); - - // ECAL variables - test &= tuple->column( prefix + "_InAccEcal", proto->info( LHCb::ProtoParticle::InAccEcal, false ) > 0.5 ); - test &= tuple->column( prefix + "_CaloEcalE", proto->info( LHCb::ProtoParticle::CaloEcalE, -10000. ) ); - test &= tuple->column( prefix + "_EcalPIDe", proto->info( LHCb::ProtoParticle::EcalPIDe, -10000. ) ); - test &= tuple->column( prefix + "_EcalPIDmu", proto->info( LHCb::ProtoParticle::EcalPIDmu, -10000. ) ); - - // HCAL - test &= tuple->column( prefix + "_InAccHcal", proto->info( LHCb::ProtoParticle::InAccHcal, false ) > 0.5 ); - test &= tuple->column( prefix + "_CaloHcalE", proto->info( LHCb::ProtoParticle::CaloHcalE, -10000. ) ); - test &= tuple->column( prefix + "_HcalPIDe", proto->info( LHCb::ProtoParticle::HcalPIDe, -10000. ) ); - test &= tuple->column( prefix + "_HcalPIDmu", proto->info( LHCb::ProtoParticle::HcalPIDmu, -10000. ) ); - - // BREM - test &= tuple->column( prefix + "_InAccBrem", proto->info( LHCb::ProtoParticle::InAccBrem, false ) > 0.5 ); - test &= tuple->column( prefix + "_BremPIDe", proto->info( LHCb::ProtoParticle::BremPIDe, -10000. ) ); - - // VELO - test &= tuple->column( prefix + "_VeloCharge", proto->info( LHCb::ProtoParticle::VeloCharge, -10000. ) ); - } - - return StatusCode( test ); - } - } - - return StatusCode::FAILURE; -} - -// Declaration of the Tool Factory -DECLARE_COMPONENT( TupleToolPid ) diff --git a/Phys/DecayTreeTuple/src/TupleToolPropertime.cpp b/Phys/DecayTreeTuple/src/TupleToolPropertime.cpp deleted file mode 100644 index 93a180d16913e28a60225c193c6d8af4040dc788..0000000000000000000000000000000000000000 --- a/Phys/DecayTreeTuple/src/TupleToolPropertime.cpp +++ /dev/null @@ -1,151 +0,0 @@ -/*****************************************************************************\ -* (c) Copyright 2000-2018 CERN for the benefit of the LHCb Collaboration * -* * -* This software is distributed under the terms of the GNU General Public * -* Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". * -* * -* In applying this licence, CERN does not waive the privileges and immunities * -* granted to it by virtue of its status as an Intergovernmental Organization * -* or submit itself to any jurisdiction. * -\*****************************************************************************/ - -#include "DecayTreeTupleBase/TupleToolBase.h" - -#include "Kernel/IParticleTupleTool.h" -#include -#include -#include - -#include "Event/Particle.h" -#include "Event/Vertex.h" - -#include "GaudiAlg/Tuple.h" -#include "GaudiAlg/TupleObj.h" -#include "GaudiKernel/SmartIF.h" - -/** - * \brief Fills the propertime for DecayTreeTuple - * - * Columns filled: - * - head_TAU - * - head_TAUERR - * - head_TAUCHI2 - * - * \sa DecayTreeTuple - * - * @author Jeremie Borel - * @date 2007-11-07 - */ -class TupleToolPropertime : public TupleToolBase, virtual public IParticleTupleTool { - -public: - TupleToolPropertime( const std::string& type, const std::string& name, const IInterface* parent ); - StatusCode initialize() override; - StatusCode fill( const LHCb::Particle*, const LHCb::Particle*, const std::string&, Tuples::Tuple&, - IGeometryInfo const& ) override; - -private: - const LHCb::Vertex* originVertex( const LHCb::Particle*, const LHCb::Particle* ) const; - - IDVAlgorithm* m_dva; - const ILifetimeFitter* m_fit; - bool m_fitToPV; -}; - -using namespace LHCb; - -// Declaration of the Tool Factory -// actually acts as a using namespace TupleTool -DECLARE_COMPONENT( TupleToolPropertime ) - -//============================================================================= -// Standard constructor, initializes variables -//============================================================================= -TupleToolPropertime::TupleToolPropertime( const std::string& type, const std::string& name, const IInterface* parent ) - : TupleToolBase( type, name, parent ), m_dva( 0 ), m_fit( 0 ) { - declareInterface( this ); - // true determines proper time of all particles w.r.t. their best PV - // false (default) determines proper time w.r.t. mother particle - declareProperty( "FitToPV", m_fitToPV = false ); -} - -StatusCode TupleToolPropertime::initialize() { - if ( !TupleToolBase::initialize() ) return StatusCode::FAILURE; - - m_dva = Gaudi::Utils::getIDVAlgorithm( contextSvc(), this ); - if ( 0 == m_dva ) return Error( "Couldn't get parent DVAlgorithm", StatusCode::FAILURE ); - - m_fit = m_dva->lifetimeFitter(); - if ( !m_fit ) { return Error( "Unable to retrieve the ILifetimeFitter tool" ); } - - return StatusCode::SUCCESS; -} - -StatusCode TupleToolPropertime::fill( const Particle* mother, const Particle* P, const std::string& head, - Tuples::Tuple& tuple, IGeometryInfo const& geometry ) { - - const std::string prefix = fullName( head ); - - Assert( m_fit && P, "Should not happen, you are inside TupleToolPropertime.cpp" ); - - // no proper-time for basic parts. - if ( P->isBasicParticle() ) return StatusCode::SUCCESS; - - const VertexBase* originVtx = NULL; - if ( m_fitToPV ) { - originVtx = m_dva->bestVertex( P, geometry ); - } else { - if ( mother != P ) { - originVtx = originVertex( mother, P ); // the origin vertex is - // somewhere in the decay - } else { // the origin vertex is the primary. - originVtx = m_dva->bestVertex( mother, geometry ); - } - } - - if ( originVtx ) { - } // I'm happy - else { - Error( "Can't get the origin vertex" ).ignore( /* AUTOMATICALLY ADDED FOR gaudi/Gaudi!763 */ ); - return StatusCode::FAILURE; - } - - double pt = -100; - double ept = -100; - double chi2 = -100; - StatusCode sc = m_fit->fit( *originVtx, *P, pt, ept, chi2, geometry ); - - if ( !sc ) { - Warning( "The propertime fit failed" ).ignore(); - pt = -100; - ept = -100; - chi2 = -100; - } - - bool test = true; - test &= tuple->column( prefix + "_TAU", pt ); // nanoseconds - test &= tuple->column( prefix + "_TAUERR", ept ); - test &= tuple->column( prefix + "_TAUCHI2", chi2 ); - - return StatusCode( test ); -} - -const Vertex* TupleToolPropertime::originVertex( const Particle* top, const Particle* P ) const { - if ( top == P || P->isBasicParticle() ) return NULL; - - const SmartRefVector& dau = top->daughters(); - if ( dau.empty() ) return NULL; - - for ( SmartRefVector::const_iterator it = dau.begin(); dau.end() != it; ++it ) { - if ( P == *it ) { return top->endVertex(); } - } - - // vertex not yet found, get deeper in the decay: - for ( SmartRefVector::const_iterator it = dau.begin(); dau.end() != it; ++it ) { - if ( P != *it && !( *it )->isBasicParticle() ) { - const Vertex* vv = originVertex( *it, P ); - if ( vv ) return vv; - } - } - return NULL; -} diff --git a/Phys/DecayTreeTuple/src/TupleToolRadUpDownAsym.cpp b/Phys/DecayTreeTuple/src/TupleToolRadUpDownAsym.cpp deleted file mode 100644 index d73f5d4162eed99bbc64291a5e2ef7e89ae0b928..0000000000000000000000000000000000000000 --- a/Phys/DecayTreeTuple/src/TupleToolRadUpDownAsym.cpp +++ /dev/null @@ -1,213 +0,0 @@ -/*****************************************************************************\ -* (c) Copyright 2000-2019 CERN for the benefit of the LHCb Collaboration * -* * -* This software is distributed under the terms of the GNU General Public * -* Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". * -* * -* In applying this licence, CERN does not waive the privileges and immunities * -* granted to it by virtue of its status as an Intergovernmental Organization * -* or submit itself to any jurisdiction. * -\*****************************************************************************/ - -#include "DecayTreeTupleBase/TupleToolBase.h" - -#include "Kernel/IParticleTupleTool.h" // Interface - -#include "Event/Particle.h" - -#include "GaudiAlg/Tuple.h" -#include "GaudiAlg/TupleObj.h" -#include "GaudiKernel/PhysicalConstants.h" -#include "GaudiKernel/Vector3DTypes.h" -#include "GaudiKernel/Vector4DTypes.h" - -#include "Math/Boost.h" - -#include "gsl/gsl_sys.h" - -/** - * @Original author: C. Potterat - * @Code Mantainer: A. Puig - * @Date: 05-02-2019 - * - * \brief Add relative angles of a photon with respect to different combination of daughters to DecayTreeTuple. - * For 3 body decays plus photon - * - * Tuple columns: - * - head_UpDownCosTheta(XY): Angle between gamma and combination X-Y of particles (x3 combinations) - * - head_UpDownID(X): ID of each particle (x3 particles) - */ -class TupleToolRadUpDownAsym : public TupleToolBase, virtual public IParticleTupleTool { - -public: - TupleToolRadUpDownAsym( const std::string& type, const std::string& name, const IInterface* parent ); - StatusCode fill( const LHCb::Particle*, const LHCb::Particle*, const std::string&, Tuples::Tuple&, - IGeometryInfo const& ) override; - -private: - bool UpDownTheta( const LHCb::Particle* top, const LHCb::Particle* part, std::vector& angleValue, - std::vector& pidValue ) const; - - bool isEndTree( const LHCb::Particle* p ) const; - std::vector getTree( const LHCb::Particle* P ) const; -}; - -using namespace LHCb; - -// Declaration of the Tool Factory -DECLARE_COMPONENT( TupleToolRadUpDownAsym ) - -//============================================================================= -// Standard constructor, initializes variables -//============================================================================= -TupleToolRadUpDownAsym::TupleToolRadUpDownAsym( const std::string& type, const std::string& name, - const IInterface* parent ) - : TupleToolBase( type, name, parent ) { - declareInterface( this ); -} - -//============================================================================= -// Fill -//============================================================================= -StatusCode TupleToolRadUpDownAsym::fill( const LHCb::Particle* top, const LHCb::Particle* part, const std::string& head, - Tuples::Tuple& tuple, IGeometryInfo const& ) { - const std::string prefix = fullName( head ); - - std::vector angleValue; - std::vector pidValue; - - angleValue.push_back( -999 ); - angleValue.push_back( -999 ); - angleValue.push_back( -999 ); - pidValue.push_back( -999 ); - pidValue.push_back( -999 ); - pidValue.push_back( -999 ); - - bool test = true; - test = UpDownTheta( top, part, angleValue, pidValue ); - if ( !test ) return StatusCode::SUCCESS; - // fill the tuple: - test &= tuple->column( prefix + "_UpDownCosTheta12", angleValue[0] ); - test &= tuple->column( prefix + "_UpDownCosTheta13", angleValue[1] ); - test &= tuple->column( prefix + "_UpDownCosTheta23", angleValue[2] ); - test &= tuple->column( prefix + "_UpDownID1", pidValue[0] ); - test &= tuple->column( prefix + "_UpDownID2", pidValue[1] ); - test &= tuple->column( prefix + "_UpDownID3", pidValue[2] ); - - return StatusCode( test ); -} -//============================================================================= -// Fill -//============================================================================= - -bool TupleToolRadUpDownAsym::isEndTree( const LHCb::Particle* p ) const { - if ( p->isBasicParticle() ) return true; - // converted photons, pi0 and V0s are considered as basic particles - if ( (int)p->particleID().abspid() == 22 ) return true; // gamma - if ( (int)p->particleID().abspid() == 111 ) return true; // pi0 - if ( (int)p->particleID().abspid() == 310 ) return true; // KS0 - if ( (int)p->particleID().abspid() == 130 ) return true; // KL0 - if ( (int)p->particleID().abspid() == 3122 ) return true; // Lambda - return false; -} - -std::vector TupleToolRadUpDownAsym::getTree( const LHCb::Particle* P ) const { - std::vector tree; - if ( isEndTree( P ) ) { - tree.push_back( P ); - } else { - SmartRefVector daughters = P->daughters(); // local copy to sort - for ( SmartRefVector::const_iterator idau = daughters.begin(); idau != daughters.end(); ++idau ) { - std::vector temp = getTree( *idau ); - for ( std::vector::iterator dd = temp.begin(); temp.end() != dd; ++dd ) { - tree.push_back( *dd ); - } - } - } - return tree; -} - -bool TupleToolRadUpDownAsym::UpDownTheta( const LHCb::Particle* top, const LHCb::Particle* part, - std::vector& angleValue, std::vector& pidValue ) const { - - if ( top != part ) return false; - - SmartRefVector dau = part->daughters(); - - if ( dau.empty() ) return false; - if ( dau.size() != 2 ) return false; - - Gaudi::LorentzVector gamma; - Gaudi::LorentzVector res; - Gaudi::LorentzVector h1; - Gaudi::LorentzVector h2; - Gaudi::LorentzVector h3; - double pidh1 = -999; - double pidh2 = -999; - double pidh3 = -999; - - for ( SmartRefVector::const_iterator it = dau.begin(); dau.end() != it; ++it ) { - if ( ( *it )->particleID().abspid() == 22 ) // found the gamma - gamma = Gaudi::LorentzVector( ( *it )->momentum() ); - else { // found the resonance - res = Gaudi::LorentzVector( ( *it )->momentum() ); - const std::vector dau_res = getTree( *it ); - if ( dau_res.empty() ) return false; - if ( dau_res.size() != 3 ) return false; - double fac = ( ( *it )->particleID().pid() > 0 ) ? 1. : -1.; - - for ( std::vector::const_iterator it2 = dau_res.begin(); dau_res.end() != it2; ++it2 ) { - if ( ( *it2 )->charge() * fac < 0 ) { - h3 = Gaudi::LorentzVector( ( *it2 )->momentum() ); - pidh3 = ( *it2 )->particleID().pid(); - } else if ( pidh1 == -999 ) { - h1 = Gaudi::LorentzVector( ( *it2 )->momentum() ); - pidh1 = ( *it2 )->particleID().pid(); - } else { - h2 = Gaudi::LorentzVector( ( *it2 )->momentum() ); - pidh2 = ( *it2 )->particleID().pid(); - } - } - } - } - - ROOT::Math::Boost boost( res.BoostToCM() ); - - const Gaudi::LorentzVector boostedh1 = boost( h1 ); - const Gaudi::LorentzVector boostedh2 = boost( h2 ); - const Gaudi::LorentzVector boostedh3 = boost( h3 ); - const Gaudi::LorentzVector boostedgamma = boost( gamma ); - - const Gaudi::LorentzVector res12 = Gaudi::LorentzVector( boostedh1 + boostedh2 ); - const Gaudi::LorentzVector res13 = Gaudi::LorentzVector( boostedh1 + boostedh3 ); - const Gaudi::LorentzVector res23 = Gaudi::LorentzVector( boostedh2 + boostedh3 ); - - double s12 = res12.M2(); - double s13 = res13.M2(); - double s23 = res23.M2(); - - // Calculate cos theta - - const Gaudi::XYZVector h1V = Gaudi::XYZVector( boostedh1 ).unit(); - const Gaudi::XYZVector h2V = Gaudi::XYZVector( boostedh2 ).unit(); - const Gaudi::XYZVector h3V = Gaudi::XYZVector( boostedh3 ).unit(); - const Gaudi::XYZVector gammaV = Gaudi::XYZVector( boostedgamma ).unit(); - - const Gaudi::XYZVector n12 = ( h1V.Cross( h2V ) ).unit(); - const Gaudi::XYZVector n13 = ( h1V.Cross( h3V ) ).unit(); - const Gaudi::XYZVector n23 = ( h2V.Cross( h3V ) ).unit(); - - double costheta12 = n12.Dot( -gammaV ); - double costheta13 = n13.Dot( -gammaV ); - double costheta23 = n23.Dot( -gammaV ); - // Correct sign and return - angleValue[0] = ( s13 > s23 ) ? costheta12 : -costheta12; - angleValue[1] = ( s12 > s23 ) ? costheta13 : -costheta13; - angleValue[2] = ( s12 > s13 ) ? costheta23 : -costheta23; - - pidValue[0] = pidh1; - pidValue[1] = pidh2; - pidValue[2] = pidh3; - - return true; -} diff --git a/Phys/DecayTreeTuple/src/TupleToolSubMass.cpp b/Phys/DecayTreeTuple/src/TupleToolSubMass.cpp deleted file mode 100644 index 531e4bc9bc9ae01513501b2be6a0003e916bc773..0000000000000000000000000000000000000000 --- a/Phys/DecayTreeTuple/src/TupleToolSubMass.cpp +++ /dev/null @@ -1,471 +0,0 @@ -/*****************************************************************************\ -* (c) Copyright 2000-2018 CERN for the benefit of the LHCb Collaboration * -* * -* This software is distributed under the terms of the GNU General Public * -* Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". * -* * -* In applying this licence, CERN does not waive the privileges and immunities * -* granted to it by virtue of its status as an Intergovernmental Organization * -* or submit itself to any jurisdiction. * -\*****************************************************************************/ - -#include "DecayTreeTupleBase/TupleToolBase.h" - -#include "Event/Particle.h" - -#include "Kernel/GetIDVAlgorithm.h" -#include "Kernel/IDVAlgorithm.h" -#include "Kernel/IDistanceCalculator.h" -#include "Kernel/IParticleCombiner.h" -#include "Kernel/IParticlePropertySvc.h" -#include "Kernel/IParticleTupleTool.h" // Interface -#include "Kernel/ParticleProperty.h" - -#include "GaudiAlg/Tuple.h" -#include "GaudiAlg/TupleObj.h" - -#include - -/** - * \brief Return all n-bodies mass combinations from the decay tree - * - * - * \verbatim -from configurables import TupleToolSubMass -Tuple.addTool(TupleToolSubMass) -Tuple.TupleToolSubMass.SetMax = 3 # look to 2- and 3-bodies (defaut all possible n-bodies) -\endverbatim - * - * - will create Sum_{p=2,max) C(N,p) new entries in the nTuple called [head]_M[ij...] - * - * - Particle daughters are sorted by PID at each branch of the tree (cc-independant) - * - * **** Substitution property - * - * - usage : - * TupleTool.Substitution += ["pi+ => K+"] - * TupleTool.Substitution += ["K+ => pi+"] - * - * - produce alternative mass with substituted PID pi<->K (cc is assumed) - * - * -change only one pion (K) at once in case of several pion (K) in the decay tree (producing separate output par pion -(K) ) - * - * **** DoubleSubstitution property - * - * - usage : - * TupleTool.DoubleSubstitution += ["K+/pi- => pi+/K-"] - * TupleTool.DoubleSubstitution += ["K+/K-" => pi+/pi-"] - * - * - change all [K+pi-]cc ([K+K-]cc) pairs to (pi+K-)cc ([pi+pi-]cc) - * - change only one pair at once in case of several pairs in the decay tree (producing separate output per pair) - * - "/" separator is not mandatory : K+pi- syntax is allowed (just a bit slower to parse) - * - * @author Olivier Deschamps - * @date 2011-06-01 - * 2011-02-10 Patrick Koppenburg - */ -class SortDaughtersByPID { -public: - SortDaughtersByPID( const LHCb::Particle* P, LHCb::IParticlePropertySvc* ppsvc ) { - m_sign = 1; - m_ppsvc = ppsvc; - if ( P ) m_sign = ( P->particleID().pid() > 0 ) ? +1 : -1; - } - bool operator()( const LHCb::Particle* c1, const LHCb::Particle* c2 ) { - int p1 = ( property( c1->particleID() )->selfcc() ) ? c1->particleID().pid() : m_sign * c1->particleID().pid(); - int p2 = ( property( c2->particleID() )->selfcc() ) ? c2->particleID().pid() : m_sign * c2->particleID().pid(); - // special case c1 == c2 but with different decay structure (e.g. pi0->g(g->ee) : check daughters size - if ( p1 == p2 && c1->daughters().size() != c2->daughters().size() ) - return c1->daughters().size() > c2->daughters().size(); - // add a complete test of the decay structure (above test won't work for e.g. Bs->phi(KsKs)phi(K+K-) decay - // .. - // else - return p1 > p2; - }; - -private: - const LHCb::ParticleProperty* property( const LHCb::ParticleID pid ) { - return ( m_ppsvc ) ? m_ppsvc->find( pid ) : NULL; - }; - LHCb::IParticlePropertySvc* m_ppsvc; - int m_sign; -}; - -class TupleToolSubMass : public TupleToolBase, virtual public IParticleTupleTool { -public: - /// Standard constructor - TupleToolSubMass( const std::string& type, const std::string& name, const IInterface* parent ); - - StatusCode initialize() override; ///< initialisation - - StatusCode fill( const LHCb::Particle*, const LHCb::Particle*, const std::string&, Tuples::Tuple&, - IGeometryInfo const& ) override; - -private: - std::vector> combine( std::vector> vec, unsigned int level, int nfs ); - std::vector getTree( const LHCb::Particle* P ); - bool isEndTree( const LHCb::Particle* p ); - bool fillVertexInfo( const LHCb::Particle* P, std::vector tree, const std::vector map, - Tuples::Tuple& tuple, const std::string prefix, IGeometryInfo const& geometry ); - std::pair getMass( std::vector tree, const std::vector map, - int sPos = -1, double sMass = 0., int sPos2 = -1, double sMass2 = 0. ); - std::string getFlag( std::string from, std::string to, int pos, std::string from2 = "", std::string to2 = "", - int pos2 = -1 ); - Gaudi::LorentzVector sMomentum( const LHCb::Particle* part, double sMass ); - std::pair parseID( std::string PID ); - std::pair parseSubst( std::string subst ); - - unsigned int m_max; - std::vector m_subst; - std::vector m_subst2; - LHCb::IParticlePropertySvc* m_ppsvc; - const LHCb::ParticleProperty* property( std::string name ) { return ( m_ppsvc ) ? m_ppsvc->find( name ) : NULL; }; - const LHCb::ParticleProperty* property( const LHCb::ParticleID pid ) { - return ( m_ppsvc ) ? m_ppsvc->find( pid ) : NULL; - }; - const LHCb::Particle* m_ancestor; - IDVAlgorithm* m_dva; - bool m_vertex; - std::vector m_endTree; -}; - -// Declaration of the Tool Factory -// actually acts as a using namespace TupleTool -DECLARE_COMPONENT( TupleToolSubMass ) - -//============================================================================= -// Standard constructor, initializes variables -//============================================================================= -TupleToolSubMass::TupleToolSubMass( const std::string& type, const std::string& name, const IInterface* parent ) - : TupleToolBase( type, name, parent ), m_dva( 0 ), m_vertex( true ), m_endTree() { - declareInterface( this ); - declareProperty( "SetMax", m_max = 0 ); - declareProperty( "Substitution", m_subst ); - declareProperty( "DoubleSubstitution", m_subst2 ); - declareProperty( "SubVertexFit", m_vertex ); - declareProperty( "EndTreePIDs", m_endTree ); - - // converted photons and V0s are considered as basic particles - m_endTree.push_back( 22 ); - m_endTree.push_back( 310 ); // - m_endTree.push_back( 3122 ); // -} - -StatusCode TupleToolSubMass::initialize() { - const StatusCode sc = TupleToolBase::initialize(); - if ( sc.isFailure() ) return sc; - - // get parent DV - m_dva = Gaudi::Utils::getIDVAlgorithm( contextSvc(), this ); - if ( !m_dva ) { return Error( "Couldn't get parent DVAlgorithm", StatusCode::FAILURE ); } - // get property service - m_ppsvc = svc( "LHCb::ParticlePropertySvc", true ); - - // consistentcy checks - for ( std::vector::const_iterator is = m_subst.begin(); m_subst.end() != is; ++is ) { - const std::pair fromto = parseSubst( *is ); - const std::string from = fromto.first; - const std::string to = fromto.second; - if ( NULL == property( from ) ) - return Warning( "Cannot substitute from unknown particle " + from, StatusCode::FAILURE ); - if ( NULL == property( to ) ) return Warning( "Cannot substitute to unknown particle " + to, StatusCode::FAILURE ); - } - for ( std::vector::const_iterator is = m_subst2.begin(); m_subst2.end() != is; ++is ) { - const std::pair fromto = parseSubst( *is ); - const std::string from = fromto.first; - const std::string to = fromto.second; - if ( parseID( from ).first == "NONE" ) - return Warning( "Cannot substitute from unknown particles pair " + from, StatusCode::FAILURE ); - if ( parseID( to ).first == "NONE" ) - return Warning( "Cannot substitute to unknown particles pair " + from, StatusCode::FAILURE ); - } - return sc; -} - -StatusCode TupleToolSubMass::fill( const LHCb::Particle*, const LHCb::Particle* P, const std::string& head, - Tuples::Tuple& tuple, IGeometryInfo const& geometry ) { - const std::string prefix = fullName( head ); - bool fill = true; - if ( !P ) return StatusCode::FAILURE; - if ( P->isBasicParticle() ) return StatusCode::SUCCESS; - - // get the final state tree - m_ancestor = P; // cache the ancestor for cc-independant tree-sorting - std::vector tree = getTree( P ); - - //== check sorting - std::string decay = property( P->particleID() )->name() + " -> ["; - for ( unsigned int pos = 0; pos < tree.size(); pos++ ) { - if ( pos >= tree.size() ) return Warning( "Unexpected error", StatusCode::FAILURE ); - // if(msgLevel(MSG::DEBUG))debug() << " Ancestor : " << P->particleID().pid() << " daughter " << pos << " : " << - // tree[pos]->particleID().pid() << endmsg; - std::string sep = ( pos != 0 ) ? "," : ""; - decay += sep + property( tree[pos]->particleID() )->name(); - } - decay += "]"; - if ( msgLevel( MSG::DEBUG ) ) - debug() << "===> sorted decay structure for " << P->particleID().pid() << " : " << decay << endmsg; - - counter( decay ) += 1; - - //=== Get all combinaisons - unsigned int nfs = tree.size(); - ; - unsigned int max = ( m_max > 1 ) ? m_max : nfs; - if ( max > nfs ) max = nfs; - - for ( unsigned int level = 2; level <= max; ++level ) { - for ( unsigned int d = 0; d < max - level + 1; ++d ) { - std::vector v; - std::vector> vv; - v.push_back( d ); - vv.push_back( v ); - // produce the combinations tables - std::vector> out = combine( vv, level, nfs ); - // loop over combinations tables - for ( std::vector>::const_iterator ivv = out.begin(); ivv != out.end(); ++ivv ) { - const std::vector map = *ivv; - - //==== Mass for the current combination (no substition) - std::pair fMass = getMass( tree, map ); - if ( fMass.first != "NONE" ) fill &= tuple->column( prefix + "_M" + fMass.first, fMass.second ); - if ( m_vertex ) fill &= fillVertexInfo( P, tree, map, tuple, prefix, geometry ); - - //==== Try single substitution when requested - for ( std::vector::const_iterator is = m_subst.begin(); m_subst.end() != is; ++is ) { - const std::pair fromto = parseSubst( *is ); - const std::string from = fromto.first; - const std::string to = fromto.second; - unsigned int fromID = property( from )->pid().abspid(); - double toMass = property( to )->mass(); - for ( std::vector::const_iterator im = map.begin(); map.end() != im; ++im ) { - int pos = *im; - const LHCb::Particle* part = tree[pos]; - if ( part->particleID().abspid() == fromID ) { - std::pair sMass = getMass( tree, map, pos, toMass ); - if ( sMass.first != "NONE" ) - fill &= tuple->column( prefix + "_M" + sMass.first + "_" + getFlag( from, to, pos ), sMass.second ); - } - } - } - //==== Try double substitutions when requested - for ( std::vector::const_iterator iss = m_subst2.begin(); m_subst2.end() != iss; ++iss ) { - const std::pair fromto = parseSubst( *iss ); - const std::string from = fromto.first; - const std::string to = fromto.second; - const std::string from1 = parseID( from ).first; - const std::string from2 = parseID( from ).second; - const std::string to1 = parseID( to ).first; - const std::string to2 = parseID( to ).second; - int fromID1 = property( from1 )->pid().pid(); - int fromID2 = property( from2 )->pid().pid(); - double toMass1 = property( to1 )->mass(); - double toMass2 = property( to2 )->mass(); - unsigned int size = map.size(); - for ( unsigned int i1 = 0; i1 < size; i1++ ) { - for ( unsigned int i2 = i1 + 1; i2 < size; i2++ ) { - int pos1 = map[i1]; - int pos2 = map[i2]; - const LHCb::Particle* part1 = tree[pos1]; - const LHCb::Particle* part2 = tree[pos2]; - int pid1 = part1->particleID().pid(); - int apid1 = ( part1->charge() == 0 ) ? pid1 : -pid1; - int pid2 = part2->particleID().pid(); - int apid2 = ( part2->charge() == 0 ) ? pid2 : -pid2; - if ( ( pid1 == fromID1 && pid2 == fromID2 ) || ( apid1 == fromID1 && apid2 == fromID2 ) ) { - std::pair sMass = getMass( tree, map, pos1, toMass1, pos2, toMass2 ); - if ( sMass.first != "NONE" ) { - fill &= tuple->column( - prefix + "_M" + sMass.first + "_" + getFlag( from1, to1, pos1, from2, to2, pos2 ), sMass.second ); - } - } else if ( ( pid1 == fromID2 && pid2 == fromID1 ) || ( apid2 == fromID1 && apid1 == fromID2 ) ) { - std::pair sMass = getMass( tree, map, pos1, toMass2, pos2, toMass1 ); - if ( sMass.first != "NONE" ) { - fill &= tuple->column( - prefix + "_M" + sMass.first + "_" + getFlag( from1, to1, pos1, from2, to2, pos2 ), sMass.second ); - } - } - } - } - } - } - } - } - return StatusCode( fill ); -} - -// ------ parse substitution string -std::pair TupleToolSubMass::parseSubst( std::string subst ) { - int i = subst.find_last_of( "=>" ); - std::string from = subst.substr( 0, i - 1 ); - std::string to = subst.substr( i + 1, std::string::npos ); - boost::erase_all( from, " " ); - boost::erase_all( to, " " ); - return std::make_pair( from, to ); -} - -//------- particleID parser for double substitution map -std::pair TupleToolSubMass::parseID( std::string PID ) { - // syntax a/b - if ( PID.find_last_of( "/" ) != std::string::npos ) { - int i = PID.find_last_of( "/" ); - std::string pid1 = PID.substr( 0, i ); - std::string pid2 = PID.substr( i + 1, std::string::npos ); - if ( property( pid1 ) != NULL && property( pid2 ) != NULL ) - return std::make_pair( property( pid1 )->name(), property( pid2 )->name() ); - } else { - // try another syntax : ab - for ( unsigned int i = 1; i < PID.size(); ++i ) { - std::string pid1 = PID.substr( 0, i ); - std::string pid2 = PID.substr( i, std::string::npos ); - if ( property( pid1 ) != NULL && property( pid2 ) != NULL ) - return std::make_pair( property( pid1 )->name(), property( pid2 )->name() ); - } - } - // parsing failed - return std::make_pair( "NONE", "NONE" ); -} - -//------- produce the ntuple entry flag : -std::string TupleToolSubMass::getFlag( std::string from, std::string to, int pos, std::string from2, std::string to2, - int pos2 ) { - boost::replace_all( from, "+", "" ); - boost::replace_all( from, "-", "" ); - boost::replace_all( to, "+", "" ); - boost::replace_all( to, "-", "" ); - boost::replace_all( from2, "+", "" ); - boost::replace_all( from2, "-", "" ); - boost::replace_all( to2, "+", "" ); - boost::replace_all( to2, "-", "" ); - if ( pos2 < 0 ) return "Subst" + Gaudi::Utils::toString( pos ) + "_" + from + "2" + to; - return "Subst" + Gaudi::Utils::toString( pos ) + Gaudi::Utils::toString( pos2 ) + "_" + from + from2 + "2" + to + to2; -} - -//------- compute momentum (possibly with PID substitution) -Gaudi::LorentzVector TupleToolSubMass::sMomentum( const LHCb::Particle* part, double sMass ) { - Gaudi::LorentzVector momentum = part->momentum(); - if ( isPureNeutralCalo( part ) ) { // photon (E is measured) - use-case : gamma <->pi0 substitution - if ( sMass < momentum.E() ) { - double P = sqrt( momentum.E() * momentum.E() - sMass * sMass ); - double px = momentum.px() / momentum.P() * P; - double py = momentum.py() / momentum.P() * P; - double pz = momentum.pz() / momentum.P() * P; - momentum.SetPx( px ); - momentum.SetPy( py ); - momentum.SetPz( pz ); - } - } else { // tracks (p is measured) - double E = sqrt( momentum.P() * momentum.P() + sMass * sMass ); - momentum.SetE( E ); - } - return momentum; -} - -//-------- compute vertex information for the combination : -bool TupleToolSubMass::fillVertexInfo( const LHCb::Particle* P, std::vector tree, - const std::vector map, Tuples::Tuple& tuple, const std::string prefix, - IGeometryInfo const& geometry ) { - bool fill = true; - LHCb::Vertex vertex; - LHCb::Particle mother; - LHCb::Particle::ConstVector subTree; - std::string flag; - for ( std::vector::const_iterator iv = map.begin(); iv != map.end(); ++iv ) { - int pos = *iv; - const LHCb::Particle* part = tree[pos]; - subTree.push_back( part ); - flag += Gaudi::Utils::toString( pos ); - } - - // Vertex chi2 - StatusCode sc = m_dva->particleCombiner()->combine( subTree, mother, vertex, geometry ); - double chi2 = ( sc.isSuccess() ) ? vertex.chi2() : -1.; - double nDoF = ( sc.isSuccess() ) ? vertex.nDoF() : 0.; - fill &= tuple->column( prefix + "_VtxChi2_" + flag, chi2 ); - fill &= tuple->column( prefix + "_VtxnDoF" + flag, nDoF ); - fill &= tuple->column( prefix + "_VtxM" + flag, mother.momentum().M() ); - - // IP chi2 - double ip = 0; - double ipchi2 = 0; - const LHCb::VertexBase* PV = m_dva->bestVertex( P, geometry ); - bool ok = m_dva->distanceCalculator()->distance( &mother, PV, ip, ipchi2, geometry ).isSuccess(); - if ( !ok ) { - ip = 0; - ipchi2 = -1.; - } - fill &= tuple->column( prefix + "_IP" + flag, ip ); - fill &= tuple->column( prefix + "_IPChi2_" + flag, ipchi2 ); - return fill; -} - -//-------- compute the combination mass (possibly with PID substitution(s)) -std::pair TupleToolSubMass::getMass( std::vector tree, - const std::vector map, int sPos, double sMass, int sPos2, - double sMass2 ) { - Gaudi::LorentzVector sum; - std::string flag; - bool doSub1 = false; - bool doSub2 = false; - for ( std::vector::const_iterator iv = map.begin(); iv != map.end(); ++iv ) { - int pos = *iv; - const LHCb::Particle* part = tree[pos]; - - if ( pos == sPos ) { - doSub1 = true; - sum += sMomentum( part, sMass ); - } else if ( pos == sPos2 ) { - doSub2 = true; - sum += sMomentum( part, sMass2 ); - } else - sum += part->momentum(); - flag += Gaudi::Utils::toString( pos ); - } - if ( ( !doSub1 && sPos >= 0 ) || ( !doSub2 && sPos2 >= 0 ) ) return std::make_pair( "NONE", 0. ); - return std::make_pair( flag, sum.M() ); -} - -bool TupleToolSubMass::isEndTree( const LHCb::Particle* p ) { - if ( p->isBasicParticle() ) return true; - for ( std::vector::iterator it = m_endTree.begin(); m_endTree.end() != it; ++it ) { - if ( (int)p->particleID().abspid() == *it ) return true; - } - return false; -} - -//-------- get sorted tree (cc-independant) -std::vector TupleToolSubMass::getTree( const LHCb::Particle* P ) { - std::vector tree; - // if( P->isBasicParticle() ){ - if ( isEndTree( P ) ) { - tree.push_back( P ); - } else { - SmartRefVector daughters = P->daughters(); // local copy to sort - std::stable_sort( daughters.begin(), daughters.end(), SortDaughtersByPID( m_ancestor, m_ppsvc ) ); - for ( SmartRefVector::const_iterator idau = daughters.begin(); idau != daughters.end(); ++idau ) { - std::vector temp = getTree( *idau ); - for ( std::vector::iterator dd = temp.begin(); temp.end() != dd; ++dd ) { - tree.push_back( *dd ); - } - } - } - return tree; -} - -//-------- get the combinations tables -std::vector> TupleToolSubMass::combine( std::vector> vec, unsigned int level, - int nfs ) { - if ( ( vec.back() ).size() == level ) return vec; - std::vector> cc; // local vector - for ( std::vector>::iterator iv = vec.begin(); iv != vec.end(); ++iv ) { - if ( iv->size() == level ) continue; - int min = iv->back(); - for ( int i = min + 1; i < nfs; ++i ) { - std::vector c = *iv; - c.push_back( i ); - cc.push_back( c ); - }; - } - return combine( cc, level, nfs ); -} diff --git a/Phys/DecayTreeTuple/src/TupleToolTagging.cpp b/Phys/DecayTreeTuple/src/TupleToolTagging.cpp deleted file mode 100755 index 77c236709530d311de23528dbb003194fea0aaa8..0000000000000000000000000000000000000000 --- a/Phys/DecayTreeTuple/src/TupleToolTagging.cpp +++ /dev/null @@ -1,331 +0,0 @@ -/*****************************************************************************\ -* (c) Copyright 2000-2018 CERN for the benefit of the LHCb Collaboration * -* * -* This software is distributed under the terms of the GNU General Public * -* Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". * -* * -* In applying this licence, CERN does not waive the privileges and immunities * -* granted to it by virtue of its status as an Intergovernmental Organization * -* or submit itself to any jurisdiction. * -\*****************************************************************************/ - -#include "Kernel/IParticleTupleTool.h" -#include "Kernel/IVertexFit.h" - -#include "DecayTreeTupleBase/TupleToolBase.h" - -#include "Kernel/GetIDVAlgorithm.h" -#include "Kernel/IBTaggingTool.h" -#include "Kernel/IDVAlgorithm.h" - -#include "Event/Particle.h" -#include "Event/RecVertex.h" -#include "Event/Vertex.h" - -#include "GaudiAlg/Tuple.h" -#include "GaudiAlg/TupleObj.h" -#include "GaudiKernel/SmartIF.h" - -struct VerboseData { - double id, p, px, py, pz, pt, theta, phi; - double pid_e, pid_mu, pid_k, pid_p; - double ip, chi2, bip, bchi2, bp_chi2; - VerboseData() - : id( 0 ) - , p( 0 ) - , px( 0 ) - , pz( 0 ) - , pt( 0 ) - , theta( 0 ) - , phi( 0 ) - , pid_e( 0 ) - , pid_mu( 0 ) - , pid_k( 0 ) - , pid_p( 0 ) - , ip( 0 ) - , chi2( 0 ) - , bip( 0 ) - , bchi2( 0 ) - , bp_chi2( 0 ) {} -}; - -/** - * \brief Fill the tagging information in the tuple. - * - * The output of this DecayTreeTupleTool consists of the tag decision (TAGDEC) - * and the estimated mistag probability (TAGETA) of each tagging algorithm. The - * list of considered tagging algorithms depends on whether the tag results are - * read out from the TES or if they are produced by the associated BTaggingTool. - * - * If the results are read out from TES (UseFTfromDST is set to true), the list - * of results written to the tuple depends on the list of active taggers defined - * in the property ActiveTaggers. Elsewise, this list will be overwritten by the - * list of active taggers in the associated BTaggingTool. - * - * If Verbose is set the effective charge of the tagging object and the MVA - * output are filled for each tagger. - * - * @see BTaggingTool - * @see Tagger - * - * @author Jeremie Borel - * @author Julian Wishahi - * @date 2007-2017 - */ -class TupleToolTagging : public TupleToolBase, virtual public IParticleTupleTool { -public: - TupleToolTagging( const std::string& type, const std::string& name, const IInterface* parent ); - StatusCode initialize() override; - StatusCode fill( const LHCb::Particle* motherPart, const LHCb::Particle* signalPart, const std::string& head, - Tuples::Tuple& tuple, IGeometryInfo const& geometry ) override; - -private: - StatusCode fillTagInfo( const LHCb::FlavourTag& flavourTag, const std::string& prefix, Tuples::Tuple& tuple ); - - Gaudi::Property m_nameTaggingTool{this, "TaggingToolName", "BTaggingTool/BTaggingTool", - "Name of the TaggingTool to be used"}; - - Gaudi::Property m_useFTfromDST{this, "UseFTfromDST", false, - "Do not rerun flavour tagging but retrieve from DST"}; - - Gaudi::Property> m_activeTaggerTypeNames{ - this, - "ActiveTaggerTypes", - {"OS_Muon", "OS_Electron", "OS_Kaon", "VtxCharge", "OS_Charm", "SS_nnetKaon", "SS_PionBDT", "SS_Proton"}, - "List of active tagger types. This list is only used when UseFTfromDST is set."}; - - std::map m_activeTaggers; - - Gaudi::Property m_tagNonBeauty{this, "TagNonBeauty", false, - "Also run tagging on candidates that do not contain a beauty quark"}; - - Gaudi::Property m_addMVAFeatureInfo{this, "AddMVAFeatureInfo", false, - "Add feature values used by the MVA for the tagging decision to the tuple"}; - - Gaudi::Property m_addTagPartsInfo{this, "AddTagPartsInfo", false, - "Add feature values of all tagging particles considered"}; - - Gaudi::Property m_maxTagPartsInfo{this, "MaximumTagPartsInfo", 1000, - "Maximum of rows to be saved when adding VerboseFeatureInfo"}; - - IDVAlgorithm* m_parentDVA = nullptr; ///< pointer to the parent DV algorithm - IBTaggingTool* m_taggingTool = nullptr; ///< pointer to the BTaggingTool -}; - -using namespace LHCb; - -// Declaration of the Tool Factory -// actually acts as a using namespace TupleTool -DECLARE_COMPONENT( TupleToolTagging ) - -//============================================================================== -// Standard constructor -//============================================================================== -TupleToolTagging::TupleToolTagging( const std::string& type, const std::string& name, const IInterface* parent ) - : TupleToolBase( type, name, parent ) { - declareInterface( this ); -} - -//============================================================================== -// Initialize method -//============================================================================== -StatusCode TupleToolTagging::initialize() { - if ( !TupleToolBase::initialize() ) return StatusCode::FAILURE; - - // get parent DaVinci algorithm - m_parentDVA = Gaudi::Utils::getIDVAlgorithm( contextSvc(), this ); - if ( m_parentDVA == nullptr ) { return Error( "Unable to retrieve parent DVAlg", StatusCode::FAILURE ); } - - // write out information from FlavourTag saved on DST - if ( m_useFTfromDST ) { - info() << "Read tagging results saved in TES. " << endmsg; - - // sanity checks and warning for user - if ( m_addMVAFeatureInfo ) { - warning() << "Asked to read tagging results from TES. Will ignore AddMVAFeatureInfo." << endmsg; - } - if ( m_addTagPartsInfo ) { - warning() << "Asked to read tagging results from TES. Will ignore AddTagPartsInfo." << endmsg; - } - } - // configured to run FT, thus have to get/create TaggingTool - else { - // if no name is given, get TaggingTool from parent DVA, else create a new - // private tool - if ( m_nameTaggingTool == "" ) { - m_taggingTool = m_parentDVA->flavourTagging(); - } else { - m_taggingTool = tool( m_nameTaggingTool, this ); - } - if ( m_taggingTool == nullptr ) { - return Error( "Unable to retrieve the IBTaggingTool tool", StatusCode::FAILURE ); - } - - // set active tagger list to the list of active taggers of the TaggingTool - info() << "Will use TaggingTool " << m_taggingTool->name() << " for tagging." << endmsg; - m_activeTaggerTypeNames = m_taggingTool->activeTaggerTypeNames(); - } - - // transform TaggerType names to pair of TaggerTypes and names - info() << "Will save information for following tags (if available): "; - std::vector invalidTaggerNames; - for ( auto activeTaggerName : m_activeTaggerTypeNames ) { - auto activeTaggerType = Tagger::TaggerTypeToType( activeTaggerName ); - if ( activeTaggerType != Tagger::TaggerType::unknown && activeTaggerType != Tagger::TaggerType::none ) { - info() << activeTaggerName << " "; - m_activeTaggers.emplace( activeTaggerName, activeTaggerType ); - } else { - invalidTaggerNames.push_back( activeTaggerName ); - } - } - info() << "." << endmsg; - - if ( !( invalidTaggerNames.empty() ) ) { - warning() << "." << endmsg; - warning() << "Could not add the following taggers, as they are unknown:"; - for ( auto invalidTaggerName : invalidTaggerNames ) { warning() << " " << invalidTaggerName; } - warning() << "." << endmsg; - } - - if ( m_tagNonBeauty ) { info() << "Running Flavour Tagging on all particles (not only b-hadrons)" << endmsg; } - - return StatusCode::SUCCESS; -} - -//============================================================================== -// fill method -//============================================================================== -StatusCode TupleToolTagging::fill( const Particle* motherPart, const Particle* signalPart, const std::string& head, - Tuples::Tuple& tuple, IGeometryInfo const& geometry ) { - // consistency checks - Assert( signalPart && motherPart && m_parentDVA && ( m_taggingTool || m_useFTfromDST ), - "Should not happen, you are inside TupleToolTagging.cpp" ); - - // nothing to tag on something which is not a B (unless explicitly required) - if ( !m_tagNonBeauty ) { - if ( !( signalPart->particleID().hasBottom() ) ) return StatusCode::SUCCESS; - } - - // instantiate empty FlavourTag and FlavourTags - FlavourTag flavourTag; - FlavourTags* flavourTags = nullptr; - - // create successful statuscode - StatusCode sc = StatusCode::SUCCESS; - bool check = false; - - // if requested, retrieve FlavourTag objects from DST location - if ( m_useFTfromDST ) { - info() << "Will read flavour tagging results from TES." << endmsg; - // get location of signal particles, then replace with expected location of - // FlavourTags vector - std::string signalPartLoc = objectLocation( signalPart->parent() ); - boost::replace_all( signalPartLoc, "/Particles", "/FlavourTags" ); - - // get FlavourTags from expected DST location - if ( exist( signalPartLoc, IgnoreRootInTES ) ) { - flavourTags = get( signalPartLoc, IgnoreRootInTES ); - } - } - - // check if retrieved FlavourTags belong to to the signal particle - if ( flavourTags != nullptr ) { - for ( FlavourTags::const_iterator it = flavourTags->begin(); it != flavourTags->end(); ++it ) { - if ( signalPart != ( **it ).taggedB() ) continue; - flavourTag = **it; - check = true; - } - if ( !check ) sc = StatusCode::FAILURE; - } else { - const RecVertex* assocVtx = dynamic_cast( m_parentDVA->bestVertex( motherPart, geometry ) ); - if ( assocVtx == nullptr ) { - sc = m_taggingTool->tag( flavourTag, signalPart ); - } else { - sc = m_taggingTool->tag( flavourTag, signalPart, assocVtx ); - } - } - - if ( !( sc.isSuccess() ) ) return sc; - - // Start filling the tuples - // get tuple branch prefix - const std::string prefix = fullName( head ); - sc = fillTagInfo( flavourTag, prefix, tuple ); - - return sc; -} - -StatusCode TupleToolTagging::fillTagInfo( const FlavourTag& flavourTag, const std::string& prefix, - Tuples::Tuple& tuple ) { - - // retrieve taggers - auto taggers = flavourTag.taggers(); - - bool test = true; - std::string tuplePrefix = prefix; - std::string taggerName( "none" ); - Tagger::TaggerType taggerType( Tagger::TaggerType::none ); - // loop over map of all active taggers - for ( auto activeTaggerNameAndType : m_activeTaggers ) { - taggerName = activeTaggerNameAndType.first; - taggerType = activeTaggerNameAndType.second; - tuplePrefix = prefix + "_" + taggerName; - - // check if active tagger has a Tagger object in Taggers - // loop over all Tagger object and check if type matches active tagger type - auto tagger = std::find_if( taggers.begin(), taggers.end(), [&taggerType]( Tagger current_tagger ) -> bool { - return ( current_tagger.type() == taggerType ); - } ); - bool hasTagged = ( tagger != taggers.end() ); - - int taggerDec = 0; - double taggerEta = 0.5; - double taggerCharge = 0.; - double taggerMVAout = -1.; - if ( hasTagged ) { - taggerDec = static_cast( tagger->decision() ); - taggerEta = static_cast( tagger->omega() ); - } - - // tagging decision and estimated mistag probability - test &= tuple->column( tuplePrefix + "_TAGDEC", taggerDec ); - test &= tuple->column( tuplePrefix + "_TAGETA", taggerEta ); - - // charge used for decision and raw (uncalibrated) MVA classifier output - if ( isVerbose() ) { - if ( hasTagged ) { - taggerCharge = static_cast( tagger->charge() ); - taggerMVAout = static_cast( tagger->mvaValue() ); - } - test &= tuple->column( tuplePrefix + "_CHARGE", taggerCharge ); - test &= tuple->column( tuplePrefix + "_MVAOUT", taggerMVAout ); - } - - if ( !m_useFTfromDST ) { - if ( m_addMVAFeatureInfo ) { - auto featureNames = m_taggingTool->featureNames( taggerType ); - auto featureValues = ( hasTagged ? m_taggingTool->featureValues( taggerType ) - : std::vector( featureNames.size(), -99999. ) ); - // write features to tuple - for ( size_t i = 0; i < featureNames.size(); ++i ) { - test &= tuple->column( tuplePrefix + "_MVAFeature_" + featureNames.at( i ), featureValues.at( i ) ); - } - } - - if ( m_addTagPartsInfo ) { - auto featureNames = m_taggingTool->featureNamesTagParts( taggerType ); - auto featureValueMatrix = ( hasTagged ? m_taggingTool->featureValuesTagParts( taggerType ) - : std::vector>( featureNames.size(), {-99999.} ) ); - - // write features to tuple - const std::string tupleNumName = tuplePrefix + "_TagPartsFeature_" + "NUM"; - for ( size_t i = 0; i < featureNames.size(); ++i ) { - test &= tuple->farray( tuplePrefix + "_TagPartsFeature_" + featureNames.at( i ), featureValueMatrix.at( i ), - tupleNumName, m_maxTagPartsInfo ); - } - } - } - } - - return StatusCode( test ); -} diff --git a/Phys/DecayTreeTuple/src/TupleToolVeto.cpp b/Phys/DecayTreeTuple/src/TupleToolVeto.cpp deleted file mode 100644 index 70f0d702db3debbeb16659227fd2636c5037a0de..0000000000000000000000000000000000000000 --- a/Phys/DecayTreeTuple/src/TupleToolVeto.cpp +++ /dev/null @@ -1,122 +0,0 @@ -/*****************************************************************************\ -* (c) Copyright 2000-2018 CERN for the benefit of the LHCb Collaboration * -* * -* This software is distributed under the terms of the GNU General Public * -* Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". * -* * -* In applying this licence, CERN does not waive the privileges and immunities * -* granted to it by virtue of its status as an Intergovernmental Organization * -* or submit itself to any jurisdiction. * -\*****************************************************************************/ - -#include "DecayTreeTupleBase/TupleToolBase.h" - -#include "Kernel/IParticlePropertySvc.h" -#include "Kernel/IParticleTupleTool.h" -#include "Kernel/IParticleVeto.h" -#include "Kernel/ParticleProperty.h" - -#include "Event/Particle.h" - -#include "GaudiAlg/Tuple.h" -#include "GaudiAlg/TupleObj.h" -#include "GaudiKernel/IRegistry.h" - -#include - -/** - * Flag particle P when it overlaps with any particle from given container(s) - * - * usage : - * - * mytuple.Particle="name" # the specific particle to be checked (default : all maked - * DecayTreeTuple::DecayDescriptor particles) mytuple.TupleToolVeto[VetoName].["Container1","Container2",...] # list - * of containers to be checked - * - * - * e.g.: - * - pi0-Veto for single photon : flag all photons which are already used to build a pi0 as defined in - * StdLooseResolvedPi0 - * mytuple.TupleToolVeto.Particle="gamma" - * mytuple.TupleToolVeto.Veto[Pi0R]=["/Event/Phys/StdLooseResolvedPi0/Particles"] - * - * - pi0-veto for pi0 : flag all pi0 which are not exclusive with respect to **other** pi0's - * mytuple.TupleToolVeto.Particle="pi0" - * mytuple.TupleToolVeto.VetoOther[Pi0R]=["/Event/Phys/StdLooseResolvedPi0/Particles"] - * - * -> the overlap of the pi0 with itself is not considered (property VetoOther) - only partial overlap are checked - * - * - works for any (composite or basic) particle. Relies on tool DaVinciTools/ParticleVeto (see doxygen for details) - */ -class TupleToolVeto : public TupleToolBase, virtual public IParticleTupleTool { - -public: - TupleToolVeto( const std::string& type, const std::string& name, const IInterface* parent ); - StatusCode initialize() override; - StatusCode fill( const LHCb::Particle*, const LHCb::Particle*, const std::string&, Tuples::Tuple&, - IGeometryInfo const& ) override; - -private: - IParticleVeto* m_check; - std::string m_part; - unsigned int m_pid; - std::map> m_veto; - std::map> m_vetoOther; -}; - -using namespace Gaudi; -using namespace LHCb; - -// Declaration of the Tool Factory -DECLARE_COMPONENT( TupleToolVeto ) - -//============================================================================= -// Standard constructor, initializes variables -//============================================================================= -TupleToolVeto::TupleToolVeto( const std::string& type, const std::string& name, const IInterface* parent ) - : TupleToolBase( type, name, parent ), m_pid( 0 ) { - declareInterface( this ); - declareProperty( "Particle", m_part = "" ); - declareProperty( "Veto", m_veto ); - declareProperty( "VetoOther", m_vetoOther ); -} - -StatusCode TupleToolVeto::initialize() { - const StatusCode sc = TupleToolBase::initialize(); - if ( sc.isFailure() ) return sc; - m_check = tool( "ParticleVeto", "ParticleVeto", this ); - if ( !m_part.empty() ) { - LHCb::IParticlePropertySvc* ppsvc = svc( "LHCb::ParticlePropertySvc", true ); - const LHCb::ParticleProperty* pp = ppsvc->find( m_part ); - m_pid = ( pp ) ? pp->pdgID().abspid() : 0; - } - return sc; -} - -StatusCode TupleToolVeto::fill( const Particle*, const Particle* P, const std::string& head, Tuples::Tuple& tuple, - IGeometryInfo const& ) { - const std::string prefix = fullName( head ); - - bool filltuple = true; - if ( P ) { - - if ( !m_part.empty() && m_pid != P->particleID().abspid() ) { return StatusCode::SUCCESS; } - - for ( std::map>::const_iterator i = m_veto.begin(); m_veto.end() != i; ++i ) { - const std::string& flag = i->first; - const std::vector& cont = i->second; - const bool veto = m_check->foundOverlap( P, cont ); - filltuple &= tuple->column( prefix + "_Veto" + flag, veto ); - } - - for ( std::map>::const_iterator i = m_vetoOther.begin(); - m_vetoOther.end() != i; ++i ) { - const std::string& flag = i->first; - const std::vector& cont = i->second; - const bool veto = m_check->foundOverlap( P, cont, 0x3 ); // mode == 3 - filltuple &= tuple->column( prefix + "_VetoOther" + flag, veto ); - } - } - - return StatusCode( filltuple ); -} diff --git a/Phys/DecayTreeTuple/src/TupleToolVtxDaughters.cpp b/Phys/DecayTreeTuple/src/TupleToolVtxDaughters.cpp deleted file mode 100755 index 4d7b8efa7d7f3df3b3bca2381c582278b4c419c4..0000000000000000000000000000000000000000 --- a/Phys/DecayTreeTuple/src/TupleToolVtxDaughters.cpp +++ /dev/null @@ -1,438 +0,0 @@ -/*****************************************************************************\ -* (c) Copyright 2000-2018 CERN for the benefit of the LHCb Collaboration * -* * -* This software is distributed under the terms of the GNU General Public * -* Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". * -* * -* In applying this licence, CERN does not waive the privileges and immunities * -* granted to it by virtue of its status as an Intergovernmental Organization * -* or submit itself to any jurisdiction. * -\*****************************************************************************/ - -#include "DecayTreeFitter/Fitter.h" -#include "DecayTreeTupleBase/TupleToolBase.h" - -#include "TrackInterfaces/ITrackStateProvider.h" - -#include "Event/Particle.h" - -#include "Kernel/GetIDVAlgorithm.h" -#include "Kernel/IDVAlgorithm.h" -#include "Kernel/IDistanceCalculator.h" -#include "Kernel/IPVReFitter.h" -#include "Kernel/IParticleCombiner.h" -#include "Kernel/IParticleTupleTool.h" // Interface -#include "Kernel/IVertexFit.h" - -#include "GaudiAlg/GaudiTool.h" -#include "GaudiAlg/Tuple.h" -#include "GaudiAlg/TupleObj.h" -#include "GaudiKernel/ToolHandle.h" - -/** - * \brief Compute vertices of pairs and triplet of daughters + FD info between these and the mother vertex for - * DecayTreeTuple. - * - * \sa DecayTreeTuple - * - * @author Adlene Hicheur - * @date 2014-10-07, first hand - * 2019-12: upgrade to Triplet vertices, time to commit - */ -class TupleToolVtxDaughters : public TupleToolBase, virtual public IParticleTupleTool { - -public: - TupleToolVtxDaughters( const std::string& type, const std::string& name, const IInterface* parent ); - StatusCode initialize() override; - StatusCode fill( const LHCb::Particle*, const LHCb::Particle*, const std::string&, Tuples::Tuple&, - IGeometryInfo const& ) override; - -private: - /// prong vertex - const LHCb::VertexBase* ProngVertex( LHCb::Particle::ConstVector daus, double& mass, LHCb::Particle& PairMom, - IGeometryInfo const& geometry ) const; - - /// fill end vertex stuff - StatusCode fillVertex( const LHCb::VertexBase* vtx, const std::string& vtx_name, Tuples::Tuple& ) const; - - /// fill flight - StatusCode fillFlight( const LHCb::VertexBase* pairVtx, const LHCb::Particle* P, const std::string& prefix, - Tuples::Tuple& tuple, const std::string& trail = "" ) const; - - double dira( const LHCb::VertexBase* oriVtx, const LHCb::Particle P ) const { - if ( !oriVtx ) { - Exception( "Wrong use of dira" ); - return -1501.; - } - const LHCb::Vertex* evtx = P.endVertex(); - if ( !evtx ) { - Warning( "Cannot find end vertex", StatusCode::SUCCESS, 1 ).ignore(); - return -999.; - } - const Gaudi::XYZVector& A = P.momentum().Vect(); - const Gaudi::XYZVector B = evtx->position() - oriVtx->position(); - return A.Dot( B ) / std::sqrt( A.Mag2() * B.Mag2() ); - } - -private: - const IDistanceCalculator* m_dist = nullptr; - const IVertexFit* m_vtx = nullptr; - - bool m_fillSubVtx; - bool m_doThreeProng; - - IDVAlgorithm* m_dva = nullptr; -}; - -using namespace LHCb; -using namespace DecayTreeFitter; - -// Declaration of the Tool Factory -// actually acts as a using namespace TupleTool -DECLARE_COMPONENT( TupleToolVtxDaughters ) - -//============================================================================= -// Standard constructor, initializes variables -//============================================================================= -TupleToolVtxDaughters::TupleToolVtxDaughters( const std::string& type, const std::string& name, - const IInterface* parent ) - : TupleToolBase( type, name, parent ), m_dist( 0 ), m_vtx( 0 ), m_dva( 0 ) { - declareInterface( this ); - declareProperty( "FillSubVtxInfo", m_fillSubVtx = false, "Fill complete pair vertex info" ); - declareProperty( "DoThreeProng", m_doThreeProng = false, "Compute three prong vertices" ); - // replaced by Verbose -} - -//============================================================================= - -StatusCode TupleToolVtxDaughters::initialize() { - const StatusCode sc = TupleToolBase::initialize(); - if ( sc.isFailure() ) return sc; - - m_dva = Gaudi::Utils::getIDVAlgorithm( contextSvc(), this ); - if ( !m_dva ) return Error( "Couldn't get parent DVAlgorithm" ); - - m_dist = m_dva->distanceCalculator(); - if ( !m_dist ) { return Error( "Unable to retrieve the IDistanceCalculator tool" ); } - - m_vtx = m_dva->vertexFitter(); - if ( !m_vtx ) { return Error( "Unable to retrieve the IVertexFit tool" ); } - - return sc; -} - -//============================================================================= -StatusCode TupleToolVtxDaughters::fill( const Particle* mother, const Particle* P, const std::string& head, - Tuples::Tuple& tuple, IGeometryInfo const& geometry ) { - const std::string prefix = fullName( head ); - - StatusCode sc = StatusCode::SUCCESS; - - Assert( P && m_dist && m_dva && m_vtx, "No mother or particle, or tools misconfigured." ); - - if ( isPureNeutralCalo( P ) ) - return Warning( "Will not fill geometry tuple for neutral Calo particles. No worry", StatusCode::SUCCESS, 10 ); - if ( msgLevel( MSG::VERBOSE ) ) - verbose() << "TupleToolVtxDaughters::fill " << mother << " " << P << " " << prefix << endmsg; - - //========================================================================= - // fill end vertex info - //========================================================================= - if ( P->isBasicParticle() || P->daughters().size() < 3 ) { - if ( msgLevel( MSG::DEBUG ) ) - debug() - << "TupleToolVtxDaughters does not fill info for basic particles or decays with less than three daughters." - << endmsg; - } else { - //========================================================================= - if ( msgLevel( MSG::VERBOSE ) && P->endVertex() ) { // https://its.cern.ch/jira/browse/LHCBPS-598 - verbose() << "Before cast : " << P->endVertex() << endmsg; - verbose() << "Container " << P->endVertex()->parent()->registry()->identifier() << " key " - << P->endVertex()->key() << endmsg; - } - - const VertexBase* evtx = P->endVertex(); - if ( !evtx ) { - fatal() << "Can't retrieve the end vertex for " << prefix - << ". TupleToolVtxDaughters cannot act on such a particle. Define a branch" << endmsg; - fatal() << "See https://twiki.cern.ch/twiki/bin/view/LHCb/DaVinciTutorial7#Branches" << endmsg; - return StatusCode::FAILURE; - } - - if ( msgLevel( MSG::VERBOSE ) ) { // https://its.cern.ch/jira/browse/LHCBPS-598 - verbose() << "End Vertex : " << *evtx << endmsg; - verbose() << "Container " << evtx->parent()->registry()->identifier() << " key " << evtx->key() << endmsg; - } - // Pairing daughters for subvertices: - - const SmartRefVector& dau = P->daughters(); - - int sizeDau = P->daughters().size(); - - // LHCb::DecayTree tree ( *P ) ; - - // Two prongs - - for ( int i = 0; i < sizeDau; ++i ) { - for ( int j = i + 1; j < sizeDau; ++j ) { - char buffer[40]; - sprintf( buffer, "_%d%d", i + 1, j + 1 ); - std::string trail( buffer ); - const VertexBase* vtxpair = NULL; - double myMass = -999.; - LHCb::Particle tempmother( ParticleID( 531 ) ); - LHCb::Particle::ConstVector tmp( 2 ); - tmp[0] = dau[i]; - tmp[1] = dau[j]; - - vtxpair = ProngVertex( tmp, myMass, tempmother, geometry ); - - LHCb::Particle::ConstVector newTree; - newTree.push_back( &tempmother ); - LHCb::Particle newHead( ParticleID( 541 ) ); - newHead.addToDaughters( &tempmother ); - LHCb::Vertex tmpvertex; - - for ( int k = 0; k < sizeDau; k++ ) { - if ( k != i && k != j ) { - newTree.push_back( dau[k] ); - newHead.addToDaughters( dau[k] ); - } - } - // create the fitter object - ToolHandle m_stateprovider( "TrackStateProvider" ); - StatusCode sc = m_stateprovider.retrieve(); - const ITrackStateProvider* stateprovider = ( m_stateprovider.empty() ? NULL : &( *m_stateprovider ) ); - DecayTreeFitter::Fitter myfitter( newHead, stateprovider ); - // fit and get the fit parameters - myfitter.fit( geometry ); - const LHCb::Particle* pairmother = &tempmother; - const Gaudi::Math::ParticleParams* myPairParams = myfitter.fitParams( pairmother ); - // get the decay length with err - const Gaudi::Math::ValueWithError& declen = myPairParams->decayLength(); - double flight = declen.value(); - double errlen = declen.error(); - double fdchi2 = -999; - if ( errlen > 1e-8 ) fdchi2 = ( flight / errlen ) * ( flight / errlen ); - const Gaudi::LorentzVector& p4 = myPairParams->momentum(); - double measPairMass = p4.M(); - const Gaudi::Math::Point3DWithError& pairposerr = myPairParams->position(); - const Gaudi::XYZPoint& pairpos = pairposerr.point(); - const Gaudi::SymMatrix3x3& paircov = pairposerr.covariance(); - - if ( vtxpair ) { - - bool test = true; - double dist = 0; - double chi2 = 0; - sc = m_dist->distance( P->endVertex(), vtxpair, dist, chi2 ); - if ( !sc.isFailure() ) { - - test &= tuple->column( prefix + "_SubVtx" + trail + "_FD", flight ); - test &= tuple->column( prefix + "_SubVtx" + trail + "_FDCHI2", fdchi2 ); - test &= tuple->column( prefix + "_SubVtx" + trail + "_Mass", measPairMass ); - test &= tuple->column( prefix + "_SubVtx" + trail + "_DIRA", - dira( m_dva->bestVertex( P, geometry ), tempmother ) ); - } - - if ( !test ) Warning( "Error in fillFlight " + prefix, StatusCode::SUCCESS, 1 ).ignore(); - - if ( m_fillSubVtx ) { - - if ( sc.isFailure() ) { return Warning( "Could not fill Endvertex " + prefix, StatusCode::SUCCESS, 1 ); } - test = true; - test &= tuple->column( prefix + "_SubVtx" + trail + "_", pairpos ); - test &= tuple->column( prefix + "_SubVtx" + trail + "_XERR", std::sqrt( paircov( 0, 0 ) ) ); - test &= tuple->column( prefix + "_SubVtx" + trail + "_YERR", std::sqrt( paircov( 1, 1 ) ) ); - test &= tuple->column( prefix + "_SubVtx" + trail + "_ZERR", std::sqrt( paircov( 2, 2 ) ) ); - test &= tuple->column( prefix + "_SubVtx" + trail + "_CHI2", vtxpair->chi2() ); - test &= tuple->column( prefix + "_SubVtx" + trail + "_NDOF", vtxpair->nDoF() ); - test &= tuple->matrix( prefix + "_SubVtx" + trail + "_COV_", paircov ); - - if ( !test ) Warning( "Error in filling Vtx info " + prefix + trail, StatusCode::SUCCESS, 1 ).ignore(); - } - } - } - } - - // Three prongs: - - if ( m_doThreeProng && sizeDau > 3 ) { - - for ( int i = 0; i < sizeDau; ++i ) { - for ( int j = i + 1; j < sizeDau; ++j ) { - for ( int k = j + 1; k < sizeDau; ++k ) { - - char buffer[40]; - sprintf( buffer, "_%d%d%d", i + 1, j + 1, k + 1 ); - std::string trail( buffer ); - const VertexBase* vtx3prong = NULL; - double myMass = -999.; - LHCb::Particle tempmother( ParticleID( 531 ) ); - LHCb::Particle::ConstVector tmp( 3 ); - tmp[0] = dau[i]; - tmp[1] = dau[j]; - tmp[2] = dau[k]; - vtx3prong = ProngVertex( tmp, myMass, tempmother, geometry ); - // create the new head: - LHCb::Particle::ConstVector newTree; - newTree.push_back( &tempmother ); - LHCb::Particle newHead( ParticleID( 541 ) ); - newHead.addToDaughters( &tempmother ); - LHCb::Vertex tmpvertex; - - for ( int ibach = 0; ibach < sizeDau; ibach++ ) { - if ( ibach != i && ibach != j && ibach != k ) { - newTree.push_back( dau[ibach] ); - newHead.addToDaughters( dau[ibach] ); - } - } - // create the fitter object - ToolHandle m_stateprovider( "TrackStateProvider" ); - StatusCode sc = m_stateprovider.retrieve(); - const ITrackStateProvider* stateprovider = ( m_stateprovider.empty() ? NULL : &( *m_stateprovider ) ); - DecayTreeFitter::Fitter myfitter( newHead, stateprovider ); - // fit and get the results - myfitter.fit( geometry ); - const LHCb::Particle* pairmother = &tempmother; - const Gaudi::Math::ParticleParams* myPairParams = myfitter.fitParams( pairmother ); - // get the decay length with err - const Gaudi::Math::ValueWithError& declen = myPairParams->decayLength(); - double flight = declen.value(); - double errlen = declen.error(); - double fdchi2 = -999; - if ( errlen > 1e-8 ) fdchi2 = ( flight / errlen ) * ( flight / errlen ); - const Gaudi::LorentzVector& p4 = myPairParams->momentum(); - double measPairMass = p4.M(); - const Gaudi::Math::Point3DWithError& pairposerr = myPairParams->position(); - const Gaudi::XYZPoint& pairpos = pairposerr.point(); - const Gaudi::SymMatrix3x3& paircov = pairposerr.covariance(); - if ( vtx3prong ) { - bool test = true; - double dist = 0; - double chi2 = 0; - sc = m_dist->distance( P->endVertex(), vtx3prong, dist, chi2 ); - if ( !sc.isFailure() ) { - test &= tuple->column( prefix + "_SubVtx" + trail + "_FD", flight ); - test &= tuple->column( prefix + "_SubVtx" + trail + "_FDCHI2", fdchi2 ); - test &= tuple->column( prefix + "_SubVtx" + trail + "_Mass", measPairMass ); - } - - if ( !test ) Warning( "Error in fillFlight " + prefix, StatusCode::SUCCESS, 1 ).ignore(); - - if ( m_fillSubVtx ) { - - if ( sc.isFailure() ) { - return Warning( "Could not fill Endvertex " + prefix, StatusCode::SUCCESS, 1 ); - } - test = true; - test &= tuple->column( prefix + "_SubVtx" + trail + "_", pairpos ); - test &= tuple->column( prefix + "_SubVtx" + trail + "_XERR", std::sqrt( paircov( 0, 0 ) ) ); - test &= tuple->column( prefix + "_SubVtx" + trail + "_YERR", std::sqrt( paircov( 1, 1 ) ) ); - test &= tuple->column( prefix + "_SubVtx" + trail + "_ZERR", std::sqrt( paircov( 2, 2 ) ) ); - test &= tuple->column( prefix + "_SubVtx" + trail + "_CHI2", vtx3prong->chi2() ); - test &= tuple->column( prefix + "_SubVtx" + trail + "_NDOF", vtx3prong->nDoF() ); - test &= tuple->matrix( prefix + "_SubVtx" + trail + "_COV_", paircov ); - - if ( !test ) Warning( "Error in filling Vtx info " + prefix + trail, StatusCode::SUCCESS, 1 ).ignore(); - } - } - } - } - } - - } // end doThreeProng - } - - //========================================================================= - - return sc; -} - -//========================================================================= -// fill vertex stuff -//========================================================================= -StatusCode TupleToolVtxDaughters::fillVertex( const LHCb::VertexBase* vtx, const std::string& vtx_name, - Tuples::Tuple& tuple ) const { - bool test = true; - - // decay vertex information: - if ( !vtx ) { - Gaudi::XYZPoint pt( -999., -999., -999. ); // arbitrary point - test &= tuple->column( vtx_name + "_", pt ); - test &= tuple->column( vtx_name + "_XERR", -999. ); - test &= tuple->column( vtx_name + "_YERR", -999. ); - test &= tuple->column( vtx_name + "_ZERR", -999. ); - test &= tuple->column( vtx_name + "_CHI2", -999. ); - test &= tuple->column( vtx_name + "_NDOF", -1 ); - test &= tuple->matrix( vtx_name + "_COV_", Gaudi::SymMatrix3x3() ); - } else { - // std::cout<<"position of passed VTX - fillVertex ++++ "<position()<column( vtx_name + "_", vtx->position() ); - const Gaudi::SymMatrix3x3& m = vtx->covMatrix(); - test &= tuple->column( vtx_name + "_XERR", std::sqrt( m( 0, 0 ) ) ); - test &= tuple->column( vtx_name + "_YERR", std::sqrt( m( 1, 1 ) ) ); - test &= tuple->column( vtx_name + "_ZERR", std::sqrt( m( 2, 2 ) ) ); - test &= tuple->column( vtx_name + "_CHI2", vtx->chi2() ); - test &= tuple->column( vtx_name + "_NDOF", vtx->nDoF() ); - test &= tuple->matrix( vtx_name + "_COV_", m ); - } - - // -------------------------------------------------- - if ( !test ) Warning( "Error in fillVertex " + vtx_name, StatusCode::SUCCESS, 1 ).ignore(); - return StatusCode( test ); -} -//========================================================================= -// fill flight distance, angle... -//========================================================================= -StatusCode TupleToolVtxDaughters::fillFlight( const LHCb::VertexBase* PairVtx, const Particle* P, - const std::string& prefix, Tuples::Tuple& tuple, - const std::string& trail ) const { - bool test = true; - // -------------------------------------------------- - if ( !PairVtx ) { - test &= tuple->column( prefix + "_FD" + trail, -999. ); - test &= tuple->column( prefix + "_FDCHI2" + trail, -999. ); - test &= tuple->column( prefix + "_DIRA" + trail, -999. ); - } else { - - // flight distance - double dist = 0; - double chi2 = 0; - StatusCode sc = m_dist->distance( P->endVertex(), PairVtx, dist, chi2 ); - if ( sc.isFailure() ) return sc; - - test &= tuple->column( prefix + "_FD" + trail, dist ); - test &= tuple->column( prefix + "_FDCHI2" + trail, chi2 ); - // -------------------------------------------------- - // cosine of (flight distance) dot (momentum): - // find the origin vertex. Either the primary or the origin in the - // decay - // test &= tuple->column( prefix + "_DIRA"+trail, dira(oriVtx,P) ); - } - - if ( !test ) Warning( "Error in fillFlight " + prefix, StatusCode::SUCCESS, 1 ).ignore(); - return StatusCode( test ); -} -// ===================================================== -// find pair vertex in the decay chain -// ===================================================== - -const VertexBase* TupleToolVtxDaughters::ProngVertex( LHCb::Particle::ConstVector daus, double& Mass, - LHCb::Particle& PairMom, IGeometryInfo const& geometry ) const { - - LHCb::Vertex DauVtx; - LHCb::Particle DummyPart( ParticleID( 531 ) ); - - StatusCode scFit = m_vtx->fit( daus, DauVtx, DummyPart, geometry ); - // StatusCode scFit = m_vtx->fit(DauPairVtx,tmp); - if ( !scFit ) { - Warning( "Pair Vtx Fit error" ).ignore(); - return 0; - } - - const VertexBase* myVtx = DummyPart.endVertex(); - Mass = DummyPart.measuredMass(); - PairMom = DummyPart; - return myVtx; -} diff --git a/Phys/DecayTreeTuple/src/TupleToolVtxIsoln.cpp b/Phys/DecayTreeTuple/src/TupleToolVtxIsoln.cpp deleted file mode 100644 index 14f21b208b65a91dc84132fa912c8089270c17f5..0000000000000000000000000000000000000000 --- a/Phys/DecayTreeTuple/src/TupleToolVtxIsoln.cpp +++ /dev/null @@ -1,136 +0,0 @@ -/*****************************************************************************\ -* (c) Copyright 2000-2018 CERN for the benefit of the LHCb Collaboration * -* * -* This software is distributed under the terms of the GNU General Public * -* Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". * -* * -* In applying this licence, CERN does not waive the privileges and immunities * -* granted to it by virtue of its status as an Intergovernmental Organization * -* or submit itself to any jurisdiction. * -\*****************************************************************************/ - -#include "DecayTreeTupleBase/TupleToolBase.h" - -#include "CaloUtils/CaloAlgUtils.h" - -#include "Kernel/GetIDVAlgorithm.h" -#include "Kernel/IDVAlgorithm.h" -#include "Kernel/IDistanceCalculator.h" -#include "Kernel/IExtraInfoTool.h" // Interface -#include "Kernel/IParticleTupleTool.h" // Interface -#include "Kernel/IVertexFit.h" - -#include "Event/Particle.h" - -#include "GaudiAlg/Tuple.h" -#include "GaudiAlg/TupleObj.h" - -/** - * \brief Fill vertex isolation information for DecayTreeTuple - * Take vertexed particle and add other tracks of the - * event, one by one, building a new vertex. By default, this tool - * will look for ExtraInfo filled by the VertexIsolation tool. If it - * is not found, the tool is run to fill the ExtraInfo. - * - * Leaves filled by the tool: - * - (head)_NumVtxWithinChi2WindowOneTrack: number of particles that generate a vertex within a chi2 window - * - (head)_SmallestDeltaChi2OneTrack: smallest delta chi2 when adding one track - * - (head)_SmallestDeltaChi2MassOneTrack: mass of the candidate with the smallest delta chi2 - * - (head)_SmallestDeltaChi2TwoTracks: smallest delta chi2 when adding one track to the - * combination that has the smallest delta chi2 when adding one track - * - (head)_SmallestDeltaChi2MassTwoTracks: mass of the candidate with the smallest delta chi2 - * when adding one track to the combination that has the smallest delta chi2 when adding one track - * - * - * @author Albert Puig, based on previous work from Mitesh Patel, Patrick Koppenburg - * @date 2013-08-05 - * - */ -class TupleToolVtxIsoln : public TupleToolBase, virtual public IParticleTupleTool { - -public: - /// Standard constructor - TupleToolVtxIsoln( const std::string& type, const std::string& name, const IInterface* parent ); - - StatusCode initialize() override; - - StatusCode fill( const LHCb::Particle*, const LHCb::Particle*, const std::string&, Tuples::Tuple&, - IGeometryInfo const& ) override; - -private: - // Isolation tool - IExtraInfoTool* m_isolationTool; - struct IsolationIndices { - int first; - int last; - }; - IsolationIndices m_indices; - // Variable names to store in the tuple - std::map m_varNames; -}; - -using namespace LHCb; - -// Declaration of the Tool Factory -// actually acts as a using namespace TupleTool -DECLARE_COMPONENT( TupleToolVtxIsoln ) - -//============================================================================= -// Standard constructor, initializes variables -//============================================================================= -TupleToolVtxIsoln::TupleToolVtxIsoln( const std::string& type, const std::string& name, const IInterface* parent ) - : TupleToolBase( type, name, parent ), m_isolationTool( 0 ) { - declareInterface( this ); -} - -StatusCode TupleToolVtxIsoln::initialize() { - const StatusCode sc = TupleToolBase::initialize(); - if ( sc.isFailure() ) return sc; - - m_isolationTool = tool( "VertexIsolation", "VertexIsolation", this ); - if ( !m_isolationTool ) { - Error( "Unable to retrieve the isolation tool" ).ignore( /* AUTOMATICALLY ADDED FOR gaudi/Gaudi!763 */ ); - return StatusCode::FAILURE; - } - // Get var names - m_indices.first = m_isolationTool->getFirstIndex(); - m_indices.last = m_isolationTool->getNumberOfParameters() + m_indices.first; - double dummy; - std::string varName; - for ( int index = m_indices.first; index != m_indices.last; index++ ) { - m_isolationTool->getInfo( index, dummy, varName ); - m_varNames[index] = varName; - } - - return sc; -} - -StatusCode TupleToolVtxIsoln::fill( const Particle* mother, const Particle* P, const std::string& head, - Tuples::Tuple& tuple, IGeometryInfo const& geometry ) { - - const std::string prefix = fullName( head ); - Assert( P && mother, "This should not happen, you are inside TupleToolVtxIsoln.cpp :(" ); - // Check the ExtraInfo - bool test = true; - if ( P->isBasicParticle() ) return StatusCode::SUCCESS; - // Fill tuple - if ( P->hasInfo( m_indices.first ) ) { - double def = -999999.; - double val; - for ( int index = m_indices.first; index != m_indices.last; ++index ) { - val = P->info( index, def ); - test &= tuple->column( prefix + "_" + m_varNames[index], val ); - } - } else { - m_isolationTool->calculateExtraInfo( P, P, geometry ).ignore( /* AUTOMATICALLY ADDED FOR gaudi/Gaudi!763 */ ); - double val; - int result; - for ( int index = m_indices.first; index != m_indices.last; ++index ) { - std::string name; - result = m_isolationTool->getInfo( index, val, name ); - if ( !result ) continue; - test &= tuple->column( prefix + "_" + name, val ); - } - } - return StatusCode( test ); -} diff --git a/Phys/DecayTreeTuple/tests/qmtest/QMTest/configuration b/Phys/DecayTreeTuple/tests/qmtest/QMTest/configuration deleted file mode 100644 index 40e0c47c19ff24c6f00af677ee5953bc13f4b36b..0000000000000000000000000000000000000000 --- a/Phys/DecayTreeTuple/tests/qmtest/QMTest/configuration +++ /dev/null @@ -1,5 +0,0 @@ - - -extension class="xml_database.XMLDatabase" kind="database"/> diff --git a/Phys/DecayTreeTuple/tests/qmtest/decaytreetuple.qms/decaytreetuple-configuration-methods.qmt b/Phys/DecayTreeTuple/tests/qmtest/decaytreetuple.qms/decaytreetuple-configuration-methods.qmt deleted file mode 100644 index a24af0a1c06f9c94dd7ea1f1eaff04fcffc70681..0000000000000000000000000000000000000000 --- a/Phys/DecayTreeTuple/tests/qmtest/decaytreetuple.qms/decaytreetuple-configuration-methods.qmt +++ /dev/null @@ -1,21 +0,0 @@ - - - - - python - - - - $DECAYTREETUPLEROOT/tests/test_configuration_methods.py - - - diff --git a/Phys/DecayTreeTuple/tests/test_configuration_methods.py b/Phys/DecayTreeTuple/tests/test_configuration_methods.py deleted file mode 100644 index ee3e1e7ec5b723c7f413999e751ee5270fcf4f00..0000000000000000000000000000000000000000 --- a/Phys/DecayTreeTuple/tests/test_configuration_methods.py +++ /dev/null @@ -1,132 +0,0 @@ -############################################################################### -# (c) Copyright 2000-2020 CERN for the benefit of the LHCb Collaboration # -# # -# This software is distributed under the terms of the GNU General Public # -# Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". # -# # -# In applying this licence, CERN does not waive the privileges and immunities # -# granted to it by virtue of its status as an Intergovernmental Organization # -# or submit itself to any jurisdiction. # -############################################################################### -import random -import string - -from Configurables import DecayTreeTuple, TupleToolDecay -from DecayTreeTuple import Configuration - - -def _random_string(length=10): - """Return a string of randomly chosen lowercase characters.""" - return ''.join( - random.choice(string.ascii_lowercase) for _ in range(length)) - - -def _create_decaytreetuple(name=''): - """Return a DecayTreeTuple instance for test cases. - - Because the DecayTreeTuple object is a Configurable, instances are - 'global', which could mess up a test case if the DecayTreeTuple instance - was created previously. Avoid this by adding a random string to the name. - """ - return DecayTreeTuple(name + _random_string()) - - -def test_add_branches(): - """The addBranches method should add members on the DTT that are instances - of TupleToolDecay, with a name equal to the branch name. - """ - # The decay descriptors don't need to be valid for this test - branches = dict(A='', B='', C='') - - dtt = _create_decaytreetuple() - dtt.addBranches(branches) - - for bname in branches: - try: - bobj = getattr(dtt, bname) - except AttributeError: - assert False, 'Attribute for branch {0!r} not found'.format(bname) - - assert isinstance(bobj, TupleToolDecay) - - -def test_add_branches_no_whitespace_branch_name(): - """addBranches should not allow whitespace in the branch name.""" - for char in string.whitespace: - branches = {char: ''} - - dtt = _create_decaytreetuple() - try: - dtt.addBranches(branches) - assert False, 'Was able to make a branch with whitespace character {0!r}'.format( - char) - except NameError: - pass - - -def test_set_descriptor_template(): - """The setDescriptorTemplate method should create the correct set of - branches and the correct decay descriptor. - """ - descriptor_template = '${Dst}[D*(2010)+ -> ${D0}(D0 -> ${D0_K}K- ${D0_pi}pi+) ${Dst_pi}pi+]CC' - - # The head does not need to marked, it always is implicitly - expected_decay = '[D*(2010)+ -> ^(D0 -> ^K- ^pi+) ^pi+]CC' - expected_branches = { - 'Dst': '[D*(2010)+ -> (D0 -> K- pi+) pi+]CC', - 'Dst_pi': '[D*(2010)+ -> (D0 -> K- pi+) ^pi+]CC', - 'D0': '[D*(2010)+ -> ^(D0 -> K- pi+) pi+]CC', - 'D0_K': '[D*(2010)+ -> (D0 -> ^K- pi+) pi+]CC', - 'D0_pi': '[D*(2010)+ -> (D0 -> K- ^pi+) pi+]CC' - } - - dtt = _create_decaytreetuple() - dtt.setDescriptorTemplate(descriptor_template) - assert dtt.Decay == expected_decay - for bname, bdecay in dtt.Branches.items(): - assert bname in expected_branches, '{0!r} branch expected, not found'.format( - bname) - exp_bdecay = expected_branches[bname] - assert bdecay == exp_bdecay, '{0!r} expected, found {1!r}'.format( - exp_bdecay, bdecay) - - -def test_set_descriptor_template_complex(): - """The setDescriptorTemplate method should create the correct set of - branches and the correct decay descriptor, given a (more) complex template. - """ - # Captures both the Cabibbo-favoured and doubly Cabibbo-suppressed decays - descriptor_template = '[${Dst}(D*(2010)+ -> ${D0}(D0 -> ${D0_K}K- ${D0_pi}pi+) ${Dst_pi}pi+), ${Dst}(D*(2010)+ -> ${D0}(D0 -> ${D0_K}K+ ${D0_pi}pi-) ${Dst_pi}pi+)]CC' - - # The head does not need to marked, it always is implicitly - expected_decay = '[(D*(2010)+ -> ^(D0 -> ^K- ^pi+) ^pi+), (D*(2010)+ -> ^(D0 -> ^K+ ^pi-) ^pi+)]CC' - expected_branches = { - 'Dst': - '[(D*(2010)+ -> (D0 -> K- pi+) pi+), (D*(2010)+ -> (D0 -> K+ pi-) pi+)]CC', - 'Dst_pi': - '[(D*(2010)+ -> (D0 -> K- pi+) ^pi+), (D*(2010)+ -> (D0 -> K+ pi-) ^pi+)]CC', - 'D0': - '[(D*(2010)+ -> ^(D0 -> K- pi+) pi+), (D*(2010)+ -> ^(D0 -> K+ pi-) pi+)]CC', - 'D0_K': - '[(D*(2010)+ -> (D0 -> ^K- pi+) pi+), (D*(2010)+ -> (D0 -> ^K+ pi-) pi+)]CC', - 'D0_pi': - '[(D*(2010)+ -> (D0 -> K- ^pi+) pi+), (D*(2010)+ -> (D0 -> K+ ^pi-) pi+)]CC' - } - - dtt = _create_decaytreetuple() - dtt.setDescriptorTemplate(descriptor_template) - assert dtt.Decay == expected_decay - for bname, bdecay in dtt.Branches.items(): - assert bname in expected_branches, '{0!r} branch expected, not found'.format( - bname) - exp_bdecay = expected_branches[bname] - assert bdecay == exp_bdecay, '{0!r} expected, found {1!r}'.format( - exp_bdecay, bdecay) - - -if __name__ == '__main__': - test_add_branches() - test_add_branches_no_whitespace_branch_name() - - test_set_descriptor_template() - test_set_descriptor_template_complex() diff --git a/Phys/DecayTreeTupleANNPID/CMakeLists.txt b/Phys/DecayTreeTupleANNPID/CMakeLists.txt deleted file mode 100644 index 1868de9e35a6833854af89807fc5f2f38391e9c3..0000000000000000000000000000000000000000 --- a/Phys/DecayTreeTupleANNPID/CMakeLists.txt +++ /dev/null @@ -1,24 +0,0 @@ -############################################################################### -# (c) Copyright 2000-2021 CERN for the benefit of the LHCb Collaboration # -# # -# This software is distributed under the terms of the GNU General Public # -# Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". # -# # -# In applying this licence, CERN does not waive the privileges and immunities # -# granted to it by virtue of its status as an Intergovernmental Organization # -# or submit itself to any jurisdiction. # -############################################################################### -#[=======================================================================[.rst: -Phys/DecayTreeTupleANNPID -------------------------- -#]=======================================================================] - -gaudi_add_module(DecayTreeTupleANNPID - SOURCES - src/TupleToolANNPID.cpp - src/TupleToolANNPIDTraining.cpp - LINK - Analysis::DecayTreeTupleBaseLib - Phys::DaVinciInterfacesLib - Rec::RecInterfacesLib -) diff --git a/Phys/DecayTreeTupleANNPID/doc/release.notes b/Phys/DecayTreeTupleANNPID/doc/release.notes deleted file mode 100644 index 3edd1bd3e06c1969f2e27b5b947d108cb0959878..0000000000000000000000000000000000000000 --- a/Phys/DecayTreeTupleANNPID/doc/release.notes +++ /dev/null @@ -1,29 +0,0 @@ -!----------------------------------------------------------------------------- -! Package : Phys/DecayTreeTupleANNPID -! Responsible : Chris Jones -! Purpose : ANNPID training tuple tools. -!----------------------------------------------------------------------------- - -!============ DecayTreeTupleANNPID v2r0 2016-03-22 ================= - -! 2016-02-23 - Chris Jones - - Add "MC12TuneV4" and "MC15TuneV1" to the default list of ANNPID tunes. - -!========================= DecayTreeTupleANNPID v1r2 2014-12-15 ========================= -! 2014-12-02 - Chris Jones - - Add some Bs2MuMu tunings for testing (disabled by default). - -! 2014-12-02 - Chris Jones - - Add support for missing ANNPID networks, for instance when a tune only - provides one mass hypothesis (e.g. Bs2MuMu). - -!========================= DecayTreeTupleANNPID v1r1 2014-07-25 ========================= - -! 2014-06-27 - Chris Jones - - Add a new TupleTool that fills the ANNPID variables for a given list - of MVA tunes. - -!========================= DecayTreeTupleANNPID v1r0 2014-04-02 ========================= - -! 2014-04-01 - Chris Jones - - First version. Provides a tuple tool for the ANNPID training. diff --git a/Phys/DecayTreeTupleANNPID/src/TupleToolANNPID.cpp b/Phys/DecayTreeTupleANNPID/src/TupleToolANNPID.cpp deleted file mode 100644 index ef535bc20f9fc94fae8f7e59648e552be5319cdb..0000000000000000000000000000000000000000 --- a/Phys/DecayTreeTupleANNPID/src/TupleToolANNPID.cpp +++ /dev/null @@ -1,144 +0,0 @@ -/*****************************************************************************\ -* (c) Copyright 2000-2018 CERN for the benefit of the LHCb Collaboration * -* * -* This software is distributed under the terms of the GNU General Public * -* Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". * -* * -* In applying this licence, CERN does not waive the privileges and immunities * -* granted to it by virtue of its status as an Intergovernmental Organization * -* or submit itself to any jurisdiction. * -\*****************************************************************************/ - -#include "DecayTreeTupleBase/TupleToolBase.h" -#include "Kernel/IParticleTupleTool.h" -#include "RecInterfaces/IChargedProtoANNPIDTool.h" - -#include -#include - -class TupleToolANNPID : public TupleToolBase, virtual public IParticleTupleTool { - -public: - TupleToolANNPID( const std::string& type, const std::string& name, const IInterface* parent ); - StatusCode initialize() override; - StatusCode fill( const LHCb::Particle*, const LHCb::Particle*, const std::string&, Tuples::Tuple&, - IGeometryInfo const& ) override; - -private: - // Local PID type enum - enum PID { El = 0, Mu, Pi, Ka, Pr, De, Gh }; - // total PID types possible - static const std::size_t NPIDs = 7; - - /// Activation flag for each type - std::array m_pidIsOn; - - /// Pointer to the ANNPID tool - const ANNGlobalPID::IChargedProtoANNPIDTool* m_pidTool = nullptr; - - /// The ANNPID tunes to fill - std::vector m_pidTunes; - - /// The PID types to fill - std::vector m_pidTypes; -}; - -//============================================================================= -// Standard constructor, initializes variables -//============================================================================= -TupleToolANNPID::TupleToolANNPID( const std::string& type, const std::string& name, const IInterface* parent ) - : TupleToolBase( type, name, parent ) { - declareInterface( this ); - declareProperty( "ANNPIDTunes", m_pidTunes = {"MCUpTuneV1"} ); - // PID types. Deuteron by default is not included at the moment. - declareProperty( "PIDTypes", m_pidTypes = {"Electron", "Muon", "Pion", "Kaon", "Proton", "Ghost"} ); -} - -StatusCode TupleToolANNPID::initialize() { - const StatusCode sc = TupleToolBase::initialize(); - if ( sc.isFailure() ) return sc; - - m_pidTool = - tool( "ANNGlobalPID::ChargedProtoANNPIDTool", "ChargedProtoANNPID" ); - - // by default all types are off - m_pidIsOn.fill( false ); - // turn on as required - for ( const auto& p : m_pidTypes ) { - if ( "Electron" == p ) { - m_pidIsOn[El] = true; - } else if ( "Muon" == p ) { - m_pidIsOn[Mu] = true; - } else if ( "Pion" == p ) { - m_pidIsOn[Pi] = true; - } else if ( "Kaon" == p ) { - m_pidIsOn[Ka] = true; - } else if ( "Proton" == p ) { - m_pidIsOn[Pr] = true; - } else if ( "Deuteron" == p ) { - m_pidIsOn[De] = true; - } else if ( "Ghost" == p ) { - m_pidIsOn[Gh] = true; - } - } - - return sc; -} - -StatusCode TupleToolANNPID::fill( const LHCb::Particle*, const LHCb::Particle* P, const std::string& head, - Tuples::Tuple& tuple, IGeometryInfo const& geometry ) { - StatusCode sc = StatusCode::SUCCESS; - - // Only run on charged stable particles - if ( !P || !P->proto() || !P->proto()->track() ) return sc; - - // get the prefix - const auto prefix = fullName( head ); - - // Loop over PID tunes - for ( const auto& pidTune : m_pidTunes ) { - // Fill the ANNPID variables for those that are defined - ANNGlobalPID::IChargedProtoANNPIDTool::RetType res; - // Electrons - if ( sc && m_pidIsOn[El] ) { - res = m_pidTool->annPID( P->proto(), LHCb::ParticleID( 11 ), pidTune, geometry ); - if ( res.status ) { sc = tuple->column( prefix + "_" + pidTune + "_ProbNNe", res.value ); } - } - // Muons - if ( sc && m_pidIsOn[Mu] ) { - res = m_pidTool->annPID( P->proto(), LHCb::ParticleID( 13 ), pidTune, geometry ); - if ( res.status ) { sc = tuple->column( prefix + "_" + pidTune + "_ProbNNmu", res.value ); } - } - // Pions - if ( sc && m_pidIsOn[Pi] ) { - res = m_pidTool->annPID( P->proto(), LHCb::ParticleID( 211 ), pidTune, geometry ); - if ( res.status ) { sc = tuple->column( prefix + "_" + pidTune + "_ProbNNpi", res.value ); } - } - // Kaons - if ( sc && m_pidIsOn[Ka] ) { - res = m_pidTool->annPID( P->proto(), LHCb::ParticleID( 321 ), pidTune, geometry ); - if ( res.status ) { sc = tuple->column( prefix + "_" + pidTune + "_ProbNNk", res.value ); } - } - // Protons - if ( sc && m_pidIsOn[Pr] ) { - res = m_pidTool->annPID( P->proto(), LHCb::ParticleID( 2212 ), pidTune, geometry ); - if ( res.status ) { sc = tuple->column( prefix + "_" + pidTune + "_ProbNNp", res.value ); } - } - // Deuterons - if ( sc && m_pidIsOn[De] ) { - res = m_pidTool->annPID( P->proto(), LHCb::ParticleID( 1000010020 ), pidTune, geometry ); - if ( res.status ) { sc = tuple->column( prefix + "_" + pidTune + "_ProbNNd", res.value ); } - } - // Ghosts - if ( sc && m_pidIsOn[Gh] ) { - res = m_pidTool->annPID( P->proto(), LHCb::ParticleID( 0 ), pidTune, geometry ); - if ( res.status ) { sc = tuple->column( prefix + "_" + pidTune + "_ProbNNghost", res.value ); } - } - } - - // return - return sc; -} - -// Declaration of the Tool Factory -DECLARE_COMPONENT( TupleToolANNPID ) diff --git a/Phys/DecayTreeTupleANNPID/src/TupleToolANNPIDTraining.cpp b/Phys/DecayTreeTupleANNPID/src/TupleToolANNPIDTraining.cpp deleted file mode 100644 index 6be21bde80b5d425a7a5cb3479eaf721b0a3d868..0000000000000000000000000000000000000000 --- a/Phys/DecayTreeTupleANNPID/src/TupleToolANNPIDTraining.cpp +++ /dev/null @@ -1,56 +0,0 @@ -/*****************************************************************************\ -* (c) Copyright 2000-2018 CERN for the benefit of the LHCb Collaboration * -* * -* This software is distributed under the terms of the GNU General Public * -* Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". * -* * -* In applying this licence, CERN does not waive the privileges and immunities * -* granted to it by virtue of its status as an Intergovernmental Organization * -* or submit itself to any jurisdiction. * -\*****************************************************************************/ - -#include "DecayTreeTupleBase/TupleToolBase.h" -#include "Kernel/IParticleTupleTool.h" -#include "RecInterfaces/IChargedProtoANNPIDTupleTool.h" - -class TupleToolANNPIDTraining : public TupleToolBase, virtual public IParticleTupleTool { - -public: - TupleToolANNPIDTraining( const std::string& type, const std::string& name, const IInterface* parent ); - StatusCode initialize() override; ///< Initialise - -public: - StatusCode fill( const LHCb::Particle*, const LHCb::Particle*, const std::string&, Tuples::Tuple&, - IGeometryInfo const& ) override; - -private: - /// Pointer to the ANNPID tuple tool - const ANNGlobalPID::IChargedProtoANNPIDTupleTool* m_tuple; -}; - -// Declaration of the Tool Factory -DECLARE_COMPONENT( TupleToolANNPIDTraining ) - -//============================================================================= -// Standard constructor, initializes variables -//============================================================================= -TupleToolANNPIDTraining::TupleToolANNPIDTraining( const std::string& type, const std::string& name, - const IInterface* parent ) - : TupleToolBase( type, name, parent ), m_tuple( NULL ) { - declareInterface( this ); -} - -StatusCode TupleToolANNPIDTraining::initialize() { - const StatusCode sc = TupleToolBase::initialize(); - if ( sc.isFailure() ) return sc; - m_tuple = - tool( "ANNGlobalPID::ChargedProtoANNPIDTupleTool", "Tuple", this ); - return sc; -} - -StatusCode TupleToolANNPIDTraining::fill( const LHCb::Particle*, const LHCb::Particle* P, const std::string& /* head */, - Tuples::Tuple& tuple, IGeometryInfo const& geometry ) { - // Fill the ANNPID variables - // Note, prefix is not used here, so can only use this tool on a single particle at a time... - return m_tuple->fill( tuple, P, geometry ); -} diff --git a/Phys/DecayTreeTupleBase/CMakeLists.txt b/Phys/DecayTreeTupleBase/CMakeLists.txt deleted file mode 100644 index 6d6c2c3e2f292babe90ec6e31116fc85b3a6d2b6..0000000000000000000000000000000000000000 --- a/Phys/DecayTreeTupleBase/CMakeLists.txt +++ /dev/null @@ -1,52 +0,0 @@ -############################################################################### -# (c) Copyright 2000-2021 CERN for the benefit of the LHCb Collaboration # -# # -# This software is distributed under the terms of the GNU General Public # -# Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". # -# # -# In applying this licence, CERN does not waive the privileges and immunities # -# granted to it by virtue of its status as an Intergovernmental Organization # -# or submit itself to any jurisdiction. # -############################################################################### -#[=======================================================================[.rst: -Phys/DecayTreeTupleBase ------------------------ -#]=======================================================================] - -gaudi_add_library(DecayTreeTupleBaseLib - SOURCES - src/lib/DecayTreeTupleBase.cpp - src/lib/OnePart.cpp - LINK - PUBLIC - Boost::headers - Gaudi::GaudiAlgLib - Gaudi::GaudiKernel - LHCb::CaloUtils - LHCb::LHCbKernel - LHCb::LoKiMCLib - LHCb::MCEvent - LHCb::MCInterfaces - Phys::DaVinciInterfacesLib - Phys::DaVinciKernelLib - Phys::DaVinciMCKernelLib - Phys::LoKiPhysLib - PRIVATE - LHCb::LoKiCoreLib -) - -gaudi_add_module(DecayTreeTupleBase - SOURCES - src/component/DecayTreeTuple.cpp - src/component/EventTuple.cpp - src/component/MCDecayTreeTuple.cpp - src/component/TupleToolDecay.cpp - LINK - Boost::headers - DecayTreeTupleBaseLib - Gaudi::GaudiAlgLib - Gaudi::GaudiKernel - LHCb::LHCbKernel - LHCb::LoKiCoreLib - Phys::DaVinciKernelLib -) diff --git a/Phys/DecayTreeTupleBase/doc/release.notes b/Phys/DecayTreeTupleBase/doc/release.notes deleted file mode 100644 index 4c8eeef36ac3ded070fb81e3b4f4fab3a5e7d091..0000000000000000000000000000000000000000 --- a/Phys/DecayTreeTupleBase/doc/release.notes +++ /dev/null @@ -1,57 +0,0 @@ -!----------------------------------------------------------------------------- -! Package : Phys/DecayTreeTupleBase -! Responsible : Chris Jones -! Purpose : Base classes for the DecayTreeTuples -!----------------------------------------------------------------------------- - -!==================== DecayTreeTupleBase v1r5 2015-11-27 ===================== - -! 2015-11-01 - Gerhard Raven - - replace endreq with endmsg - - replace LoKi::select with std::copy_if - -!========================= DecayTreeTupleBase v1r4 2014-07-25 ========================= - -! 2014-06-29 - Chris Jones - - Add "TupleToolANNPID" to the list of default TupleTools. - -!========================= DecayTreeTupleBase v1r3p1 2014-06-13 ========================= - -! 2014-06-13 - Patrick Koppenburg - - Improve a doxygen comment. - -!========================= DecayTreeTupleBase v1r3 2013-10-29 ========================= - -! 2013-10-22 - Patrick Koppenburg - - Fix warning -WARNING EventTuple:: Tuple 'EventTuple' 'unsigned long' has different sizes on 32/64 bit systems. Casting 'EventInSequence' to 'unsigned long long' - -! 2013-10-09 - Patrick Koppenburg - - Bug https://savannah.cern.ch/bugs/index.php?102616: Stop treating errors as warnings. - Now DecayTreeTuple will stop if any tool returns an error. - -!========================= DecayTreeTupleBase v1r2 2013-08-21 ========================= - -! 2013-08-20 - Chris Jones - - Make default setting for UseLoKiDecayFinders true, to allow more testing - in the nightlies etc. - -! 2013-08-13 - Pieter David - - Added the option to use LoKi decay finders, cfr. - https://twiki.cern.ch/twiki/bin/view/LHCb/FAQ/LoKiNewDecayFinders , - in (MC)DecayTreeTuple by setting the "UseLoKiDecayFinders" property. - -!========================= DecayTreeTupleBase v1r1 2013-02-20 ========================= - -! 2013-02-20 - Chris Jones - - Clean up. - -!========================= DecayTreeTupleBase v1r0 2012-11-30 ========================= - -! 2012-11-29 - Marco Clemencic - - Added CMake configuration file. - -! 2012-11-22 - Chris Jones - - First version. Split off the base classes from Phys/DecayTreeTuple - into a linker library here. Also builds a component library with a few core - components. diff --git a/Phys/DecayTreeTupleBase/include/DecayTreeTupleBase/DecayTreeTupleBase.h b/Phys/DecayTreeTupleBase/include/DecayTreeTupleBase/DecayTreeTupleBase.h deleted file mode 100755 index ae3950e5b214714029cddff6779c6b85a120bce3..0000000000000000000000000000000000000000 --- a/Phys/DecayTreeTupleBase/include/DecayTreeTupleBase/DecayTreeTupleBase.h +++ /dev/null @@ -1,180 +0,0 @@ -/*****************************************************************************\ -* (c) Copyright 2000-2018 CERN for the benefit of the LHCb Collaboration * -* * -* This software is distributed under the terms of the GNU General Public * -* Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". * -* * -* In applying this licence, CERN does not waive the privileges and immunities * -* granted to it by virtue of its status as an Intergovernmental Organization * -* or submit itself to any jurisdiction. * -\*****************************************************************************/ -#ifndef JBOREL_DECAYTREETUPLEBASE_H -#define JBOREL_DECAYTREETUPLEBASE_H 1 - -// Include files -// from DaVinci, this is a specialized GaudiAlgorithm -#include "DecayTreeTupleBase/ITupleToolDecay.h" -#include "DecayTreeTupleBase/OnePart.h" -#include "Kernel/DaVinciTupleAlgorithm.h" -#include "Kernel/Escape.h" -#include "Kernel/IEventTupleTool.h" -#include "Kernel/IMCParticleTupleTool.h" -#include "Kernel/IParticleTupleTool.h" -#include "boost/lexical_cast.hpp" - -#include "Event/MCParticle.h" -#include "LoKi/IDecay.h" -#include "LoKi/IMCDecay.h" - -/** @class DecayTreeTupleBase DecayTreeTupleBase.h jborel/DecayTreeTupleBase.h - * - * Base class for algorithms providing a DecayTreeTuple - * - * \sa DecayTreeTuple, MCDecayTreeTuple - * - * \author Patrick Koppenburg based on Jérémie Borels DecayTreeTuple - * \date 2009-01-20 - */ -class DecayTreeTupleBase : public DaVinciTupleAlgorithm { - -public: - /// Standard constructor - DecayTreeTupleBase( const std::string& name, ISvcLocator* pSvcLocator ); - - virtual ~DecayTreeTupleBase(); ///< Destructor - - StatusCode initialize() override; ///< Algorithm initialization - StatusCode execute() override; ///< Algorithm execution - StatusCode finalize() override; ///< Algorithm finalization - -protected: - /// Access the head decay name - const std::string& headDecay() const { return m_headDecay; } - - /// Access the tuple name - const std::string& tupleName() const { return m_tupleName; } - - /// Access the decay finder tool - IMCDecayFinder* mcdkFinder() const { return m_mcdkFinder; } - - /// Access the MC decay finder tool - IDecayFinder* dkFinder() const { return m_dkFinder; } - - bool useLoKiDecayFinders() const { return m_useLoKiDecayFinders; } - const Decays::IMCDecay::iTree& mcDecayTree() const { return m_mcdecayTree; } - const Decays::IDecay::iTree& decayTree() const { return m_decayTree; } - - /// Initialize the main decay - bool initializeDecays( const bool isMC ); - - //! Retrieve from the local storage all the top level particles that match - //! the decay descriptor - bool getDecayMatches( const LHCb::Particle::ConstVector& src, LHCb::Particle::ConstVector& target ); - - //! Retrieve from the local storage all the top level particles that match - //! the decay descriptor - bool getDecayMatches( const LHCb::MCParticle::ConstVector& src, LHCb::MCParticle::ConstVector& target ); - -private: - //! Call the fill methode which does not take a particle as argument - StatusCode fillEventRelatedVariables( Tuples::Tuple& ); - - //! Check if ready to fill or trigger the initialization - //! this is where all the difference between MC particle and Particle occurs - void matchSubDecays( const LHCb::Particle::ConstVector&, LHCb::Particle::ConstVector&, const ITupleToolDecay* ); - - //! Check if ready to fill or trigger the initialization - //! this is where all the difference between MC particle and Particle occurs - void matchSubDecays( const LHCb::MCParticle::ConstVector&, LHCb::MCParticle::ConstVector&, const ITupleToolDecay* ); - - /// Call successively all OnePart's fill methods - bool fillOnePart( Decays::OnePart*, Tuples::Tuple&, const LHCb::Particle* mother, const LHCb::Particle*, - IGeometryInfo const& geometry ); - - /// Call successively all OnePart's fill methods - bool fillOnePart( Decays::OnePart*, Tuples::Tuple&, const LHCb::MCParticle* mother, const LHCb::MCParticle*, - IGeometryInfo const& geometry ); - - /// check for unicity of names - bool checkUnicity() const; - - /// print infos - void printInfos() const; - - /// get daughters for Particles trivially - LHCb::Particle::ConstVector daughtersVector( const LHCb::Particle* d ) const { - if ( !d ) Exception( "NULL Particle" ); - return d->daughtersVector(); - } - - /// get daughters for MCParticles, not so trivially - LHCb::MCParticle::ConstVector daughtersVector( const LHCb::MCParticle* d ) const; - - /// Switch for initializeStufferTools - void switchStufferTools( const LHCb::MCParticle* ) { - if ( msgLevel( MSG::VERBOSE ) ) verbose() << "Initialize MCParticle tools" << endmsg; - initializeStufferTools( m_mcTools ); - } - - /// Switch for initializeStufferTools - void switchStufferTools( const LHCb::Particle* ) { - if ( msgLevel( MSG::VERBOSE ) ) verbose() << "Initialize Particle tools" << endmsg; - initializeStufferTools( m_pTools ); - } - - /// has oscillated (needed to tell if one needs reverting) - bool hasOscillated( const LHCb::Particle* ) const { return false; } - - /// has oscillated (needed to tell if one needs reverting) - bool hasOscillated( const LHCb::MCParticle* P ) const { return ( P ? P->hasOscillated() : false ); } - - /// Get a list of the event tools - std::vector getEventTools() const; - - /// Get branch name for given particle - std::string getBranchName( const std::string& realname ) const; - -protected: - std::vector m_toolList; - - std::vector m_mcTools; - -private: - IMCDecayFinder* m_mcdkFinder; ///< MC truth decay finder - - IDecayFinder* m_dkFinder; ///< Decay finder - - bool m_useLoKiDecayFinders; - Decays::IMCDecay::Tree m_mcdecayTree; ///< MC truth decay tree - Decays::IDecay::Tree m_decayTree; ///< decay tree - - std::string m_headDecay; - - std::string m_tupleName; - - std::map m_decayMap; - std::vector m_decays; - - bool m_useLabName; ///< use labX_ as particle name - bool m_tupleNameAsToolName; - - /// force the mother to have a positive ID and revert all other particles. - /// This is a neat alternative to m_useLabName - bool m_revertToPositiveID; - - std::vector m_parts; - - std::vector m_eTools; - std::vector m_pTools; - - //============================================================================= - // Templated methods accessed from other classes need to be in the header - // to make sure the linker builds them. - //============================================================================= -protected: - mutable Gaudi::Accumulators::Counter<> m_eventCounter{this, "Event"}; - -#include "DecayTreeTupleBaseTemplates.icpp" -}; - -#endif // JBOREL_DECAYTREETUPLEBASE_H diff --git a/Phys/DecayTreeTupleBase/include/DecayTreeTupleBase/DecayTreeTupleBaseTemplates.icpp b/Phys/DecayTreeTupleBase/include/DecayTreeTupleBase/DecayTreeTupleBaseTemplates.icpp deleted file mode 100644 index 291c23493976df417a7555cc1014648a0d3cb3d5..0000000000000000000000000000000000000000 --- a/Phys/DecayTreeTupleBase/include/DecayTreeTupleBase/DecayTreeTupleBaseTemplates.icpp +++ /dev/null @@ -1,374 +0,0 @@ -/*****************************************************************************\ -* (c) Copyright 2000-2018 CERN for the benefit of the LHCb Collaboration * -* * -* This software is distributed under the terms of the GNU General Public * -* Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". * -* * -* In applying this licence, CERN does not waive the privileges and immunities * -* granted to it by virtue of its status as an Intergovernmental Organization * -* or submit itself to any jurisdiction. * -\*****************************************************************************/ -/** @file DecayTreeTupleBaseTemplates.icpp - * - * All templates methods in DecayTreeTupleBase that need to be included - * in header to allow proper linking with DecayTreeTuple and MCDecayTreeTuple - * - * \sa DecayTreeTuple, MCDecayTreeTuple - * - * \author Patrick Koppenburg based on Jérémie Borels DecayTreeTuple - * \date 2009-01-20 - */ -//============================================================================= -//============================================================================= -//! Trigger all fill procedures -template -StatusCode fillTuple( Tuples::Tuple& tuple, const PARTICLEVECTOR& heads, DECAYFINDER* dkFinder, - IGeometryInfo const& geometry ) { - typename PARTICLEVECTOR::const_iterator pit = heads.begin(); - PARTICLEVECTOR row; - - unsigned int nCandidates = 0; - StatusCode test = StatusCode::FAILURE; - - for ( ; heads.end() != pit; ++pit ) { - if ( msgLevel( MSG::DEBUG ) ) debug() << "######################################## New head" << endmsg; - test = StatusCode::FAILURE; - row.clear(); - dkFinder->decayMembers( *pit, row ); - row.insert( row.begin(), *pit ); // must insert the head as it cant be flagged. - - if ( fillParticles( tuple, row, geometry ) ) { - tuple->column( "nCandidate", nCandidates ).ignore(); - tuple->column( "totCandidates", (unsigned long long)heads.size() ).ignore(); - tuple->column( "EventInSequence", (unsigned long long)m_eventCounter.nEntries() ).ignore(); - ++nCandidates; - } else { - fatal() << "Failed to fill a candidate. Please fix your options." << endmsg; - fatal() << "### NOTE : This is a new behaviour since bug https://its.cern.ch/jira/browse/LHCBPS-690" << endmsg; - fatal() << "### NOTE : If you think this is wrong, report to lhcb-davinci@cern.ch" << endmsg; - return StatusCode::FAILURE; - } - - test = fillEventRelatedVariables( tuple ); - - if ( test ) { - test = tuple->write(); - } else { - Warning( "Failed to fill some variable, will skip this candidate." ).ignore(); - } - } - - return test; -} - -template -StatusCode fillTuple( Tuples::Tuple& tuple, COLLECTION heads, const typename Decays::iTree_& decaytree, - IGeometryInfo const& geometry ) { - unsigned int nCandidates = 0; - StatusCode test = StatusCode::FAILURE; - std::vector row; - for ( typename COLLECTION::const_iterator pIt = heads.begin(); pIt != heads.end(); ++pIt ) { - if ( msgLevel( MSG::DEBUG ) ) debug() << "######################################## New head" << endmsg; - test = StatusCode::FAILURE; - row.clear(); - if ( decaytree( *pIt ) && decaytree.marked() ) { decaytree.collect( row ); } - row.insert( row.begin(), *pIt ); // must insert the head as it cant be flagged. - - if ( fillParticles( tuple, row, geometry ) ) { - tuple->column( "nCandidate", nCandidates ).ignore(); - tuple->column( "totCandidates", (unsigned long long)heads.size() ).ignore(); - tuple->column( "EventInSequence", (unsigned long long)m_eventCounter.nEntries() ).ignore(); - ++nCandidates; - } else { - fatal() << "Failed to fill a candidate. Please fix your options." << endmsg; - fatal() << "### NOTE : This is a new behaviour since bug https://its.cern.ch/jira/browse/LHCBPS-690" << endmsg; - fatal() << "### NOTE : If you think this is wrong, report to lhcb-davinci@cern.ch" << endmsg; - return StatusCode::FAILURE; - } - - test = fillEventRelatedVariables( tuple ); - if ( test ) { - test = tuple->write(); - } else { - Warning( "Failed to fill some variable, will skip this candidate." ).ignore(); - } - } - return test; -} - -//============================================================================= -/// get offset in tree -template -int getOffset( const PARTICLE* p, const std::vector& v, bool secure = true ) { - typename std::vector::const_iterator f; - f = std::find( v.begin(), v.end(), p ); - if ( secure ) Assert( f != v.end() ); - return f - v.begin(); -} -//============================================================================= -/// Recursively fill (MC)Particles. PARTICLEVECTOR is LHCb::(MC)Particle::ConstVector -template -StatusCode fillParticles( Tuples::Tuple& tuple, const PARTICLEVECTOR& row, IGeometryInfo const& geometry ) { - if ( sizeCheckOrInit( row ) ) { - bool test = true; - const int size = m_parts.size(); - for ( int k = 0; size > k; ++k ) { // row[0] is the deday head. - if ( msgLevel( MSG::DEBUG ) ) debug() << "#### Filling " << row[k]->particleID().pid() << endmsg; - test &= fillOnePart( m_parts[k], tuple, row[0], row[k], geometry ); - } - return StatusCode( test ); - } - return StatusCode::FAILURE; -} - -std::string getParticleName( const LHCb::ParticleProperty* partProp ) { - return partProp != NULL ? partProp->particle() : "Unknown"; -} - -//============================================================================= -/// Initialize Tuple, or check all is consistent PARTICLE is LHCb::(MC)Particle -template -bool sizeCheckOrInit( const std::vector& row ) { - const unsigned int size = row.size(); - if ( m_parts.size() == size ) return true; - - if ( !m_parts.empty() ) { - Error( "The number of matched particles with the DecayFinder (" + m_headDecay + - ") has changed. Skipping the candidate." ) - .ignore(); - return false; - } - - if ( msgLevel( MSG::DEBUG ) ) debug() << "Entering the initialization process" << endmsg; - - // initializing the particles object. - m_parts.reserve( size ); - bool revertChain = false; - bool revertHead = false; - if ( m_revertToPositiveID ) { - revertHead = ( row[0]->particleID().pid() < 0 ); // revert all heads - bool oscillated = hasOscillated( row[0] ); // only makes sense for MC - // revert chain only for particles oscillating : - revertChain = ( revertHead != oscillated ); // Bbar -> Bbar or B -> Bbar - info() << "The head of chain is a " << getParticleName( ppSvc()->find( row[0]->particleID() ) ); - if ( oscillated ) info() << " that has oscillated"; - info() << " : "; - if ( revertHead ) info() << "Will change to its antiparticle. "; - if ( revertChain ) info() << "Will change daughters to antiparticles. "; - if ( !( revertHead || revertChain ) ) info() << "Will keep whole chain as is. "; - info() << endmsg; - } - - for ( unsigned int i = 0; i < size; ++i ) { - bool revert = ( ( i == 0 ) ? revertHead : revertChain ); - bool exists = ppSvc()->find( row[i]->particleID() ) != NULL; - const LHCb::ParticleProperty* pp = ( ( exists && revert ) ? ppSvc()->find( row[i]->particleID() )->antiParticle() - : ppSvc()->find( row[i]->particleID() ) ); - Decays::OnePart* p = new Decays::OnePart( getParticleName( pp ), getBranchName( getParticleName( pp ) ) ); - - // inherit the default properties: - m_parts.push_back( p ); - } - - if ( msgLevel( MSG::DEBUG ) ) debug() << "There are " << m_parts.size() << " particles to initialize." << endmsg; - - // set the base properties... - switchStufferTools( row[0] ); // that's a cheat - if ( msgLevel( MSG::VERBOSE ) ) verbose() << "Done switchStufferTools" << endmsg; - // set the branch names and inherit the particle specific tools - std::vector::iterator mit; - std::vector buffer; - - if ( msgLevel( MSG::VERBOSE ) ) verbose() << "Decays size " << m_decays.size() << endmsg; - // is there any special name for this MCParticle ?: - for ( mit = m_decays.begin(); m_decays.end() != mit; ++mit ) { - if ( msgLevel( MSG::VERBOSE ) ) verbose() << "Looping over Decays" << *mit << endmsg; - if ( 0 == *mit ) continue; - buffer.clear(); - if ( msgLevel( MSG::VERBOSE ) ) verbose() << "Cleared buffer" << *mit << endmsg; - matchSubDecays( row, buffer, *mit ); - if ( msgLevel( MSG::VERBOSE ) ) verbose() << "Matched sub decays" << *mit << endmsg; - } - - if ( msgLevel( MSG::VERBOSE ) ) verbose() << "Going to re-recreate daughter-mother relationship" << endmsg; - - // re-creating mother->daughter relationship, - // allows better printout later on - for ( int i = 0; i < (int)row.size(); ++i ) { - Decays::OnePart* Mother = m_parts[i]; - - std::vector dau = daughtersVector( row[i] ); // row[i]->daughtersVector() - typename std::vector::const_iterator dauit, f; - for ( dauit = dau.begin(); dau.end() != dauit; ++dauit ) { - if ( msgLevel( MSG::VERBOSE ) ) verbose() << "Looping over daughter " << ( *dauit )->particleID().pid() << endmsg; - // am I in the search decay ? - f = std::find( row.begin(), row.end(), *dauit ); - if ( f == row.end() ) continue; - int off = getOffset( *f, row ); - Mother->addDaughter( m_parts[off] ); - m_parts[off]->setMother( Mother ); - } - } - - if ( !checkUnicity() ) return false; - printInfos(); - return true; -} -//============================================================================= -/// Find associated OneParts -template -void findAssociatedOneParts( PARTICLEVECTOR& buffer, const PARTICLEVECTOR& row, const ITupleToolDecay* mit, - std::vector& pTools ) { - const int size = buffer.size(); - for ( int k = 0; k < size; ++k ) { - if ( msgLevel( MSG::VERBOSE ) ) - verbose() << "Looping on " << buffer[k]->particleID().pid() << " with " << mit->name() << endmsg; - // loop on the matched particles and find the associated Decays::OnePart* object - int off = getOffset( buffer[k], row, false ); - if ( off == (int)row.size() ) { - Error( "The decay descriptor '" + mit->getInfo() + - "' returned a match which is not also matched by your main decay descriptor. Ignoring it." ) - .ignore(); - break; - } - if ( m_tupleNameAsToolName ) { - std::string n = mit->getName(); - // if there is more than one, append numerical values: - if ( size > 1 ) n.append( boost::lexical_cast( k ) ); - m_parts[off]->headName( Decays::escape( n ) ); - } - // assign the correct tools: - initializeOnePartsStufferTools( m_parts[off], mit, pTools ); - } -} -//============================================================================= -/// Initialize all Particle tools -template -void initializeStufferTools( std::vector& pTools ) { - if ( msgLevel( MSG::VERBOSE ) ) - verbose() << "input tool list " << m_toolList << " size " << m_toolList.size() << endmsg; - - std::sort( m_toolList.begin(), m_toolList.end() ); - m_toolList.erase( std::unique( m_toolList.begin(), m_toolList.end() ), m_toolList.end() ); - - if ( msgLevel( MSG::VERBOSE ) ) - verbose() << "unique tool list " << m_toolList << " size " << m_toolList.size() << endmsg; - - // base instantiation: - for ( std::vector::const_iterator it = m_toolList.begin(); m_toolList.end() != it; ++it ) { - if ( msgLevel( MSG::VERBOSE ) ) verbose() << ( *it ) << " " << ( *it ).find( "TupleToolDecay", 0 ) << endmsg; - if ( 0 == ( *it ).find( "TupleToolDecay", 0 ) ) { // ignore TupleToolDecay - if ( msgLevel( MSG::DEBUG ) ) debug() << "Ignoring " << ( *it ) << endmsg; - continue; - } - IAlgTool* tt = tool( *it, this ); - if ( !tt ) { - Error( "Not AlgTool: Cannot get the tool '" + *it + "', check your syntax" ).ignore(); - continue; - } - // splitting in the correct list. - SmartIF test1( tt ); - if ( msgLevel( MSG::VERBOSE ) ) verbose() << *it << " is IEventTupleTool? " << test1 << endmsg; - if ( test1 ) m_eTools.push_back( test1 ); - SmartIF test2( tt ); - if ( msgLevel( MSG::VERBOSE ) ) verbose() << *it << " is ITUPLETOOL " << test2 << endmsg; - if ( test2 ) { - pTools.push_back( test2 ); - - // inherit by default: give all the tools to the particles: - for ( std::vector::iterator op = m_parts.begin(); op != m_parts.end(); ++op ) { - if ( msgLevel( MSG::VERBOSE ) ) - verbose() << "Adding " << test2->type() << " to " << ( *op )->headName() << endmsg; - ( *op )->addTool( test2 ); - } - } - - if ( !test1 && !test2 ) { Error( "Can't get the tool '" + *it + "', check your syntax" ).ignore(); } - if ( test1 && test2 ) { - Warning( "The tool '" + *it + "', will be called both by the IParticleTupleTool" + - " and IEventTupleTool interfaces. That's fine as long as you" + " know what you are doing." ) - .ignore(); - } - if ( test1 && !test2 ) - if ( msgLevel( MSG::VERBOSE ) ) verbose() << *it << " instantiated as an Event related tool" << endmsg; - if ( !test1 && test2 ) - if ( msgLevel( MSG::VERBOSE ) ) verbose() << *it << " instantiated as a Particle related tool" << endmsg; - } - - if ( msgLevel( MSG::DEBUG ) ) debug() << "Generic and inherited tool list successfully created" << endmsg; -} -//============================================================================= -//============================================================================= -/// Initialize all Particle tools -template -void initializeOnePartsStufferTools( Decays::OnePart* P, const ITupleToolDecay* m, std::vector& pTools ) { - if ( !m ) Exception( "No ITupleToolDecay" ); - if ( !P ) Exception( "No Particle" ); - if ( msgLevel( MSG::DEBUG ) ) { - debug() << "initializeOnePartsStufferTools for " << P->headName() << " " << P->info() << endmsg; - debug() << " - Tool: " << m->name() << " " << m->getName() << " " << m->decay() << endmsg; - } - // there is a specific descriptor for P, i.e. default settings are wrong - P->clearTools(); - - // tool list must become : specific + (inherited-specific) - std::vector remainTools; - std::vector globalTools = getParticleTools( pTools ); - const std::vector& locTools = m->getStuffers(); - if ( msgLevel( MSG::VERBOSE ) ) { - verbose() << "Stuffers are "; - for ( std::vector::const_iterator i = locTools.begin(); i != locTools.end(); ++i ) { - verbose() << *i << " "; - } - verbose() << endmsg; - } - - std::insert_iterator> ii( remainTools, remainTools.begin() ); - std::set_difference( globalTools.begin(), globalTools.end(), locTools.begin(), locTools.end(), ii ); - - if ( msgLevel( MSG::VERBOSE ) ) verbose() << "Remains " << remainTools.size() << " to inherit" << endmsg; - - // inherit again the remaining global tools: - if ( m->inheritTools() ) { - for ( std::vector::const_iterator it = remainTools.begin(); remainTools.end() != it; ++it ) { - if ( msgLevel( MSG::VERBOSE ) ) verbose() << "Remaining tool " << *it << endmsg; - // find the right tool: - bool flag = false; - for ( unsigned int k = 0; k < pTools.size(); ++k ) { - if ( *it == pTools[k]->type() ) { - if ( msgLevel( MSG::VERBOSE ) ) - verbose() << "Found! Part " << P->info() << " inherits " << pTools[k]->type() << endmsg; - P->addTool( pTools[k] ); - flag = true; - break; - } - } - if ( !flag ) - Warning( "Hmm, should not happen, the tool '" + *it + "' will be ignored for some reason..." ).ignore(); - } - } - - // now instanciate the specific tools from the TupleToolDecay: - for ( std::vector::const_iterator it = locTools.begin(); locTools.end() != it; ++it ) { - if ( msgLevel( MSG::DEBUG ) ) debug() << "locTools: Creating tool " << *it << " for " << P->headName() << endmsg; - ITUPLETOOL* tt = tool( *it, m ); - if ( !tt ) { - Error( "Cannot instanciate the tool '" + *it + "', check your syntax" ).ignore(); - continue; - } - if ( msgLevel( MSG::VERBOSE ) ) verbose() << "locTools: Part " << P->info() << " inherits " << tt->type() << endmsg; - P->addTool( tt ); - } -} -//============================================================================= -/// get (MC)Particle tools -template -std::vector getParticleTools( const std::vector pTools ) const { - std::vector ret; - ret.reserve( pTools.size() ); - for ( typename std::vector::const_iterator it = pTools.begin(); pTools.end() != it; ++it ) { - ret.push_back( ( *it )->type() ); - } - return ret; -} -//=============================================================================} diff --git a/Phys/DecayTreeTupleBase/include/DecayTreeTupleBase/ITupleToolDecay.h b/Phys/DecayTreeTupleBase/include/DecayTreeTupleBase/ITupleToolDecay.h deleted file mode 100644 index 7eb3c5c98d5cb6478da4d0547ab9221e139cc65c..0000000000000000000000000000000000000000 --- a/Phys/DecayTreeTupleBase/include/DecayTreeTupleBase/ITupleToolDecay.h +++ /dev/null @@ -1,67 +0,0 @@ -/*****************************************************************************\ -* (c) Copyright 2000-2018 CERN for the benefit of the LHCb Collaboration * -* * -* This software is distributed under the terms of the GNU General Public * -* Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". * -* * -* In applying this licence, CERN does not waive the privileges and immunities * -* granted to it by virtue of its status as an Intergovernmental Organization * -* or submit itself to any jurisdiction. * -\*****************************************************************************/ -#ifndef DECAYTREETUPLE_ITUPLETOOLDECAY_H -#define DECAYTREETUPLE_ITUPLETOOLDECAY_H 1 - -// from STL -#include - -// Interfaces -#include "Kernel/IDecayFinder.h" -#include "MCInterfaces/IMCDecayFinder.h" - -#include "LoKi/IDecay.h" -#include "LoKi/IMCDecay.h" - -// from Gaudi -#include "GaudiKernel/IAlgTool.h" - -static const InterfaceID IID_ITupleToolDecay( "ITupleToolDecay", 1, 0 ); - -/** @class ITupleToolDecay ITupleToolDecay.h DecayTreeTuple/ITupleToolDecay.h - * - * Interface for TupleToolDecay - * - * @author Chris Jones - * @date 2012-11-22 - */ - -class ITupleToolDecay : virtual public IAlgTool { - -public: - // Return the interface ID - static const InterfaceID& interfaceID() { return IID_ITupleToolDecay; } - -public: - virtual std::string decay() const = 0; - - virtual std::string getInfo() const = 0; - - virtual void printInfo() const = 0; - - virtual StatusCode initializeDecay( const std::string&, bool ) = 0; - - virtual IDecayFinder* decayFinder() const = 0; - - virtual IMCDecayFinder* mcDecayFinder() const = 0; - - virtual bool useLoKiDecayFinders() const = 0; - virtual const Decays::IMCDecay::iTree& mcDecayTree() const = 0; - virtual const Decays::IDecay::iTree& decayTree() const = 0; - - virtual const std::string& getName() const = 0; - - virtual const std::vector& getStuffers() const = 0; - - virtual bool inheritTools() const = 0; -}; - -#endif // DECAYTREETUPLE_ITUPLETOOLDECAY_H diff --git a/Phys/DecayTreeTupleBase/include/DecayTreeTupleBase/OnePart.h b/Phys/DecayTreeTupleBase/include/DecayTreeTupleBase/OnePart.h deleted file mode 100644 index 84725b50894fcd4a3d6b3701cb90b49bb666f178..0000000000000000000000000000000000000000 --- a/Phys/DecayTreeTupleBase/include/DecayTreeTupleBase/OnePart.h +++ /dev/null @@ -1,105 +0,0 @@ -/*****************************************************************************\ -* (c) Copyright 2000-2018 CERN for the benefit of the LHCb Collaboration * -* * -* This software is distributed under the terms of the GNU General Public * -* Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". * -* * -* In applying this licence, CERN does not waive the privileges and immunities * -* granted to it by virtue of its status as an Intergovernmental Organization * -* or submit itself to any jurisdiction. * -\*****************************************************************************/ -#ifndef ONEPART_H -#define ONEPART_H 1 - -#include "GaudiKernel/MsgStream.h" - -/** @class OnePart OnePart.h - * - * Helper class for DecayTreeTupleBase - * - * Stores info about one particle and its tools - * - * @author Jérémie Borel - * @date 2007-11-01 - * @author Patrick Koppenburg - extracted from DecayTreeTuple - * @date 2009-01-09 - */ -struct IParticleTupleTool; -class IMCParticleTupleTool; -namespace Decays { - class OnePart { - public: - /// constructor - OnePart( const std::string& partname, const std::string& head ); - /// destructor - ~OnePart(); - /// Refers to the tuple column name prefix - std::string headName(); - /// Refers to the tuple column name prefix - void headName( const std::string& h ); - /// Refers to the particle's real syntax (not escaped) - std::string getRealName(); - /// Refers to the particle's real syntax (not escaped) - const std::string& getRealName() const; - /// Prints the tree strucutre, if verbose, also prints the tool list - void printStructure( MsgStream& os, bool verbose = false ) const; - /// depth - int depth() const; - /// set mother - void setMother( const OnePart* ); - /// mother - const OnePart* getMother() const; - /// add daughter - void addDaughter( OnePart* ); - /// info string - std::string info() const; - /// add a Tuple tool - void addTool( IParticleTupleTool* tool ); - void addTool( IMCParticleTupleTool* tool ); - /// list of tuple tools - std::vector& tools(); - std::vector& mctools(); - /// list of tools - std::vector toolList() const; - std::vector mctoolList() const; - /// clear list of tools - void clearTools(); - - private: - std::string m_head, m_realname; //< real name of particle - OnePart(); //< constructor - OnePart( const OnePart& ); //< copy constructor - const OnePart* m_mother; //< mother - std::vector m_daughters; //< daughters - std::vector m_tools; //< tools - std::vector m_mctools; //< tools - }; - - // =============================================================== - // ======================= inline & template body ================ - // =============================================================== - /** join a container with a separation char. */ - template - std::string join( ForwardIterator first, ForwardIterator last, const char* sep = ", ", - const char* ifempty = "none" ) { - std::stringstream ret; - ForwardIterator it( first ), it2( first ); - if ( first == last ) return std::string( ifempty ); - ++it2; - if ( it2 == last ) { - ret << *first; - return ret.str(); - } - it2 = first; - while ( it2 != last ) { - ret << *it << sep; - ++it; - it2 = it; - ++it2; - } - ret << *it; - return ret.str(); - } - -} // namespace Decays -#endif // ONEPART_H diff --git a/Phys/DecayTreeTupleBase/include/DecayTreeTupleBase/TupleToolBase.h b/Phys/DecayTreeTupleBase/include/DecayTreeTupleBase/TupleToolBase.h deleted file mode 100755 index cd3637dd6c81de188f4ee2145e731cdc71c02dd9..0000000000000000000000000000000000000000 --- a/Phys/DecayTreeTupleBase/include/DecayTreeTupleBase/TupleToolBase.h +++ /dev/null @@ -1,87 +0,0 @@ -/*****************************************************************************\ -* (c) Copyright 2000-2018 CERN for the benefit of the LHCb Collaboration * -* * -* This software is distributed under the terms of the GNU General Public * -* Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". * -* * -* In applying this licence, CERN does not waive the privileges and immunities * -* granted to it by virtue of its status as an Intergovernmental Organization * -* or submit itself to any jurisdiction. * -\*****************************************************************************/ -#ifndef DV_TUPLETOOLBASE_H -#define DV_TUPLETOOLBASE_H 1 - -// Include files -// from Gaudi -#include "CaloUtils/CaloParticle.h" -#include "GaudiAlg/GaudiTupleTool.h" - -/** @class TupleToolBase TupleToolBase.h jborel/TupleToolBase.h - * - * \brief Shared functions/options for all TupleTools - * - * - * \sa DecayTreeTuple - * - * @author Rob Lambert - * @date 2010-01-19 - */ -class TupleToolBase : public GaudiTupleTool { - -public: - /// Standard constructor - TupleToolBase( const std::string& type, const std::string& name, const IInterface* parent ) - : GaudiTupleTool( type, name, parent ) { - declareProperty( "ExtraName", m_extraName = "", "prepend the name of any variable with this string" ); - declareProperty( "Verbose", m_verbose = false, "add extra variables for this tool" ); - declareProperty( "MaxPV", m_maxPV = 100, "Maximal number of PVs considered" ); - } - - virtual ~TupleToolBase() {} ///< Destructor - -protected: - inline const std::string& extraName() const { return m_extraName; } - inline bool isVerbose() const { return m_verbose; } - - /// Returns the full name for the tuple variables - inline std::string fullName( const std::string& head = "" ) const { - return ( m_extraName.empty() ? head : head.empty() ? m_extraName + '_' : head + '_' + m_extraName ); - } - - /// generic templated method to check if a container exists without loading the data on demand service - /// (which exist<> would do) - /// @author Ivan.Belyaev@nikhef.nl - template - inline bool safeExist( const std::string& location ) { - DataObject* obj = NULL; - StatusCode sc = evtSvc()->findObject( location, obj ); - return sc.isSuccess() && obj && dynamic_cast( obj ); - } - - /// generic templated method to extract the number of entries in a given location. - /// usage int n = number('/Event/Phys/MyParts/Particles') - template - inline int number( const std::string& location ) { - return ( safeExist( location ) ? (int)( get( location ) )->size() : -1 ); - } - - /// Get the TES location of an object. - const std::string objectLocation( const DataObject* pObject ) const { - return ( !pObject ? "Null DataObject" - : ( pObject->registry() ? pObject->registry()->identifier() : "UnRegistered" ) ); - } - -protected: - /// Check if a pure CALO Particle - inline bool isPureNeutralCalo( const LHCb::Particle* P ) const { - LHCb::CaloParticle caloP( (LHCb::Particle*)P ); - return caloP.isPureNeutralCalo(); - } - -protected: - std::string m_extraName; ///< Extra title to add to head - bool m_verbose; ///< Add extra items to the tuple - unsigned int m_maxPV; ///< max number of PVs (constant) -}; - -#endif // DV_TUPLETOOLBASE diff --git a/Phys/DecayTreeTupleBase/include/DecayTreeTupleBase/isStable.h b/Phys/DecayTreeTupleBase/include/DecayTreeTupleBase/isStable.h deleted file mode 100644 index a41b30129b2cf11b7d2b3ff2941ebcfea8402b40..0000000000000000000000000000000000000000 --- a/Phys/DecayTreeTupleBase/include/DecayTreeTupleBase/isStable.h +++ /dev/null @@ -1,33 +0,0 @@ -/*****************************************************************************\ -* (c) Copyright 2000-2018 CERN for the benefit of the LHCb Collaboration * -* * -* This software is distributed under the terms of the GNU General Public * -* Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". * -* * -* In applying this licence, CERN does not waive the privileges and immunities * -* granted to it by virtue of its status as an Intergovernmental Organization * -* or submit itself to any jurisdiction. * -\*****************************************************************************/ -#ifndef ISSTABLE_H -#define ISSTABLE_H 1 - -// Include files - -/** @class isStable isStable.h - * - * - * @author Patrick Koppenburg - * @date 2009-05-14 - */ -bool isStable( const LHCb::MCParticle* mc ) const { - if ( !mc ) return true; - if ( mc->endVertices().empty() ) return true; - unsigned int anID = abs( mc->particleID().pid() ); - - if ( anID == 11 || anID == 13 || anID == 22 || anID == 12 || anID == 111 || anID == 211 || anID == 130 || - anID == 321 || anID == 2112 || anID == 2212 ) - return true; - return false; -} - -#endif // ISSTABLE_H diff --git a/Phys/DecayTreeTupleBase/src/component/DecayTreeTuple.cpp b/Phys/DecayTreeTupleBase/src/component/DecayTreeTuple.cpp deleted file mode 100644 index abb7f53026d918fbde0a30e3f29cb3e95df74ece..0000000000000000000000000000000000000000 --- a/Phys/DecayTreeTupleBase/src/component/DecayTreeTuple.cpp +++ /dev/null @@ -1,178 +0,0 @@ -/*****************************************************************************\ -* (c) Copyright 2000-2018 CERN for the benefit of the LHCb Collaboration * -* * -* This software is distributed under the terms of the GNU General Public * -* Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". * -* * -* In applying this licence, CERN does not waive the privileges and immunities * -* granted to it by virtue of its status as an Intergovernmental Organization * -* or submit itself to any jurisdiction. * -\*****************************************************************************/ - -#include "DecayTreeTupleBase/DecayTreeTupleBase.h" -#include "DecayTreeTupleBase/OnePart.h" - -#include "Kernel/Escape.h" - -#include "DetDesc/IDetectorElement.h" - -#include "boost/lexical_cast.hpp" - -#include -#include - -/** - * \brief This is the new version of the so-called DecayChainNTuple - * - * \section basics (Basic usage:) - * - * DecayTreeTuple has a decay descriptor (given by the Decay - * property). One line of the Tuple if filled for each reconstructed - * candidate. - * - * For examples on how to use it, refer to Tutorial 8. - * See https://twiki.cern.ch/twiki/bin/view/LHCb/DaVinciTutorial - * - * \section principle How it works: - * - * DecayTreeTuple basically owns a set of tools which all implement - * either the IEventTupleTool or the IParticleTupleTool - * interfaces. For every reconstructed candidates, it successively - * call all the tools: - * - * - Once for each matched particles for the IParticleTupleTool instances - * - * - Once for the candidate for the IEventTupleTool instances - * - * \subsection branches Fine tuning of the branches: - * - * The \b Branches property, is a map. Each of its - * entry associates a name with decay descriptor matching a specific - * part of the main decay. - * - * Once an entry exists, specific tools for this entry can be - * added. They will only act on the particles matched by the - * associated decay AND the main decay. Specific tools have their own - * properties, whether or not the tool already exists in the generic - * tool list. - * - * \note Notice the way the decay head is matched as it is a bit unusual. - * - * \subsection names Naming the tuple column: - * - * The following rules applies to name the tuple columns: - *
    - * - *
  1. By default, the name of the particles from the first matched - * candidate are taken to prefix the column names (after having - * sanitized some ugly chars). - * - *
  2. If a specific decay is given for some particles, the first - * argument of the \b Branches property is taken as prefix. This is not - * true anymore if \b UseToolNameForBranchName is set to false. - * - *
  3. For the nostalgics of DecayChainNTuple, the \b UseLabXSyntax - * allows to prefix the branches with the good old \em labX style. Yet it - * will be prefixed, not post fixed. - * - *
- * - * \sa TupleToolDecay IEventTupleTool IParticleTupleTool - * - * \author Jeremie Borel with the help of Patrick and lhcb-davinci@cern.ch - * \date 2007-11-01 - */ -struct DecayTreeTuple : DecayTreeTupleBase { - - DecayTreeTuple( const std::string& name, ISvcLocator* pSvcLocator ); - StatusCode initialize() override; - StatusCode execute() override; -}; - -using namespace LHCb; -using namespace Gaudi; - -//============================================================================= -// Standard constructor, initializes variables -//============================================================================= -DecayTreeTuple::DecayTreeTuple( const std::string& name, ISvcLocator* pSvcLocator ) - : DecayTreeTupleBase( name, pSvcLocator ) { - // fill some default value - m_toolList.push_back( "TupleToolKinematic" ); - m_toolList.push_back( "TupleToolPid" ); - m_toolList.push_back( "TupleToolANNPID" ); - m_toolList.push_back( "TupleToolGeometry" ); - m_toolList.push_back( "TupleToolEventInfo" ); - declareProperty( "ToolList", m_toolList ); - setProperty( "TupleName", "DecayTree" ).ignore( /* AUTOMATICALLY ADDED FOR gaudi/Gaudi!763 */ ); -} - -//============================================================================= -// Initialization -//============================================================================= -StatusCode DecayTreeTuple::initialize() { - StatusCode sc = DecayTreeTupleBase::initialize(); - if ( sc.isFailure() ) { return Error( "Error from base class", sc ); } - sc = initializeDecays( false ) ? StatusCode::SUCCESS : StatusCode::FAILURE; - if ( sc.isFailure() ) { return Error( "Error from initializeDecays(false)" ); } - return sc; -} - -//============================================================================= -// Execute -//============================================================================= -StatusCode DecayTreeTuple::execute() { - if ( msgLevel( MSG::DEBUG ) ) debug() << "==> Execute" << endmsg; - ++m_eventCounter; - - LHCb::Particle::ConstVector heads; - bool found = false; - if ( useLoKiDecayFinders() ) { - std::copy_if( i_particles().begin(), i_particles().end(), std::back_inserter( heads ), std::cref( decayTree() ) ); - found = !heads.empty(); - } else { - const LHCb::Particle::ConstVector mothers( this->particles().begin(), this->particles().end() ); - if ( mothers.empty() ) { - setFilterPassed( false ); - return StatusCode::SUCCESS; - } - if ( msgLevel( MSG::VERBOSE ) ) verbose() << "I have " << mothers.size() << " particles to handle" << endmsg; - StatusCode test = getDecayMatches( mothers, heads ) ? StatusCode::SUCCESS : StatusCode::FAILURE; - found = test.isSuccess(); - } - if ( found ) { - if ( msgLevel( MSG::VERBOSE ) ) - verbose() << "There is " << heads.size() << " top particles matching the decay." << endmsg; - } else { - if ( msgLevel( MSG::VERBOSE ) ) verbose() << "No particle matching the decay." << endmsg; - setFilterPassed( false ); - return StatusCode::SUCCESS; - } - - // Get the default geometry FIXME, use functional framework - auto lhcb = getDet( m_standardGeometry_address ); - if ( !lhcb ) { throw GaudiException( "Could not load geometry", name(), StatusCode::FAILURE ); } - - // don't create the ntuple if there's nothing to fill! - Tuple tuple = nTuple( tupleName(), tupleName() ); - StatusCode test; - if ( useLoKiDecayFinders() ) { - test = fillTuple( tuple, heads, decayTree(), *lhcb->geometry() ); - } else { - test = fillTuple( tuple, heads, dkFinder(), *lhcb->geometry() ); - } - - if ( test.isSuccess() ) { - if ( msgLevel( MSG::VERBOSE ) ) verbose() << "NTuple sucessfully filled" << endmsg; - } - - setFilterPassed( test.isSuccess() ); - - // Mandatory. Set to true if event is accepted. - return test; -} - -//============================================================================= - -// Declaration of the Algorithm Factory -DECLARE_COMPONENT( DecayTreeTuple ) diff --git a/Phys/DecayTreeTupleBase/src/component/EventTuple.cpp b/Phys/DecayTreeTupleBase/src/component/EventTuple.cpp deleted file mode 100755 index b9f16a477324f44402c5a6f69494bfe749732e54..0000000000000000000000000000000000000000 --- a/Phys/DecayTreeTupleBase/src/component/EventTuple.cpp +++ /dev/null @@ -1,108 +0,0 @@ -/*****************************************************************************\ -* (c) Copyright 2000-2018 CERN for the benefit of the LHCb Collaboration * -* * -* This software is distributed under the terms of the GNU General Public * -* Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". * -* * -* In applying this licence, CERN does not waive the privileges and immunities * -* granted to it by virtue of its status as an Intergovernmental Organization * -* or submit itself to any jurisdiction. * -\*****************************************************************************/ -// Include files - -// from Gaudi -#include "GaudiKernel/IRegistry.h" - -#include "Kernel/IEventTupleTool.h" // Interface - -// local -#include "EventTuple.h" - -//----------------------------------------------------------------------------- -// Implementation file for class : EventTuple -// -// 2008-07-01 : Patrick Koppenburg -//----------------------------------------------------------------------------- - -// Declaration of the Algorithm Factory -DECLARE_COMPONENT( EventTuple ) - -//============================================================================= -// Standard constructor, initializes variables -//============================================================================= -EventTuple::EventTuple( const std::string& name, ISvcLocator* pSvcLocator ) : GaudiTupleAlg( name, pSvcLocator ) { - m_toolList.push_back( "TupleToolEventInfo" ); - m_collectionName = name + "/ETC"; - declareProperty( "ToolList", m_toolList, "List of tools to be used" ); - declareProperty( "TupleName", m_tupleName = "EventTuple", "Name of nTuple" ); - declareProperty( "CollectionName", m_collectionName = "", "Default is evtColPath()" ); -} -//============================================================================= -// Destructor -//============================================================================= -EventTuple::~EventTuple() {} - -//============================================================================= -// Initialization -//============================================================================= -StatusCode EventTuple::initialize() { - const StatusCode sc = GaudiTupleAlg::initialize(); - if ( sc.isFailure() ) return sc; - if ( msgLevel( MSG::DEBUG ) ) debug() << "==> Initialize" << endmsg; - - info() << "Tools to be used : "; - for ( std::vector::const_iterator s = m_toolList.begin(); s != m_toolList.end(); ++s ) { - m_tools.push_back( tool( *s, this ) ); - info() << *s << ", "; - } - info() << endmsg; - - if ( produceEvtCols() ) { - if ( m_collectionName.empty() ) { m_collectionName = evtColPath(); } - info() << "Will be writing an ETC with name " << m_collectionName << "/" << m_tupleName << endmsg; - } - - return sc; -} - -//============================================================================= -// Main execution -//============================================================================= -StatusCode EventTuple::execute() { - - if ( msgLevel( MSG::DEBUG ) ) debug() << "==> Execute" << endmsg; - ++m_eventCounter; - StatusCode sc = StatusCode::SUCCESS; - - Tuple tuple = ( produceEvtCols() ? evtCol( m_tupleName, m_collectionName ) : nTuple( m_tupleName ) ); - if ( msgLevel( MSG::VERBOSE ) ) verbose() << "Got tuple" << endmsg; - if ( produceEvtCols() ) { - // pick up the location of the event -- - // this is what makes the tag collection a collection... - DataObject* pObject = get( "/Event" ); - if ( pObject ) { - if ( msgLevel( MSG::VERBOSE ) ) verbose() << "Filling Address " << endmsg; - sc = tuple->column( "Address", pObject->registry()->address() ); - if ( !sc ) { - err() << "Error writing address" << endmsg; - return sc; - } - } else { - return Error( " not able to retrieve IOpaqueAddress" ); - } - } - - sc = tuple->column( "EventInSequence", (unsigned long long)m_eventCounter.nEntries() ); - if ( sc.isFailure() ) return sc; - - for ( std::vector::iterator i = m_tools.begin(); i != m_tools.end(); ++i ) { - if ( msgLevel( MSG::VERBOSE ) ) verbose() << "Filling " << ( *i )->name() << endmsg; - sc = ( *i )->fill( tuple ); - if ( msgLevel( MSG::VERBOSE ) ) verbose() << ( *i )->name() << " returns " << sc << endmsg; - if ( !sc ) return sc; - } - if ( msgLevel( MSG::VERBOSE ) ) verbose() << "Writing tuple" << endmsg; - return tuple->write(); -} - -//============================================================================= diff --git a/Phys/DecayTreeTupleBase/src/component/EventTuple.h b/Phys/DecayTreeTupleBase/src/component/EventTuple.h deleted file mode 100755 index e8e9f8aca60ada4aa91da6fdc5b2fa8c74822cbe..0000000000000000000000000000000000000000 --- a/Phys/DecayTreeTupleBase/src/component/EventTuple.h +++ /dev/null @@ -1,43 +0,0 @@ -/*****************************************************************************\ -* (c) Copyright 2000-2018 CERN for the benefit of the LHCb Collaboration * -* * -* This software is distributed under the terms of the GNU General Public * -* Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". * -* * -* In applying this licence, CERN does not waive the privileges and immunities * -* granted to it by virtue of its status as an Intergovernmental Organization * -* or submit itself to any jurisdiction. * -\*****************************************************************************/ -#pragma once - -#include "GaudiAlg/GaudiTupleAlg.h" - -/** @class EventTuple EventTuple.h - * - * \brief Fill event-related variables only - * - * \sa DecayTreeTuple - * - * @author Patrick Koppenburg - * @date 2008-07-01 - */ -class EventTuple : public GaudiTupleAlg { - -public: - /// Standard constructor - EventTuple( const std::string& name, ISvcLocator* pSvcLocator ); - - virtual ~EventTuple(); ///< Destructor - - StatusCode initialize() override; ///< Algorithm initialization - StatusCode execute() override; ///< Algorithm execution - -private: - std::vector m_toolList; ///< names of tools to be used - std::vector m_tools; ///< tools to be filled - std::string m_tupleName; ///< name of Tuple - /// ETC name - std::string m_collectionName; - - mutable Gaudi::Accumulators::Counter<> m_eventCounter{this, "Event"}; -}; diff --git a/Phys/DecayTreeTupleBase/src/component/MCDecayTreeTuple.cpp b/Phys/DecayTreeTupleBase/src/component/MCDecayTreeTuple.cpp deleted file mode 100644 index 658c5e79bbd9ef3706e8017131b63ec018e906d3..0000000000000000000000000000000000000000 --- a/Phys/DecayTreeTupleBase/src/component/MCDecayTreeTuple.cpp +++ /dev/null @@ -1,160 +0,0 @@ -/*****************************************************************************\ -* (c) Copyright 2000-2018 CERN for the benefit of the LHCb Collaboration * -* * -* This software is distributed under the terms of the GNU General Public * -* Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". * -* * -* In applying this licence, CERN does not waive the privileges and immunities * -* granted to it by virtue of its status as an Intergovernmental Organization * -* or submit itself to any jurisdiction. * -\*****************************************************************************/ - -#include "DecayTreeTupleBase/DecayTreeTupleBase.h" -#include "DecayTreeTupleBase/OnePart.h" - -#include "Kernel/Escape.h" - -#include "DetDesc/IDetectorElement.h" - -#include "boost/lexical_cast.hpp" - -#include -#include - -/** - * \brief This is the new version of the so-called DecayChainNTuple - * - * \section basics (Basic usage:) - * - * MCDecayTreeTuple has a decay descriptor (given by the Decay - * property). One line of the Tuple if filled for each reconstructed - * candidate. This algorithm is NOT backward compatible with - * DecayChainNTuple. Yet the base syntax is quite close. - * - * Here is a minimalist but working example: - * \verbatim - from Configurables import MCDecayTreeTuple, GaudiSequencer - MyMCDecayTreeTuple = MCDecayTreeTuple("MyMCDecayTreeTuple") - GaudiSequencer("MySeq").Members =+ [ MyMCDecayTreeTuple] - # Decay descriptor: thick arrow to take into account additional photons from PHOTOS! - MyMCDecayTreeTuple.Decay = "[ ( [B0]nos | [B~0]os ) => ^K+ ^pi-]CC" - MyMCDecayTreeTuple.TupleName = "MyTuple"\endverbatim - * - * \note Any particle to be stored in the Tuple has to be flagged with - * '^' (an exception here is the decay head which cannot be flagged as - * DecayFinder will refuse it. Top level particle are therefore always - * stored). - - * \sa DecayTreeTuple IEventTupleTool IMCParticleTupleTool - * - * \author Jeremie Borel with the help of Patrick and lhcb-davinci@cern.ch - * \date 2007-11-01 - */ -class MCDecayTreeTuple : public DecayTreeTupleBase { - -public: - MCDecayTreeTuple( const std::string& name, ISvcLocator* pSvcLocator ); - StatusCode initialize() override; - StatusCode execute() override; - -private: - mutable Gaudi::Accumulators::Counter<> m_eventCounter{this, "Event"}; -}; - -using namespace LHCb; -using namespace Gaudi; - -// Declaration of the Algorithm Factory -DECLARE_COMPONENT( MCDecayTreeTuple ) - -//============================================================================= -// Standard constructor, initializes variables -//============================================================================= -MCDecayTreeTuple::MCDecayTreeTuple( const std::string& name, ISvcLocator* pSvcLocator ) - : DecayTreeTupleBase( name, pSvcLocator ) { - // fill some default value - m_toolList.push_back( "MCTupleToolKinematic" ); - m_toolList.push_back( "TupleToolEventInfo" ); - declareProperty( "ToolList", m_toolList ); - setProperty( "TupleName", "MCDecayTree" ).ignore( /* AUTOMATICALLY ADDED FOR gaudi/Gaudi!763 */ ); -} - -//============================================================================= -// Initialization -//============================================================================= -StatusCode MCDecayTreeTuple::initialize() { - const StatusCode sc = DecayTreeTupleBase::initialize(); - if ( sc.isFailure() ) return sc; - if ( msgLevel( MSG::DEBUG ) ) debug() << "==> Initialize" << endmsg; - - info() << "Tools to be used : "; - for ( std::vector::const_iterator s = m_toolList.begin(); s != m_toolList.end(); ++s ) { - tool( *s, this ); - info() << *s << ", "; - } - info() << endmsg; - - initializeStufferTools( m_mcTools ); - - if ( sc && initializeDecays( true ) ) { - return StatusCode::SUCCESS; - } else { - return StatusCode::FAILURE; - } -} - -//============================================================================= -// Execute -//============================================================================= -StatusCode MCDecayTreeTuple::execute() { - if ( msgLevel( MSG::DEBUG ) ) debug() << "==> Execute" << endmsg; - ++m_eventCounter; - - LHCb::MCParticle::ConstVector heads; - bool found = false; - if ( useLoKiDecayFinders() ) { - const LHCb::MCParticles* mcParts = get( LHCb::MCParticleLocation::Default ); - std::copy_if( mcParts->begin(), mcParts->end(), std::back_inserter( heads ), std::cref( mcDecayTree() ) ); - found = !heads.empty(); - } else { - LHCb::MCParticle::ConstVector mothers; - const LHCb::MCParticle* head = 0; - while ( mcdkFinder()->findDecay( head ) ) { mothers.push_back( head ); } - if ( mothers.empty() ) { - if ( msgLevel( MSG::VERBOSE ) ) verbose() << "No mothers of decay " << headDecay() << " found" << endmsg; - setFilterPassed( false ); - return StatusCode::SUCCESS; - } - if ( msgLevel( MSG::VERBOSE ) ) verbose() << "I have " << mothers.size() << " particles to handle" << endmsg; - found = getDecayMatches( mothers, heads ); - } - if ( found ) { - if ( msgLevel( MSG::VERBOSE ) ) - verbose() << "There is " << heads.size() << " top particles matching the decay." << endmsg; - } else { - if ( msgLevel( MSG::VERBOSE ) ) verbose() << "No particle matching the decay." << endmsg; - setFilterPassed( false ); - return StatusCode::SUCCESS; - } - - // Get the default geometry FIXME, use functional framework - auto lhcb = getDet( m_standardGeometry_address ); - if ( !lhcb ) { throw GaudiException( "Could not load geometry", name(), StatusCode::FAILURE ); } - - // don't create the ntuple if there's nothing to fill! - Tuple tuple = nTuple( tupleName(), tupleName() ); - StatusCode test; - if ( useLoKiDecayFinders() ) { - test = fillTuple( tuple, heads, mcDecayTree(), *lhcb->geometry() ); - } else { - test = fillTuple( tuple, heads, mcdkFinder(), *lhcb->geometry() ); - } - - if ( test.isSuccess() ) { - if ( msgLevel( MSG::VERBOSE ) ) verbose() << "NTuple sucessfully filled" << endmsg; - } - - setFilterPassed( test.isSuccess() ); - // Mandatory. Set to true if event is accepted. - return test; -} diff --git a/Phys/DecayTreeTupleBase/src/component/TupleToolDecay.cpp b/Phys/DecayTreeTupleBase/src/component/TupleToolDecay.cpp deleted file mode 100644 index 4007e5598db2a30069074b3f52bb5a34521c4dc1..0000000000000000000000000000000000000000 --- a/Phys/DecayTreeTupleBase/src/component/TupleToolDecay.cpp +++ /dev/null @@ -1,132 +0,0 @@ -/*****************************************************************************\ -* (c) Copyright 2000-2018 CERN for the benefit of the LHCb Collaboration * -* * -* This software is distributed under the terms of the GNU General Public * -* Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". * -* * -* In applying this licence, CERN does not waive the privileges and immunities * -* granted to it by virtue of its status as an Intergovernmental Organization * -* or submit itself to any jurisdiction. * -\*****************************************************************************/ -// Include files - -// local -#include "TupleToolDecay.h" - -#include "LoKi/Trees.h" - -#include "GaudiAlg/Tuple.h" -#include "GaudiAlg/TupleObj.h" - -#include "GaudiKernel/Algorithm.h" - -#include - -using namespace Gaudi; -using namespace LHCb; - -//----------------------------------------------------------------------------- -// Implementation file for class : TupleTool -// -// 2007-11-02 : Jeremie Borel -//----------------------------------------------------------------------------- - -// Declaration of the Tool Factory -DECLARE_COMPONENT( TupleToolDecay ) - -//============================================================================= -// Standard constructor, initializes variables -//============================================================================= -TupleToolDecay::TupleToolDecay( const std::string& type, const std::string& name, const IInterface* parent ) - : GaudiTool( type, name, parent ) - , m_hasMatched( false ) - , m_myName( name ) - , m_dkFinder( NULL ) - , m_mcdkFinder( NULL ) - , m_isMC( false ) - , m_mcdecayTree( Decays::Trees::Invalid_() ) - , m_decayTree( Decays::Trees::Invalid_() ) { - declareInterface( this ); - declareProperty( "ToolList", m_stufferList ); - declareProperty( "InheritTools", m_inheritTools = true ); - declareProperty( "UseLoKiDecayFinders", m_useLoKiDecayFinders = true ); -} - -//============================================================================= -// Destructor -//============================================================================= -TupleToolDecay::~TupleToolDecay() {} - -//============================================================================= - -StatusCode TupleToolDecay::initializeDecay( const std::string& dcy, bool isMC ) { - if ( !GaudiTool::initialize() ) return StatusCode::FAILURE; - - m_isMC = isMC; - - if ( msgLevel( MSG::DEBUG ) ) debug() << "TupleToolDecay::initialize " << dcy << " " << isMC << endmsg; - - std::string pname; // sets the name to "ToolName" and not to "AlgoParent.ToolName" - auto alg = dynamic_cast( parent() ); - if ( alg ) pname = alg->name(); - - if ( pname.empty() ) - Warning( "Did someone change the name structure ???, your printout will not be nice..." ) - .ignore( /* AUTOMATICALLY ADDED FOR gaudi/Gaudi!763 */ ); - else { - m_myName = m_myName.substr( pname.size() + 1 ); - } - - bool test = true; - if ( m_useLoKiDecayFinders ) { - if ( m_isMC ) { - Decays::IMCDecay* mcdecaytool = tool( "LoKi::MCDecay", this ); - if ( mcdecaytool != NULL ) { m_mcdecayTree = mcdecaytool->tree( dcy ); } - test = m_mcdecayTree.valid(); - } else { - Decays::IDecay* decaytool = tool( "LoKi::Decay", this ); - if ( decaytool != NULL ) { m_decayTree = decaytool->tree( dcy ); } - test = m_decayTree.valid(); - } - } else { - if ( m_isMC ) { - m_mcdkFinder = tool( "MCDecayFinder", this ); - test &= m_mcdkFinder->setDecay( dcy ).isSuccess(); - } else { - m_dkFinder = tool( "DecayFinder", this ); - test &= m_dkFinder->setDecay( dcy ).isSuccess(); - } - } - - if ( msgLevel( MSG::DEBUG ) ) debug() << "Initialized " << name() << " with decay " << decay() << endmsg; - - std::sort( m_stufferList.begin(), m_stufferList.end() ); - m_stufferList.erase( std::unique( m_stufferList.begin(), m_stufferList.end() ), m_stufferList.end() ); - - return StatusCode( test ); -} - -//============================================================================= -// get decay -//============================================================================= -std::string TupleToolDecay::decay() const { - if ( m_useLoKiDecayFinders ) { - return ( m_isMC ? m_mcdecayTree.toString() : m_decayTree.toString() ); - } else { - return ( m_isMC ? m_mcdkFinder->decay() : m_dkFinder->decay() ); - } -} - -std::string TupleToolDecay::getInfo() const { return name() + " :" + decay(); } -void TupleToolDecay::printInfo() const { info() << getInfo() << endmsg; } - -IDecayFinder* TupleToolDecay::decayFinder() const { return m_dkFinder; } -IMCDecayFinder* TupleToolDecay::mcDecayFinder() const { return m_mcdkFinder; } - -bool TupleToolDecay::hasMatched() const { return m_hasMatched; } -void TupleToolDecay::hasMatched( bool state ) { m_hasMatched = state; } - -bool TupleToolDecay::inheritTools() const { return m_inheritTools; } - -const std::string& TupleToolDecay::getName() const { return m_myName; } -const std::vector& TupleToolDecay::getStuffers() const { return m_stufferList; } diff --git a/Phys/DecayTreeTupleBase/src/component/TupleToolDecay.h b/Phys/DecayTreeTupleBase/src/component/TupleToolDecay.h deleted file mode 100755 index 0ed5d552ce6add8a156155abcd00ed61f601ccff..0000000000000000000000000000000000000000 --- a/Phys/DecayTreeTupleBase/src/component/TupleToolDecay.h +++ /dev/null @@ -1,91 +0,0 @@ -/*****************************************************************************\ -* (c) Copyright 2000-2018 CERN for the benefit of the LHCb Collaboration * -* * -* This software is distributed under the terms of the GNU General Public * -* Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". * -* * -* In applying this licence, CERN does not waive the privileges and immunities * -* granted to it by virtue of its status as an Intergovernmental Organization * -* or submit itself to any jurisdiction. * -\*****************************************************************************/ -#ifndef JBOREL_TUPLETOOLDECAY_H -#define JBOREL_TUPLETOOLDECAY_H 1 - -// Include files -// from Gaudi -#include "GaudiAlg/GaudiTool.h" -//#include "Event/Particle.h" -//#include "Kernel/IParticleTupleTool.h" -#include "DecayTreeTupleBase/ITupleToolDecay.h" - -/** @class TupleToolDecay TupleToolDecay.h jborel/TupleToolDecay.h - * - * \brief Not really meant to be used outside DecayTreeTuple - * - * look at this later doc for more information. - * - * It has two properties: - * - * - \b ToolList, a vector of string stating which tool are associated - to this part of the decay - * - * - \b InheritTools, boolean, stating whether the tools given in the - parent DecayTreeTuple should be inherit to this part of the decay. - * - * \sa DecayTreeTuple - * - * @author Jeremie Borel - * @date 2007-11-02 - */ -class TupleToolDecay : public GaudiTool, virtual public ITupleToolDecay { - -public: - /// Standard constructor - TupleToolDecay( const std::string& type, const std::string& name, const IInterface* parent ); - - virtual ~TupleToolDecay(); ///< Destructor - - StatusCode initializeDecay( const std::string&, bool ) override; - -public: - std::string decay() const override; - - std::string getInfo() const override; - void printInfo() const override; - - IDecayFinder* decayFinder() const override; - IMCDecayFinder* mcDecayFinder() const override; - - bool useLoKiDecayFinders() const override { return m_useLoKiDecayFinders; } - const Decays::IMCDecay::iTree& mcDecayTree() const override { return m_mcdecayTree; } - const Decays::IDecay::iTree& decayTree() const override { return m_decayTree; } - - bool hasMatched() const; - void hasMatched( bool state ); - - bool inheritTools() const override; - - const std::string& getName() const override; - const std::vector& getStuffers() const override; - -private: - bool isMC() const { return m_isMC; } - -private: - bool m_hasMatched; - bool m_inheritTools; - - std::string m_myName; - - std::vector m_stufferList; - - IDecayFinder* m_dkFinder; - IMCDecayFinder* m_mcdkFinder; - bool m_isMC; - - bool m_useLoKiDecayFinders; - Decays::IMCDecay::Tree m_mcdecayTree; ///< MC truth decay tree - Decays::IDecay::Tree m_decayTree; ///< MC truth decay tree -}; - -#endif // JBOREL_TUPLETOOLDECAY_H diff --git a/Phys/DecayTreeTupleBase/src/lib/DecayTreeTupleBase.cpp b/Phys/DecayTreeTupleBase/src/lib/DecayTreeTupleBase.cpp deleted file mode 100644 index 4bea99cb8507e8672d7521bc5a84ea001cf4e441..0000000000000000000000000000000000000000 --- a/Phys/DecayTreeTupleBase/src/lib/DecayTreeTupleBase.cpp +++ /dev/null @@ -1,380 +0,0 @@ -/*****************************************************************************\ -* (c) Copyright 2000-2018 CERN for the benefit of the LHCb Collaboration * -* * -* This software is distributed under the terms of the GNU General Public * -* Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". * -* * -* In applying this licence, CERN does not waive the privileges and immunities * -* granted to it by virtue of its status as an Intergovernmental Organization * -* or submit itself to any jurisdiction. * -\*****************************************************************************/ -// Include files - -// from Gaudi -#include "DecayTreeTupleBase/DecayTreeTupleBase.h" -#include "GaudiKernel/AlgTool.h" -#include "GaudiKernel/IRegistry.h" // IOpaqueAddress -#include "GaudiKernel/SmartIF.h" -#include "Kernel/IDecayFinder.h" -#include "LoKi/Trees.h" -#include "MCInterfaces/IMCDecayFinder.h" - -//----------------------------------------------------------------------------- -// Implementation file for class : DecayTreeTupleBase -// -// 2007-11-01 : Jeremie Borel -//----------------------------------------------------------------------------- - -using namespace Gaudi; -using namespace LHCb; -//============================================================================= -// Standard constructor, initializes variables -//============================================================================= -DecayTreeTupleBase::DecayTreeTupleBase( const std::string& name, ISvcLocator* pSvcLocator ) - : DaVinciTupleAlgorithm( name, pSvcLocator ) - , m_mcdkFinder( NULL ) - , m_dkFinder( NULL ) - , m_mcdecayTree( Decays::Trees::Invalid_() ) - , m_decayTree( Decays::Trees::Invalid_() ) { - declareProperty( "TupleName", m_tupleName = "" ); - declareProperty( "Branches", m_decayMap, "Branches with other tools" ); - declareProperty( "Decay", m_headDecay, "decay descriptor" ); - declareProperty( "UseLabXSyntax", m_useLabName = false, "Use labX syntax" ); - declareProperty( "UseToolNameForBranchName", m_tupleNameAsToolName = true ); - declareProperty( "RevertToPositiveID", m_revertToPositiveID = true ); - declareProperty( "UseLoKiDecayFinders", m_useLoKiDecayFinders = true ); -} - -//============================================================================= -// Destructor -//============================================================================= -DecayTreeTupleBase::~DecayTreeTupleBase() {} - -//============================================================================= -// Initialization -//============================================================================= -StatusCode DecayTreeTupleBase::initialize() { - const StatusCode sc = DaVinciTupleAlgorithm::initialize(); - if ( sc.isFailure() ) return sc; - - if ( msgLevel( MSG::DEBUG ) ) debug() << "==> Initialize" << endmsg; - if ( m_useLabName && m_revertToPositiveID ) { - m_revertToPositiveID = false; - return Warning( "UseLabXSyntax and RevertToPositiveID are exclusive. Switched off reverting." ); - } - return sc; -} - -//============================================================================= -// Main execution -//============================================================================= -StatusCode DecayTreeTupleBase::execute() { - err() << "==> Do not call DecayTreeTupleBase::Execute" << endmsg; - return StatusCode::FAILURE; -} - -//============================================================================= -// Finalize -//============================================================================= -StatusCode DecayTreeTupleBase::finalize() { - if ( msgLevel( MSG::DEBUG ) ) debug() << "==> Finalize" << endmsg; - // the DecayTools are explicitly initialized, and should be explicitly finalized/released - for ( std::vector::iterator di = m_decays.begin(); di != m_decays.end(); ++di ) { - ( *di )->finalize().ignore( /* AUTOMATICALLY ADDED FOR gaudi/Gaudi!763 */ ); - //(*di)->release(); - } - return DaVinciTupleAlgorithm::finalize(); -} - -//============================================================================= -//============================================================================= -bool DecayTreeTupleBase::initializeDecays( const bool isMC ) { - // main decay initialization - - if ( useLoKiDecayFinders() ) { - if ( isMC ) { - Decays::IMCDecay* mcdecaytool = tool( "LoKi::MCDecay", this ); - if ( !mcdecaytool ) { - Error( "Could not retrieve MC-decay finder" ).ignore(); - return false; - } - m_mcdecayTree = mcdecaytool->tree( m_headDecay ); - if ( !m_mcdecayTree ) { - Error( "Unable to decode/parse MC-decay descriptor '" + m_headDecay + "'." ).ignore(); - return false; - } - info() << "Will look for " << m_mcdecayTree << endmsg; - } else { - Decays::IDecay* decaytool = tool( "LoKi::Decay", this ); - if ( !decaytool ) { - Error( "Could not retrieve decay finder" ).ignore(); - return false; - } - m_decayTree = decaytool->tree( m_headDecay ); - if ( !m_decayTree ) { - Error( "Unable to decode/parse decay descriptor '" + m_headDecay + "'." ).ignore(); - return false; - } - info() << "Will look for " << m_decayTree << endmsg; - } - } else { - if ( isMC ) { - m_mcdkFinder = tool( "MCDecayFinder", this ); - if ( !m_mcdkFinder->setDecay( m_headDecay ) ) { - Error( "Cannot initialize the main decay '" + m_headDecay + "' properly." ).ignore(); - return false; - } - info() << "Will look for " << m_mcdkFinder->decay() << endmsg; - } else { - m_dkFinder = tool( "DecayFinder", this ); - if ( !m_dkFinder->setDecay( m_headDecay ) ) { - Error( "Cannot initialize the main decay '" + m_headDecay + "' properly." ).ignore(); - return false; - } - info() << "Will look for " << m_dkFinder->decay() << endmsg; - } - } - - // sub-decays initialization (if any) - m_decays.reserve( m_decayMap.size() ); - std::map::iterator mit; - for ( mit = m_decayMap.begin(); m_decayMap.end() != mit; ++mit ) { - if ( msgLevel( MSG::DEBUG ) ) debug() << "Try now to instanciate " << mit->first << endmsg; - ITupleToolDecay* m = tool( "TupleToolDecay", mit->first, this ); - if ( !Gaudi::Utils::setProperty( m, "UseLoKiDecayFinders", useLoKiDecayFinders() ) ) { - Error( "Failed to set tool property 'UseLoKiDecayFinders'" ).ignore(); - return false; - } - if ( !m->initializeDecay( mit->second, isMC ) ) { - Error( "Cannot initialize '" + mit->first + "' branch properly, skipping it." ).ignore(); - continue; - } - m_decays.push_back( m ); - } - - if ( !m_decays.empty() ) { - info() << "Explicit sub decays :" << m_decays.size() << endmsg; - for ( std::vector::const_iterator di = m_decays.begin(); di != m_decays.end(); ++di ) { - ( *di )->printInfo(); - } - } else { - if ( msgLevel( MSG::DEBUG ) ) debug() << "No sub decay to create" << endmsg; - } - return true; -} -//============================================================================= -//============================================================================= -std::vector DecayTreeTupleBase::getEventTools() const { - std::vector ret; - ret.reserve( m_eTools.size() ); - for ( std::vector::const_iterator it = m_eTools.begin(); m_eTools.end() != it; ++it ) { - ret.push_back( ( *it )->type() ); - } - return ret; -} -//============================================================================= -//============================================================================= -// get daughters -LHCb::MCParticle::ConstVector DecayTreeTupleBase::daughtersVector( const LHCb::MCParticle* d ) const { - if ( !d ) Exception( "NULL MCParticle" ); - LHCb::MCParticle::ConstVector dau; - for ( SmartRefVector::const_iterator v = d->endVertices().begin(); v != d->endVertices().end(); - ++v ) { - if ( ( *v )->isDecay() ) { - for ( SmartRefVector::const_iterator p = ( *v )->products().begin(); - p != ( *v )->products().end(); ++p ) { - dau.push_back( *p ); - } - } - } - if ( msgLevel( MSG::VERBOSE ) ) verbose() << d->particleID().pid() << " has " << dau.size() << " daughters" << endmsg; - return dau; -} -//============================================================================= -//============================================================================= -StatusCode DecayTreeTupleBase::fillEventRelatedVariables( Tuples::Tuple& tuple ) { - if ( !m_eTools.empty() ) { - for ( std::vector::iterator it = m_eTools.begin(); m_eTools.end() != it; ++it ) { - if ( !( *it )->fill( tuple ) ) return StatusCode::FAILURE; - } - return StatusCode::SUCCESS; - } - return StatusCode::SUCCESS; -} -//========================================================================= -// Check unicity of names -//========================================================================= -bool DecayTreeTupleBase::checkUnicity() const { - // check the name unicity - std::set names; - for ( std::vector::const_iterator iP = m_parts.begin(); iP != m_parts.end(); ++iP ) { - const std::string n = ( *iP )->headName(); - if ( names.count( n ) > 0 ) { - Error( "You are using two times the name " + n + " for your tuple branches." ).ignore(); - return false; - } - } - return true; -} -//========================================================================= -// print infos -//========================================================================= -void DecayTreeTupleBase::printInfos() const { - info() << "Tree " << m_tupleName << " initialized :-" << endmsg; - - info() << " Event related tools : " << getEventTools() << endmsg; - - info() << " Particle related stuffers :- " << endmsg; - for ( std::vector::const_iterator iP = m_parts.begin(); iP != m_parts.end(); ++iP ) { - if ( !( *iP )->getMother() ) { ( *iP )->printStructure( info(), msgLevel( MSG::INFO ) ); } - } -} -// =============================================================== -// this is where all the difference between MC particle and Particle occurs -void DecayTreeTupleBase::matchSubDecays( const Particle::ConstVector& row, Particle::ConstVector& buffer, - const ITupleToolDecay* mit ) { - if ( !mit ) Exception( "DecayTreeTupleBase::matchSubDecays ITupleToolDecay undefined" ); - - if ( mit->useLoKiDecayFinders() ? ( !mit->decayTree() ) : ( !mit->decayFinder() ) ) - Exception( "DecayTreeTupleBase::matchSubDecays ITupleToolDecay DecayFinder or DecayTree undefined" ); - - if ( !row[0] ) Exception( "DecayTreeTupleBase::matchSubDecays DecayTreeTupleBase::Null Particle" ); - - const Particle* head = row[0]; - if ( msgLevel( MSG::VERBOSE ) ) verbose() << "Match subdecay for Particle " << head->particleID().pid() << endmsg; - if ( mit->useLoKiDecayFinders() ) { - const Decays::IDecay::iTree& tree = mit->decayTree(); - if ( tree( head ) ) { - if ( tree.marked() ) { - tree.collect( buffer ); - } else { - buffer.push_back( head ); - } - } - } else { - mit->decayFinder()->decayMembers( head, buffer ); - } - if ( msgLevel( MSG::VERBOSE ) ) - verbose() << "Decay finder gets " << buffer.size() << " particles for " << mit->decay() << endmsg; - findAssociatedOneParts( buffer, row, mit, m_pTools ); -} -// =============================================================== -// this is where all the difference between MC particle and Particle occurs -void DecayTreeTupleBase::matchSubDecays( const MCParticle::ConstVector& row, MCParticle::ConstVector& buffer, - const ITupleToolDecay* mit ) { - if ( !mit ) Exception( "DecayTreeTupleBase::matchSubDecays ITupleToolDecay undefined" ); - - if ( mit->useLoKiDecayFinders() ? ( !mit->mcDecayTree() ) : ( !mit->mcDecayFinder() ) ) - Exception( "DecayTreeTupleBase::matchSubDecays ITupleToolDecay MCDecayFinder undefined" ); - - if ( !row[0] ) Exception( "DecayTreeTupleBase::matchSubDecays DecayTreeTupleBase::Null MC Particle" ); - - const MCParticle* head = row[0]; - if ( msgLevel( MSG::VERBOSE ) ) verbose() << "Match subdecay for MCParticle " << head->particleID().pid() << endmsg; - if ( mit->useLoKiDecayFinders() ) { - const Decays::IMCDecay::iTree& tree = mit->mcDecayTree(); - if ( tree( head ) ) { - if ( tree.marked() ) { - tree.collect( buffer ); - } else { - buffer.push_back( head ); - } - } - } else { - mit->mcDecayFinder()->decayMembers( head, buffer ); - } - if ( msgLevel( MSG::VERBOSE ) ) - verbose() << "Decay finder gets " << buffer.size() << " mc particles for " << mit->decay() << endmsg; - // this is the cause of all the difference between MC particle and Particle occurs - findAssociatedOneParts( buffer, row, mit, m_mcTools ); - if ( msgLevel( MSG::VERBOSE ) ) verbose() << "Looked for associated Parts " << endmsg; -} -//============================================================================= -// Moved from OnePart -//============================================================================= -bool DecayTreeTupleBase::fillOnePart( Decays::OnePart* op, Tuples::Tuple& tuple, const Particle* mother, - const Particle* pp, IGeometryInfo const& geometry ) { - bool test = true; - if ( msgLevel( MSG::DEBUG ) ) debug() << "FillOnePart " << pp->particleID().pid() << endmsg; - for ( std::vector::iterator it = op->tools().begin(); op->tools().end() != it; ++it ) { - if ( msgLevel( MSG::DEBUG ) ) - debug() << "FillOnePart " << pp->particleID().pid() << " in " << ( *it )->type() << endmsg; - if ( msgLevel( MSG::VERBOSE ) ) verbose() << "FillOnePart " << mother << " " << op->headName() << endmsg; - const bool localTest = ( *it )->fill( mother, pp, op->headName(), tuple, geometry ).isSuccess(); - test &= localTest; - if ( !localTest ) { - fatal() << "Tool '" << ( *it )->type() << "' acting on particle '" << op->headName() - << "' returned a failure status." << endmsg; - return false; - } - } - return test; -} -//============================================================================= -// Same for MCParticle (cannot template trivially because of IParticleTupleTool) -//============================================================================= -bool DecayTreeTupleBase::fillOnePart( Decays::OnePart* op, Tuples::Tuple& tuple, const MCParticle* mother, - const MCParticle* pp, IGeometryInfo const& ) { - bool test = true; - if ( msgLevel( MSG::DEBUG ) ) - debug() << "FillOnePart MC " << pp->particleID().pid() << " " << op->headName() << endmsg; - for ( std::vector::iterator it = op->mctools().begin(); op->mctools().end() != it; ++it ) { - if ( msgLevel( MSG::DEBUG ) ) - debug() << "FillOnePart MC " << pp->particleID().pid() << " in " << ( *it )->type() << endmsg; - const bool localTest = ( *it )->fill( mother, pp, op->headName(), tuple ).isSuccess(); - test &= localTest; - if ( !localTest ) { - Warning( "Tool '" + ( *it )->type() + "' acting on particle '" + op->headName() + "' returned a failure status." ) - .ignore(); - } - } - return test; -} -//============================================================================= -bool DecayTreeTupleBase::getDecayMatches( const Particle::ConstVector& pool, Particle::ConstVector& heads ) { - const Particle* head( 0 ); - while ( m_dkFinder->findDecay( pool, head ) ) { - if ( !head ) { - Error( "Cannot find head of decay", StatusCode::FAILURE, 1 ).ignore(); - return false; - } - heads.push_back( head ); - } - return !( heads.empty() ); -} - -//============================================================================= - -bool DecayTreeTupleBase::getDecayMatches( const MCParticle::ConstVector& pool, MCParticle::ConstVector& heads ) { - const MCParticle* head( 0 ); - while ( m_mcdkFinder->findDecay( pool, head ) ) { heads.push_back( head ); } - return !( heads.empty() ); -} - -// ============================================================================ - -// Get branch name for given particle -std::string DecayTreeTupleBase::getBranchName( const std::string& realname ) const { - if ( m_useLabName ) { return ( std::string( "lab" ) + boost::lexical_cast( m_parts.size() ) ); } - - std::string name = Decays::escape( realname ), buffer = name; - - // check that it is not yet used, if yes, append a number until not used. - bool flag = false; - int kk = 0; - do { - flag = false; - for ( std::vector::const_iterator iP = m_parts.begin(); iP != m_parts.end(); ++iP ) { - if ( buffer == ( *iP )->headName() ) { - flag = true; - break; - } - } - if ( !flag ) break; - buffer = name + boost::lexical_cast( kk ); - ++kk; - } while ( kk < 100 ); // for security. - return buffer; -} - -// ============================================================================ diff --git a/Phys/DecayTreeTupleBase/src/lib/OnePart.cpp b/Phys/DecayTreeTupleBase/src/lib/OnePart.cpp deleted file mode 100644 index 9473c46044aa070309459cda4a1fc9914357d2fc..0000000000000000000000000000000000000000 --- a/Phys/DecayTreeTupleBase/src/lib/OnePart.cpp +++ /dev/null @@ -1,81 +0,0 @@ -/*****************************************************************************\ -* (c) Copyright 2000-2018 CERN for the benefit of the LHCb Collaboration * -* * -* This software is distributed under the terms of the GNU General Public * -* Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". * -* * -* In applying this licence, CERN does not waive the privileges and immunities * -* granted to it by virtue of its status as an Intergovernmental Organization * -* or submit itself to any jurisdiction. * -\*****************************************************************************/ -// Include files - -#include "Kernel/IMCParticleTupleTool.h" -#include "Kernel/IParticleTupleTool.h" -// local -#include "DecayTreeTupleBase/OnePart.h" - -using namespace LHCb; -//----------------------------------------------------------------------------- -// Implementation file for class : OnePart -// -// 2009-01-20 : Patrick Koppenburg -//----------------------------------------------------------------------------- -Decays::OnePart::OnePart( const std::string& realname, const std::string& head ) - : m_head( head ), m_realname( realname ), m_mother( 0 ) {} -// ----------------------------------------------------- -std::string Decays::OnePart::headName() { return m_head; } -void Decays::OnePart::headName( const std::string& h ) { m_head = h; } -std::string Decays::OnePart::getRealName() { return m_realname; } -const std::string& Decays::OnePart::getRealName() const { return m_realname; } -std::string Decays::OnePart::info() const { return m_realname + " (" + m_head + ")"; } -void Decays::OnePart::setMother( const OnePart* mother ) { m_mother = mother; } -const Decays::OnePart* Decays::OnePart::getMother() const { return m_mother; } -void Decays::OnePart::addDaughter( OnePart* d ) { m_daughters.push_back( d ); } -int Decays::OnePart::depth() const { - if ( m_mother ) return m_mother->depth() + 1; - return 0; -} -// ----------------------------------------------------- -void Decays::OnePart::addTool( IParticleTupleTool* tool ) { m_tools.push_back( tool ); } -void Decays::OnePart::addTool( IMCParticleTupleTool* tool ) { m_mctools.push_back( tool ); } -std::vector& Decays::OnePart::tools() { return m_tools; } -std::vector& Decays::OnePart::mctools() { return m_mctools; } -void Decays::OnePart::clearTools() { - m_tools.clear(); - m_mctools.clear(); -} -std::vector Decays::OnePart::toolList() const { - std::vector v; - v.reserve( m_tools.size() ); - for ( std::vector::const_iterator it = m_tools.begin(); m_tools.end() != it; ++it ) { - v.push_back( ( *it )->type() ); - } - return v; -} -std::vector Decays::OnePart::mctoolList() const { - std::vector v; - v.reserve( m_mctools.size() ); - for ( std::vector::const_iterator it = m_mctools.begin(); m_mctools.end() != it; ++it ) { - v.push_back( ( *it )->type() ); - } - return v; -} -// ----------------------------------------------------- -void Decays::OnePart::printStructure( MsgStream& os, bool verbose ) const { - const int dd = depth(); - std::string i; - if ( dd ) i = std::string( 3 * dd, ' ' ); - i.append( info() ); - if ( !verbose ) { - os << i << endmsg; - } else { - std::vector l = toolList(); - os << " " << i << std::setw( 30 - i.size() ) << " : "; - os << Decays::join( l.begin(), l.end(), ", ", "none" ) << endmsg; - } - if ( m_daughters.empty() ) return; - for ( std::vector::const_iterator cit = m_daughters.begin(); cit != m_daughters.end(); ++cit ) { - ( *cit )->printStructure( os, verbose ); - } -} diff --git a/Phys/DecayTreeTupleDalitz/CMakeLists.txt b/Phys/DecayTreeTupleDalitz/CMakeLists.txt deleted file mode 100644 index 720a70d7526447372463e846bdb29f54d0bc26f8..0000000000000000000000000000000000000000 --- a/Phys/DecayTreeTupleDalitz/CMakeLists.txt +++ /dev/null @@ -1,30 +0,0 @@ -############################################################################### -# (c) Copyright 2000-2021 CERN for the benefit of the LHCb Collaboration # -# # -# This software is distributed under the terms of the GNU General Public # -# Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". # -# # -# In applying this licence, CERN does not waive the privileges and immunities # -# granted to it by virtue of its status as an Intergovernmental Organization # -# or submit itself to any jurisdiction. # -############################################################################### -#[=======================================================================[.rst: -Phys/DecayTreeTupleDalitz -------------------------- -#]=======================================================================] - -gaudi_add_module(DecayTreeTupleDalitz - SOURCES - src/MCTupleToolDalitz.cpp - src/TupleToolDalitz.cpp - LINK - Analysis::DecayTreeTupleBaseLib - Boost::headers - Gaudi::GaudiAlgLib - LHCb::MCEvent - LHCb::PartPropLib - LHCb::PhysEvent - Phys::DaVinciInterfacesLib - Phys::DaVinciKernelLib - Phys::DaVinciMCKernelLib -) diff --git a/Phys/DecayTreeTupleDalitz/doc/release.notes b/Phys/DecayTreeTupleDalitz/doc/release.notes deleted file mode 100644 index d1c2f59e89ce4c6a61c02afad7ebe8b67b6214b1..0000000000000000000000000000000000000000 --- a/Phys/DecayTreeTupleDalitz/doc/release.notes +++ /dev/null @@ -1,38 +0,0 @@ -!----------------------------------------------------------------------------- -! Package : Phys/DecayTreeTupleDalitz -! Responsible : Chris Jones -! Purpose : Dalitz tools -!----------------------------------------------------------------------------- - -!=================== DecayTreeTupleDalitz v1r3 2015-04-22 ==================== - - 2015-03-23 - O. Deschamps - - reduce verbosity and fix compilation error - - 2015-03-15 - O. Deschamps - - make the branch name CC-independant - -!=================== DecayTreeTupleDalitz v1r2 2015-02-26 ==================== - -! 2015-02-24 - O. Deschamps - - fix problem with Dalitz variable naming when daughter vector has not a constant order (stable::sort by PID) - -!========================= DecayTreeTupleDalitz v1r1p1 2014-04-02 ========================= - -! 2014-04-02 - Chris Jones - - Minor code cleanup. - -!========================= DecayTreeTupleDalitz v1r1 2013-12-18 ========================= - -! 2013-11-18 - Chris Jones - - Fix a bug in setting the prefix name properly. - - Try and fix a issue when the tool is wrong on Wrong Sign decays ... - -!========================= DecayTreeTupleDalitz v1r0 2012-11-30 ========================= - -! 2012-11-29 - Marco Clemencic - - Added CMake configuration file. - -! 2012-11-22 - Chris Jones - - First version. Split of from monolithic Phys/DecayTreeTuple package. - Contains the 'Dalitz' tools, that share code. diff --git a/Phys/DecayTreeTupleDalitz/src/MCTupleToolDalitz.cpp b/Phys/DecayTreeTupleDalitz/src/MCTupleToolDalitz.cpp deleted file mode 100644 index 4b9432e376abd411b5d076785dd5c5f3afdb3a9b..0000000000000000000000000000000000000000 --- a/Phys/DecayTreeTupleDalitz/src/MCTupleToolDalitz.cpp +++ /dev/null @@ -1,71 +0,0 @@ -/*****************************************************************************\ -* (c) Copyright 2000-2018 CERN for the benefit of the LHCb Collaboration * -* * -* This software is distributed under the terms of the GNU General Public * -* Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". * -* * -* In applying this licence, CERN does not waive the privileges and immunities * -* granted to it by virtue of its status as an Intergovernmental Organization * -* or submit itself to any jurisdiction. * -\*****************************************************************************/ -// Include files - -#include -#include - -// local -#include "MCTupleToolDalitz.h" - -//----------------------------------------------------------------------------- -// Implementation file for class : MCTupleToolDalitz -// -// 2009-02-17 : Patrick Koppenburg -//----------------------------------------------------------------------------- - -// Declaration of the Tool Factory -DECLARE_COMPONENT( MCTupleToolDalitz ) - -//============================================================================= -// Standard constructor, initializes variables -//============================================================================= -MCTupleToolDalitz::MCTupleToolDalitz( const std::string& type, const std::string& name, const IInterface* parent ) - : TupleToolBase( type, name, parent ), m_ppSvc( 0 ) { - declareInterface( this ); -} -//============================================================================= -// Destructor -//============================================================================= -MCTupleToolDalitz::~MCTupleToolDalitz() {} - -//============================================================================= -//============================================================================= -// Fill -//============================================================================= -StatusCode MCTupleToolDalitz::fill( const LHCb::MCParticle* mother, const LHCb::MCParticle* part, - const std::string& head, Tuples::Tuple& tuple ) { - const std::string prefix = fullName( head ); - - if ( 0 == part ) return StatusCode::FAILURE; - if ( msgLevel( MSG::DEBUG ) ) - debug() << "Decay of " << part->particleID().pid() << " with mother " << mother << endmsg; - LHCb::MCParticle::ConstVector dauts; - for ( SmartRefVector::const_iterator iv = part->endVertices().begin(); - iv != part->endVertices().end(); ++iv ) { - if ( !( *iv )->isDecay() ) continue; - if ( msgLevel( MSG::VERBOSE ) ) - verbose() << "Decay vertex of type " << ( *iv )->type() << " with " << ( *iv )->products().size() << " products" - << endmsg; - const SmartRefVector pr = ( *iv )->products(); - for ( SmartRefVector::const_iterator ip = pr.begin(); ip != pr.end(); ++ip ) { - if ( msgLevel( MSG::VERBOSE ) ) verbose() << "Pushing back " << ( *ip )->particleID().pid() << endmsg; - dauts.push_back( *ip ); - } - break; - } - - if ( 2 >= dauts.size() ) { - return Warning( "Will not fill Dalitz of two body decay " + prefix, StatusCode::SUCCESS, 0 ); - } - - return fill( dauts, "MC", tuple, ( part->particleID().pid() < 0 ) ); -} diff --git a/Phys/DecayTreeTupleDalitz/src/MCTupleToolDalitz.h b/Phys/DecayTreeTupleDalitz/src/MCTupleToolDalitz.h deleted file mode 100644 index 4170b1e0fcc183d96c3ff9df05412a5e1195c988..0000000000000000000000000000000000000000 --- a/Phys/DecayTreeTupleDalitz/src/MCTupleToolDalitz.h +++ /dev/null @@ -1,50 +0,0 @@ -/*****************************************************************************\ -* (c) Copyright 2000-2018 CERN for the benefit of the LHCb Collaboration * -* * -* This software is distributed under the terms of the GNU General Public * -* Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". * -* * -* In applying this licence, CERN does not waive the privileges and immunities * -* granted to it by virtue of its status as an Intergovernmental Organization * -* or submit itself to any jurisdiction. * -\*****************************************************************************/ -#ifndef MCTUPLETOOLDALITZ_H -#define MCTUPLETOOLDALITZ_H 1 - -// Include files -// from Gaudi -#include "DecayTreeTupleBase/TupleToolBase.h" -#include "Event/MCParticle.h" -#include "GaudiAlg/Tuple.h" -#include "GaudiAlg/TupleObj.h" -#include "Kernel/Escape.h" -#include "Kernel/IMCParticleTupleTool.h" -#include "Kernel/IParticlePropertySvc.h" -#include "Kernel/ParticleProperty.h" - -// Boost -#include - -/** @class MCTupleToolDalitz MCTupleToolDalitz.h - * - * Fills square masses of all combinations of direct daughters - * - * @author Patrick Koppenburg - * @date 2009-02-17 - */ -class MCTupleToolDalitz : public TupleToolBase, virtual public IMCParticleTupleTool { - -public: - /// Standard constructor - MCTupleToolDalitz( const std::string& type, const std::string& name, const IInterface* parent ); - - virtual ~MCTupleToolDalitz(); ///< Destructor - - /// The filling method - StatusCode fill( const LHCb::MCParticle*, const LHCb::MCParticle*, const std::string&, Tuples::Tuple& ) override; - -private: - // Horrid way of sharing code. Should use inheritance instead ... -#include "TupleToolDalitz.icpp" -}; -#endif // MCTUPLETOOLDALITZ_H diff --git a/Phys/DecayTreeTupleDalitz/src/TupleToolDalitz.cpp b/Phys/DecayTreeTupleDalitz/src/TupleToolDalitz.cpp deleted file mode 100644 index bcec1d4d023071984e2badcdfa13a67cab185c3b..0000000000000000000000000000000000000000 --- a/Phys/DecayTreeTupleDalitz/src/TupleToolDalitz.cpp +++ /dev/null @@ -1,52 +0,0 @@ -/*****************************************************************************\ -* (c) Copyright 2000-2018 CERN for the benefit of the LHCb Collaboration * -* * -* This software is distributed under the terms of the GNU General Public * -* Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". * -* * -* In applying this licence, CERN does not waive the privileges and immunities * -* granted to it by virtue of its status as an Intergovernmental Organization * -* or submit itself to any jurisdiction. * -\*****************************************************************************/ -#include "Event/Particle.h" - -#include "TupleToolDalitz.h" - -//----------------------------------------------------------------------------- -// Implementation file for class : TupleToolDalitz -// -// 2009-02-17 : Patrick Koppenburg -//----------------------------------------------------------------------------- - -// Declaration of the Tool Factory -DECLARE_COMPONENT( TupleToolDalitz ) - -//============================================================================= -// Standard constructor, initializes variables -//============================================================================= -TupleToolDalitz::TupleToolDalitz( const std::string& type, const std::string& name, const IInterface* parent ) - : TupleToolBase( type, name, parent ), m_ppSvc( 0 ) { - declareInterface( this ); -} - -//============================================================================= -// Fill -//============================================================================= -StatusCode TupleToolDalitz::fill( const LHCb::Particle* mother, const LHCb::Particle* part, const std::string& head, - Tuples::Tuple& tuple, IGeometryInfo const& ) { - const std::string prefix = fullName( head ); - - if ( msgLevel( MSG::VERBOSE ) ) verbose() << "Dalitz fill " << prefix << " " << mother << " " << part << endmsg; - if ( 0 == part ) return StatusCode::FAILURE; - const LHCb::Particle::ConstVector& dauts = part->daughtersVector(); - if ( 2 >= dauts.size() ) { - debug() << "Will not fill Dalitz of two body decay " << prefix << endmsg; - return StatusCode::SUCCESS; - } - if ( part->particleID().abspid() == 98 ) { - debug() << "Will not fill Dalitz for particle type CELLjet " << endmsg; - return StatusCode::SUCCESS; - } - - return fill( dauts, head, tuple, ( part->particleID().pid() < 0 ) ); -} diff --git a/Phys/DecayTreeTupleDalitz/src/TupleToolDalitz.h b/Phys/DecayTreeTupleDalitz/src/TupleToolDalitz.h deleted file mode 100644 index a0e34835e50d8d2188f49d955149169fb6dc9b06..0000000000000000000000000000000000000000 --- a/Phys/DecayTreeTupleDalitz/src/TupleToolDalitz.h +++ /dev/null @@ -1,43 +0,0 @@ -/*****************************************************************************\ -* (c) Copyright 2000-2018 CERN for the benefit of the LHCb Collaboration * -* * -* This software is distributed under the terms of the GNU General Public * -* Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". * -* * -* In applying this licence, CERN does not waive the privileges and immunities * -* granted to it by virtue of its status as an Intergovernmental Organization * -* or submit itself to any jurisdiction. * -\*****************************************************************************/ -#pragma once - -// Include files -// from Gaudi -#include "DecayTreeTupleBase/TupleToolBase.h" -#include "Event/Particle.h" -#include "GaudiAlg/Tuple.h" -#include "GaudiAlg/TupleObj.h" -#include "Kernel/Escape.h" -#include "Kernel/IParticlePropertySvc.h" -#include "Kernel/IParticleTupleTool.h" -#include "Kernel/ParticleProperty.h" -// Boost -#include - -/** @class TupleToolDalitz TupleToolDalitz.h - * - * Fills square masses of all combinations of direct daughters - * - * @author Patrick Koppenburg - * @date 2009-02-17 - */ -class TupleToolDalitz : public TupleToolBase, virtual public IParticleTupleTool { - -public: - TupleToolDalitz( const std::string& type, const std::string& name, const IInterface* parent ); - StatusCode fill( const LHCb::Particle*, const LHCb::Particle*, const std::string&, Tuples::Tuple&, - IGeometryInfo const& ) override; - -private: - // Horrid way of sharing code. Should use inheritance instead ... -#include "TupleToolDalitz.icpp" -}; diff --git a/Phys/DecayTreeTupleDalitz/src/TupleToolDalitz.icpp b/Phys/DecayTreeTupleDalitz/src/TupleToolDalitz.icpp deleted file mode 100644 index b37b62cec16be3e8ccec032e65467ee95dd0600a..0000000000000000000000000000000000000000 --- a/Phys/DecayTreeTupleDalitz/src/TupleToolDalitz.icpp +++ /dev/null @@ -1,86 +0,0 @@ -/*****************************************************************************\ -* (c) Copyright 2000-2018 CERN for the benefit of the LHCb Collaboration * -* * -* This software is distributed under the terms of the GNU General Public * -* Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". * -* * -* In applying this licence, CERN does not waive the privileges and immunities * -* granted to it by virtue of its status as an Intergovernmental Organization * -* or submit itself to any jurisdiction. * -\*****************************************************************************/ - -private: -//============================================================================= -// The templated method filling the tuple for Particles and MCParticles -//============================================================================= -/// The templated method that does it all -template -StatusCode fill( const std::vector& dauts /// daughters - , - const std::string& head /// header - , - Tuples::Tuple& tuple /// tuple - , - bool revert ) /// revert all PID (because mother is antiparticle) -{ - - const std::string prefix = fullName( head ); - bool test = true; - // sort out daughters vector - std::vector daughters( dauts ); // local copies to sort - const LHCb::IParticlePropertySvc* pp = ppSvc(); - std::stable_sort( daughters.begin(), daughters.end(), [revert, pp]( const TYPE* c1, const TYPE* c2 ) { - int sign = ( revert ) ? -1 : 1; - int p1 = ( pp->find( c1->particleID() )->selfcc() ) ? c1->particleID().pid() : sign * c1->particleID().pid(); - int p2 = ( pp->find( c2->particleID() )->selfcc() ) ? c2->particleID().pid() : sign * c2->particleID().pid(); - bool comp = std::make_pair( p1, c1->key() ) > std::make_pair( p2, c2->key() ); - return comp; - } ); - std::map used; - - for ( typename std::vector::const_iterator i = daughters.begin(); i != daughters.end(); ++i ) { - const std::string n1 = particleName( ( *i )->particleID(), revert ); - const Gaudi::LorentzVector& p1 = ( *i )->momentum(); - for ( typename std::vector::const_iterator j = daughters.begin(); i != j; ++j ) { - const std::string n2 = particleName( ( *j )->particleID(), revert ); - const Gaudi::LorentzVector p = p1 + ( *j )->momentum(); - const std::string basename = prefix + "_Dalitz_" + n1 + "_" + n2 + "_M2"; - std::string name = basename; - if ( used.find( basename ) != used.end() ) { - unsigned int add = used[basename]; - name = basename + "_" + boost::lexical_cast( add ); - used[basename] = add + 1; - Info( "Renaming duplicate to " + name, StatusCode::SUCCESS, 1 ) - .ignore( /* AUTOMATICALLY ADDED FOR gaudi/Gaudi!763 */ ); - } else { - used[basename] = 1; - } - test &= tuple->column( name, p.M2() ); - } - } - return StatusCode( test ); -} - -/// get name of particle or anti-particle -std::string particleName( const LHCb::ParticleID& id, bool revert ) const { - const LHCb::ParticleProperty* ppp = ppSvc()->find( id ); - if ( !ppp ) { - std::ostringstream mess; - mess << "Unknown ParticleID " << id; - Exception( mess.str() ); - } - return Decays::escape( ( revert ? ppp->antiParticle()->particle() : ppp->particle() ) ); -} - -/// get particle property serivce -const LHCb::IParticlePropertySvc* ppSvc() const { return m_ppSvc; } - -public: -StatusCode initialize() override { - const StatusCode sc = TupleToolBase::initialize(); - if ( sc.isSuccess() ) { m_ppSvc = svc( "LHCb::ParticlePropertySvc", true ); } - return sc; -} - -private: -LHCb::IParticlePropertySvc* m_ppSvc; diff --git a/Phys/DecayTreeTupleHerschel/CMakeLists.txt b/Phys/DecayTreeTupleHerschel/CMakeLists.txt deleted file mode 100644 index d83e0359699fc385ab419c65a5845684b0745be2..0000000000000000000000000000000000000000 --- a/Phys/DecayTreeTupleHerschel/CMakeLists.txt +++ /dev/null @@ -1,25 +0,0 @@ -############################################################################### -# (c) Copyright 2000-2021 CERN for the benefit of the LHCb Collaboration # -# # -# This software is distributed under the terms of the GNU General Public # -# Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". # -# # -# In applying this licence, CERN does not waive the privileges and immunities # -# granted to it by virtue of its status as an Intergovernmental Organization # -# or submit itself to any jurisdiction. # -############################################################################### -#[=======================================================================[.rst: -Phys/DecayTreeTupleHerschel ---------------------------- -#]=======================================================================] - -gaudi_add_module(DecayTreeTupleHerschel - SOURCES - src/TupleToolHerschel.cpp - LINK - Analysis::DecayTreeTupleBaseLib - LHCb::DAQEventLib - LHCb::DetDescLib - LHCb::DigiEvent - LHCb::LHCbKernel -) diff --git a/Phys/DecayTreeTupleHerschel/doc/release.notes b/Phys/DecayTreeTupleHerschel/doc/release.notes deleted file mode 100644 index 3ebe37c42ff32789d0a63253ce2e4c7479c580a8..0000000000000000000000000000000000000000 --- a/Phys/DecayTreeTupleHerschel/doc/release.notes +++ /dev/null @@ -1,29 +0,0 @@ -!----------------------------------------------------------------------------- -! Package : Phys/DecayTreeTupleHerschel -! Responsible : Dan Johnson -! Purpose : Tools for Herschel -!----------------------------------------------------------------------------- - -!================= DecayTreeTupleHerschel v1r2 2015-12-03 ==================== - -! 2015-12-03 - Dan Johnson - - Small improvements (no rush to release) - * Remove #include of ToolFactory.h - * Move warning about CorrectedDigits to initialize to avoid large logfiles - -!================= DecayTreeTupleHerschel v1r1 2015-11-02 ==================== - -! 2015-12-02 - Dan Johnson - - change 'adc' from 'unsigned int' to 'int' because with pedestal subtraction - the adc can be negative - -! 2015-12-02 - Dan Johnson - - Update the tuple tool to use the corrected Herschel digits, after - common mode subtraction - -!================= DecayTreeTupleHerschel v1r0 2015-08-06 ==================== - -! 2015-08-06 - Dan Johnson - - First import of the new package and tool: - Tuple tool to convey Herschel ADC counts taken from Herschel raw bank - after decoding with HCRawBankDecoder. diff --git a/Phys/DecayTreeTupleHerschel/src/TupleToolHerschel.cpp b/Phys/DecayTreeTupleHerschel/src/TupleToolHerschel.cpp deleted file mode 100644 index f2f28354d4bac42bf182ee0649b6a707f68333b2..0000000000000000000000000000000000000000 --- a/Phys/DecayTreeTupleHerschel/src/TupleToolHerschel.cpp +++ /dev/null @@ -1,320 +0,0 @@ -/*****************************************************************************\ -* (c) Copyright 2000-2018 CERN for the benefit of the LHCb Collaboration * -* * -* This software is distributed under the terms of the GNU General Public * -* Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". * -* * -* In applying this licence, CERN does not waive the privileges and immunities * -* granted to it by virtue of its status as an Intergovernmental Organization * -* or submit itself to any jurisdiction. * -\*****************************************************************************/ -// Include files - -// from Gaudi -#include "Event/HCDigit.h" -#include "Event/ODIN.h" -// from LHCb -#include "DetDesc/Condition.h" - -// local -#include "TupleToolHerschel.h" - -DECLARE_COMPONENT( TupleToolHerschel ) - -//============================================================================= -// Standard constructor, initializes variables -//============================================================================= -TupleToolHerschel::TupleToolHerschel( const std::string& type, const std::string& name, const IInterface* parent ) - : TupleToolBase( type, name, parent ), m_cond( nullptr ) { - declareInterface( this ); -} - -StatusCode TupleToolHerschel::initialize() { - StatusCode sc = TupleToolBase::initialize(); - if ( sc.isFailure() ) return sc; - // Set up the mapping - m_channels.resize( 5 ); - m_masked.resize( 5 ); - // Check if the mapping is available in the conditions database. - const std::string location = "Conditions/ReadoutConf/HC/Mapping"; - if ( existDet( location ) ) { - registerCondition( location, m_cond, &TupleToolHerschel::cacheMapping ); - // First update. - sc = updMgrSvc()->update( this ); - if ( sc.isFailure() ) { return Error( "Cannot update mapping.", StatusCode::FAILURE ); } - } else { - warning() << "Cannot find " << location << " in database" << endmsg; - mapChannels( m_channelsB0, m_sparesB0, m_masksB0, 0, true ); - mapChannels( m_channelsB1, m_sparesB1, m_masksB1, 1, true ); - mapChannels( m_channelsB2, m_sparesB2, m_masksB2, 2, true ); - mapChannels( m_channelsF1, m_sparesF1, m_masksF1, 1, false ); - mapChannels( m_channelsF2, m_sparesF2, m_masksF2, 2, false ); - } - printMapping(); - - // Check if the FOM parameters are available in the conditions database. - const std::string location_fom = "Conditions/Calibration/HC/FigureOfMerit_SimpleChi2"; - if ( existDet( location_fom ) ) { - registerCondition( location_fom, m_condFOM, &TupleToolHerschel::cacheFOMParameters ); - // First update. - sc = updMgrSvc()->update( this ); - if ( sc.isFailure() ) { return Error( "Cannot update FOM constants." ); } - } else { - warning() << "Cannot find " << location_fom << " in database." << endmsg; - _makeFOM = false; - warning() << "Cannot set FOM constants, will not create Herschel FOM in NTuple. Please fix FOM constants location " - "in CondDB." - << endmsg; - //} - } - - return sc; -} - -//============================================================================= -// Update the channel map using the conditions database. -//============================================================================= -StatusCode TupleToolHerschel::cacheMapping() { - - m_crateB = m_cond->param( "CrateB" ); - m_crateF = m_cond->param( "CrateF" ); - - m_channelsB0 = m_cond->paramVect( "ChannelsB0" ); - m_channelsB1 = m_cond->paramVect( "ChannelsB1" ); - m_channelsB2 = m_cond->paramVect( "ChannelsB2" ); - m_channelsF1 = m_cond->paramVect( "ChannelsF1" ); - m_channelsF2 = m_cond->paramVect( "ChannelsF2" ); - - m_sparesB0 = m_cond->paramVect( "ReferenceChannelsB0" ); - m_sparesB1 = m_cond->paramVect( "ReferenceChannelsB1" ); - m_sparesB2 = m_cond->paramVect( "ReferenceChannelsB2" ); - m_sparesF1 = m_cond->paramVect( "ReferenceChannelsF1" ); - m_sparesF2 = m_cond->paramVect( "ReferenceChannelsF2" ); - - m_masksB0 = m_cond->paramVect( "MasksB0" ); - m_masksB1 = m_cond->paramVect( "MasksB1" ); - m_masksB2 = m_cond->paramVect( "MasksB2" ); - m_masksF1 = m_cond->paramVect( "MasksF1" ); - m_masksF2 = m_cond->paramVect( "MasksF2" ); - - mapChannels( m_channelsB0, m_sparesB0, m_masksB0, 0, true ); - mapChannels( m_channelsB1, m_sparesB1, m_masksB1, 1, true ); - mapChannels( m_channelsB2, m_sparesB2, m_masksB2, 2, true ); - mapChannels( m_channelsF1, m_sparesF1, m_masksF1, 1, false ); - mapChannels( m_channelsF2, m_sparesF2, m_masksF2, 2, false ); - return StatusCode::SUCCESS; -} - -//============================================================================= -// Setup the channel map for a given station. -//============================================================================= -bool TupleToolHerschel::mapChannels( const std::vector& channels, const std::vector& refs, - const std::vector& masks, const unsigned int station, const bool bwd ) { - - const unsigned int offset = bwd ? 0 : 2; - // Check if the input is valid. - if ( channels.size() != 4 || refs.size() != 4 || masks.size() != 4 ) { - std::string s = bwd ? "B" : "F"; - s += std::to_string( station ); - warning() << "Invalid channel map for station " << s << ". Masking all quadrants." << endmsg; - m_channels[station + offset].assign( 4, 0 ); - m_masked[station + offset].assign( 4, true ); - return false; - } - - const unsigned int crate = bwd ? m_crateB : m_crateF; - m_channels[station + offset].resize( 4 ); - m_masked[station + offset].resize( 4 ); - for ( unsigned int i = 0; i < 4; ++i ) { - if ( channels[i] < 0 ) { - std::string s = bwd ? "B" : "F"; - s += std::to_string( station ); - warning() << "Invalid channel number " << channels[i] << ". Masking quadrant " << s << i << endmsg; - m_masked[station + offset][i] = true; - continue; - } - m_channels[station + offset][i] = ( crate << 6 ) | channels[i]; - m_masked[station + offset][i] = masks[i] != 0; - } - return true; -} - -//============================================================================= -// Print the channel map for information -//============================================================================= -void TupleToolHerschel::printMapping() const { - - info() << " Quadrant ID Ref. ID Comment" << endmsg; - const std::vector stations = {"B0", "B1", "B2", "F1", "F2"}; - const unsigned int nStations = stations.size(); - for ( unsigned int i = 0; i < nStations; ++i ) { - for ( unsigned int j = 0; j < 4; ++j ) { - const std::string comment = m_masked[i][j] ? "Masked" : ""; - info() << format( " %2s/%1d", stations[i].c_str(), j ) << format( " %4d", m_channels[i][j] ) - << format( " %-10s", comment.c_str() ) << endmsg; - } - } -} - -//============================================================================= -// Retrieve the FOM parameters from the conditions database. -//============================================================================= -StatusCode TupleToolHerschel::cacheFOMParameters() { - info() << "Updating HRC figure of merit parameters." << endmsg; - m_hrcFomVnum = m_condFOM->param( "FOMvNum" ); - info() << "HRC FOM version number " << m_hrcFomVnum << endmsg; - - m_meanConfig.clear(); - m_rmsConfig.clear(); - const std::vector stations = {"B0", "B1", "B2", "F1", "F2"}; - for ( const auto& st : stations ) { - const auto meanEven = m_condFOM->paramVect( "Mean" + st + "Even" ); - const auto meanOdd = m_condFOM->paramVect( "Mean" + st + "Odd" ); - const auto rmsEven = m_condFOM->paramVect( "RMS" + st + "Even" ); - const auto rmsOdd = m_condFOM->paramVect( "RMS" + st + "Odd" ); - for ( unsigned int i = 0; i < 4; ++i ) { - m_meanConfig.push_back( meanEven[i] ); - m_meanConfig.push_back( meanOdd[i] ); - m_rmsConfig.push_back( rmsEven[i] ); - m_rmsConfig.push_back( rmsOdd[i] ); - } - } - return setFOMParameters(); -} - -//============================================================================= -// Update the calibration constants. -//============================================================================= -StatusCode TupleToolHerschel::setFOMParameters() { - - const unsigned int nStations = 5; - const unsigned int nQuadrants = 4; - // Check if the lists of calibration constants have the right size. - const unsigned int nExpectedSize = nStations * 4 * 2; - if ( m_meanConfig.size() != nExpectedSize || m_rmsConfig.size() != nExpectedSize ) { - return Error( "List of FOM calibration constants has incorrect size." ); - } - m_mean.resize( nStations ); - m_rms.resize( nStations ); - unsigned int index = 0; - for ( unsigned int i = 0; i < nStations; ++i ) { - m_mean[i].resize( nQuadrants ); - m_rms[i].resize( nQuadrants ); - for ( unsigned int j = 0; j < nQuadrants; ++j ) { - m_mean[i][j].resize( 2 ); - m_rms[i][j].resize( 2 ); - for ( unsigned int k = 0; k < 2; ++k ) { - m_mean[i][j][k] = m_meanConfig[index]; - m_rms[i][j][k] = m_rmsConfig[index]; - ++index; - } - } - } - return StatusCode::SUCCESS; -} - -//============================================================================= -StatusCode TupleToolHerschel::fill( Tuples::Tuple& tup ) { - const std::string prefix = fullName(); - - // Get ODIN - const LHCb::ODIN* odin = getIfExists( evtSvc(), LHCb::ODINLocation::Default ); - if ( !odin ) { odin = getIfExists( evtSvc(), LHCb::ODINLocation::Default, false ); } - if ( !odin ) { - // should always be available ... - return Error( "Cannot load the ODIN data object", StatusCode::SUCCESS ); - } - const unsigned int bxid = odin->bunchId(); - const unsigned int parity = bxid % 2; - - // Get Herschel digits - LHCb::HCDigits* digits = getIfExists( m_DigitsLocation ); - if ( !digits ) { - // should always be available ... - return Error( "Cannot load the HCDigits data object", StatusCode::SUCCESS ); - } - - // Fill the Herschel information - double log_hrc_fom = -999; - double log_hrc_fom_B = -999; - double log_hrc_fom_F = -999; - double hrc_fom = 0.; - double hrc_fom_B = 0.; - double hrc_fom_F = 0.; - - // Herschel FOM : log( sum( chi2 )) - bool test = true; - const std::vector stations = {"B0", "B1", "B2", "F1", "F2"}; - const unsigned int nStations = 5; - for ( unsigned int i = 0; i < nStations; ++i ) { - for ( unsigned int j = 0; j < 4; ++j ) { - // Build channel name - const std::string ch = stations[i] + std::to_string( j ); - LHCb::HCCellID id( m_channels[i][j] ); - const LHCb::HCDigit* digit = digits->object( id ); - - // Create a value of ADC to write out every event, irrespective of whether a HCdigit is found - int adc = -999; - - // If a digit is found *and* the channel is not masked - if ( digit && !m_masked[i][j] ) { - adc = digit->adc(); - - // Make Herschel FOM - if ( _makeFOM ) { - // A counter is to be ignored if the width is set to <0: - if ( m_rms[i][j][parity] > 0.0 ) { - - double quadrant_pull = ( adc - m_mean[i][j][parity] ) / m_rms[i][j][parity]; - hrc_fom += quadrant_pull * quadrant_pull; - - // Make Herschel FOM for B-side and F-side separately - if ( i < 3 ) - hrc_fom_B += quadrant_pull * quadrant_pull; - else - hrc_fom_F += quadrant_pull * quadrant_pull; - } - } else { - hrc_fom = -999.; - hrc_fom_B = -999.; - hrc_fom_F = -999.; - } - } else if ( !digit ) { - Warning( "Cannot retrieve digit for " + ch, StatusCode::SUCCESS, 50 ) - .ignore( /* AUTOMATICALLY ADDED FOR gaudi/Gaudi!763 */ ); - } else { - warning() << "Channel " << ch << " is masked." << endmsg; - } - - // Always write out the ADC - test &= tup->column( prefix + ch, adc ); - } - } - - if ( hrc_fom > 0 ) log_hrc_fom = std::log( hrc_fom ); - if ( hrc_fom_B > 0 ) log_hrc_fom_B = std::log( hrc_fom_B ); - if ( hrc_fom_F > 0 ) log_hrc_fom_F = std::log( hrc_fom_F ); - test &= tup->column( prefix + "log_hrc_fom" + "_v" + std::to_string( m_hrcFomVnum ), log_hrc_fom ); - test &= tup->column( prefix + "log_hrc_fom_B" + "_v" + std::to_string( m_hrcFomVnum ), log_hrc_fom_B ); - test &= tup->column( prefix + "log_hrc_fom_F" + "_v" + std::to_string( m_hrcFomVnum ), log_hrc_fom_F ); - - // Fill ADC vectors - std::vector adcB, adcF; - for ( const LHCb::HCDigit* dig : *digits ) { - const int cell = int( dig->cellID().cellID() ); - const int crate = cell >> 6; - if ( crate == 0 ) { - adcB.push_back( (double)dig->adc() ); - } else if ( crate == 1 ) { - adcF.push_back( (double)dig->adc() ); - } else { - info() << "Crate = " << crate << ". We have a problem." << endmsg; - } - } - - // Fill tuple - test &= tup->farray( prefix + "adc_B", adcB.begin(), adcB.end(), prefix + "nchB", 1000 ); - test &= tup->farray( prefix + "adc_F", adcF.begin(), adcF.end(), prefix + "nchF", 1000 ); - - return StatusCode( test ); -} diff --git a/Phys/DecayTreeTupleHerschel/src/TupleToolHerschel.h b/Phys/DecayTreeTupleHerschel/src/TupleToolHerschel.h deleted file mode 100644 index 3b62cbfb45fdfafd88c41cba836ce56219489ad4..0000000000000000000000000000000000000000 --- a/Phys/DecayTreeTupleHerschel/src/TupleToolHerschel.h +++ /dev/null @@ -1,90 +0,0 @@ -/*****************************************************************************\ -* (c) Copyright 2000-2018 CERN for the benefit of the LHCb Collaboration * -* * -* This software is distributed under the terms of the GNU General Public * -* Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". * -* * -* In applying this licence, CERN does not waive the privileges and immunities * -* granted to it by virtue of its status as an Intergovernmental Organization * -* or submit itself to any jurisdiction. * -\*****************************************************************************/ -#ifndef TUPLETOOLHERSCHEL_H -#define TUPLETOOLHERSCHEL_H 1 - -// Include files -// from Gaudi -#include "DecayTreeTupleBase/TupleToolBase.h" -#include "Kernel/IEventTupleTool.h" // Interface - -/** @class TupleToolHerschel TupleToolHerschel.h - * - * Fills Herschel information. - * - * @author Dan Johnson - * @date 2015-07-08 - */ -class TupleToolHerschel : public TupleToolBase, virtual public IEventTupleTool { - -public: - /// Standard constructor - TupleToolHerschel( const std::string& type, const std::string& name, const IInterface* parent ); - StatusCode initialize() override; ///< Algorithm initialization - StatusCode fill( Tuples::Tuple& ) override; ///< Fill tuple - - Gaudi::Property m_DigitsLocation{this, "DigitsLocation", "Raw/HC/Digits", - "TES location of Herschel digits"}; - // Mappings (to be retrieved from conditions database). - Gaudi::Property m_crateB{this, "CrateB", 0, "Number of B-side crate"}; - Gaudi::Property m_crateF{this, "CrateF", 1, "Number of F-side crate"}; - - Gaudi::Property> m_masksB0{this, "MasksB0", {false, false, false, false}, "B0 masking"}; - Gaudi::Property> m_masksB1{this, "MasksB1", {false, false, false, false}, "B1 masking"}; - Gaudi::Property> m_masksB2{this, "MasksB2", {false, false, false, false}, "B2 masking"}; - Gaudi::Property> m_masksF1{this, "MasksF1", {false, false, false, false}, "F1 masking"}; - Gaudi::Property> m_masksF2{this, "MasksF2", {false, false, false, false}, "F2 masking"}; - - Gaudi::Property> m_channelsB0{this, "ChannelsB0", {}, "B0 channels"}; - Gaudi::Property> m_channelsB1{this, "ChannelsB1", {}, "B1 channels"}; - Gaudi::Property> m_channelsB2{this, "ChannelsB2", {}, "B2 channels"}; - Gaudi::Property> m_channelsF1{this, "ChannelsF1", {}, "F1 channels"}; - Gaudi::Property> m_channelsF2{this, "ChannelsF2", {}, "F2 channels"}; - - Gaudi::Property> m_sparesB0{this, "SpareChannelsB0", {}, "B0 spare channels"}; - Gaudi::Property> m_sparesB1{this, "SpareChannelsB1", {}, "B1 spare channels"}; - Gaudi::Property> m_sparesB2{this, "SpareChannelsB2", {}, "B2 spare channels"}; - Gaudi::Property> m_sparesF1{this, "SpareChannelsF1", {}, "F1 spare channels"}; - Gaudi::Property> m_sparesF2{this, "SpareChannelsF2", {}, "F2 spare channels"}; - -protected: - /// Conditions database information - Condition* m_cond; - Condition* m_condFOM = nullptr; - - /// Channel numbers for each quadrant - std::vector> m_channels; - /// Masked flags for each quadrant - std::vector> m_masked; - /// Retrieve the mapping from the conditions database. - StatusCode cacheMapping(); - /// Setup the mapping for a given station. - bool mapChannels( const std::vector& channels, const std::vector& refs, const std::vector& masks, - const unsigned int station, const bool bwd ); - /// Print the channel mapping for information. - void printMapping() const; - - StatusCode cacheFOMParameters(); - StatusCode setFOMParameters(); - - /// FOM constants for each channel and parity - /// station (x5) ; quadrant (x4) ; parity (x2) - std::vector>> m_mean; - std::vector>> m_rms; - bool _makeFOM = true; - - // Input parameters from CondDB - std::vector m_meanConfig; - std::vector m_rmsConfig; - int m_hrcFomVnum; -}; - -#endif diff --git a/Phys/DecayTreeTupleJets/CMakeLists.txt b/Phys/DecayTreeTupleJets/CMakeLists.txt deleted file mode 100644 index 38321b13a13dbe4cc3119596cf7216c8e8dfe1a1..0000000000000000000000000000000000000000 --- a/Phys/DecayTreeTupleJets/CMakeLists.txt +++ /dev/null @@ -1,39 +0,0 @@ -############################################################################### -# (c) Copyright 2000-2021 CERN for the benefit of the LHCb Collaboration # -# # -# This software is distributed under the terms of the GNU General Public # -# Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". # -# # -# In applying this licence, CERN does not waive the privileges and immunities # -# granted to it by virtue of its status as an Intergovernmental Organization # -# or submit itself to any jurisdiction. # -############################################################################### -#[=======================================================================[.rst: -Phys/DecayTreeTupleJets ------------------------ -#]=======================================================================] - -gaudi_add_module(DecayTreeTupleJets - SOURCES - src/TupleToolJetRelations.cpp - src/TupleToolJetTag.cpp - src/TupleToolJets.cpp - src/TupleToolJetsBase.cpp - src/TupleToolJetsForB.cpp - src/TupleToolWZJets.cpp - LINK - Analysis::DecayTreeTupleBaseLib - Boost::headers - Gaudi::GaudiAlgLib - LHCb::HltEvent - LHCb::PartPropLib - LHCb::PhysEvent - LHCb::PhysInterfacesLib - Phys::DaVinciInterfacesLib - Phys::DaVinciKernelLib - Phys::JetAccessoriesLib - Phys::JetTaggingLib - Phys::LoKiArrayFunctorsLib - Phys::LoKiLib - Phys::LoKiPhysLib -) diff --git a/Phys/DecayTreeTupleJets/doc/release.notes b/Phys/DecayTreeTupleJets/doc/release.notes deleted file mode 100644 index ab0cee4f6f5cb69d51693653e80e1bcd01a1829e..0000000000000000000000000000000000000000 --- a/Phys/DecayTreeTupleJets/doc/release.notes +++ /dev/null @@ -1,60 +0,0 @@ -!----------------------------------------------------------------------------- -! Package : Phys/DecayTreeTupleJets -! Responsible : Chris Jones -! Purpose : Jet related Tuple Tools -!----------------------------------------------------------------------------- - -!==================== DecayTreeTupleJets v1r4 2016-02-05 ==================== - -- 2015-12-19 - Cedric Potterat - - fix TupleToolJetTag, hacked for BDTTag - - add all var in Base - -!==================== DecayTreeTupleJets v1r3 2015-07-24 ==================== - -! 2015-06-12 - Eduardo Rodrigues - - Removed recent "fix" from CMakeLists.txt as it did not help. - -! 2015-06-10 - Eduardo Rodrigues - - Fixed CMakeLists.txt ... hopefully, so that the package builds again. - -! 2015-06-09 - Xabier Cid Vidal - - add Event/HltEvent CMakeLists.txt to fix CMake compilation - -! 2015-06-05 - Xabier Cid Vidal - - add new TupleTool to add variables related to the use of jets in B physics - -!==================== DecayTreeTupleJets v1r2 2015-02-26 ==================== - -! 2015-01-23 - Vanya Belyaev - - minor fix to account changes in structure of LoKi header files - -!========================= DecayTreeTupleJets v1r1p2 2013-06-13 ========================= - -! 2013-06-12 - Chris Jones - - Remove unused typedefs (gcc 4.8 warning). - -! 2013-05-17 - Chris Jones - - Remove unused data members to fix clang warnings. - -!========================= DecayTreeTupleJets v1r1p1 2013-05-07 ========================= - -! 2013-02-26 - Chris Jones - - Fix -pedantic compilation warnings - -!========================= DecayTreeTupleJets v1r1 2013-02-20 ========================= - -! 2013-02-18 - Marco Clemencic - - Fixed compilation with CMake. - -! 2013-02-14 - Cedric Potterat - - Added TupleToolJetTag (need Phys/JetTagging) - -!========================= DecayTreeTupleJets v1r0 2012-11-30 ========================= - -! 2012-11-29 - Marco Clemencic - - Added CMake configuration file. - -! 2012-11-22 - Chris Jones - - First version. Split of from monolithic Phys/DecayTreeTuple package. - Contains all Jet tuple tools. diff --git a/Phys/DecayTreeTupleJets/src/TupleToolJetRelations.cpp b/Phys/DecayTreeTupleJets/src/TupleToolJetRelations.cpp deleted file mode 100644 index a6ba8ebea551f9e09bc6d4a2835dbf04e62d0c1b..0000000000000000000000000000000000000000 --- a/Phys/DecayTreeTupleJets/src/TupleToolJetRelations.cpp +++ /dev/null @@ -1,171 +0,0 @@ -/*****************************************************************************\ -* (c) Copyright 2000-2018 CERN for the benefit of the LHCb Collaboration * -* * -* This software is distributed under the terms of the GNU General Public * -* Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". * -* * -* In applying this licence, CERN does not waive the privileges and immunities * -* granted to it by virtue of its status as an Intergovernmental Organization * -* or submit itself to any jurisdiction. * -\*****************************************************************************/ - -#include "TupleToolJetsBase.h" - -#include "Kernel/IJets2Jets.h" -#include "Kernel/IParticleTupleTool.h" - -#include "boost/lexical_cast.hpp" -#include - -#include - -/** - * @author Albert Bursche - */ -class TupleToolJetRelations : public TupleToolJetsBase, virtual public IParticleTupleTool { - -public: - TupleToolJetRelations( const std::string& type, const std::string& name, const IInterface* parent ); - StatusCode fill( const LHCb::Particle*, const LHCb::Particle*, const std::string&, Tuples::Tuple&, - IGeometryInfo const& ) override; - -private: - std::string m_RelationsContainer; - bool m_Invert; // invert relation table - bool m_Reverse; // reverse order in relation table (true highest weight is closest) - IJets2Jets::Table* m_Table; - const LHCb::Particle* m_p; - // Tuples::Tuple* m_tuple; - unsigned int m_MaxMatches; - std::string m_head; - static double DeltaR( const LHCb::Particle&, const LHCb::Particle& ); // can be made virtual to allow using the same - // code with different distance measure - bool furtherAway( LHCb::Particle& a, LHCb::Particle& b ) { return DeltaR( *m_p, a ) > DeltaR( *m_p, b ); } - bool fill( unsigned int i, const IJets2Jets::Table::Entry* e ); - std::map m_ExtraTableLocations; - std::map m_ExtraTables; - StatusCode getTable( std::string loc, IJets2Jets::Table*& tab ); -}; - -// Declaration of the Tool Factory -DECLARE_COMPONENT( TupleToolJetRelations ) - -//============================================================================= -// Standard constructor, initializes variables -//============================================================================= -TupleToolJetRelations::TupleToolJetRelations( const std::string& type, const std::string& name, - const IInterface* parent ) - : TupleToolJetsBase( type, name, parent ) - -{ - declareInterface( this ); - declareProperty( "RelationsContainer", m_RelationsContainer = "", - "Where to find the table to get information from." ); - declareProperty( "InvertTable", m_Invert = false, "Invert relation table" ); - declareProperty( "ReverseMatching", m_Reverse = false, "Does best matching correspond to highes or lowest weight?" ); - declareProperty( "MaxMatches", m_MaxMatches = 1, "How many matches in the tuple?" ); - declareProperty( "ExtraWeights", m_ExtraTableLocations = std::map(), - "Write the 'weight' parameter of these tables in the tuple. Uses the value of 'InvertTable'." ); -} - -StatusCode TupleToolJetRelations::fill( const LHCb::Particle* /* top */, const LHCb::Particle* p, - const std::string& head, Tuples::Tuple& tuple, IGeometryInfo const& ) { - m_tuple = &tuple; - bool test = true; - m_p = p; - m_head = m_extraName + head; - // if(exist(m_RelationsContainer)) - for ( std::map::const_iterator it = m_ExtraTableLocations.begin(); - it != m_ExtraTableLocations.end(); ++it ) { - IJets2Jets::Table* tab = 0; - getTable( it->second, tab ).ignore( /* AUTOMATICALLY ADDED FOR gaudi/Gaudi!763 */ ); - m_ExtraTables[it->first] = tab; - } - if ( m_ExtraTables.size() != m_ExtraTableLocations.size() ) return StatusCode::FAILURE; - if ( getTable( m_RelationsContainer, m_Table ) == StatusCode::SUCCESS ) { - IJets2Jets::Table::Range r = m_Table->i_relations( p ); - ( *m_tuple )->column( m_head + "_numMatches", r.size() ).ignore( /* AUTOMATICALLY ADDED FOR gaudi/Gaudi!763 */ ); - unsigned int numMatches = 0; - if ( r.size() ) { - if ( m_Reverse ) { - IJets2Jets::Table::Range::reverse_iterator it = r.rbegin(); - for ( ; numMatches < m_MaxMatches; numMatches++ ) - if ( it != r.rend() ) - fill( numMatches, &*it++ ); - else - fill( numMatches, 0 ); - } else { - IJets2Jets::Table::Range::iterator it = r.begin(); - for ( ; numMatches < m_MaxMatches; numMatches++ ) - if ( it != r.end() ) - fill( numMatches, &*it++ ); - else - fill( numMatches, 0 ); - } - } else - for ( ; numMatches < m_MaxMatches; numMatches++ ) fill( numMatches, 0 ); - if ( m_Invert ) { - delete m_Table; - for ( std::map::iterator it = m_ExtraTables.begin(); it != m_ExtraTables.end(); - ++it ) - if ( it->second ) { - delete it->second; - it->second = 0; - } - } - } - return StatusCode( test ); -} - -double TupleToolJetRelations::DeltaR( const LHCb::Particle& jet, const LHCb::Particle& jet2 ) { // Delta R - double dphi = jet.momentum().Phi() - jet2.momentum().Phi(); - while ( fabs( dphi ) > M_PI ) dphi += ( dphi > 0 ) ? -2 * M_PI : 2 * M_PI; - return sqrt( pow( jet.momentum().Eta() - jet2.momentum().Eta(), 2 ) + pow( dphi, 2 ) ); -} -#define SAVEPOINT( POINT, FUN ) ( POINT ? POINT->FUN : -1.0 ) -bool TupleToolJetRelations::fill( unsigned int i, const IJets2Jets::Table::Entry* e ) { - bool test = true; - std::string I = boost::lexical_cast( i ); - if ( msgLevel( MSG::DEBUG ) ) debug() << "Tuple: " << m_tuple << "\t" + I + " \tRelation" << e << endmsg; - - test &= ( *m_tuple )->column( m_head + "Relation" + I + "weight", SAVEPOINT( e, weight() ) ); - test &= - ( *m_tuple )->column( m_head + "Relation" + I + "DeltaR", e == 0 ? -1 : DeltaR( ( *e->from() ), *( e->to() ) ) ); - if ( e && e->to() ) - WriteJetToTuple( e->to(), m_head + "Relation" + I + "Jet" ); - else - WriteJetToTuple( 0, m_head + "Relation" + I + "Jet" ); - for ( std::map::const_iterator it = m_ExtraTables.begin(); it != m_ExtraTables.end(); - ++it ) - if ( it->second ) // this should be true for either all or no events - { - bool found = false; - // IJets2Jets::Table::Range FromRes = it->second->i_relations (e->from()); - if ( e && e->to() && e->from() ) { - IJets2Jets::Table::Range FromRes = it->second->i_relations( e->from() ); - for ( IJets2Jets::Table::Range::iterator jt = FromRes.begin(); jt != FromRes.end(); ++jt ) - if ( jt->to() == e->to() ) { - if ( found ) Error( "Table corrupted!" ).ignore( /* AUTOMATICALLY ADDED FOR gaudi/Gaudi!763 */ ); - debug() << "Writing value in " << m_head + "Relation" + I + it->first << endmsg; - test &= ( *m_tuple )->column( m_head + "Relation" + I + it->first, jt->weight() ); - found = true; - } - } - if ( !found ) { - debug() << "Writing dummy in " << m_head + "Relation" + I + it->first << endmsg; - test &= ( *m_tuple )->column( m_head + "Relation" + I + it->first, (double)-1 ); - } - } - return test; -} -StatusCode TupleToolJetRelations::getTable( std::string loc, IJets2Jets::Table*& tab ) { - if ( exist( loc ) ) { - tab = get( loc ); - if ( m_Invert ) tab = new IJets2Jets::Table( *tab, IJets2Jets::Table::inverse_tag{} ); - debug() << "Retrieved table from :" << loc << endmsg; - return StatusCode::SUCCESS; - } else { - tab = 0; - return StatusCode::FAILURE; - } -} diff --git a/Phys/DecayTreeTupleJets/src/TupleToolJetTag.cpp b/Phys/DecayTreeTupleJets/src/TupleToolJetTag.cpp deleted file mode 100644 index 9438d7d9585632ebc831a322a2a02bc9a7633c73..0000000000000000000000000000000000000000 --- a/Phys/DecayTreeTupleJets/src/TupleToolJetTag.cpp +++ /dev/null @@ -1,159 +0,0 @@ -/*****************************************************************************\ -* (c) Copyright 2000-2018 CERN for the benefit of the LHCb Collaboration * -* * -* This software is distributed under the terms of the GNU General Public * -* Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". * -* * -* In applying this licence, CERN does not waive the privileges and immunities * -* granted to it by virtue of its status as an Intergovernmental Organization * -* or submit itself to any jurisdiction. * -\*****************************************************************************/ - -#include "TupleToolJetsBase.h" - -#include "Kernel/IJetTagTool.h" -#include "Kernel/IJets2Jets.h" -#include "Kernel/IParticleTupleTool.h" - -#include "Event/Particle.h" - -#include "GaudiAlg/Tuple.h" -#include "GaudiAlg/TupleObj.h" - -/** - * Runs one jet tagging algorithm and writes the value out to the tuple - */ -class TupleToolJetTag : public TupleToolJetsBase, virtual public IParticleTupleTool { - -public: - TupleToolJetTag( const std::string& type, const std::string& name, const IInterface* parent ); - StatusCode initialize() override; - StatusCode fill( const LHCb::Particle*, const LHCb::Particle*, const std::string&, Tuples::Tuple&, - IGeometryInfo const& ) override; - -private: - // label for ntuple - std::string m_tagToolLabel; - - // name to retrieve tool - std::string m_tagToolName; - -protected: - IJetTagTool* m_TagTool; - bool m_verboseTag; ///< get details on Tag -}; - -DECLARE_COMPONENT( TupleToolJetTag ) - -// Constructor -TupleToolJetTag::TupleToolJetTag( const std::string& type, const std::string& name, const IInterface* parent ) - : TupleToolJetsBase( type, name, parent ), m_TagTool( NULL ) { - declareInterface( this ); - - declareProperty( "tagToolName", m_tagToolName = "LoKi::BDTTag", "name of jet tagger" ); - - declareProperty( "tagToolLabel", m_tagToolLabel = "BDTTag", "label of jet tagger for tuple" ); - - declareProperty( "VerboseTag", m_verboseTag = false ); -} - -// Initalise -StatusCode TupleToolJetTag::initialize() { - const StatusCode sc = TupleToolBase::initialize(); - if ( sc.isFailure() ) return sc; - - m_TagTool = tool( m_tagToolName, m_tagToolName, this ); - - return sc; -} - -// Execute -StatusCode TupleToolJetTag::fill( const LHCb::Particle*, const LHCb::Particle* jet, const std::string& head, - Tuples::Tuple& tuple, IGeometryInfo const& ) { - bool result = true; - if ( jet ) { - const std::string prefix = fullName( head ); - - // Run jet tag tool - std::map property; - m_TagTool->calculateJetProperty( jet, property ); - if ( property.empty() ) - if ( msgLevel( MSG::ERROR ) ) debug() << "Write tag to ntuple --- not found " << endmsg; - if ( m_tagToolName != "LoKi::BDTTag" ) { - for ( std::map::iterator it = property.begin(); it != property.end(); ++it ) { - - result &= ( tuple )->column( prefix + "_" + m_tagToolLabel + "_" + ( it->first ), ( it->second ) ); - } - } else { - // spacial case for BDTTag. - std::vector fdrMin, ptSvrJet, nTrk, nTrkJet, drSvrJet; - std::vector absQSum, m, mCor, fdChi2, ipChi2Sum; - std::vector bdt0, bdt1, pass, tau, z, pt, backwards; - for ( int idx = 0; idx != (int)property.size() + 1; idx++ ) { - - std::stringstream pre; - pre << "Tag" << idx << "_"; - - fdrMin.push_back( property[pre.str() + "fdrMin"] ); - ptSvrJet.push_back( property[pre.str() + "ptSvrJet"] ); - nTrk.push_back( property[pre.str() + "nTrk"] ); - nTrkJet.push_back( property[pre.str() + "nTrkJet"] ); - drSvrJet.push_back( property[pre.str() + "drSvrJet"] ); - absQSum.push_back( property[pre.str() + "absQSum"] ); - m.push_back( property[pre.str() + "m"] ); - mCor.push_back( property[pre.str() + "mCor"] ); - fdChi2.push_back( property[pre.str() + "fdChi2"] ); - ipChi2Sum.push_back( property[pre.str() + "ipChi2Sum"] ); - bdt0.push_back( property[pre.str() + "bdt0"] ); - bdt1.push_back( property[pre.str() + "bdt1"] ); - pass.push_back( property[pre.str() + "pass"] ); - tau.push_back( property[pre.str() + "tau"] ); - z.push_back( property[pre.str() + "z"] ); - pt.push_back( property[pre.str() + "pt"] ); - backwards.push_back( property[pre.str() + "backwards"] ); - int idx2 = idx + 1; - std::stringstream pre2; - pre2 << "Tag" << idx2 << "_"; - if ( property.find( pre2.str() + "fdrMin" ) == property.end() ) break; - } - - result &= ( tuple )->column( prefix + "_" + m_tagToolLabel + "_Tag", property["Tag"] ); - result &= ( tuple )->farray( prefix + "_" + m_tagToolLabel + "_fdrMin", fdrMin.begin(), fdrMin.end(), - prefix + "_" + m_tagToolLabel + "_NbTag", 20 ); - result &= ( tuple )->farray( prefix + "_" + m_tagToolLabel + "_ptSvrJet", ptSvrJet.begin(), ptSvrJet.end(), - prefix + "_" + m_tagToolLabel + "_NbTag", 20 ); - result &= ( tuple )->farray( prefix + "_" + m_tagToolLabel + "_nTrk", nTrk.begin(), nTrk.end(), - prefix + "_" + m_tagToolLabel + "_NbTag", 20 ); - result &= ( tuple )->farray( prefix + "_" + m_tagToolLabel + "_nTrkJet", nTrkJet.begin(), nTrkJet.end(), - prefix + "_" + m_tagToolLabel + "_NbTag", 20 ); - result &= ( tuple )->farray( prefix + "_" + m_tagToolLabel + "_drSvrJet", drSvrJet.begin(), drSvrJet.end(), - prefix + "_" + m_tagToolLabel + "_NbTag", 20 ); - result &= ( tuple )->farray( prefix + "_" + m_tagToolLabel + "_absQSum", absQSum.begin(), absQSum.end(), - prefix + "_" + m_tagToolLabel + "_NbTag", 20 ); - result &= ( tuple )->farray( prefix + "_" + m_tagToolLabel + "_m", m.begin(), m.end(), - prefix + "_" + m_tagToolLabel + "_NbTag", 20 ); - result &= ( tuple )->farray( prefix + "_" + m_tagToolLabel + "_mCor", mCor.begin(), mCor.end(), - prefix + "_" + m_tagToolLabel + "_NbTag", 20 ); - result &= ( tuple )->farray( prefix + "_" + m_tagToolLabel + "_fdChi2", fdChi2.begin(), fdChi2.end(), - prefix + "_" + m_tagToolLabel + "_NbTag", 20 ); - result &= ( tuple )->farray( prefix + "_" + m_tagToolLabel + "_ipChi2Sum", ipChi2Sum.begin(), ipChi2Sum.end(), - prefix + "_" + m_tagToolLabel + "_NbTag", 20 ); - result &= ( tuple )->farray( prefix + "_" + m_tagToolLabel + "_bdt0", bdt0.begin(), bdt0.end(), - prefix + "_" + m_tagToolLabel + "_NbTag", 20 ); - result &= ( tuple )->farray( prefix + "_" + m_tagToolLabel + "_bdt1", bdt1.begin(), bdt1.end(), - prefix + "_" + m_tagToolLabel + "_NbTag", 20 ); - result &= ( tuple )->farray( prefix + "_" + m_tagToolLabel + "_pass", pass.begin(), pass.end(), - prefix + "_" + m_tagToolLabel + "_NbTag", 20 ); - result &= ( tuple )->farray( prefix + "_" + m_tagToolLabel + "_tau", tau.begin(), tau.end(), - prefix + "_" + m_tagToolLabel + "_NbTag", 20 ); - result &= ( tuple )->farray( prefix + "_" + m_tagToolLabel + "_z", z.begin(), z.end(), - prefix + "_" + m_tagToolLabel + "_NbTag", 20 ); - result &= ( tuple )->farray( prefix + "_" + m_tagToolLabel + "_pt", pt.begin(), pt.end(), - prefix + "_" + m_tagToolLabel + "_NbTag", 20 ); - result &= ( tuple )->farray( prefix + "_" + m_tagToolLabel + "_backwards", backwards.begin(), backwards.end(), - prefix + "_" + m_tagToolLabel + "_NbTag", 20 ); - } - } - - return StatusCode( result ); -} diff --git a/Phys/DecayTreeTupleJets/src/TupleToolJets.cpp b/Phys/DecayTreeTupleJets/src/TupleToolJets.cpp deleted file mode 100644 index 8851fdaea57785d046f19a9a5bd4c8acbf499ef5..0000000000000000000000000000000000000000 --- a/Phys/DecayTreeTupleJets/src/TupleToolJets.cpp +++ /dev/null @@ -1,49 +0,0 @@ -/*****************************************************************************\ -* (c) Copyright 2000-2018 CERN for the benefit of the LHCb Collaboration * -* * -* This software is distributed under the terms of the GNU General Public * -* Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". * -* * -* In applying this licence, CERN does not waive the privileges and immunities * -* granted to it by virtue of its status as an Intergovernmental Organization * -* or submit itself to any jurisdiction. * -\*****************************************************************************/ - -#include "TupleToolJetsBase.h" - -#include "Kernel/IParticleTupleTool.h" - -#include - -/** - * author: Albert Bursche - */ -class TupleToolJets : public TupleToolJetsBase, virtual public IParticleTupleTool { - -public: - TupleToolJets( const std::string& type, const std::string& name, const IInterface* parent ); - StatusCode fill( const LHCb::Particle*, const LHCb::Particle*, const std::string&, Tuples::Tuple&, - IGeometryInfo const& ) override; - -private: - const LHCb::Particle* m_p; - std::string m_head; -}; - -// Declaration of the Tool Factory -DECLARE_COMPONENT( TupleToolJets ) - -TupleToolJets::TupleToolJets( const std::string& type, const std::string& name, const IInterface* parent ) - : TupleToolJetsBase( type, name, parent ) { - declareInterface( this ); -} - -StatusCode TupleToolJets::fill( const LHCb::Particle* /* top */, const LHCb::Particle* p, const std::string& head, - Tuples::Tuple& tuple, IGeometryInfo const& ) { - m_tuple = &tuple; - bool test = true; - m_p = p; - m_head = m_extraName + head; - test &= WriteJetToTuple( p, m_head ); - return StatusCode( test ); -} diff --git a/Phys/DecayTreeTupleJets/src/TupleToolJetsBase.cpp b/Phys/DecayTreeTupleJets/src/TupleToolJetsBase.cpp deleted file mode 100644 index 8a73fd118f658016ce3b6168dac57b3816269635..0000000000000000000000000000000000000000 --- a/Phys/DecayTreeTupleJets/src/TupleToolJetsBase.cpp +++ /dev/null @@ -1,257 +0,0 @@ -/*****************************************************************************\ -* (c) Copyright 2000-2018 CERN for the benefit of the LHCb Collaboration * -* * -* This software is distributed under the terms of the GNU General Public * -* Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". * -* * -* In applying this licence, CERN does not waive the privileges and immunities * -* granted to it by virtue of its status as an Intergovernmental Organization * -* or submit itself to any jurisdiction. * -\*****************************************************************************/ -#include "TupleToolJetsBase.h" -#include "LoKi/AParticleCuts.h" -#include "LoKi/ParticleCuts.h" - -TupleToolJetsBase::TupleToolJetsBase( const std::string& type, const std::string& name, const IInterface* parent ) - : TupleToolBase( type, name, parent ) - , charge( LoKi::Cuts::ONE ) - , positiveParticles( LoKi::Cuts::ONE ) - , negativeParticles( LoKi::Cuts::ONE ) - , neutralParticles( LoKi::Cuts::ONE ) - , maxPT( LoKi::Cuts::ONE ) - , m_M( LoKi::Cuts::ONE ) - , m_MM( LoKi::Cuts::ONE ) {} -#define SAVEPOINT( POINT, FUN ) ( POINT ? POINT->FUN : -1.0 ) -bool TupleToolJetsBase::WriteJetToTuple( const LHCb::Particle* jet, std::string prefix ) { - // filter plus and minus signs out to the prefix - std::map replacements; - replacements["+"] = "plus"; - replacements["-"] = "minus"; - for ( std::map::iterator it = replacements.begin(); it != replacements.end(); ++it ) { - size_t point = 0; - while ( ( point = prefix.find( it->first ) ) != std::string::npos ) - prefix = prefix.replace( point, it->second.size(), it->second ); - } - - if ( msgLevel( MSG::DEBUG ) ) - debug() << ( jet ? "Filling jet object " : "Filling dummy jet object " ) << jet << " " << prefix - << " in tuple at address " << m_tuple << endmsg; - - bool result = true; - result &= ( *m_tuple )->column( prefix + "_PX", (double)( SAVEPOINT( jet, momentum().Px() ) ) ); - result &= ( *m_tuple )->column( prefix + "_PY", (double)( SAVEPOINT( jet, momentum().Py() ) ) ); - result &= ( *m_tuple )->column( prefix + "_PZ", (double)( SAVEPOINT( jet, momentum().Pz() ) ) ); - result &= ( *m_tuple )->column( prefix + "_PE", (double)( SAVEPOINT( jet, momentum().e() ) ) ); - result &= ( *m_tuple )->column( prefix + "_PT", (double)( SAVEPOINT( jet, momentum().Pt() ) ) ); - result &= ( *m_tuple )->column( prefix + "_P", (double)( SAVEPOINT( jet, momentum().P() ) ) ); - result &= ( *m_tuple )->column( prefix + "_Eta", (double)( SAVEPOINT( jet, momentum().Eta() ) ) ); - result &= ( *m_tuple )->column( prefix + "_Phi", (double)( SAVEPOINT( jet, momentum().Phi() ) ) ); - result &= ( *m_tuple )->column( prefix + "_M", (double)( SAVEPOINT( jet, momentum().mass() ) ) ); - - result &= ( *m_tuple )->column( prefix + "_MLoKi", (double)( jet ? m_M( jet ) : -99.0 ) ); - result &= ( *m_tuple )->column( prefix + "_MMLoKi", (double)( jet ? m_MM( jet ) : -99.0 ) ); - result &= ( *m_tuple )->column( prefix + "_NTrk", (double)( jet->info( LHCb::JetIDInfo::Ntracks, -999.9 ) ) ); - result &= ( *m_tuple )->column( prefix + "_N90", (double)( jet->info( LHCb::JetIDInfo::N90, -999.9 ) ) ); - result &= ( *m_tuple )->column( prefix + "_MTF", (double)( jet->info( LHCb::JetIDInfo::MTF, -999.9 ) ) ); - result &= ( *m_tuple )->column( prefix + "_NSatCells", (double)( jet->info( LHCb::JetIDInfo::NSatCalo, -999.9 ) ) ); - result &= ( *m_tuple )->column( prefix + "_NHasPVInfo", (double)( jet->info( LHCb::JetIDInfo::NHasPV, -999.9 ) ) ); - result &= ( *m_tuple )->column( prefix + "_JEC_Cor", (double)( jet->info( LHCb::JECInfo::JEC, -999.9 ) ) ); - result &= ( *m_tuple )->column( prefix + "_JEC_PV", (double)( jet->info( LHCb::JECInfo::NPVsForJEC, -999.9 ) ) ); - result &= ( *m_tuple )->column( prefix + "_JEC_Error", (double)( jet->info( LHCb::JECInfo::JECError, -999.9 ) ) ); - - double weigth = 1.0; - double myPT = ( SAVEPOINT( jet, momentum().Pt() ) ); - - if ( myPT < 20000 ) weigth = 1 - ( ( 20000 - myPT ) / 16000 ); - - // weigth for 5GeV jet: - - result &= ( *m_tuple )->column( prefix + "_w", (double)( weigth ) ); - result &= ( *m_tuple )->column( prefix + "_CPF", (double)( jet->info( LHCb::JetIDInfo::CPF, -999.9 ) ) ); - result &= ( *m_tuple )->column( prefix + "_JetWidth", (double)( jet->info( LHCb::JetIDInfo::JetWidth, -999.9 ) ) ); - result &= ( *m_tuple )->column( prefix + "_NSatECAL", (double)( jet->info( LHCb::JetIDInfo::NSatECAL, -999.9 ) ) ); - result &= ( *m_tuple )->column( prefix + "_NSatHCAL", (double)( jet->info( LHCb::JetIDInfo::NSatHCAL, -999.9 ) ) ); - result &= - ( *m_tuple )->column( prefix + "_NIPChi2Inf4", (double)( jet->info( LHCb::JetIDInfo::NIPChi2Inf4, -999.9 ) ) ); - result &= - ( *m_tuple ) - ->column( prefix + "_EfCharged", (double)( jet->info( LHCb::JetEnergyFractionInfo::Charged, -999.9 ) ) ); - result &= ( *m_tuple ) - ->column( prefix + "_EfChargedHadron", - (double)( jet->info( LHCb::JetEnergyFractionInfo::ChargedHadron, -999.9 ) ) ); - result &= - ( *m_tuple )->column( prefix + "_EfMuon", (double)( jet->info( LHCb::JetEnergyFractionInfo::Muon, -999.9 ) ) ); - result &= - ( *m_tuple ) - ->column( prefix + "_EfElectron", (double)( jet->info( LHCb::JetEnergyFractionInfo::Electron, -999.9 ) ) ); - result &= - ( *m_tuple ) - ->column( prefix + "_EfNeutral", (double)( jet->info( LHCb::JetEnergyFractionInfo::Neutral, -999.9 ) ) ); - result &= ( *m_tuple ) - ->column( prefix + "_EfPhoton", (double)( jet->info( LHCb::JetEnergyFractionInfo::Photon, -999.9 ) ) ); - result &= - ( *m_tuple )->column( prefix + "_EfPi0", (double)( jet->info( LHCb::JetEnergyFractionInfo::Pi0, -999.9 ) ) ); - result &= ( *m_tuple ) - ->column( prefix + "_EfMPi0", (double)( jet->info( LHCb::JetEnergyFractionInfo::MergedPi0, -999.9 ) ) ); - result &= - ( *m_tuple ) - ->column( prefix + "_EfRPi0", (double)( jet->info( LHCb::JetEnergyFractionInfo::ResolvedPi0, -999.9 ) ) ); - result &= - ( *m_tuple ) - ->column( prefix + "_EfNHad", (double)( jet->info( LHCb::JetEnergyFractionInfo::NeutralHadron, -999.9 ) ) ); - result &= ( *m_tuple ) - ->column( prefix + "_EfNReco", - (double)( jet->info( LHCb::JetEnergyFractionInfo::NeutralRecovery, -999.9 ) ) ); - result &= - ( *m_tuple ) - ->column( prefix + "_EfCompo", (double)( jet->info( LHCb::JetEnergyFractionInfo::Composite, -999.9 ) ) ); - result &= ( *m_tuple )->column( prefix + "_EfV0", (double)( jet->info( LHCb::JetEnergyFractionInfo::V0, -999.9 ) ) ); - result &= ( *m_tuple )->column( prefix + "_EfD", (double)( jet->info( LHCb::JetEnergyFractionInfo::D, -999.9 ) ) ); - result &= ( *m_tuple )->column( prefix + "_EfB", (double)( jet->info( LHCb::JetEnergyFractionInfo::B, -999.9 ) ) ); - result &= ( *m_tuple ) - ->column( prefix + "_EfBadParticle", - (double)( jet->info( LHCb::JetEnergyFractionInfo::BadParticle, -999.9 ) ) ); - result &= ( *m_tuple ) - ->column( prefix + "_EfCharged0Momentum", - (double)( jet->info( LHCb::JetEnergyFractionInfo::Charged0Momentum, -999.9 ) ) ); - result &= ( *m_tuple ) - ->column( prefix + "_EfChargedInfMomentum", - (double)( jet->info( LHCb::JetEnergyFractionInfo::ChargedInfMomentum, -999.9 ) ) ); - result &= ( *m_tuple ) - ->column( prefix + "_EfBadPhotonMatchingT", - (double)( jet->info( LHCb::JetEnergyFractionInfo::BadPhotonMatchingT, -999.9 ) ) ); - result &= - ( *m_tuple ) - ->column( prefix + "_EfBadPhoton", (double)( jet->info( LHCb::JetEnergyFractionInfo::BadPhoton, -999.9 ) ) ); - result &= ( *m_tuple ) - ->column( prefix + "_EfIsolatedPhoton", - (double)( jet->info( LHCb::JetEnergyFractionInfo::IsolatedPhoton, -999.9 ) ) ); - result &= - ( *m_tuple ) - ->column( prefix + "_NLongTrk", (double)( jet->info( LHCb::JetEnergyFractionInfo::NLongTrk, -999.9 ) ) ); - result &= - ( *m_tuple ) - ->column( prefix + "_EfLongTrk", (double)( jet->info( LHCb::JetEnergyFractionInfo::EfLongTrk, -999.9 ) ) ); - result &= - ( *m_tuple ) - ->column( prefix + "_NDownTrk", (double)( jet->info( LHCb::JetEnergyFractionInfo::NDownTrk, -999.9 ) ) ); - result &= - ( *m_tuple ) - ->column( prefix + "_EfDownTrk", (double)( jet->info( LHCb::JetEnergyFractionInfo::EfDownTrk, -999.9 ) ) ); - result &= - ( *m_tuple )->column( prefix + "_NUpTrk", (double)( jet->info( LHCb::JetEnergyFractionInfo::NUpTrk, -999.9 ) ) ); - result &= ( *m_tuple ) - ->column( prefix + "_EfUpTrk", (double)( jet->info( LHCb::JetEnergyFractionInfo::EfUpTrk, -999.9 ) ) ); - - result &= ( *m_tuple )->column( prefix + "_PU_NPVs", (double)( jet->info( LHCb::JetPileUpInfo::PUnPVs, -999.9 ) ) ); - result &= ( *m_tuple ) - ->column( prefix + "_PU_Cone06_SumPTLongTrk", - (double)( jet->info( LHCb::JetPileUpInfo::PUSumPTLongTrkCone06, -999.9 ) ) ); - result &= ( *m_tuple ) - ->column( prefix + "_PU_Cone06_SumELongTrk", - (double)( jet->info( LHCb::JetPileUpInfo::PUSumELongTrkCone06, -999.9 ) ) ); - result &= ( *m_tuple ) - ->column( prefix + "_PU_Cone06_NLongTrk", - (double)( jet->info( LHCb::JetPileUpInfo::PUNLongTrkCone06, -999.9 ) ) ); - result &= ( *m_tuple ) - ->column( prefix + "_PU_Cone06_NUpVeloTrk", - (double)( jet->info( LHCb::JetPileUpInfo::PUNUpVeloTrkCone06, -999.9 ) ) ); - result &= ( *m_tuple ) - ->column( prefix + "_PU_Cone10_SumPTLongTrk", - (double)( jet->info( LHCb::JetPileUpInfo::PUSumPTLongTrkCone10, -999.9 ) ) ); - result &= ( *m_tuple ) - ->column( prefix + "_PU_Cone10_SumELongTrk", - (double)( jet->info( LHCb::JetPileUpInfo::PUSumELongTrkCone10, -999.9 ) ) ); - result &= ( *m_tuple ) - ->column( prefix + "_PU_Cone10_NLongTrk", - (double)( jet->info( LHCb::JetPileUpInfo::PUNLongTrkCone10, -999.9 ) ) ); - result &= ( *m_tuple ) - ->column( prefix + "_PU_Cone10_NUpVeloTrk", - (double)( jet->info( LHCb::JetPileUpInfo::PUNUpVeloTrkCone10, -999.9 ) ) ); - result &= ( *m_tuple ) - ->column( prefix + "_PU_Cone15_SumPTLongTrk", - (double)( jet->info( LHCb::JetPileUpInfo::PUSumPTLongTrkCone15, -999.9 ) ) ); - result &= ( *m_tuple ) - ->column( prefix + "_PU_Cone15_SumELongTrk", - (double)( jet->info( LHCb::JetPileUpInfo::PUSumELongTrkCone15, -999.9 ) ) ); - result &= ( *m_tuple ) - ->column( prefix + "_PU_Cone15_NLongTrk", - (double)( jet->info( LHCb::JetPileUpInfo::PUNLongTrkCone15, -999.9 ) ) ); - result &= ( *m_tuple ) - ->column( prefix + "_PU_Cone15_NUpVeloTrk", - (double)( jet->info( LHCb::JetPileUpInfo::PUNUpVeloTrkCone15, -999.9 ) ) ); - - /* - - - - - - - - - - - - - - - - - - - result &= (*m_tuple)->column( prefix+"_ParticleMultiplicity", (double)( SAVEPOINT(jet,daughters().size()))); - // result &= (*m_tuple)->column( prefix+"_Charge", (double)( jet?charge(jet):-1.0)); - result &= (*m_tuple)->column( prefix+"_positiveParticleMultiplicity", (double)( jet?positiveParticles(jet):-1.0)); - result &= (*m_tuple)->column( prefix+"_negativeParticleMultiplicity", (double)( jet?negativeParticles(jet):-1.0)); - result &= (*m_tuple)->column( prefix+"_neutralParticleMultiplicity", (double)( jet?neutralParticles(jet):-1.0)); - result &= (*m_tuple)->column( prefix+"_chargedParticleMultiplicity", (double)( - jet?positiveParticles(jet)+negativeParticles(jet):-1.0)); result &= (*m_tuple)->column( prefix+"_maxPT", (double)( - jet?maxPT(jet):-1.0)); SmartRefVector< LHCb::Particle > SortedDaughters; - //buffer to store intermediate result to speed things up a bit - result &= (*m_tuple)->column( prefix+"_PT1", (double)( jet?MaxSumNPart(jet,1, - LoKi::Cuts::PT,&SortedDaughters):-1.0)); result &= (*m_tuple)->column( prefix+"_PT2", (double)( - jet?MaxSumNPart(jet,2, LoKi::Cuts::PT,&SortedDaughters):-1.0)); result &= (*m_tuple)->column( prefix+"_PT3", - (double)( jet?MaxSumNPart(jet,3, LoKi::Cuts::PT,&SortedDaughters):-1.0)); result &= (*m_tuple)->column( - prefix+"_PT4", (double)( jet?MaxSumNPart(jet,4, LoKi::Cuts::PT,&SortedDaughters):-1.0)); result &= - (*m_tuple)->column( prefix+"_PT5", (double)( jet?MaxSumNPart(jet,5, LoKi::Cuts::PT,&SortedDaughters):-1.0)); result - &= (*m_tuple)->column( prefix+"_PT10", (double)( jet?MaxSumNPart(jet,10,LoKi::Cuts::PT,&SortedDaughters):-1.0)); - result &= (*m_tuple)->column( prefix+"_PT15", (double)( - jet?MaxSumNPart(jet,15,LoKi::Cuts::PT,&SortedDaughters):-1.0)); result &= (*m_tuple)->column( prefix+"_PT25", - (double)( jet?MaxSumNPart(jet,25,LoKi::Cuts::PT,&SortedDaughters):-1.0)); - - */ - - return result; -} - -StatusCode TupleToolJetsBase::initialize() { - const StatusCode sc = TupleToolBase::initialize(); - if ( sc.isFailure() ) return sc; - // get LoKi objects - // charge = LoKi::Cuts::SUMTREE (LoKi::Cuts::Q, LoKi::Cuts::ALL, 0.0 ) ; - positiveParticles = LoKi::Cuts::NINTREE( LoKi::Cuts::Q > 0 ); - negativeParticles = LoKi::Cuts::NINTREE( LoKi::Cuts::Q < 0 ); - neutralParticles = LoKi::Cuts::NINTREE( LoKi::Cuts::Q == 0 ); - maxPT = LoKi::Cuts::MAXTREE( LoKi::Cuts::PT, LoKi::Cuts::BASIC, -1 ); - m_M = LoKi::Particles::Mass(); - m_MM = LoKi::Particles::MeasuredMass(); - return sc; -} - -double TupleToolJetsBase::MaxSumNPart( const LHCb::Particle* jet, unsigned int n, const LoKi::Types::Fun& fun, - SmartRefVector* SortedDaughters ) { - // fun == LoKi::Cuts::ONE; - // if (jet->daughters().size() <= n) - // return LoKi::Cuts::SUMTREE ( LoKi::Cuts::BASIC, fun)(jet); - if ( SortedDaughters && SortedDaughters->size() ) // Vector given and filled - return LoKi::Cuts::ASUM( fun )( - LHCb::Particle::ConstVector( SortedDaughters->begin(), SortedDaughters->begin() + n ) ); - SmartRefVector daughters; // empty vector to take address of in case SortedDaughters == NULL - if ( !SortedDaughters ) SortedDaughters = &daughters; - SortedDaughters->assign( jet->daughters().begin(), jet->daughters().end() ); - sort( SortedDaughters->begin(), SortedDaughters->end(), - Comperator( fun ) ); - return LoKi::Cuts::ASUM( fun )( - LHCb::Particle::ConstVector( SortedDaughters->begin(), SortedDaughters->begin() + n ) ); -} diff --git a/Phys/DecayTreeTupleJets/src/TupleToolJetsBase.h b/Phys/DecayTreeTupleJets/src/TupleToolJetsBase.h deleted file mode 100644 index 613d18f65d36ffde30fa7b1654493f2feb250e54..0000000000000000000000000000000000000000 --- a/Phys/DecayTreeTupleJets/src/TupleToolJetsBase.h +++ /dev/null @@ -1,49 +0,0 @@ -/*****************************************************************************\ -* (c) Copyright 2000-2018 CERN for the benefit of the LHCb Collaboration * -* * -* This software is distributed under the terms of the GNU General Public * -* Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". * -* * -* In applying this licence, CERN does not waive the privileges and immunities * -* granted to it by virtue of its status as an Intergovernmental Organization * -* or submit itself to any jurisdiction. * -\*****************************************************************************/ -#ifndef TUPLETOOLJETSBASE_H -#define TUPLETOOLJETSBASE_H 1 - -#include "DecayTreeTupleBase/TupleToolBase.h" -#include "Kernel/IParticleTupleTool.h" -#include "Kernel/JetEnums.h" -#include "LoKi/LoKi.h" - -// autor: Albert Bursche -class TupleToolJetsBase : public TupleToolBase, virtual public IParticleTupleTool { -public: - TupleToolJetsBase( const std::string& type, const std::string& name, const IInterface* parent ); - - StatusCode initialize() override; - -protected: - Tuples::Tuple* m_tuple; - LoKi::Types::Fun charge; - LoKi::Types::Fun positiveParticles; - LoKi::Types::Fun negativeParticles; - LoKi::Types::Fun neutralParticles; - LoKi::Types::Fun maxPT; - LoKi::Types::Fun m_M; - LoKi::Types::Fun m_MM; - - bool WriteJetToTuple( const LHCb::Particle* jet, std::string prefix ); - double MaxSumNPart( const LHCb::Particle* jet, unsigned int n, const LoKi::Types::Fun& fun, - SmartRefVector* SortedDaughters ); - template - class Comperator { - const LoKi::Types::Fun& m_fun; - - public: - Comperator( const LoKi::Types::Fun& fun ) : m_fun( fun ) {} - bool operator()( T1 t1, T2 t2 ) { return m_fun( t1 ) > m_fun( t2 ); } - }; -}; - -#endif // TUPLETOOLJETSBASE_H diff --git a/Phys/DecayTreeTupleJets/src/TupleToolJetsForB.cpp b/Phys/DecayTreeTupleJets/src/TupleToolJetsForB.cpp deleted file mode 100644 index 576c530411842d0ed0d31b8c4e6999f9ec715097..0000000000000000000000000000000000000000 --- a/Phys/DecayTreeTupleJets/src/TupleToolJetsForB.cpp +++ /dev/null @@ -1,546 +0,0 @@ -/*****************************************************************************\ -* (c) Copyright 2000-2018 CERN for the benefit of the LHCb Collaboration * -* * -* This software is distributed under the terms of the GNU General Public * -* Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". * -* * -* In applying this licence, CERN does not waive the privileges and immunities * -* granted to it by virtue of its status as an Intergovernmental Organization * -* or submit itself to any jurisdiction. * -\*****************************************************************************/ - -#include "DecayTreeTupleBase/TupleToolBase.h" - -#include "LoKi/ParticleCuts.h" - -#include "Kernel/GetIDVAlgorithm.h" -#include "Kernel/IDVAlgorithm.h" -#include "Kernel/IDistanceCalculator.h" -#include "Kernel/IParticleTupleTool.h" -#include "Kernel/ITriggerTisTos.h" - -#include "Event/HltObjectSummary.h" -#include "Event/Particle.h" - -struct IDVAlgorithm; - -typedef std::pair PtParticlePair; - -/** - * @author Xabier Cid Vidal - * @date 2014-06-30 - */ -class TupleToolJetsForB : public TupleToolBase, virtual public IParticleTupleTool { - -public: - TupleToolJetsForB( const std::string& type, const std::string& name, const IInterface* parent ); - StatusCode initialize() override; - StatusCode fill( const LHCb::Particle*, const LHCb::Particle*, const std::string&, Tuples::Tuple&, - IGeometryInfo const& ) override; - -protected: -private: - std::string m_loc_jetsnomu; // location of jets with no muons - std::string m_loc_jetsinc; // location of jets with no veto - std::string m_loc_jetsb; // locations of jets with B - bool m_use_jetsnomu; // look at jets with no muons - bool m_use_jetsinc; // look at jets with no veto - bool m_use_jetsb; // look at jets with B - bool m_onemu; // one muon only (for Bmunu) - int m_ind_part; // pid of the individual particle (13 for Bmunu) - - IDVAlgorithm* m_dva; // parent DVA Algorithm - const IDistanceCalculator* m_dist; // for obtaining the best PV - // IJetTagTool* m_nnjettag; //Jet Tag NN - ITriggerTisTos* m_TriggerTisTosTool; - // maps for all the extra info for all the jets - std::map m_JetNoMu1; - std::map m_JetNoMu2; - std::map m_JetNoMu3; - std::map m_JetMu1; - std::map m_JetMu2; - std::map m_JetB; - - bool m_forcePV; // force same PV as top candidate or not! - - double jetNNTag( const LHCb::Particle* jet ); - StatusCode getJetLHCbIDs( const LHCb::Particle* p, std::vector& AllIDs ) const; - StatusCode getHltObjLHCbIDs( const LHCb::HltObjectSummary* sum, std::vector& AllIDs ) const; - - void pt_sorted_samePV( const LHCb::Particles& jets_list, const int pvkey, std::vector& out_list, - IGeometryInfo const& geometry ); - - StatusCode find_jet_b( const LHCb::Particles* list_of_jets, LHCb::Particle& myjet, IGeometryInfo const& geometry ); - StatusCode find_jet_mu( const LHCb::Particles* list_of_jets, const LHCb::Particle mu, LHCb::Particle& myjet, - IGeometryInfo const& geometry ); - - void fillInfo( const std::string& prefix, Tuples::Tuple& tuple ); - std::map fillProperties( LHCb::Particle* jet ); - std::map emptyProperties( void ); -}; - -// Declaration of the Algorithm Factory -DECLARE_COMPONENT( TupleToolJetsForB ) - -//============================================================================= -// Standard constructor, initializes variables -//============================================================================= -TupleToolJetsForB::TupleToolJetsForB( const std::string& type, const std::string& name, const IInterface* parent ) - : TupleToolBase( type, name, parent ), m_dva( 0 ), m_dist( 0 ) { - - declareInterface( this ); - - declareProperty( "ForceSamePV", m_forcePV = true, "Force only banned jets from same PV as initial B" ); - - declareProperty( "LocationJetsNoMu", m_loc_jetsnomu = "Phys/StdJetsNoJetIDNoMuFromB/Particles", - "Location of the jets where muons have been removed" ); - - declareProperty( "LocationJetsNoRemove", m_loc_jetsinc = "Phys/StdJetsNoJetID/Particles", - "Location of the jets where no particle has been removed" ); - - declareProperty( "LocationJetsForceB", m_loc_jetsb = "Phys/StdJetsNoJetIDForceB/Particles", - "Location of the jets where the B has been forced as a single particle" ); - - declareProperty( "UseVarsJetsNoMu", m_use_jetsnomu = true, - "Store variables from the jets in which muons from B have been removed" ); - - declareProperty( "UseVarsJetsWithMu", m_use_jetsinc = true, - "Store variables from the jets in which the B muons are present" ); - - declareProperty( "UseVarsJetsWithB", m_use_jetsb = true, - "Store variables from the jets in which the B candidate is present" ); - - declareProperty( "IndividualParticlePID", m_ind_part = 13, - "This is initially for Bmunu or similar, the PID that should be searched for" ); -} - -//==================================================================== -// Initialize DVAlg, etc -//==================================================================== -StatusCode TupleToolJetsForB::initialize() { - - // initialize the base class (the first action) - StatusCode sc = GaudiTool::initialize(); - if ( sc.isFailure() ) return sc; - - // initialize the dva algo - m_dva = Gaudi::Utils::getIDVAlgorithm( contextSvc(), this ); - if ( 0 == m_dva ) return Error( "Couldn't get parent DVAlgorithm", StatusCode::FAILURE ); - - // Get distance calculator - m_dist = m_dva->distanceCalculator(); - if ( !m_dist ) { return Error( "Unable to retrieve the IDistanceCalculator tool", StatusCode::FAILURE ); } - - m_TriggerTisTosTool = tool( "Hlt2TriggerTisTos", "Hlt2TriggerTisTos", this ); - if ( m_TriggerTisTosTool == 0 ) return Error( "Couldn't get requested jet tag tool", StatusCode::SUCCESS ); - - // initialize the nntag tool - // m_nnjettag = tool("LoKi::NNBTag",this); - - debug() << "Initialization correct" << endmsg; - return StatusCode::SUCCESS; -} - -//============================================================================== -// Determine the maximum ratio of shard LHCbID by an HLT2 obj in a jet -//============================================================================= -double TupleToolJetsForB::jetNNTag( const LHCb::Particle* jet ) { - - std::vector hltObjs = - m_TriggerTisTosTool->hltObjectSummaries( "Hlt2Topo.*Decision", 2, 2 ); - - unsigned int num = hltObjs.size(); - - std::vector AllIDs; - AllIDs.clear(); - getJetLHCbIDs( jet, AllIDs ).ignore( /* AUTOMATICALLY ADDED FOR gaudi/Gaudi!763 */ ); - double maxRatio = 0.; - for ( unsigned int i = 0; i < num; i++ ) { - std::vector hltLHCbIDs; - hltLHCbIDs.clear(); - getHltObjLHCbIDs( ( hltObjs[i] ), hltLHCbIDs ).ignore( /* AUTOMATICALLY ADDED FOR gaudi/Gaudi!763 */ ); - double TotN = (double)hltLHCbIDs.size(); - double TotMatching = 0.0; - double ratio = 0.; - for ( std::vector::iterator iID1 = hltLHCbIDs.begin(); iID1 != hltLHCbIDs.end(); iID1++ ) { - for ( std::vector::iterator iAllIDs = AllIDs.begin(); iAllIDs != AllIDs.end(); iAllIDs++ ) { - if ( ( *iID1 ).lhcbID() == ( *iAllIDs ).lhcbID() ) { - TotMatching += 1.0; - ratio = TotMatching / TotN; - } - } - } - - if ( ratio > maxRatio ) { maxRatio = ratio; } - } - - return maxRatio; -} - -//========================================================================= -// Get the LHCbID of HLT obj -//========================================================================= -StatusCode TupleToolJetsForB::getHltObjLHCbIDs( const LHCb::HltObjectSummary* sum, - std::vector& AllIDs ) const { - if ( 0 == sum ) return StatusCode::SUCCESS; - if ( sum->substructure().size() > 0 ) { - for ( SmartRefVector::const_iterator s = sum->substructure().begin(); - s != sum->substructure().end(); ++s ) - getHltObjLHCbIDs( *s, AllIDs ).ignore( /* AUTOMATICALLY ADDED FOR gaudi/Gaudi!763 */ ); - - const std::vector lIDs = sum->lhcbIDsFlattened(); - AllIDs.insert( AllIDs.end(), lIDs.begin(), lIDs.end() ); - - } else { - - const std::vector lIDs = sum->lhcbIDsFlattened(); - AllIDs.insert( AllIDs.end(), lIDs.begin(), lIDs.end() ); - } - - return StatusCode::SUCCESS; -} - -//========================================================================= -// Get daughters track the LHCbID of a jet. -//========================================================================= -StatusCode TupleToolJetsForB::getJetLHCbIDs( const LHCb::Particle* p, std::vector& AllIDs ) const { - - if ( p->particleID().abspid() == 98 ) { - LHCb::Particle::ConstVector daus = p->daughtersVector(); - for ( LHCb::Particle::ConstVector::iterator idaus = daus.begin(); idaus != daus.end(); idaus++ ) { - getJetLHCbIDs( ( *idaus ), AllIDs ).ignore( /* AUTOMATICALLY ADDED FOR gaudi/Gaudi!763 */ ); - } - } else { - const LHCb::ProtoParticle* proto = p->proto(); - if ( proto ) { - if ( proto->track() ) { - const std::vector lIDs = proto->track()->lhcbIDs(); - AllIDs.insert( AllIDs.end(), lIDs.begin(), lIDs.end() ); - } else { - for ( SmartRefVector::const_iterator iP = p->daughters().begin(); iP != p->daughters().end(); - ++iP ) { - getJetLHCbIDs( *iP, AllIDs ).ignore( /* AUTOMATICALLY ADDED FOR gaudi/Gaudi!763 */ ); - } - } - } - } - return StatusCode::SUCCESS; -} - -//============================================================================= -// Function to sort according to pT and same PV as B -//============================================================================= -void TupleToolJetsForB::pt_sorted_samePV( const LHCb::Particles& jets_list, const int pvkey, - std::vector& out_list, IGeometryInfo const& geometry ) { - std::vector myPtParticleVector; - debug() << jets_list.size() << " jets to be sorted" << endmsg; - for ( LHCb::Particles::const_iterator ijet = jets_list.begin(); ijet != jets_list.end(); ++ijet ) { - - // if pvkey<0, we skip this check - if ( m_forcePV && pvkey >= 0 ) { - const LHCb::VertexBase* BPV = m_dva->bestVertex( *ijet, geometry ); - // only add if the pv is the same as the one of the B - if ( BPV->key() != pvkey ) continue; - } - PtParticlePair mypair( ( *ijet )->pt(), ( *ijet ) ); - myPtParticleVector.push_back( mypair ); - } - // sort by pT (smaller to larger) - std::sort( myPtParticleVector.begin(), myPtParticleVector.end() ); - // and now reverse it to have from larger to smaller - std::reverse( myPtParticleVector.begin(), myPtParticleVector.end() ); - debug() << myPtParticleVector.size() << " jets sorted" << endmsg; - - // now store only the jets again - for ( std::vector::const_iterator ipair = myPtParticleVector.begin(); - ipair != myPtParticleVector.end(); ++ipair ) { - out_list.push_back( ipair->second->clone() ); - } - debug() << "Jet list ready" << endmsg; -} - -//============================================================================= -// Find jet with particle -//============================================================================= -StatusCode TupleToolJetsForB::find_jet_mu( const LHCb::Particles* list_of_jets, const LHCb::Particle mu, - LHCb::Particle& myjet, IGeometryInfo const& geometry ) { - - debug() << "Looking for jets with muon " << mu.key() << " inside" << endmsg; - LHCb::Particles jets_list; - for ( LHCb::Particles::const_iterator ijet = list_of_jets->begin(); ijet != list_of_jets->end(); ++ijet ) { - - // for each jet, loop in all the daughters - for ( SmartRefVector::const_iterator idau = ( *ijet )->daughters().begin(); - idau != ( *ijet )->daughters().end(); ++idau ) { - const LHCb::Particle dau = ( *( *idau ) ); - // check if the daughter has the same key as the particle - if ( !( dau.proto() ) ) continue; - if ( !( dau.proto()->track() ) ) continue; - if ( dau.proto()->track()->key() == mu.proto()->track()->key() ) { - jets_list.insert( *ijet, ( *ijet )->key() ); - debug() << "Jet " << ( *ijet )->key() << " has the muon inside!" << endmsg; - break; - } - } - } - // if more than 1, store the one with larger pT - if ( !jets_list.size() ) return StatusCode::FAILURE; - debug() << jets_list.size() << " jets found with the muon inside" << endmsg; - std::vector jets_list_sorted; - pt_sorted_samePV( jets_list, -1, jets_list_sorted, geometry ); // the -1 is to avoid any PV check - // this is not needed because the PV of the muon should be the same as the PV of the jet (since the muon is inside) - debug() << " These jets have been sorted " << endmsg; - if ( !jets_list_sorted.size() ) return StatusCode::FAILURE; - myjet = *( jets_list_sorted.at( 0 ) ); - return StatusCode::SUCCESS; -} - -//============================================================================= -// Find jet with bottom -//============================================================================= -StatusCode TupleToolJetsForB::find_jet_b( const LHCb::Particles* list_of_jets, LHCb::Particle& myjet, - IGeometryInfo const& geometry ) { - LHCb::Particles jets_list; - for ( LHCb::Particles::const_iterator ijet = list_of_jets->begin(); ijet != list_of_jets->end(); ++ijet ) { - // for each jet, loop in all the daughters and store the jet if a B is part of the daughters - for ( SmartRefVector::const_iterator idau = ( *ijet )->daughters().begin(); - idau != ( *ijet )->daughters().end(); ++idau ) { - if ( ( *idau )->particleID().hasBottom() ) { - jets_list.insert( *ijet, ( *ijet )->key() ); - debug() << "Jet " << ( *ijet )->key() << " has the B inside!" << endmsg; - break; - } - } - } - // save the one with larger pT - if ( !jets_list.size() ) return StatusCode::FAILURE; - debug() << jets_list.size() << " jets found with the B inside" << endmsg; - std::vector jets_list_sorted; - pt_sorted_samePV( jets_list, -1, jets_list_sorted, geometry ); // the -1 is to avoid any PV check, - // this is not needed because the PV of the B should be the same as the PV of the jet (since the B is inside) - if ( !jets_list_sorted.size() ) return StatusCode::FAILURE; - debug() << " These jets have been sorted " << endmsg; - myjet = *( jets_list_sorted.at( 0 ) ); - return StatusCode::SUCCESS; -} - -//============================================================================= -// Empty properties list -//============================================================================= -std::map TupleToolJetsForB::emptyProperties( void ) { - std::map out; - out["Px"] = -10.; - out["Py"] = -10.; - out["Pz"] = -10.; - out["PT"] = -10.; - out["JetWidth"] = -10.; - out["NNTag"] = -10.; - out["MNF"] = -10.; - debug() << "empty dict created" << endmsg; - return out; -} - -//============================================================================= -// Empty properties list -//============================================================================= -std::map TupleToolJetsForB::fillProperties( LHCb::Particle* jet ) { - std::map out; - out["Px"] = jet->momentum().x(); - out["Py"] = jet->momentum().y(); - out["Pz"] = jet->momentum().z(); - out["PT"] = jet->pt(); - out["JetWidth"] = LoKi::Cuts::INFO( 9007, -10. )( jet ); - out["MNF"] = LoKi::Cuts::INFO( 9012, -10. )( jet ); - out["NNTag"] = jetNNTag( jet ); - debug() << "Dictionary created for jet " << jet->key() << endmsg; - debug() << "with value " << out << endmsg; - return out; -} - -//============================================================================= -// Fill Output m_map -//============================================================================= -void TupleToolJetsForB::fillInfo( const std::string& prefix, Tuples::Tuple& tuple ) { - bool test = true; - - if ( m_use_jetsnomu ) { - test &= tuple->column( prefix + "_JETNOMU1PX", m_JetNoMu1["Px"] ); - test &= tuple->column( prefix + "_JETNOMU1PY", m_JetNoMu1["Py"] ); - test &= tuple->column( prefix + "_JETNOMU1PZ", m_JetNoMu1["Pz"] ); - test &= tuple->column( prefix + "_JETNOMU1PT", m_JetNoMu1["PT"] ); - test &= tuple->column( prefix + "_JETNOMU1JETWIDTH", m_JetNoMu1["JetWidth"] ); - test &= tuple->column( prefix + "_JETNOMU1NNTAG", m_JetNoMu1["NNTag"] ); - test &= tuple->column( prefix + "_JETNOMU1MNF", m_JetNoMu1["MNF"] ); - test &= tuple->column( prefix + "_JETNOMU2PX", m_JetNoMu2["Px"] ); - test &= tuple->column( prefix + "_JETNOMU2PY", m_JetNoMu2["Py"] ); - test &= tuple->column( prefix + "_JETNOMU2PZ", m_JetNoMu2["Pz"] ); - test &= tuple->column( prefix + "_JETNOMU2PT", m_JetNoMu2["PT"] ); - test &= tuple->column( prefix + "_JETNOMU2JETWIDTH", m_JetNoMu2["JetWidth"] ); - test &= tuple->column( prefix + "_JETNOMU2NNTAG", m_JetNoMu2["NNTag"] ); - test &= tuple->column( prefix + "_JETNOMU2MNF", m_JetNoMu2["MNF"] ); - test &= tuple->column( prefix + "_JETNOMU3PX", m_JetNoMu3["Px"] ); - test &= tuple->column( prefix + "_JETNOMU3PY", m_JetNoMu3["Py"] ); - test &= tuple->column( prefix + "_JETNOMU3PZ", m_JetNoMu3["Pz"] ); - test &= tuple->column( prefix + "_JETNOMU3PT", m_JetNoMu3["PT"] ); - test &= tuple->column( prefix + "_JETNOMU3JETWIDTH", m_JetNoMu3["JetWidth"] ); - test &= tuple->column( prefix + "_JETNOMU3NNTAG", m_JetNoMu3["NNTag"] ); - test &= tuple->column( prefix + "_JETNOMU3MNF", m_JetNoMu3["MNF"] ); - } - - if ( m_use_jetsinc ) { - test &= tuple->column( prefix + "_JETMU1PX", m_JetMu1["Px"] ); - test &= tuple->column( prefix + "_JETMU1PY", m_JetMu1["Py"] ); - test &= tuple->column( prefix + "_JETMU1PZ", m_JetMu1["Pz"] ); - test &= tuple->column( prefix + "_JETMU1PT", m_JetMu1["PT"] ); - test &= tuple->column( prefix + "_JETMU1JETWIDTH", m_JetMu1["JetWidth"] ); - test &= tuple->column( prefix + "_JETMU1NNTAG", m_JetMu1["NNTag"] ); - test &= tuple->column( prefix + "_JETMU1MNF", m_JetMu1["MNF"] ); - if ( !( m_onemu ) ) { - test &= tuple->column( prefix + "_JETMU2PX", m_JetMu2["Px"] ); - test &= tuple->column( prefix + "_JETMU2PY", m_JetMu2["Py"] ); - test &= tuple->column( prefix + "_JETMU2PZ", m_JetMu2["Pz"] ); - test &= tuple->column( prefix + "_JETMU2PT", m_JetMu2["PT"] ); - test &= tuple->column( prefix + "_JETMU2JETWIDTH", m_JetMu2["JetWidth"] ); - test &= tuple->column( prefix + "_JETMU2NNTAG", m_JetMu2["NNTag"] ); - test &= tuple->column( prefix + "_JETMU2MNF", m_JetMu2["MNF"] ); - } - } - if ( m_use_jetsb ) { - test &= tuple->column( prefix + "_JETBPX", m_JetB["Px"] ); - test &= tuple->column( prefix + "_JETBPY", m_JetB["Py"] ); - test &= tuple->column( prefix + "_JETBPZ", m_JetB["Pz"] ); - test &= tuple->column( prefix + "_JETBPT", m_JetB["PT"] ); - test &= tuple->column( prefix + "_JETBJETWIDTH", m_JetB["JetWidth"] ); - test &= tuple->column( prefix + "_JETBNNTAG", m_JetB["NNTag"] ); - test &= tuple->column( prefix + "_JETBMNF", m_JetB["MNF"] ); - } - if ( !test ) Warning( "Error in filling values " + prefix, StatusCode::SUCCESS, 1 ).ignore(); -} - -//============================================================================= -// Fill Jets RelatedInfo structure -//============================================================================= -StatusCode TupleToolJetsForB::fill( const LHCb::Particle* top, const LHCb::Particle* part, const std::string& head, - Tuples::Tuple& tuple, IGeometryInfo const& geometry ) { - - const std::string prefix = fullName( head ); - - debug() << "The top particle is " << top->key() << endmsg; - debug() << "And the particle is " << part->key() << endmsg; - - m_onemu = true; // in principle start with only one muon - m_JetNoMu1 = emptyProperties(); - m_JetNoMu2 = emptyProperties(); - m_JetNoMu3 = emptyProperties(); - m_JetMu1 = emptyProperties(); - m_JetMu2 = emptyProperties(); - m_JetB = emptyProperties(); - fillInfo( prefix, tuple ); - - debug() << "Filled empty dicts" << endmsg; - - // only fill infos for top particle! - if ( part != top ) return StatusCode::SUCCESS; - - LHCb::Particle mu1; - LHCb::Particle mu2; - - // get bestPV of the top particle - const LHCb::VertexBase* BPV = m_dva->bestVertex( top, geometry ); - - // now find the RecVertex that is closest to the refitted one - double dist, distc2_tmp, distc2; - distc2 = 1e6; - LHCb::VertexBase* closePV = NULL; - LHCb::RecVertex::Container* verts = getIfExists( LHCb::RecVertexLocation::Primary ); - // create a list of pairs ipchi2/vertex - for ( LHCb::RecVertex::Container::const_iterator iv = verts->begin(); iv != verts->end(); iv++ ) { - StatusCode sc = m_dist->distance( BPV, ( *iv ), dist, distc2_tmp ); - if ( sc.isFailure() ) { - debug() << "Failure obtaining IPchi2" << endmsg; - continue; - } - if ( distc2_tmp < distc2 ) { - closePV = ( *iv ); - distc2 = distc2_tmp; - } - } - int bpvkey; - if ( closePV ) - bpvkey = closePV->key(); - else - bpvkey = 0; - debug() << "The top particle is associated to PV " << bpvkey << endmsg; - - // this is for Bmunu (m_ind_particle = 13) - if ( top->particleID().pid() == m_ind_part || top->particleID().pid() == ( ( -1 ) * m_ind_part ) ) { - mu1 = ( *top ); - m_onemu = true; - m_use_jetsb = false; - } - // and this for Bsmumu - else { - mu1 = *( top->daughters().at( 0 ) ); - mu2 = *( top->daughters().at( 1 ) ); - m_onemu = false; - } - - debug() << "m_onemu=" << m_onemu << endmsg; - debug() << "m_use_jetsb=" << m_use_jetsb << endmsg; - - if ( m_use_jetsnomu ) { - debug() << "Jets no mu" << endmsg; - if ( exist( m_loc_jetsnomu ) ) { - const LHCb::Particles* stdjets_nomu_0 = get( m_loc_jetsnomu ); - // sort according to pT and same PV as B - std::vector stdjets_nomu; - pt_sorted_samePV( *stdjets_nomu_0, bpvkey, stdjets_nomu, geometry ); - debug() << "Looking at " << stdjets_nomu.size() << "jets" << endmsg; - if ( stdjets_nomu.size() > 0 ) m_JetNoMu1 = fillProperties( stdjets_nomu.at( 0 ) ); - if ( stdjets_nomu.size() > 1 ) m_JetNoMu2 = fillProperties( stdjets_nomu.at( 1 ) ); - if ( stdjets_nomu.size() > 2 ) m_JetNoMu3 = fillProperties( stdjets_nomu.at( 2 ) ); - debug() << "Jets info filled " << endmsg; - } else - debug() << "No jets found" << endmsg; - } - - if ( m_use_jetsinc ) { - debug() << "Jets with mu" << endmsg; - if ( exist( m_loc_jetsinc ) ) { - const LHCb::Particles* stdjets_inc = get( m_loc_jetsinc ); - LHCb::Particle myjet1; - StatusCode sc1 = find_jet_mu( stdjets_inc, mu1, myjet1, geometry ); - if ( sc1.isSuccess() ) { - m_JetMu1 = fillProperties( &myjet1 ); - debug() << "Jets with mu1, top pT" << myjet1.pt() << endmsg; - } - - if ( !m_onemu ) { - LHCb::Particle myjet2; - StatusCode sc2 = find_jet_mu( stdjets_inc, mu2, myjet2, geometry ); - if ( sc2.isSuccess() ) { - debug() << "Jets with mu2, top pT" << myjet2.pt() << endmsg; - m_JetMu2 = fillProperties( &myjet2 ); - } - } - } else - debug() << "No jets found" << endmsg; - } - - if ( m_use_jetsb ) { - debug() << "Jets with B" << endmsg; - if ( exist( m_loc_jetsb ) ) { - const LHCb::Particles* stdjets_forceb = get( m_loc_jetsb ); - LHCb::Particle myjet3; - StatusCode sc3 = find_jet_b( stdjets_forceb, myjet3, geometry ); - if ( sc3.isSuccess() ) { - debug() << "Jets with B, top pT" << myjet3.pt() << endmsg; - m_JetB = fillProperties( &myjet3 ); - } - } else - debug() << "No jets found" << endmsg; - } - - fillInfo( prefix, tuple ); - return StatusCode::SUCCESS; -} diff --git a/Phys/DecayTreeTupleJets/src/TupleToolWZJets.cpp b/Phys/DecayTreeTupleJets/src/TupleToolWZJets.cpp deleted file mode 100644 index 1a9a3b897f4762f8d2525ca222c40f7b11d4e799..0000000000000000000000000000000000000000 --- a/Phys/DecayTreeTupleJets/src/TupleToolWZJets.cpp +++ /dev/null @@ -1,364 +0,0 @@ -/*****************************************************************************\ -* (c) Copyright 2000-2018 CERN for the benefit of the LHCb Collaboration * -* * -* This software is distributed under the terms of the GNU General Public * -* Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". * -* * -* In applying this licence, CERN does not waive the privileges and immunities * -* granted to it by virtue of its status as an Intergovernmental Organization * -* or submit itself to any jurisdiction. * -\*****************************************************************************/ - -#include "TupleToolJetsBase.h" - -#include "LoKi/AParticleCuts.h" -#include "LoKi/ParticleCuts.h" -#include "LoKi/PhysTypes.h" - -#include "Kernel/FilterParticlesBase.h" -#include "Kernel/IJetMaker.h" -#include "Kernel/IParticleFilter.h" -#include "Kernel/IParticlePropertySvc.h" -#include "Kernel/IParticleTupleTool.h" -#include "Kernel/ParticleProperty.h" - -#include "Event/Particle.h" - -#include "GaudiAlg/Tuple.h" -#include "GaudiAlg/TupleObj.h" - -#include "boost/assign.hpp" -#include "boost/lexical_cast.hpp" - -#include -#include -#include -#include -#include - -/** - * @author Albert Bursche - */ -class TupleToolWZJets : public TupleToolJetsBase, virtual public IParticleTupleTool { - -public: - TupleToolWZJets( const std::string& type, const std::string& name, const IInterface* parent ); - StatusCode fill( const LHCb::Particle*, const LHCb::Particle*, const std::string&, Tuples::Tuple&, - IGeometryInfo const& ) override; - StatusCode initialize() override; - -private: - std::vector m_decayParticles; - - /// Check if your track belongs to your decay or not - bool isParticleInDecay( const LHCb::Particle* part ); - - /// Save all particles in your decay descriptor in a vector - void SaveDecayChainParticles( const LHCb::Particle* top ); - - std::string m_BaseName; - // std::string m_BosonContainer; - std::vector m_PartContainer; - unsigned int m_MaxJets; - bool m_IsoJetAbsID; - // Tuples::Tuple* m_tuple; - std::string m_prefix; - const IJetMaker* m_AdditionalJetMaker; - const IJetMaker* m_IsoJetMaker; - const IParticleFilter* m_LokiAddJetFilter; - const IParticleFilter* m_LokiIsoJetFilter; - const LHCb::IParticlePropertySvc* m_ppSvc; - unsigned int m_magic; // magic number to identify the decay products in the jet - - LoKi::Types::Fun m_DPHI; - LoKi::Types::Fun m_DETA; - LoKi::Types::Fun m_DR2; - - LHCb::Particles& GetParticles(); - void AddDecProducts( LHCb::Particles& ); - bool StoreAdditionalJets( const IJetMaker::Jets& AddJets ); - bool MatchAndStoreIsoJets( const IJetMaker::Jets& IsoJets ); - bool WriteJetComparisonToTuple( const LHCb::Particle* jet, std::string prefix ); - void addBasicParticles( std::map& particleCharges, LHCb::Particles& myParts, - LHCb::Particle::ConstVector parts ); -}; - -//============================================================================= -// Standard constructor, initializes variables -//============================================================================= -TupleToolWZJets::TupleToolWZJets( const std::string& type, const std::string& name, const IInterface* parent ) - : TupleToolJetsBase( type, name, parent ) - , m_ppSvc( NULL ) - , m_magic( 528 ) - , m_DPHI( LoKi::Cuts::ONE ) - , m_DETA( LoKi::Cuts::ONE ) - , m_DR2( LoKi::Cuts::ONE ) { - declareInterface( this ); - declareProperty( "BaseName", m_BaseName = "jet", - "Configure this if you want to run this tool more than once in a job." ); - declareProperty( "ParticleContainer", m_PartContainer = std::vector(), - "Where to find the particles to make the jets of" ); - declareProperty( "MaxJets", m_MaxJets = 4, "Maximal number of jets to be stored in the tuple" ); - declareProperty( "IsoJetAbsID", m_IsoJetAbsID = false, - "Use AbsID for naming the isojet variables (change this if you get spurious segfaults)" ); -} - -StatusCode TupleToolWZJets::initialize() { - const StatusCode sc = TupleToolBase::initialize(); - if ( sc.isFailure() ) return sc; - // PP Svc - m_ppSvc = svc( "LHCb::ParticlePropertySvc", true ); - // get LoKi objects - m_AdditionalJetMaker = tool( "LoKi::FastJetMaker", "AdditionalJetMaker", this ); - m_IsoJetMaker = tool( "LoKi::FastJetMaker", "IsoJetMaker", this ); - m_LokiAddJetFilter = tool( "LoKi::Hybrid::FilterCriterion", "AdditionalJetsFilter", this ); - m_LokiIsoJetFilter = tool( "LoKi::Hybrid::FilterCriterion", "IsolationJetsFilter", this ); - return sc; -} -StatusCode TupleToolWZJets::fill( const LHCb::Particle* top, const LHCb::Particle* P, const std::string& /* head */, - Tuples::Tuple& tuple, IGeometryInfo const& ) { - m_tuple = &tuple; - m_prefix = m_BaseName; //+fullName(head); - - // intitalise LoKi comparators to reference particle - m_DPHI = LoKi::Cuts::DPHI( P->momentum().Phi() ); - m_DETA = LoKi::Cuts::DETA( P->momentum().Eta() ); - m_DR2 = LoKi::Cuts::DR2( P->momentum() ); - bool test = true; - LHCb::Particles& myParts = GetParticles(); - - // Get particles in decay - m_decayParticles.clear(); - if ( msgLevel( MSG::DEBUG ) ) debug() << "Filling particle with ID " << top->particleID().pid() << endmsg; - m_decayParticles.push_back( P->clone() ); - SaveDecayChainParticles( P ); - IJetMaker::Jets AddJets; // jets in the event additional to the particle in question - IJetMaker::Jets IsoJets; // jets containg the particle in question. Used to make an isolation criterion - test &= m_AdditionalJetMaker->makeJets( myParts.begin(), myParts.end(), AddJets ); - if ( msgLevel( MSG::DEBUG ) ) - debug() << "Recieved" << AddJets.size() << "additional jets from the jet algorithm." << endmsg; - AddDecProducts( myParts ); - test &= m_IsoJetMaker->makeJets( myParts.begin(), myParts.end(), IsoJets ); - if ( msgLevel( MSG::DEBUG ) ) - debug() << "Recieved " << AddJets.size() << " isolation jet canditates from the jet algorithm." << endmsg; - - // match IsoJets to particles - test &= StoreAdditionalJets( AddJets ); - test &= MatchAndStoreIsoJets( IsoJets ); - - if ( !exist( "/Event/Phys/" + m_BaseName + "IsoCollection/Particles" ) ) - put( &myParts, "/Event/Phys/" + m_BaseName + "IsoCollection/Particles" ); - else if ( msgLevel( MSG::WARNING ) ) - warning() << "Cannot write to TES at /Event/Phys/" + m_BaseName + "IsoCollection/Particles" << endmsg; - if ( !exist( "/Event/Phys/" + m_BaseName + "AddJets/Particles" ) ) { - LHCb::Particles* jets = new LHCb::Particles(); - for ( IJetMaker::Jets::iterator iJet = AddJets.begin(); AddJets.end() != iJet; ++iJet ) jets->insert( *iJet ); - put( jets, "/Event/Phys/" + m_BaseName + "AddJets/Particles" ); - } else if ( msgLevel( MSG::WARNING ) ) - warning() << "Cannot write to TES at /Event/Phys/" + m_BaseName + "AddJets/Particles" << endmsg; - if ( !exist( "/Event/Phys/" + m_BaseName + "IsoJets/Particles" ) ) { - LHCb::Particles* jets = new LHCb::Particles(); - for ( IJetMaker::Jets::iterator iJet = IsoJets.begin(); IsoJets.end() != iJet; ++iJet ) jets->insert( *iJet ); - put( jets, "/Event/Phys/" + m_BaseName + "IsoJets/Particles" ); - } else if ( msgLevel( MSG::WARNING ) ) - warning() << "Cannot write to TES at /Event/Phys/" + m_BaseName + "IsoJets/Particles" << endmsg; - // In case the objects cannot be saved in TES some memory gets lost! - // But I can not call delete on these objects yet because I don't know what happens later. - - return StatusCode( test ); -} - -//============================================================================= -// Save the particles in the decay chain (recursive function) -//============================================================================= -void TupleToolWZJets::SaveDecayChainParticles( const LHCb::Particle* top ) { - - // -- Get the daughters of the top particle - const SmartRefVector& daughters = top->daughters(); - - // -- Fill all the daugthers in m_decayParticles - for ( SmartRefVector::const_iterator idau = daughters.begin(); idau != daughters.end(); ++idau ) { - - // -- If the particle is stable, save it in the vector, or... - if ( ( *idau )->isBasicParticle() ) { - if ( msgLevel( MSG::DEBUG ) ) debug() << "Filling particle with ID " << ( *idau )->particleID().pid() << endmsg; - m_decayParticles.push_back( ( *idau )->clone() ); - } else { - // -- if it is not stable, call the function recursively - m_decayParticles.push_back( ( *idau )->clone() ); - if ( msgLevel( MSG::DEBUG ) ) debug() << "Filling particle with ID " << ( *idau )->particleID().pid() << endmsg; - SaveDecayChainParticles( ( *idau ) ); - } - } -} - -//============================================================================= -// Check if the particle is already in the decay -//============================================================================= -bool TupleToolWZJets::isParticleInDecay( const LHCb::Particle* part ) { - bool isInDecay = false; - const LHCb::ProtoParticle* proto1 = part->proto(); - if ( !proto1 ) { - warning() << "Could not retrieve protoparticle! Cannot check overlap!" << endmsg; - return false; - } - const LHCb::Track* track = proto1->track(); - for ( std::vector::iterator it = m_decayParticles.begin(); it != m_decayParticles.end(); ++it ) { - const LHCb::ProtoParticle* proto = ( *it )->proto(); - if ( proto ) { - const LHCb::Track* myTrack = proto->track(); - if ( myTrack == track ) { - if ( msgLevel( MSG::DEBUG ) ) debug() << "Track is in decay, skipping it" << endmsg; - isInDecay = true; - } - } - } - return isInDecay; -} -LHCb::Particles& TupleToolWZJets::GetParticles() { - // -- Get all particles in the event to cluster jets - LHCb::Particle::ConstVector inputParts; - for ( std::vector::const_iterator InputContainer = m_PartContainer.begin(); - InputContainer != m_PartContainer.end(); ++InputContainer ) { - if ( msgLevel( MSG::DEBUG ) ) debug() << "Getting particles from: " << *InputContainer << endmsg; - if ( exist( *InputContainer ) ) { - LHCb::Particle::Range addInp = get( *InputContainer ); - inputParts.insert( inputParts.begin(), addInp.begin(), addInp.end() ); - } - } - // filter the decay products from the collection - // this filter only looks for overlag with the decay products - //(other filters can be applied with a filter desktop before running the tuple) - LHCb::Particles& myParts = *new LHCb::Particles(); - std::map particleCharges = boost::assign::map_list_of( -1, 0 )( 0, 0 )( 1, 0 ); // counter - addBasicParticles( particleCharges, myParts, inputParts ); - - if ( m_verbose ) { - ( *m_tuple ) - ->column( m_prefix + "_ChargedTracksUsed", particleCharges[-1] + particleCharges[+1] ) - .ignore( /* AUTOMATICALLY ADDED FOR gaudi/Gaudi!763 */ ); - ( *m_tuple ) - ->column( m_prefix + "_NeutralObjectsUsed", particleCharges[0] ) - .ignore( /* AUTOMATICALLY ADDED FOR gaudi/Gaudi!763 */ ); - ( *m_tuple ) - ->column( m_prefix + "_PositiveTracksUsed", particleCharges[+1] ) - .ignore( /* AUTOMATICALLY ADDED FOR gaudi/Gaudi!763 */ ); - ( *m_tuple ) - ->column( m_prefix + "_NegativeTracksUsed", particleCharges[-1] ) - .ignore( /* AUTOMATICALLY ADDED FOR gaudi/Gaudi!763 */ ); - } - - return myParts; -} - -void TupleToolWZJets::addBasicParticles( std::map& particleCharges, LHCb::Particles& myParts, - LHCb::Particle::ConstVector inputParts ) { - for ( LHCb::Particle::ConstVector::const_iterator parts = inputParts.begin(); parts != inputParts.end(); ++parts ) - if ( ( *parts )->isBasicParticle() ) { - if ( !isParticleInDecay( *parts ) ) { - myParts.insert( new LHCb::Particle( **parts ) ); - particleCharges[( *parts )->charge()]++; - } - } else - addBasicParticles( particleCharges, myParts, ( *parts )->daughtersVector() ); -} - -void TupleToolWZJets::AddDecProducts( LHCb::Particles& myParts ) { - int PartID = 0; // counter for decay product (needed later when matching IsoJets) - for ( std::vector::iterator idau = m_decayParticles.begin(); idau != m_decayParticles.end(); ++idau ) - if ( ( *idau )->isBasicParticle() ) { - ( *idau )->addInfo( LHCb::Particle::LastGlobal + m_magic, PartID++ ); - // myParts.push_back(&**idau); - myParts.insert( new LHCb::Particle( **idau ) ); - } - if ( msgLevel( MSG::DEBUG ) ) debug() << "Added " << PartID << " particles to the collection." << endmsg; -} -bool TupleToolWZJets::StoreAdditionalJets( const IJetMaker::Jets& AddJets ) { - bool test = true; - unsigned int numJets = 0; - for ( IJetMaker::Jets::const_iterator iJet = AddJets.begin(); AddJets.end() != iJet; ++iJet ) - if ( ( *m_LokiAddJetFilter )( *iJet ) ) { - numJets = numJets + 1; - if ( numJets <= m_MaxJets ) - test &= WriteJetComparisonToTuple( *iJet, m_prefix + "_Jet" + boost::lexical_cast( numJets ) ); - } else if ( msgLevel( MSG::DEBUG ) ) - debug() << "Jet number " << std::distance( (IJetMaker::Jets::const_iterator)AddJets.begin(), iJet ) - << " failed selection." << endmsg; - for ( unsigned int i = numJets + 1; i <= m_MaxJets; i++ ) // fill remaining jets slots in tuple with dummys - test &= WriteJetComparisonToTuple( NULL, m_prefix + "_Jet" + boost::lexical_cast( i ) ); - test &= ( *m_tuple )->column( m_prefix + "_NumJets", numJets ); - return test; -} -bool TupleToolWZJets::MatchAndStoreIsoJets( const IJetMaker::Jets& IsoJets ) { - bool test = true; - std::vector isoJetFound( m_decayParticles.size() ); - for ( std::vector::iterator it = isoJetFound.begin(); it != isoJetFound.end(); ++it ) *it = false; - for ( IJetMaker::Jets::const_iterator iJet = IsoJets.begin(); IsoJets.end() != iJet; ++iJet ) { - std::vector::iterator ThisIsoJetFound = isoJetFound.begin(); - for ( std::vector::const_iterator DecProduct = m_decayParticles.begin(); - DecProduct != m_decayParticles.end(); ++DecProduct ) { - for ( SmartRefVector::const_iterator daughter = ( *iJet )->daughters().begin(); - daughter != ( *iJet )->daughters().end(); ++daughter ) - if ( ( *DecProduct )->info( LHCb::Particle::LastGlobal + m_magic, 1000 ) == - ( *daughter )->info( LHCb::Particle::LastGlobal + m_magic, -1000 ) && - ( *m_LokiIsoJetFilter )( *iJet ) ) { - const LHCb::ParticleProperty* ppp = - m_ppSvc->find( ( LHCb::ParticleID )( ( *DecProduct )->particleID().abspid() ) ); - if ( !ppp ) { - std::ostringstream mess; - mess << "Unknown ParticleID " << ( *DecProduct )->particleID().abspid(); - Exception( mess.str() ); - } - if ( m_IsoJetAbsID ) - test &= WriteJetComparisonToTuple( *iJet, ppp->name() ); - else - test &= WriteJetComparisonToTuple( *iJet, ppp->name() ); - if ( ( *ThisIsoJetFound ) && msgLevel( MSG::WARNING ) ) warning() << "Found more than one IsoJet!" << endmsg; - *ThisIsoJetFound = true; - } - ++ThisIsoJetFound; - } - } - { - std::vector::iterator ThisIsoJetFound = isoJetFound.begin(); - for ( std::vector::const_iterator DecProduct = m_decayParticles.begin(); - DecProduct != m_decayParticles.end(); ++DecProduct ) - if ( !*ThisIsoJetFound++ ) // write default value to tuple - { - const LHCb::ParticleProperty* ppp = - m_ppSvc->find( ( LHCb::ParticleID )( ( *DecProduct )->particleID().abspid() ) ); - if ( 0 == ppp ) { - err() << "Unknown PID " << ( *DecProduct )->particleID().abspid() << endmsg; - Exception( "Unknown PID" ); - } - if ( m_IsoJetAbsID ) - test &= WriteJetComparisonToTuple( NULL, m_BaseName + "IsoJet" + ppp->name() ); - else - test &= WriteJetComparisonToTuple( NULL, m_BaseName + "IsoJet" + ppp->name() ); - if ( msgLevel( MSG::DEBUG ) ) debug() << "IsoJet missing!" << endmsg; - } - } - return test; -} -bool TupleToolWZJets::WriteJetComparisonToTuple( const LHCb::Particle* jet, std::string prefix ) { - // filter plus and minus signs out to the prefix (dublicated in TuplToolJetsBase) - std::map replacements; - replacements["+"] = "plus"; - replacements["-"] = "minus"; - for ( std::map::iterator it = replacements.begin(); it != replacements.end(); ++it ) { - size_t point = 0; - while ( ( point = prefix.find( it->first ) ) != std::string::npos ) - prefix = prefix.replace( point, it->second.size(), it->second ); - } - - bool result = true; - if ( m_verbose ) { - result &= ( *m_tuple )->column( prefix + "_DETA", jet ? m_DETA( jet ) : -10.0 ); - result &= ( *m_tuple )->column( prefix + "_DPHI", jet ? m_DPHI( jet ) : -10.0 ); - result &= ( *m_tuple )->column( prefix + "_DR", jet ? sqrt( m_DR2( jet ) ) : -1.0 ); - } - return result &= WriteJetToTuple( jet, prefix ); -} - -// Declaration of the Tool Factory -DECLARE_COMPONENT( TupleToolWZJets ) diff --git a/Phys/DecayTreeTupleMC/CMakeLists.txt b/Phys/DecayTreeTupleMC/CMakeLists.txt deleted file mode 100644 index 750d1280bd695d09ae520ceb8387bb7f3fbacd93..0000000000000000000000000000000000000000 --- a/Phys/DecayTreeTupleMC/CMakeLists.txt +++ /dev/null @@ -1,54 +0,0 @@ -############################################################################### -# (c) Copyright 2000-2021 CERN for the benefit of the LHCb Collaboration # -# # -# This software is distributed under the terms of the GNU General Public # -# Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". # -# # -# In applying this licence, CERN does not waive the privileges and immunities # -# granted to it by virtue of its status as an Intergovernmental Organization # -# or submit itself to any jurisdiction. # -############################################################################### -#[=======================================================================[.rst: -Phys/DecayTreeTupleMC ---------------------- -#]=======================================================================] - -gaudi_add_module(DecayTreeTupleMC - SOURCES - src/MCTupleToolAngles.cpp - src/MCTupleToolDecayType.cpp - src/MCTupleToolEventType.cpp - src/MCTupleToolHierarchy.cpp - src/MCTupleToolInteractions.cpp - src/MCTupleToolKinematic.cpp - src/MCTupleToolPID.cpp - src/MCTupleToolPrimaries.cpp - src/MCTupleToolPrompt.cpp - src/MCTupleToolReconstructed.cpp - src/MCTupleToolRedecay.cpp - src/MCTupleToolTOS.cpp - src/TupleToolMCBackgroundInfo.cpp - src/TupleToolMCPVAssociation.cpp - src/TupleToolMCTruth.cpp - src/TupleToolPV2MC.cpp - LINK - Analysis::DecayTreeTupleBaseLib - Gaudi::GaudiAlgLib - Gaudi::GaudiKernel - GSL::gsl - LHCb::GenEvent - LHCb::HltEvent - LHCb::LHCbKernel - LHCb::MCAssociators - LHCb::MCEvent - LHCb::MCInterfaces - LHCb::PartPropLib - LHCb::PhysEvent - LHCb::PhysInterfacesLib - LHCb::RecEvent - LHCb::RelationsLib - Phys::DaVinciInterfacesLib - Phys::DaVinciMCKernelLib - Phys::LoKiPhysLib - ROOT::GenVector -) diff --git a/Phys/DecayTreeTupleMC/doc/release.notes b/Phys/DecayTreeTupleMC/doc/release.notes deleted file mode 100644 index da12ae514069b0575a4614ed83c1adb9592600e5..0000000000000000000000000000000000000000 --- a/Phys/DecayTreeTupleMC/doc/release.notes +++ /dev/null @@ -1,65 +0,0 @@ -!----------------------------------------------------------------------------- -! Package : Phys/DecayTreeTupleMC -! Responsible : Chris Jones -! Purpose : MC tuple tools -!----------------------------------------------------------------------------- - -!===================== DecayTreeTupleMC v1r7 2016-03-07 ====================== - -! 2016-02-25 - Francesco Dettori - - Add flag "StoreStablePropertime" (off by default) to MCTupleToolKinematic - to allow propertime and endvertex to be stored for particles considered - stable in LHCb, e.g. for the Kaon in the K-> pi pi pi decay. - -!===================== DecayTreeTupleMC v1r6 2015-06-02 ====================== - -! 2015-06-02 - Eduardo Rodrigues -- Various declareProperty changed to setProperty to remove compilation warnings - of the kind "WARNING duplicated property name 'ExtraName', - see https://its.cern.ch/jira/browse/GAUDI-1023". - -!========================= DecayTreeTupleMC v1r5 2014-12-15 ========================= - -! 2014-12-15 - Eduardo Rodrigues -- Tagging new version with trivial but undocumented changes that happened 6 weeks ago - -!========================= DecayTreeTupleMC v1r4 2013-08-01 ========================= - -! 2013-07-05 - S. Blusk -- Change MCTupleToolKinematic to choose end vertex as either a decay or - hadronic interaction. - -! 2013-07-05 - Chris Jones - - Clean up TupleToolMCTruth a bit. - -! 2013-06-27 - Chris Jones - - Clean up a bit MCTupleToolInteractions ... - -!========================= DecayTreeTupleMC v1r3 2013-06-13 ========================= - -! 2013-05-17 - Chris Jones - - Remove unused data members to fix clang warnings. - -! 2013-05-14 - Chris Jones - - Patch TupleToolGeneration to not throw an exception if a NULL LHCb::HepMCEvent - pointer is found, as this is now normal in MC12 data (and thus this tool - currently does not work for these MC samples, and needs updating...). - -!========================= DecayTreeTupleMC v1r2 2013-05-07 ========================= - -! 2013-Apr-11 - Patrick Spradlin - - Update MCTupleToolPrompt to make it a real MCTupleTool - -!========================= DecayTreeTupleMC v1r1 2013-04-05 ========================= - -! 2013-03-25 - Chris Jones - - Update MCTupleToolPrompt to use LHCb::ParticlePropertySvc - -!========================= DecayTreeTupleMC v1r0 2012-11-30 ========================= - -! 2012-11-29 - Marco Clemencic - - Added CMake configuration file. - -! 2012-11-22 - Chris Jones - - First version. Split of from monolithic Phys/DecayTreeTuple package. - Contains the tools that require or provide MC information. diff --git a/Phys/DecayTreeTupleMC/src/MCTupleToolAngles.cpp b/Phys/DecayTreeTupleMC/src/MCTupleToolAngles.cpp deleted file mode 100644 index bbc0c9064837f44a8f773d646ca67ae37c716098..0000000000000000000000000000000000000000 --- a/Phys/DecayTreeTupleMC/src/MCTupleToolAngles.cpp +++ /dev/null @@ -1,69 +0,0 @@ -/*****************************************************************************\ -* (c) Copyright 2000-2018 CERN for the benefit of the LHCb Collaboration * -* * -* This software is distributed under the terms of the GNU General Public * -* Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". * -* * -* In applying this licence, CERN does not waive the privileges and immunities * -* granted to it by virtue of its status as an Intergovernmental Organization * -* or submit itself to any jurisdiction. * -\*****************************************************************************/ -// Include files -#include "gsl/gsl_sys.h" - -// from Gaudi -#include "GaudiKernel/PhysicalConstants.h" -#include "GaudiKernel/Vector3DTypes.h" - -// local -#include "MCTupleToolAngles.h" - -#include "GaudiAlg/Tuple.h" -#include "GaudiAlg/TupleObj.h" - -#include "Event/MCParticle.h" - -using namespace LHCb; -//----------------------------------------------------------------------------- -// Implementation file for class : MCTupleToolAngles -// -// 2009-01-19 : Patrick Koppenburg -//----------------------------------------------------------------------------- - -// Declaration of the Tool Factory -DECLARE_COMPONENT( MCTupleToolAngles ) - -//============================================================================= -// Standard constructor, initializes variables -//============================================================================= -MCTupleToolAngles::MCTupleToolAngles( const std::string& type, const std::string& name, const IInterface* parent ) - : TupleToolBase( type, name, parent ) { - declareInterface( this ); -} - -//============================================================================= -// Destructor -//============================================================================= -MCTupleToolAngles::~MCTupleToolAngles() {} - -//============================================================================= -// Fill -//============================================================================= -StatusCode MCTupleToolAngles::fill( const LHCb::MCParticle* mother, const LHCb::MCParticle* mcp, - const std::string& head, Tuples::Tuple& tuple ) { - const std::string prefix = fullName( head ); - - bool test = true; - - double cosT = -999.; - - if ( 0 != mcp && 0 != mother && mcp != mother ) cosT = cosTheta( mother->momentum(), mcp->momentum() ); - // fill the tuple: - test &= tuple->column( prefix + "_TRUECosTheta", cosT ); - if ( isVerbose() ) test &= tuple->column( prefix + "_TRUETheta", acos( cosT ) ); - if ( msgLevel( MSG::DEBUG ) && 0 != mcp && 0 != mother ) - debug() << mother->particleID().pid() << " " << mother->momentum() << " " << mcp->particleID().pid() << " " - << mcp->momentum() << endmsg; - - return StatusCode( test ); -} diff --git a/Phys/DecayTreeTupleMC/src/MCTupleToolAngles.h b/Phys/DecayTreeTupleMC/src/MCTupleToolAngles.h deleted file mode 100644 index 21df6520d50ed75e5383ea9376a6e4ed7d882050..0000000000000000000000000000000000000000 --- a/Phys/DecayTreeTupleMC/src/MCTupleToolAngles.h +++ /dev/null @@ -1,55 +0,0 @@ -/*****************************************************************************\ -* (c) Copyright 2000-2018 CERN for the benefit of the LHCb Collaboration * -* * -* This software is distributed under the terms of the GNU General Public * -* Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". * -* * -* In applying this licence, CERN does not waive the privileges and immunities * -* granted to it by virtue of its status as an Intergovernmental Organization * -* or submit itself to any jurisdiction. * -\*****************************************************************************/ -#ifndef MCTUPLETOOLANGLES_H -#define MCTUPLETOOLANGLES_H 1 - -// Include files -// from Gaudi -#include "DecayTreeTupleBase/TupleToolBase.h" -#include "GaudiKernel/Vector4DTypes.h" -#include "Kernel/IMCParticleTupleTool.h" // Interface -#include "Math/Boost.h" - -/** @class MCTupleToolAngles MCTupleToolAngles.h - * - * Fill MC Particle with decay angle in mother frame - * - * - head_TRUECosTheta : angle in mother's frame - * - * \sa TupleToolAngles, DecayTreeTuple, MCDecayTreeTuple - * - * @author Patrick Koppenburg - * @date 2009-01-19 - */ - -class MCTupleToolAngles : public TupleToolBase, virtual public IMCParticleTupleTool { - -public: - /// Standard constructor - MCTupleToolAngles( const std::string& type, const std::string& name, const IInterface* parent ); - - virtual ~MCTupleToolAngles(); ///< Destructor - - StatusCode fill( const LHCb::MCParticle*, const LHCb::MCParticle*, const std::string&, Tuples::Tuple& ) override; - -private: - inline double cosTheta( const Gaudi::LorentzVector& mother, const Gaudi::LorentzVector& mcp ) { - ROOT::Math::Boost boost( mother.BoostToCM() ); - const Gaudi::XYZVector boostedParticle = ( boost( mcp ) ).Vect().unit(); - const Gaudi::XYZVector boostedMother = mother.Vect().unit(); - double cosT = boostedParticle.Dot( boostedMother ); - if ( msgLevel( MSG::VERBOSE ) ) - verbose() << mother << " " << mcp << " " << boostedMother << " " << boostedParticle << " " << cosT << endmsg; - return cosT; - } -}; - -#endif // MCTUPLETOOLANGLES_H diff --git a/Phys/DecayTreeTupleMC/src/MCTupleToolDecayType.cpp b/Phys/DecayTreeTupleMC/src/MCTupleToolDecayType.cpp deleted file mode 100644 index 14e27a3967a05c315bf939e3d664176613405b68..0000000000000000000000000000000000000000 --- a/Phys/DecayTreeTupleMC/src/MCTupleToolDecayType.cpp +++ /dev/null @@ -1,229 +0,0 @@ -/*****************************************************************************\ -* (c) Copyright 2000-2018 CERN for the benefit of the LHCb Collaboration * -* * -* This software is distributed under the terms of the GNU General Public * -* Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". * -* * -* In applying this licence, CERN does not waive the privileges and immunities * -* granted to it by virtue of its status as an Intergovernmental Organization * -* or submit itself to any jurisdiction. * -\*****************************************************************************/ -// Include files -#include "gsl/gsl_sys.h" -// from Gaudi -#include "GaudiKernel/PhysicalConstants.h" -// local -#include "MCTupleToolDecayType.h" - -#include "GaudiAlg/Tuple.h" -#include "GaudiAlg/TupleObj.h" - -#include "Event/MCParticle.h" -#include "Event/Particle.h" - -using namespace LHCb; - -//----------------------------------------------------------------------------- -// Implementation file for class : MCTupleToolDecayType -// -// 2009-05-01 : Rob Lambert -//----------------------------------------------------------------------------- - -// Declaration of the Tool Factory -// actually acts as a using namespace TupleTool -DECLARE_COMPONENT( MCTupleToolDecayType ) - -//============================================================================= -// Standard constructor, initializes variables -//============================================================================= -MCTupleToolDecayType::MCTupleToolDecayType( const std::string& type, const std::string& name, const IInterface* parent ) - : TupleToolBase( type, name, parent ) - , m_mother( 0 ) - , m_fillSlowFind( 0 ) - , m_fillPseudoFind( 0 ) - , m_findEventTypes( 0 ) - , m_hasEventType( 0 ) - , m_hasMCDecay( "" ) - , m_mcEventType( 0 ) - , m_mcDecay( 0 ) { - declareInterface( this ); - - // categorise the mcmother of this mcparticle, not the associate itself - declareProperty( "mother", m_mother = false ); - - // categorise the ultimate mcmother of this mcparticle, not the associate itself - declareProperty( "top", m_mother = false ); - - // search through using decay strings, very slow method - declareProperty( "fillSlowFind", m_fillSlowFind = false ); - - // construct the event types logically, much faster but less accurate - declareProperty( "fillPseudoFind", m_fillPseudoFind = true ); - - // the full list of all event types to consider. - declareProperty( "allEventTypes", m_findEventTypes = std::vector( 0 ) ); - - // list of event types, the number of these types in the event will appear as an entry in the ntuple - declareProperty( "hasEventTypes", m_hasEventType = std::vector( 0 ) ); - - // look for this decay string aswell - declareProperty( "hasMCDecay", m_hasMCDecay = "" ); - - // extra name. MCP in this case. - setProperty( "ExtraName", "MCP" ).ignore( /* AUTOMATICALLY ADDED FOR gaudi/Gaudi!763 */ ); -} - -//============================================================================= - -StatusCode MCTupleToolDecayType::initialize() { - StatusCode sc = TupleToolBase::initialize(); - if ( sc.isFailure() ) return sc; - - m_mcEventType = tool( "MCEventTypeFinder", "Event_Type", this ); - m_mcDecay = tool( "MCDecayFinder", "Decay_Type", this ); - - vec2set( m_findEventTypes, m_findEventTypeSet ); - vec2set( m_hasEventType, m_hasEventTypeSet ); - - if ( !m_findEventTypes.empty() ) sc = m_mcEventType->setEventTypes( m_findEventTypeSet ); - if ( !m_findEventTypes.empty() && sc.isFailure() ) { - warning() << "Error setting the event types starting with " << m_findEventTypes[0] << endmsg; - m_findEventTypes.clear(); - } - - if ( m_mcDecay && m_hasMCDecay != "" ) sc = m_mcDecay->setDecay( m_hasMCDecay ); - if ( sc.isFailure() ) { - warning() << "Error setting this decay string " << m_hasMCDecay << endmsg; - m_mcDecay = NULL; - m_hasMCDecay = ""; - } - if ( msgLevel( MSG::DEBUG ) ) { - // output all the options - debug() << "MCTupleToolDecayType initialised. Values are set as follows:" << endmsg; - debug() << "-m_mother " << m_mother << endmsg; - debug() << "-m_fillSlowFind " << m_fillSlowFind << endmsg; - debug() << "-m_fillPseudoFind " << m_fillPseudoFind << endmsg; - debug() << "-m_hasMCDecay " << m_hasMCDecay << endmsg; - debug() << "-m_findEventTypeSet.size() " << m_findEventTypeSet.size() << endmsg; - debug() << "-m_hasEventTypeSet.size() " << m_hasEventTypeSet.size() << endmsg; - debug() << "-m_mcEventType " << ( m_mcEventType != NULL ) << endmsg; - debug() << "-m_mcDecay " << ( m_mcDecay != NULL ) << endmsg; - } - - return StatusCode::SUCCESS; -} - -StatusCode MCTupleToolDecayType::fill( const LHCb::MCParticle*, const LHCb::MCParticle* mcp, const std::string& head, - Tuples::Tuple& tuple ) { - const std::string prefix = fullName( head ); - - if ( msgLevel( MSG::DEBUG ) ) debug() << "Filling MCTupleToolDecayType" << endmsg; - - // The fill method is is two stages and is steered by the options. - // Firstly, if asked, (fillWholeEvent) the full event is searched for all types - // Secondly, if asked, (fillAssociated) the MC associated particle is searched for all types - - StatusCode sc = StatusCode::SUCCESS; - - bool test = true; - - if ( msgLevel( MSG::DEBUG ) ) debug() << "finding event types for MCAssociate" << endmsg; - LHCb::EventTypeSet foundfull; - LHCb::EventTypeSet foundfast; - - // pointer is ready, prepare the sets: - if ( mcp ) { - verbose() << "found MC Particle" << endmsg; - // fast or slow? - if ( m_fillSlowFind ) sc = m_mcEventType->findDecayType( foundfull, mcp ); - if ( sc.isFailure() ) { - warning() << "Could not perform the fill using the slow method, reverting to the fast method" << endmsg; - m_fillSlowFind = false; - m_fillPseudoFind = true; - } - - if ( m_fillPseudoFind ) sc = m_mcEventType->constructDecayType( foundfast, mcp ); - if ( sc.isFailure() ) { - warning() << "Could not perform the fill using the fast method," - << " I therefore cannot find the overall event type" << endmsg; - m_fillPseudoFind = false; - } - } - if ( msgLevel( MSG::DEBUG ) ) debug() << "filling info for MCAssociate" << endmsg; - if ( m_fillSlowFind ) { - test &= tuple->column( prefix + "_numFoundTypes", foundfull.size() ); - // insert "found" as an farray - std::vector foundvec( 0 ); - set2vec( foundfull, foundvec ); - test &= tuple->farray( prefix + "_MCP_FoundTypes", foundvec, prefix + "_FoundLen", 20 ); - - if ( !m_hasEventTypeSet.empty() ) // book the matching types - { - - LHCb::EventTypeSet intersection; - std::set_intersection( foundfull.begin(), foundfull.end(), m_hasEventTypeSet.begin(), m_hasEventTypeSet.end(), - std::inserter( intersection, intersection.begin() ), LHCb::EventTypeComp() ); - - // bool foundGiven=(intersection.size()>0); - test &= tuple->column( prefix + "_numMatchingTypes", intersection.size() ); - if ( msgLevel( MSG::DEBUG ) ) debug() << "booked intersection of size:" << intersection.size() << endmsg; - // insert "found" as an farray - std::vector _foundvec( 0 ); - set2vec( intersection, _foundvec ); - test &= tuple->farray( prefix + "_MatchingTypes", _foundvec, prefix + "_MatchLen", m_hasEventTypeSet.size() ); - } - } - if ( m_fillPseudoFind ) { - test &= tuple->column( prefix + "_numPseudoTypes", foundfast.size() ); - // insert "found" as an farray - std::vector foundvec( 0 ); - set2vec( foundfast, foundvec ); - test &= tuple->farray( prefix + "_PseudoTypes", foundvec, prefix + "_MCP_PseudoLen", 20 ); - - if ( !m_hasEventTypeSet.empty() ) // book the matching types - { - - LHCb::EventTypeSet intersection; - std::set_intersection( foundfast.begin(), foundfast.end(), m_hasEventTypeSet.begin(), m_hasEventTypeSet.end(), - std::inserter( intersection, intersection.begin() ), LHCb::EventTypeComp() ); - - // bool foundGiven=(intersection.size()>0); - test &= tuple->column( prefix + "_numMatchingPseudoTypes", intersection.size() ); - if ( msgLevel( MSG::DEBUG ) ) debug() << "booked intersection of size:" << intersection.size() << endmsg; - // insert "found" as an farray - std::vector _foundvec( 0 ); - set2vec( intersection, _foundvec ); - test &= tuple->farray( prefix + "_MatchingPseudoTypes", _foundvec, prefix + "_MCP_MatchPseudoLen", - m_hasEventTypeSet.size() ); - } - } - - if ( m_hasMCDecay != "" && m_mcDecay ) { - bool hasMCDecay = false; - LHCb::MCParticle::ConstVector dummyvec( 0 ); // stupid way, but is the only way! - if ( mcp ) { - dummyvec.push_back( mcp ); - hasMCDecay = m_mcDecay->hasDecay( dummyvec ); - } - - test &= tuple->column( prefix + "_hasGivenDecay", hasMCDecay ); - // use the standard decay finding method - } - - if ( msgLevel( MSG::DEBUG ) ) debug() << "done and returning" << endmsg; - - return StatusCode( test ); -} - -bool MCTupleToolDecayType::vec2set( std::vector& avec, LHCb::EventTypeSet& aset ) { - aset.clear(); - for ( std::vector::iterator n = avec.begin(); n != avec.end(); n++ ) { aset.insert( *n ); } - return ( aset.size() > 0 ); -} - -bool MCTupleToolDecayType::set2vec( LHCb::EventTypeSet& aset, std::vector& avec ) { - avec.clear(); - avec.reserve( aset.size() ); - for ( LHCb::EventTypeSet::iterator n = aset.begin(); n != aset.end(); n++ ) { avec.push_back( *n ); } - return ( avec.size() > 0 ); -} diff --git a/Phys/DecayTreeTupleMC/src/MCTupleToolDecayType.h b/Phys/DecayTreeTupleMC/src/MCTupleToolDecayType.h deleted file mode 100755 index 067f6609a9b959ff6c788579e2e1adbcf2cbe2d1..0000000000000000000000000000000000000000 --- a/Phys/DecayTreeTupleMC/src/MCTupleToolDecayType.h +++ /dev/null @@ -1,257 +0,0 @@ -/*****************************************************************************\ -* (c) Copyright 2000-2018 CERN for the benefit of the LHCb Collaboration * -* * -* This software is distributed under the terms of the GNU General Public * -* Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". * -* * -* In applying this licence, CERN does not waive the privileges and immunities * -* granted to it by virtue of its status as an Intergovernmental Organization * -* or submit itself to any jurisdiction. * -\*****************************************************************************/ -#ifndef TUPLETOOLMCDECAYTYPE_H -#define TUPLETOOLMCDECAYTYPE_H 1 - -// Include files -// from Gaudi -#include "DecayTreeTupleBase/TupleToolBase.h" -#include "Event/GenCollision.h" -#include "Event/GenHeader.h" -#include "Kernel/IMCParticleTupleTool.h" // Interface - -// struct Particle2MCLinker; -#include "Kernel/IBackgroundCategory.h" -#include "Kernel/IDaVinciAssociatorsWrapper.h" -#include "Kernel/Particle2MCLinker.h" -#include "MCInterfaces/IMCDecayFinder.h" -#include "MCInterfaces/IMCEventTypeFinder.h" -#include -/** @class MCTupleToolDecayType MCTupleToolDecayType.h jborel/MCTupleToolDecayType.h - * - * \brief - * \sa DecayTreeTuple - * - * @author Robert Lambert - * @date 2009-02-25 - * - * This TupleTool enables you to output the LHCb EventTypes for the MC particle associated to this candidate - * and/or search for a given MCDecay string - * The association should be done in TupleToolMCTruth - * - * There are two methods used to find the event type (Pseudo or Slow) - * and several places you can look for the event type (GenHeader, FullEvent, MCAssociate) - * - * CONFIGURATION: - - * You will also need to configure the EvtTypeSvc(), which takes the list of all possible decays from Gauss - - * EvtTypeSvc().EvtTypesFile='...fullpath.../table_event.txt' - - * Usually the file resides in $DECFILESROOT/doc/table_event.txt, copy and ship it with your job - - * METHODS: - - * - - * A) The Pseudo method: guesses the event type, by constructing the possible types - - * based on the definition of event types in the LHCb note - - * this is fast, works on all decays, but is ambiguous. - - * To look for inclusive types, this is the best method. - - * - - * B) The Slow Method : Finds the event type based on the decay string. - - * This is accurate, but relies on the string being correct - - * in the .dec file of this decay. Most of the time this is not the case. - - * To check the decay file you've written is correct, this is the best method. - - * - - * WHERE TO LOOK: - - * - - * 1) The GenHeader : The GenHeader contains the event type which was generated. - - * If this is all you need, and you want no information on the other - - * possible decays in this event, you can stop here. - - * If all you want to do is find the heaviest quark in the event, - - * use the TupleToolGeneration. - - * - - * 2) The Full Event : Every MCParticle in the event is checked to see how it decayed. - - * The full list of all possible event types of this event can then be found. - - * - - * 3) The MCAssociate : The decay of the MCAssociate, or it's mother, or the top of the tree, is checked. - - * A categorisation of any fully or partially reconstructed backgrounds - - * can then be made. - - * This output is complimentary to background category and the MCHierachy and - - * can be used as a rudimentary categorisation of backgrounds. - - * - - * For method (3) use this TupleTool. For methods (1) and (2) use the TupleToolMCEventType - - * - - * - - * OPTIONS: - - * - * - - * mother bool Actually categorise the mc mother of this particle, not the associate itself - - * by default this is false - - * top bool Actually categorise the ultimate mcmother of this mcparticle, not the associate itself - - * by default this is false - - * - - * UseChi2Method bool assosciate using chi2 - - * by default this is false - - * InputLocations bool Associator input location. - - * by default this is empty, fine for most cases - - * - - * fillSlowFind bool search through using decay strings, very slow method - - * by default this is false - - * fillPseudoFind bool construct the event types logically, much faster but less accurate - - * by default this is true - - * - - * allEventTypes std::vector the full list of all event types to consider. for the slow find. - - * This is ignored by the fast find. - - * By default this is the whole list in the DekFile doc - - * hasEventTypes std::vector list of event types, the number of these types in the event - - * will appear as an entry in the ntuple - - * by default this is empty - - * hasMCDecay std::string look for this decay string aswell - - * by default this is empty - - * - - * ENTRIES: - - * - - * Depending on the options, different entries will be written out. - - * By default, only the Pseudo event types will be looked for - - * - - * _MCP_FoundTypes (farray) List of all found event types for the assosciate - - * _MCP_FoundLen (unsigned int) Maximum length of this farray - - * _MCP_numFoundTypes (unsigned int) number of types found in this case - - * _MCP_MatchingTypes (farray) List of Event types which match those in hasEventType for the - assosciate - - * _MCP_MatchLen (unsigned int) Maximum length of this farray - - * _MCP_numMatchingTypes (unsigned int) How many of hasEventType there are in the Event Types for the - assosciate - - * - - * _MCP_PseudoTypes (farray) List of all found event types for the assosciate - - * _MCP_PseudoLen (unsigned int) Maximum length of this farray - - * _MCP_numPseudoTypes (unsigned int) number of pseudo types found in this case - - * _MCP_MatchingPseudoTypes (farray) List of Pseudo Event types which match those in hasEventType for - the MCP - - * _MCP_MatchPseudoLen (unsigned int) Maximum length of this farray - - * _MCP_numMatchingPseudoTypes (unsigned int) How many of hasEventType are in the Pseudo Event Types for the - assosciate - - * - - * _MCP_hasGivenDecay (bool) does this MCP decay by the string in hasMCDecay? - - * - */ - -class MCTupleToolDecayType : public TupleToolBase, virtual public IMCParticleTupleTool { - -public: - /// Standard constructor - MCTupleToolDecayType( const std::string& type, const std::string& name, const IInterface* parent ); - - virtual ~MCTupleToolDecayType(){}; ///< Destructor - - StatusCode fill( const LHCb::MCParticle*, const LHCb::MCParticle*, const std::string&, Tuples::Tuple& ) override; - - StatusCode initialize() override; - -private: - // const GaudiAlgorithm* getParent() const ; - - // Members which are set by the options: - - bool m_mother; //!< set by mother option categorise the mcmother of this mcparticle, not the associate itself - bool m_fillSlowFind; //< set by the fillSlowFind option, search through using decay strings - bool m_fillPseudoFind; //< set by the fillPseudoFind option, construct the event types logically, much faster but less - // accurate - - /// m_findEventTypes set by the allEventTypes option, the full list of all event types to consider. - std::vector m_findEventTypes; - /// m_hasEventType set by the hasEventType option, how many of this list of types appear in this event? - std::vector m_hasEventType; - std::string m_hasMCDecay; //< set by the hasMCDecay option, look for this decay string aswell - - // Other Members - - LHCb::EventTypeSet m_findEventTypeSet; //< loaded from m_findEventTypes - LHCb::EventTypeSet m_hasEventTypeSet; //< loaded from m_hasEventType - - IMCEventTypeFinder* m_mcEventType; //< the EventTypeFinder tool - IMCDecayFinder* m_mcDecay; //< the DecayTypeFinder tool - - /// convert a std::vector to a std::set - bool vec2set( std::vector& avec, LHCb::EventTypeSet& aset ); - bool set2vec( LHCb::EventTypeSet& aset, std::vector& avec ); - // want to cache genEventID/string?? -}; - -#endif // TUPLETOOLMCDECAYTYPE_H diff --git a/Phys/DecayTreeTupleMC/src/MCTupleToolEventType.cpp b/Phys/DecayTreeTupleMC/src/MCTupleToolEventType.cpp deleted file mode 100644 index 90064dc7c0f604db5496dc848b2fac459b5fe56a..0000000000000000000000000000000000000000 --- a/Phys/DecayTreeTupleMC/src/MCTupleToolEventType.cpp +++ /dev/null @@ -1,283 +0,0 @@ -/*****************************************************************************\ -* (c) Copyright 2000-2018 CERN for the benefit of the LHCb Collaboration * -* * -* This software is distributed under the terms of the GNU General Public * -* Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". * -* * -* In applying this licence, CERN does not waive the privileges and immunities * -* granted to it by virtue of its status as an Intergovernmental Organization * -* or submit itself to any jurisdiction. * -\*****************************************************************************/ -// Include files -// from Gaudi -#include "GaudiKernel/PhysicalConstants.h" -// local -#include "MCTupleToolEventType.h" - -#include "GaudiAlg/Tuple.h" -#include "GaudiAlg/TupleObj.h" - -#include "Event/Particle.h" - -using namespace LHCb; - -//----------------------------------------------------------------------------- -// Implementation file for class : MCTupleToolEventType -// -// 2009-03-04 : R Lambert -//----------------------------------------------------------------------------- - -// Declaration of the Tool Factory -// actually acts as a using namespace TupleTool -DECLARE_COMPONENT( MCTupleToolEventType ) - -//============================================================================= -// Standard constructor, initializes variables -//============================================================================= -MCTupleToolEventType::MCTupleToolEventType( const std::string& type, const std::string& name, const IInterface* parent ) - : TupleToolBase( type, name, parent ) - , m_fillGenEvent( 0 ) - , m_findGenEvent( 0 ) - , m_fillWholeEvent( 0 ) - , m_fillSlowFind( 0 ) - , m_fillPseudoFind( 0 ) - , m_findEventTypes( 0 ) - , m_hasEventType( 0 ) - , m_hasMCDecay( "" ) - , m_mcEventType( 0 ) - , m_mcDecay( 0 ) { - declareInterface( this ); - - // should I write out the gen event header? - declareProperty( "fillGenEvent", m_fillGenEvent = true ); - - // should I look for the generated type in the event? - declareProperty( "findGenEvent", m_findGenEvent = false ); - - // should I examine every MC particle in the event? - declareProperty( "fillWholeEvent", m_fillWholeEvent = true ); - - // search through using decay strings, very slow method - declareProperty( "fillSlowFind", m_fillSlowFind = false ); - - // construct the event types logically, much faster but less accurate - declareProperty( "fillPseudoFind", m_fillPseudoFind = true ); - - // the full list of all event types to consider.for the slow find. This is ignored by the fast/Pseudo find. - declareProperty( "allEventTypes", m_findEventTypes = std::vector( 0 ) ); - - // list of event types, the number of these types in the event will appear as an entry in the ntuple - declareProperty( "hasEventTypes", m_hasEventType = std::vector( 0 ) ); - - // look for this decay string aswell - declareProperty( "hasMCDecay", m_hasMCDecay = "" ); - - // extra name. EVT in this case. - setProperty( "ExtraName", "EVT" ).ignore( /* AUTOMATICALLY ADDED FOR gaudi/Gaudi!763 */ ); -} - -//============================================================================= - -StatusCode MCTupleToolEventType::initialize() { - if ( !TupleToolBase::initialize() ) return StatusCode::FAILURE; - StatusCode sc = StatusCode::SUCCESS; - - m_mcEventType = tool( "MCEventTypeFinder", "Event_Type", this ); - m_mcDecay = tool( "MCDecayFinder", "Decay_Type", this ); - - vec2set( m_findEventTypes, m_findEventTypeSet ); - vec2set( m_hasEventType, m_hasEventTypeSet ); - - if ( !m_findEventTypeSet.empty() ) sc = m_mcEventType->setEventTypes( m_findEventTypeSet ); - if ( !m_findEventTypeSet.empty() && sc.isFailure() ) { - warning() << "Error setting the event types starting with " << m_findEventTypes[0] << endmsg; - m_findEventTypes.clear(); - m_findEventTypeSet.clear(); - } - - if ( m_mcDecay && m_hasMCDecay != "" ) sc = m_mcDecay->setDecay( m_hasMCDecay ); - if ( sc.isFailure() ) { - warning() << "Error setting this decay string " << m_hasMCDecay << endmsg; - m_mcDecay = NULL; - m_hasMCDecay = ""; - } - if ( msgLevel( MSG::DEBUG ) ) { - // output all the options - debug() << "MCTupleToolEventType initialised. Values are set as follows:" << endmsg; - debug() << "-m_fillGenEvent " << m_fillGenEvent << endmsg; - debug() << "-m_findGenEvent " << m_findGenEvent << endmsg; - debug() << "-m_fillWholeEvent " << m_fillWholeEvent << endmsg; - debug() << "-m_fillSlowFind " << m_fillSlowFind << endmsg; - debug() << "-m_fillPseudoFind " << m_fillPseudoFind << endmsg; - debug() << "-m_hasMCDecay " << m_hasMCDecay << endmsg; - debug() << "-m_findEventTypeSet.size() " << m_findEventTypeSet.size() << endmsg; - debug() << "-m_hasEventTypeSet.size() " << m_hasEventTypeSet.size() << endmsg; - debug() << "-m_mcEventType " << ( m_mcEventType != NULL ) << endmsg; - debug() << "-m_mcDecay " << ( m_mcDecay != NULL ) << endmsg; - } - if ( !m_fillGenEvent && !m_fillWholeEvent ) - warning() << "Nothing to fill, choose at least one of" - << " fillGenEvent or fillWholeEvent" << endmsg; - - return StatusCode::SUCCESS; -} - -StatusCode MCTupleToolEventType::fill( Tuples::Tuple& tuple ) /*( const LHCb::Particle* - , const LHCb::Particle* P - , const std::string& - , Tuples::Tuple& tuple )*/ -{ - - const std::string prefix = fullName(); - - if ( msgLevel( MSG::DEBUG ) ) debug() << "Filling MCTupleToolEventType" << endmsg; - - // The fill method is is two stages and is steered by the options. - // Firstly, if asked, (fillWholeEvent) the full event is searched for all types - - StatusCode sc = StatusCode::SUCCESS; - - bool test = true; - - LHCb::EventTypeSet foundfull, foundfast; - - // 1) Find event types from full event - - // fast or slow? - if ( m_findGenEvent || m_fillWholeEvent ) { - if ( msgLevel( MSG::DEBUG ) ) debug() << "Running event type finder on full event" << endmsg; - // slow or fast method? - if ( m_fillSlowFind ) sc = m_mcEventType->findEventTypes( foundfull ); - if ( sc.isFailure() ) { - warning() << "Could not perform the fill using the slow method, reverting to the fast method" << endmsg; - m_fillSlowFind = false; - m_fillPseudoFind = true; - } - - if ( m_fillPseudoFind && msgLevel( MSG::DEBUG ) ) debug() << "Just about to call construct event types" << endmsg; - if ( m_fillPseudoFind ) sc = m_mcEventType->constructEventTypes( foundfast ); - if ( m_fillPseudoFind && msgLevel( MSG::DEBUG ) ) debug() << "Finished call to construct event types" << endmsg; - if ( sc.isFailure() ) { - warning() << "Could not perform the fill using the fast method, I therefore cannot find the overall event type" - << endmsg; - m_fillWholeEvent = m_findGenEvent = false; - } else if ( msgLevel( MSG::DEBUG ) || msgLevel( MSG::VERBOSE ) ) - debug() << "Found types on full event. All OK. fast:" << foundfast.size() << " slow:" << foundfull.size() - << endmsg; - } - - // add the generated event type, if it exists. - - if ( m_fillGenEvent ) { - - if ( msgLevel( MSG::DEBUG ) || msgLevel( MSG::VERBOSE ) ) debug() << "filling gen event" << endmsg; - LHCb::GenHeader* header = getIfExists( evtSvc(), LHCb::GenHeaderLocation::Default, false ); - if ( !header ) { - warning() << "The GenHeader could not be found, therefore it will not be filled" << endmsg; - m_fillGenEvent = false; - } else { - - long unsigned int genType = header->evType(); - - // add this to the tuple - test &= tuple->column( prefix + "GenEvent", genType ); - - if ( m_findGenEvent ) // find the event of this type :) - { - if ( m_fillSlowFind ) { - - bool foundGenType = ( foundfull.count( genType ) ); - test &= tuple->column( prefix + "hasGenEvent", foundGenType ); - if ( msgLevel( MSG::DEBUG ) || msgLevel( MSG::VERBOSE ) ) debug() << "Booked slow event find" << endmsg; - } - if ( m_fillPseudoFind ) { - - bool foundGenType = ( foundfast.count( genType ) ); - test &= tuple->column( prefix + "hasPseudoGenEvent", foundGenType ); - if ( msgLevel( MSG::DEBUG ) || msgLevel( MSG::VERBOSE ) ) debug() << "Booked fast event find" << endmsg; - } - } - } - } - - // add the event types for the whole event - - if ( m_fillWholeEvent ) { - if ( msgLevel( MSG::DEBUG ) ) debug() << "filling info for whole event" << endmsg; - if ( m_fillSlowFind ) { - - test &= tuple->column( prefix + "numFoundTypes", foundfull.size() ); - - // insert "found" as an farray - std::vector foundvec( 0 ); - set2vec( foundfull, foundvec ); - if ( msgLevel( MSG::DEBUG ) ) debug() << "ready to book vector of size:" << foundvec.size() << endmsg; - test &= tuple->farray( "FoundTypes", foundvec, "FoundLen", 20 ); - if ( msgLevel( MSG::DEBUG ) ) debug() << "booked vector of size:" << foundvec.size() << endmsg; - - if ( !m_hasEventTypeSet.empty() ) // book the matching types - { - - LHCb::EventTypeSet intersection; - std::set_intersection( foundfull.begin(), foundfull.end(), m_hasEventTypeSet.begin(), m_hasEventTypeSet.end(), - std::insert_iterator( intersection, intersection.begin() ), - LHCb::EventTypeComp() ); - - test &= tuple->column( prefix + "numMatchingTypes", intersection.size() ); - if ( msgLevel( MSG::DEBUG ) ) debug() << "booked intersection of size:" << intersection.size() << endmsg; - // insert "found" as an farray - std::vector _foundvec( 0 ); - set2vec( intersection, _foundvec ); - test &= tuple->farray( prefix + "MatchingTypes", _foundvec, prefix + "MatchLen", m_hasEventTypeSet.size() ); - } - } - if ( m_fillPseudoFind ) { - - test &= tuple->column( prefix + "numPseudoTypes", foundfast.size() ); - // insert "found" as an farray - std::vector foundvec( 0 ); - set2vec( foundfast, foundvec ); - if ( msgLevel( MSG::DEBUG ) ) debug() << "ready to book vector of size:" << foundvec.size() << endmsg; - test &= tuple->farray( prefix + "PseudoTypes", foundvec, prefix + "PseudoLen", 20 ); - if ( msgLevel( MSG::DEBUG ) ) debug() << "booked vector of size:" << foundvec.size() << endmsg; - - if ( !m_hasEventTypeSet.empty() ) // book the matching types - { - - LHCb::EventTypeSet intersection; - std::set_intersection( foundfast.begin(), foundfast.end(), m_hasEventTypeSet.begin(), m_hasEventTypeSet.end(), - std::insert_iterator( intersection, intersection.begin() ), - LHCb::EventTypeComp() ); - - test &= tuple->column( prefix + "numMatchingPseudoTypes", intersection.size() ); - if ( msgLevel( MSG::DEBUG ) ) debug() << "booked intersection of size:" << intersection.size() << endmsg; - // insert "found" as an farray - std::vector _foundvec( 0 ); - set2vec( intersection, _foundvec ); - test &= tuple->farray( prefix + "MatchingPseudoTypes", _foundvec, prefix + "MatchPseudoLen", - m_hasEventTypeSet.size() ); - } - } - if ( m_hasMCDecay != "" && m_mcDecay ) { - bool hasMCDecay = m_mcDecay->hasDecay(); - test &= tuple->column( prefix + "hasGivenDecay", hasMCDecay ); - // use the standard decay finding method - } - } - - if ( msgLevel( MSG::DEBUG ) || msgLevel( MSG::VERBOSE ) ) debug() << "done and returning" << endmsg; - return StatusCode( test ); -} - -bool MCTupleToolEventType::vec2set( std::vector& avec, LHCb::EventTypeSet& aset ) { - aset.clear(); - for ( std::vector::iterator n = avec.begin(); n != avec.end(); n++ ) { aset.insert( *n ); } - return ( aset.size() > 0 ); -} - -bool MCTupleToolEventType::set2vec( LHCb::EventTypeSet& aset, std::vector& avec ) { - avec.clear(); - avec.reserve( aset.size() ); - for ( LHCb::EventTypeSet::iterator n = aset.begin(); n != aset.end(); n++ ) { avec.push_back( *n ); } - return ( avec.size() > 0 ); -} diff --git a/Phys/DecayTreeTupleMC/src/MCTupleToolEventType.h b/Phys/DecayTreeTupleMC/src/MCTupleToolEventType.h deleted file mode 100755 index 143b2b1ed81dfc82aae582c4fc922176195bca96..0000000000000000000000000000000000000000 --- a/Phys/DecayTreeTupleMC/src/MCTupleToolEventType.h +++ /dev/null @@ -1,250 +0,0 @@ -/*****************************************************************************\ -* (c) Copyright 2000-2018 CERN for the benefit of the LHCb Collaboration * -* * -* This software is distributed under the terms of the GNU General Public * -* Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". * -* * -* In applying this licence, CERN does not waive the privileges and immunities * -* granted to it by virtue of its status as an Intergovernmental Organization * -* or submit itself to any jurisdiction. * -\*****************************************************************************/ -#ifndef MCTUPLETOOLEVENTTYPE_H -#define MCTUPLETOOLEVENTTYPE_H 1 - -// Include files -// from Gaudi -#include "DecayTreeTupleBase/TupleToolBase.h" -#include "Event/GenCollision.h" -#include "Event/GenHeader.h" -#include "Kernel/IEventTupleTool.h" // Interface - -// struct Particle2MCLinker; -#include "Kernel/IDaVinciAssociatorsWrapper.h" -#include "Kernel/Particle2MCLinker.h" -#include "MCInterfaces/IMCDecayFinder.h" -#include "MCInterfaces/IMCEventTypeFinder.h" -#include -/** @class MCTupleToolEventType MCTupleToolEventType.h jborel/MCTupleToolEventType.h - * - * \brief - * \sa DecayTreeTuple - * - * @author Robert Lambert - * @date 2009-02-25 - * - * This TupleTool enables you to output the LHCb EventTypes for this event and/or search for a given MCDecay string - * - * There are two methods used to find the event type (Pseudo or Slow) - * and several places you can look for the event type (GenHeader, FullEvent, MCAssociate) - * - * CONFIGURATION: - - * You will also need to configure the EvtTypeSvc(), which takes the list of all possible decays from Gauss - - * EvtTypeSvc().EvtTypesFile='...fullpath.../table_event.txt' - - * Usually the file resides in $DECFILESROOT/doc/table_event.txt, copy and ship it with your job - - * - * METHODS: - * - * A) The Pseudo method: guesses the event type, by constructing the possible types - - * based on the definition of event types in the LHCb note - - * this is fast, works on all decays, but is ambiguous. - - * To look for inclusive types, this is the best method. - * - - * B) The Slow Method : Finds the event type based on the decay string. - - * This is accurate, but relies on the string being correct - - * in the .dec file of this decay. Most of the time this is not the case. - - * To check the decay file you've written is correct, this is the best method. - - * - * WHERE TO LOOK: - - * - - * 1) The GenHeader : The GenHeader contains the event type which was generated. - - * If this is all you need, and you want no information on the other - - * possible decays in this event, you can stop here. - - * If all you want to do is find the heaviest quark in the event, - - * use the TupleToolGeneration - - * - * 2) The Full Event : Every MCParticle in the event is checked to see how it decayed. - - * The full list of all possible event types of this event can then be found. - - * - - * 3) The MCAssociate : The decay of the MCAssociate, or it's mother, or the top of the tree is checked. - - * A categorisation of any fully or partially reconstructed backgrounds - - * can then be made. - - * This output is complimentary to background category and the MCHierachy and - - * can be used as a rudimentary categorisation of backgrounds. - - * - * To check the GenHeader and the event (1,2), use this tool. - - * To check the MCAssociate (3), use TupleToolMCDecayType - - * - - * OPTIONS: - - * - * - - * fillGenEvent bool should I write out the gen event header? - - * by default this is true - - * findGenEvent bool should I look for the generated type in the event? - - * by default this is false - - * fillWholeEvent bool should I examine every MC particle in the event? - - * by default this is true - - * - - * fillSlowFind bool search through using decay strings, very slow method - - * by default this is false - - * fillPseudoFind bool construct the event types logically, much faster but less accurate - - * by default this is true - - * - - * allEventTypes std::vector the full list of all event types to consider. for the slow find. - - * This is ignored by the fast find. - - * By default this is the whole list in the DekFile doc - - * hasEventTypes std::vector list of event types, the number of these types in the event - - * will appear as an entry in the ntuple - - * by default this is empty - - * hasMCDecay std::string look for this decay string aswell - - * by default this is empty - - * - - * ENTRIES: - - * - - * Depending on the options, different entries will be written out. - - * By default, only the Pseudo event types will be looked for - - * - - * EVT_GenEvent (long unsigned int) The event type in the GenHeader - - * EVT_hasGenEvent (bool) Does the GenEvent decay string appear? - - * EVT_hasPseudoGenEvent (bool) is there a pseudo decay like the one generated? - - * - - * EVT_FoundTypes (farray) List of all found event types - - * EVT_FoundLen (unsigned int) Maximum length of this farray - - * EVT_numFoundTypes (unsigned int) number of types found in this case - - * EVT_MatchingTypes (farray) List of Event types which match those in hasEventType - - * EVT_MatchLen (unsigned int) Maximum length of this farray - - * EVT_numMatchingTypes (unsigned int) How many of hasEventType there are in the Event Types - - * - - * EVT_PseudoTypes (farray) List of all found event types - - * EVT_PseudoLen (unsigned int) Maximum length of this farray - - * EVT_numPseudoTypes (unsigned int) number of pseudo types found in this case - - * EVT_MatchingPseudoTypes (farray) List of Pseudo Event types which match those in hasEventType - - * EVT_MatchPseudoLen (unsigned int) Maximum length of this farray - - * EVT_numMatchingPseudoTypes (unsigned int) How many of hasEventType there are in the Pseudo Event Types - - * - - * EVT_hasGivenDecay (bool) does this event contain the decay in hasMCDecay - - * - * - */ - -class MCTupleToolEventType : public TupleToolBase, virtual public IEventTupleTool { -public: - /// Standard constructor - MCTupleToolEventType( const std::string& type, const std::string& name, const IInterface* parent ); - - virtual ~MCTupleToolEventType(){}; ///< Destructor - - StatusCode fill( Tuples::Tuple& ) override; /*( const LHCb::Particle* - , const LHCb::Particle* - , const std::string& - , Tuples::Tuple& );*/ - - StatusCode initialize() override; - // virtual StatusCode finalize(); - -private: - // Members which are set by the options: - - bool m_fillGenEvent; //< set by the fillGenEvent option, should I check the gen event header? - bool m_findGenEvent; //< set by the findGenEvent option, should I look for the gen event header in the events? - bool m_fillWholeEvent; //< set by the fillWholeEvent option, to fill info on the whole event - bool m_fillSlowFind; //< set by the fillSlowFind option, search through using decay strings - bool m_fillPseudoFind; //< set by the fillPseudoFind option, construct the event types logically, much faster but less - // accurate - - /// m_findEventTypes set by the allEventTypes option, the full list of all event types to consider. - std::vector m_findEventTypes; - /// m_hasEventType set by the hasEventType option, how many of this list of types appear in this event? - std::vector m_hasEventType; - std::string m_hasMCDecay; //< set by the hasMCDecay option, look for this decay string aswell - - // Other Members - - LHCb::EventTypeSet m_findEventTypeSet; //< loaded from m_findEventTypes - LHCb::EventTypeSet m_hasEventTypeSet; //< loaded from m_hasEventType - - IMCEventTypeFinder* m_mcEventType; //< the EventTypeFinder tool - IMCDecayFinder* m_mcDecay; //< the DecayTypeFinder tool - - /// convert a std::vector to a std::set - bool vec2set( std::vector& avec, LHCb::EventTypeSet& aset ); - bool set2vec( LHCb::EventTypeSet& aset, std::vector& avec ); -}; - -#endif // MCTUPLETOOLEVENTTYPE_H diff --git a/Phys/DecayTreeTupleMC/src/MCTupleToolHierarchy.cpp b/Phys/DecayTreeTupleMC/src/MCTupleToolHierarchy.cpp deleted file mode 100755 index 3162612219730aa1829abfcb8834730b309465b6..0000000000000000000000000000000000000000 --- a/Phys/DecayTreeTupleMC/src/MCTupleToolHierarchy.cpp +++ /dev/null @@ -1,88 +0,0 @@ -/*****************************************************************************\ -* (c) Copyright 2000-2018 CERN for the benefit of the LHCb Collaboration * -* * -* This software is distributed under the terms of the GNU General Public * -* Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". * -* * -* In applying this licence, CERN does not waive the privileges and immunities * -* granted to it by virtue of its status as an Intergovernmental Organization * -* or submit itself to any jurisdiction. * -\*****************************************************************************/ -// Include files -#include "gsl/gsl_sys.h" -// from Gaudi -#include "GaudiKernel/PhysicalConstants.h" -// local -#include "MCTupleToolHierarchy.h" - -#include "GaudiAlg/Tuple.h" -#include "GaudiAlg/TupleObj.h" - -#include "Event/MCParticle.h" -#include "Event/Particle.h" - -using namespace LHCb; - -//----------------------------------------------------------------------------- -// Implementation file for class : EventInfoTupleTool -// -// 2008-02-28 : Stephane Poss -//----------------------------------------------------------------------------- - -// Declaration of the Tool Factory -// actually acts as a using namespace TupleTool -DECLARE_COMPONENT( MCTupleToolHierarchy ) - -//============================================================================= -// Standard constructor, initializes variables -//============================================================================= -MCTupleToolHierarchy::MCTupleToolHierarchy( const std::string& type, const std::string& name, const IInterface* parent ) - : TupleToolBase( type, name, parent ) { - declareInterface( this ); -} - -//============================================================================= -StatusCode MCTupleToolHierarchy::fill( const LHCb::MCParticle*, const LHCb::MCParticle* mcp, const std::string& head, - Tuples::Tuple& tuple ) { - const std::string prefix = fullName( head ); - bool test = true; - - int mc_mother_id = 0; - int mc_mother_key = 0; - int mc_gd_mother_id = 0; - int mc_gd_mother_key = 0; - int mc_gd_gd_mother_id = 0; - int mc_gd_gd_mother_key = 0; - - // pointer is ready, prepare the values: - if ( mcp ) { - const MCParticle* mcpmom( 0 ); - mcpmom = mcp->mother(); - if ( mcpmom ) { - mc_mother_id = mcpmom->particleID().pid(); - mc_mother_key = mcpmom->key(); - const MCParticle* mcpmom_mom( 0 ); - mcpmom_mom = mcpmom->mother(); - if ( mcpmom_mom ) { - mc_gd_mother_id = mcpmom_mom->particleID().pid(); - mc_gd_mother_key = mcpmom_mom->key(); - const MCParticle* mcpmom_mom_mom( 0 ); - mcpmom_mom_mom = mcpmom_mom->mother(); - if ( mcpmom_mom_mom ) { - mc_gd_gd_mother_id = mcpmom_mom_mom->particleID().pid(); - mc_gd_gd_mother_key = mcpmom_mom_mom->key(); - } - } - } - } - - // fill the tuple: - test &= tuple->column( prefix + "_MC_MOTHER_ID", mc_mother_id ); - test &= tuple->column( prefix + "_MC_MOTHER_KEY", mc_mother_key ); - test &= tuple->column( prefix + "_MC_GD_MOTHER_ID", mc_gd_mother_id ); - test &= tuple->column( prefix + "_MC_GD_MOTHER_KEY", mc_gd_mother_key ); - test &= tuple->column( prefix + "_MC_GD_GD_MOTHER_ID", mc_gd_gd_mother_id ); - test &= tuple->column( prefix + "_MC_GD_GD_MOTHER_KEY", mc_gd_gd_mother_key ); - - return StatusCode( test ); -} diff --git a/Phys/DecayTreeTupleMC/src/MCTupleToolHierarchy.h b/Phys/DecayTreeTupleMC/src/MCTupleToolHierarchy.h deleted file mode 100755 index 433f2f1f61423ef85417f8a6432ad2232d268a9b..0000000000000000000000000000000000000000 --- a/Phys/DecayTreeTupleMC/src/MCTupleToolHierarchy.h +++ /dev/null @@ -1,58 +0,0 @@ -/*****************************************************************************\ -* (c) Copyright 2000-2018 CERN for the benefit of the LHCb Collaboration * -* * -* This software is distributed under the terms of the GNU General Public * -* Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". * -* * -* In applying this licence, CERN does not waive the privileges and immunities * -* granted to it by virtue of its status as an Intergovernmental Organization * -* or submit itself to any jurisdiction. * -\*****************************************************************************/ -#ifndef SPOSS_TUPLETOOLMCHIERARCHY_H -#define SPOSS_TUPLETOOLMCHIERARCHY_H 1 - -// Include files -// from Gaudi -#include "DecayTreeTupleBase/TupleToolBase.h" -#include "Kernel/IMCParticleTupleTool.h" // Interface - -// struct Particle2MCLinker; -#include "Kernel/IDaVinciAssociatorsWrapper.h" -#include "Kernel/Particle2MCLinker.h" - -/** @class MCTupleToolHierarchy - * - * \brief Fill MC hierarchy info if a link is present - * - * Requires association from TupleToolMCTruth, or a MCDecayTreeTuple - * - * - * - head_MC_MOTHER_ID : true mc mother ID - - * - head_MC_MOTHER_KEY : true mc mother key - - * - head_MC_GD_MOTHER_ID : grand mother ID - - * - head_MC_GD_MOTHER_KEY : grand mother key - - * - head_MC_GD_GD_MOTHER_ID : grand grand mother ID - - * - head_MC_GD_GD_MOTHER_KEY : grand grand mother key - - * \sa DecayTreeTuple - * - * @author Stephane Poss - * @date 2008-02-28 - */ -class MCTupleToolHierarchy : public TupleToolBase, virtual public IMCParticleTupleTool { - -public: - /// Standard constructor - MCTupleToolHierarchy( const std::string& type, const std::string& name, const IInterface* parent ); - - virtual ~MCTupleToolHierarchy(){}; ///< Destructor - - StatusCode fill( const LHCb::MCParticle*, const LHCb::MCParticle*, const std::string&, Tuples::Tuple& ) override; -}; - -#endif // SPOSS_TUPLETOOLMCHIERARCHY_H diff --git a/Phys/DecayTreeTupleMC/src/MCTupleToolInteractions.cpp b/Phys/DecayTreeTupleMC/src/MCTupleToolInteractions.cpp deleted file mode 100644 index a70eb156aab65935966e188298603f6e6bc21b34..0000000000000000000000000000000000000000 --- a/Phys/DecayTreeTupleMC/src/MCTupleToolInteractions.cpp +++ /dev/null @@ -1,141 +0,0 @@ -/*****************************************************************************\ -* (c) Copyright 2000-2018 CERN for the benefit of the LHCb Collaboration * -* * -* This software is distributed under the terms of the GNU General Public * -* Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". * -* * -* In applying this licence, CERN does not waive the privileges and immunities * -* granted to it by virtue of its status as an Intergovernmental Organization * -* or submit itself to any jurisdiction. * -\*****************************************************************************/ - -// local -#include "MCTupleToolInteractions.h" - -//----------------------------------------------------------------------------- -// Implementation file for class : GenerationTupleTool -// -// 2008-07-01 : Patrick Koppenburg -//----------------------------------------------------------------------------- - -using namespace Gaudi; -using namespace LHCb; - -// Declaration of the Tool Factory -DECLARE_COMPONENT( MCTupleToolInteractions ) - -//============================================================================= -// Standard constructor, initializes variables -//============================================================================= -MCTupleToolInteractions::MCTupleToolInteractions( const std::string& type, const std::string& name, - const IInterface* parent ) - : TupleToolBase( type, name, parent ), m_mean( 0. ), m_adjustmean( 0. ), m_normaliseAt( 0 ), m_useRecPV( false ) { - declareInterface( this ); - - // overwrite the mean value of interactions for this event - declareProperty( "Mean", m_mean = 0. ); - - // calculate a scaling factor to approximate this number of interactions per event - declareProperty( "AdjustMean", m_adjustmean = 0. ); - - // normalise the scaling factor such that it is equal to 1 at this value of I - declareProperty( "NormaliseAt", m_normaliseAt = 0 ); - - // use the #of reconstructed PVs, rather than the MC Collisions. - declareProperty( "UseRecPV", m_useRecPV = false ); - - // deprecated, use Verbose - // fill extra information on MCPV, MC Collisions and Reconstructed PVs - // declareProperty( "FillDetails", m_fillDetails=false ); - - // change the default PV location - declareProperty( "RecPVLocation", m_RecPVLocation = LHCb::RecVertexLocation::Primary ); - - // prefix to give to the variables, in case you want to use two copies of this tool - setProperty( "ExtraName", "EVT_Int" ).ignore( /* AUTOMATICALLY ADDED FOR gaudi/Gaudi!763 */ ); -} - -//============================================================================= - -StatusCode MCTupleToolInteractions::fill( Tuples::Tuple& tuple ) { - const std::string prefix = fullName(); - unsigned int n = 1; - int MCI = -1; - int MCPV = -1; - int RecPV = -1; - const LHCb::GenHeader* gh = get( LHCb::GenHeaderLocation::Default ); - - if ( gh && !gh->collisions().empty() ) { - MCI = gh->collisions().size(); - if ( msgLevel( MSG::VERBOSE ) ) verbose() << "retrieved I from genHeader" << endmsg; - } - - if ( MCI <= 0 || isVerbose() ) { - const LHCb::MCHeader* mch = get( LHCb::MCHeaderLocation::Default ); - if ( mch ) { MCPV = mch->primaryVertices().size(); } - } - - if ( isVerbose() || m_useRecPV ) { - const RecVertex::Container* PV = get( m_RecPVLocation ); - if ( PV ) { RecPV = PV->size(); } - } - if ( m_useRecPV && RecPV >= 0 ) { - n = RecPV; - } else if ( !m_useRecPV && MCI > 0 ) { - n = MCI; - } else if ( !m_useRecPV && MCPV > 0 ) { - n = MCPV; - } else { - Warning( "Could not retrieve number of interactions, filling as if n=1", StatusCode::SUCCESS ).ignore(); - } - - double mean = m_mean; - if ( mean == 0. ) { - if ( msgLevel( MSG::VERBOSE ) ) verbose() << "calculating mean" << endmsg; - // extract it from the GenHeader - - // as in the IPileUpTool for FixedLuminosity.{h,cpp} - if ( gh && gh->crossingFreq() && gh->luminosity() && gh->totCrossSection() ) { - if ( msgLevel( MSG::VERBOSE ) ) verbose() << "using genheader " << mean << endmsg; - mean = gh->luminosity() * gh->totCrossSection() / gh->crossingFreq(); - } - - // if it isn't in the GenHeader, then make a default, the DC06 mean - else { - if ( msgLevel( MSG::VERBOSE ) ) verbose() << "using default for DC06 data " << mean << endmsg; - mean = ( 2.e32 / Gaudi::Units::cm2 / Gaudi::Units::s ) * ( 102.4 * Gaudi::Units::millibarn ) / - ( 30.0 * Gaudi::Units::megahertz ); - } - - if ( msgLevel( MSG::VERBOSE ) ) verbose() << "calculated mean " << mean << endmsg; - // if it isn't in the GenHeader, then make a default - } - - if ( msgLevel( MSG::VERBOSE ) ) verbose() << "Filling tuples" << endmsg; - bool test = true; - test &= tuple->column( prefix + "_I", n ); - test &= tuple->column( prefix + "_Mean", mean ); - test &= tuple->column( prefix + "_Prob", poisson( mean, n ) ); - - if ( m_adjustmean != 0. ) { - if ( msgLevel( MSG::VERBOSE ) ) verbose() << "Filling adjusted tuples" << endmsg; - double normalise = 1; - if ( m_normaliseAt ) normalise = weight( mean, m_adjustmean, m_normaliseAt ); - test &= tuple->column( prefix + "_AdjustMean", m_adjustmean ); - test &= tuple->column( prefix + "_AdjustProb", poisson( m_adjustmean, n ) ); - test &= tuple->column( prefix + "_AdjustWeight", weight( mean, m_adjustmean, n ) / normalise ); - if ( isVerbose() ) test &= tuple->column( prefix + "_NormalisedAt", m_normaliseAt ); - if ( isVerbose() ) test &= tuple->column( prefix + "_NormalisedTo", normalise ); - } - - if ( isVerbose() ) { - if ( msgLevel( MSG::VERBOSE ) ) verbose() << "Filling detailed tuples" << endmsg; - test &= tuple->column( prefix + "_nMCI", MCI ); - test &= tuple->column( prefix + "_nMCPV", MCPV ); - test &= tuple->column( prefix + "_nRecPV", RecPV ); - } - - return StatusCode( test ); -} - -//============================================================================= diff --git a/Phys/DecayTreeTupleMC/src/MCTupleToolInteractions.h b/Phys/DecayTreeTupleMC/src/MCTupleToolInteractions.h deleted file mode 100755 index 6fbe0cf552140bc16112afcd3399697cb7d99979..0000000000000000000000000000000000000000 --- a/Phys/DecayTreeTupleMC/src/MCTupleToolInteractions.h +++ /dev/null @@ -1,128 +0,0 @@ -/*****************************************************************************\ -* (c) Copyright 2000-2018 CERN for the benefit of the LHCb Collaboration * -* * -* This software is distributed under the terms of the GNU General Public * -* Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". * -* * -* In applying this licence, CERN does not waive the privileges and immunities * -* granted to it by virtue of its status as an Intergovernmental Organization * -* or submit itself to any jurisdiction. * -\*****************************************************************************/ -#ifndef MCTUPLETOOLINTERACTIONS_H -#define MCTUPLETOOLINTERACTIONS_H 1 - -#include - -// from Gaudi -#include "GaudiKernel/SystemOfUnits.h" - -#include "DecayTreeTupleBase/TupleToolBase.h" -#include "Kernel/IEventTupleTool.h" - -#include "Event/GenHeader.h" -#include "Event/MCHeader.h" -#include "Kernel/ParticleID.h" -#include - -#include "GaudiAlg/ITupleTool.h" -#include "GaudiAlg/Tuple.h" - -#include "GaudiKernel/IRegistry.h" // IOpaqueAddress - -class ITupleTool; - -/** @class MCTupleToolInteractions MCTupleToolInteractions.h rlambert/MCTupleToolInteractions.h - * - * \brief Number of interactions. This TupleTool will allow the calculation of a scaling factor - * as an event-by-event weight. When applied to events it will approximate a different mean number of - * interactions per event. - * The starting mean number of interactions will by default be taken from the GenHeader. - * If this is not available it will set to the DC06 default - * The mean can be overwritten by setting the option "Mean" as below - * - * Tuple columns: - * - * EVT_Int_I unsigned int number of interactions - * EVT_Int_Mean double mean number of interactions - * EVT_Int_Prob double probability of generating this number of interactions - * - * If the scaling option (AdjustMean) is set - * EVT_Int_AdjustMean double mean number of interactions to weight to - * EVT_Int_AdjustProb double probability of this event in the adjusted case - * EVT_Int_AdjustWeight double weight to apply to change from mean to adjust mean - * - * If the Verbose option is set - * EVT_Int_NormalisedAt unsigned int chosen place to normalise the weight - * EVT_Int_NormalisedTo double weights normalised to this value - * EVT_Int_nMCI unsigned int number of collisions from the GenHeader - * EVT_Int_nMCPV unsigned int number of collisions from the MCHeader - * EVT_Int_nRecPV unsigned int number of reconstructed PVs - * - * Options: - * Mean double overwrite the mean value of interactions for this event - * -default is described above - * AdjustMean double calculate a scaling factor to approximate this number of interactions per event - * -by default this is zero, and no scaling information is filled - * NormaliseAt int normalise the scaling factor such that it is equal to 1 at this value of I - * -by default this is set to zero, and no normalisation is performed - * Prefix string prefix to give to the variables, in case you want to use two copies of this tool - * -by default this is "EVT_Int" - * UseRecPV bool use the #of reconstructed PVs, rather than the MC Collisions - * -by default this is false - * FillDetails bool fill extra information on MCPV, MC Collisions and Reconstructed PV - * -by default this is false, fine for most purposes - * RecPVLocation string change the default PV location - * -by default this is LHCb::RecVertexLocation::Primary - * - * \sa DecayTreeTuple - * @author R. Lambert - * @date 2009-05-01 - */ -class MCTupleToolInteractions : public TupleToolBase, virtual public IEventTupleTool { - -public: - /// Standard constructor - MCTupleToolInteractions( const std::string& type, const std::string& name, const IInterface* parent ); - - ~MCTupleToolInteractions(){}; ///< Destructor - - StatusCode fill( Tuples::Tuple& ) override; - -private: - double m_mean; ///< mean number of interactions per event. set by the option Mean. Default of zero will get the result - ///< from the GenHeader - double m_adjustmean; ///< mean number of interactions to weight to. set by the option AdjustMean. Default of zero will - ///< not calculate the adjustment. - unsigned int m_normaliseAt; ///< where to place the normalisation such that the weight is one at this value. set by - ///< the option NormaliseAt. Default of zero will not calculate specific normalisation, - ///< but use the correct weighting from te poisson. - // std::string m_prefix; ///( this ); - - // Store kinetic information from the associated candidate - declareProperty( "StoreKineticInfo", m_storeKinetic = true ); - - // Store the end and origin true vertex information - declareProperty( "StoreVertexInfo", m_storeVertexes = true ); - - // Store the propertime information for associated composite particle - declareProperty( "StorePropertimeInfo", m_storePT = true ); - - // Store the eta information - declareProperty( "StoreEtaInfo", m_storeEta = false ); - - // Store propertime and endvertex also for stable particles - // This is needed in case you study, for example, K-> pi pi pi - // As the Kaon is considerad stable in LHCb - // False by default as it will store properime also of pions, electrons etc - declareProperty( "StoreStablePropertime", m_storeStablePropertime = false ); -} -//============================================================================= -// Destructor -//============================================================================= -MCTupleToolKinematic::~MCTupleToolKinematic() {} - -//============================================================================= -// initialize -//============================================================================= - -StatusCode MCTupleToolKinematic::initialize() { - const StatusCode sc = TupleToolBase::initialize(); - if ( sc.isFailure() ) return StatusCode::FAILURE; - if ( isVerbose() ) { m_storePT = m_storeVertexes = m_storeKinetic = m_storeEta = true; } - return sc; -} -//============================================================================= -// Fill -//============================================================================= -StatusCode MCTupleToolKinematic::fill( const LHCb::MCParticle*, const LHCb::MCParticle* mcp, const std::string& head, - Tuples::Tuple& tuple ) { - const std::string prefix = fullName( head ); - bool test = true; - - if ( msgLevel( MSG::DEBUG ) ) debug() << "MCTupleToolKinematic::fill " << head << endmsg; - - double mcTau = -1; - double mcPT = 0; - double mcETA = 0; - - Gaudi::XYZVector endVertex, originVertex; - Gaudi::LorentzVector trueP; - bool hasOsc = false; - - if ( msgLevel( MSG::VERBOSE ) ) verbose() << "MCTupleToolKinematic::fill mcp " << mcp << endmsg; - // pointer is ready, prepare the values: - if ( mcp ) { - trueP = mcp->momentum(); - mcPT = mcp->pt(); - mcETA = mcp->momentum().eta(); - if ( msgLevel( MSG::VERBOSE ) ) verbose() << " " << trueP << endmsg; - - originVertex = mcp->originVertex()->position(); - if ( msgLevel( MSG::VERBOSE ) ) verbose() << " origin vertex position " << originVertex << endmsg; - - if ( !isStable( mcp ) || m_storeStablePropertime ) { - const SmartRefVector& endVertices = mcp->endVertices(); - if ( msgLevel( MSG::VERBOSE ) ) verbose() << " vertices " << endVertices.size() << endmsg; - - const LHCb::MCVertex* mcV = NULL; - if ( !endVertices.empty() ) { - for ( SmartRefVector::const_iterator v = endVertices.begin(); v != endVertices.end(); ++v ) { - if ( ( *v )->type() == LHCb::MCVertex::DecayVertex || ( *v )->type() == LHCb::MCVertex::OscillatedAndDecay || - ( *v )->type() == LHCb::MCVertex::HadronicInteraction ) { - mcV = *v; - break; - } - } - } else { - Warning( "No end vertices for " + prefix ).ignore(); - } - - if ( mcV ) { - endVertex = mcV->position(); - } else { - Warning( "NULL end vertex for " + prefix ).ignore(); - } - - if ( msgLevel( MSG::VERBOSE ) ) verbose() << " end vertex " << endVertex << endmsg; - - // lifetime - if ( mcV && m_storePT ) { - const Gaudi::XYZVector dist = endVertex - originVertex; - // copied from DecayChainNTuple // - mcTau = trueP.M() * dist.Dot( trueP.Vect() ) / trueP.Vect().mag2(); - mcTau /= Gaudi::Units::c_light; // nanoseconds - hasOsc = mcp->hasOscillated(); - if ( msgLevel( MSG::DEBUG ) ) { - debug() << head << " " << mcp->particleID().pid() << " time " << mcTau << " oscil" << hasOsc << endmsg; - } - } - } - } - - if ( msgLevel( MSG::VERBOSE ) ) verbose() << "MCTupleToolKinematic::fill filling " << head << endmsg; - - // fill the tuple: - // test &= tuple->column( head+"_TRUEID", mcPid ); - if ( m_storeKinetic ) { - test &= tuple->column( prefix + "_TRUEP_", trueP ); - test &= tuple->column( prefix + "_TRUEPT", mcPT ); - } - - if ( m_storeVertexes ) { - test &= tuple->column( prefix + "_TRUEORIGINVERTEX_", originVertex ); - test &= tuple->column( prefix + "_TRUEENDVERTEX_", endVertex ); - test &= tuple->column( prefix + "_TRUEISSTABLE", isStable( mcp ) ); - } - - if ( m_storePT ) { - test &= tuple->column( prefix + "_TRUETAU", mcTau ); - if ( isVerbose() ) { test &= tuple->column( prefix + "_OSCIL", hasOsc ); } - } - - if ( m_storeEta ) { test &= tuple->column( prefix + "_TRUEETA", mcETA ); } - - if ( msgLevel( MSG::VERBOSE ) ) verbose() << "MCTupleToolKinematic::fill bye " << prefix << endmsg; - - return StatusCode( test ); -} diff --git a/Phys/DecayTreeTupleMC/src/MCTupleToolKinematic.h b/Phys/DecayTreeTupleMC/src/MCTupleToolKinematic.h deleted file mode 100644 index dd687513130817f8e67140d4d8cf612dcf83ae50..0000000000000000000000000000000000000000 --- a/Phys/DecayTreeTupleMC/src/MCTupleToolKinematic.h +++ /dev/null @@ -1,58 +0,0 @@ -/*****************************************************************************\ -* (c) Copyright 2000-2018 CERN for the benefit of the LHCb Collaboration * -* * -* This software is distributed under the terms of the GNU General Public * -* Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". * -* * -* In applying this licence, CERN does not waive the privileges and immunities * -* granted to it by virtue of its status as an Intergovernmental Organization * -* or submit itself to any jurisdiction. * -\*****************************************************************************/ -#ifndef MCTUPLETOOLKINEMATIC_H -#define MCTUPLETOOLKINEMATIC_H 1 - -// Include files -// from Gaudi -#include "DecayTreeTupleBase/TupleToolBase.h" -#include "Event/MCParticle.h" // Interface -#include "Kernel/IMCParticleTupleTool.h" // Interface -/** @class MCTupleToolKinematic MCTupleToolKinematic.h - * - * Fill MC Particle - * - * See the properties inline documentation to toggle on/off some of - * the columns - * - * - head_TRUEP[E|X|Y|Z] : true four vector momentum - * - head_TRUEPT : true transverse momentum, PT - * - head_TRUEORIGINVERTEX_[X|Y|Z] : position of the true origin vertex. - * - head_TRUEENDVERTEX_[X|Y|Z] : position of the true end vertex (the - first one) - * - head_TRUEISSTABLE : MCAssociate has no daughters. - * - head_TRUETAU : true propertime - * - * \sa MCTupleToolKinematic, DecayTreeTuple, MCDecayTreeTuple - * - * @author Patrick Koppenburg - * @date 2009-01-19 - */ - -class MCTupleToolKinematic : public TupleToolBase, virtual public IMCParticleTupleTool { -public: - /// Standard constructor - MCTupleToolKinematic( const std::string& type, const std::string& name, const IInterface* parent ); - - virtual ~MCTupleToolKinematic(); ///< Destructor - StatusCode initialize() override; - StatusCode fill( const LHCb::MCParticle*, const LHCb::MCParticle*, const std::string&, Tuples::Tuple& ) override; - -private: - bool m_storeKinetic; //!< Store kinetic information from the associated candidate - bool m_storePT; //!< Store the propertime information for associated composite particle - bool m_storeVertexes; //!< Store the end and origin true vertex information - bool m_storeStablePropertime; //!< Store the propertime and vertex also for "stable" particles - bool m_storeEta; //!< Store the pseudorapidity of the candidate - -#include "DecayTreeTupleBase/isStable.h" -}; -#endif // MCTUPLETOOLKINEMATIC_H diff --git a/Phys/DecayTreeTupleMC/src/MCTupleToolPID.cpp b/Phys/DecayTreeTupleMC/src/MCTupleToolPID.cpp deleted file mode 100644 index 09c0e769369e8956dbefa841ff535c047acb7c7a..0000000000000000000000000000000000000000 --- a/Phys/DecayTreeTupleMC/src/MCTupleToolPID.cpp +++ /dev/null @@ -1,69 +0,0 @@ -/*****************************************************************************\ -* (c) Copyright 2000-2018 CERN for the benefit of the LHCb Collaboration * -* * -* This software is distributed under the terms of the GNU General Public * -* Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". * -* * -* In applying this licence, CERN does not waive the privileges and immunities * -* granted to it by virtue of its status as an Intergovernmental Organization * -* or submit itself to any jurisdiction. * -\*****************************************************************************/ -// Include files -#include "Event/MCParticle.h" -#include "gsl/gsl_sys.h" - -// local -#include "MCTupleToolPID.h" - -// from Gaudi -#include "GaudiAlg/Tuple.h" -#include "GaudiAlg/TupleObj.h" - -#include - -// using namespace LHCb; -//----------------------------------------------------------------------------- -// Implementation file for class : MCTupleToolPID -// -// 2009-11-19 : Rob Lambert -//----------------------------------------------------------------------------- - -// Declaration of the Tool Factory -DECLARE_COMPONENT( MCTupleToolPID ) - -//============================================================================= -// Standard constructor, initializes variables -//============================================================================= -MCTupleToolPID::MCTupleToolPID( const std::string& type, const std::string& name, const IInterface* parent ) - : TupleToolBase( type, name, parent ) { - declareInterface( this ); -} - -//============================================================================= -// Destructor -//============================================================================= -MCTupleToolPID::~MCTupleToolPID() {} - -//============================================================================= -// Fill -//============================================================================= -StatusCode MCTupleToolPID::fill( const LHCb::MCParticle*, const LHCb::MCParticle* mcp, const std::string& head, - Tuples::Tuple& tuple ) { - const std::string prefix = fullName( head ); - bool test = true; - - if ( msgLevel( MSG::DEBUG ) ) debug() << "MCTupleToolPID::fill " << head << endmsg; - - int mcPid = 0; - - if ( msgLevel( MSG::VERBOSE ) ) verbose() << "MCTupleToolPID::fill mcp " << mcp << endmsg; - // pointer is ready, prepare the values: - if ( mcp ) { mcPid = mcp->particleID().pid(); } - if ( msgLevel( MSG::VERBOSE ) ) verbose() << "MCTupleToolPID::fill filling " << head << endmsg; - - test &= tuple->column( prefix + "_ID", mcPid ); - - if ( msgLevel( MSG::VERBOSE ) ) verbose() << "MCTupleToolPID::fill bye " << head << endmsg; - - return StatusCode( test ); -} diff --git a/Phys/DecayTreeTupleMC/src/MCTupleToolPID.h b/Phys/DecayTreeTupleMC/src/MCTupleToolPID.h deleted file mode 100644 index 9a2fb2799982caf9b996d54c5f2b2fec9f86f728..0000000000000000000000000000000000000000 --- a/Phys/DecayTreeTupleMC/src/MCTupleToolPID.h +++ /dev/null @@ -1,44 +0,0 @@ -/*****************************************************************************\ -* (c) Copyright 2000-2018 CERN for the benefit of the LHCb Collaboration * -* * -* This software is distributed under the terms of the GNU General Public * -* Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". * -* * -* In applying this licence, CERN does not waive the privileges and immunities * -* granted to it by virtue of its status as an Intergovernmental Organization * -* or submit itself to any jurisdiction. * -\*****************************************************************************/ -#ifndef MCTUPLETOOLPID_H -#define MCTUPLETOOLPID_H 1 - -// Include files -// from Gaudi -#include "DecayTreeTupleBase/TupleToolBase.h" -#include "Event/MCParticle.h" // Interface -#include "Kernel/IMCParticleTupleTool.h" // Interface - -/** @class MCTupleToolPID MCTupleToolPID.h - * - * Fill MC Particle - * - * - head_ID : pid - * - * - * \sa MCTupleToolPID, DecayTreeTuple, MCDecayTreeTuple - * - * @author Rob Lambert - * @date 2009-11-19 - */ - -class MCTupleToolPID : public TupleToolBase, virtual public IMCParticleTupleTool { - -public: - /// Standard constructor - MCTupleToolPID( const std::string& type, const std::string& name, const IInterface* parent ); - - virtual ~MCTupleToolPID(); ///< Destructor - - StatusCode fill( const LHCb::MCParticle*, const LHCb::MCParticle*, const std::string&, Tuples::Tuple& ) override; -}; - -#endif // MCTUPLETOOLPID_H diff --git a/Phys/DecayTreeTupleMC/src/MCTupleToolPrimaries.cpp b/Phys/DecayTreeTupleMC/src/MCTupleToolPrimaries.cpp deleted file mode 100644 index 4a144e7bff4bc1ba7a0017057f4a64709cbbf352..0000000000000000000000000000000000000000 --- a/Phys/DecayTreeTupleMC/src/MCTupleToolPrimaries.cpp +++ /dev/null @@ -1,70 +0,0 @@ -/*****************************************************************************\ -* (c) Copyright 2000-2018 CERN for the benefit of the LHCb Collaboration * -* * -* This software is distributed under the terms of the GNU General Public * -* Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". * -* * -* In applying this licence, CERN does not waive the privileges and immunities * -* granted to it by virtue of its status as an Intergovernmental Organization * -* or submit itself to any jurisdiction. * -\*****************************************************************************/ -// Include files - -// from Gaudi -#include "Event/MCHeader.h" -#include "Event/MCVertex.h" -#include "GaudiAlg/Tuple.h" -#include "GaudiAlg/TupleObj.h" -// local -#include "MCTupleToolPrimaries.h" - -//----------------------------------------------------------------------------- -// Implementation file for class : MCTupleToolPrimaries -// -// 2009-11-16 : Patrick Koppenburg -//----------------------------------------------------------------------------- - -// Declaration of the Tool Factory -DECLARE_COMPONENT( MCTupleToolPrimaries ) - -//============================================================================= -// Standard constructor, initializes variables -//============================================================================= -MCTupleToolPrimaries::MCTupleToolPrimaries( const std::string& type, const std::string& name, const IInterface* parent ) - : TupleToolBase( type, name, parent ) { - declareInterface( this ); -} - -//============================================================================= -// Destructor -//============================================================================= -MCTupleToolPrimaries::~MCTupleToolPrimaries() {} - -//============================================================================= -StatusCode MCTupleToolPrimaries::fill( Tuples::Tuple& tuple ) { - const std::string prefix = fullName(); - - if ( msgLevel( MSG::VERBOSE ) ) verbose() << "getting MCHeader" << endmsg; - if ( !exist( LHCb::MCHeaderLocation::Default ) ) { - Warning( "No MCHeader at " + LHCb::MCHeaderLocation::Default, StatusCode::SUCCESS, 1 ) - .ignore( /* AUTOMATICALLY ADDED FOR gaudi/Gaudi!763 */ ); - return StatusCode::SUCCESS; - } - const LHCb::MCHeader* mch = get( LHCb::MCHeaderLocation::Default ); - std::vector pvx, pvy, pvz, pvt; - for ( SmartRefVector::const_iterator i = mch->primaryVertices().begin(); - i != mch->primaryVertices().end(); ++i ) { - if ( ( *i )->isPrimary() ) { - pvx.push_back( ( *i )->position().X() ); - pvy.push_back( ( *i )->position().Y() ); - pvz.push_back( ( *i )->position().Z() ); - pvt.push_back( ( *i )->time() ); - } - } - if ( !( tuple->farray( prefix + "MCPVX", pvx, prefix + "MCPVs", 50 ) ) ) return StatusCode::FAILURE; - if ( !( tuple->farray( prefix + "MCPVY", pvy, prefix + "MCPVs", 50 ) ) ) return StatusCode::FAILURE; - if ( !( tuple->farray( prefix + "MCPVZ", pvz, prefix + "MCPVs", 50 ) ) ) return StatusCode::FAILURE; - if ( !( tuple->farray( prefix + "MCPVT", pvt, prefix + "MCPVs", 50 ) ) ) return StatusCode::FAILURE; - - return StatusCode::SUCCESS; -} diff --git a/Phys/DecayTreeTupleMC/src/MCTupleToolPrimaries.h b/Phys/DecayTreeTupleMC/src/MCTupleToolPrimaries.h deleted file mode 100644 index 0eb34e90e80bc551018fa25030a2ba6ed2d3bedf..0000000000000000000000000000000000000000 --- a/Phys/DecayTreeTupleMC/src/MCTupleToolPrimaries.h +++ /dev/null @@ -1,37 +0,0 @@ -/*****************************************************************************\ -* (c) Copyright 2000-2018 CERN for the benefit of the LHCb Collaboration * -* * -* This software is distributed under the terms of the GNU General Public * -* Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". * -* * -* In applying this licence, CERN does not waive the privileges and immunities * -* granted to it by virtue of its status as an Intergovernmental Organization * -* or submit itself to any jurisdiction. * -\*****************************************************************************/ -#ifndef MCTUPLETOOLPRIMARIES_H -#define MCTUPLETOOLPRIMARIES_H 1 - -// Include files -// from Gaudi -#include "DecayTreeTupleBase/TupleToolBase.h" -#include "Kernel/IEventTupleTool.h" // Interface - -/** @class MCTupleToolPrimaries MCTupleToolPrimaries.h - * - * \brief Primary MC vertices properties for DecayTreeTuple - * - * Tuple columns: - * - coordinates PVX, PVY, PVZ, PVT (time) - * - * @author Patrick Koppenburg - * @date 2009-11-16 - */ -class MCTupleToolPrimaries : public TupleToolBase, virtual public IEventTupleTool { -public: - /// Standard constructor - MCTupleToolPrimaries( const std::string& type, const std::string& name, const IInterface* parent ); - - virtual ~MCTupleToolPrimaries(); ///< Destructor - StatusCode fill( Tuples::Tuple& ) override; -}; -#endif // MCTUPLETOOLPRIMARIES_H diff --git a/Phys/DecayTreeTupleMC/src/MCTupleToolPrompt.cpp b/Phys/DecayTreeTupleMC/src/MCTupleToolPrompt.cpp deleted file mode 100644 index d68034639d4527164b9e05bc848bb6900602e59a..0000000000000000000000000000000000000000 --- a/Phys/DecayTreeTupleMC/src/MCTupleToolPrompt.cpp +++ /dev/null @@ -1,118 +0,0 @@ -/*****************************************************************************\ -* (c) Copyright 2000-2018 CERN for the benefit of the LHCb Collaboration * -* * -* This software is distributed under the terms of the GNU General Public * -* Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". * -* * -* In applying this licence, CERN does not waive the privileges and immunities * -* granted to it by virtue of its status as an Intergovernmental Organization * -* or submit itself to any jurisdiction. * -\*****************************************************************************/ -// Include files - -// local -#include "MCTupleToolPrompt.h" - -// using namespace LHCb; - -//----------------------------------------------------------------------------- -// Implementation file for class : MCTupleToolPrompt -// -// 2011-06-13 : Philip John Hunt -//----------------------------------------------------------------------------- - -// Declaration of the Tool Factory -DECLARE_COMPONENT( MCTupleToolPrompt ) - -//============================================================================= -// Standard constructor, initializes variables -//============================================================================= -MCTupleToolPrompt::MCTupleToolPrompt( const std::string& type, const std::string& name, const IInterface* parent ) - : TupleToolBase( type, name, parent ), m_ppSvc( 0 ) { - declareInterface( this ); - - // maximum lifetime of short-lived particles (ns) - declareProperty( "MaxLifetime", m_maxLifetime = 1e-7, "Maximum lifetime of short-lived particles (ns)" ); - declareProperty( "StoreLongLivedParticleID", m_storeLongLivedPid = true ); -} - -StatusCode MCTupleToolPrompt::initialize() { - StatusCode sc = TupleToolBase::initialize(); - if ( sc.isFailure() ) return sc; - - if ( isVerbose() ) m_storeLongLivedPid = true; - - sc = service( "LHCb::ParticlePropertySvc", m_ppSvc ); - - return sc; -} - -StatusCode MCTupleToolPrompt::fill( const LHCb::MCParticle*, const LHCb::MCParticle* mcp, const std::string& head, - Tuples::Tuple& tuple ) { - const std::string prefix = fullName( head ); - - bool test = true; - - int longLivedPid = 0; - int longLivedKey = 0; - - int isPrompt = -1; - - int mcParentPid = 0; - int mcParentKey = 0; - - double lcl_lifetime( 0 ); - - const LHCb::MCParticle* mcp_parent = mcp; - - const LHCb::ParticleProperty* lclPprop = NULL; - - if ( msgLevel( MSG::DEBUG ) ) debug() << "MCTupleToolPrompt::fill " << head << endmsg; - - if ( mcp ) { - isPrompt = 1; - while ( isPrompt && mcp_parent->mother() ) { - mcp_parent = mcp_parent->mother(); - - mcParentPid = mcp_parent->particleID().pid(); - mcParentKey = mcp_parent->key(); - - lclPprop = m_ppSvc->find( mcp_parent->particleID() ); - - // Some particle IDs are not known to the ppSvc - // Log a warning if that's the case and assign a large negative lifetime - if ( lclPprop ) { - lcl_lifetime = lclPprop->lifetime(); - if ( msgLevel( MSG::DEBUG ) ) { - debug() << "Particle: " << lclPprop->evtGenName() << " lifetime: " << lcl_lifetime << endmsg; - } - } else { - warning() << "Particle ID '" << mcp_parent->particleID() << "' not found in particle property service" - << endmsg; - lcl_lifetime = -999.0; - } - - if ( lcl_lifetime > m_maxLifetime * Gaudi::Units::ns ) { - isPrompt = 0; - longLivedPid = mcParentPid; - longLivedKey = mcParentKey; - } - } - } - - if ( msgLevel( MSG::DEBUG ) ) debug() << "MCTupleToolPrompt::fill - filling " << head << endmsg; - - test &= tuple->column( prefix + "_MC_ISPROMPT", isPrompt ); - if ( m_storeLongLivedPid ) { - test &= tuple->column( prefix + "_MC_LONGLIVED_ID", longLivedPid ); - test &= tuple->column( prefix + "_MC_LONGLIVED_KEY", longLivedKey ); - } - return StatusCode( test ); -} - -//============================================================================= -// Destructor -//============================================================================= -MCTupleToolPrompt::~MCTupleToolPrompt() {} - -//============================================================================= diff --git a/Phys/DecayTreeTupleMC/src/MCTupleToolPrompt.h b/Phys/DecayTreeTupleMC/src/MCTupleToolPrompt.h deleted file mode 100644 index 164a9d8e5430efea00335b63ae1c3366c43708d2..0000000000000000000000000000000000000000 --- a/Phys/DecayTreeTupleMC/src/MCTupleToolPrompt.h +++ /dev/null @@ -1,63 +0,0 @@ -/*****************************************************************************\ -* (c) Copyright 2000-2018 CERN for the benefit of the LHCb Collaboration * -* * -* This software is distributed under the terms of the GNU General Public * -* Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". * -* * -* In applying this licence, CERN does not waive the privileges and immunities * -* granted to it by virtue of its status as an Intergovernmental Organization * -* or submit itself to any jurisdiction. * -\*****************************************************************************/ -#ifndef MCTUPLETOOLPROMPT_H -#define MCTUPLETOOLPROMPT_H 1 - -// from Gaudi -#include "GaudiKernel/PhysicalConstants.h" - -// from Kernel -#include "Kernel/IMCParticleTupleTool.h" -#include "Kernel/IParticlePropertySvc.h" -#include "Kernel/ParticleProperty.h" - -#include "DecayTreeTupleBase/TupleToolBase.h" - -// from GaudiAlg -#include "GaudiAlg/Tuple.h" -#include "GaudiAlg/TupleObj.h" - -// from Event -#include "Event/MCParticle.h" - -/** @class MCTupleToolPrompt MCTupleToolPrompt.h - * - * \brief Tool to determine whether a decay originates from prompt charm based on the true lifetime of its ancestors. - * Based on code written by Patrick Spradlin. - * - * Tuple columns: - * - MC_ISPROMPT, MC_LONGLIVED_ID, MC_LONGLIVED_KEY - * - * @author Philip John Hunt - * @date 2011-06-13 - */ - -class MCTupleToolPrompt : public TupleToolBase, virtual public IMCParticleTupleTool { - -public: - /// Standard constructor - MCTupleToolPrompt( const std::string& type, const std::string& name, const IInterface* parent ); - - virtual ~MCTupleToolPrompt(); ///< Destructor - - StatusCode initialize() override; - - StatusCode fill( const LHCb::MCParticle*, const LHCb::MCParticle*, const std::string&, Tuples::Tuple& ) override; - -protected: - double m_maxLifetime; - bool m_storeLongLivedPid; - -private: - LHCb::IParticlePropertySvc* m_ppSvc; -}; - -#endif // MCTUPLETOOLPROMPT_H diff --git a/Phys/DecayTreeTupleMC/src/MCTupleToolReconstructed.cpp b/Phys/DecayTreeTupleMC/src/MCTupleToolReconstructed.cpp deleted file mode 100644 index 171d4d989befa447cb2a94c96bb8be9a0e0b6497..0000000000000000000000000000000000000000 --- a/Phys/DecayTreeTupleMC/src/MCTupleToolReconstructed.cpp +++ /dev/null @@ -1,146 +0,0 @@ -/*****************************************************************************\ -* (c) Copyright 2000-2018 CERN for the benefit of the LHCb Collaboration * -* * -* This software is distributed under the terms of the GNU General Public * -* Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". * -* * -* In applying this licence, CERN does not waive the privileges and immunities * -* granted to it by virtue of its status as an Intergovernmental Organization * -* or submit itself to any jurisdiction. * -\*****************************************************************************/ -// Include files -#include "gsl/gsl_sys.h" - -// from Gaudi -#include "GaudiKernel/PhysicalConstants.h" -#include "GaudiKernel/Vector3DTypes.h" - -// local -#include "MCTupleToolReconstructed.h" - -#include "GaudiAlg/Tuple.h" -#include "GaudiAlg/TupleObj.h" - -#include "Event/MCParticle.h" -#include "MCInterfaces/IMCReconstructed.h" -#include "MCInterfaces/IMCReconstructible.h" - -using namespace LHCb; -//----------------------------------------------------------------------------- -// Implementation file for class : MCTupleToolReconstructed -// -// 2009-01-19 : Patrick Koppenburg -//----------------------------------------------------------------------------- - -// Declaration of the Tool Factory -DECLARE_COMPONENT( MCTupleToolReconstructed ) - -//============================================================================= -// Standard constructor, initializes variables -//============================================================================= -MCTupleToolReconstructed::MCTupleToolReconstructed( const std::string& type, const std::string& name, - const IInterface* parent ) - : TupleToolBase( type, name, parent ), m_recible( 0 ), m_rected( 0 ), m_pCPPAsct( 0 ), m_pNPPAsct( 0 ) { - declareInterface( this ); - declareProperty( "Associate", m_associate = true, "Fill associated protoparticle" ); - declareProperty( "FillPID", m_pid = true, "Fill PID, also set by Verbose" ); -} - -//============================================================================= -// initialize -//============================================================================= - -StatusCode MCTupleToolReconstructed::initialize() { - if ( !TupleToolBase::initialize() ) return StatusCode::FAILURE; - - m_recible = tool( "MCReconstructible" ); - m_rected = tool( "MCReconstructed" ); - - if ( m_associate ) { - m_pCPPAsct = new Object2FromMC( this, Particle2MCMethod::ChargedPP, - LHCb::ProtoParticleLocation::Charged ); - m_pNPPAsct = new Object2FromMC( this, Particle2MCMethod::NeutralPP, - LHCb::ProtoParticleLocation::Neutrals ); - } - - if ( isVerbose() ) m_pid = true; - - return StatusCode::SUCCESS; -} -//============================================================================= -// Fill -//============================================================================= -StatusCode MCTupleToolReconstructed::fill( const LHCb::MCParticle*, const LHCb::MCParticle* mcp, - const std::string& head, Tuples::Tuple& tuple ) { - const std::string prefix = fullName( head ); - - bool test = true; - int catted = -10; - int catible = -10; - - // pointer is ready, prepare the values: - if ( 0 != mcp ) { - catted = m_rected->reconstructed( mcp ); - catible = m_recible->reconstructible( mcp ); - } - - // fill the tuple: - test &= tuple->column( prefix + "_Reconstructible", catible ); - test &= tuple->column( prefix + "_Reconstructed", catted ); - std::vector PX, PY, PZ, Weights, dlle, dllmu, dllk, dllp, pchi2; - - if ( ( 0 != mcp ) && m_associate && isStable( mcp ) ) { - std::vector> ppv = getProtos( mcp ); - for ( std::vector>::const_iterator ppp = ppv.begin(); - ppp != ppv.end(); ++ppp ) { - const LHCb::ProtoParticle* proto = ppp->first; - double w = ppp->second; - /// @todo There's plenty more that can be added here. Like PID for instance. - if ( 0 != proto->track() ) { - Gaudi::XYZVector mom = proto->track()->momentum(); - PX.push_back( mom.X() ); - PY.push_back( mom.Y() ); - PZ.push_back( mom.Z() ); - pchi2.push_back( proto->track()->probChi2() ); - } - Weights.push_back( w ); - if ( m_pid ) { - dlle.push_back( proto->info( ProtoParticle::CombDLLe, -999.0 ) ); - dllmu.push_back( proto->info( ProtoParticle::CombDLLmu, -999.0 ) ); - dllk.push_back( proto->info( ProtoParticle::CombDLLk, -999.0 ) ); - dllp.push_back( proto->info( ProtoParticle::CombDLLp, -999.0 ) ); - } - } - } - const unsigned int maxPP = 20; - test &= tuple->farray( prefix + "_PP_PX", PX, prefix + "_ProtoParticles", maxPP ); - test &= tuple->farray( prefix + "_PP_PY", PY, prefix + "_ProtoParticles", maxPP ); - test &= tuple->farray( prefix + "_PP_PZ", PZ, prefix + "_ProtoParticles", maxPP ); - test &= tuple->farray( prefix + "_PP_Weight", Weights, prefix + "_ProtoParticles", maxPP ); - test &= tuple->farray( prefix + "_PP_tr_pchi2", pchi2, prefix + "_ProtoParticles", maxPP ); - if ( m_pid ) { - test &= tuple->farray( prefix + "_PP_DLLe", dlle, prefix + "_ProtoParticles", maxPP ); - test &= tuple->farray( prefix + "_PP_DLLk", dllk, prefix + "_ProtoParticles", maxPP ); - test &= tuple->farray( prefix + "_PP_DLLp", dllp, prefix + "_ProtoParticles", maxPP ); - test &= tuple->farray( prefix + "_PP_DLLmu", dllmu, prefix + "_ProtoParticles", maxPP ); - } - - return StatusCode( test ); -} - -//========================================================================= -/// Protoparticles list @todo return weight as well -//======================================================================== -std::vector> -MCTupleToolReconstructed::getProtos( const LHCb::MCParticle* mcp ) const { - auto* asct = ( mcp->particleID().threeCharge() == 0 ) ? m_pNPPAsct : m_pCPPAsct; - if ( 0 == asct ) Exception( "Null PP asociator" ); - std::vector> ppv; - double w = 0; - const LHCb::ProtoParticle* pp = asct->firstP( mcp, w ); - while ( pp ) { - ppv.push_back( std::pair( pp, w ) ); - pp = asct->nextP( w ); - } - return ppv; -} diff --git a/Phys/DecayTreeTupleMC/src/MCTupleToolReconstructed.h b/Phys/DecayTreeTupleMC/src/MCTupleToolReconstructed.h deleted file mode 100644 index f81cc5eb5675e9577a13956508673eac0cf4d7b2..0000000000000000000000000000000000000000 --- a/Phys/DecayTreeTupleMC/src/MCTupleToolReconstructed.h +++ /dev/null @@ -1,64 +0,0 @@ -/*****************************************************************************\ -* (c) Copyright 2000-2018 CERN for the benefit of the LHCb Collaboration * -* * -* This software is distributed under the terms of the GNU General Public * -* Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". * -* * -* In applying this licence, CERN does not waive the privileges and immunities * -* granted to it by virtue of its status as an Intergovernmental Organization * -* or submit itself to any jurisdiction. * -\*****************************************************************************/ -#ifndef MCTUPLETOOLMCRECONSTRUCTED_H -#define MCTUPLETOOLMCRECONSTRUCTED_H 1 - -// Include files -// from Gaudi -#include "DecayTreeTupleBase/TupleToolBase.h" -#include "Event/ProtoParticle.h" -#include "Kernel/IMCParticleTupleTool.h" // Interface -#include "Kernel/Particle2MCLinker.h" - -/** @class MCTupleToolReconstructed MCTupleToolReconstructed.h - * - * Fill MC Particle - * - * See the properties inline documentation to toggle on/off some of - * the columns - * - * - head_Reconstructible : IMCReconstructible category - * - head_Reconstructed : IMCReconstructed category - * - head_PP_PX,Y,Z : ProtoParticle PX, PY, PZ - * - head_PP_Weight : ProtoParticle association weight - * - * \sa MCDecayTreeTuple, IMCReconstructible, IMCReconstructed - * - * @author Patrick Koppenburg - * @date 2009-01-22 - */ -struct IMCReconstructible; -struct IMCReconstructed; - -class MCTupleToolReconstructed : public TupleToolBase, virtual public IMCParticleTupleTool { -public: - /// Standard constructor - MCTupleToolReconstructed( const std::string& type, const std::string& name, const IInterface* parent ); - - StatusCode initialize() override; - -public: - StatusCode fill( const LHCb::MCParticle*, const LHCb::MCParticle*, const std::string&, Tuples::Tuple& ) override; - -private: - std::vector> getProtos( const LHCb::MCParticle* ) const; - -#include "DecayTreeTupleBase/isStable.h" - -private: - IMCReconstructible* m_recible; ///< Reconstructible tool - IMCReconstructed* m_rected; ///< Reconstructed too - Object2FromMC* m_pCPPAsct; ///< Charged protoparticle associator - Object2FromMC* m_pNPPAsct; ///< Neutral protoparticle associator - bool m_associate; ///< Do association - bool m_pid; ///< Do PID -}; -#endif // MCTUPLETOOLMCRECONSTRUCTED_H diff --git a/Phys/DecayTreeTupleMC/src/MCTupleToolRedecay.cpp b/Phys/DecayTreeTupleMC/src/MCTupleToolRedecay.cpp deleted file mode 100644 index 1cfd799956faa2eda511dd14c4c7195b39cda32d..0000000000000000000000000000000000000000 --- a/Phys/DecayTreeTupleMC/src/MCTupleToolRedecay.cpp +++ /dev/null @@ -1,76 +0,0 @@ -/*****************************************************************************\ -* (c) Copyright 2000-2019 CERN for the benefit of the LHCb Collaboration * -* * -* This software is distributed under the terms of the GNU General Public * -* Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". * -* * -* In applying this licence, CERN does not waive the privileges and immunities * -* granted to it by virtue of its status as an Intergovernmental Organization * -* or submit itself to any jurisdiction. * -\*****************************************************************************/ -// Include files - -// from Gaudi -#include "Event/MCHeader.h" -#include "Event/MCVertex.h" -#include "GaudiAlg/Tuple.h" -#include "GaudiAlg/TupleObj.h" -// local -#include "MCTupleToolRedecay.h" - -//----------------------------------------------------------------------------- -// Implementation file for class : MCTupleToolRedecay -// -// 2017-1-26 : Dominik Muller -//----------------------------------------------------------------------------- - -// Declaration of the Tool Factory -DECLARE_COMPONENT( MCTupleToolRedecay ) - -//============================================================================= -// Standard constructor, initializes variables -//============================================================================= -MCTupleToolRedecay::MCTupleToolRedecay( const std::string& type, const std::string& name, const IInterface* parent ) - : TupleToolBase( type, name, parent ) { - declareInterface( this ); -} - -//============================================================================= -// Destructor -//============================================================================= -MCTupleToolRedecay::~MCTupleToolRedecay() {} - -//============================================================================= -StatusCode MCTupleToolRedecay::fill( Tuples::Tuple& tuple ) { - const std::string prefix = fullName(); - - if ( msgLevel( MSG::VERBOSE ) ) verbose() << "getting MCHeader" << endmsg; - LHCb::MCHeader* mch = 0; - if ( exist( LHCb::MCHeaderLocation::Default ) ) { - mch = get( LHCb::MCHeaderLocation::Default ); - } else if ( exist( LHCb::MCHeaderLocation::Default, false ) ) { - mch = get( LHCb::MCHeaderLocation::Default, false ); - } else { - Warning( "Cannot find MCHeader at location: " + LHCb::MCHeaderLocation::Default + "; will not fill tuple", - StatusCode::SUCCESS, 1 ) - .ignore( /* AUTOMATICALLY ADDED FOR gaudi/Gaudi!763 */ ); - return StatusCode::SUCCESS; // don't interrupt event loop - } - auto time = mch->evtTime(); - // for ReDecay, the unused evtTime contains the cantor pairing of - // the original event run and event number. Decomposing it now - // following https://en.wikipedia.org/wiki/Pairing_function. - // Magic - - auto w = std::floor( ( sqrtl( 8 * time + 1 ) - 1 ) / 2 ); - auto t = ( w * w + w ) / 2; - unsigned long long RD_org_runNumber = time - t; - unsigned long long RD_org_eventNumber = w - RD_org_runNumber; - unsigned int RD_i_event = mch->evtNumber() - RD_org_eventNumber; - - if ( !( tuple->column( prefix + "RD_org_eventNumber", RD_org_eventNumber ) ) ) return StatusCode::FAILURE; - if ( !( tuple->column( prefix + "RD_org_runNumber", RD_org_runNumber ) ) ) return StatusCode::FAILURE; - if ( !( tuple->column( prefix + "RD_i_event", RD_i_event ) ) ) return StatusCode::FAILURE; - - return StatusCode::SUCCESS; -} diff --git a/Phys/DecayTreeTupleMC/src/MCTupleToolRedecay.h b/Phys/DecayTreeTupleMC/src/MCTupleToolRedecay.h deleted file mode 100644 index 401a1271d7d5d9607732a9904d2794267907a442..0000000000000000000000000000000000000000 --- a/Phys/DecayTreeTupleMC/src/MCTupleToolRedecay.h +++ /dev/null @@ -1,41 +0,0 @@ -/*****************************************************************************\ -* (c) Copyright 2000-2018 CERN for the benefit of the LHCb Collaboration * -* * -* This software is distributed under the terms of the GNU General Public * -* Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". * -* * -* In applying this licence, CERN does not waive the privileges and immunities * -* granted to it by virtue of its status as an Intergovernmental Organization * -* or submit itself to any jurisdiction. * -\*****************************************************************************/ -#ifndef MCTUPLETOOLREDECAY_H -#define MCTUPLETOOLREDECAY_H 1 - -// Include files -// from Gaudi -#include "DecayTreeTupleBase/TupleToolBase.h" -#include "Kernel/IEventTupleTool.h" // Interface - -/** @class MCTupleToolRedecay MCTupleToolRedecay.h - * - * \brief Decodes evtTime to add redecay information to the ntuple. - * RD_org_eventNumber and RD_org_runNumber contain the event and run number - * of the original event to allow to group events stemming from the same - * original event. - * RD_i_event gives the index of the ReDecay event - * - * Tuple columns: - * - RD_org_eventNumber, RD_org_runNumber, RD_i_event - * - * @author Dominik Muller - * @date 2017-1-26 - */ -class MCTupleToolRedecay : public TupleToolBase, virtual public IEventTupleTool { -public: - /// Standard constructor - MCTupleToolRedecay( const std::string& type, const std::string& name, const IInterface* parent ); - - virtual ~MCTupleToolRedecay(); ///< Destructor - StatusCode fill( Tuples::Tuple& ) override; -}; -#endif // MCTUPLETOOLREDECAY_H diff --git a/Phys/DecayTreeTupleMC/src/MCTupleToolTOS.cpp b/Phys/DecayTreeTupleMC/src/MCTupleToolTOS.cpp deleted file mode 100644 index ec402a29b64bdbd1a12687d06cdcf86a69335063..0000000000000000000000000000000000000000 --- a/Phys/DecayTreeTupleMC/src/MCTupleToolTOS.cpp +++ /dev/null @@ -1,353 +0,0 @@ -/*****************************************************************************\ -* (c) Copyright 2000-2018 CERN for the benefit of the LHCb Collaboration * -* * -* This software is distributed under the terms of the GNU General Public * -* Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". * -* * -* In applying this licence, CERN does not waive the privileges and immunities * -* granted to it by virtue of its status as an Intergovernmental Organization * -* or submit itself to any jurisdiction. * -\*****************************************************************************/ -// Include files -#include "boost/regex.hpp" -#include "gsl/gsl_sys.h" - -// local -#include "Event/MCParticle.h" -#include "GaudiAlg/Tuple.h" -#include "GaudiAlg/TupleObj.h" -#include "MCTupleToolTOS.h" - -using namespace LHCb; -//----------------------------------------------------------------------------- -// Implementation file for class : MCTupleToolTOS -// -// 2020-03-03 : Ross Hunter -//----------------------------------------------------------------------------- - -// Declaration of the Tool Factory -DECLARE_COMPONENT( MCTupleToolTOS ) - -//============================================================================= -// Standard constructor, initializes variables -//============================================================================= -MCTupleToolTOS::MCTupleToolTOS( const std::string& type, const std::string& name, const IInterface* parent ) - : TupleToolBase( type, name, parent ) { - declareInterface( this ); -} - -//============================================================================= -// initialize -//============================================================================= -StatusCode MCTupleToolTOS::initialize() { - if ( !TupleToolBase::initialize() ) return StatusCode::FAILURE; - - if ( !m_triggerList.empty() ) compileTriggerLineList( m_triggerList ); - - if ( m_level.empty() ) { - error() << "Please specify the trigger level." << endmsg; - return StatusCode::FAILURE; - } - - return StatusCode::SUCCESS; -} - -bool MCTupleToolTOS::fetchLHCbIDsFromMCParticle( const LHCb::MCParticle* mcp, const LHCb::LinksByKey* mc2IdLink, - std::map& map_of_ID_weights ) { - // Recursive function to iterate over each child of the MCParticle and collect the LHCbIDs in map - - if ( !mcp->fromSignal() ) { - warning() << "MCParticle with ID " << mcp->particleID() << "is not fromSignal()!" << endmsg; - } - - // Add this track's LHCbIDs to the map - std::map this_track_map_of_ids{}; - mc2IdLink->applyToAllLinks( [&this_track_map_of_ids, &mcp]( unsigned int id, int mcPartKey, float weight ) { - if ( mcPartKey == mcp->key() ) { this_track_map_of_ids.insert( {LHCb::LHCbID( id ), weight} ); } - } ); - [[maybe_unused]] size_t this_track_size{this_track_map_of_ids.size()}; - [[maybe_unused]] size_t current_map_size{map_of_ID_weights.size()}; - if ( this_track_map_of_ids.size() > 0 ) { - map_of_ID_weights.merge( this_track_map_of_ids ); - if ( msgLevel( MSG::DEBUG ) ) { - debug() << "Added hits from MCP with ID " << mcp->particleID() << ". The map of IDs container now has size " - << map_of_ID_weights.size() << endmsg; - } - if ( map_of_ID_weights.size() != ( current_map_size + this_track_size ) and msgLevel( MSG::DEBUG ) ) { - debug() << "The map of IDs container should have had size " << ( current_map_size + this_track_size ) - << " but has size " << map_of_ID_weights.size() << ". Some hits must have been duplicated." << endmsg; - } - } else { - if ( msgLevel( MSG::DEBUG ) ) { - debug() << "This track has no LHCbIDs associated with it. Not adding to the map." << endmsg; - } - } - - // Now iterate through children and add their LHCbIDs to the map - // Use the MCParticle::endVertices method to get vertices on this track. Those that are are isDecay() are decay - // vertices - // TODO should we consider other types of vertex? I guess they are just radiating photons, material interactions etc. - // Use fromSignal() to give us a hint, but this will only work for EvtGen decays - const auto& endVertices = mcp->endVertices(); - if ( endVertices.size() != 1 and msgLevel( MSG::DEBUG ) ) { - debug() << "EndVertex container has size " << endVertices.size() << endmsg; - } - - for ( SmartRefVector::const_iterator vtx_iter = endVertices.begin(); vtx_iter != endVertices.end(); - ++vtx_iter ) { - const LHCb::MCVertex& decayVertex = *( vtx_iter->target() ); - if ( msgLevel( MSG::DEBUG ) ) { debug() << "This vertex is a decay vertex? " << decayVertex.isDecay() << endmsg; } - if ( decayVertex.isDecay() ) { - const auto& decayProducts = decayVertex.products(); - if ( msgLevel( MSG::DEBUG ) ) { - debug() << "Found a isDecay() vertex with products container with size " << decayProducts.size() << endmsg; - } - for ( SmartRefVector::const_iterator part_iter = decayProducts.begin(); - part_iter != decayProducts.end(); ++part_iter ) { - const LHCb::MCParticle* childParticle = part_iter->target(); - if ( !childParticle->fromSignal() ) { warning() << "This particle is not fromSignal" << endmsg; } - if ( !fetchLHCbIDsFromMCParticle( childParticle, mc2IdLink, map_of_ID_weights ) ) { return false; } - } - } else { - if ( msgLevel( MSG::DEBUG ) ) { debug() << "This is not a decay vertex. Going no further." << endmsg; } - continue; - } - } - - if ( msgLevel( MSG::DEBUG ) ) { - debug() << "Finished collecting IDs for MCParticle with ID " << mcp->particleID() << endmsg; - } - return true; -} - -std::map MCTupleToolTOS::getCandidateLHCbMap( const LHCb::HltObjectSummary& topLevelSummary ) { - - const SmartRefVector& sub = topLevelSummary.substructure(); - if ( msgLevel( MSG::DEBUG ) ) { - debug() << "Attempting to break down the selection summary into its subsummaries" << endmsg; - debug() << "There are " << sub.size() << " HltObjectSummary objects/Trigger Candidates in the topLevelSummary" - << endmsg; - } - std::map idsByTriggerCandidateMap{}; - - if ( topLevelSummary.summarizedObjectCLID() == 1 ) { - // A selection summary, made up of tracks and vertices - if ( msgLevel( MSG::DEBUG ) ) { - debug() << "Found a selection summary. Printing..." << endmsg; - std::cout << topLevelSummary << std::endl; - } - - int iCand = 0; - for ( SmartRefVector::const_iterator subsummary_iter = sub.begin(); - subsummary_iter != sub.end(); ++subsummary_iter ) { - const LHCb::HltObjectSummary& subsummary = *( subsummary_iter->target() ); - IDvec thisCandIDVec{}; - fetchLHCbIDsFromHOS( subsummary, thisCandIDVec ); - auto result = idsByTriggerCandidateMap.insert( std::pair( thisCandIDVec, iCand ) ); - if ( !result.second ) { warning() << "Insertion failed. Seems this candidate is already there." << endmsg; } - iCand++; - } - } else { - warning() << "Not a selection summary. Dont know what to do with this object with summarizedObjectCLID " - << topLevelSummary.summarizedObjectCLID() << endmsg; - } - return idsByTriggerCandidateMap; -} - -bool MCTupleToolTOS::fetchLHCbIDsFromHOS( const LHCb::HltObjectSummary& hltObjectSummary, IDvec& bucket_of_ids ) { - // Recursive function to iterate over each track of the trigger candidate and collect the LHCbIDs in bucket_of_ids - - const SmartRefVector& sub = hltObjectSummary.substructure(); - - if ( hltObjectSummary.summarizedObjectCLID() == 10030 ) { - // Vertex-like summary -> should be made of tracks and further vertices -> pass on the substructure... - if ( msgLevel( MSG::DEBUG ) ) { - debug() << "Found a vertex-like object with IDs. Passing on the substructure..." << endmsg; - debug() << "This vertex has " << sub.size() << " objects within it" << endmsg; - } - bool isEmptySummary = true; - for ( SmartRefVector::const_iterator subsummary_iter = sub.begin(); - subsummary_iter != sub.end(); ++subsummary_iter ) { - const LHCb::HltObjectSummary& subsummary = *( subsummary_iter->target() ); - if ( msgLevel( MSG::DEBUG ) ) { - debug() << "This sub-object has CLID " << subsummary.summarizedObjectCLID() << endmsg; - } - fetchLHCbIDsFromHOS( subsummary, bucket_of_ids ); - isEmptySummary = false; - } - if ( isEmptySummary ) { return false; } - } else if ( hltObjectSummary.summarizedObjectCLID() == 10010 ) { - // Track-like -> add to the bucket. - if ( msgLevel( MSG::DEBUG ) ) { debug() << "Found a track-like object with IDs. Adding to bucket..." << endmsg; } - bucket_of_ids.insert( bucket_of_ids.end(), hltObjectSummary.lhcbIDs().begin(), hltObjectSummary.lhcbIDs().end() ); - - // NOTE it seems that the lhcbIDs() and lhcbIDsFlattened() method do the same thing, or the case where they differ - // is unknown to me so we'll put this to catch when this case arises: - assert( hltObjectSummary.lhcbIDs() == hltObjectSummary.lhcbIDsFlattened() ); - } else { - warning() << "Dont know how to handle object with summarizedObjectCLID " << hltObjectSummary.summarizedObjectCLID() - << endmsg; - return false; - } - return true; -} - -//============================================================================= -// Fill -//============================================================================= -StatusCode MCTupleToolTOS::fill( const LHCb::MCParticle*, const LHCb::MCParticle* mcp, const std::string& head, - Tuples::Tuple& tuple ) { - const std::string prefix = fullName( head ); - - // TODO need to figure out why it looks like this is all getting called twice. - - std::vector names = std::vector( 0 ); - if ( m_level == "Hlt1" ) { - names = m_hlt1; - } else if ( m_level == "Hlt2" ) { - names = m_hlt2; - } else { - return StatusCode::FAILURE; - } - - if ( mcp != 0 ) { - - // Get the LHCbIDs from the MCParticle - LHCb::LinksByKey* mcp_id_link = m_mc2IdLinkDh.get(); - if ( !mcp_id_link ) { - // Should always be available... - return Error( "Cannot load the MC 2 ID links Location object", StatusCode::SUCCESS ); - } - - // TODO is weight always =1? If so a simpler vector will suffice. - std::map mcp_ID_map{}; - if ( !fetchLHCbIDsFromMCParticle( mcp, mcp_id_link, mcp_ID_map ) ) { - fatal() << "Failed to get all the IDs from the MCParticle." << endmsg; - } else { - if ( msgLevel( MSG::DEBUG ) ) { - debug() << "Fetched all the IDs from the MCParticle. Printing..." << endmsg; - std::cout << mcp_ID_map << std::endl; - } - } - - // Open up the SelReports - LHCb::HltSelReports* selReports = m_hltSelReportDh.get(); - if ( !selReports ) { - // Should always be available... - return Error( "Cannot load the Hlt SelReport Location object", StatusCode::SUCCESS ); - } - - for ( std::vector::const_iterator n = names.begin(); n != names.end(); ++n ) { - if ( msgLevel( MSG::DEBUG ) ) { debug() << "Trying to fill " << ( *n ) << endmsg; } - // individual Hlt trigger lines - bool tos_on_this_line{false}; - std::vector mc_match_fracs, reco_match_fracs, mc_unmatch_fracs; - - // Then loop over the sel reports - for ( LHCb::HltSelReports::Container::const_iterator it = selReports->begin(); it != selReports->end(); ++it ) { - if ( ( it->first == *n ) ) { - - if ( msgLevel( MSG::DEBUG ) ) { - debug() << "The line " << *n << " fired on the event with this candidate in it." << endmsg; - debug() << "Getting the LHCbIDs in a map, one vector for each trigger candidate." << endmsg; - } - - LHCb::HltObjectSummary hltObjectSummary = it->second; - auto idsByCandidateMap = getCandidateLHCbMap( hltObjectSummary ); - if ( msgLevel( MSG::DEBUG ) ) { - debug() << "Found " << idsByCandidateMap.size() << " candidates that fired the trigger" << endmsg; - } - - for ( auto const& [trig_cand_IDs, i] : idsByCandidateMap ) { - - float n_matching_IDs{0.f}; - for ( const auto& id : trig_cand_IDs ) { - const auto iter = mcp_ID_map.find( id ); - if ( iter != mcp_ID_map.end() ) { n_matching_IDs += iter->second; } - } - - float mc_match_frac{1.f}; - float reco_match_frac{1.f}; - float mc_unmatch_frac{0.f}; - - mc_match_frac = n_matching_IDs / mcp_ID_map.size(); - reco_match_frac = n_matching_IDs / trig_cand_IDs.size(); - mc_unmatch_frac = 1.f - mc_match_frac; - if ( msgLevel( MSG::DEBUG ) ) { - debug() << "Fraction of MCP hits that overlap with candidate " << i << " is " - << std::to_string( mc_match_frac ) << endmsg; - debug() << "Fraction of trig candidate " << i << " that overlap with the MCP is (TOS) " - << std::to_string( reco_match_frac ) << endmsg; - debug() << "Fraction of MCP hits that dont overlap with candidate " << i << " is " - << std::to_string( mc_unmatch_frac ) << endmsg; - } - assert( reco_match_frac <= 1.f ); - tos_on_this_line |= reco_match_frac >= tos_threshold ? true : false; - - mc_match_fracs.emplace_back( mc_match_frac ); - reco_match_fracs.emplace_back( reco_match_frac ); - mc_unmatch_fracs.emplace_back( mc_unmatch_frac ); - } - if ( msgLevel( MSG::DEBUG ) ) { - debug() << "For trigger with name = " << it->first << ", TOS decision = " << tos_on_this_line - << " on MCParticle with ID " << mcp->particleID() << endmsg; - } - } - } - - if ( !tuple->column( prefix + "_" + *n + "TOS", tos_on_this_line ) ) { return StatusCode::FAILURE; } - if ( !tuple->farray( prefix + "_" + *n + "MCMatchFracs", mc_match_fracs.begin(), mc_match_fracs.end(), - prefix + "_" + *n + "NCandidates", max_candidates ) ) { - return StatusCode::FAILURE; - } - if ( !tuple->farray( prefix + "_" + *n + "TOSMatchFracs", reco_match_fracs.begin(), reco_match_fracs.end(), - prefix + "_" + *n + "NCandidates", max_candidates ) ) { - return StatusCode::FAILURE; - } - if ( !tuple->farray( prefix + "_" + *n + "MCUnMatchFracs", mc_unmatch_fracs.begin(), mc_unmatch_fracs.end(), - prefix + "_" + *n + "NCandidates", max_candidates ) ) { - return StatusCode::FAILURE; - } - } - // TODO add a total nTOS branch? - } else { - warning() << "Arghhh! Particle = 0... Not doing anything" << endmsg; - } - - if ( msgLevel( MSG::DEBUG ) ) { debug() << "Done " << prefix << " " << m_level << endmsg; } - - return StatusCode::SUCCESS; -} - -bool MCTupleToolTOS::compileTriggerLineList( const std::vector& list ) { - - if ( msgLevel( MSG::DEBUG ) ) debug() << "compiling List " << endmsg; - - boost::regex hlt1( "Hlt1.*Decision" ); - boost::regex hlt2( "Hlt2.*Decision" ); - - for ( std::vector::const_iterator s = list.begin(); s != list.end(); ++s ) { - if ( boost::regex_match( *s, hlt1 ) ) { - m_hlt1.push_back( *s ); - } else if ( boost::regex_match( *s, hlt2 ) ) { - m_hlt2.push_back( *s ); - } else { - error() << "List member ``" << *s - << "'' does not match any known pattern. Have you forgotten the trailing 'Decision'? " << endmsg; - } - } - - if ( msgLevel( MSG::DEBUG ) ) { - debug() << " ==== HLT1 ==== " << endmsg; - for ( std::vector::const_iterator s = m_hlt1.begin(); s != m_hlt1.end(); ++s ) - debug() << " " << ( *s ); - debug() << endmsg; - debug() << " ==== HLT2 ==== " << endmsg; - for ( std::vector::const_iterator s = m_hlt2.begin(); s != m_hlt2.end(); ++s ) - debug() << " " << ( *s ); - debug() << endmsg; - debug() << " ==== Compiled list ====" << endmsg; - } - - return true; -} \ No newline at end of file diff --git a/Phys/DecayTreeTupleMC/src/MCTupleToolTOS.h b/Phys/DecayTreeTupleMC/src/MCTupleToolTOS.h deleted file mode 100644 index 56be678d438caa4ea0fcb7a92b6e0cf3518b4a8a..0000000000000000000000000000000000000000 --- a/Phys/DecayTreeTupleMC/src/MCTupleToolTOS.h +++ /dev/null @@ -1,75 +0,0 @@ -/*****************************************************************************\ -* (c) Copyright 2000-2018 CERN for the benefit of the LHCb Collaboration * -* * -* This software is distributed under the terms of the GNU General Public * -* Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". * -* * -* In applying this licence, CERN does not waive the privileges and immunities * -* granted to it by virtue of its status as an Intergovernmental Organization * -* or submit itself to any jurisdiction. * -\*****************************************************************************/ -#ifndef MCTUPLETOOLTOS_H -#define MCTUPLETOOLTOS_H 1 - -#include "DecayTreeTupleBase/TupleToolBase.h" -#include "Event/HltSelReports.h" -#include "Event/RecVertex.h" -#include "GaudiKernel/DataObjectHandle.h" -#include "Kernel/IMCParticleTupleTool.h" // Interface -#include "Kernel/Particle2MCLinker.h" - -/** @class MCTupleToolTOS MCTupleToolTOS.h - * - * Add "trigger-on-signal" decision flags to the tuple, as well as other related information on the trigger candidate - - * MCParticle matching - * - * Matching is done by extracting the LHCbIDs (hits) from the MCParticle and the trigger candidate, - * then comparing the two containers of hits. If there is greater than or equal to fraction of the - * MCParticle hits overlapping, then we declare that the trigger candidate was TOS with respect to that MCParticle. If - * at least one trigger candidate has triggered on the signal, then that line has triggered on the signal in the event. - * - * NOTE that currently all hits from each track in the trigger candidate are all aggregated into a single container. - * We then compare this container to the MCParticle's hits. For trigger candidates made up of e.g. 4 tracks, - * this method will say a trigger is TOS if only 3 of the 4 tracks are indeed from the signal. - * - * \todo TOS match on a track-by-track basis to fix this issue. - * - * See for further description of the algorithm and results on a simple - * test case. - * - * \sa MCDecayTreeTuple - * - * @author Ross Hunter - * @date 2020-03-03 - */ - -using IDvec = std::vector; -class MCTupleToolTOS : public TupleToolBase, virtual public IMCParticleTupleTool { -public: - /// Standard constructor - MCTupleToolTOS( const std::string& type, const std::string& name, const IInterface* parent ); - StatusCode initialize() override; - StatusCode fill( const LHCb::MCParticle*, const LHCb::MCParticle*, const std::string&, Tuples::Tuple& ) override; - -private: - bool fetchLHCbIDsFromHOS( const LHCb::HltObjectSummary& hltObjectSummary, IDvec& bucket_of_ids ); - bool fetchLHCbIDsFromMCParticle( const LHCb::MCParticle* mcp, const LHCb::LinksByKey* mc2IdLink, - std::map& map_of_ids ); - std::map getCandidateLHCbMap( const LHCb::HltObjectSummary& topLevelSummary ); - bool compileTriggerLineList( const std::vector& ); - -private: - DataObjectReadHandle m_hltSelReportDh = {this, "HltSelReports", - LHCb::HltSelReportsLocation::Default}; - DataObjectReadHandle m_mc2IdLinkDh = {this, "MC2IDLink", - "Link/Pr/LHCbID"}; // FIXME is there a default? - - Gaudi::Property tos_threshold{this, "tos_threshold", {0.70}}; - Gaudi::Property max_candidates{this, "max_candidates", {20}}; - Gaudi::Property m_level{this, "Level", "Hlt1"}; - std::vector m_hlt1{std::vector( 0 )}; - std::vector m_hlt2{std::vector( 0 )}; - Gaudi::Property> m_triggerList{ - this, "TriggerList", std::vector( 0 )}; // property: list of triggers to specifically look at -}; -#endif // MCTUPLETOOLTOS_H diff --git a/Phys/DecayTreeTupleMC/src/TupleToolMCBackgroundInfo.cpp b/Phys/DecayTreeTupleMC/src/TupleToolMCBackgroundInfo.cpp deleted file mode 100755 index 8482f3738fe67f8976bc85bdb844e315d787b770..0000000000000000000000000000000000000000 --- a/Phys/DecayTreeTupleMC/src/TupleToolMCBackgroundInfo.cpp +++ /dev/null @@ -1,89 +0,0 @@ -/*****************************************************************************\ -* (c) Copyright 2000-2018 CERN for the benefit of the LHCb Collaboration * -* * -* This software is distributed under the terms of the GNU General Public * -* Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". * -* * -* In applying this licence, CERN does not waive the privileges and immunities * -* granted to it by virtue of its status as an Intergovernmental Organization * -* or submit itself to any jurisdiction. * -\*****************************************************************************/ - -#include "DecayTreeTupleBase/TupleToolBase.h" - -#include "Kernel/IBackgroundCategory.h" -#include "Kernel/IParticleTupleTool.h" - -#include "Event/Particle.h" - -#include "GaudiAlg/Tuple.h" -#include "GaudiAlg/TupleObj.h" - -/** - * \brief Fill the info from IBackgroundCategory - * - * An answer is only filled for composite particles. - * - * IBackgroundCategory controlled by property IBackgroundCatagoryType, default "BackgroundCategory". - * - * head_BKGCAT : category. - * - * \sa DecayTreeTuple - * - * @author Jeremie Borel - * @date 2007-11-07 - */ -class TupleToolMCBackgroundInfo : public TupleToolBase, virtual public IParticleTupleTool { - -public: - TupleToolMCBackgroundInfo( const std::string& type, const std::string& name, const IInterface* parent ); - StatusCode initialize() override; - StatusCode fill( const LHCb::Particle*, const LHCb::Particle*, const std::string&, Tuples::Tuple&, - IGeometryInfo const& ) override; - -private: - std::vector m_backCatTypes; - std::vector m_bkgs; -}; - -using namespace LHCb; - -TupleToolMCBackgroundInfo::TupleToolMCBackgroundInfo( const std::string& type, const std::string& name, - const IInterface* parent ) - : TupleToolBase( type, name, parent ) { - declareInterface( this ); - m_backCatTypes.push_back( "BackgroundCategoryViaRelations" ); - m_backCatTypes.push_back( "BackgroundCategory" ); - declareProperty( "IBackgroundCategoryTypes", m_backCatTypes ); -} - -StatusCode TupleToolMCBackgroundInfo::initialize() { - const StatusCode sc = TupleToolBase::initialize(); - if ( sc.isFailure() ) return sc; - if ( msgLevel( MSG::DEBUG ) ) debug() << "Background Category tools " << m_backCatTypes << endmsg; - for ( std::vector::const_iterator iT = m_backCatTypes.begin(); iT != m_backCatTypes.end(); ++iT ) { - m_bkgs.push_back( tool( *iT, *iT, this ) ); - } - return sc; -} - -StatusCode TupleToolMCBackgroundInfo::fill( const Particle* headP, const Particle* P, const std::string& head, - Tuples::Tuple& tuple, IGeometryInfo const& ) { - StatusCode sc = StatusCode::SUCCESS; - const std::string prefix = fullName( head ); - Assert( P && !m_bkgs.empty(), "This should not happen :(" ); - if ( !P->isBasicParticle() ) { - IBackgroundCategory::categories cat = IBackgroundCategory::Undefined; - for ( std::vector::const_iterator iT = m_bkgs.begin(); iT != m_bkgs.end(); ++iT ) { - cat = ( *iT )->category( P, headP ).category; - if ( cat != IBackgroundCategory::Undefined ) break; - } - if ( msgLevel( MSG::DEBUG ) ) debug() << "BackgroundCategory decision for " << prefix << " : " << cat << endmsg; - sc = tuple->column( prefix + "_BKGCAT", (int)cat ); - } - return sc; -} - -// Declaration of the Tool Factory -// actually acts as a using namespace TupleTool -DECLARE_COMPONENT( TupleToolMCBackgroundInfo ) diff --git a/Phys/DecayTreeTupleMC/src/TupleToolMCPVAssociation.cpp b/Phys/DecayTreeTupleMC/src/TupleToolMCPVAssociation.cpp deleted file mode 100644 index e328fbf8a91cd5a25d8f5e8cd8f6d1c3d5ec9f7a..0000000000000000000000000000000000000000 --- a/Phys/DecayTreeTupleMC/src/TupleToolMCPVAssociation.cpp +++ /dev/null @@ -1,222 +0,0 @@ -/*****************************************************************************\ -* (c) Copyright 2000-2018 CERN for the benefit of the LHCb Collaboration * -* * -* This software is distributed under the terms of the GNU General Public * -* Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". * -* * -* In applying this licence, CERN does not waive the privileges and immunities * -* granted to it by virtue of its status as an Intergovernmental Organization * -* or submit itself to any jurisdiction. * -\*****************************************************************************/ - -#include - -#include -#include -#include - -#include -#include - -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#include -#include -#include - -#include - -/** - * Ask if the head is association to the correct PV - * Adapted from TupleToolMCKinematic - * See the properties inline documentation to toggle on/off some of - * the columns - * - * - head_MCPV_[XYZ] : the position of the MC PV of the MC particle associated to the candidate. - * - head_RecPVToMCPV_Chi2 : the chi2 of the reco'd PV wrt the MC PV. - * - head_RecPV_correct : whether the candidate's best PV is associated to the correct MC PV. - * - head_RecPV_nMatchTracks : the number of tracks in the candidate's best PV that're associated to the MC PV. - * - head_RecPV_matchFrac : the fraction of tracks in the candidate's best PV that're associated to the MC PV. - * - * Note that the PV2MC tool that's used to do the PV associations requires the Track -> MCParticle association - * table to be in the format produced by LoKi::Track2MC, so you'll need to run an instance of this in your - * sequence before the DecayTreeTuple. Also, for run 2, the tracks used to fit the PVs are contained in - * Rec/Track/FittedHLT1VeloTracks, so you'll need to add this to the Tracks attribute of LoKi::Track2MC. - * - * \sa TupleToolPV2MC, DecayTreeTuple, MCDecayTreeTuple, PV2MC, Track2MC - * - * @author Michael Alexander & Adam Davis - * @date 2018-05-09 - */ -class TupleToolMCPVAssociation : public TupleToolBase, virtual public IParticleTupleTool { -public: - TupleToolMCPVAssociation( const std::string& type, const std::string& name, const IInterface* parent ); - virtual StatusCode initialize() override; - virtual StatusCode fill( const LHCb::Particle*, const LHCb::Particle*, const std::string&, Tuples::Tuple&, - IGeometryInfo const& ) override; - -private: - Gaudi::Property> m_p2mcAssocTypes{ - this, - "IP2MCPAssociatorTypes", - {"DaVinciSmartAssociator", "MCMatchObjP2MCRelator"}, - "Types of particle -> MC particle associators to be used (in order)."}; - std::vector m_p2mcAssocs; - Gaudi::Property m_pv2mctooltype{this, "PV2MCToolType", "LoKi::PV2MC", - "Type of PV2MC tool to be used (must inherit from IPV2MC)"}; - IPV2MC* m_pv2mctool = nullptr; - IDVAlgorithm* m_dva = nullptr; -}; - -using namespace LHCb; - -//============================================================================= -// Standard constructor, initializes variables -//============================================================================= -TupleToolMCPVAssociation::TupleToolMCPVAssociation( const std::string& type, const std::string& name, - const IInterface* parent ) - : TupleToolBase( type, name, parent ) { - declareInterface( this ); -} - -//============================================================================= -// initialize -//============================================================================= -StatusCode TupleToolMCPVAssociation::initialize() { - const StatusCode sc = TupleToolBase::initialize(); - if ( sc.isFailure() ) return StatusCode::FAILURE; - m_pv2mctool = tool( m_pv2mctooltype ); - // the MC associators - m_p2mcAssocs.clear(); - for ( std::vector::const_iterator iMCAss = m_p2mcAssocTypes.begin(); iMCAss != m_p2mcAssocTypes.end(); - ++iMCAss ) { - m_p2mcAssocs.push_back( tool( *iMCAss, this ) ); - } - if ( m_p2mcAssocs.empty() ) { return Error( "No MC associators configured" ); } - - m_dva = Gaudi::Utils::getIDVAlgorithm( contextSvc(), this ); - if ( 0 == m_dva ) return Error( "Couldn't get parent DVAlgorithm", StatusCode::FAILURE ); - - return sc; -} - -//============================================================================= -// Fill -//============================================================================= -StatusCode TupleToolMCPVAssociation::fill( const LHCb::Particle*, const LHCb::Particle* P, const std::string& head, - Tuples::Tuple& tuple, IGeometryInfo const& geometry ) { - if ( msgLevel( MSG::DEBUG ) ) { - debug() << "TupleToolMCPVAssociation::fill " << head << endmsg; - debug() << "P = " << P << endmsg; - } - - const std::string prefix = fullName( head ); - - LHCb::RecVertex* recpv = (LHCb::RecVertex*)m_dva->bestVertex( P, geometry ); - - const LHCb::MCParticle* mcp( NULL ); - - // get the MC particle. (depends on signal decay association) this can only work for true decays... - if ( P ) { - for ( std::vector::const_iterator iMCAss = m_p2mcAssocs.begin(); - iMCAss != m_p2mcAssocs.end(); ++iMCAss ) { - // first check to see if there is a particle association to the head. If so, that's easy! - mcp = ( *iMCAss )->relatedMCP( P ); - if ( mcp ) break; - } - } - // get the PV of the head of the chain. - LHCb::MCVertex* head_vtx( NULL ); - if ( mcp ) { - head_vtx = (LHCb::MCVertex*)mcp->primaryVertex(); - - if ( msgLevel( MSG::DEBUG ) ) { - debug() << "head_vtx filled. checking" << endmsg; - debug() << "Checkpoint 1, got MC Particle" << mcp << endmsg; - if ( head_vtx ) { debug() << "Checkpoint 2, got head vertex" << head_vtx << endmsg; } - } - } else if ( msgLevel( MSG::DEBUG ) ) - debug() << "Checkpoint 1, no MC particle found." << endmsg; - - // Get the PV<->MCPV relations table. - const IPV2MC::PV2MC* pv2mctable = m_pv2mctool->pv2MC(); - auto pvrelations = pv2mctable->relations( recpv ); - // match by position in case match by pointer fails. - if ( pvrelations.empty() ) { - for ( auto& relation : pv2mctable->relations() ) { - if ( relation.from()->position() == recpv->position() ) { - pvrelations = pv2mctable->relations( relation.from() ); - break; - } - } - } - - if ( msgLevel( MSG::DEBUG ) ) { - debug() << "name " << prefix << endmsg; - debug() << "recpv " << recpv << " " << recpv->position() << endmsg; - if ( head_vtx ) - debug() << "mcpv " << head_vtx << " " << head_vtx->position() << endmsg; - else - debug() << "mcpv " << head_vtx << " " - << "None" << endmsg; - for ( auto& relation : pv2mctable->relations() ) { - debug() << "from " << relation.from() << " " << relation.from()->position() << " to " << relation.to() << " " - << relation.to()->position() << " weight.first " << relation.weight().first << " weight.second " - << relation.weight().second << endmsg; - } - } - - // fill the tuple - bool test( true ); - if ( NULL == head_vtx ) { - test &= tuple->column( prefix + "_MCPV_X", 0. ); - test &= tuple->column( prefix + "_MCPV_Y", 0. ); - test &= tuple->column( prefix + "_MCPV_Z", 0. ); - test &= tuple->column( prefix + "_RecPVToMCPV_Chi2", -1. ); - // test &= tuple->column(prefix + "_MCPV_recible", -1); - test &= tuple->column( prefix + "_RecPV_correct", -1 ); - test &= tuple->column( prefix + "_RecPV_nMatchTracks", 0 ); - test &= tuple->column( prefix + "_RecPV_matchFrac", 0.F ); - } else { - test &= tuple->column( prefix + "_MCPV_X", head_vtx->position().x() ); - test &= tuple->column( prefix + "_MCPV_Y", head_vtx->position().y() ); - test &= tuple->column( prefix + "_MCPV_Z", head_vtx->position().z() ); - // not sure now to get this in the current framework. - // test &= tuple->column( prefix + "_MCPV_recible", -1); - if ( pvrelations.empty() ) { - test &= tuple->column( prefix + "_RecPVToMCPV_Chi2", -1. ); - test &= tuple->column( prefix + "_RecPV_correct", -1 ); - test &= tuple->column( prefix + "_RecPV_nMatchTracks", 0 ); - test &= tuple->column( prefix + "_RecPV_matchFrac", 0.F ); - } else { - auto relation = pvrelations.back(); - LHCb::MCVertex* matchmcpv = relation.to(); - int ntracks = relation.weight().first; - float matchfrac = float( ntracks ) / relation.from()->tracks().size(); - double chi2 = -relation.weight().second; - if ( msgLevel( MSG::DEBUG ) ) - debug() << "matchpv " << matchmcpv << " " << matchmcpv->position() << " " << ntracks << " " << chi2 << " " - << matchfrac << endmsg; - test &= tuple->column( prefix + "_RecPVToMCPV_Chi2", chi2 ); - test &= tuple->column( prefix + "_RecPV_correct", int( matchmcpv == head_vtx ) ); - test &= tuple->column( prefix + "_RecPV_nMatchTracks", ntracks ); - test &= tuple->column( prefix + "_RecPV_matchFrac", matchfrac ); - } - } - - return StatusCode( test ); -} - -// Declaration of the Tool Factory -// actually acts as a using namespace TupleTool -DECLARE_COMPONENT( TupleToolMCPVAssociation ) diff --git a/Phys/DecayTreeTupleMC/src/TupleToolMCTruth.cpp b/Phys/DecayTreeTupleMC/src/TupleToolMCTruth.cpp deleted file mode 100755 index c42dbf9bdf669038fe670f2342a9e40460316977..0000000000000000000000000000000000000000 --- a/Phys/DecayTreeTupleMC/src/TupleToolMCTruth.cpp +++ /dev/null @@ -1,137 +0,0 @@ -/*****************************************************************************\ -* (c) Copyright 2000-2018 CERN for the benefit of the LHCb Collaboration * -* * -* This software is distributed under the terms of the GNU General Public * -* Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". * -* * -* In applying this licence, CERN does not waive the privileges and immunities * -* granted to it by virtue of its status as an Intergovernmental Organization * -* or submit itself to any jurisdiction. * -\*****************************************************************************/ - -#include "DecayTreeTupleBase/TupleToolBase.h" - -#include "Kernel/IMCParticleTupleTool.h" -#include "Kernel/IParticle2MCAssociator.h" -#include "Kernel/IParticleTupleTool.h" - -#include "Event/MCParticle.h" -#include "Event/Particle.h" - -#include "GaudiAlg/Tuple.h" -#include "GaudiAlg/TupleObj.h" -#include "GaudiKernel/PhysicalConstants.h" - -#include "gsl/gsl_sys.h" - -#include - -/** - * \brief Fill MC truth info if a link is present - * - * Uses an IParticle2MCAssociator to perform the association. - * Properties: - * - * IP2MCPAssociatorType: Implementation of IP2MCAssociator to be used. Default: DaVinciSmartAssociator. - * - * ToolList: List of MCTupleTools to run. Default: [MCTupleToolKinematic] - * - * - head_TRUEID : true pid - * - * To add more entries, add the appropriate MCTupleTool - * Configure the option ToolList to add MCTupleTools - * The MCAssociation is run only once, then these tuple tools are called - * \sa DecayTreeTuple - * - * @author Jeremie Borel - * @date 2007-11-07 - * 2008-09-23 Adlene Hicheur - Added true angles information for P2VV - * 2009-06-03 Rob Lambert - Major Changes - */ -class TupleToolMCTruth : public TupleToolBase, virtual public IParticleTupleTool { - -public: - TupleToolMCTruth( const std::string& type, const std::string& name, const IInterface* parent ); - StatusCode fill( const LHCb::Particle*, const LHCb::Particle*, const std::string&, Tuples::Tuple&, - IGeometryInfo const& ) override; - StatusCode initialize() override; - -private: - std::vector m_p2mcAssocs; - std::vector m_p2mcAssocTypes; - std::vector m_toolList; ///< names of all MCTupleTools, set by the option ToolList - - std::vector m_mcTools; ///< vector of MCTools to fill -}; - -using namespace LHCb; - -TupleToolMCTruth::TupleToolMCTruth( const std::string& type, const std::string& name, const IInterface* parent ) - : TupleToolBase( type, name, parent ), m_toolList( 1, "MCTupleToolKinematic" ) { - // interface - declareInterface( this ); - // The names of MCTupleTools to use on the associated mcp - declareProperty( "ToolList", m_toolList ); - // MC associators to try, in order - m_p2mcAssocTypes.push_back( "DaVinciSmartAssociator" ); - m_p2mcAssocTypes.push_back( "MCMatchObjP2MCRelator" ); - declareProperty( "IP2MCPAssociatorTypes", m_p2mcAssocTypes ); -} - -StatusCode TupleToolMCTruth::initialize() { - const StatusCode sc = TupleToolBase::initialize(); - if ( sc.isFailure() ) return sc; - // the MC associators - m_p2mcAssocs.clear(); - for ( std::vector::const_iterator iMCAss = m_p2mcAssocTypes.begin(); iMCAss != m_p2mcAssocTypes.end(); - ++iMCAss ) { - m_p2mcAssocs.push_back( tool( *iMCAss, this ) ); - } - if ( m_p2mcAssocs.empty() ) { return Error( "No MC associators configured" ); } - // remove duplicate tools from the list - std::sort( m_toolList.begin(), m_toolList.end() ); - m_toolList.erase( std::unique( m_toolList.begin(), m_toolList.end() ), m_toolList.end() ); - // initialise the tuple tools - for ( std::vector::const_iterator it = m_toolList.begin(); m_toolList.end() != it; ++it ) { - if ( msgLevel( MSG::VERBOSE ) ) verbose() << "Adding the tool " << *it << endmsg; - IMCParticleTupleTool* aTool = tool( *it, this ); - if ( aTool ) { - m_mcTools.push_back( aTool ); - } else { - Warning( "There was a problem retrieving " + *it + " , this tool will be ignored" ).ignore(); - } - } - if ( msgLevel( MSG::VERBOSE ) ) { - verbose() << "Completed TupleTool intialisation, " << m_mcTools.size() << " tools added " << endmsg; - } - return sc; -} - -StatusCode TupleToolMCTruth::fill( const LHCb::Particle*, const LHCb::Particle* P, const std::string& head, - Tuples::Tuple& tuple, IGeometryInfo const& ) { - const std::string prefix = fullName( head ); - bool test = true; - const LHCb::MCParticle* mcp( NULL ); - if ( P ) { - // assignedPid = P->particleID().pid(); - if ( msgLevel( MSG::VERBOSE ) ) verbose() << "Getting related MCP to " << P << endmsg; - for ( std::vector::const_iterator iMCAss = m_p2mcAssocs.begin(); - iMCAss != m_p2mcAssocs.end(); ++iMCAss ) { - mcp = ( *iMCAss )->relatedMCP( P ); - if ( mcp ) break; - } - if ( msgLevel( MSG::VERBOSE ) ) verbose() << "Got mcp " << mcp << endmsg; - } - // pointer is ready, prepare the values - const int mcPid = ( mcp ? mcp->particleID().pid() : 0 ); - // fill the tuple: - test &= tuple->column( prefix + "_TRUEID", mcPid ); - // fill all requested MCTools - for ( std::vector::const_iterator it = m_mcTools.begin(); it != m_mcTools.end(); ++it ) { - test &= ( *it )->fill( NULL, mcp, prefix, tuple ); - } - return StatusCode( test ); -} - -// Declaration of the Tool Factory -DECLARE_COMPONENT( TupleToolMCTruth ) diff --git a/Phys/DecayTreeTupleMC/src/TupleToolPV2MC.cpp b/Phys/DecayTreeTupleMC/src/TupleToolPV2MC.cpp deleted file mode 100644 index 907f824f40b2cd205a0ab349ecc59893b978e3e7..0000000000000000000000000000000000000000 --- a/Phys/DecayTreeTupleMC/src/TupleToolPV2MC.cpp +++ /dev/null @@ -1,151 +0,0 @@ -/*****************************************************************************\ -* (c) Copyright 2000-2018 CERN for the benefit of the LHCb Collaboration * -* * -* This software is distributed under the terms of the GNU General Public * -* Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". * -* * -* In applying this licence, CERN does not waive the privileges and immunities * -* granted to it by virtue of its status as an Intergovernmental Organization * -* or submit itself to any jurisdiction. * -\*****************************************************************************/ -// Include files - -// from Gaudi -#include -#include -#include -#include - -// local -#include "TupleToolPV2MC.h" - -#include - -// Relations -#include -#include -#include - -using std::vector; - -//----------------------------------------------------------------------------- -// Implementation file for class : TupleToolPV2MC -// -// 2018-05-09 - Michael Alexander -//----------------------------------------------------------------------------- - -//============================================================================= -// Standard constructor, initializes variables -//============================================================================= -TupleToolPV2MC::TupleToolPV2MC( const std::string& type, const std::string& name, const IInterface* parent ) - : TupleToolBase( type, name, parent ) { - declareInterface( this ); -} - -StatusCode TupleToolPV2MC::initialize() { - const StatusCode sc = TupleToolBase::initialize(); - if ( sc.isFailure() ) return StatusCode::FAILURE; - m_pv2mc = tool( m_pv2mctooltype ); - return sc; -} - -//============================================================================= -StatusCode TupleToolPV2MC::fill( Tuples::Tuple& tuple ) { - const std::string prefix = fullName(); - - if ( msgLevel( MSG::VERBOSE ) ) verbose() << "getting MCHeader" << endmsg; - if ( !exist( LHCb::MCHeaderLocation::Default ) ) { - Warning( "No MCHeader at " + LHCb::MCHeaderLocation::Default, StatusCode::SUCCESS, 1 ) - .ignore( /* AUTOMATICALLY ADDED FOR gaudi/Gaudi!763 */ ); - return StatusCode::SUCCESS; - } - const LHCb::MCHeader* mch = get( LHCb::MCHeaderLocation::Default ); - vector mcpvs; - for ( SmartRefVector::const_iterator i = mch->primaryVertices().begin(); - i != mch->primaryVertices().end(); ++i ) { - if ( ( *i )->isPrimary() ) mcpvs.push_back( &( **i ) ); - } - - const LHCb::RecVertices* pvs = get( m_pvslocation ); - if ( !pvs ) { return StatusCode::FAILURE; } // RETURN - - const IPV2MC::PV2MC* pv2mctable = m_pv2mc->pv2MC(); - vector> mcpvindices; - vector> matchtracks; - vector nmatches; - vector nmatchtrackstot; - vector fracmatchtot; - vector> matchfracs; - vector> matchchi2s; - vector> matchdists; - - for ( auto& recpv : *pvs ) { - int pvntracks = recpv->tracks().size(); - auto pvrelations = pv2mctable->relations( recpv ); - // match by position in case match by pointer fails. - if ( pvrelations.empty() ) { - for ( auto& relation : pv2mctable->relations() ) { - if ( relation.from()->position() == recpv->position() ) { - pvrelations = pv2mctable->relations( relation.from() ); - break; - } - } - } - nmatches.push_back( pvrelations.size() ); - int trackstot = 0; - vector pv_mcpvindices; - vector pv_matchtracks; - vector pv_matchfracs; - vector pv_matchchi2s; - vector pv_matchdists; - for ( auto imatch = pvrelations.rbegin(); imatch != pvrelations.rend(); ++imatch ) { - auto& match = *imatch; - LHCb::MCVertex* mcpv = match.to(); - pv_mcpvindices.push_back( find( mcpvs.begin(), mcpvs.end(), mcpv ) - mcpvs.begin() ); - pv_matchtracks.push_back( match.weight().first ); - trackstot += match.weight().first; - pv_matchfracs.push_back( float( match.weight().first ) / pvntracks ); - pv_matchchi2s.push_back( -match.weight().second ); - pv_matchdists.push_back( sqrt( ( recpv->position() - match.to()->position() ).mag2() ) ); - } - mcpvindices.push_back( pv_mcpvindices ); - matchtracks.push_back( pv_matchtracks ); - matchfracs.push_back( pv_matchfracs ); - matchchi2s.push_back( pv_matchchi2s ); - matchdists.push_back( pv_matchdists ); - nmatchtrackstot.push_back( trackstot ); - fracmatchtot.push_back( float( trackstot ) / pvntracks ); - } - - unsigned int maxrelations = 10; - // make sure all the rows are the same length. - for ( unsigned int jpv = 0; jpv < nmatches.size(); ++jpv ) { - for ( unsigned int kpv = nmatches[jpv]; kpv < maxrelations; ++kpv ) { - mcpvindices[jpv].push_back( -1 ); - matchtracks[jpv].push_back( -1 ); - matchfracs[jpv].push_back( -1. ); - matchchi2s[jpv].push_back( -1. ); - matchdists[jpv].push_back( 0. ); - } - } - - unsigned int maxnpvs = 30; - tuple->farray( prefix + "RecPV_nMatches", nmatches, "nPVs", maxnpvs ) - .ignore( /* AUTOMATICALLY ADDED FOR gaudi/Gaudi!763 */ ); - tuple->fmatrix( prefix + "RecPV_matchMCPVIndices", mcpvindices, nmatches.size(), maxrelations, "nPVs", maxnpvs ) - .ignore( /* AUTOMATICALLY ADDED FOR gaudi/Gaudi!763 */ ); - tuple->fmatrix( prefix + "RecPV_matchNTracks", matchtracks, nmatches.size(), maxrelations, "nPVs", maxnpvs ) - .ignore( /* AUTOMATICALLY ADDED FOR gaudi/Gaudi!763 */ ); - tuple->fmatrix( prefix + "RecPV_matchFracs", matchfracs, nmatches.size(), maxrelations, "nPVs", maxnpvs ) - .ignore( /* AUTOMATICALLY ADDED FOR gaudi/Gaudi!763 */ ); - tuple->fmatrix( prefix + "RecPV_matchChi2s", matchchi2s, nmatches.size(), maxrelations, "nPVs", maxnpvs ) - .ignore( /* AUTOMATICALLY ADDED FOR gaudi/Gaudi!763 */ ); - tuple->fmatrix( prefix + "RecPV_matchDistances", matchdists, nmatches.size(), maxrelations, "nPVs", maxnpvs ) - .ignore( /* AUTOMATICALLY ADDED FOR gaudi/Gaudi!763 */ ); - tuple->farray( prefix + "RecPV_totMatchNTracks", nmatchtrackstot, "nPVs", maxnpvs ) - .ignore( /* AUTOMATICALLY ADDED FOR gaudi/Gaudi!763 */ ); - tuple->farray( prefix + "RecPV_totMatchFrac", fracmatchtot, "nPVs", maxnpvs ) - .ignore( /* AUTOMATICALLY ADDED FOR gaudi/Gaudi!763 */ ); - - return StatusCode::SUCCESS; -} diff --git a/Phys/DecayTreeTupleMC/src/TupleToolPV2MC.h b/Phys/DecayTreeTupleMC/src/TupleToolPV2MC.h deleted file mode 100644 index f42342c1c5fe6e17813f7c7f703a8aedc18fcb32..0000000000000000000000000000000000000000 --- a/Phys/DecayTreeTupleMC/src/TupleToolPV2MC.h +++ /dev/null @@ -1,72 +0,0 @@ -/*****************************************************************************\ -* (c) Copyright 2000-2018 CERN for the benefit of the LHCb Collaboration * -* * -* This software is distributed under the terms of the GNU General Public * -* Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". * -* * -* In applying this licence, CERN does not waive the privileges and immunities * -* granted to it by virtue of its status as an Intergovernmental Organization * -* or submit itself to any jurisdiction. * -\*****************************************************************************/ -#ifndef TUPLETOOLPV2MC_H -#define TUPLETOOLPV2MC_H 1 - -// Include files -// from Gaudi -#include -#include -#include -#include // Interface - -class IPV2MC; - -/** @class TupleToolPV2MC TupleToolPV2MC.h - * - * Write the relations table of PV -> MC PV. Should be used in conjunction with TupleToolPrimaries and - * MCTupleToolPrimaries. Fills: - * - * - nPVs : Number of reco'd PVs in the container. - * - RecPV_nMatches : Array, one entry per reco'd PV. The number of MC PVs the PV has been checked against (normally - * just the number of MC PVs in the event). - * - RecPV_totMatchNTracks : Array, as above. The total number of tracks in each PV that're matched to an MC particle. - * - RecPV_totMatchFrac : Array, as above. The total fraction of tracks in each PV that're matched to an MC particle. - * - RecPV_matchMCPVIndices : Matrix, one row per reco'd PV, each row i is of length RecPV_nMatches[i]. The sorted lists - * of the indices of the best matching MC PVs in the MC PVs container. The sorting is descending by the number of tracks - * matched to each PV. - * - RecPV_matchNTracks : Matrix as above. The number of tracks in the PV matched to each MC PV. - * - RecPV_matchFracs : Matrix as above. The fraction of the tracks matched to each MC PV. - * - RecPV_matchChi2s : Matrix as above. The chi2 of the PV wrt the position of each MC PV. - * - RecPV_matchDistances : Matrix as above. The distances between the PV and each MC PV. - * - * Example usage: - * - * - Select PVs with at least 50 % of tracks originating from the same MC PV with "RecPV_matchFracs[][0] >= 0.5". - * - Plot the chi2 of PVs wrt their best matching MC PV with "RecPV_matchChi2s[][0]" and selection as above. - * - Plot the PV x resolution with "PVX[] - MCPVX[RecPV_matchMCPVIndices[][0]]" and selection as above, assuming - * TupleToolPrimaries and MCTupleToolPrimaries have been used. - * - * Note that the PV2MC tool that's used to do the PV associations requires the Track -> MCParticle association - * table to be in the format produced by LoKi::Track2MC, so you'll need to run an instance of this in your - * sequence before the DecayTreeTuple. Also, for run 2, the tracks used to fit the PVs are contained in - * Rec/Track/FittedHLT1VeloTracks, so you'll need to add this to the Tracks attribute of LoKi::Track2MC. - * - * \sa TupleToolPrimaries, MCTupleToolPrimaries, TupleToolMCPVAssociation, PV2MC, Track2MC. - * @author Michael Alexander - * @date 2018-05-09 - */ -class TupleToolPV2MC : public TupleToolBase, virtual public IEventTupleTool { -public: - /// Standard constructor - TupleToolPV2MC( const std::string& type, const std::string& name, const IInterface* parent ); - - virtual StatusCode fill( Tuples::Tuple& ) override; - virtual StatusCode initialize() override; - -private: - IPV2MC* m_pv2mc = nullptr; - Gaudi::Property m_pv2mctooltype{this, "PV2MCToolType", "LoKi::PV2MC", - "Type of PV2MC tool to be used (must inherit from IPV2MC)"}; - Gaudi::Property m_pvslocation{this, "PVLocation", LHCb::RecVertexLocation::Primary, - "Location of PVs to associate."}; -}; -#endif // TUPLETOOLPV2MC_H diff --git a/Phys/DecayTreeTupleMuonCalib/CMakeLists.txt b/Phys/DecayTreeTupleMuonCalib/CMakeLists.txt deleted file mode 100644 index 7eb9917f5918ca8f703356c2a731485f70f2d553..0000000000000000000000000000000000000000 --- a/Phys/DecayTreeTupleMuonCalib/CMakeLists.txt +++ /dev/null @@ -1,40 +0,0 @@ -############################################################################### -# (c) Copyright 2000-2021 CERN for the benefit of the LHCb Collaboration # -# # -# This software is distributed under the terms of the GNU General Public # -# Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". # -# # -# In applying this licence, CERN does not waive the privileges and immunities # -# granted to it by virtue of its status as an Intergovernmental Organization # -# or submit itself to any jurisdiction. # -############################################################################### -#[=======================================================================[.rst: -Phys/DecayTreeTupleMuonCalib ----------------------------- -#]=======================================================================] - -gaudi_add_module(DecayTreeTupleMuonCalib - SOURCES - src/TupleToolMuonIDCalib.cpp - src/TupleToolMuonPid.cpp - LINK - Analysis::DecayTreeTupleBaseLib - Boost::headers - Gaudi::GaudiAlgLib - Gaudi::GaudiKernel - GSL::gsl - LHCb::DetDescLib - LHCb::DigiEvent - LHCb::EventBase - LHCb::GenEvent - LHCb::LHCbKernel - LHCb::MCAssociators - LHCb::MCEvent - LHCb::MuonDetLib - LHCb::PhysEvent - LHCb::RecEvent - LHCb::TrackEvent - Phys::DaVinciInterfacesLib - Phys::DaVinciMCKernelLib - Rec::TrackInterfacesLib -) diff --git a/Phys/DecayTreeTupleMuonCalib/doc/release.notes b/Phys/DecayTreeTupleMuonCalib/doc/release.notes deleted file mode 100644 index a6691179288f16e4b5fccf1a0878b53b40f80125..0000000000000000000000000000000000000000 --- a/Phys/DecayTreeTupleMuonCalib/doc/release.notes +++ /dev/null @@ -1,69 +0,0 @@ -!----------------------------------------------------------------------------- -! Package : Phys/DecayTreeTupleMuonCalib -! Responsible : Chris Jones -! Purpose : tuple tools for Muon PID calibration -!----------------------------------------------------------------------------- - -!================== DecayTreeTupleMuonCalib v1r6 2015-12-04 ================== - -! 2015-12-03 - Ricardo Vazquez Gomez - - Include extra options in TupleToolMuonVariables - - Add the TupleZVIso.cpp to the DecayTreeTupleMuonCalib package - -! 2015-11-01 - Gerhard Raven - - replace endreq with endmsg - -!================= DecayTreeTupleMuonCalib v1r5 2015-10-019 ================== - -! 2015-10-09 - Ricardo Vazquez Gomez - - Control the momentum estimate using muon chambers via a flag. - -! 2015-07-30 - Ricardo Vazquez Gomez - - Added momentum estimate with and without M1 to TupleToolMuonIDCalib.cpp - -!========================= DecayTreeTupleMuonCalib v1r4 2015-06-02 ========================= - -! 2015-05-26 - Ricardo Vazquez Gomez - - Quick fix in the MuonIDCalib tool - -! 2015-05-20 - Ricardo Vazquez Gomez - - Added the muon hit time and the momentum from the muonTrack - -!========================= DecayTreeTupleMuonCalib v1r3 2014-10-30 ========================= - -! 2014-08-28 - Ricardo Vazquez Gomez - - All hits stored only for particle lab2 in the lab frame. - -! 2014-08-27 - Ricardo Vazquez Gomez - - Add the possibility to store all the hits of the muon system. - -!========================= DecayTreeTupleMuonCalib v1r2p1 2013-06-13 ========================= - -! 2013-05-17 - Chris Jones - - Fix clang warning for variable self-assignment - -!========================= DecayTreeTupleMuonCalib v1r2 2013-05-07 ========================= - -! 2013-04-15 - Jose Helder Lopes - - Implemented code to extrapolate a track to the muon system and find the region - it crosses in each station. - - Added the region of the extrapolated track in M2 to the ntuple. - -!========================= DecayTreeTupleMuonCalib v1r1 2013-04-05 ========================= - -! 2013-03-05 - Kazu Akiba - - Adding muondet to TupleToolMuonPid. Had to change the requirements file too. - No variables were added using the muon det element yet. - -! 2013-02-26 - Chris Jones - - Fix -pedantic compilation warnings - -!========================= DecayTreeTupleMuonCalib v1r0 2012-11-30 ========================= - -! 2012-11-29 - Marco Clemencic - - Added CMake configuration file. - - Modified requirements to simplify auto conversion to CMake. - -! 2012-11-22 - Chris Jones - - First version. Split of from monolithic Phys/DecayTreeTuple package. - Contains the tools for Muon PID calibration. diff --git a/Phys/DecayTreeTupleMuonCalib/src/TupleToolMuonIDCalib.cpp b/Phys/DecayTreeTupleMuonCalib/src/TupleToolMuonIDCalib.cpp deleted file mode 100644 index d7d14728f4ee80ac9a44bbb8cc98df716f3dc6c0..0000000000000000000000000000000000000000 --- a/Phys/DecayTreeTupleMuonCalib/src/TupleToolMuonIDCalib.cpp +++ /dev/null @@ -1,1053 +0,0 @@ -/*****************************************************************************\ -* (c) Copyright 2000-2018 CERN for the benefit of the LHCb Collaboration * -* * -* This software is distributed under the terms of the GNU General Public * -* Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". * -* * -* In applying this licence, CERN does not waive the privileges and immunities * -* granted to it by virtue of its status as an Intergovernmental Organization * -* or submit itself to any jurisdiction. * -\*****************************************************************************/ - -#include "DecayTreeTupleBase/TupleToolBase.h" -#include "TrackInterfaces/ITrackExtrapolator.h" - -#include "MuonDet/DeMuonDetector.h" -#include "MuonDet/MuonBasicGeometry.h" - -#include "Kernel/IBIntegrator.h" -#include "Kernel/IDistanceCalculator.h" -#include "Kernel/IPVReFitter.h" -#include "Kernel/IParticle2MCAssociator.h" -#include "Kernel/IParticleTupleTool.h" -#include "Kernel/LHCbID.h" -#include "Kernel/MuonTileID.h" -#include "Kernel/Particle2MCLinker.h" - -#include "Event/GenHeader.h" -#include "Event/IntLink.h" -#include "Event/MCHeader.h" -#include "Event/MCMuonDigit.h" -#include "Event/MCMuonDigitInfo.h" -#include "Event/MuonCoord.h" -#include "Event/MuonDigit.h" -#include "Event/Particle.h" - -#include "GaudiAlg/Tuple.h" -#include "GaudiAlg/TupleObj.h" -#include "GaudiKernel/PhysicalConstants.h" - -#include "gsl/gsl_math.h" - -#include - -/** - * @author Fatima Soomro - * @date 2011-09-26 - */ -class TupleToolMuonIDCalib : public TupleToolBase, virtual public IParticleTupleTool { - -public: - TupleToolMuonIDCalib( const std::string& type, const std::string& name, const IInterface* parent ); - - /// Loop over differnt conesizes and fill the variables into the tuple - StatusCode fill( const LHCb::Particle*, const LHCb::Particle*, const std::string&, Tuples::Tuple&, - IGeometryInfo const& ) override; - -private: - StatusCode fillVars( const LHCb::Particle* part, std::string, Tuples::Tuple&, IGeometryInfo const& ); - void LoadMuonGeometry(); - StatusCode fillCoordVectors(); - double foiX( const int& station, const int& region, const double& p, const double& dx ); - double foiY( const int& station, const int& region, const double& p, const double& dy ); - StatusCode FindFieldPolarity(); - bool linFit( int& FromM1 ); - bool calculatePt( int& FromM1 ); - bool estrapola( IGeometryInfo const& geometry ); - - int m_NFoi; // look for hits winhin m_NFoi*Foi */ - std::string m_particlesPath; - - // FOIs parameters: - // function that defines the field of interest size - // formula is p(1) + p(2)*momentum+p(3)*exp(-p(4)*momentum) - std::vector m_xfoiParam1; - std::vector m_xfoiParam2; - std::vector m_xfoiParam3; - std::vector m_yfoiParam1; - std::vector m_yfoiParam2; - std::vector m_yfoiParam3; - - //-------------------------- - // Muon Detector variables: - //-------------------------- - - int m_NStation; /// Number of stations - int m_NRegion; /// Number of regions - // Names of the station - std::vector m_stationNames; - // fill local arrays of pad sizes and region sizes - DeMuonDetector* m_mudet; - - // track state @ M1 - const LHCb::State* m_stateP; - - // These are indexed [station] - std::vector m_stationZ; // station position - double m_trackX[5]; // position of track in x(mm) in each station - double m_trackY[5]; // position of track in y(mm) in each station - - std::string m_extrapolatorName; - ITrackExtrapolator* m_extrapolator; ///< extrapolator - double m_TextraX[5]; // x(mm) position of extrapolated track in each station - double m_TextraY[5]; // y(mm) position of extrapolated track in each station - double m_ms2X[5]; // ms error on x(mm) position in each station - double m_ms2Y[5]; // ms error on y(mm) position in each station - double m_TextraReg[5]; // region crossed by the extrapolated track - - // closest hit in FOI[station] ==> input for linFit, the linear fit - double m_smalldist_X[5]; - double m_smalldist_Y[5]; - double m_smalldist_Z[5]; - double m_smalldist_dX[5]; - double m_smalldist_dY[5]; - double m_smalldist_dZ[5]; - - // linear fit results - double m_sx, m_sy; - double m_bx, m_by; - double m_errbx, m_errsx, m_covbsx; - double m_errby, m_errsy, m_covbsy; - double m_chi2x, m_chi2y; - - // pt calculation - std::vector m_ParabolicCorrection; - std::vector m_resParams; - double m_Constant; - IBIntegrator* m_bIntegrator; // magnetic field tool - double m_FieldPolarity; - - double m_4qOverP; - double m_4sigmaQOverP2; - double m_4pZM1; - double m_4pXPvtx; - double m_4pYPvtx; - double m_4pZPvtx; - - double m_5qOverP; - double m_5sigmaQOverP2; - double m_5pZM1; - double m_5pXPvtx; - double m_5pYPvtx; - double m_5pZPvtx; - - std::vector m_hitInFOIx; - std::vector m_hitInFOIdx; - std::vector m_hitInFOIy; - std::vector m_hitInFOIdy; - std::vector m_hitInFOIz; - std::vector m_hitInFOIdz; - std::vector m_hitInFOIuncrossed; - std::vector m_hitInFOIID; - std::vector m_hitInFOITDC1; - std::vector m_hitInFOITDC2; - std::vector m_allMuonHitsX; - std::vector m_allMuonHitsDX; - std::vector m_allMuonHitsY; - std::vector m_allMuonHitsDY; - std::vector m_allMuonHitsZ; - std::vector m_allMuonHitsDZ; - std::vector m_allMuonHitsUncrossed; - std::vector m_allMuonHitsTDC1; - std::vector m_allMuonHitsTDC2; - std::vector m_allMuonHitsID; - bool m_doVerbose; - bool m_estimate; - - // local array of region sizes - std::vector m_regionInnerX; // inner edge in abs(x) - std::vector m_regionOuterX; // outer edge in abs(x) - std::vector m_regionInnerY; // inner edge in abs(y) - std::vector m_regionOuterY; // outer edge in abs(y) - - // Store x,dx,y,dy of each coord - class coordExtent_ { - public: - coordExtent_( double x, double dx, double y, double dy, double z, double dz, bool uncrossed, int digitTDC1, - int digitTDC2, LHCb::MuonCoord* pCoord ) - : m_x( x ) - , m_dx( dx ) - , m_y( y ) - , m_dy( dy ) - , m_z( z ) - , m_dz( dz ) - , m_uncrossed( uncrossed ) - , m_digitTDC1( digitTDC1 ) - , m_digitTDC2( digitTDC2 ) - , m_pCoord( pCoord ){}; - double m_x; - double m_dx; - double m_y; - double m_dy; - double m_z; - double m_dz; - bool m_uncrossed; - int m_digitTDC1; - int m_digitTDC2; - LHCb::MuonCoord* m_pCoord; - }; - // vector of positions of coords (innner vector coords, - // outer is [station* m_NRegion + region ] - std::vector> m_coordPos; -}; - -using namespace LHCb; -using namespace Gaudi::Units; -using namespace Gaudi; - -// Declaration of the Algorithm Factory -DECLARE_COMPONENT( TupleToolMuonIDCalib ) - -//============================================================================= -// Standard constructor, initializes variables -//============================================================================= -TupleToolMuonIDCalib::TupleToolMuonIDCalib( const std::string& type, const std::string& name, const IInterface* parent ) - : TupleToolBase( type, name, parent ) { - declareInterface( this ); - declareProperty( "NFoi", m_NFoi = 2 ); - declareProperty( "XFOIParameter1", m_xfoiParam1 ); - declareProperty( "XFOIParameter2", m_xfoiParam2 ); - declareProperty( "XFOIParameter3", m_xfoiParam3 ); - declareProperty( "YFOIParameter1", m_yfoiParam1 ); - declareProperty( "YFOIParameter2", m_yfoiParam2 ); - declareProperty( "YFOIParameter3", m_yfoiParam3 ); - declareProperty( "isVerbose", m_doVerbose = false ); - declareProperty( "MomentumEstimate", m_estimate = true ); - - std::vector tmp1 = boost::assign::list_of( 0.015 )( 0.29 ); - declareProperty( "resParams", m_resParams = tmp1 ); - - std::vector tmp2 = boost::assign::list_of( 1.04 )( 0.14 ); - declareProperty( "ParabolicCorrection", m_ParabolicCorrection = tmp2 ); - - declareProperty( "ConstantCorrection", m_Constant = 0. * Gaudi::Units::MeV ); - declareProperty( "Extrapolator", m_extrapolatorName = "TrackMasterExtrapolator" ); -} - -//============================================================================= -// Fill the tuple -//============================================================================= -StatusCode TupleToolMuonIDCalib::fill( const LHCb::Particle* /* top */, const LHCb::Particle* part, - const std::string& head, Tuples::Tuple& tuple, IGeometryInfo const& geometry ) { - // nothing for particles that are not Bs - if ( !part->isBasicParticle() || NULL == part->proto() ) return StatusCode::SUCCESS; - - LoadMuonGeometry(); - if ( msgLevel( MSG::DEBUG ) ) debug() << "Fatima: Loaded Geometry in TupleToolMuIDCalib" << endmsg; - - m_bIntegrator = tool( "BIntegrator" ); - if ( !m_bIntegrator ) return StatusCode::FAILURE; - - m_extrapolator = tool( m_extrapolatorName, "MuEffExtrap", this ); - if ( !m_extrapolator ) return StatusCode::FAILURE; - - StatusCode sc = fillCoordVectors(); - if ( !sc ) error() << "couldnt fillCoorVectors!!!" << endmsg; - debug() << "Fatima: fillCoordVectors in TupleToolMuIDCalib" << endmsg; - - m_FieldPolarity = 1; - StatusCode sc2 = FindFieldPolarity(); - if ( !sc2 ) error() << "couldnt determine field polarity !!" << endmsg; - - const std::string prefix = fullName( head ); - StatusCode sc3 = fillVars( part, prefix, tuple, geometry ); - return sc3; -} - -//========================================================================== -// Load the geometry -//========================================================================== - -void TupleToolMuonIDCalib::LoadMuonGeometry() { - m_NStation = 0; - m_NRegion = 0; - MuonBasicGeometry basegeometry( detSvc(), msgSvc() ); - m_NStation = basegeometry.getStations(); - m_NRegion = basegeometry.getRegions(); - debug() << "stations and regions from MuonGeometry are " << m_NStation << " " << m_NRegion << endmsg; - - int i = 0; - while ( i < m_NStation ) { - m_stationNames.push_back( basegeometry.getStationName( i ) ); - debug() << " station " << i << " " << m_stationNames[i] << endmsg; - i++; - } - m_mudet = getDet( "/dd/Structure/LHCb/DownstreamRegion/Muon" ); - // set the size of the local vectors - m_regionInnerX.resize( m_NStation ); - m_regionOuterX.resize( m_NStation ); - m_regionInnerY.resize( m_NStation ); - m_regionOuterY.resize( m_NStation ); - for ( int station = 0; station < m_NStation; station++ ) { - m_stationZ.push_back( m_mudet->getStationZ( station ) ); - m_regionInnerX[station] = m_mudet->getInnerX( station ); - m_regionOuterX[station] = m_mudet->getOuterX( station ); - m_regionInnerY[station] = m_mudet->getInnerY( station ); - m_regionOuterY[station] = m_mudet->getOuterY( station ); - } -} - -//========================================================================== -// fill vectors of x,y,z positions for the MuonCoords -//========================================================================== - -StatusCode TupleToolMuonIDCalib::fillCoordVectors() { - - // m_HitInTrk.clear(); - m_coordPos.clear(); - m_coordPos.resize( m_NStation * m_NRegion ); - m_hitInFOIx.clear(); - m_hitInFOIdx.clear(); - m_hitInFOIy.clear(); - m_hitInFOIdy.clear(); - m_hitInFOIz.clear(); - m_hitInFOIdz.clear(); - m_hitInFOIuncrossed.clear(); - m_hitInFOIID.clear(); - m_hitInFOITDC1.clear(); - m_hitInFOITDC2.clear(); - m_allMuonHitsX.clear(); - m_allMuonHitsDX.clear(); - m_allMuonHitsY.clear(); - m_allMuonHitsDY.clear(); - m_allMuonHitsZ.clear(); - m_allMuonHitsDZ.clear(); - m_allMuonHitsUncrossed.clear(); - m_allMuonHitsID.clear(); - m_allMuonHitsTDC1.clear(); - m_allMuonHitsTDC2.clear(); - - // get the MuonCoords for each station in turn - LHCb::MuonCoords* coords = NULL; - if ( exist( LHCb::MuonCoordLocation::MuonCoords ) ) - coords = get( LHCb::MuonCoordLocation::MuonCoords ); - if ( !coords ) { - err() << "Cannot retrieve MuonCoords " << endmsg; - return StatusCode::FAILURE; - } - - // loop over the coords - LHCb::MuonCoords::const_iterator iCoord; - for ( iCoord = coords->begin(); iCoord != coords->end(); iCoord++ ) { - int region = ( *iCoord )->key().region(); - int station = ( *iCoord )->key().station(); - bool uncrossed = ( *iCoord )->uncrossed(); - int digitTDC1 = ( *iCoord )->digitTDC1(); - int digitTDC2 = ( *iCoord )->digitTDC2(); - LHCb::MuonTileID tile = ( *iCoord )->key(); - auto tilePosition = m_mudet->position( tile ); - if ( !tilePosition ) { - warning() << "Failed to get x,y,z of tile " << tile << endmsg; - continue; - } - auto x = tilePosition->position.x(); - auto y = tilePosition->position.y(); - auto z = tilePosition->position.z(); - auto dx = tilePosition->dX; - auto dy = tilePosition->dY; - auto dz = tilePosition->dZ; - m_coordPos[station * m_NRegion + region].push_back( - coordExtent_( x, dx, y, dy, z, dz, uncrossed, digitTDC1, digitTDC2, *iCoord ) ); - // m_HitInTrk.push_back(false); - } - - return StatusCode::SUCCESS; -} - -// return the FOI in x in a station and region for momentum (in MeV/c) -// this is a simpler version of the parameterization: -// foi = par0 + par2*exp(-par3*p) -//============================================================================= -double TupleToolMuonIDCalib::foiX( const int& station, const int& region, const double& p, const double& dx ) { - //============================================================================= - const double temp_x = ( m_xfoiParam1[station * m_NRegion + region] + - m_xfoiParam2[station * m_NRegion + region] * - std::exp( -m_xfoiParam3[station * m_NRegion + region] * p / Gaudi::Units::GeV ) ) * - dx; - // in the future optimize this checking that 2*dx =m_padSizeX[station * m_NRegion + region] - // then eliminates dx from function - - if ( msgLevel( MSG::VERBOSE ) ) verbose() << "from FOIX " << temp_x << endmsg; - - return temp_x; -} - -// return the FOI in y in a station and region for momentum (in MeV/c) -//============================================================================= -double TupleToolMuonIDCalib::foiY( const int& station, const int& region, const double& p, const double& dy ) { - //============================================================================= - const double temp_y = ( m_yfoiParam1[station * m_NRegion + region] + - m_yfoiParam2[station * m_NRegion + region] * - std::exp( -m_yfoiParam3[station * m_NRegion + region] * p / Gaudi::Units::GeV ) ) * - dy; - - if ( msgLevel( MSG::VERBOSE ) ) verbose() << "from FOIY " << temp_y << endmsg; - - return temp_y; -} - -//============================================================================= -// fill Xs, Ys and DistAve -//============================================================================= -StatusCode TupleToolMuonIDCalib::fillVars( const LHCb::Particle* part, const std::string prefix, Tuples::Tuple& tuple, - IGeometryInfo const& geometry ) { - - if ( ( !part->isBasicParticle() ) || NULL == part->proto() ) { - error() << "!! Tried to fill MuonIDCalib quantities for particle " << part->particleID().pid() - << "!!! This should not happen" << endmsg; - return StatusCode::SUCCESS; - } - - const LHCb::Track* track = part->proto()->track(); - if ( ( track->checkFlag( LHCb::Track::Flags::Clone ) ) || - !( track->checkType( LHCb::Track::Types::Long ) || track->checkType( LHCb::Track::Types::Downstream ) || - track->checkType( LHCb::Track::Types::Ttrack ) ) ) { - return StatusCode::SUCCESS; - } - - ///------------------------------------------------------------------------------------- - // 6 March 2012, Add the muon detector hit positions related to the track, to the ntuple - // one has to get the muon part of the track (from muonPIDs)and then get the lhcbIDs related to it - ///------------------------------------------------------------------------------------- - - if ( m_doVerbose ) { - - std::vector m_x; - std::vector m_y; - std::vector m_z; - - LHCb::MuonPIDs* pMuids = NULL; - if ( exist( LHCb::MuonPIDLocation::Default ) ) - pMuids = get( LHCb::MuonPIDLocation::Default ); - - if ( !pMuids ) { - error() << " Failed to get pMuids" << LHCb::MuonPIDLocation::Default << endmsg; - return StatusCode::FAILURE; - } - if ( msgLevel( MSG::DEBUG ) ) debug() << " >> number of Mu tracks in the event " << pMuids->size() << endmsg; - const LHCb::Track* mutrack = NULL; - LHCb::MuonPIDs::const_iterator ip; - for ( ip = pMuids->begin(); ip != pMuids->end(); ip++ ) { - if ( ( *ip )->idTrack() == track ) { - mutrack = ( *ip )->muonTrack(); - if ( !mutrack ) continue; - debug() << "found a mutrack " << endmsg; - } - } // end of muonIDs loop - if ( msgLevel( MSG::DEBUG ) ) debug() << "Fatima, I out of mutrack loop" << endmsg; - - if ( mutrack ) { - const std::vector lhcbIDs = mutrack->lhcbIDs(); - if ( msgLevel( MSG::DEBUG ) ) - debug() << " Starting to find the muon hit info, have " << lhcbIDs.size() << " to loop over " << endmsg; - - int countVelo( 0 ), countIT( 0 ), countOT( 0 ), countTT( 0 ), countMuon( 0 ), countCALO( 0 ), countRICH( 0 ); - std::vector::const_iterator myID = lhcbIDs.begin(); - for ( ; myID != lhcbIDs.end(); myID++ ) { - if ( ( ( *myID ).isVelo() ) ) countVelo++; - if ( ( ( *myID ).isIT() ) ) countIT++; - if ( ( ( *myID ).isOT() ) ) countOT++; - if ( ( ( *myID ).isTT() ) ) countTT++; - if ( ( ( *myID ).isCalo() ) ) countCALO++; - if ( ( ( *myID ).isRich() ) ) countRICH++; - - if ( ( ( *myID ).isMuon() ) ) { - countMuon++; - const LHCb::MuonTileID mutile = ( *myID ).muonID(); - double x, dx, y, dy, z, dz; - StatusCode sc = m_mudet->Tile2XYZ( mutile, x, dx, y, dy, z, dz ); - if ( msgLevel( MSG::DEBUG ) ) - debug() << "Muon pad hit: " << x << " " << dx << " " << y << " " << dy << " " << z << " " << dz - << ". Stn: " << mutile.station() << " regn: " << mutile.region() << " qrtr: " << mutile.quarter() - << " nX and nY " << mutile.nX() << " " << mutile.nY() << endmsg; - if ( sc.isSuccess() ) { - m_x.push_back( x ); - m_y.push_back( y ); - m_z.push_back( z ); - } else { - warning() << "m_mudet->Tile2XYZ() failed for mutile = " << mutile << endmsg; - } - } - } - if ( msgLevel( MSG::DEBUG ) ) { - debug() << "track history is " << track->checkHistory( LHCb::Track::History::MuonID ) << endmsg; - debug() << "=============== velo " << countVelo << " IT " << countIT << " OT " << countOT << " TT " << countTT - << " calo " << countCALO << " rich " << countRICH << " muon " << countMuon << endmsg; - } - } - - else { - if ( msgLevel( MSG::DEBUG ) ) debug() << "While trying to get lhcbIDs, I didn't find a mutrack! " << endmsg; - } - - tuple->farray( prefix + "_LHCbID_X", m_x.begin(), m_x.end(), prefix + "_n", 100 ) - .ignore( /* AUTOMATICALLY ADDED FOR gaudi/Gaudi!763 */ ); - tuple->farray( prefix + "_LHCbID_Y", m_y.begin(), m_y.end(), prefix + "_n", 100 ) - .ignore( /* AUTOMATICALLY ADDED FOR gaudi/Gaudi!763 */ ); - tuple->farray( prefix + "_LHCbID_Z", m_z.begin(), m_z.end(), prefix + "_n", 100 ) - .ignore( /* AUTOMATICALLY ADDED FOR gaudi/Gaudi!763 */ ); - - } // m_doVerbose - - ///------------------------------------------------------------------------------- - /// Project the state at M1 into the rest of the muon stations and store the x, y - ///------------------------------------------------------------------------------- - - m_stateP = &( track->closestState( m_stationZ[0] ) ); - - for ( int station = 0; station < m_NStation; station++ ) { - - m_trackX[station] = m_stateP->x() + ( m_stateP->tx() * ( m_stationZ[station] - m_stateP->z() ) ); - m_trackY[station] = m_stateP->y() + ( m_stateP->ty() * ( m_stationZ[station] - m_stateP->z() ) ); - if ( msgLevel( MSG::DEBUG ) ) - debug() << "Station: " << station << ". " - << "m_trackX[station] " << m_trackX[station] << " = " << m_stateP->x() << " + " - << " (" << m_stateP->tx() << " * (" << m_stationZ[station] << " - " << m_stateP->z() << " ) )" << endmsg; - } // station - - // extrapolation through the stations to get expected positions with - // errors due to multiple scattering - - bool ecode = estrapola( geometry ); - if ( !ecode ) debug() << "estrapola: track extrapolation failed " << endmsg; - - bool test = true; - for ( int station = 0; station < m_NStation; station++ ) { - std::stringstream ss; - ss << station + 1; - test &= tuple->column( prefix + "_Xs" + ss.str(), m_trackX[station] ); - test &= tuple->column( prefix + "_Ys" + ss.str(), m_trackY[station] ); - - test &= tuple->column( prefix + "_extraXs" + ss.str(), m_TextraX[station] ); - test &= tuple->column( prefix + "_extraYs" + ss.str(), m_TextraY[station] ); - test &= tuple->column( prefix + "_ms2Xs" + ss.str(), m_ms2X[station] ); - test &= tuple->column( prefix + "_ms2Ys" + ss.str(), m_ms2Y[station] ); - test &= tuple->column( prefix + "_TRegs" + ss.str(), m_TextraReg[station] ); - } - - // ====================================== - // Calculate and fill DistAve and Xs, Ys - // ====================================== - - double m_momentum = m_stateP->p(); - int nHits = 0; - int ic_hit = 0; - // int ic_closesthit = 0; - float dist_ave = 0; - std::vector small_dist( m_NStation ); - - for ( int i = 0; i < m_NStation; ++i ) { - small_dist[i] = 100000000.; - m_smalldist_X[i] = 100000000.; - m_smalldist_Y[i] = 100000000.; - m_smalldist_Z[i] = 100000000.; - m_smalldist_dX[i] = 0.; - m_smalldist_dY[i] = 0.; - m_smalldist_dZ[i] = 0.; - } - - // store hit info if its in the FOI of the track - - for ( int station = 0; station < m_NStation; station++ ) { - - for ( int region = 0; region < m_NRegion; region++ ) { - - if ( !m_coordPos[station * m_NRegion + region].empty() ) { - - std::vector::const_iterator itPos; - - for ( itPos = m_coordPos[station * m_NRegion + region].begin(); - itPos != m_coordPos[station * m_NRegion + region].end(); itPos++ ) { - - // all muon hits - if ( m_doVerbose ) { - m_allMuonHitsX.push_back( itPos->m_x ); - m_allMuonHitsDX.push_back( itPos->m_dx ); - m_allMuonHitsY.push_back( itPos->m_y ); - m_allMuonHitsDY.push_back( itPos->m_dy ); - m_allMuonHitsZ.push_back( itPos->m_z ); - m_allMuonHitsDZ.push_back( itPos->m_dz ); - m_allMuonHitsUncrossed.push_back( itPos->m_uncrossed ); - m_allMuonHitsID.push_back( station * m_NRegion + region ); - m_allMuonHitsTDC1.push_back( itPos->m_digitTDC1 ); - m_allMuonHitsTDC2.push_back( itPos->m_digitTDC2 ); - } - - // hits in foi - double x = itPos->m_x; - double dx = itPos->m_dx; - double y = itPos->m_y; - double dy = itPos->m_dy; - - if ( msgLevel( MSG::VERBOSE ) ) - verbose() << "Computing DistAve: x, dx, y, dy are " << x << " " << dx << " " << y << " " << dy - << endmsg; - - double xdist = fabs( x - m_trackX[station] ) / dx; - double ydist = fabs( y - m_trackY[station] ) / dy; - double dist = std::sqrt( xdist * xdist + ydist * ydist ); - - if ( msgLevel( MSG::VERBOSE ) ) - verbose() << "xdist, ydist and dist are " << xdist << " " << ydist << " " << dist << endmsg; - - // Look for the Closest hit to the track in any station: - if ( dist < small_dist[station] ) { - small_dist[station] = dist; - m_smalldist_X[station] = itPos->m_x; - m_smalldist_Y[station] = itPos->m_y; - m_smalldist_Z[station] = itPos->m_z; - m_smalldist_dX[station] = itPos->m_dx; - m_smalldist_dY[station] = itPos->m_dy; - m_smalldist_dZ[station] = itPos->m_dz; - // ic_closesthit = ic_hit; - } - - // define the FOI in which we have to evaluate the average - double foiXDim = m_NFoi * foiX( station, region, m_momentum, dx ); - double foiYDim = m_NFoi * foiY( station, region, m_momentum, dy ); - - if ( msgLevel( MSG::VERBOSE ) ) - verbose() << "Checking for FOI: " << m_NFoi << " " << station << " " << region << " " << m_momentum << " " - << dx << endmsg; - - // check if the hit is in the window - if ( ( fabs( x - m_trackX[station] ) < foiXDim ) && ( fabs( y - m_trackY[station] ) < foiYDim ) ) { - ++nHits; - dist_ave = dist_ave + ( xdist * xdist + ydist * ydist ); - - if ( m_doVerbose ) { - m_hitInFOIx.push_back( x ); - m_hitInFOIdx.push_back( dx ); - m_hitInFOIy.push_back( y ); - m_hitInFOIdy.push_back( dy ); - m_hitInFOIz.push_back( itPos->m_z ); - m_hitInFOIdz.push_back( itPos->m_dz ); - m_hitInFOIuncrossed.push_back( itPos->m_uncrossed ); - m_hitInFOIID.push_back( station * m_NRegion + region ); - m_hitInFOITDC1.push_back( itPos->m_digitTDC1 ); - m_hitInFOITDC2.push_back( itPos->m_digitTDC2 ); - m_hitInFOIID.push_back( station * m_NRegion + region ); - } - } - - ++ic_hit; - } // for itPos - - } // region not empty - - } // region - - } // station - - if ( m_doVerbose ) { - tuple->farray( prefix + "_hitInFOI_X", m_hitInFOIx.begin(), m_hitInFOIx.end(), prefix + "_n_InFOI", 500 ) - .ignore( /* AUTOMATICALLY ADDED FOR gaudi/Gaudi!763 */ ); - tuple->farray( prefix + "_hitInFOI_dX", m_hitInFOIdx.begin(), m_hitInFOIdx.end(), prefix + "_n_InFOI", 500 ) - .ignore( /* AUTOMATICALLY ADDED FOR gaudi/Gaudi!763 */ ); - tuple->farray( prefix + "_hitInFOI_Y", m_hitInFOIy.begin(), m_hitInFOIy.end(), prefix + "_n_InFOI", 500 ) - .ignore( /* AUTOMATICALLY ADDED FOR gaudi/Gaudi!763 */ ); - tuple->farray( prefix + "_hitInFOI_dY", m_hitInFOIdy.begin(), m_hitInFOIdy.end(), prefix + "_n_InFOI", 500 ) - .ignore( /* AUTOMATICALLY ADDED FOR gaudi/Gaudi!763 */ ); - tuple->farray( prefix + "_hitInFOI_Z", m_hitInFOIz.begin(), m_hitInFOIz.end(), prefix + "_n_InFOI", 500 ) - .ignore( /* AUTOMATICALLY ADDED FOR gaudi/Gaudi!763 */ ); - tuple->farray( prefix + "_hitInFOI_dZ", m_hitInFOIdz.begin(), m_hitInFOIdz.end(), prefix + "_n_InFOI", 500 ) - .ignore( /* AUTOMATICALLY ADDED FOR gaudi/Gaudi!763 */ ); - tuple->farray( prefix + "_hitInFOI_ID", m_hitInFOIID.begin(), m_hitInFOIID.end(), prefix + "_n_InFOI", 500 ) - .ignore( /* AUTOMATICALLY ADDED FOR gaudi/Gaudi!763 */ ); - tuple - ->farray( prefix + "_hitInFOI_uncrossed", m_hitInFOIuncrossed.begin(), m_hitInFOIuncrossed.end(), - prefix + "_n_InFOI", 500 ) - .ignore( /* AUTOMATICALLY ADDED FOR gaudi/Gaudi!763 */ ); - tuple->farray( prefix + "_hitInFOI_TDC1", m_hitInFOITDC1.begin(), m_hitInFOITDC1.end(), prefix + "_n_InFOI", 500 ) - .ignore( /* AUTOMATICALLY ADDED FOR gaudi/Gaudi!763 */ ); - tuple->farray( prefix + "_hitInFOI_TDC2", m_hitInFOITDC2.begin(), m_hitInFOITDC2.end(), prefix + "_n_InFOI", 500 ) - .ignore( /* AUTOMATICALLY ADDED FOR gaudi/Gaudi!763 */ ); - if ( prefix == "lab2" ) { - tuple - ->farray( prefix + "_allMuonHits_X", m_allMuonHitsX.begin(), m_allMuonHitsX.end(), prefix + "_n_AllHits", - 10000 ) - .ignore( /* AUTOMATICALLY ADDED FOR gaudi/Gaudi!763 */ ); - tuple - ->farray( prefix + "_allMuonHits_dX", m_allMuonHitsDX.begin(), m_allMuonHitsDX.end(), prefix + "_n_AllHits", - 10000 ) - .ignore( /* AUTOMATICALLY ADDED FOR gaudi/Gaudi!763 */ ); - tuple - ->farray( prefix + "_allMuonHits_Y", m_allMuonHitsY.begin(), m_allMuonHitsY.end(), prefix + "_n_AllHits", - 10000 ) - .ignore( /* AUTOMATICALLY ADDED FOR gaudi/Gaudi!763 */ ); - tuple - ->farray( prefix + "_allMuonHits_dY", m_allMuonHitsDY.begin(), m_allMuonHitsDY.end(), prefix + "_n_AllHits", - 10000 ) - .ignore( /* AUTOMATICALLY ADDED FOR gaudi/Gaudi!763 */ ); - tuple - ->farray( prefix + "_allMuonHits_Z", m_allMuonHitsZ.begin(), m_allMuonHitsZ.end(), prefix + "_n_AllHits", - 10000 ) - .ignore( /* AUTOMATICALLY ADDED FOR gaudi/Gaudi!763 */ ); - tuple - ->farray( prefix + "_allMuonHits_dZ", m_allMuonHitsDZ.begin(), m_allMuonHitsDZ.end(), prefix + "_n_AllHits", - 10000 ) - .ignore( /* AUTOMATICALLY ADDED FOR gaudi/Gaudi!763 */ ); - tuple - ->farray( prefix + "_allMuonHits_ID", m_allMuonHitsID.begin(), m_allMuonHitsID.end(), prefix + "_n_AllHits", - 10000 ) - .ignore( /* AUTOMATICALLY ADDED FOR gaudi/Gaudi!763 */ ); - tuple - ->farray( prefix + "_allMuonHits_uncrossed", m_allMuonHitsUncrossed.begin(), m_allMuonHitsUncrossed.end(), - prefix + "_n_AllHits", 10000 ) - .ignore( /* AUTOMATICALLY ADDED FOR gaudi/Gaudi!763 */ ); - tuple - ->farray( prefix + "_allMuonHits_TDC1", m_allMuonHitsTDC1.begin(), m_allMuonHitsTDC1.end(), - prefix + "_n_AllHits", 10000 ) - .ignore( /* AUTOMATICALLY ADDED FOR gaudi/Gaudi!763 */ ); - tuple - ->farray( prefix + "_allMuonHits_TDC2", m_allMuonHitsTDC2.begin(), m_allMuonHitsTDC2.end(), - prefix + "_n_AllHits", 10000 ) - .ignore( /* AUTOMATICALLY ADDED FOR gaudi/Gaudi!763 */ ); - } - - for ( int station = 0; station < m_NStation; ++station ) { - std::stringstream ss; - ss << station + 1; - const std::string& mychar2 = ss.str(); - test &= tuple->column( prefix + "Stn" + mychar2 + "X", m_smalldist_X[station] ); - test &= tuple->column( prefix + "Stn" + mychar2 + "Y", m_smalldist_Y[station] ); - test &= tuple->column( prefix + "Stn" + mychar2 + "Z", m_smalldist_Z[station] ); - } - } - - if ( m_estimate ) { - // estimate the momentum of the muon-track assuming it cames from the primary vertex - // first --> do a linear fit with the closest hits in FOI, starting from M1 to M5, - // if successful call the tool to estimate the momentum - // - m_5pZM1 = 0.; - m_5qOverP = 0.; - m_5sigmaQOverP2 = 0.; - m_5pXPvtx = 0.; - m_5pYPvtx = 0.; - m_5pZPvtx = 0.; - - int FromM1 = 1; - bool fcode = linFit( FromM1 ); - if ( !fcode ) { - debug() << "linFit: linear fit closest hits in FOI failed " << endmsg; - } else { - bool pcode = calculatePt( FromM1 ); - if ( !pcode ) debug() << "calculatePt: calculation momentum of muon track failed From M1" << endmsg; - } - test &= tuple->column( prefix + "_5pZM1", m_5pZM1 ); - test &= tuple->column( prefix + "_5qOverP", m_5qOverP ); - test &= tuple->column( prefix + "_5sigmaQOverP2", m_5sigmaQOverP2 ); - test &= tuple->column( prefix + "_5pXvtx", m_5pXPvtx ); - test &= tuple->column( prefix + "_5pYvtx", m_5pYPvtx ); - test &= tuple->column( prefix + "_5pZvtx", m_5pZPvtx ); - - // estimate the momentum of the muon-track assuming it cames from the primary vertex - // first --> do a linear fit with the closest hits in FOI, starting from M2 to M5, - // if successful call the tool to estimate the momentum - // - m_4pZM1 = 0.; - m_4qOverP = 0.; - m_4sigmaQOverP2 = 0.; - m_4pXPvtx = 0.; - m_4pYPvtx = 0.; - m_4pZPvtx = 0.; - - int FromM1_2 = 0; - bool fcode_2 = linFit( FromM1_2 ); - if ( !fcode_2 ) { - debug() << "linFit: linear fit closest hits in FOI failed " << endmsg; - } else { - bool pcode_2 = calculatePt( FromM1_2 ); - if ( !pcode_2 ) debug() << "calculatePt: calculation momentum of muon track failed From M2" << endmsg; - } - test &= tuple->column( prefix + "_4pZM1", m_4pZM1 ); - test &= tuple->column( prefix + "_4qOverP", m_4qOverP ); - test &= tuple->column( prefix + "_4sigmaQOverP2", m_4sigmaQOverP2 ); - test &= tuple->column( prefix + "_4pXvtx", m_4pXPvtx ); - test &= tuple->column( prefix + "_4pYvtx", m_4pYPvtx ); - test &= tuple->column( prefix + "_4pZvtx", m_4pZPvtx ); - } - - if ( nHits > 0 ) { dist_ave = dist_ave / nHits; } - - if ( msgLevel( MSG::VERBOSE ) ) - verbose() << " So the dist_ave for track " << track->key() << " (" << track->charge() - << ") will be: " << dist_ave << endmsg; - - test &= tuple->column( prefix + "_DistAve", dist_ave ); - return test ? StatusCode::SUCCESS : StatusCode::FAILURE; - -} // fillVars - -/// track fitting with linear Chi^2 from M1/M2 to M5 -bool TupleToolMuonIDCalib::linFit( int& FromM1 ) { - - m_sx = m_sy = 0.; - m_bx = m_by = 0.; - m_errbx = m_errsx = m_covbsx = 0.; - m_errby = m_errsy = m_covbsy = 0.; - m_chi2x = m_chi2y = 0.; - - int StartI = 0; // fit from M1 to M5 - if ( FromM1 == 0 ) StartI = 1; // fit from M2 to M5 - - int nPunti = 0; - for ( int i = StartI; i < m_NStation; ++i ) { - if ( m_smalldist_X[i] == 0.0 ) continue; - nPunti++; - } - - double dof = nPunti - 2.; - if ( dof == 0. ) return false; - - double xc11, xc12, xc22, xv1, xv2, xxx; - xc11 = xc12 = xc22 = xv1 = xv2 = xxx = 0.; - double yc11, yc12, yc22, yv1, yv2, yyy; - yc11 = yc12 = yc22 = yv1 = yv2 = yyy = 0.; - double xdet, ydet; - xdet = ydet = 0.; - double xerr, yerr; - xerr = yerr = 0.; - - for ( int i = StartI; i < m_NStation; ++i ) { - - if ( m_smalldist_dX[i] == 0.0 ) continue; - double x, dx, y, dy, z; // dz; - - x = m_smalldist_X[i]; - y = m_smalldist_Y[i]; - z = m_smalldist_Z[i]; - dx = m_smalldist_dX[i]; - dy = m_smalldist_dY[i]; - // dz = m_smalldist_dZ[i]; - - xerr = 2. * dx; - yerr = 2. * dy; - - // then fit them with a min chi^2 in the 2 projections xz and yz - // 1) XZ projection: - xc11 += z * z / xerr / xerr; - xc12 += z / xerr / xerr; - xc22 += 1.0 / xerr / xerr; - xv1 += z * x / xerr / xerr; - xv2 += x / xerr / xerr; - xxx += x * x / xerr / xerr; - - // 2) YZ projection: - yc11 += z * z / yerr / yerr; - yc12 += z / yerr / yerr; - yc22 += 1.0 / yerr / yerr; - yv1 += z * y / yerr / yerr; - yv2 += y / yerr / yerr; - yyy += y * y / yerr / yerr; - } - - if ( ( xdet = xc11 * xc22 - xc12 * xc12 ) == 0 ) return false; - if ( ( ydet = yc11 * yc22 - yc12 * yc12 ) == 0 ) return false; - m_sx = ( xv1 * xc22 - xv2 * xc12 ) / xdet; - m_sy = ( yv1 * yc22 - yv2 * yc12 ) / ydet; - m_bx = ( xv2 * xc11 - xv1 * xc12 ) / xdet; - m_by = ( yv2 * yc11 - yv1 * yc12 ) / ydet; - - m_errbx = sqrt( xc11 / xdet ); - m_errsx = sqrt( xc22 / xdet ); - m_covbsx = -xc12 / xdet; - - m_errby = sqrt( yc11 / ydet ); - m_errsy = sqrt( yc22 / ydet ); - m_covbsy = -yc12 / ydet; - - m_chi2x = - ( xxx + m_sx * m_sx * xc11 + m_bx * m_bx * xc22 - 2. * m_sx * xv1 - 2. * m_bx * xv2 + 2 * m_sx * m_bx * xc12 ) / - dof; - m_chi2y = - ( yyy + m_sy * m_sy * yc11 + m_by * m_by * yc22 - 2. * m_sy * yv1 - 2. * m_by * yv2 + 2 * m_sy * m_by * yc12 ) / - dof; - - return true; -} - -//============================================================================= -// Determination of the field polarity -//============================================================================= -StatusCode TupleToolMuonIDCalib::FindFieldPolarity() { - // compute fiels polarity - // we will use this value for all tracks - - double Zfirst = m_stationZ[0]; // M1 - - Gaudi::XYZPoint begin( 0., 0., 0. ); - Gaudi::XYZPoint end( 0., 0., Zfirst ); - Gaudi::XYZVector bdl; - double z; - - StatusCode sc = m_bIntegrator->calculateBdlAndCenter( begin, end, 0., 0., z, bdl ); - if ( sc.isFailure() ) { return Error( "Failed to find field centre !", StatusCode::FAILURE ); } - - if ( bdl.x() > 0.0 ) { - m_FieldPolarity = 1; - } else { - m_FieldPolarity = -1; - } - - debug() << "Integrated B field is " << bdl.x() << " Tm" - << " centered at Z=" << z / Gaudi::Units::m << " m" << endmsg; - - return StatusCode::SUCCESS; -} - -//==================================================================================== -/// estimate the momentum of the muon-track assuming it cames from the primary vertex -//==================================================================================== -bool TupleToolMuonIDCalib::calculatePt( int& FromM1 ) { - - double pZM1 = 0.; - double qOverP = 0.; - double sigmaQOverP2 = 0.; - double pXPvtx = 0.; - double pYPvtx = 0.; - double pZPvtx = 0.; - - double Zfirst = m_stationZ[0]; // M1 - if ( FromM1 == 0 ) Zfirst = m_stationZ[1]; // M2 - - Gaudi::XYZPoint trackPos( m_bx + m_sx * Zfirst, m_by + m_sy * Zfirst, Zfirst ); - LHCb::State state( LHCb::StateVector( trackPos, Gaudi::XYZVector( m_sx, m_sy, 1.0 ), 1. / 10000. ) ); - - // - Gaudi::XYZPoint begin( 0., 0., 0. ); - Gaudi::XYZPoint end( state.x(), state.y(), state.z() ); - Gaudi::XYZVector bdl; - double zCenter; - - StatusCode sc = m_bIntegrator->calculateBdlAndCenter( begin, end, state.tx(), state.ty(), zCenter, bdl ); - if ( !sc ) { - error() << " Failed to integrate field !!" << endmsg; - return false; - } - - // copied from the TrackPtKick tool by M. Needham - double q = 0.; - double p = 1e6 * Gaudi::Units::MeV; - - double tX; - double xCenter; - double zeta_trk; - double tx_vtx; - double zeta_vtx; - double curv; - - if ( fabs( bdl.x() ) > TrackParameters::hiTolerance ) { - // can estimate momentum and charge - - // Rotate to the 0-0-z axis and do the ptkick - tX = state.tx(); - xCenter = state.x() + tX * ( zCenter - state.z() ); - - zeta_trk = -tX / sqrt( 1.0 + tX * tX ); - tx_vtx = xCenter / zCenter; - zeta_vtx = -tx_vtx / sqrt( 1.0 + tx_vtx * tx_vtx ); - - // curvature - curv = ( zeta_trk - zeta_vtx ); - - // charge - int sign = 1; - if ( curv < TrackParameters::hiTolerance ) { sign *= -1; } - if ( bdl.x() < TrackParameters::hiTolerance ) { sign *= -1; } - q = -1. * m_FieldPolarity * sign; - - // momentum - p = Gaudi::Units::eplus * Gaudi::Units::c_light * fabs( bdl.x() ) * - sqrt( ( 1.0 + tX * tX + gsl_pow_2( state.ty() ) ) / ( 1.0 + gsl_pow_2( tX ) ) ) / fabs( curv ); - - // Addition Correction factor for the angle of the track! - if ( m_ParabolicCorrection.size() == 2u ) { - // p*= (a + b*tx*tx ) - p += m_Constant; - p *= ( m_ParabolicCorrection[0] + ( m_ParabolicCorrection[1] * tX * tX ) ); - } - - } else { - // can't estimate momentum or charge - error() << "B integral is 0!" << endmsg; - return false; - } - - pZM1 = p; - qOverP = q / p; - const double err2 = gsl_pow_2( m_resParams[0] ) + gsl_pow_2( m_resParams[1] / p ); - sigmaQOverP2 = err2 * gsl_pow_2( 1.0 / p ); - - // set MuonTrack momentum variables (momentum at primary vertex) - if ( ( tx_vtx * tx_vtx + state.ty() * state.ty() ) > 1. ) { - // can't estimate momentum vector components - error() << "can't estimate px, py, pz " << endmsg; - return false; - } - double pz_vtx = p * sqrt( 1 - tx_vtx * tx_vtx - state.ty() * state.ty() ); - Gaudi::XYZVector momentum_vtx( tx_vtx * pz_vtx, state.ty() * pz_vtx, pz_vtx ); - pXPvtx = momentum_vtx.X(); - pYPvtx = momentum_vtx.Y(); - pZPvtx = momentum_vtx.Z(); - - if ( FromM1 == 1 ) { - m_5pZM1 = pZM1; - m_5qOverP = qOverP; - m_5sigmaQOverP2 = sigmaQOverP2; - m_5pXPvtx = pXPvtx; - m_5pYPvtx = pYPvtx; - m_5pZPvtx = pZPvtx; - } else if ( FromM1 == 0 ) { - m_4pZM1 = pZM1; - m_4qOverP = qOverP; - m_4sigmaQOverP2 = sigmaQOverP2; - m_4pXPvtx = pXPvtx; - m_4pYPvtx = pYPvtx; - m_4pZPvtx = pZPvtx; - } - - return true; -} - -// extrapolation through the stations to get expected positions with -// errors due to multiple scattering -bool TupleToolMuonIDCalib::estrapola( IGeometryInfo const& geometry ) { - - LHCb::State ExtraState = *( m_stateP ); - - for ( int station = 0; station < m_NStation; station++ ) { - - StatusCode sc = m_extrapolator->propagate( ExtraState, m_stationZ[station], geometry, LHCb::Tr::PID::Muon() ); - if ( sc.isFailure() ) { - debug() << " ==> Extrapolating to z = " << m_stationZ[station] << " failed " << endmsg; - return false; - } - - m_TextraX[station] = ExtraState.x(); - m_TextraY[station] = ExtraState.y(); - m_ms2X[station] = ExtraState.errX2(); - m_ms2Y[station] = ExtraState.errY2(); - - int region = 0; - while ( region < 3 ) { - if ( fabs( m_TextraX[station] ) < ( m_regionOuterX[station] / pow( 2., 3 - region ) ) && - fabs( m_TextraY[station] ) < ( m_regionOuterY[station] / pow( 2., 3 - region ) ) ) - break; - region++; - } - m_TextraReg[station] = region; - } - return true; -} diff --git a/Phys/DecayTreeTupleMuonCalib/src/TupleToolMuonPid.cpp b/Phys/DecayTreeTupleMuonCalib/src/TupleToolMuonPid.cpp deleted file mode 100644 index 0bebec6c64be74219483a29471bae1c0cd0adee1..0000000000000000000000000000000000000000 --- a/Phys/DecayTreeTupleMuonCalib/src/TupleToolMuonPid.cpp +++ /dev/null @@ -1,257 +0,0 @@ -/*****************************************************************************\ -* (c) Copyright 2000-2018 CERN for the benefit of the LHCb Collaboration * -* * -* This software is distributed under the terms of the GNU General Public * -* Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". * -* * -* In applying this licence, CERN does not waive the privileges and immunities * -* granted to it by virtue of its status as an Intergovernmental Organization * -* or submit itself to any jurisdiction. * -\*****************************************************************************/ - -#include "DecayTreeTupleBase/TupleToolBase.h" - -#include "Kernel/IParticleTupleTool.h" // Interface -#include "Kernel/LHCbID.h" -#include "Kernel/MuonTileID.h" -#include "Kernel/Particle2MCLinker.h" - -#include "MuonDet/DeMuonDetector.h" -#include "MuonDet/MuonBasicGeometry.h" - -#include "Event/MuonCoord.h" -#include "Event/MuonDigit.h" -#include "Event/MuonPID.h" -#include "Event/Particle.h" -#include "Event/Track.h" - -#include "GaudiAlg/Tuple.h" -#include "GaudiAlg/TupleObj.h" - -/** - * @author Kazu Akiba - * @date 2011-09-01 - * 2007-11-07 : Jeremie Borel - */ -class TupleToolMuonPid : public TupleToolBase, virtual public IParticleTupleTool { -public: - TupleToolMuonPid( const std::string& type, const std::string& name, const IInterface* parent ); - StatusCode initialize() override; - StatusCode fill( const LHCb::Particle*, const LHCb::Particle*, const std::string&, Tuples::Tuple&, - IGeometryInfo const& ) override; - - StatusCode trackExtrapolate( const LHCb::Track* pTrack, std::vector& trackX, std::vector& trackY ); - std::vector findTrackRegions( const LHCb::Track* pTrack ); - -private: - DeMuonDetector* m_mudet; - unsigned int m_NStation; // Number of stations - unsigned int m_NRegion; // Number of regions - std::vector m_stationZ; // station position - std::vector m_trackX; // position of track in x(mm) in each station - std::vector m_trackY; // position of track in y(mm) in each station - - // Names of the station - std::vector m_stationNames; -}; - -using namespace LHCb; - -//============================================================================= -// Standard constructor, initializes variables -//============================================================================= -TupleToolMuonPid::TupleToolMuonPid( const std::string& type, const std::string& name, const IInterface* parent ) - : TupleToolBase( type, name, parent ) { - declareInterface( this ); -} - -StatusCode TupleToolMuonPid::initialize() { - const StatusCode sc = TupleToolBase::initialize(); - if ( sc.isFailure() ) return sc; - // Get Basic Muon geometry info - m_NStation = 0; - m_NRegion = 0; - MuonBasicGeometry basegeometry( detSvc(), msgSvc() ); - m_NStation = basegeometry.getStations(); - m_NRegion = basegeometry.getRegions(); - unsigned int i = 0; - while ( i < m_NStation ) { - m_stationNames.push_back( basegeometry.getStationName( i ) ); - if ( msgLevel( MSG::DEBUG ) ) debug() << " station " << i << " " << m_stationNames[i] << endmsg; - i++; - } - m_mudet = getDet( "/dd/Structure/LHCb/DownstreamRegion/Muon" ); - // m_mudet=getDet(DeMuonLocation::Default); - for ( unsigned int station = 0; station < m_NStation; station++ ) { - m_stationZ.push_back( m_mudet->getStationZ( station ) ); - } - if ( !m_mudet ) return StatusCode::FAILURE; - return sc; -} - -StatusCode TupleToolMuonPid::fill( const Particle*, const Particle* P, const std::string& head, Tuples::Tuple& tuple, - IGeometryInfo const& ) { - const std::string prefix = fullName( head ); - if ( msgLevel( MSG::DEBUG ) ) - debug() << "TupleToolMuonPid::fill: ++++++++ Filling info for particle with key " << P->key() << " head: " << head - << " ++++++++ " << endmsg; - if ( P ) { - bool test = true; - test &= tuple->column( prefix + "_ID", P->particleID().pid() ); - if ( !P->isBasicParticle() ) return StatusCode( test ); // no rich info for composite! - if ( isPureNeutralCalo( P ) ) return StatusCode( test ); // no rich information for calo neutrals - const ProtoParticle* proto = P->proto(); - if ( proto ) { - // Combined DLLs - test &= - tuple->column( prefix + "_CombDLLMu", proto->info( LHCb::ProtoParticle::additionalInfo::CombDLLmu, -1000 ) ); - test &= - tuple->column( prefix + "_ProbNNmu", proto->info( LHCb::ProtoParticle::additionalInfo::ProbNNmu, -1000 ) ); - test &= tuple->column( prefix + "_ProbNNghost", - proto->info( LHCb::ProtoParticle::additionalInfo::ProbNNghost, -1000 ) ); - test &= - tuple->column( prefix + "_InMuonAcc", proto->info( LHCb::ProtoParticle::additionalInfo::InAccMuon, -1000 ) ); - bool hasMuon = false; - bool isMuon = false; - bool isMuonLoose = false; - // bool isMuonTight = false; - double muonLLmu = -99999; - double muonLLbg = -99999; - const MuonPID* muonPID = proto->muonPID(); - int NShared = -1; - double muonDist2 = -99999; - if ( muonPID ) { - hasMuon = true; - isMuon = muonPID->IsMuon(); - isMuonLoose = muonPID->IsMuonLoose(); - // isMuonTight = muonPID->IsMuonTight(); - NShared = muonPID->nShared(); - muonLLmu = muonPID->MuonLLMu(); - muonLLbg = muonPID->MuonLLBg(); - // std::cout << "before get Tracks" << std::endl; - const LHCb::Track* track = muonPID->muonTrack(); - if ( track ) { - // std::cout << "before get muonDist2" << std::endl; - muonDist2 = track->info( LHCb::Track::AdditionalInfo::MuonDist2, -1000 ); - } - } - - // Find region in M2 or M3 from track extrapolation, used to calculate muLL - const LHCb::Track* pTrack = proto->track(); - std::vector trackRegion( m_NStation, -1 ); - - // find track region - trackRegion = findTrackRegions( pTrack ); - int region = trackRegion[1]; // M2 - if ( region < 0 ) { - if ( msgLevel( MSG::DEBUG ) ) - debug() << " Track extrapolation in station 2 gives non-existent region " << endmsg; - region = trackRegion[2]; // M3 - } - if ( region < 0 && msgLevel( MSG::DEBUG ) ) - debug() << " Track extrapolation in station 3 gives non-existent region " << endmsg; - - if ( msgLevel( MSG::DEBUG ) ) - debug() << "TupleToolMuonPid::fill:Track info: p = " << pTrack->p() << " Region in M2/M3: " << region - << " IsMuonLoose = " << isMuonLoose << " IsMuon = " << isMuon << " Dist2 = " << muonDist2 - << " muonLLmu = " << muonLLmu << " muonLLbg = " << muonLLbg << endmsg; - - // std::cout << "before add MuonDist2 to ntuple" << std::endl; - test &= tuple->column( prefix + "_MuonDist2", muonDist2 ); - test &= tuple->column( prefix + "_regionInM2", region ); - int isMuonFromProto = -2000; - test &= tuple->column( prefix + "_hasMuon", hasMuon ); - test &= tuple->column( prefix + "_isMuon", isMuon ); - test &= tuple->column( prefix + "_isMuonLoose", isMuonLoose ); - // test &= tuple->column( prefix+"_isMuonTight", isMuonTight); - test &= tuple->column( prefix + "_NShared", NShared ); - test &= tuple->column( prefix + "_MuonLLmu", muonLLmu ); - test &= tuple->column( prefix + "_MuonLLbg", muonLLbg ); - - isMuonFromProto = ( (int)( proto->info( LHCb::ProtoParticle::additionalInfo::MuonPIDStatus, -999 ) ) ) % 2; - test &= tuple->column( prefix + "_isMuonFromProto", isMuonFromProto ); - - // const LHCb::Track* track = proto->track(); - // if (track) { - // test &= tuple->column( prefix+"_MuonDist2", track->info(LHCb::Track::AdditionalInfo::MuonDist2, -1000)); - //} - - return StatusCode( test ); - } - } - return StatusCode::FAILURE; -} - -//===================================================================== -// Extrapolate track to Muon system and find region in each chamber. Region in M2 is used in the dll calculation -// Code copied/adapted from MuonIDAlg. J. Helder. 04/2013 -//===================================================================== - -StatusCode TupleToolMuonPid::trackExtrapolate( const LHCb::Track* pTrack, std::vector& trackX, - std::vector& trackY ) { - - // get first state for the preSel cut - const LHCb::State* state1 = &( pTrack->firstState() ); - // get state closest to M1 for extrapolation - const LHCb::State* state = &( pTrack->closestState( 9450. ) ); - - if ( !state1 ) return Error( " Failed to get 1st state from track " ); - if ( !state ) return Error( " Failed to get state from track " ); - - // get the momentum (MeV/c) - // double momentum = state->p(); - // double momentumPre = state1->p(); - // if (msgLevel(MSG::DEBUG)) debug() << "trackExtrapolate: momentum = " << momentum << " momentumPre = " << - // momentumPre << endmsg; - - // Project the state into the muon stations - for ( unsigned int station = 0; station < m_NStation; station++ ) { - // x(z') = x(z) + (dx/dz * (z' - z)) - trackX.push_back( state->x() + ( state->tx() * ( m_stationZ[station] - state->z() ) ) ); - trackY.push_back( state->y() + ( state->ty() * ( m_stationZ[station] - state->z() ) ) ); - } - if ( msgLevel( MSG::DEBUG ) ) { - debug() << "trackExtrapolate: trackX = " << trackX << endmsg; - debug() << "trackExtrapolate: trackY = " << trackY << endmsg; - } - return StatusCode::SUCCESS; -} - -//===================================================================== -std::vector TupleToolMuonPid::findTrackRegions( const LHCb::Track* pTrack ) { - //===================================================================== - // comment: Returns the muon detector region of the extrapolated track; - // authors: G. Lanfranchi & S. Furcas & X. Cid Vidal, - // date: 10/3/11 - //===================================================================== - - std::vector trackX; - std::vector trackY; - trackExtrapolate( pTrack, trackX, trackY ).ignore( /* AUTOMATICALLY ADDED FOR gaudi/Gaudi!763 */ ); - - // info() << "findTrackRegions: trackX = " << trackX << endmsg; - // info() << "findTrackRegions: trackY = " << trackY << endmsg; - - std::vector trackRegion( m_NStation, -1 ); - // Region of the track extrapolated: - - for ( unsigned int sta = 0; sta < m_NStation; sta++ ) { - - int chnum = -1; - int regnum = -1; - - m_mudet->Pos2StChamberNumber( trackX[sta], trackY[sta], sta, chnum, regnum ).ignore(); - // if (msgLevel(MSG::DEBUG)) debug() << "TupleToolMuonPid: Station = " << sta << " chnum = " << chnum << " regnum = - // " << regnum << endmsg; - trackRegion[sta] = regnum; - if ( trackRegion[sta] < 0 && msgLevel( MSG::DEBUG ) ) - debug() << format( " Track extrapolation in station %d gives not-existent region ", sta ) << endmsg; - } - - if ( msgLevel( MSG::DEBUG ) ) debug() << "TrackRegions: " << trackRegion << endmsg; - return trackRegion; -} - -// Declaration of the Tool Factory -// actually acts as a using namespace TupleTool -DECLARE_COMPONENT( TupleToolMuonPid ) diff --git a/Phys/DecayTreeTupleReco/CMakeLists.txt b/Phys/DecayTreeTupleReco/CMakeLists.txt deleted file mode 100644 index 5c90886309d00588e20ebe583062e8254678513e..0000000000000000000000000000000000000000 --- a/Phys/DecayTreeTupleReco/CMakeLists.txt +++ /dev/null @@ -1,42 +0,0 @@ -############################################################################### -# (c) Copyright 2000-2021 CERN for the benefit of the LHCb Collaboration # -# # -# This software is distributed under the terms of the GNU General Public # -# Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". # -# # -# In applying this licence, CERN does not waive the privileges and immunities # -# granted to it by virtue of its status as an Intergovernmental Organization # -# or submit itself to any jurisdiction. # -############################################################################### -#[=======================================================================[.rst: -Phys/DecayTreeTupleReco ------------------------ -#]=======================================================================] - -gaudi_add_module(DecayTreeTupleReco - SOURCES - src/TupleToolAllPhotons.cpp - src/TupleToolAllVeloTracks.cpp - src/TupleToolCPU.cpp - src/TupleToolPrimaries.cpp - src/TupleToolProtoPData.cpp - src/TupleToolRICHPid.cpp - src/TupleToolRecoStats.cpp - src/TupleToolTrackInfo.cpp - LINK - Analysis::DecayTreeTupleBaseLib - Gaudi::GaudiAlgLib - Gaudi::GaudiKernel - LHCb::CaloUtils - LHCb::DigiEvent - LHCb::HltDAQLib - LHCb::LHCbKernel - LHCb::PhysEvent - LHCb::RecEvent - LHCb::RichUtils - LHCb::TrackEvent - Phys::DaVinciInterfacesLib - Phys::DaVinciKernelLib - Phys::DaVinciMCKernelLib - Rec::TrackInterfacesLib -) diff --git a/Phys/DecayTreeTupleReco/doc/release.notes b/Phys/DecayTreeTupleReco/doc/release.notes deleted file mode 100644 index 00ada7bcac673b4397ace947a71d2114252ec484..0000000000000000000000000000000000000000 --- a/Phys/DecayTreeTupleReco/doc/release.notes +++ /dev/null @@ -1,77 +0,0 @@ -!----------------------------------------------------------------------------- -! Package : Phys/DecayTreeTupleReco -! Responsible : Chris Jones -! Purpose : Reconstruction related tuple tools -!----------------------------------------------------------------------------- - -! 2017-12-22 - Cristina Sanchez Gras, Patrick Koppenburg - - TupleToolTrackInfo : added option StoreFirstMeasurement that adds the new values - * - X_TRACK_qOverp : q/p of state at 'FirstMeasurement' - * - X_TRACK_Tx : x slope of state at 'FirstMeasurement' - * - X_TRACK_Ty : y slope of state at 'FirstMeasurement' - The already existing X_TRACK_FirstMeasurement{X,Y,Z} get also added. Verbose also adds these six variables. The change is thus backward-comaptible. - -!=================== DecayTreeTupleReco v1r5 2015-07-24 ====================== - -! 2015-07-10 - Sean Benson - - Add additional fallback to make the RecSummary from the HLT selection reports as a last resort. - -! 2015-06-06 - Sean Benson - - Make TupleToolRecoStats look in one more place. - -!========================= DecayTreeTupleReco v1r4p1 2014-10-30 ========================= - -! 2014-10-30 - Chris Jones - - Fix an ifdef typo - -!========================= DecayTreeTupleReco v1r4 2013-12-18 ========================= - -! 2013-11-05 - Francesco Dettori - - Adding TupleToolKink: A tool to find kink information in the given tracks. - TrackFitEvent added in the requirements. - -!========================= DecayTreeTupleReco v1r3 2013-06-13 ========================= - -! 2013-05-13 - Chris Jones - - TupleToolVELOClusters - . Fix inappropriate return values causing compilation warnings with icc11. - . Do not load the RecSummary object, as not actually used. - -!========================= DecayTreeTupleReco v1r2 2013-04-05 ========================= - -! 2013-03-08 - Marco Clemencic - - Fixed compilation with CMake. - -! 2013-02-26 - Chris Jones - - Fix -pedantic compilation warnings - -! 2013-02-25 - Kazu Akiba - - Adding 2 new variables to TupleToolVELOClusters - -!========================= DecayTreeTupleReco v1r1 2013-02-20 ========================= - -! 2013-01-24 - Patrick Koppenburg - - Rob said "undo your changes", so I did. Actually the functionality is already in - the baseclass. - -! 2013-01-22 - P. Koppenburg - - TupleToolTrackExtrapolation: add a prefix field to allow several instances to be used. - -! 2013-01-07 - Chris Jones - - Minor optimisations to TupleToolTrackIsolation - -! 2012-12-11 - Kazu Akiba - - Adding TupleToolVeloTrackClusterInfo - - Adding TupleToolDEDX and TupleToolVeloClusters. - TupleToolDEDX has many variables to use the energy loss in the VELO - TupleToolVeloClusters searches for unused velo clusters. - -!========================= DecayTreeTupleReco v1r0 2012-11-30 ========================= - - -! 2012-11-29 - Marco Clemencic - - Added CMake configuration file. - -! 2012-11-22 - Chris Jones - - First version. Split of from monolithic Phys/DecayTreeTuple package. - Contains the tools that provide reconstruction information. diff --git a/Phys/DecayTreeTupleReco/src/TupleToolAllPhotons.cpp b/Phys/DecayTreeTupleReco/src/TupleToolAllPhotons.cpp deleted file mode 100644 index e8c8dc9c023712f92834201efdbce856d8a0862f..0000000000000000000000000000000000000000 --- a/Phys/DecayTreeTupleReco/src/TupleToolAllPhotons.cpp +++ /dev/null @@ -1,163 +0,0 @@ -/*****************************************************************************\ -* (c) Copyright 2000-2018 CERN for the benefit of the LHCb Collaboration * -* * -* This software is distributed under the terms of the GNU General Public * -* Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". * -* * -* In applying this licence, CERN does not waive the privileges and immunities * -* granted to it by virtue of its status as an Intergovernmental Organization * -* or submit itself to any jurisdiction. * -\*****************************************************************************/ -// from Gaudi -#include "Event/Particle.h" -#include "Event/RecSummary.h" -#include "Event/RecVertex.h" -#include "Event/Track.h" -#include "Event/VeloCluster.h" -#include "Event/VertexBase.h" -#include "Kernel/DefaultDVToolTypes.h" -#include "TrackInterfaces/IMeasurementProvider.h" -// local -#include "Kernel/IParticle2MCAssociator.h" -#include "TrackInterfaces/ITrackExtrapolator.h" -#include "TrackInterfaces/ITrackStateProvider.h" -#include "TupleToolAllPhotons.h" - -//----------------------------------------------------------------------------- -// Implementation file for class : TupleToolAllPhotons -// -// 2017-05-25 : Dan Johnson, Victor Coco, Kazu Akiba -//----------------------------------------------------------------------------- - -//============================================================================= -// Standard constructor, initializes variables -//============================================================================= -TupleToolAllPhotons::TupleToolAllPhotons( const std::string& type, const std::string& name, const IInterface* parent ) - : TupleToolBase( type, name, parent ) { - declareInterface( this ); -} - -StatusCode TupleToolAllPhotons::initialize() { - StatusCode sc = TupleToolBase::initialize(); - if ( sc.isFailure() ) return sc; - - info() << "Will fill all particles from " << m_location << " up to size " << m_max << endmsg; - - m_pvf = tool( DaVinci::DefaultTools::PVRelator, this ); - if ( !m_pvf ) return Error( "Couldn't get PVRelator" ); - - m_dist = tool( DaVinci::DefaultTools::Distance, this ); - if ( !m_dist ) { return Error( "Unable to retrieve the IDistanceCalculator tool" ); } - m_extrapolator = tool( "TrackStateProvider", this ); - - // MC associators - for ( const auto& iMCAss : m_p2mcAssocTypes ) { - m_p2mcAssocs.push_back( tool( iMCAss, this ) ); - } - - return sc; -} - -//============================================================================= -StatusCode TupleToolAllPhotons::fill( Tuples::Tuple& tup ) { - const std::string prefix = fullName(); - - LHCb::Particle::Range parts; - if ( exist( m_location ) ) { - parts = get( m_location ); - } else - return Warning( "Nothing found at " + m_location, StatusCode::SUCCESS, 1 ); - - // Fill the tuple - bool test = true; - - std::vector PX, PY, PZ, PE, CL, Prob; - std::vector ISMUON; - std::vector PID, TCAT, TPID; - std::vector vCaloTrMatch; - std::vector vCaloDepositID; - std::vector vShowerShape; - std::vector vClusterMass; - std::vector vCaloNeutralEcal; - std::vector vCaloNeutralHcal2Ecal; - std::vector vCaloNeutralE49; - std::vector vCaloNeutralID; - std::vector vPhotonID; - std::vector vIsPhoton; - - for ( const auto& p : parts ) { - if ( PID.size() == m_max ) { - Warning( "Reached maximum size of array", StatusCode::SUCCESS ).ignore(); - break; - } - PID.push_back( p->particleID().pid() ); - TPID.push_back( TID( p ) ); - PX.push_back( p->momentum().x() ); - PY.push_back( p->momentum().y() ); - PZ.push_back( p->momentum().z() ); - PE.push_back( p->momentum().T() ); - const LHCb::ProtoParticle* pp = p->proto(); - if ( pp ) { - vCaloTrMatch.push_back( pp->info( LHCb::ProtoParticle::CaloTrMatch, -1000 ) ); - vCaloDepositID.push_back( pp->info( LHCb::ProtoParticle::CaloDepositID, -1000 ) ); - vShowerShape.push_back( pp->info( LHCb::ProtoParticle::ShowerShape, -1000 ) ); - vClusterMass.push_back( pp->info( LHCb::ProtoParticle::ClusterMass, -1000 ) ); - vCaloNeutralEcal.push_back( pp->info( LHCb::ProtoParticle::CaloNeutralEcal, -1000 ) ); - vCaloNeutralHcal2Ecal.push_back( pp->info( LHCb::ProtoParticle::CaloNeutralHcal2Ecal, -1000 ) ); - vCaloNeutralE49.push_back( pp->info( LHCb::ProtoParticle::CaloNeutralE49, -1000 ) ); - vCaloNeutralID.push_back( pp->info( LHCb::ProtoParticle::CaloNeutralID, -1000 ) ); - vPhotonID.push_back( pp->info( LHCb::ProtoParticle::PhotonID, -1000 ) ); - vIsPhoton.push_back( pp->info( LHCb::ProtoParticle::IsPhoton, -1000 ) ); - } - } - unsigned int siz = PID.size(); - - test &= ( PE.empty() || PE.size() == siz ); // check - test &= ( vIsPhoton.empty() || vIsPhoton.size() == siz ); // check - if ( !test ) { - err() << "Inconsistent array sizes " << siz << " and " << PE.size() << " and " << vIsPhoton.size() << endmsg; - return StatusCode( test ); - } - - test &= tup->farray( prefix + "AllPhotons_PID", PID, prefix + "nParts", m_max ); - test &= tup->farray( prefix + "AllPhotons_TPID", TPID, prefix + "nParts", m_max ); - test &= tup->farray( prefix + "AllPhotons_PX", PX, prefix + "nParts", m_max ); - test &= tup->farray( prefix + "AllPhotons_PY", PY, prefix + "nParts", m_max ); - test &= tup->farray( prefix + "AllPhotons_PZ", PZ, prefix + "nParts", m_max ); - test &= tup->farray( prefix + "AllPhotons_PE", PE, prefix + "nParts", m_max ); - - test &= tup->farray( prefix + "AllPhotons_CaloTrMatch", vCaloTrMatch, prefix + "nParts", m_max ); - test &= tup->farray( prefix + "AllPhotons_CaloDepositID", vCaloDepositID, prefix + "nParts", m_max ); - test &= tup->farray( prefix + "AllPhotons_ShowerShape", vShowerShape, prefix + "nParts", m_max ); - test &= tup->farray( prefix + "AllPhotons_ClusterMass", vClusterMass, prefix + "nParts", m_max ); - test &= tup->farray( prefix + "AllPhotons_CaloNeutralEcal", vCaloNeutralEcal, prefix + "nParts", m_max ); - test &= tup->farray( prefix + "AllPhotons_CaloNeutralHcal2Ecal", vCaloNeutralHcal2Ecal, prefix + "nParts", m_max ); - test &= tup->farray( prefix + "AllPhotons_CaloNeutralE49", vCaloNeutralE49, prefix + "nParts", m_max ); - test &= tup->farray( prefix + "AllPhotons_CaloNeutralID", vCaloNeutralID, prefix + "nParts", m_max ); - test &= tup->farray( prefix + "AllPhotons_PhotonID", vPhotonID, prefix + "nParts", m_max ); - test &= tup->farray( prefix + "AllPhotons_IsPhoton", vIsPhoton, prefix + "nParts", m_max ); - - return StatusCode( test ); -} -//============================================================================ -int TupleToolAllPhotons::TID( const LHCb::Particle* P ) { - Assert( !m_p2mcAssocs.empty(), "The DaVinci smart associator(s) have not been initialized!" ); - const LHCb::MCParticle* mcp( NULL ); - if ( P ) { - // assignedPid = P->particleID().pid(); - if ( msgLevel( MSG::VERBOSE ) ) verbose() << "Getting related MCP to " << P << endmsg; - for ( const auto& iMCAss : m_p2mcAssocs ) { - mcp = iMCAss->relatedMCP( P ); - if ( mcp ) break; - } - if ( msgLevel( MSG::VERBOSE ) ) verbose() << "Got mcp " << mcp << endmsg; - } - // pointer is ready, prepare the values: - if ( mcp ) - return mcp->particleID().pid(); - else - return 0; -} - -// Declaration of the Tool Factory -DECLARE_COMPONENT( TupleToolAllPhotons ) diff --git a/Phys/DecayTreeTupleReco/src/TupleToolAllPhotons.h b/Phys/DecayTreeTupleReco/src/TupleToolAllPhotons.h deleted file mode 100644 index 2458fb5839d38e1898cda32bbfee9c51fa559d00..0000000000000000000000000000000000000000 --- a/Phys/DecayTreeTupleReco/src/TupleToolAllPhotons.h +++ /dev/null @@ -1,62 +0,0 @@ -/*****************************************************************************\ -* (c) Copyright 2000-2018 CERN for the benefit of the LHCb Collaboration * -* * -* This software is distributed under the terms of the GNU General Public * -* Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". * -* * -* In applying this licence, CERN does not waive the privileges and immunities * -* granted to it by virtue of its status as an Intergovernmental Organization * -* or submit itself to any jurisdiction. * -\*****************************************************************************/ -#ifndef TUPLETOOLALLTRACKS_H -#define TUPLETOOLALLTRACKS_H 1 - -// Include files -// from Gaudi -#include "DecayTreeTupleBase/TupleToolBase.h" -#include "Kernel/IEventTupleTool.h" // Interface -#include "Kernel/IRelatedPVFinder.h" -#include - -struct ITrackExtrapolator; -struct ITrackStateProvider; -class IParticle2MCAssociator; - -/** @class TupleToolAllPhotons TupleToolAllPhotons.h - * - * This tuple tool fills information about every calorimeter object in the StdLooseAllPhotons container. - * - * The primary target of this tool is analysis in a low multiplicity environment, particularly CEP studies. - * The default case is therefore to limit the stored information to 12 objects in the container, in order - * to minimise the impact on ntuple size. However, this limit is left configurable. - * - * @author Dan Johnson, Victor Coco, Kazu Akiba - * @date 2017-05-25 - */ -class TupleToolAllPhotons : public TupleToolBase, virtual public IEventTupleTool { -public: - /// Standard constructor - TupleToolAllPhotons( const std::string& type, const std::string& name, const IInterface* parent ); - - /// Declare properties - Gaudi::Property m_location{this, "Location", "/Event/Phys/StdLooseAllPhotons/Particles", - "Location of particles"}; - Gaudi::Property m_max{this, "Max", 12, "Maximum n photons to store information about"}; - Gaudi::Property m_allChi2{this, "AllChi2", false, "Fill all chi2?"}; - Gaudi::Property> m_p2mcAssocTypes{this, - "IP2MCPAssociatorTypes", - {"DaVinciSmartAssociator", "MCMatchObjP2MCRelator"}, - "MC associators to try, in order"}; - - virtual StatusCode fill( Tuples::Tuple& ) override; ///< Fill tuple - StatusCode initialize() override; ///< init - -private: - int TID( const LHCb::Particle* p ); - const IDistanceCalculator* m_dist = 0; - IRelatedPVFinder* m_pvf = 0; - const ITrackStateProvider* m_extrapolator = 0; ///< pointer to the track extrapolator - std::vector m_p2mcAssocs; -}; - -#endif // TUPLETOOLALLTRACKS_H diff --git a/Phys/DecayTreeTupleReco/src/TupleToolAllVeloTracks.cpp b/Phys/DecayTreeTupleReco/src/TupleToolAllVeloTracks.cpp deleted file mode 100644 index bba3c77ba21f0fe4bd75c819d4077afd10a3ffce..0000000000000000000000000000000000000000 --- a/Phys/DecayTreeTupleReco/src/TupleToolAllVeloTracks.cpp +++ /dev/null @@ -1,92 +0,0 @@ -/*****************************************************************************\ -* (c) Copyright 2000-2018 CERN for the benefit of the LHCb Collaboration * -* * -* This software is distributed under the terms of the GNU General Public * -* Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". * -* * -* In applying this licence, CERN does not waive the privileges and immunities * -* granted to it by virtue of its status as an Intergovernmental Organization * -* or submit itself to any jurisdiction. * -\*****************************************************************************/ -// from Gaudi -#include "Event/Particle.h" -#include "Event/RecSummary.h" -#include "Event/RecVertex.h" -#include "Event/Track.h" -#include "Event/VeloCluster.h" -#include "Event/VertexBase.h" -#include "Kernel/DefaultDVToolTypes.h" -#include "TrackInterfaces/IMeasurementProvider.h" -// local -#include "Kernel/IParticle2MCAssociator.h" -#include "TrackInterfaces/ITrackExtrapolator.h" -#include "TrackInterfaces/ITrackStateProvider.h" -#include "TupleToolAllVeloTracks.h" - -//----------------------------------------------------------------------------- -// Implementation file for class : TupleToolAllVeloTracks -// -// 2017-05-25 : Dan Johnson, Victor Coco, Kazu Akiba -//----------------------------------------------------------------------------- - -//============================================================================= -// Standard constructor, initializes variables -//============================================================================= -TupleToolAllVeloTracks::TupleToolAllVeloTracks( const std::string& type, const std::string& name, - const IInterface* parent ) - : TupleToolBase( type, name, parent ) { - declareInterface( this ); -} - -StatusCode TupleToolAllVeloTracks::initialize() { - StatusCode sc = TupleToolBase::initialize(); - if ( sc.isFailure() ) return sc; - - return sc; -} - -//============================================================================= -StatusCode TupleToolAllVeloTracks::fill( Tuples::Tuple& tup ) { - const std::string prefix = fullName(); - bool test = true; - - std::vector vSlopeX; - std::vector vSlopeY; - std::vector vPointX; - std::vector vPointY; - std::vector vPointZ; - std::vector vChi2pDOF; - std::vector vType; - std::vector vKey; - - const LHCb::Tracks* tracks = get( m_location ); - if ( !tracks || tracks->empty() ) return StatusCode::FAILURE; - for ( const auto& tr : ( *tracks ) ) { - // Only save tracks with a velo segment (long, velo or upstream) - if ( tr->type() != LHCb::Track::Types::Velo && tr->type() != LHCb::Track::Types::Upstream && - tr->type() != LHCb::Track::Types::Long ) - continue; - Gaudi::XYZPoint pos = tr->position(); - Gaudi::XYZVector slop = tr->slopes(); - vSlopeX.push_back( slop.X() ); - vSlopeY.push_back( slop.Y() ); - vPointX.push_back( pos.X() ); - vPointY.push_back( pos.Y() ); - vPointZ.push_back( pos.Z() ); - vType.push_back( tr->type() ); - vKey.push_back( tr->key() ); - vChi2pDOF.push_back( tr->chi2PerDoF() ); - } // tracks - test &= tup->farray( prefix + "VeloSegTr_slopeX", vSlopeX, prefix + "nVeloSegTracks", m_max ); - test &= tup->farray( prefix + "VeloSegTr_slopeY", vSlopeY, prefix + "nVeloSegTracks", m_max ); - test &= tup->farray( prefix + "VeloSegTr_pointX", vPointX, prefix + "nVeloSegTracks", m_max ); - test &= tup->farray( prefix + "VeloSegTr_pointY", vPointY, prefix + "nVeloSegTracks", m_max ); - test &= tup->farray( prefix + "VeloSegTr_pointZ", vPointZ, prefix + "nVeloSegTracks", m_max ); - test &= tup->farray( prefix + "VeloSegTr_chi2pdof", vChi2pDOF, prefix + "nVeloSegTracks", m_max ); - test &= tup->farray( prefix + "VeloSegTr_type", vType, prefix + "nVeloSegTracks", m_max ); - test &= tup->farray( prefix + "VeloSegTr_key", vKey, prefix + "nVeloSegTracks", m_max ); - return StatusCode( test ); -} - -// Declaration of the Tool Factory -DECLARE_COMPONENT( TupleToolAllVeloTracks ) diff --git a/Phys/DecayTreeTupleReco/src/TupleToolAllVeloTracks.h b/Phys/DecayTreeTupleReco/src/TupleToolAllVeloTracks.h deleted file mode 100644 index a9ff16e9b4b58ae017b74059bf6105b2a506763b..0000000000000000000000000000000000000000 --- a/Phys/DecayTreeTupleReco/src/TupleToolAllVeloTracks.h +++ /dev/null @@ -1,49 +0,0 @@ -/*****************************************************************************\ -* (c) Copyright 2000-2018 CERN for the benefit of the LHCb Collaboration * -* * -* This software is distributed under the terms of the GNU General Public * -* Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". * -* * -* In applying this licence, CERN does not waive the privileges and immunities * -* granted to it by virtue of its status as an Intergovernmental Organization * -* or submit itself to any jurisdiction. * -\*****************************************************************************/ -#ifndef TUPLETOOLALLTRACKS_H -#define TUPLETOOLALLTRACKS_H 1 - -// Include files -// from Gaudi -#include "DecayTreeTupleBase/TupleToolBase.h" -#include "Kernel/IEventTupleTool.h" // Interface -#include "Kernel/IRelatedPVFinder.h" -#include - -struct ITrackExtrapolator; -struct ITrackStateProvider; -class IParticle2MCAssociator; - -/** @class TupleToolAllVeloTracks TupleToolAllVeloTracks.h - * - * This tuple tool fills information about every VELO track best-tracks container. - * - * The primary target of this tool is analysis in a low multiplicity environment, particularly CEP studies. - * The default case is therefore to limit the stored information to 50 tracks in the container, in order - * to minimise the impact on ntuple size. However, this limit is left configurable. - * - * @author Dan Johnson, Victor Coco, Kazu Akiba - * @date 2017-05-25 - */ -class TupleToolAllVeloTracks : public TupleToolBase, virtual public IEventTupleTool { -public: - /// Standard constructor - TupleToolAllVeloTracks( const std::string& type, const std::string& name, const IInterface* parent ); - - /// Declare properties - Gaudi::Property m_location{this, "Location", LHCb::TrackLocation::Default, "Location of particles"}; - Gaudi::Property m_max{this, "Max", 50, "Maximum n photons to store information about"}; - - virtual StatusCode fill( Tuples::Tuple& ) override; ///< Fill tuple - StatusCode initialize() override; ///< init -}; - -#endif // TUPLETOOLALLTRACKS_H diff --git a/Phys/DecayTreeTupleReco/src/TupleToolCPU.cpp b/Phys/DecayTreeTupleReco/src/TupleToolCPU.cpp deleted file mode 100755 index 41c2401288bc78023e6cd56bbbe7ffed984e1d49..0000000000000000000000000000000000000000 --- a/Phys/DecayTreeTupleReco/src/TupleToolCPU.cpp +++ /dev/null @@ -1,59 +0,0 @@ -/*****************************************************************************\ -* (c) Copyright 2000-2018 CERN for the benefit of the LHCb Collaboration * -* * -* This software is distributed under the terms of the GNU General Public * -* Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". * -* * -* In applying this licence, CERN does not waive the privileges and immunities * -* granted to it by virtue of its status as an Intergovernmental Organization * -* or submit itself to any jurisdiction. * -\*****************************************************************************/ -#include "TupleToolCPU.h" - -#include "GaudiAlg/ISequencerTimerTool.h" -#include "GaudiAlg/ITupleTool.h" -#include "GaudiAlg/Tuple.h" -#include "GaudiKernel/Memory.h" - -#include "GaudiKernel/IRegistry.h" // IOpaqueAddress - -//----------------------------------------------------------------------------- -// Implementation file for class : CPUTupleTool -// -// 2010-08-19 Patrick Koppenburg -//----------------------------------------------------------------------------- - -// Declaration of the Tool Factory -DECLARE_COMPONENT( TupleToolCPU ) - -//============================================================================= -// Standard constructor, initializes variables -//============================================================================= -TupleToolCPU::TupleToolCPU( const std::string& type, const std::string& name, const IInterface* parent ) - : TupleToolBase( type, name, parent ), m_timerTool( 0 ), m_timer( 0 ) { - declareInterface( this ); -} -//============================================================================= - -StatusCode TupleToolCPU::initialize() { - const StatusCode sc = TupleToolBase::initialize(); - m_timerTool = tool( "SequencerTimerTool" ); // global tool - m_timer = m_timerTool->addTimer( name() ); - m_timerTool->start( m_timer ); /// start it now - return sc; -} - -//============================================================================= - -StatusCode TupleToolCPU::fill( Tuples::Tuple& tuple ) { - const std::string prefix = fullName(); - - double t = m_timerTool->stop( m_timer ); /// stop - if ( msgLevel( MSG::DEBUG ) ) debug() << "Time is " << t << endmsg; - m_timerTool->start( m_timer ); /// start again - - bool test = true; - test &= tuple->column( prefix + "Memory", (double)System::virtualMemory() ); - test &= tuple->column( prefix + "CPUTime", t ); - return StatusCode( test ); -} diff --git a/Phys/DecayTreeTupleReco/src/TupleToolCPU.h b/Phys/DecayTreeTupleReco/src/TupleToolCPU.h deleted file mode 100755 index 45aa9fb86a3ed94b029a685c66f2c9980a6ef307..0000000000000000000000000000000000000000 --- a/Phys/DecayTreeTupleReco/src/TupleToolCPU.h +++ /dev/null @@ -1,48 +0,0 @@ -/*****************************************************************************\ -* (c) Copyright 2000-2018 CERN for the benefit of the LHCb Collaboration * -* * -* This software is distributed under the terms of the GNU General Public * -* Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". * -* * -* In applying this licence, CERN does not waive the privileges and immunities * -* granted to it by virtue of its status as an Intergovernmental Organization * -* or submit itself to any jurisdiction. * -\*****************************************************************************/ -#ifndef JBOREL_TUPLETOOLCPU_H -#define JBOREL_TUPLETOOLCPU_H 1 - -// Include files -// from Gaudi -#include "DecayTreeTupleBase/TupleToolBase.h" -#include "Kernel/IEventTupleTool.h" // Interface - -class ITupleTool; -class ISequencerTimerTool; - -/** @class TupleToolCPU TupleToolCPU.h jborel/TupleToolCPU.h - * - * \brief Event and Run number for DecayTreeTuple - * - * Tuple columns: - * - CPU of event - * - Memory used - - * \sa DecayTreeTuple - * @author Patrick Koppenburg - * @date 2010-08-19 - */ -class TupleToolCPU : public TupleToolBase, virtual public IEventTupleTool { -public: - /// Standard constructor - TupleToolCPU( const std::string& type, const std::string& name, const IInterface* parent ); - - ~TupleToolCPU(){}; ///< Destructor - - StatusCode fill( Tuples::Tuple& ) override; - StatusCode initialize() override; - -private: - ISequencerTimerTool* m_timerTool; ///< timer tool - int m_timer; ///< timer index -}; -#endif // JBOREL_TUPLETOOLCPU_H diff --git a/Phys/DecayTreeTupleReco/src/TupleToolPrimaries.cpp b/Phys/DecayTreeTupleReco/src/TupleToolPrimaries.cpp deleted file mode 100644 index de05ef8ce299081219451ba7297dbeec086bfac6..0000000000000000000000000000000000000000 --- a/Phys/DecayTreeTupleReco/src/TupleToolPrimaries.cpp +++ /dev/null @@ -1,123 +0,0 @@ -/*****************************************************************************\ -* (c) Copyright 2000-2018 CERN for the benefit of the LHCb Collaboration * -* * -* This software is distributed under the terms of the GNU General Public * -* Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". * -* * -* In applying this licence, CERN does not waive the privileges and immunities * -* granted to it by virtue of its status as an Intergovernmental Organization * -* or submit itself to any jurisdiction. * -\*****************************************************************************/ -#include "TupleToolPrimaries.h" - -#include "Event/Track.h" -#include "Event/VertexBase.h" -#include "GaudiAlg/Tuple.h" -#include "GaudiAlg/TupleObj.h" - -using namespace LHCb; - -//----------------------------------------------------------------------------- -// Implementation file for class : TupleToolPrimaries -// -// 2007-11-07 : Jeremie Borel -//----------------------------------------------------------------------------- - -// Declaration of the Tool Factory -// actually acts as a using namespace TupleTool -DECLARE_COMPONENT( TupleToolPrimaries ) - -//============================================================================= -// Standard constructor, initializes variables -//============================================================================= -TupleToolPrimaries::TupleToolPrimaries( const std::string& type, const std::string& name, const IInterface* parent ) - : TupleToolBase( type, name, parent ) { - declareInterface( this ); - declareProperty( "InputLocation", m_pvLocation = LHCb::RecVertexLocation::Primary, "PV location to be used." ); -} - -//============================================================================= -//============================================================================= - -StatusCode TupleToolPrimaries::initialize() { - const StatusCode sc = TupleToolBase::initialize(); - if ( sc.isFailure() ) return sc; - - debug() << "Will be looking for PVs at " << m_pvLocation << endmsg; - - return sc; -} - -//============================================================================= -//============================================================================= - -StatusCode TupleToolPrimaries::fill( Tuples::Tuple& tuple ) { - const std::string prefix = fullName(); - - if ( msgLevel( MSG::VERBOSE ) ) verbose() << "Storing PVs with prefix ``" << prefix << "''" << endmsg; - - std::vector pvx, pvy, pvz; - std::vector epvx, epvy, epvz; - std::vector pvchi2, pvndof, pvntracks, pvsumpt; - - const RecVertex::Container* PV = getIfExists( m_pvLocation ); - if ( PV ) { - - if ( PV->size() > m_maxPV ) { - Warning( "Too many primaries, no PVs will be stored." ).ignore(); - } else { - for ( RecVertex::Container::const_iterator i = PV->begin(); PV->end() != i; ++i ) { - if ( msgLevel( MSG::VERBOSE ) ) verbose() << "PV: " << ( *i )->position() << endmsg; - pvx.push_back( ( *i )->position().X() ); - pvy.push_back( ( *i )->position().Y() ); - pvz.push_back( ( *i )->position().Z() ); - if ( msgLevel( MSG::VERBOSE ) ) - verbose() << "PV matrix: " << ( *i )->covMatrix()( 0, 0 ) << " " << ( *i )->covMatrix()( 1, 1 ) << " " - << ( *i )->covMatrix()( 2, 2 ) << endmsg; - epvx.push_back( std::sqrt( ( *i )->covMatrix()( 0, 0 ) ) ); - epvy.push_back( std::sqrt( ( *i )->covMatrix()( 1, 1 ) ) ); - epvz.push_back( std::sqrt( ( *i )->covMatrix()( 2, 2 ) ) ); - pvchi2.push_back( ( *i )->chi2() ); - pvndof.push_back( (double)( *i )->nDoF() ); - pvntracks.push_back( (double)( *i )->tracks().size() ); - if ( isVerbose() ) pvsumpt.push_back( sumPT( *i ) ); - if ( msgLevel( MSG::VERBOSE ) ) verbose() << "Tracks: " << ( *i )->tracks().size() << endmsg; - } - } - if ( msgLevel( MSG::DEBUG ) ) debug() << "There are " << PV->size() << " PVs at " << pvz << endmsg; - } else if ( msgLevel( MSG::DEBUG ) ) { - debug() << "PV container is empty" << endmsg; - } - - bool test = true; - test &= tuple->farray( prefix + "PVX", pvx, prefix + "nPV", m_maxPV ); - test &= tuple->farray( prefix + "PVY", pvy, prefix + "nPV", m_maxPV ); - test &= tuple->farray( prefix + "PVZ", pvz, prefix + "nPV", m_maxPV ); - test &= tuple->farray( prefix + "PVXERR", epvx, prefix + "nPV", m_maxPV ); - test &= tuple->farray( prefix + "PVYERR", epvy, prefix + "nPV", m_maxPV ); - test &= tuple->farray( prefix + "PVZERR", epvz, prefix + "nPV", m_maxPV ); - - test &= tuple->farray( prefix + "PVCHI2", pvchi2, prefix + "nPV", m_maxPV ); - test &= tuple->farray( prefix + "PVNDOF", pvndof, prefix + "nPV", m_maxPV ); - test &= tuple->farray( prefix + "PVNTRACKS", pvntracks, prefix + "nPV", m_maxPV ); - if ( isVerbose() ) test &= tuple->farray( prefix + "PVsumPT", pvsumpt, prefix + "nPV", m_maxPV ); - - return StatusCode( test ); - // return StatusCode::SUCCESS; -} -//============================================================================= -// Sum PT -//============================================================================= -double TupleToolPrimaries::sumPT( const LHCb::RecVertex* pv ) const { - if ( !pv ) Exception( "Not a RecVertex?" ); - double spt = 0; - for ( SmartRefVector::const_iterator t = pv->tracks().begin(); t != pv->tracks().end(); ++t ) { - if ( 0 == *t ) { - Warning( "Cannot resolve pointer to Track. Probably a microDST. Set Verbose to false.", StatusCode::FAILURE, 10 ) - .ignore( /* AUTOMATICALLY ADDED FOR gaudi/Gaudi!763 */ ); - return -1; - } - spt += ( *t )->pt(); - } - return spt; -} diff --git a/Phys/DecayTreeTupleReco/src/TupleToolPrimaries.h b/Phys/DecayTreeTupleReco/src/TupleToolPrimaries.h deleted file mode 100755 index c1d40b6f2b2c0423d07409c76a8400c654350e6a..0000000000000000000000000000000000000000 --- a/Phys/DecayTreeTupleReco/src/TupleToolPrimaries.h +++ /dev/null @@ -1,52 +0,0 @@ -/*****************************************************************************\ -* (c) Copyright 2000-2018 CERN for the benefit of the LHCb Collaboration * -* * -* This software is distributed under the terms of the GNU General Public * -* Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". * -* * -* In applying this licence, CERN does not waive the privileges and immunities * -* granted to it by virtue of its status as an Intergovernmental Organization * -* or submit itself to any jurisdiction. * -\*****************************************************************************/ -#ifndef JBOREL_TUPLETOOLPRIMARIES_H -#define JBOREL_TUPLETOOLPRIMARIES_H 1 - -// Include files -// from Gaudi -#include "DecayTreeTupleBase/TupleToolBase.h" -#include "Event/RecVertex.h" -#include "Kernel/IEventTupleTool.h" // Interface - -class DVAlgorithm; - -/** @class TupleToolPrimaries TupleToolPrimaries.h jborel/TupleToolPrimaries.h - * - * \brief Primary vertices properties for DecayTreeTuple - * - * Tuple columns: - * - coordinates PVX, PVY, PVZ - * - errors PVXERR, PVYERR, PVZERR - * - vertex chi2 PVCHI - * - vertex ndf PVNDOF - * - Nb of tracks used to do the vertex PVNTRACKS - * - * \sa DecayTr