Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:20:54

0001 // Utilities.h
0002 
0003 #ifndef L1Trigger_L1TMuonEndCap_emtf_Utilities
0004 #define L1Trigger_L1TMuonEndCap_emtf_Utilities
0005 
0006 #include <vector>
0007 #include <string>
0008 #include <sstream>
0009 #include <algorithm>
0010 #include <utility>
0011 
0012 namespace emtf {
0013 
0014   //////////////////////////////////////////////////////////////////////////
0015   // ------------------Some Helpful Things----------------------------------
0016   //////////////////////////////////////////////////////////////////////////
0017 
0018   // Array of counts for error calculation.
0019   extern const double twoJets_scale[16];
0020   extern const std::vector<double> twoJetsScale;
0021 
0022   // Array of GeV values for error calculation.
0023   extern const double ptscale[31];
0024   extern const std::vector<double> ptScale;
0025 
0026   template <class bidiiter>
0027   bidiiter shuffle(bidiiter begin, bidiiter end, size_t num_random) {
0028     // We will end up with the same elements in the collection except that
0029     // the first num_random elements will be randomized.
0030 
0031     size_t left = std::distance(begin, end);
0032     while (num_random--) {
0033       bidiiter r = begin;
0034       std::advance(r, rand() % left);
0035       std::swap(*begin, *r);
0036       ++begin;
0037       --left;
0038     }
0039     return begin;
0040   }
0041 
0042   template <typename T>
0043   std::string numToStr(T num) {
0044     // Convert a number to a string.
0045     std::stringstream ss;
0046     ss << num;
0047     std::string s = ss.str();
0048     return s;
0049   };
0050 
0051   float processPrediction(float BDTPt, int Quality, float PrelimFit);
0052 
0053   void mergeNtuples(const char* ntuplename, const char* filestomerge, const char* outputfile);
0054 
0055   void sortNtupleByEvent(const char* ntuplename, const char* filenametosort, const char* outputfile);
0056 
0057 }  // namespace emtf
0058 
0059 #endif