CMS 3D CMS Logo

L1TLSBlock.cc
Go to the documentation of this file.
1 
20 //
21 
22 // This class header
24 
25 // System include files
26 // --
27 
29 //#include "DQMServices/Core/interface/DQMStore.h"
30 //
31 //#include "DataFormats/Scalers/interface/LumiScalers.h"
32 //#include "DataFormats/Scalers/interface/Level1TriggerRates.h"
33 //#include "DataFormats/Scalers/interface/Level1TriggerScalers.h"
34 //
35 //#include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerReadoutRecord.h"
36 //#include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerEvmReadoutRecord.h"
37 //
38 //#include "DataFormats/Common/interface/ConditionsInEdm.h" // Parameters associated to Run, LS and Event
39 //
40 //#include "CondFormats/L1TObjects/interface/L1GtTriggerMenuFwd.h"
41 //#include "CondFormats/L1TObjects/interface/L1GtTriggerMenu.h"
42 //#include "CondFormats/L1TObjects/interface/L1GtPrescaleFactors.h"
43 //#include "CondFormats/DataRecord/interface/L1GtTriggerMenuRcd.h"
44 //#include "CondFormats/DataRecord/interface/L1GtPrescaleFactorsAlgoTrigRcd.h"
45 //#include "CondFormats/L1TObjects/interface/L1GtMuonTemplate.h"
50 //
53 //#include "DQMOffline/L1Trigger/interface/L1TMenuHelper.h"
54 //
55 //#include "TList.h"
56 
57 using namespace std;
58 
59 //-------------------------------------------------------------------------------------
60 //-------------------------------------------------------------------------------------
61 
63  // Initialize LumiRangeList object. This will be redone at every doBlocking call. Perhaps rethink this
64  initializeIO(false);
65 }
66 
67 //-------------------------------------------------------------------------------------
68 //-------------------------------------------------------------------------------------
69 
71 
72 //-------------------------------------------------------------------------------------
73 //-------------------------------------------------------------------------------------
74 
76  double threshold,
77  BLOCKBY blockingMethod) {
78  inputDoubleList_ = inputList;
79  thresholdD_ = threshold;
80 
81  initializeIO(true);
82 
83  orderTestDoubleList();
84 
85  switch (blockingMethod) {
86  case STATISTICS:
87  blockByStatistics();
88  break;
89  default:
90  cout << "[L1TLSBlock::doBlocking()]: Blocking method does not exist or is not implemented" << endl;
91  }
92 
93  return outputList_;
94 }
95 
96 //-------------------------------------------------------------------------------------
97 //-------------------------------------------------------------------------------------
98 
100  int threshold,
101  BLOCKBY blockingMethod) {
102  inputIntList_ = inputList;
103  thresholdI_ = threshold;
104 
105  initializeIO(true);
106 
107  orderTestIntList();
108 
109  switch (blockingMethod) {
110  case STATISTICS:
111  cout << "[L1TLSBlock::doBlocking()]: Blocking by statistics require doubles as inputs for test variable and "
112  "threshold"
113  << endl;
114  break;
115  default:
116  cout << "[L1TLSBlock::doBlocking()]: Blocking method does not exist or is not implemented" << endl;
117  }
118 
119  return outputList_;
120 }
121 
122 //-------------------------------------------------------------------------------------
123 //-------------------------------------------------------------------------------------
124 
125 void L1TLSBlock::initializeIO(bool outputOnly) {
126  if (!outputOnly) {
127  inputIntList_.clear();
128  inputDoubleList_.clear();
129  }
130  outputList_.clear();
131 }
132 
133 //-------------------------------------------------------------------------------------
134 //-------------------------------------------------------------------------------------
135 
137  std::sort(inputDoubleList_.begin(), inputDoubleList_.end(), sort_pair_first<int, double>());
138  // std::sort(v.begin(), v.end(), sort_pair_second<int, std::greater<int> >());
139 }
140 
141 //-------------------------------------------------------------------------------------
142 //-------------------------------------------------------------------------------------
143 
145  std::sort(inputIntList_.begin(), inputIntList_.end(), sort_pair_first<int, int>());
146 }
147 
148 //-------------------------------------------------------------------------------------
149 //-------------------------------------------------------------------------------------
150 
152  LumiRange currentRange;
153  double currentError(0);
154  bool resetFlag(true);
155 
156  for (LumiTestDoubleList::iterator i = inputDoubleList_.begin(); i != inputDoubleList_.end(); i++) {
157  if (resetFlag) {
158  currentRange = std::make_pair(i->first, i->first);
159  resetFlag = false;
160  } else
161  currentRange = std::make_pair(currentRange.first, i->first);
162  currentError = computeErrorFromRange(currentRange);
163  if (currentError < thresholdD_) {
164  outputList_.push_back(currentRange);
165  resetFlag = true;
166  }
167  }
168 }
169 
171  std::vector<double> errorList;
172  errorList.clear();
173 
174  for (size_t i = 0; i < inputDoubleList_.size(); i++) {
175  if (inputDoubleList_[i].first > lumiRange.first && inputDoubleList_[i].first < lumiRange.second)
176  errorList.push_back(inputDoubleList_[i].second);
177  }
178 
179  double error(-1);
180  for (size_t i = 0; i < errorList.size(); i++)
181  error += 1 / (errorList[i] * errorList[i]);
182  return error;
183 }
void blockByStatistics()
Definition: L1TLSBlock.cc:151
void orderTestIntList()
Definition: L1TLSBlock.cc:144
std::vector< LumiRange > LumiRangeList
Definition: L1TLSBlock.h:75
std::vector< std::pair< int, double > > LumiTestIntList
Definition: L1TLSBlock.h:73
U second(std::pair< T, U > const &p)
virtual ~L1TLSBlock()
Definition: L1TLSBlock.cc:70
LumiRangeList doBlocking(const LumiTestDoubleList &, double, BLOCKBY)
Definition: L1TLSBlock.cc:75
std::pair< int, int > LumiRange
Definition: L1TLSBlock.h:74
string inputList
Definition: crabTemplate.py:6
double computeErrorFromRange(LumiRange &)
Definition: L1TLSBlock.cc:170
void orderTestDoubleList()
Definition: L1TLSBlock.cc:136
void initializeIO(bool)
Definition: L1TLSBlock.cc:125
std::vector< std::pair< int, double > > LumiTestDoubleList
Definition: L1TLSBlock.h:72