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 /*
2  * \class L1TLSBlock
3  *
4  *
5  * Description: offline DQM class for LS blocking
6  *
7  * Implementation:
8  * <TODO: enter implementation details>
9  *
10  * \author: Pietro Vischia - LIP Lisbon pietro.vischia@gmail.com
11  *
12  * Changelog:
13  * 2012/10/23 12:01:01: Class
14  *
15  * Todo: see header file
16  *
17  * $Date: 2012/11/27 14:56:17 $
18  * $Revision: 1.1 $
19  *
20  */
21 
22 //
23 
24 // This class header
26 
27 // System include files
28 // --
29 
31 //#include "DQMServices/Core/interface/DQMStore.h"
32 //
33 //#include "DataFormats/Scalers/interface/LumiScalers.h"
34 //#include "DataFormats/Scalers/interface/Level1TriggerRates.h"
35 //#include "DataFormats/Scalers/interface/Level1TriggerScalers.h"
36 //
37 //#include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerReadoutRecord.h"
38 //#include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerEvmReadoutRecord.h"
39 //
40 //#include "DataFormats/Common/interface/ConditionsInEdm.h" // Parameters associated to Run, LS and Event
41 //
42 //#include "CondFormats/L1TObjects/interface/L1GtTriggerMenuFwd.h"
43 //#include "CondFormats/L1TObjects/interface/L1GtTriggerMenu.h"
44 //#include "CondFormats/L1TObjects/interface/L1GtPrescaleFactors.h"
45 //#include "CondFormats/DataRecord/interface/L1GtTriggerMenuRcd.h"
46 //#include "CondFormats/DataRecord/interface/L1GtPrescaleFactorsAlgoTrigRcd.h"
47 //#include "CondFormats/L1TObjects/interface/L1GtMuonTemplate.h"
52 //
55 //#include "DQMOffline/L1Trigger/interface/L1TMenuHelper.h"
56 //
57 //#include "TList.h"
58 
59 using namespace std;
60 
61 //-------------------------------------------------------------------------------------
62 //-------------------------------------------------------------------------------------
63 
65 
66  // Initialize LumiRangeList object. This will be redone at every doBlocking call. Perhaps rethink this
67  initializeIO(false);
68 
69 }
70 
71 //-------------------------------------------------------------------------------------
72 //-------------------------------------------------------------------------------------
73 
75 
76 //-------------------------------------------------------------------------------------
77 //-------------------------------------------------------------------------------------
78 
80 {
81  inputDoubleList_ = inputList;
82  thresholdD_ = threshold;
83 
84  initializeIO(true);
85 
86  orderTestDoubleList();
87 
88  switch(blockingMethod){
89  case STATISTICS:
90  blockByStatistics();
91  break;
92  default:
93  cout << "[L1TLSBlock::doBlocking()]: Blocking method does not exist or is not implemented" << endl;
94  }
95 
96 
97  return outputList_;
98 }
99 
100 //-------------------------------------------------------------------------------------
101 //-------------------------------------------------------------------------------------
102 
104 {
105  inputIntList_ = inputList;
106  thresholdI_ = threshold;
107 
108  initializeIO(true);
109 
110  orderTestIntList();
111 
112  switch(blockingMethod){
113  case STATISTICS:
114  cout << "[L1TLSBlock::doBlocking()]: Blocking by statistics require doubles as inputs for test variable and threshold" << endl;
115  break;
116  default:
117  cout << "[L1TLSBlock::doBlocking()]: Blocking method does not exist or is not implemented" << endl;
118  }
119 
120  return outputList_;
121 }
122 
123 //-------------------------------------------------------------------------------------
124 //-------------------------------------------------------------------------------------
125 
126 void L1TLSBlock::initializeIO(bool outputOnly){
127  if(!outputOnly){
128  inputIntList_.clear();
129  inputDoubleList_.clear();
130  }
131  outputList_.clear();
132 }
133 
134 //-------------------------------------------------------------------------------------
135 //-------------------------------------------------------------------------------------
136 
138  std::sort(inputDoubleList_.begin(), inputDoubleList_.end(), sort_pair_first<int, double>());
139  // std::sort(v.begin(), v.end(), sort_pair_second<int, std::greater<int> >());
140 }
141 
142 //-------------------------------------------------------------------------------------
143 //-------------------------------------------------------------------------------------
144 
146  std::sort(inputIntList_.begin(), inputIntList_.end(), sort_pair_first<int, int>());
147 }
148 
149 //-------------------------------------------------------------------------------------
150 //-------------------------------------------------------------------------------------
151 
153  LumiRange currentRange;
154  double currentError(0);
155  bool resetFlag(true);
156 
157  for(LumiTestDoubleList::iterator i=inputDoubleList_.begin(); i!=inputDoubleList_.end(); i++){
158  if(resetFlag){
159  currentRange = std::make_pair(i->first,i->first);
160  resetFlag = false;
161  }
162  else
163  currentRange = std::make_pair(currentRange.first,i->first);
164  currentError = computeErrorFromRange(currentRange);
165  if(currentError < thresholdD_){
166  outputList_.push_back(currentRange);
167  resetFlag = true;
168  }
169 
170  }
171 }
172 
174  std::vector<double> errorList;
175  errorList.clear();
176 
177  for(size_t i=0; i < inputDoubleList_.size(); i++){
178  if(inputDoubleList_[i].first>lumiRange.first && inputDoubleList_[i].first<lumiRange.second)
179  errorList.push_back(inputDoubleList_[i].second);
180  }
181 
182  double error(-1);
183  for(size_t i=0; i<errorList.size(); i++)
184  error += 1 / (errorList[i] * errorList[i] );
185  return error;
186 
187 }
int i
Definition: DBlmapReader.cc:9
void blockByStatistics()
Definition: L1TLSBlock.cc:152
void orderTestIntList()
Definition: L1TLSBlock.cc:145
std::vector< LumiRange > LumiRangeList
Definition: L1TLSBlock.h:81
U second(std::pair< T, U > const &p)
virtual ~L1TLSBlock()
Definition: L1TLSBlock.cc:74
LumiRangeList doBlocking(LumiTestDoubleList, double, BLOCKBY)
Definition: L1TLSBlock.cc:79
std::pair< int, int > LumiRange
Definition: L1TLSBlock.h:80
std::vector< std::pair< int, double > > LumiTestDoubleList
Definition: L1TLSBlock.h:78
bool first
Definition: L1TdeRCT.cc:94
double computeErrorFromRange(LumiRange &)
Definition: L1TLSBlock.cc:173
std::vector< std::pair< int, double > > LumiTestIntList
Definition: L1TLSBlock.h:79
void orderTestDoubleList()
Definition: L1TLSBlock.cc:137
void initializeIO(bool)
Definition: L1TLSBlock.cc:126
tuple cout
Definition: gather_cfg.py:121