Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include "DQMOffline/L1Trigger/interface/L1TLSBlock.h"
00026
00027
00028
00029
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00052
00055
00056
00057
00058
00059 using namespace std;
00060
00061
00062
00063
00064 L1TLSBlock::L1TLSBlock(){
00065
00066
00067 initializeIO(false);
00068
00069 }
00070
00071
00072
00073
00074 L1TLSBlock::~L1TLSBlock(){}
00075
00076
00077
00078
00079 L1TLSBlock::LumiRangeList L1TLSBlock::doBlocking(LumiTestDoubleList inputList, double threshold, BLOCKBY blockingMethod)
00080 {
00081 inputDoubleList_ = inputList;
00082 thresholdD_ = threshold;
00083
00084 initializeIO(true);
00085
00086 orderTestDoubleList();
00087
00088 switch(blockingMethod){
00089 case STATISTICS:
00090 blockByStatistics();
00091 break;
00092 default:
00093 cout << "[L1TLSBlock::doBlocking()]: Blocking method does not exist or is not implemented" << endl;
00094 }
00095
00096
00097 return outputList_;
00098 }
00099
00100
00101
00102
00103 L1TLSBlock::LumiRangeList L1TLSBlock::doBlocking(LumiTestIntList inputList, int threshold, BLOCKBY blockingMethod)
00104 {
00105 inputIntList_ = inputList;
00106 thresholdI_ = threshold;
00107
00108 initializeIO(true);
00109
00110 orderTestIntList();
00111
00112 switch(blockingMethod){
00113 case STATISTICS:
00114 cout << "[L1TLSBlock::doBlocking()]: Blocking by statistics require doubles as inputs for test variable and threshold" << endl;
00115 break;
00116 default:
00117 cout << "[L1TLSBlock::doBlocking()]: Blocking method does not exist or is not implemented" << endl;
00118 }
00119
00120 return outputList_;
00121 }
00122
00123
00124
00125
00126 void L1TLSBlock::initializeIO(bool outputOnly){
00127 if(!outputOnly){
00128 inputIntList_.clear();
00129 inputDoubleList_.clear();
00130 }
00131 outputList_.clear();
00132 }
00133
00134
00135
00136
00137 void L1TLSBlock::orderTestDoubleList(){
00138 std::sort(inputDoubleList_.begin(), inputDoubleList_.end(), sort_pair_first<int, double>());
00139
00140 }
00141
00142
00143
00144
00145 void L1TLSBlock::orderTestIntList(){
00146 std::sort(inputIntList_.begin(), inputIntList_.end(), sort_pair_first<int, int>());
00147 }
00148
00149
00150
00151
00152 void L1TLSBlock::blockByStatistics(){
00153 LumiRange currentRange;
00154 double currentError(0);
00155 bool resetFlag(true);
00156
00157 for(LumiTestDoubleList::iterator i=inputDoubleList_.begin(); i!=inputDoubleList_.end(); i++){
00158 if(resetFlag){
00159 currentRange = std::make_pair(i->first,i->first);
00160 resetFlag = false;
00161 }
00162 else
00163 currentRange = std::make_pair(currentRange.first,i->first);
00164 currentError = computeErrorFromRange(currentRange);
00165 if(currentError < thresholdD_){
00166 outputList_.push_back(currentRange);
00167 resetFlag = true;
00168 }
00169
00170 }
00171 }
00172
00173 double L1TLSBlock::computeErrorFromRange(LumiRange& lumiRange){
00174 std::vector<double> errorList;
00175 errorList.clear();
00176
00177 for(size_t i=0; i < inputDoubleList_.size(); i++){
00178 if(inputDoubleList_[i].first>lumiRange.first && inputDoubleList_[i].first<lumiRange.second)
00179 errorList.push_back(inputDoubleList_[i].second);
00180 }
00181
00182 double error(-1);
00183 for(size_t i=0; i<errorList.size(); i++)
00184 error += 1 / (errorList[i] * errorList[i] );
00185 return error;
00186
00187 }