diff --git a/examples/config/my_combined_config_file.yaml b/examples/config/my_combined_config_file.yaml index d26e29bc..eb5f5252 100644 --- a/examples/config/my_combined_config_file.yaml +++ b/examples/config/my_combined_config_file.yaml @@ -23,18 +23,15 @@ clas12::ZVertexFilter: # default cuts - default: - pids: [ 11 ] - cuts: [ -33.0, 11.0 ] + electron_vz: [ -33.0, 11.0 ] #RG-A fall2018 inbending - runs: [ 4760, 5419 ] - pids: [ 11 ] - cuts: [ -13.0, 12.0 ] + electron_vz: [ -13.0, 12.0 ] #RG-A fall2018 outbending - runs: [ 5420, 5674 ] - pids: [ 11 ] - cuts: [ -18.0, 10.0 ] + electron_vz: [ -18.0, 10.0 ] another::Algorithm: #Cuts below are just examples: diff --git a/examples/config/my_config_directory/algorithms/clas12/ZVertexFilter/Config.yaml b/examples/config/my_config_directory/algorithms/clas12/ZVertexFilter/Config.yaml index 9082fbdb..411b1103 100644 --- a/examples/config/my_config_directory/algorithms/clas12/ZVertexFilter/Config.yaml +++ b/examples/config/my_config_directory/algorithms/clas12/ZVertexFilter/Config.yaml @@ -3,15 +3,12 @@ clas12::ZVertexFilter: # default cuts - default: - pids: [ 11 ] - cuts: [ -15.0, 15.0 ] + electron_vz: [ -15.0, 15.0 ] # RG-A fall2018 inbending - runs: [ 4760, 5419 ] - pids: [ 11 ] - cuts: [ -5.0, 3.0 ] + electron_vz: [ -5.0, 3.0 ] # RG-A fall2018 outbending - runs: [ 5420, 5674 ] - pids: [ 11 ] - cuts: [ -8.0, 7.0 ] + electron_vz: [ -8.0, 7.0 ] diff --git a/examples/config/my_z_vertex_cuts.yaml b/examples/config/my_z_vertex_cuts.yaml index a90185af..8d5d8e37 100644 --- a/examples/config/my_z_vertex_cuts.yaml +++ b/examples/config/my_z_vertex_cuts.yaml @@ -3,15 +3,12 @@ clas12::ZVertexFilter: # default cuts - default: - pids: [ 11 ] - cuts: [ -1.5, 1.3 ] + electron_vz: [ -1.5, 1.3 ] # RG-A fall2018 inbending - runs: [ 4760, 5419 ] - pids: [ 11 ] - cuts: [ -0.5, 0.5 ] + electron_vz: [ -0.5, 0.5 ] # RG-A fall2018 outbending - runs: [ 5420, 5674 ] - pids: [ 11 ] - cuts: [ -0.8, 0.7 ] + electron_vz: [ -0.8, 0.7 ] diff --git a/examples/iguana_ex_cpp_config_files.cc b/examples/iguana_ex_cpp_config_files.cc index 95e18be0..ded2a4c5 100644 --- a/examples/iguana_ex_cpp_config_files.cc +++ b/examples/iguana_ex_cpp_config_files.cc @@ -47,22 +47,22 @@ int main(int argc, char** argv) algo->Start(); auto key = algo->PrepareEvent(4800); // sets the run number and loads the cuts assert((algo->GetRunNum(key) == 4800)); // pass the key into the 'Get*' methods - assert((algo->GetZcuts(key).at(0) == -13.0)); - assert((algo->GetZcuts(key).at(1) == 12.0)); + assert((algo->GetElectronZcuts(key).at(0) == -13.0)); + assert((algo->GetElectronZcuts(key).at(1) == 12.0)); break; } case 2: { - // Use `SetZcuts` to set the cuts + // Use `SetElectronZcuts` to set the cuts // - note that this will OVERRIDE any value used in any configuration file - // - only use `SetZcuts` if for any reason you want to hard-code a specific value; usage + // - only use `SetElectronZcuts` if for any reason you want to hard-code a specific value; usage // of configuration files is preferred in general algo->Start(); - iguana::concurrent_key_t const key = 0; // need the same key in `SetZcuts` and `GetZcuts` - algo->SetZcuts(-5.0, 3.0, key); - assert((algo->GetZcuts(key).at(0) == -5.0)); - assert((algo->GetZcuts(key).at(1) == 3.0)); + iguana::concurrent_key_t const key = 0; // need the same key in `SetElectronZcuts` and `GetElectronZcuts` + algo->SetElectronZcuts(-5.0, 3.0, key); + assert((algo->GetElectronZcuts(key).at(0) == -5.0)); + assert((algo->GetElectronZcuts(key).at(1) == 3.0)); break; } @@ -72,8 +72,8 @@ int main(int argc, char** argv) algo->SetConfigFile(configDir + "/my_z_vertex_cuts.yaml"); algo->Start(); auto key = algo->PrepareEvent(5500); - assert((algo->GetZcuts(key).at(0) == -0.8)); - assert((algo->GetZcuts(key).at(1) == 0.7)); + assert((algo->GetElectronZcuts(key).at(0) == -0.8)); + assert((algo->GetElectronZcuts(key).at(1) == 0.7)); break; } @@ -85,8 +85,8 @@ int main(int argc, char** argv) algo->SetConfigFile("my_z_vertex_cuts.yaml"); algo->Start(); auto key = algo->PrepareEvent(0); // run number "0" means "no run number" - assert((algo->GetZcuts(key).at(0) == -1.5)); - assert((algo->GetZcuts(key).at(1) == 1.3)); + assert((algo->GetElectronZcuts(key).at(0) == -1.5)); + assert((algo->GetElectronZcuts(key).at(1) == 1.3)); break; } @@ -99,8 +99,8 @@ int main(int argc, char** argv) algo->SetConfigDirectory(configDir + "/my_config_directory"); algo->Start(); auto key = algo->PrepareEvent(0); // run number "0" means "no run number" - assert((algo->GetZcuts(key).at(0) == -15.0)); - assert((algo->GetZcuts(key).at(1) == 15.0)); + assert((algo->GetElectronZcuts(key).at(0) == -15.0)); + assert((algo->GetElectronZcuts(key).at(1) == 15.0)); break; } @@ -111,8 +111,8 @@ int main(int argc, char** argv) algo->SetConfigFile("my_combined_config_file.yaml"); algo->Start(); auto key = algo->PrepareEvent(0); // run number "0" means "no run number" - assert((algo->GetZcuts(key).at(0) == -33.0)); - assert((algo->GetZcuts(key).at(1) == 11.0)); + assert((algo->GetElectronZcuts(key).at(0) == -33.0)); + assert((algo->GetElectronZcuts(key).at(1) == 11.0)); break; } diff --git a/src/iguana/algorithms/clas12/ZVertexFilter/Algorithm.cc b/src/iguana/algorithms/clas12/ZVertexFilter/Algorithm.cc index dda42173..8ef755df 100644 --- a/src/iguana/algorithms/clas12/ZVertexFilter/Algorithm.cc +++ b/src/iguana/algorithms/clas12/ZVertexFilter/Algorithm.cc @@ -1,4 +1,5 @@ #include "Algorithm.h" +#include "iguana/algorithms/TypeDefs.h" namespace iguana::clas12 { @@ -10,7 +11,7 @@ namespace iguana::clas12 { // get configuration ParseYAMLConfig(); o_runnum = ConcurrentParamFactory::Create(); - o_zcuts = ConcurrentParamFactory::Create>(); + o_electron_vz_cuts = ConcurrentParamFactory::Create>(); // get expected bank indices b_particle = GetBankIndex(banks, "REC::Particle"); @@ -63,25 +64,16 @@ namespace iguana::clas12 { std::lock_guard const lock(m_mutex); // NOTE: be sure to lock successive `ConcurrentParam::Save` calls !!! m_log->Trace("-> calling Reload({}, {})", runnum, key); o_runnum->Save(runnum, key); - o_zcuts->Save(GetOptionVector("cuts", {GetConfig()->InRange("runs", runnum), "cuts"}), key); - // FIXME: handle PIDs + o_electron_vz_cuts->Save(GetOptionVector("electron_vz", {GetConfig()->InRange("runs", runnum), "electron_vz"}), key); } bool ZVertexFilter::Filter(double const zvertex, int const pid, int const status, concurrent_key_t key) const { - auto zcuts = GetZcuts(key); - return zvertex > zcuts.at(0) && zvertex < zcuts.at(1); - - // FIXME - // FIXME - // FIXME - // //only apply filter if particle pid is in list of pids - // //and particles not in FT (ie FD or CD) - // if(o_pids.find(pid) != o_pids.end() && abs(status)>=2000) { - // return zvertex > GetZcutLower() && zvertex < GetZcutUpper(); - // } else { - // return true; - // } + if(pid == particle::PDG::electron && abs(status) >= 2000) { + auto zcuts = GetElectronZcuts(key); + return zvertex > zcuts.at(0) && zvertex < zcuts.at(1); + } + return true; // cuts don't apply } int ZVertexFilter::GetRunNum(concurrent_key_t const key) const @@ -89,14 +81,14 @@ namespace iguana::clas12 { return o_runnum->Load(key); } - std::vector ZVertexFilter::GetZcuts(concurrent_key_t const key) const + std::vector ZVertexFilter::GetElectronZcuts(concurrent_key_t const key) const { - return o_zcuts->Load(key); + return o_electron_vz_cuts->Load(key); } - void ZVertexFilter::SetZcuts(double zcut_lower, double zcut_upper, concurrent_key_t const key) + void ZVertexFilter::SetElectronZcuts(double zcut_lower, double zcut_upper, concurrent_key_t const key) { - o_zcuts->Save({zcut_lower, zcut_upper}, key); + o_electron_vz_cuts->Save({zcut_lower, zcut_upper}, key); } void ZVertexFilter::Stop() diff --git a/src/iguana/algorithms/clas12/ZVertexFilter/Algorithm.h b/src/iguana/algorithms/clas12/ZVertexFilter/Algorithm.h index ddea6da5..32bbd606 100644 --- a/src/iguana/algorithms/clas12/ZVertexFilter/Algorithm.h +++ b/src/iguana/algorithms/clas12/ZVertexFilter/Algorithm.h @@ -13,7 +13,7 @@ namespace iguana::clas12 { /// @end_doc /// /// @begin_doc_config - /// @config_param{cuts | list[double] | lower and upper @f$z@f$-vertex cuts; run-range dependent} + /// @config_param{electron_vz | list[double] | lower and upper electron @f$z@f$-vertex cuts; run-range dependent; cuts are not applied to FT electrons (FD and CD only)} /// @end_doc class ZVertexFilter : public Algorithm { @@ -48,15 +48,15 @@ namespace iguana::clas12 { /// @param key the return value of `::PrepareEvent` /// @returns the current z-vertex cuts - std::vector GetZcuts(concurrent_key_t const key) const; + std::vector GetElectronZcuts(concurrent_key_t const key) const; /// @brief sets the z-vertex cuts /// @warning this method is not thread safe; instead, for thread safety, /// use `::PrepareEvent` and a custom configuration file. /// @param zcut_lower the lower bound of the cut /// @param zcut_upper the upper bound of the cut - /// @param key the, for `::GetZcuts` - void SetZcuts(double zcut_lower, double zcut_upper, concurrent_key_t const key); + /// @param key the, for `::GetElectronZcuts` + void SetElectronZcuts(double zcut_lower, double zcut_upper, concurrent_key_t const key); private: hipo::banklist::size_type b_particle, b_config; @@ -67,11 +67,9 @@ namespace iguana::clas12 { /// Run number mutable std::unique_ptr> o_runnum; - /// Z-vertex cut - mutable std::unique_ptr>> o_zcuts; + /// Electron Z-vertex cuts + mutable std::unique_ptr>> o_electron_vz_cuts; - /// pids to apply ZVertexFilter to - std::set o_pids; }; } diff --git a/src/iguana/algorithms/clas12/ZVertexFilter/Config.yaml b/src/iguana/algorithms/clas12/ZVertexFilter/Config.yaml index ee02020d..557f9d33 100644 --- a/src/iguana/algorithms/clas12/ZVertexFilter/Config.yaml +++ b/src/iguana/algorithms/clas12/ZVertexFilter/Config.yaml @@ -3,15 +3,12 @@ clas12::ZVertexFilter: # default cuts - default: - pids: [ 11 ] - cuts: [ -20.0, 20.0 ] + electron_vz: [ -20.0, 20.0 ] # RG-A fall2018 inbending - runs: [ 4760, 5419 ] - pids: [ 11 ] - cuts: [ -13.0, 12.0 ] + electron_vz: [ -13.0, 12.0 ] # RG-A fall2018 outbending - runs: [ 5420, 5674 ] - pids: [ 11 ] - cuts: [ -18.0, 10.0 ] + electron_vz: [ -18.0, 10.0 ]