CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 
64  // Initialize LumiRangeList object. This will be redone at every doBlocking call. Perhaps rethink this
65  initializeIO(false);
66 
67 }
68 
69 //-------------------------------------------------------------------------------------
70 //-------------------------------------------------------------------------------------
71 
73 
74 //-------------------------------------------------------------------------------------
75 //-------------------------------------------------------------------------------------
76 
78 {
79  inputDoubleList_ = inputList;
80  thresholdD_ = threshold;
81 
82  initializeIO(true);
83 
84  orderTestDoubleList();
85 
86  switch(blockingMethod){
87  case STATISTICS:
88  blockByStatistics();
89  break;
90  default:
91  cout << "[L1TLSBlock::doBlocking()]: Blocking method does not exist or is not implemented" << endl;
92  }
93 
94 
95  return outputList_;
96 }
97 
98 //-------------------------------------------------------------------------------------
99 //-------------------------------------------------------------------------------------
100 
102 {
103  inputIntList_ = inputList;
104  thresholdI_ = threshold;
105 
106  initializeIO(true);
107 
108  orderTestIntList();
109 
110  switch(blockingMethod){
111  case STATISTICS:
112  cout << "[L1TLSBlock::doBlocking()]: Blocking by statistics require doubles as inputs for test variable and threshold" << endl;
113  break;
114  default:
115  cout << "[L1TLSBlock::doBlocking()]: Blocking method does not exist or is not implemented" << endl;
116  }
117 
118  return outputList_;
119 }
120 
121 //-------------------------------------------------------------------------------------
122 //-------------------------------------------------------------------------------------
123 
124 void L1TLSBlock::initializeIO(bool outputOnly){
125  if(!outputOnly){
126  inputIntList_.clear();
127  inputDoubleList_.clear();
128  }
129  outputList_.clear();
130 }
131 
132 //-------------------------------------------------------------------------------------
133 //-------------------------------------------------------------------------------------
134 
136  std::sort(inputDoubleList_.begin(), inputDoubleList_.end(), sort_pair_first<int, double>());
137  // std::sort(v.begin(), v.end(), sort_pair_second<int, std::greater<int> >());
138 }
139 
140 //-------------------------------------------------------------------------------------
141 //-------------------------------------------------------------------------------------
142 
144  std::sort(inputIntList_.begin(), inputIntList_.end(), sort_pair_first<int, int>());
145 }
146 
147 //-------------------------------------------------------------------------------------
148 //-------------------------------------------------------------------------------------
149 
151  LumiRange currentRange;
152  double currentError(0);
153  bool resetFlag(true);
154 
155  for(LumiTestDoubleList::iterator i=inputDoubleList_.begin(); i!=inputDoubleList_.end(); i++){
156  if(resetFlag){
157  currentRange = std::make_pair(i->first,i->first);
158  resetFlag = false;
159  }
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 }
170 
172  std::vector<double> errorList;
173  errorList.clear();
174 
175  for(size_t i=0; i < inputDoubleList_.size(); i++){
176  if(inputDoubleList_[i].first>lumiRange.first && inputDoubleList_[i].first<lumiRange.second)
177  errorList.push_back(inputDoubleList_[i].second);
178  }
179 
180  double error(-1);
181  for(size_t i=0; i<errorList.size(); i++)
182  error += 1 / (errorList[i] * errorList[i] );
183  return error;
184 
185 }
int i
Definition: DBlmapReader.cc:9
void blockByStatistics()
Definition: L1TLSBlock.cc:150
void orderTestIntList()
Definition: L1TLSBlock.cc:143
std::vector< LumiRange > LumiRangeList
Definition: L1TLSBlock.h:79
U second(std::pair< T, U > const &p)
virtual ~L1TLSBlock()
Definition: L1TLSBlock.cc:72
std::pair< int, int > LumiRange
Definition: L1TLSBlock.h:78
LumiRangeList doBlocking(const LumiTestDoubleList &, double, BLOCKBY)
Definition: L1TLSBlock.cc:77
std::vector< std::pair< int, double > > LumiTestDoubleList
Definition: L1TLSBlock.h:76
bool first
Definition: L1TdeRCT.cc:75
double computeErrorFromRange(LumiRange &)
Definition: L1TLSBlock.cc:171
std::vector< std::pair< int, double > > LumiTestIntList
Definition: L1TLSBlock.h:77
void orderTestDoubleList()
Definition: L1TLSBlock.cc:135
void initializeIO(bool)
Definition: L1TLSBlock.cc:124
tuple cout
Definition: gather_cfg.py:121