Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:02:28

0001 /****************************************************************************
0002  * Authors:
0003  *   Jan Kašpar
0004  *   Grzegorz Sroka
0005  ****************************************************************************/
0006 
0007 #ifndef CondFormats_PPSObjects_PPSAssociationCuts_h
0008 #define CondFormats_PPSObjects_PPSAssociationCuts_h
0009 
0010 struct TF1;
0011 
0012 #include "CondFormats/Serialization/interface/Serializable.h"
0013 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0014 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
0015 #include "FWCore/Utilities/interface/Exception.h"
0016 
0017 #include <iostream>
0018 #include <memory>
0019 #include <cmath>
0020 #include <vector>
0021 
0022 class PPSAssociationCuts {
0023 public:
0024   class CutsPerArm {
0025   public:
0026     enum Quantities { qX, qY, qXi, qThetaY };
0027 
0028     CutsPerArm() {}
0029 
0030     CutsPerArm(const edm::ParameterSet &iConfig, int sector);
0031 
0032     ~CutsPerArm() {}
0033 
0034     const std::vector<std::string> &getMeans() const { return s_means_; }
0035     const std::vector<std::string> &getThresholds() const { return s_thresholds_; }
0036 
0037     double getTiTrMin() const { return ti_tr_min_; }
0038     double getTiTrMax() const { return ti_tr_max_; }
0039 
0040     // build TF1 representations of the mean and threshold functions
0041     void buildFunctions();
0042 
0043     // returns whether the specified cut is applied
0044     bool isApplied(Quantities quantity) const;
0045 
0046     // returns whether if the specified cut is satisfied (for a particular event)
0047     bool isSatisfied(Quantities quantity, double x_near, double y_near, double xangle, double q_NF_diff) const;
0048 
0049   protected:
0050     // string representation of the cut parameters - for serialisation
0051     std::vector<std::string> s_means_;
0052     std::vector<std::string> s_thresholds_;
0053 
0054     // TF1 representation of the cut parameters - for run time evaluations
0055     std::vector<std::shared_ptr<TF1> > f_means_ COND_TRANSIENT;
0056     std::vector<std::shared_ptr<TF1> > f_thresholds_ COND_TRANSIENT;
0057 
0058     // timing-tracking cuts
0059     double ti_tr_min_;
0060     double ti_tr_max_;
0061 
0062     static double evaluateExpression(std::shared_ptr<TF1> expression, double x_near, double y_near, double xangle);
0063 
0064     COND_SERIALIZABLE;
0065   };
0066 
0067   PPSAssociationCuts() {}
0068 
0069   PPSAssociationCuts(const edm::ParameterSet &iConfig);
0070 
0071   ~PPSAssociationCuts() {}
0072 
0073   // checks if the data have a valid structure
0074   bool isValid() const;
0075 
0076   // builds run-time data members, useful e.g. after loading data from DB
0077   void initialize();
0078 
0079   const CutsPerArm &getAssociationCuts(const int sector) const { return association_cuts_.find(sector)->second; }
0080 
0081   static edm::ParameterSetDescription getDefaultParameters();
0082 
0083 private:
0084   std::map<unsigned int, CutsPerArm> association_cuts_;
0085 
0086   COND_SERIALIZABLE;
0087 };
0088 
0089 //----------------------------------------------------------------------------------------------------
0090 
0091 std::ostream &operator<<(std::ostream &os, const PPSAssociationCuts::CutsPerArm &cutsPerArm);
0092 
0093 std::ostream &operator<<(std::ostream &os, const PPSAssociationCuts &ppsAssociationCuts);
0094 
0095 #endif