diff --git a/addons/FastJet/JetClustering.h b/addons/FastJet/JetClustering.h index 36cd1ef54a9..6a7de3babbd 100644 --- a/addons/FastJet/JetClustering.h +++ b/addons/FastJet/JetClustering.h @@ -8,8 +8,11 @@ #include "fastjet/ClusterSequence.hh" #include "fastjet/ClusterSequenceArea.hh" #include "fastjet/JetDefinition.hh" +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-copy" #include "fastjet/EECambridgePlugin.hh" #include "fastjet/JadePlugin.hh" +#pragma GCC diagnostic pop #include "FastJet/ValenciaPlugin.h" diff --git a/addons/FastJet/ValenciaPlugin.h b/addons/FastJet/ValenciaPlugin.h index 4d3a1be476d..e0727ebd105 100644 --- a/addons/FastJet/ValenciaPlugin.h +++ b/addons/FastJet/ValenciaPlugin.h @@ -55,6 +55,7 @@ FASTJET_BEGIN_NAMESPACE // defined in fastjet/internal/base.hh /// copy constructor ValenciaPlugin(const ValenciaPlugin &plugin) { *this = plugin; } + ValenciaPlugin &operator=(const ValenciaPlugin &) = default; // the things that are required by base class virtual std::string description() const; diff --git a/addons/FastJet/src/JetClustering.cc b/addons/FastJet/src/JetClustering.cc index e2e5ed87658..c5a3abc7219 100644 --- a/addons/FastJet/src/JetClustering.cc +++ b/addons/FastJet/src/JetClustering.cc @@ -23,8 +23,7 @@ namespace JetClustering { // initialize recombination scheme _recombScheme = FCCAnalyses::JetClusteringUtils::recomb_scheme(_recombination); - //define the clustering sequence and jet definition - fastjet::ClusterSequence _cs; + // define the clustering sequence and jet definition _def = fastjet::JetDefinition(_jetAlgorithm, _radius, _recombScheme); if (_recombScheme == fastjet::RecombinationScheme::external_scheme) _def.set_recombiner(new ExternalRecombiner(_recombination)); @@ -64,8 +63,7 @@ namespace JetClustering { // initialize recombination scheme _recombScheme = FCCAnalyses::JetClusteringUtils::recomb_scheme(_recombination); - //define the clustering sequence and jet definition - fastjet::ClusterSequence _cs; + // define the clustering sequence and jet definition _def = fastjet::JetDefinition(_jetAlgorithm, _radius, _recombScheme); if (_recombScheme == fastjet::RecombinationScheme::external_scheme) _def.set_recombiner(new ExternalRecombiner(_recombination)); @@ -104,8 +102,7 @@ namespace JetClustering { // initialize recombination scheme _recombScheme = FCCAnalyses::JetClusteringUtils::recomb_scheme(_recombination); - //define the clustering sequence and jet definition - fastjet::ClusterSequence _cs; + // define the clustering sequence and jet definition _def = fastjet::JetDefinition(_jetAlgorithm, _radius, _recombScheme); if (_recombScheme == fastjet::RecombinationScheme::external_scheme) _def.set_recombiner(new ExternalRecombiner(_recombination)); @@ -140,8 +137,7 @@ namespace JetClustering { // initialize recombination scheme _recombScheme = FCCAnalyses::JetClusteringUtils::recomb_scheme(_recombination); - //define the clustering sequence and jet definition - fastjet::ClusterSequence _cs; + // define the clustering sequence and jet definition _def = fastjet::JetDefinition(_jetAlgorithm, _recombScheme); if (_recombScheme == fastjet::RecombinationScheme::external_scheme) _def.set_recombiner(new ExternalRecombiner(_recombination)); @@ -179,8 +175,7 @@ namespace JetClustering { // initialize recombination scheme _recombScheme = FCCAnalyses::JetClusteringUtils::recomb_scheme(_recombination); - //define the clustering sequence and jet definition - fastjet::ClusterSequence _cs; + // define the clustering sequence and jet definition _def = fastjet::JetDefinition(_jetAlgorithm, _radius, _exponent, _recombScheme); if (_recombScheme == fastjet::RecombinationScheme::external_scheme) _def.set_recombiner(new ExternalRecombiner(_recombination)); @@ -218,8 +213,7 @@ namespace JetClustering { // initialize recombination scheme _recombScheme = FCCAnalyses::JetClusteringUtils::recomb_scheme(_recombination); - //define the clustering sequence and jet definition - fastjet::ClusterSequence _cs; + // define the clustering sequence and jet definition _def = fastjet::JetDefinition(_jetAlgorithm, _radius, _exponent, _recombScheme); if (_recombScheme == fastjet::RecombinationScheme::external_scheme) _def.set_recombiner(new ExternalRecombiner(_recombination)); @@ -263,8 +257,7 @@ namespace JetClustering { // initialize recombination scheme _recombScheme = FCCAnalyses::JetClusteringUtils::recomb_scheme(_recombination); - //define the clustering sequence and jet definition - fastjet::ClusterSequence _cs; + // define the clustering sequence and jet definition _def = fastjet::JetDefinition(_jetAlgorithm); _def.set_recombination_scheme(_recombScheme); if (_recombScheme == fastjet::RecombinationScheme::external_scheme) @@ -300,12 +293,12 @@ namespace JetClustering { _jetAlgorithm = new fastjet::JadePlugin(); // initialize recombination scheme - fastjet::RecombinationScheme _recombScheme = FCCAnalyses::JetClusteringUtils::recomb_scheme(_recombination); + fastjet::RecombinationScheme recombScheme = + FCCAnalyses::JetClusteringUtils::recomb_scheme(_recombination); - fastjet::ClusterSequence _cs; _def = fastjet::JetDefinition(_jetAlgorithm); - _def.set_recombination_scheme(_recombScheme); - if (_recombScheme == fastjet::RecombinationScheme::external_scheme) + _def.set_recombination_scheme(recombScheme); + if (recombScheme == fastjet::RecombinationScheme::external_scheme) _def.set_recombiner(new ExternalRecombiner(_recombination)); } diff --git a/addons/ONNXRuntime/WeaverInterface.h b/addons/ONNXRuntime/WeaverInterface.h index 6c31ba478a7..bd932c1879a 100644 --- a/addons/ONNXRuntime/WeaverInterface.h +++ b/addons/ONNXRuntime/WeaverInterface.h @@ -47,7 +47,9 @@ class WeaverInterface { size_t min_length{0}, max_length{0}; std::vector var_names; std::unordered_map var_info_map; - VarInfo info(const std::string& name) const { return var_info_map.at(name); } + VarInfo info(const std::string &variableName) const { + return var_info_map.at(variableName); + } void dumpVars() const; }; std::vector center_norm_pad(const rv::RVec& input, diff --git a/addons/ONNXRuntime/src/ONNXRuntime.cc b/addons/ONNXRuntime/src/ONNXRuntime.cc index c021a46c8ed..bdc590b91aa 100644 --- a/addons/ONNXRuntime/src/ONNXRuntime.cc +++ b/addons/ONNXRuntime/src/ONNXRuntime.cc @@ -71,7 +71,7 @@ ONNXRuntime::Tensor ONNXRuntime::run(Tensor& input, } else { input_dims = input_shapes[input_pos]; // rely on the given input_shapes to set the batch size - if (input_dims[0] != batch_size) + if (static_cast(input_dims[0]) != batch_size) throw std::runtime_error("The first element of `input_shapes` (" + std::to_string(input_dims[0]) + ") does not match the given `batch_size` (" + std::to_string(batch_size) + ")"); } diff --git a/addons/TMVAHelper/src/TMVAHelper.cc b/addons/TMVAHelper/src/TMVAHelper.cc index 87617512c63..5448c5651b1 100644 --- a/addons/TMVAHelper/src/TMVAHelper.cc +++ b/addons/TMVAHelper/src/TMVAHelper.cc @@ -1,5 +1,7 @@ #include "TMVAHelper/TMVAHelper.h" +#include + #include "RVersion.h" tmva_helper_xgb::tmva_helper_xgb(const std::string &filename, @@ -20,8 +22,8 @@ tmva_helper_xgb::tmva_helper_xgb(const std::string &filename, ROOT::VecOps::RVec tmva_helper_xgb::operator()(const ROOT::VecOps::RVec vars) { - auto const tbb_slot = - std::max(tbb::this_task_arena::current_thread_index(), 0); + const auto tbb_slot = static_cast( + std::max(tbb::this_task_arena::current_thread_index(), 0)); if (tbb_slot >= m_interpreters.size()) { throw std::runtime_error( "Not enough interpreters allocated for number of tbb threads"); diff --git a/analyzers/dataframe/FCCAnalyses/myUtils.h b/analyzers/dataframe/FCCAnalyses/myUtils.h index 2b8f3a6ded2..b9b55a6c9ff 100644 --- a/analyzers/dataframe/FCCAnalyses/myUtils.h +++ b/analyzers/dataframe/FCCAnalyses/myUtils.h @@ -49,10 +49,9 @@ namespace myUtils{ ROOT::VecOps::RVec pvindex); }; - - - struct build_tau23pi { - build_tau23pi( float arg_masslow, float arg_masshigh, float arg_p, float arg_angle, bool arg_rho); + struct sel_tau23pi { + sel_tau23pi(float arg_masslow, float arg_masshigh, float arg_p, + float arg_angle, bool arg_rho); float m_masslow=0.05; float m_masshigh=3.0; float m_p=1.; @@ -62,8 +61,6 @@ namespace myUtils{ ROOT::VecOps::RVec recop); }; - - struct sel_PV { sel_PV(bool arg_closest); bool m_closest; diff --git a/analyzers/dataframe/src/Algorithms.cc b/analyzers/dataframe/src/Algorithms.cc index 9d8f6ceda84..9ea83e4a05b 100644 --- a/analyzers/dataframe/src/Algorithms.cc +++ b/analyzers/dataframe/src/Algorithms.cc @@ -1,13 +1,16 @@ #include "FCCAnalyses/Algorithms.h" #include "FCCAnalyses/Utils.h" +#include -#include "Math/Minimizer.h" -#include "Math/IFunction.h" #include "Math/Factory.h" #include "Math/Functor.h" +#include "Math/IFunction.h" +#include "Math/Minimizer.h" #include +#include #include #include +#include #include "Math/IFunction.h" #include "Math/Factory.h" @@ -197,13 +200,14 @@ ROOT::VecOps::RVec Algorithms::calculate_thrust::operator()( // Array to store x, y, z and magnitude squared of the particles. // 0 -- magnitude squared, 1 -- x, 2 -- y, 3 -- z - float pArr[nParticles][4]; + std::vector> pArr(nParticles); float pSum = 0.; for (size_t i = 0; i < nParticles; ++i) { pArr[i][1] = px[i]; pArr[i][2] = py[i]; pArr[i][3] = pz[i]; - mag2(pArr[i]); + pArr[i][0] = pArr[i][1] * pArr[i][1] + pArr[i][2] * pArr[i][2] + + pArr[i][3] * pArr[i][3]; pSum += std::sqrt(pArr[i][0]); } @@ -214,7 +218,7 @@ ROOT::VecOps::RVec Algorithms::calculate_thrust::operator()( for (size_t i = 0; i < nParticles - 1; ++i) { for (size_t j = i + 1; j < nParticles; ++j) { float nRef[4]; - cross(nRef, pArr[i], pArr[j]); + cross(nRef, pArr[i].data(), pArr[j].data()); mag2(nRef); unit(nRef); @@ -224,29 +228,29 @@ ROOT::VecOps::RVec Algorithms::calculate_thrust::operator()( continue; } - if (dot(nRef, pArr[k]) > 0.) { - plus(pPart, pPart, pArr[k]); + if (dot(nRef, pArr[k].data()) > 0.) { + plus(pPart, pPart, pArr[k].data()); } else { - minus(pPart, pPart, pArr[k]); + minus(pPart, pPart, pArr[k].data()); } } float pFullArr[4][4]; // pPart + pArr[i] + pArr[j] - plus(pFullArr[0], pPart, pArr[i]); - plus(pFullArr[0], pFullArr[0], pArr[j]); + plus(pFullArr[0], pPart, pArr[i].data()); + plus(pFullArr[0], pFullArr[0], pArr[j].data()); // pPart + pArr[i] - pArr[j] - plus(pFullArr[1], pPart, pArr[i]); - minus(pFullArr[1], pFullArr[1], pArr[j]); + plus(pFullArr[1], pPart, pArr[i].data()); + minus(pFullArr[1], pFullArr[1], pArr[j].data()); // pPart - pArr[i] + pArr[j] - minus(pFullArr[2], pPart, pArr[i]); - plus(pFullArr[2], pFullArr[2], pArr[j]); + minus(pFullArr[2], pPart, pArr[i].data()); + plus(pFullArr[2], pFullArr[2], pArr[j].data()); // pPart - pArr[i] - pArr[j] - minus(pFullArr[3], pPart, pArr[i]); - minus(pFullArr[3], pFullArr[3], pArr[j]); + minus(pFullArr[3], pPart, pArr[i].data()); + minus(pFullArr[3], pFullArr[3], pArr[j].data()); for (size_t k = 0; k < 4; ++k) { mag2(pFullArr[k]); @@ -487,24 +491,22 @@ JetClustering::FCCAnalysesJet jets_TwoHemispheres::operator() ( float pz_minus=0; float e_minus=0; - for ( int i=0; i < RP_costheta.size(); i++) { - if ( RP_costheta[i] > 0 ) { - constituents_JetPlus.push_back( i ); - px_plus += RP_px[i]; - py_plus += RP_py[i]; - pz_plus += RP_pz[i]; - e_plus += RP_e[i]; - } - else { - constituents_JetMimus.push_back( i ); - px_minus += RP_px[i]; - py_minus += RP_py[i]; - pz_minus += RP_pz[i]; - e_minus += RP_e[i]; - } + for (std::size_t i = 0; i < RP_costheta.size(); i++) { + if (RP_costheta[i] > 0) { + constituents_JetPlus.push_back(i); + px_plus += RP_px[i]; + py_plus += RP_py[i]; + pz_plus += RP_pz[i]; + e_plus += RP_e[i]; + } else { + constituents_JetMimus.push_back(i); + px_minus += RP_px[i]; + py_minus += RP_py[i]; + pz_minus += RP_pz[i]; + e_minus += RP_e[i]; + } } - float pt_plus = sqrt( pow( px_plus,2) + pow( py_plus,2) + pow( pz_plus, 2) ) ; float pt_minus = sqrt( pow( px_minus, 2) + pow( py_minus, 2) + pow( pz_minus, 2) ) ; diff --git a/analyzers/dataframe/src/Analysis_FCChh.cc b/analyzers/dataframe/src/Analysis_FCChh.cc index 8033813f673..524d4c38297 100644 --- a/analyzers/dataframe/src/Analysis_FCChh.cc +++ b/analyzers/dataframe/src/Analysis_FCChh.cc @@ -1,4 +1,5 @@ #include "FCCAnalyses/Analysis_FCChh.h" +#include // #include "FCCAnalyses/lester_mt2_bisect.h" #include @@ -191,7 +192,7 @@ bool AnalysisFCChh::isFromHadron( // loop over all parents (usually onle 1, but sometimes more for reasons not // understood?): - for (int parent_i = first_parent_index; parent_i < last_parent_index; + for (unsigned int parent_i = first_parent_index; parent_i < last_parent_index; parent_i++) { // first get the index from the parent auto parent_MC_index = parent_ids.at(parent_i).index; @@ -219,7 +220,7 @@ bool AnalysisFCChh::hasHiggsParent( // loop over all parents (usually onle 1, but sometimes more for reasons not // understood?): - for (int parent_i = first_parent_index; parent_i < last_parent_index; + for (unsigned int parent_i = first_parent_index; parent_i < last_parent_index; parent_i++) { // first get the index from the parent auto parent_MC_index = parent_ids.at(parent_i).index; @@ -249,7 +250,7 @@ bool AnalysisFCChh::isFromHiggsDirect( // loop over all parents (usually only 1, but sometimes more for reasons not // understood?): - for (int parent_i = first_parent_index; parent_i < last_parent_index; + for (unsigned int parent_i = first_parent_index; parent_i < last_parent_index; parent_i++) { // first get the index from the parent auto parent_MC_index = parent_ids.at(parent_i).index; @@ -278,7 +279,7 @@ bool AnalysisFCChh::isChildOfTauFromHiggs( // loop over all parents (usually onle 1, but sometimes more for reasons not // understood?): - for (int parent_i = first_parent_index; parent_i < last_parent_index; + for (unsigned int parent_i = first_parent_index; parent_i < last_parent_index; parent_i++) { // first get the index from the parent auto parent_MC_index = parent_ids.at(parent_i).index; @@ -311,7 +312,7 @@ bool AnalysisFCChh::isChildOfZFromHiggs( // loop over all parents (usually onle 1, but sometimes more for reasons not // understood?): - for (int parent_i = first_parent_index; parent_i < last_parent_index; + for (unsigned int parent_i = first_parent_index; parent_i < last_parent_index; parent_i++) { // first get the index from the parent auto parent_MC_index = parent_ids.at(parent_i).index; @@ -344,7 +345,7 @@ bool AnalysisFCChh::isChildOfWFromHiggs( // loop over all parents (usually only 1, but sometimes more for reasons not // understood?): - for (int parent_i = first_parent_index; parent_i < last_parent_index; + for (unsigned int parent_i = first_parent_index; parent_i < last_parent_index; parent_i++) { // first get the index from the parent auto parent_MC_index = parent_ids.at(parent_i).index; @@ -487,8 +488,6 @@ int AnalysisFCChh::findTopDecayChannel( auto first_child_index = truth_part.daughters_begin; auto last_child_index = truth_part.daughters_end; - auto children_size = last_child_index - first_child_index; - // skip intermediate tops that just have another top as children if (last_child_index - first_child_index != 2) { continue; @@ -561,8 +560,6 @@ int AnalysisFCChh::findHiggsDecayChannel( auto first_child_index = truth_part.daughters_begin; auto last_child_index = truth_part.daughters_end; - auto children_size = last_child_index - first_child_index; - // skip intermediate tops that just have another Higgs as children if (last_child_index - first_child_index != 2) { continue; @@ -860,7 +857,7 @@ AnalysisFCChh::getJet_tag(ROOT::VecOps::RVec index, // return the list of c hadrons ROOT::VecOps::RVec AnalysisFCChh::getChadron( ROOT::VecOps::RVec truth_particles, - ROOT::VecOps::RVec parent_ids) { + ROOT::VecOps::RVec) { ROOT::VecOps::RVec c_had_list; for (auto &truth_part : truth_particles) { @@ -875,7 +872,7 @@ ROOT::VecOps::RVec AnalysisFCChh::getChadron( // return the list of b hadrons ROOT::VecOps::RVec AnalysisFCChh::getBhadron( ROOT::VecOps::RVec truth_particles, - ROOT::VecOps::RVec parent_ids) { + ROOT::VecOps::RVec) { ROOT::VecOps::RVec b_had_list; for (auto &truth_part : truth_particles) { @@ -2255,7 +2252,7 @@ AnalysisFCChh::get_immediate_children( // std::cout << "children size: " << children_size << std::endl; - for (int child_i = 0; child_i < children_size; child_i++) { + for (unsigned int child_i = 0; child_i < children_size; child_i++) { auto child_i_index = daughter_ids.at(first_child_index + child_i).index; auto child = truth_particles.at(child_i_index); // std::cout << "PDG ID of child number " << child_i << " : " << child.PDG @@ -2481,12 +2478,11 @@ ROOT::VecOps::RVec AnalysisFCChh::getLepsFromTau( ROOT::VecOps::RVec AnalysisFCChh::getTruthTau( ROOT::VecOps::RVec truth_particles, - ROOT::VecOps::RVec daughter_ids, + ROOT::VecOps::RVec, ROOT::VecOps::RVec parent_ids, TString type) { ROOT::VecOps::RVec tau_list; for (auto &truth_part : truth_particles) { - bool flagchildren = false; if (isTau(truth_part)) { // check also if from Higgs to count only from Higgs ones @@ -2505,8 +2501,8 @@ ROOT::VecOps::RVec AnalysisFCChh::getTruthTau( std::cout << " found tau neither from Higgs or from Had" << std::endl; auto first_parent_index = truth_part.parents_begin; auto last_parent_index = truth_part.parents_end; - for (int parent_i = first_parent_index; parent_i < last_parent_index; - parent_i++) { + for (unsigned int parent_i = first_parent_index; + parent_i < last_parent_index; parent_i++) { auto parent_MC_index = parent_ids.at(parent_i).index; auto parent = truth_particles.at(parent_MC_index); std::cout << "Parent PDG:" << std::endl; @@ -2550,8 +2546,8 @@ ROOT::VecOps::RVec AnalysisFCChh::getTruthTauLeps( std::cout << " found tau neither from Higgs or from Had" << std::endl; auto first_parent_index = truth_part.parents_begin; auto last_parent_index = truth_part.parents_end; - for (int parent_i = first_parent_index; parent_i < last_parent_index; - parent_i++) { + for (unsigned int parent_i = first_parent_index; + parent_i < last_parent_index; parent_i++) { auto parent_MC_index = parent_ids.at(parent_i).index; auto parent = truth_particles.at(parent_MC_index); std::cout << "Parent PDG:" << std::endl; @@ -2565,8 +2561,8 @@ ROOT::VecOps::RVec AnalysisFCChh::getTruthTauLeps( auto last_child_index = truth_part.daughters_end; // auto child_1_MC_index = daughter_ids.at(first_child_index).index; // auto hild_2_MC_index = daughter_ids.at(last_child_index-1).index; - for (int child_i = first_child_index; child_i < last_child_index; - child_i++) { + for (unsigned int child_i = first_child_index; + child_i < last_child_index; child_i++) { auto child = truth_particles.at(daughter_ids.at(child_i).index); if (abs(child.PDG) == 15) { isItself = true; @@ -2581,7 +2577,8 @@ ROOT::VecOps::RVec AnalysisFCChh::getTruthTauLeps( // std::cout << " found tau with children" << std::endl; auto first_child_index = truth_part.daughters_begin; auto last_child_index = truth_part.daughters_end; - for (int ch_i = first_child_index; ch_i < last_child_index; ch_i++) { + for (unsigned int ch_i = first_child_index; ch_i < last_child_index; + ch_i++) { auto ch = truth_particles.at(daughter_ids.at(ch_i).index); std::cout << "Child ID: " << ch.PDG << std::endl; if (isLep(ch)) { @@ -2627,8 +2624,8 @@ ROOT::VecOps::RVec AnalysisFCChh::getTruthTauHads( std::cout << " found tau neither from Higgs or from Had" << std::endl; auto first_parent_index = truth_part.parents_begin; auto last_parent_index = truth_part.parents_end; - for (int parent_i = first_parent_index; parent_i < last_parent_index; - parent_i++) { + for (unsigned int parent_i = first_parent_index; + parent_i < last_parent_index; parent_i++) { auto parent_MC_index = parent_ids.at(parent_i).index; auto parent = truth_particles.at(parent_MC_index); std::cout << "Parent PDG:" << std::endl; @@ -2642,8 +2639,8 @@ ROOT::VecOps::RVec AnalysisFCChh::getTruthTauHads( auto last_child_index = truth_part.daughters_end; // auto child_1_MC_index = daughter_ids.at(first_child_index).index; // auto hild_2_MC_index = daughter_ids.at(last_child_index-1).index; - for (int child_i = first_child_index; child_i < last_child_index; - child_i++) { + for (unsigned int child_i = first_child_index; + child_i < last_child_index; child_i++) { auto child = truth_particles.at(daughter_ids.at(child_i).index); if (abs(child.PDG) == 15) { isItself = true; @@ -2658,7 +2655,8 @@ ROOT::VecOps::RVec AnalysisFCChh::getTruthTauHads( // std::cout << " found tau with children" << std::endl; auto first_child_index = truth_part.daughters_begin; auto last_child_index = truth_part.daughters_end; - for (int ch_i = first_child_index; ch_i < last_child_index; ch_i++) { + for (unsigned int ch_i = first_child_index; ch_i < last_child_index; + ch_i++) { auto ch = truth_particles.at(daughter_ids.at(ch_i).index); std::cout << "Child ID: " << ch.PDG << std::endl; if (isHadron(ch)) { @@ -2905,7 +2903,7 @@ AnalysisFCChh::find_reco_matched( ROOT::VecOps::RVec AnalysisFCChh::get_IP_delphes( ROOT::VecOps::RVec test_parts, ROOT::VecOps::RVec reco_parts_all, - float dR_min, float pT_min, bool exclude_light_leps) { + float dR_min, float pT_min, bool) { ROOT::VecOps::RVec out_vector; @@ -3178,7 +3176,7 @@ ROOT::VecOps::RVec AnalysisFCChh::find_reco_matched_index( TLorentzVector truth_part_tlv = getTLV_MC(truth_part_to_match); - for (int i = 0; i < check_reco_parts.size(); ++i) { + for (std::size_t i = 0; i < check_reco_parts.size(); ++i) { edm4hep::ReconstructedParticleData check_reco_part = check_reco_parts[i]; @@ -3322,7 +3320,6 @@ AnalysisFCChh::find_reco_matches_exclusive( } for (auto &truth_part : truth_parts) { - bool excludedMatch = false; ROOT::VecOps::RVec reco_match_vector = find_reco_matched_particle(truth_part, reco_particles, dR_thres); ROOT::VecOps::RVec mc_excluded_vector = diff --git a/analyzers/dataframe/src/EventFilter.cc b/analyzers/dataframe/src/EventFilter.cc index a3206fb7f08..043fdb1e008 100644 --- a/analyzers/dataframe/src/EventFilter.cc +++ b/analyzers/dataframe/src/EventFilter.cc @@ -4,7 +4,7 @@ namespace FCCAnalyses ::EventFilter { // ---------------------------------------------------------------------------- -stride::stride(const ULong64_t stride) : m_stride(stride) {} +stride::stride(const ULong64_t value) : m_stride(value) {} bool stride::operator()(const ULong64_t rdfEntry) { diff --git a/analyzers/dataframe/src/JetClusteringUtils.cc b/analyzers/dataframe/src/JetClusteringUtils.cc index 3a5c81f5f40..79501ff8580 100644 --- a/analyzers/dataframe/src/JetClusteringUtils.cc +++ b/analyzers/dataframe/src/JetClusteringUtils.cc @@ -1,6 +1,8 @@ #include "FCCAnalyses/JetClusteringUtils.h" #include "TLorentzVector.h" +#include + namespace FCCAnalyses { namespace JetClusteringUtils { @@ -16,14 +18,16 @@ get_constituents(const JetClustering::FCCAnalysesJet &jets) { float get_exclusive_dmerge(const JetClustering::FCCAnalysesJet &in, int n) { float d = -1; - if (n >= 1 && n <= Nmax_dmerge && in.exclusive_dmerge.size() > n - 1) + if (n >= 1 && n <= Nmax_dmerge && + static_cast(n) <= in.exclusive_dmerge.size()) d = in.exclusive_dmerge[n - 1]; return d; } float get_exclusive_dmerge_max(const JetClustering::FCCAnalysesJet &in, int n) { float d = -1; - if (n >= 1 && n <= Nmax_dmerge && in.exclusive_dmerge.size() > n - 1) + if (n >= 1 && n <= Nmax_dmerge && + static_cast(n) <= in.exclusive_dmerge_max.size()) d = in.exclusive_dmerge_max[n - 1]; return d; } @@ -258,7 +262,7 @@ std::vector exclusive_dmerge(fastjet::ClusterSequence &cs, } bool check(unsigned int n, int exclusive, float cut) { - if (exclusive > 0 && n < int(cut)) + if (exclusive > 0 && cut > 0 && n < static_cast(cut)) return false; return true; } diff --git a/analyzers/dataframe/src/JetConstituentsUtils.cc b/analyzers/dataframe/src/JetConstituentsUtils.cc index 89a99942b8e..72341abff75 100644 --- a/analyzers/dataframe/src/JetConstituentsUtils.cc +++ b/analyzers/dataframe/src/JetConstituentsUtils.cc @@ -1,5 +1,6 @@ #include "FCCAnalyses/JetConstituentsUtils.h" +#include // EDM4hep #include "edm4hep/EDM4hepVersion.h" // FastJet @@ -31,12 +32,9 @@ namespace FCCAnalyses for (const auto &jet : jets) { auto &jc = jcs.emplace_back(); - float energy_jet = jet.energy; - float energy_const = 0; for (auto it = jet.particles_begin; it < jet.particles_end; ++it) { jc.emplace_back(rps.at(it)); - energy_const += rps.at(it).energy; } } return jcs; @@ -168,8 +166,7 @@ namespace FCCAnalyses nconst.push_back(jet.particles_end - jet.particles_begin); } auto indices = ROOT::VecOps::Argsort(nconst); - for (int index = 0; index < jets.size(); ++index) - { + for (std::size_t index = 0; index < jets.size(); ++index) { out.push_back(jets.at(indices.at(indices.size() - 1 - index))); } return out; @@ -184,8 +181,7 @@ namespace FCCAnalyses energy.push_back(jet.energy); } auto indices = ROOT::VecOps::Argsort(energy); - for (int index = 0; index < jets.size(); ++index) - { + for (std::size_t index = 0; index < jets.size(); ++index) { out.push_back(jets.at(indices.at(indices.size() - 1 - index))); } return out; @@ -402,12 +398,10 @@ namespace FCCAnalyses rv::RVec D0 = cast_constituent_2(jcs, tracks, ReconstructedParticle2Track::getRP2TRK_D0); rv::RVec phi0 = cast_constituent_2(jcs, tracks, ReconstructedParticle2Track::getRP2TRK_phi); - for (int i = 0; i < jets.size(); ++i) - { + for (std::size_t i = 0; i < jets.size(); ++i) { TVector2 p(jets[i].momentum.x, jets[i].momentum.y); FCCAnalysesJetConstituentsData cprojs; - for (int j = 0; j < jcs[i].size(); ++j) - { + for (std::size_t j = 0; j < jcs[i].size(); ++j) { if (D0.at(i).at(j) != -9) { TVector2 d0(-D0.at(i).at(j) * TMath::Sin(phi0.at(i).at(j)), D0.at(i).at(j) * TMath::Cos(phi0.at(i).at(j))); @@ -431,12 +425,10 @@ namespace FCCAnalyses rv::RVec D0 = cast_constituent_2(jcs, tracks, ReconstructedParticle2Track::getRP2TRK_D0); rv::RVec phi0 = cast_constituent_2(jcs, tracks, ReconstructedParticle2Track::getRP2TRK_phi); - for (int i = 0; i < jets.size(); ++i) - { + for (std::size_t i = 0; i < jets.size(); ++i) { TVector2 p(jets[i].px(), jets[i].py()); FCCAnalysesJetConstituentsData cprojs; - for (int j = 0; j < jcs[i].size(); ++j) - { + for (std::size_t j = 0; j < jcs[i].size(); ++j) { if (D0.at(i).at(j) != -9) { TVector2 d0(-D0.at(i).at(j) * TMath::Sin(phi0.at(i).at(j)), D0.at(i).at(j) * TMath::Cos(phi0.at(i).at(j))); @@ -452,19 +444,17 @@ namespace FCCAnalyses return out; } - rv::RVec get_Sip2dVal_clusterV(const rv::RVec &jets, - const rv::RVec &D0, - const rv::RVec &phi0, - const float Bz) - { + rv::RVec + get_Sip2dVal_clusterV(const rv::RVec &jets, + const rv::RVec &D0, + const rv::RVec &phi0, + const float) { rv::RVec out; - for (int i = 0; i < jets.size(); ++i) - { + for (std::size_t i = 0; i < jets.size(); ++i) { TVector2 p(jets[i].px(), jets[i].py()); FCCAnalysesJetConstituentsData cprojs; - for (int j = 0; j < D0[i].size(); ++j) - { + for (std::size_t j = 0; j < D0[i].size(); ++j) { if (D0.at(i).at(j) != -9) { TVector2 d0(-D0.at(i).at(j) * TMath::Sin(phi0.at(i).at(j)), D0.at(i).at(j) * TMath::Cos(phi0.at(i).at(j))); @@ -486,11 +476,9 @@ namespace FCCAnalyses const rv::RVec &err2_D0) { rv::RVec out; - for (int i = 0; i < Sip2dVals.size(); ++i) - { + for (std::size_t i = 0; i < Sip2dVals.size(); ++i) { FCCAnalysesJetConstituentsData s; - for (int j = 0; j < Sip2dVals.at(i).size(); ++j) - { + for (std::size_t j = 0; j < Sip2dVals.at(i).size(); ++j) { if (err2_D0.at(i).at(j) > 0) { s.push_back(Sip2dVals.at(i).at(j) / std::sqrt(err2_D0.at(i).at(j))); @@ -514,12 +502,10 @@ namespace FCCAnalyses rv::RVec Z0 = cast_constituent_2(jcs, tracks, ReconstructedParticle2Track::getRP2TRK_Z0); rv::RVec phi0 = cast_constituent_2(jcs, tracks, ReconstructedParticle2Track::getRP2TRK_phi); - for (int i = 0; i < jets.size(); ++i) - { + for (std::size_t i = 0; i < jets.size(); ++i) { TVector3 p(jets[i].momentum.x, jets[i].momentum.y, jets[i].momentum.z); FCCAnalysesJetConstituentsData cprojs; - for (int j = 0; j < jcs[i].size(); ++j) - { + for (std::size_t j = 0; j < jcs[i].size(); ++j) { if (D0.at(i).at(j) != -9) { TVector3 d(-D0.at(i).at(j) * TMath::Sin(phi0.at(i).at(j)), D0.at(i).at(j) * TMath::Cos(phi0.at(i).at(j)), Z0.at(i).at(j)); @@ -544,12 +530,10 @@ namespace FCCAnalyses rv::RVec Z0 = cast_constituent_2(jcs, tracks, ReconstructedParticle2Track::getRP2TRK_Z0); rv::RVec phi0 = cast_constituent_2(jcs, tracks, ReconstructedParticle2Track::getRP2TRK_phi); - for (int i = 0; i < jets.size(); ++i) - { + for (std::size_t i = 0; i < jets.size(); ++i) { TVector3 p(jets[i].px(), jets[i].py(), jets[i].pz()); FCCAnalysesJetConstituentsData cprojs; - for (int j = 0; j < jcs[i].size(); ++j) - { + for (std::size_t j = 0; j < jcs[i].size(); ++j) { if (D0.at(i).at(j) != -9) { TVector3 d(-D0.at(i).at(j) * TMath::Sin(phi0.at(i).at(j)), D0.at(i).at(j) * TMath::Cos(phi0.at(i).at(j)), Z0.at(i).at(j)); @@ -565,20 +549,18 @@ namespace FCCAnalyses return out; } - rv::RVec get_Sip3dVal_clusterV(const rv::RVec &jets, - const rv::RVec &D0, - const rv::RVec &Z0, - const rv::RVec &phi0, - const float Bz) - { + rv::RVec + get_Sip3dVal_clusterV(const rv::RVec &jets, + const rv::RVec &D0, + const rv::RVec &Z0, + const rv::RVec &phi0, + const float) { rv::RVec out; - for (int i = 0; i < jets.size(); ++i) - { + for (std::size_t i = 0; i < jets.size(); ++i) { TVector3 p(jets[i].px(), jets[i].py(), jets[i].pz()); FCCAnalysesJetConstituentsData cprojs; - for (int j = 0; j < D0[i].size(); ++j) - { + for (std::size_t j = 0; j < D0[i].size(); ++j) { if (D0.at(i).at(j) != -9) { TVector3 d(-D0.at(i).at(j) * TMath::Sin(phi0.at(i).at(j)), D0.at(i).at(j) * TMath::Cos(phi0.at(i).at(j)), Z0.at(i).at(j)); @@ -599,11 +581,9 @@ namespace FCCAnalyses const rv::RVec &err2_Z0) { rv::RVec out; - for (int i = 0; i < Sip3dVals.size(); ++i) - { + for (std::size_t i = 0; i < Sip3dVals.size(); ++i) { FCCAnalysesJetConstituentsData s; - for (int j = 0; j < Sip3dVals.at(i).size(); ++j) - { + for (std::size_t j = 0; j < Sip3dVals.at(i).size(); ++j) { if (err2_D0.at(i).at(j) > 0.) { s.push_back(Sip3dVals.at(i).at(j) / sqrt(err2_D0.at(i).at(j) + err2_Z0.at(i).at(j))); @@ -626,13 +606,11 @@ namespace FCCAnalyses rv::RVec D0 = cast_constituent_2(jcs, tracks, ReconstructedParticle2Track::getRP2TRK_D0); rv::RVec Z0 = cast_constituent_2(jcs, tracks, ReconstructedParticle2Track::getRP2TRK_Z0); rv::RVec phi0 = cast_constituent_2(jcs, tracks, ReconstructedParticle2Track::getRP2TRK_phi); - for (int i = 0; i < jets.size(); ++i) - { + for (std::size_t i = 0; i < jets.size(); ++i) { FCCAnalysesJetConstituentsData tmp; TVector3 p_jet(jets[i].momentum.x, jets[i].momentum.y, jets[i].momentum.z); FCCAnalysesJetConstituents ct = jcs.at(i); - for (int j = 0; j < ct.size(); ++j) - { + for (std::size_t j = 0; j < ct.size(); ++j) { if (D0.at(i).at(j) != -9) { TVector3 d(-D0.at(i).at(j) * TMath::Sin(phi0.at(i).at(j)), D0.at(i).at(j) * TMath::Cos(phi0.at(i).at(j)), Z0.at(i).at(j)); @@ -659,13 +637,11 @@ namespace FCCAnalyses rv::RVec D0 = cast_constituent_2(jcs, tracks, ReconstructedParticle2Track::getRP2TRK_D0); rv::RVec Z0 = cast_constituent_2(jcs, tracks, ReconstructedParticle2Track::getRP2TRK_Z0); rv::RVec phi0 = cast_constituent_2(jcs, tracks, ReconstructedParticle2Track::getRP2TRK_phi); - for (int i = 0; i < jets.size(); ++i) - { + for (std::size_t i = 0; i < jets.size(); ++i) { FCCAnalysesJetConstituentsData tmp; TVector3 p_jet(jets[i].px(), jets[i].py(), jets[i].pz()); FCCAnalysesJetConstituents ct = jcs.at(i); - for (int j = 0; j < ct.size(); ++j) - { + for (std::size_t j = 0; j < ct.size(); ++j) { if (D0.at(i).at(j) != -9) { TVector3 d(-D0.at(i).at(j) * TMath::Sin(phi0.at(i).at(j)), D0.at(i).at(j) * TMath::Cos(phi0.at(i).at(j)), Z0.at(i).at(j)); @@ -684,22 +660,19 @@ namespace FCCAnalyses return out; } - rv::RVec get_JetDistVal_clusterV(const rv::RVec &jets, - const rv::RVec &jcs, - const rv::RVec &D0, - const rv::RVec &Z0, - const rv::RVec &phi0, - const float Bz) - { + rv::RVec get_JetDistVal_clusterV( + const rv::RVec &jets, + const rv::RVec &jcs, + const rv::RVec &D0, + const rv::RVec &Z0, + const rv::RVec &phi0, const float) { rv::RVec out; - for (int i = 0; i < jets.size(); ++i) - { + for (std::size_t i = 0; i < jets.size(); ++i) { FCCAnalysesJetConstituentsData tmp; TVector3 p_jet(jets[i].px(), jets[i].py(), jets[i].pz()); FCCAnalysesJetConstituents ct = jcs.at(i); - for (int j = 0; j < ct.size(); ++j) - { + for (std::size_t j = 0; j < ct.size(); ++j) { if (D0.at(i).at(j) != -9) { TVector3 d(-D0.at(i).at(j) * TMath::Sin(phi0.at(i).at(j)), D0.at(i).at(j) * TMath::Cos(phi0.at(i).at(j)), Z0.at(i).at(j)); @@ -723,11 +696,9 @@ namespace FCCAnalyses const rv::RVec &err2_Z0) { rv::RVec out; - for (int i = 0; i < JetDistVal.size(); ++i) - { + for (std::size_t i = 0; i < JetDistVal.size(); ++i) { FCCAnalysesJetConstituentsData tmp; - for (int j = 0; j < JetDistVal.at(i).size(); ++j) - { + for (std::size_t j = 0; j < JetDistVal.at(i).size(); ++j) { if (err2_D0.at(i).at(j) > 0) { float err3d = std::sqrt(err2_D0.at(i).at(j) + err2_Z0.at(i).at(j)); @@ -767,12 +738,10 @@ namespace FCCAnalyses ) { rv::RVec out; - for (int i = 0; i < jcs.size(); ++i) - { + for (std::size_t i = 0; i < jcs.size(); ++i) { FCCAnalysesJetConstituents ct = jcs.at(i); FCCAnalysesJetConstituentsData tmp; - for (int j = 0; j < ct.size(); ++j) - { + for (std::size_t j = 0; j < ct.size(); ++j) { if (ct.at(j).clusters_begin < nhdata.size() + gammadata.size()) { #if edm4hep_VERSION > EDM4HEP_VERSION(0, 10, 5) @@ -1088,12 +1057,10 @@ namespace FCCAnalyses rv::RVec get_isEl(const rv::RVec &jcs) { rv::RVec out; - for (int i = 0; i < jcs.size(); ++i) - { + for (std::size_t i = 0; i < jcs.size(); ++i) { FCCAnalysesJetConstituentsData is_El; FCCAnalysesJetConstituents ct = jcs.at(i); - for (int j = 0; j < ct.size(); ++j) - { + for (std::size_t j = 0; j < ct.size(); ++j) { if (std::abs(ct.at(j).charge) > 0 and std::abs(ct.at(j).mass - 0.000510999) < 1.e-05) { is_El.push_back(1.); @@ -1112,12 +1079,10 @@ namespace FCCAnalyses rv::RVec get_isMu(const rv::RVec &jcs) { rv::RVec out; - for (int i = 0; i < jcs.size(); ++i) - { + for (std::size_t i = 0; i < jcs.size(); ++i) { FCCAnalysesJetConstituentsData is_Mu; FCCAnalysesJetConstituents ct = jcs.at(i); - for (int j = 0; j < ct.size(); ++j) - { + for (std::size_t j = 0; j < ct.size(); ++j) { if (std::abs(ct.at(j).charge) > 0 and std::abs(ct.at(j).mass - 0.105658) < 1.e-03) { is_Mu.push_back(1.); @@ -1136,12 +1101,10 @@ namespace FCCAnalyses rv::RVec get_isChargedHad(const rv::RVec &jcs) { rv::RVec out; - for (int i = 0; i < jcs.size(); ++i) - { + for (std::size_t i = 0; i < jcs.size(); ++i) { FCCAnalysesJetConstituentsData is_ChargedHad; FCCAnalysesJetConstituents ct = jcs.at(i); - for (int j = 0; j < ct.size(); ++j) - { + for (std::size_t j = 0; j < ct.size(); ++j) { if (std::abs(ct.at(j).charge) > 0 and std::abs(ct.at(j).mass - 0.13957) < 1.e-03) { is_ChargedHad.push_back(1.); @@ -1160,12 +1123,10 @@ namespace FCCAnalyses rv::RVec get_isNeutralHad(const rv::RVec &jcs) { rv::RVec out; - for (int i = 0; i < jcs.size(); ++i) - { + for (std::size_t i = 0; i < jcs.size(); ++i) { FCCAnalysesJetConstituentsData is_NeutralHad; FCCAnalysesJetConstituents ct = jcs.at(i); - for (int j = 0; j < ct.size(); ++j) - { + for (std::size_t j = 0; j < ct.size(); ++j) { #if edm4hep_VERSION > EDM4HEP_VERSION(0, 10, 5) if (ct.at(j).PDG == 130) #else @@ -1185,12 +1146,10 @@ namespace FCCAnalyses rv::RVec get_isGamma(const rv::RVec &jcs) { rv::RVec out; - for (int i = 0; i < jcs.size(); ++i) - { + for (std::size_t i = 0; i < jcs.size(); ++i) { FCCAnalysesJetConstituentsData is_NeutralHad; FCCAnalysesJetConstituents ct = jcs.at(i); - for (int j = 0; j < ct.size(); ++j) - { + for (std::size_t j = 0; j < ct.size(); ++j) { #if edm4hep_VERSION > EDM4HEP_VERSION(0, 10, 5) if (ct.at(j).PDG == 22) #else @@ -1216,8 +1175,7 @@ namespace FCCAnalyses rv::RVec count_consts(rv::RVec jets) { rv::RVec out; - for (int i = 0; i < jets.size(); ++i) - { + for (std::size_t i = 0; i < jets.size(); ++i) { out.push_back(jets.at(i).size()); } return out; @@ -1226,12 +1184,10 @@ namespace FCCAnalyses rv::RVec count_type(const rv::RVec &isType) { rv::RVec out; - for (int i = 0; i < isType.size(); ++i) - { + for (std::size_t i = 0; i < isType.size(); ++i) { int count = 0; rv::RVec istype = isType.at(i); - for (int j = 0; j < istype.size(); ++j) - { + for (std::size_t j = 0; j < istype.size(); ++j) { if ((int)(istype.at(j)) == 1) count++; } @@ -1256,8 +1212,7 @@ namespace FCCAnalyses rv::RVec sum_tlv_constituents(const rv::RVec &jets) { rv::RVec out; - for (int i = 0; i < jets.size(); ++i) - { + for (std::size_t i = 0; i < jets.size(); ++i) { TLorentzVector sum_tlv; // initialized by (0., 0., 0., 0.) FCCAnalysesJetConstituents jcs = jets.at(i); for (const auto &jc : jcs) @@ -1293,11 +1248,11 @@ namespace FCCAnalyses if(AllJets.size() < 2) return InvariantMasses; // For each jet, take its invariant mass with the remaining jets. Stop at last jet. - for(int i = 0; i < AllJets.size()-1; ++i) { + for (std::size_t i = 0; i + 1 < AllJets.size(); ++i) { - tlv1 = AllJets.at(i); + tlv1 = AllJets.at(i); - for(int j=i+1; j < AllJets.size(); ++j){ // go until end + for (std::size_t j = i + 1; j < AllJets.size(); ++j) { // go until end tlv2 = AllJets.at(j); E = tlv1.E() + tlv2.E(); px = tlv1.Px() + tlv2.Px(); @@ -1306,7 +1261,6 @@ namespace FCCAnalyses invmass = std::sqrt(E*E - px*px - py*py - pz*pz); InvariantMasses.push_back(invmass); - } } @@ -1316,8 +1270,7 @@ namespace FCCAnalyses rv::RVec compute_residue_energy(const rv::RVec& tlv_jet, const rv::RVec& sum_tlv_jcs) { rv::RVec out; - for (int i = 0; i < tlv_jet.size(); ++i) - { + for (std::size_t i = 0; i < tlv_jet.size(); ++i) { float de = (sum_tlv_jcs.at(i).E() - tlv_jet.at(i).E()) / tlv_jet.at(i).E(); out.push_back(de); } @@ -1327,8 +1280,7 @@ namespace FCCAnalyses rv::RVec compute_residue_px(const rv::RVec &tlv_jet, const rv::RVec &sum_tlv_jcs) { rv::RVec out; - for (int i = 0; i < tlv_jet.size(); ++i) - { + for (std::size_t i = 0; i < tlv_jet.size(); ++i) { float dpx = (sum_tlv_jcs.at(i).Px() - tlv_jet.at(i).Px()) / tlv_jet.at(i).Px(); out.push_back(dpx); } @@ -1338,8 +1290,7 @@ namespace FCCAnalyses rv::RVec compute_residue_py(const rv::RVec &tlv_jet, const rv::RVec &sum_tlv_jcs) { rv::RVec out; - for (int i = 0; i < tlv_jet.size(); ++i) - { + for (std::size_t i = 0; i < tlv_jet.size(); ++i) { float dpy = (sum_tlv_jcs.at(i).Py() - tlv_jet.at(i).Py()) / tlv_jet.at(i).Py(); out.push_back(dpy); } @@ -1349,8 +1300,7 @@ namespace FCCAnalyses rv::RVec compute_residue_pz(const rv::RVec &tlv_jet, const rv::RVec &sum_tlv_jcs) { rv::RVec out; - for (int i = 0; i < tlv_jet.size(); ++i) - { + for (std::size_t i = 0; i < tlv_jet.size(); ++i) { float dpz = (sum_tlv_jcs.at(i).Pz() - tlv_jet.at(i).Pz()) / tlv_jet.at(i).Pz(); out.push_back(dpz); } @@ -1360,8 +1310,7 @@ namespace FCCAnalyses rv::RVec compute_residue_pt(const rv::RVec &tlv_jet, const rv::RVec &sum_tlv_jcs) { rv::RVec out; - for (int i = 0; i < tlv_jet.size(); ++i) - { + for (std::size_t i = 0; i < tlv_jet.size(); ++i) { double pt_jet = std::sqrt(tlv_jet.at(i).Px() * tlv_jet.at(i).Px() + tlv_jet.at(i).Py() * tlv_jet.at(i).Py()); double pt_jcs = std::sqrt(sum_tlv_jcs.at(i).Px() * sum_tlv_jcs.at(i).Px() + sum_tlv_jcs.at(i).Py() * sum_tlv_jcs.at(i).Py()); double dpt = (pt_jcs - pt_jet) / pt_jet; @@ -1373,8 +1322,7 @@ namespace FCCAnalyses rv::RVec compute_residue_phi(const rv::RVec &tlv_jet, const rv::RVec &sum_tlv_jcs) { rv::RVec out; - for (int i = 0; i < tlv_jet.size(); ++i) - { + for (std::size_t i = 0; i < tlv_jet.size(); ++i) { double phi_jet = tlv_jet.at(i).Phi(); double phi_jcs = sum_tlv_jcs.at(i).Phi(); double dphi = (phi_jcs - phi_jet) / phi_jet; @@ -1386,8 +1334,7 @@ namespace FCCAnalyses rv::RVec compute_residue_theta(const rv::RVec &tlv_jet, const rv::RVec &sum_tlv_jcs) { rv::RVec out; - for (int i = 0; i < tlv_jet.size(); ++i) - { + for (std::size_t i = 0; i < tlv_jet.size(); ++i) { double theta_jet = tlv_jet.at(i).Theta(); double theta_jcs = sum_tlv_jcs.at(i).Theta(); double dtheta = (theta_jcs - theta_jet) / theta_jet; diff --git a/analyzers/dataframe/src/JetFlavourUtils.cc b/analyzers/dataframe/src/JetFlavourUtils.cc index 7a88909bf49..94917b550a3 100644 --- a/analyzers/dataframe/src/JetFlavourUtils.cc +++ b/analyzers/dataframe/src/JetFlavourUtils.cc @@ -1,6 +1,7 @@ #include "FCCAnalyses/JetFlavourUtils.h" #include "ONNXRuntime/WeaverInterface.h" +#include #include namespace FCCAnalyses { @@ -49,9 +50,9 @@ namespace FCCAnalyses { throw std::runtime_error("Invalid index requested for jet flavour weight."); rv::RVec out; for (const auto& jet_weights : jets_weights) { - if (weight >= jet_weights.size()) + if (static_cast(weight) >= jet_weights.size()) throw std::runtime_error("Flavour weight index exceeds the number of weights registered."); - out.emplace_back(jet_weights.at(weight)); + out.emplace_back(jet_weights.at(static_cast(weight))); } return out; } diff --git a/analyzers/dataframe/src/JetTaggingUtils.cc b/analyzers/dataframe/src/JetTaggingUtils.cc index 7ed529c18a3..d9ec0e5f267 100644 --- a/analyzers/dataframe/src/JetTaggingUtils.cc +++ b/analyzers/dataframe/src/JetTaggingUtils.cc @@ -9,7 +9,6 @@ get_flavour(ROOT::VecOps::RVec in, ROOT::VecOps::RVec MCin) { ROOT::VecOps::RVec result(in.size(), 0); - int loopcount = 0; for (size_t i = 0; i < MCin.size(); ++i) { auto &parton = MCin[i]; // Select partons only (for pythia8 71-79, for pythia6 2): diff --git a/analyzers/dataframe/src/MCParticle.cc b/analyzers/dataframe/src/MCParticle.cc index 8e7d42c458c..e78fbe63937 100644 --- a/analyzers/dataframe/src/MCParticle.cc +++ b/analyzers/dataframe/src/MCParticle.cc @@ -1,9 +1,9 @@ #include "FCCAnalyses/MCParticle.h" -#include #include +#include +#include #include - namespace FCCAnalyses{ namespace MCParticle{ @@ -85,16 +85,16 @@ bool filter_pdgID::operator() (ROOT::VecOps::RVec in) get_EventPrimaryVertex::get_EventPrimaryVertex( int arg_genstatus) { m_genstatus = arg_genstatus; }; TVector3 get_EventPrimaryVertex::operator() ( ROOT::VecOps::RVec in ) { - TVector3 result(-1e12,-1e12,-1e12); - int i=0; - for (auto & p: in) { - i++; - if ( p.generatorStatus == m_genstatus ) { // generator status code for the incoming particles of the hardest subprocess - TVector3 res( p.vertex.x, p.vertex.y, p.vertex.z ); - result = res; - break; - } - } + TVector3 result(-1e12, -1e12, -1e12); + for (auto &p : in) { + if (p.generatorStatus == + m_genstatus) { // generator status code for the incoming particles of + // the hardest subprocess + TVector3 res(p.vertex.x, p.vertex.y, p.vertex.z); + result = res; + break; + } + } return result; } @@ -145,8 +145,6 @@ TLorentzVector get_EventPrimaryVertexP4::operator() ( ROOT::VecOps::RVec get_tree::operator() (ROOT::VecOps::RVec in, ROOT::VecOps::RVec ind){ ROOT::VecOps::RVec result; - auto & particle = in[m_index]; - //for (unsigned j = in.at(i).parents_begin; j != in.at(i).parents_end; ++j){ // if // result.push_back(ind.at(j)); @@ -286,9 +284,8 @@ ROOT::VecOps::RVec get_endPoint(ROOT::VecOps::RVec= 0 && d1 < in.size() ) { - vertex = in.at(d1).vertex ; - } + if (d1 >= 0 && static_cast(d1) < in.size()) + vertex = in.at(d1).vertex; } result.push_back(vertex); } @@ -481,9 +478,8 @@ ROOT::VecOps::RVec get_parentid(ROOT::VecOps::RVec mcind, ROOT::VecOps // returns one MCParticle selected by its index in the particle block edm4hep::MCParticleData sel_byIndex( int idx, ROOT::VecOps::RVec in) { edm4hep::MCParticleData dummy; - if ( idx >= 0 && idx < in.size() ) { - return in.at(idx) ; - } + if (idx >= 0 && static_cast(idx) < in.size()) + return in.at(idx); else { std::cout << " !!!! in sel_byIndex : index = " << idx << " is larger than the size of the MCParticle block " << in.size() << std::endl; } @@ -503,7 +499,8 @@ std::vector get_list_of_stable_particles_from_decay( int i, ROOT::VecOps::R // returns a vector with the indices (in the Particle block) of the stable daughters of the particle i, // from the complete decay chain. - if ( i < 0 || i >= in.size() ) return res; + if (i < 0 || static_cast(i) >= in.size()) + return res; int db = in.at(i).daughters_begin ; int de = in.at(i).daughters_end; @@ -537,7 +534,8 @@ std::vector get_list_of_particles_from_decay(int i, ROOT::VecOps::RVec= in.size() ) return res; + if (i < 0 || static_cast(i) >= in.size()) + return res; int db = in.at(i).daughters_begin ; int de = in.at(i).daughters_end; @@ -660,7 +658,7 @@ ROOT::VecOps::RVec get_indices::operator() ( ROOT::VecOps::RVec result; - for ( int imother =0; imother < in.size(); imother ++){ + for (std::size_t imother = 0; imother < in.size(); imother++) { int pdg = in[imother].PDG ; bool found_a_mother = false; if ( ! m_chargeConjugateMother ) found_a_mother = ( pdg == m_pdg_mother ); @@ -672,7 +670,6 @@ ROOT::VecOps::RVec get_indices::operator() ( ROOT::VecOps::RVec AngleBetweenTwoMCParticles( ROOT::VecOps::RVec &in, const ROOT::VecOps::RVec &ind){ - if ( index < 0 || index >= in.size() ) return -1; + if (index < 0 || static_cast(index) >= in.size()) + return -1; edm4hep::MCParticleData p = in[index]; return get_lepton_origin( p, in, ind ); } diff --git a/analyzers/dataframe/src/ReconstructedParticle.cc b/analyzers/dataframe/src/ReconstructedParticle.cc index 221a335e2f6..b946711df3b 100644 --- a/analyzers/dataframe/src/ReconstructedParticle.cc +++ b/analyzers/dataframe/src/ReconstructedParticle.cc @@ -1,4 +1,5 @@ #include "FCCAnalyses/ReconstructedParticle.h" +#include // Standard library #include @@ -229,18 +230,22 @@ float angular_separationBuilder::operator() ( ROOT::VecOps::RVec dmax) dmax = delta_ij; - if ( delta_ij < dmin) dmin = delta_ij; - sum = sum + delta_ij; - npairs ++; - } + for (std::size_t i = 0; i < in.size(); i++) { + if (in.at(i).energy < 0) + continue; // "dummy" particle - cf selRP_matched_to_list + TVector3 p1(in.at(i).momentum.x, in.at(i).momentum.y, in.at(i).momentum.z); + for (std::size_t j = i + 1; j < in.size(); j++) { + if (in.at(j).energy < 0) + continue; // "dummy" particle + TVector3 p2(in.at(j).momentum.x, in.at(j).momentum.y, in.at(j).momentum.z); + float delta_ij = fabs(p1.Angle(p2)); + if (delta_ij > dmax) + dmax = delta_ij; + if (delta_ij < dmin) + dmin = delta_ij; + sum = sum + delta_ij; + npairs++; + } } float delta_max = dmax; float delta_min = dmin; diff --git a/analyzers/dataframe/src/ReconstructedParticle2MC.cc b/analyzers/dataframe/src/ReconstructedParticle2MC.cc index 45abccdd4e8..b27ce90c7da 100644 --- a/analyzers/dataframe/src/ReconstructedParticle2MC.cc +++ b/analyzers/dataframe/src/ReconstructedParticle2MC.cc @@ -1,4 +1,5 @@ #include "FCCAnalyses/ReconstructedParticle2MC.h" +#include #include namespace FCCAnalyses{ @@ -272,16 +273,17 @@ selRP_PDG::operator() (ROOT::VecOps::RVec recind, std::vector result; - for (int i=0; i recind, ROOT::VecOps::RVec result; - for (int i=0; i recind, std::vector result; - for (int i=0; i mcParticles_indices, // is this MC particle associated with a Reco particle : bool found = false; - for (int i=0; i reco) { int mc_index = -1; - for (int i=0; i= 0 && reco.at(reco_idx).tracks_begin == + static_cast(track_index)) + return mc_index; + } return mc_index; } diff --git a/analyzers/dataframe/src/ReconstructedParticle2Track.cc b/analyzers/dataframe/src/ReconstructedParticle2Track.cc index f8aa59e8901..6bd150e530e 100644 --- a/analyzers/dataframe/src/ReconstructedParticle2Track.cc +++ b/analyzers/dataframe/src/ReconstructedParticle2Track.cc @@ -216,11 +216,11 @@ namespace ReconstructedParticle2Track{ return out; } - ROOT::VecOps::RVec XPtoPar_ct(const ROOT::VecOps::RVec& in, - const ROOT::VecOps::RVec& tracks, - const float& Bz) { + ROOT::VecOps::RVec + XPtoPar_ct(const ROOT::VecOps::RVec &in, + const ROOT::VecOps::RVec &tracks, + const float &) { - const double cSpeed = 2.99792458e8 * 1.0e-9; ROOT::VecOps::RVec out; for (const auto & rp: in) { @@ -241,7 +241,6 @@ namespace ReconstructedParticle2Track{ return out; } - ROOT::VecOps::RVec getRP2TRK_D0(ROOT::VecOps::RVec in, ROOT::VecOps::RVec tracks) { @@ -516,8 +515,8 @@ getRP2TRK( ROOT::VecOps::RVec in, result.reserve( in.size() ); for (auto & p: in) { - if (p.tracks_begin >= 0 && p.tracks_begin in, for (unsigned int ctr=0; ctr= 0 && p.tracks_begin in ) { result.reserve( in.size() ); for (auto & p: in) { - if (p.tracks_begin >= 0 && p.tracks_begin != p.tracks_end) result.push_back(true) ; + if (p.tracks_begin != p.tracks_end) + result.push_back(true); else result.push_back(false); } return result ; diff --git a/analyzers/dataframe/src/SmearObjects.cc b/analyzers/dataframe/src/SmearObjects.cc index b15eb52b51b..3b28639a81b 100644 --- a/analyzers/dataframe/src/SmearObjects.cc +++ b/analyzers/dataframe/src/SmearObjects.cc @@ -1,4 +1,5 @@ #include "FCCAnalyses/SmearObjects.h" +#include // std #include @@ -77,7 +78,7 @@ ROOT::VecOps::RVec SmearedTracks::operator()( // find the corresponding MC particle int MCindex = -1; - for (int ireco = 0; ireco < allRecoParticles.size(); ireco++) { + for (std::size_t ireco = 0; ireco < allRecoParticles.size(); ireco++) { edm4hep::ReconstructedParticleData rp = allRecoParticles[ireco]; int track_index = rp.tracks_begin; if (track_index == itrack) { @@ -87,9 +88,8 @@ ROOT::VecOps::RVec SmearedTracks::operator()( } // end loop on RPs if (MCindex < 0 || - MCindex >= - mcParticles - .size()) { // in principle, this should not happen in delphes, + static_cast(MCindex) >= mcParticles.size()) { + // In principle, this should not happen in Delphes, // each track should be matched to a MC particle. result[itrack] = dummy; continue; @@ -193,11 +193,9 @@ ROOT::VecOps::RVec mcTrackParameters( edm4hep::TrackState dummy; for (int itrack = 0; itrack < ntracks; itrack++) { - edm4hep::TrackState track = alltracks[itrack]; - // find the corresponding MC particle int MCindex = -1; - for (int ireco = 0; ireco < allRecoParticles.size(); ireco++) { + for (std::size_t ireco = 0; ireco < allRecoParticles.size(); ireco++) { edm4hep::ReconstructedParticleData rp = allRecoParticles[ireco]; int track_index = rp.tracks_begin; if (track_index == itrack) { @@ -206,7 +204,8 @@ ROOT::VecOps::RVec mcTrackParameters( } } // end loop on RPs - if (MCindex < 0 || MCindex >= mcParticles.size()) { + if (MCindex < 0 || + static_cast(MCindex) >= mcParticles.size()) { result.push_back(dummy); continue; } @@ -300,7 +299,7 @@ TVectorD CovSmear(TVectorD x, TMatrixDSym C, TRandom *ran, bool debug = false) { // ---------------------------------------------------------------------------- SmearedTracksdNdx::SmearedTracksdNdx(float scale, bool debug = false) - : m_scale(scale), m_debug(debug) {} + : m_debug(debug), m_scale(scale) {} ROOT::VecOps::RVec SmearedTracksdNdx::operator()( const ROOT::VecOps::RVec @@ -325,7 +324,7 @@ ROOT::VecOps::RVec SmearedTracksdNdx::operator()( // find the corresponding MC particle int MCindex = -1; - for (int ireco = 0; ireco < allRecoParticles.size(); ireco++) { + for (std::size_t ireco = 0; ireco < allRecoParticles.size(); ireco++) { edm4hep::ReconstructedParticleData rp = allRecoParticles[ireco]; int track_index = rp.tracks_begin; if (track_index == itrack) { @@ -335,9 +334,8 @@ ROOT::VecOps::RVec SmearedTracksdNdx::operator()( } // end loop on RPs if (MCindex < 0 || - MCindex >= - mcParticles - .size()) { // in principle, this should not happen in delphes, + static_cast(MCindex) >= mcParticles.size()) { + // In principle, this should not happen in Delphes, // each track should be matched to a MC particle. result.push_back(dNdxSmeared); continue; @@ -428,7 +426,7 @@ ROOT::VecOps::RVec SmearedTracksTOF::operator()( // find the corresponding MC particle int MCindex = -1; - for (int ireco = 0; ireco < allRecoParticles.size(); ireco++) { + for (std::size_t ireco = 0; ireco < allRecoParticles.size(); ireco++) { edm4hep::ReconstructedParticleData rp = allRecoParticles[ireco]; int track_index = rp.tracks_begin; if (track_index == itrack) { @@ -438,9 +436,8 @@ ROOT::VecOps::RVec SmearedTracksTOF::operator()( } // end loop on RPs if (MCindex < 0 || - MCindex >= - mcParticles - .size()) { // in principle, this should not happen in delphes, + static_cast(MCindex) >= mcParticles.size()) { + // In principle, this should not happen in Delphes, // each track should be matched to a MC particle. result[idx_tin] = smeared_thits_0; result[idx_tpix] = smeared_thits_1; @@ -549,7 +546,8 @@ SmearedReconstructedParticle::operator()( // smear particle only if MC particle found, else return original particle // and if type == requested - if (MCindex >= 0 and MCindex < mcParticles.size() and + if (MCindex >= 0 and + static_cast(MCindex) < mcParticles.size() and reco_part_type == m_type) { edm4hep::MCParticleData mc_part = mcParticles[MCindex]; diff --git a/analyzers/dataframe/src/Smearing.cc b/analyzers/dataframe/src/Smearing.cc index 9ecea2fe228..52d517e6c22 100644 --- a/analyzers/dataframe/src/Smearing.cc +++ b/analyzers/dataframe/src/Smearing.cc @@ -2,7 +2,7 @@ logNormal::logNormal(float arg_a, float arg_b, float arg_c){m_a = arg_a; m_b = arg_b; m_c = arg_c;}; -ROOT::VecOps::RVec logNormal::operator() (ROOT::VecOps::RVec in) { +ROOT::VecOps::RVec logNormal::operator()(ROOT::VecOps::RVec) { ROOT::VecOps::RVec result; return result; diff --git a/analyzers/dataframe/src/VertexFinderLCFIPlus.cc b/analyzers/dataframe/src/VertexFinderLCFIPlus.cc index d7ca7a23087..8fae36bc7dc 100644 --- a/analyzers/dataframe/src/VertexFinderLCFIPlus.cc +++ b/analyzers/dataframe/src/VertexFinderLCFIPlus.cc @@ -2,6 +2,7 @@ // contact: kunal.gautam@cern.ch #include "FCCAnalyses/VertexFinderLCFIPlus.h" +#include #include namespace FCCAnalyses{ @@ -44,13 +45,13 @@ ROOT::VecOps::RVec> get_SV // remove primary tracks & separate non-primary tracks by jet std::vector i_jetconsti = jet_consti[j]; - for (int ctr=0; ctr VertexSeed_best(ROOT::VecOps::RVec tr_pair.push_back(tr_j); VertexingUtils::FCCAnalysesVertex vtx_seed; double chi2_min = 99; - - for(unsigned int i=0; i addTrack_best(ROOT::VecOps::RVec tr tr_vtx.push_back(tr_i); // find best track to add to the vtx - for(unsigned int i=0; i addTrack_best(ROOT::VecOps::RVec tr if(chi2_vtx < chi2_min) { isel = i; chi2_min = chi2_vtx; - } + } } if(isel>=0) result.push_back(isel); @@ -285,14 +286,14 @@ ROOT::VecOps::RVec findSVfromTracks(ROOT::Vec if(debug_me){ std::cout << "tracks_fin.size(): " << tracks_fin.size() << std::endl; - for(int i=0; i vtx_fin = vtx_seed; - int vtx_fin_size = 0; // to start the loop + std::size_t vtx_fin_size = 0; // to start the loop while(vtx_fin_size != vtx_fin.size()) { vtx_fin_size = vtx_fin.size(); vtx_fin = addTrack_best(tracks_fin, vtx_fin, PV, chi2_cut, invM_cut, chi2Tr_cut); @@ -392,11 +393,11 @@ ROOT::VecOps::RVec isV0(ROOT::VecOps::RVec np_tracks, t_pair.push_back(tr_j); VertexingUtils::FCCAnalysesVertex V0; // - for(unsigned int i=0; i 0) continue; // don't pair tracks with same charge (same sign curvature = same sign charge) t_pair[1] = np_tracks[j]; @@ -427,8 +428,8 @@ ROOT::VecOps::RVec isV0(ROOT::VecOps::RVec np_tracks, result[i] = true; result[j] = true; break; - } - // + } + // } } @@ -473,11 +474,11 @@ VertexingUtils::FCCAnalysesV0 get_V0s(ROOT::VecOps::RVec np tr_pair.push_back(tr_i); tr_pair.push_back(tr_j); // - for(unsigned int i=0; i 0) continue; // don't pair tracks with same charge (same sign curvature = same sign charge) tr_pair[1] = np_tracks[j]; @@ -571,11 +572,11 @@ VertexingUtils::FCCAnalysesV0 get_V0s(ROOT::VecOps::RVec np tr_pair.push_back(tr_i); tr_pair.push_back(tr_j); // - for(unsigned int i=0; i 0) continue; // don't pair tracks with same charge (same sign curvature = same sign charge) tr_pair[1] = np_tracks[j]; @@ -691,77 +692,89 @@ VertexingUtils::FCCAnalysesV0 get_V0s_jet(ROOT::VecOps::RVec i_jetconsti = jet_consti[j]; - for (int ctr=0; ctr isInV0(nTr, false); // - for(unsigned int i=0; i 0) continue; // don't pair tracks with same charge (same sign curvature = same sign charge) - tr_pair[1] = np_tracks[j]; - - ROOT::VecOps::RVec V0_cand = get_V0candidate(V0_vtx, tr_pair, PV, true, chi2_cut); - if(V0_cand[0] == -1) continue; - - // Ks - if(V0_cand[0]>isKs[0] && V0_cand[0]isKs[2] && V0_cand[5]>isKs[3]) { - if(debug_me) std::cout<<"Found a Ks"<isLambda0[0] && V0_cand[1]isLambda0[2] && V0_cand[5]>isLambda0[3]) { - if(debug_me) std::cout<<"Found a Lambda0"<isLambda0[0] && V0_cand[2]isLambda0[2] && V0_cand[5]>isLambda0[3]) { - if(debug_me) std::cout<<"Found a Lambda0"<isGamma[2] && V0_cand[5]>isGamma[3]) { - if(debug_me) std::cout<<"Found a Photon coversion"< 0) + continue; // don't pair tracks with same charge (same sign curvature = + // same sign charge) + tr_pair[1] = np_tracks[trackIndex]; + + ROOT::VecOps::RVec V0_cand = + get_V0candidate(V0_vtx, tr_pair, PV, true, chi2_cut); + if (V0_cand[0] == -1) + continue; + + // Ks + if (V0_cand[0] > isKs[0] && V0_cand[0] < isKs[1] && + V0_cand[4] > isKs[2] && V0_cand[5] > isKs[3]) { + if (debug_me) + std::cout << "Found a Ks" << std::endl; + isInV0[i] = true; + isInV0[trackIndex] = true; + vtx.push_back(V0_vtx); + pdgAbs.push_back(310); + invM.push_back(V0_cand[0]); + i_nSV++; + break; + } + + // Lambda0 + else if (V0_cand[1] > isLambda0[0] && V0_cand[1] < isLambda0[1] && + V0_cand[4] > isLambda0[2] && V0_cand[5] > isLambda0[3]) { + if (debug_me) + std::cout << "Found a Lambda0" << std::endl; + isInV0[i] = true; + isInV0[trackIndex] = true; + vtx.push_back(V0_vtx); + pdgAbs.push_back(3122); + invM.push_back(V0_cand[1]); + i_nSV++; + break; + } else if (V0_cand[2] > isLambda0[0] && V0_cand[2] < isLambda0[1] && + V0_cand[4] > isLambda0[2] && V0_cand[5] > isLambda0[3]) { + if (debug_me) + std::cout << "Found a Lambda0" << std::endl; + isInV0[i] = true; + isInV0[trackIndex] = true; + vtx.push_back(V0_vtx); + pdgAbs.push_back(3122); + invM.push_back(V0_cand[2]); + i_nSV++; + break; + } + + // photon conversion + else if (V0_cand[3] < isGamma[1] && V0_cand[4] > isGamma[2] && + V0_cand[5] > isGamma[3]) { + if (debug_me) + std::cout << "Found a Photon coversion" << std::endl; + isInV0[i] = true; + isInV0[trackIndex] = true; + vtx.push_back(V0_vtx); + pdgAbs.push_back(22); + invM.push_back(V0_cand[3]); + i_nSV++; + break; + } + // } } diff --git a/analyzers/dataframe/src/VertexFitterSimple.cc b/analyzers/dataframe/src/VertexFitterSimple.cc index 6144ee10871..be8967c9a80 100644 --- a/analyzers/dataframe/src/VertexFitterSimple.cc +++ b/analyzers/dataframe/src/VertexFitterSimple.cc @@ -1,5 +1,6 @@ #include "FCCAnalyses/VertexFitterSimple.h" #include "FCCAnalyses/MCParticle.h" +#include #include "edm4hep/EDM4hepVersion.h" @@ -64,11 +65,11 @@ VertexingUtils::FCCAnalysesVertex VertexFitter( // fill the indices of the tracks ROOT::VecOps::RVec reco_ind; - int Ntr = tracks.size(); + const std::size_t Ntr = tracks.size(); for (auto &p : recoparticles) { // std::cout << " in VertexFitter: a recoparticle with charge = " << // p.charge << std::endl; - if (p.tracks_begin >= 0 && p.tracks_begin < thetracks.size()) { + if (p.tracks_begin < thetracks.size()) { reco_ind.push_back(p.tracks_begin); } } @@ -123,9 +124,9 @@ VertexFitter_Tk(int Primary, ROOT::VecOps::RVec tracks, // if the collection of all tracks has been passed, keep trace of the indices // of the tracks that are used to fit this vertex if (alltracks.size() > 0) { - for (int i = 0; i < tracks.size(); i++) { // the fitted tracks + for (std::size_t i = 0; i < tracks.size(); i++) { // the fitted tracks edm4hep::TrackState tr1 = tracks[i]; - for (int j = 0; j < alltracks.size(); + for (std::size_t j = 0; j < alltracks.size(); j++) { // the collection of all tracks edm4hep::TrackState tr2 = alltracks[j]; if (VertexingUtils::compare_Tracks(tr1, tr2)) { diff --git a/analyzers/dataframe/src/VertexingUtils.cc b/analyzers/dataframe/src/VertexingUtils.cc index f60ccfba7e9..a697f03961f 100644 --- a/analyzers/dataframe/src/VertexingUtils.cc +++ b/analyzers/dataframe/src/VertexingUtils.cc @@ -1,5 +1,6 @@ #include "FCCAnalyses/VertexingUtils.h" #include "FCCAnalyses/VertexFitterSimple.h" +#include #include "TrkUtil.h" // from delphes @@ -303,7 +304,7 @@ FCCAnalysesVertex get_FCCAnalysesVertex(ROOT::VecOps::RVec TheVertexColl, int index) { FCCAnalysesVertex result; - if (index < TheVertexColl.size()) + if (index >= 0 && static_cast(index) < TheVertexColl.size()) result = TheVertexColl.at(index); return result; } @@ -328,7 +329,7 @@ get_VertexData(ROOT::VecOps::RVec TheVertexColl) { edm4hep::VertexData get_VertexData(ROOT::VecOps::RVec TheVertexColl, int index) { edm4hep::VertexData result; - if (index < TheVertexColl.size()) + if (index >= 0 && static_cast(index) < TheVertexColl.size()) result = TheVertexColl.at(index).vertex; return result; } @@ -354,13 +355,14 @@ ROOT::VecOps::RVec get_VertexRecoParticlesInd( ROOT::VecOps::RVec result; ROOT::VecOps::RVec indices_tracks = TheVertex.reco_ind; - for (int i = 0; i < indices_tracks.size(); i++) { - int tk_index = indices_tracks[i]; - for (int j = 0; j < reco.size(); j++) { + for (std::size_t i = 0; i < indices_tracks.size(); i++) { + const int tk_index = indices_tracks[i]; + for (std::size_t j = 0; j < reco.size(); j++) { auto &p = reco[j]; if (p.tracks_begin == p.tracks_end) continue; - if (p.tracks_begin == tk_index) { + if (tk_index >= 0 && + p.tracks_begin == static_cast(tk_index)) { result.push_back(j); break; } @@ -473,7 +475,7 @@ double get_invM_pairs(FCCAnalysesVertex vertex, double m1, double m2) { double m[2] = {m1, m2}; int nTr = p_tracks.size(); - for (unsigned int i = 0; i < nTr; i++) { + for (int i = 0; i < nTr; i++) { TLorentzVector p4_tr; p4_tr.SetXYZM(p_tracks[i].X(), p_tracks[i].Y(), p_tracks[i].Z(), m[i]); p4_vtx += p4_tr; @@ -499,7 +501,7 @@ get_invM_pairs(ROOT::VecOps::RVec vertices, double m1, double m[2] = {m1, m2}; int nTr = p_tracks.size(); - for (unsigned int i = 0; i < nTr; i++) { + for (int i = 0; i < nTr; i++) { TLorentzVector p4_tr; p4_tr.SetXYZM(p_tracks[i].X(), p_tracks[i].Y(), p_tracks[i].Z(), m[i]); p4_vtx += p4_tr; @@ -938,16 +940,16 @@ get_relTheta_SV(ROOT::VecOps::RVec vertices, ROOT::VecOps::RVec jets) { ROOT::VecOps::RVec result; - unsigned int j = 0; - int nSV = nSV_jet[0]; - for (unsigned int i = 0; i < vertices.size(); i++) { + std::size_t j = 0; + std::size_t nSV = static_cast(nSV_jet[0]); + for (std::size_t i = 0; i < vertices.size(); i++) { auto &ivtx = vertices[i]; TVector3 xyz(ivtx.vertex.position[0], ivtx.vertex.position[1], ivtx.vertex.position[2]); if (i >= nSV) { j++; - nSV += nSV_jet[j]; + nSV += static_cast(nSV_jet[j]); } auto &ijet = jets[j]; double jetTheta = ijet.theta(); @@ -965,16 +967,16 @@ get_relPhi_SV(ROOT::VecOps::RVec vertices, ROOT::VecOps::RVec jets) { ROOT::VecOps::RVec result; - unsigned int j = 0; - int nSV = nSV_jet[0]; - for (unsigned int i = 0; i < vertices.size(); i++) { + std::size_t j = 0; + std::size_t nSV = static_cast(nSV_jet[0]); + for (std::size_t i = 0; i < vertices.size(); i++) { auto &ivtx = vertices[i]; TVector3 xyz(ivtx.vertex.position[0], ivtx.vertex.position[1], ivtx.vertex.position[2]); if (i >= nSV) { j++; - nSV += nSV_jet[j]; + nSV += static_cast(nSV_jet[j]); } auto &ijet = jets[j]; TVector3 jetP(ijet.px(), ijet.py(), ijet.pz()); @@ -1040,13 +1042,13 @@ std::vector> get_tracksInJets( int nJet = jets.size(); // - for (unsigned int j = 0; j < nJet; j++) { + for (int j = 0; j < nJet; j++) { std::vector i_jetconsti = jet_consti[j]; for (unsigned int ip : i_jetconsti) { auto &p = recoparticles[ip]; - if (p.tracks_begin >= 0 && p.tracks_begin < thetracks.size()) + if (p.tracks_begin < thetracks.size()) iJet_tracks.push_back(thetracks.at(p.tracks_begin)); } @@ -1422,7 +1424,6 @@ get_d3d_SV(ROOT::VecOps::RVec> vertices, ROOT::VecOps::RVec> get_position_SV( ROOT::VecOps::RVec> vertices) { ROOT::VecOps::RVec> result; - ROOT::VecOps::RVec i_result; for (unsigned int i = 0; i < vertices.size(); i++) { ROOT::VecOps::RVec i_result; diff --git a/analyzers/dataframe/src/WeaverUtils.cc b/analyzers/dataframe/src/WeaverUtils.cc index b7b6d0b2707..e0799464b1b 100644 --- a/analyzers/dataframe/src/WeaverUtils.cc +++ b/analyzers/dataframe/src/WeaverUtils.cc @@ -1,6 +1,7 @@ #include "FCCAnalyses/WeaverUtils.h" #include "ONNXRuntime/WeaverInterface.h" +#include #include namespace FCCAnalyses { @@ -46,9 +47,9 @@ namespace FCCAnalyses { throw std::runtime_error("Invalid index requested for object weight " + std::to_string(weight) + "."); ROOT::VecOps::RVec out; for (const auto& object_weights : objects_weights) { - if (weight >= object_weights.size()) + if (static_cast(weight) >= object_weights.size()) throw std::runtime_error("Flavour weight index exceeds the number of weights registered."); - out.emplace_back(object_weights.at(weight)); + out.emplace_back(object_weights.at(static_cast(weight))); } return out; } diff --git a/analyzers/dataframe/src/myFinalSel.cc b/analyzers/dataframe/src/myFinalSel.cc index 8983be2bedd..26087dcc06e 100644 --- a/analyzers/dataframe/src/myFinalSel.cc +++ b/analyzers/dataframe/src/myFinalSel.cc @@ -1,7 +1,8 @@ #include "FCCAnalyses/myFinalSel.h" -#include +#include #include +#include #include namespace FCCAnalyses{ @@ -90,7 +91,8 @@ float get_min(ROOT::VecOps::RVec in, for (size_t i = 0; i < in.size(); ++i){ if (ispv.at(i)>0)continue; - if (index==i)continue; + if (index >= 0 && static_cast(index) == i) + continue; if (in.at(i) in, for (size_t i = 0; i < in.size(); ++i){ if (ispv.at(i)>0)continue; - if (index==i)continue; + if (index >= 0 && static_cast(index) == i) + continue; if (in.at(i)>max)max=in.at(i); } return max; @@ -117,7 +120,8 @@ float get_ave(ROOT::VecOps::RVec in, float aven=0.; for (size_t i = 0; i < in.size(); ++i){ if (ispv.at(i)>0)continue; - if (index==i)continue; + if (index >= 0 && static_cast(index) == i) + continue; ave+=in.at(i); aven+=1.; diff --git a/analyzers/dataframe/src/myUtils.cc b/analyzers/dataframe/src/myUtils.cc index 4b919b1770b..1d54df513e0 100644 --- a/analyzers/dataframe/src/myUtils.cc +++ b/analyzers/dataframe/src/myUtils.cc @@ -1,8 +1,9 @@ #include "FCCAnalyses/myUtils.h" // std -#include +#include #include +#include #include // EDM4hep @@ -82,15 +83,6 @@ bool isPrimaryVtx(const edm4hep::VertexData& vertex) { #endif } -bool isPrimaryOrSecondaryVtx(const edm4hep::VertexData &vertex) { -#if EDM4HEP_BUILD_VERSION <= EDM4HEP_VERSION(0, 10, 5) - return vertex.primary > 0; -#else - return edm4hep::utils::checkAnyBits(vertex.type, - edm4hep::Vertex::BITPrimaryVertex, - edm4hep::Vertex::BITSecondaryVertex); -#endif -} } // namespace int get_PV_ntracks(ROOT::VecOps::RVec vertex){ @@ -507,10 +499,10 @@ ROOT::VecOps::RVec get_MCVertexObject(ROOT: if (result.size()==0){ VertexingUtils::FCCAnalysesVertexMC vertex; - ROOT::VecOps::RVec ind; - ind.push_back(tmpvecint.at(i)); + ROOT::VecOps::RVec vertexIndices; + vertexIndices.push_back(tmpvecint.at(i)); vertex.vertex=vertexPos; - vertex.mc_ind=ind; + vertex.mc_ind = vertexIndices; result.push_back(vertex); } else{ @@ -791,10 +783,11 @@ ROOT::VecOps::RVec getMC_daughter(int daughterindex, ROOT::VecOps::RVec ind){ ROOT::VecOps::RVec result; for (size_t i = 0; i < in.size(); ++i) { - if (daughterindex+1>in.at(i).daughters_end-in.at(i).daughters_begin) { + if (daughterindex < 0 || + static_cast(daughterindex) >= + in.at(i).daughters_end - in.at(i).daughters_begin) { result.push_back(-999); - } - else { + } else { result.push_back(ind.at(in.at(i).daughters_begin+daughterindex)); } } @@ -806,10 +799,10 @@ ROOT::VecOps::RVec getMC_parent(int parentindex, ROOT::VecOps::RVec ind){ ROOT::VecOps::RVec result; for (size_t i = 0; i < in.size(); ++i) { - if (parentindex+1>in.at(i).parents_end-in.at(i).parents_begin) { + if (parentindex < 0 || static_cast(parentindex) >= + in.at(i).parents_end - in.at(i).parents_begin) { result.push_back(-999); - } - else { + } else { result.push_back(ind.at(in.at(i).parents_begin+parentindex)); } } @@ -820,23 +813,21 @@ int getMC_parent(int parentindex, edm4hep::MCParticleData in, ROOT::VecOps::RVec ind){ int result; - if (parentindex+1>in.parents_end-in.parents_begin) + if (parentindex < 0 || static_cast(parentindex) >= + in.parents_end - in.parents_begin) result = -999; else result = ind.at(in.parents_begin+parentindex); return result; } - -ROOT::VecOps::RVec add_truthmatched(ROOT::VecOps::RVec comp, - ROOT::VecOps::RVec mc, - //ROOT::VecOps::RVec> rp2mc){ - ROOT::VecOps::RVec rp2mc, - ROOT::VecOps::RVec recop, - ROOT::VecOps::RVec ind){ - - - +ROOT::VecOps::RVec +add_truthmatched(ROOT::VecOps::RVec comp, + ROOT::VecOps::RVec mc, + // ROOT::VecOps::RVec> rp2mc){ + ROOT::VecOps::RVec rp2mc, + ROOT::VecOps::RVec, + ROOT::VecOps::RVec ind) { for (size_t i = 0; i < comp.size(); ++i) { //std::cout << "compo " << i << " charge " << comp.at(i).charge<< std::endl; @@ -850,9 +841,7 @@ ROOT::VecOps::RVec add_truthmatched(ROOT::VecOps::RVec add_truthmatched(ROOT::VecOps::RVec get_trueVertex(ROOT::VecOps::RVec vertex, ROOT::VecOps::RVec mc, ROOT::VecOps::RVec ind, @@ -924,13 +911,13 @@ ROOT::VecOps::RVec get_trueVertex(ROOT::VecOps::RVec add_truthmatched2(ROOT::VecOps::RVec comp, - ROOT::VecOps::RVec mc, - ROOT::VecOps::RVec vertex, - ROOT::VecOps::RVec rp2mc, - ROOT::VecOps::RVec recop, - ROOT::VecOps::RVec ind){ - +ROOT::VecOps::RVec +add_truthmatched2(ROOT::VecOps::RVec comp, + ROOT::VecOps::RVec mc, + ROOT::VecOps::RVec vertex, + ROOT::VecOps::RVec rp2mc, + ROOT::VecOps::RVec, + ROOT::VecOps::RVec ind) { for (size_t i = 0; i < comp.size(); ++i) { ROOT::VecOps::RVec index = vertex.at(comp.at(i).vertex).reco_ind; @@ -940,9 +927,7 @@ ROOT::VecOps::RVec add_truthmatched2(ROOT::VecOps::RVec in, for (auto & p: in) { bool found=false; for (size_t i = 0; i < index.size(); ++i) { - if (p.tracks_begin==index.at(i)){found=true; break;} + const int track_index = index.at(i); + if (track_index >= 0 && + p.tracks_begin == static_cast(track_index)) { + found = true; + break; + } } if (found==false && m_pv==false)result.push_back(p); else if (found==true && m_pv==true)result.push_back(p); @@ -1470,7 +1460,10 @@ ROOT::VecOps::RVec getFCCAnalysesComposite_vertex(ROOT::Vec bool isPV(edm4hep::ReconstructedParticleData recop, ROOT::VecOps::RVec pvindex){ for (size_t i = 0; i < pvindex.size(); ++i) { - if (recop.tracks_begin==pvindex.at(i))return true; + const int track_index = pvindex.at(i); + if (track_index >= 0 && + recop.tracks_begin == static_cast(track_index)) + return true; } return false; } @@ -1649,11 +1642,9 @@ ROOT::VecOps::RVec get_RP_atVertex(ROOT::Vec return recop; } - - - -float build_invmass(ROOT::VecOps::RVec recop, ROOT::VecOps::RVec index){ - float result=0; +float build_invmass( + ROOT::VecOps::RVec recop, + ROOT::VecOps::RVec index) { TLorentzVector tlv; for (size_t i=0;i recop return tlv.M(); } -TLorentzVector build_tlv(ROOT::VecOps::RVec recop, ROOT::VecOps::RVec index){ - float result=0; +TLorentzVector +build_tlv(ROOT::VecOps::RVec recop, + ROOT::VecOps::RVec index) { TLorentzVector tlv; for (size_t i=0;i return tlv; } - ROOT::VecOps::RVec build_tau23pi(ROOT::VecOps::RVec vertex, ROOT::VecOps::RVec recop){ @@ -1990,10 +1981,13 @@ ROOT::VecOps::RVec build_Bd2MuMu(ROOT::VecOps::RVec -build_tau23pi::operator() (ROOT::VecOps::RVec vertex, - ROOT::VecOps::RVec recop){ +sel_tau23pi::sel_tau23pi(float arg_masslow, float arg_masshigh, float arg_p, + float arg_angle, bool arg_rho) + : m_masslow(arg_masslow), m_masshigh(arg_masshigh), m_p(arg_p), + m_angle(arg_angle), m_rho(arg_rho) {}; +ROOT::VecOps::RVec sel_tau23pi::operator()( + ROOT::VecOps::RVec vertex, + ROOT::VecOps::RVec recop) { ROOT::VecOps::RVec result; //std::cout <<"n reco V " << vertex.size()< return result; } - - - ROOT::VecOps::RVec get_Vertex_thrusthemis_angle(ROOT::VecOps::RVec vertex, ROOT::VecOps::RVec recop, ROOT::VecOps::RVec thrust){ @@ -2259,9 +2250,13 @@ ROOT::VecOps::RVec get_mass(ROOT::VecOps::RVec result; + if (index < 0) + return result; + const auto particle_index = static_cast(index); for (auto &p:in){ - if (index>=p.size())continue; - result.push_back(p.at(index).mass); + if (particle_index >= p.size()) + continue; + result.push_back(p.at(particle_index).mass); } return result; } diff --git a/tests/integration/low_level_edm4hep.cxx b/tests/integration/low_level_edm4hep.cxx index 5297111e305..3d7f05d1b09 100644 --- a/tests/integration/low_level_edm4hep.cxx +++ b/tests/integration/low_level_edm4hep.cxx @@ -7,6 +7,8 @@ #include #include +#include + ROOT::VecOps::RVec selElectrons(ROOT::VecOps::RVec &inParticles) { ROOT::VecOps::RVec electrons; @@ -23,16 +25,16 @@ struct selPDG { selPDG(int pdg, bool chargeConjugateAllowed); const int m_pdg; const bool m_chargeConjugateAllowed; - ROOT::VecOps::RVec - operator()(ROOT::VecOps::RVec &inParticles); + std::vector operator()( + const ROOT::VecOps::RVec &inParticles) const; }; selPDG::selPDG(int pdg, bool chargeConjugateAllowed) : m_pdg(pdg), m_chargeConjugateAllowed(chargeConjugateAllowed){}; -ROOT::VecOps::RVec -selPDG::operator()(ROOT::VecOps::RVec &inParticles) { - ROOT::VecOps::RVec result; +std::vector selPDG::operator()( + const ROOT::VecOps::RVec &inParticles) const { + std::vector result; for (size_t i = 0; i < inParticles.size(); ++i) { auto &particle = inParticles[i]; if (m_chargeConjugateAllowed) { @@ -59,6 +61,16 @@ getPx(ROOT::VecOps::RVec inParticles) { return result; } +ROOT::VecOps::RVec +getPxStd(const std::vector &inParticles) { + ROOT::VecOps::RVec result; + for (const auto &p : inParticles) { + result.push_back(p.momentum.x); + } + + return result; +} + int main(int argc, const char *argv[]) { #if ROOT_VERSION_CODE >= ROOT_VERSION(6, 36, 0) auto verbosity = ROOT::RLogScopedVerbosity(ROOT::Detail::RDF::RDFLogChannel(), @@ -93,7 +105,7 @@ int main(int argc, const char *argv[]) { auto rdf2 = rdf.Define("particles_px", getPx, {"Particle"}); // auto rdf3 = rdf2.Define("electrons", selElectrons, {"MCParticles"}); auto rdf3 = rdf2.Define("electrons", selPDG(11, false), {"Particle"}); - auto rdf4 = rdf3.Define("electrons_px", getPx, {"electrons"}); + auto rdf4 = rdf3.Define("electrons_px", getPxStd, {"electrons"}); auto h_particles_px = rdf4.Histo1D("particles_px"); auto h_electrons_px = rdf4.Histo1D("electrons_px");