Go to the documentation of this file.00001
00002
00003
00004
00005
00007 #include "SimRomanPot/SimFP420/interface/ZeroSuppressFP420.h"
00008 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00009
00010 ZeroSuppressFP420::ZeroSuppressFP420(const edm::ParameterSet& conf, float noise) : conf_(conf), theNumFEDalgos(4)
00011 {
00012 noiseInAdc=noise;
00013 initParams(conf_);
00014 verbosity = conf_.getUntrackedParameter<int>("VerbosityLevel");
00015
00016 if(verbosity>0) {
00017 std::cout << "ZeroSuppressFP420: constructor: noiseInAdc= " << noiseInAdc << std::endl;
00018 }
00019 }
00020
00021
00022
00023
00024
00025
00026
00027 void ZeroSuppressFP420::initParams(edm::ParameterSet const& conf_)
00028 {
00029 verbosity = conf_.getUntrackedParameter<int>("VerbosityLevel");
00030 algoConf = conf_.getParameter<int>("FedFP420Algorithm");
00031 lowthreshConf = conf_.getParameter<double>("FedFP420LowThreshold");
00032 highthreshConf = conf_.getParameter<double>("FedFP420HighThreshold");
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042 theFEDalgorithm = algoConf;
00043 theFEDlowThresh = lowthreshConf * noiseInAdc;
00044 theFEDhighThresh = highthreshConf * noiseInAdc;
00045
00046 if(verbosity>0) {
00047 std::cout << "ZeroSuppressFP420: initParams: !!! theFEDalgorithm= " << theFEDalgorithm << std::endl;
00048 std::cout << " lowthreshConf= " << lowthreshConf << " highthreshConf= " << highthreshConf << " theFEDlowThresh= " << theFEDlowThresh << " theFEDhighThresh= " << theFEDhighThresh << std::endl;
00049 }
00050
00051
00052 if (theFEDalgorithm < 1 || theFEDalgorithm > theNumFEDalgos) {
00053 edm::LogError("FP420DigiInfo")<<"ZeroSuppressFP420 FATAL ERROR: Unknown zero suppress algorithm "<<theFEDalgorithm;
00054 exit(1);
00055 }
00056
00057
00058 if (theFEDlowThresh > theFEDhighThresh) {
00059 edm::LogError("FP420DigiInfo")<<"ZeroSuppressFP420 FATAL ERROR: Low threshold exceeds high threshold: "<<theFEDlowThresh<<" > "<<theFEDhighThresh;
00060 exit(2);
00061 }
00062 }
00063
00064 ZSuppressFP420::DigitalMapType ZeroSuppressFP420::zeroSuppress(const DigitalMapType& notZeroSuppressedMap,int vrb)
00065 {
00066 return trkFEDclusterizer(notZeroSuppressedMap, vrb);
00067 if(vrb>0) {
00068 std::cout << "zeroSuppress: return trkFEDclusterizer(notZeroSuppressedMap)" << std::endl;
00069 }
00070 }
00071
00072
00073 ZSuppressFP420::DigitalMapType ZeroSuppressFP420::trkFEDclusterizer(const DigitalMapType &in, int vrb)
00074 {
00075 const std::string s2("ZeroSuppressFP420::trkFEDclusterizer1");
00076
00077 DigitalMapType selectedSignal;
00078 register DigitalMapType::const_iterator i, iPrev, iNext, iPrev2, iNext2;
00079
00080 if(vrb>0) {
00081 std::cout << "Before For loop" << std::endl;
00082 }
00083
00084 for (i = in.begin(); i != in.end(); i++) {
00085
00086
00087 int strip = i->first;
00088 int adc = i->second;
00089 iPrev = in.find(strip - 1);
00090 iNext = in.find(strip + 1);
00091 if(vrb>0) {
00092 std::cout << "Inside For loop trkFEDclusterizer: strip= " << strip << " adc= " << adc << std::endl;
00093 }
00094
00095
00096
00097 int adcPrev = -99999;
00098 int adcNext = -99999;
00099 if ( ((strip)%128) == 127) adcNext = 99999;
00100 if ( ((strip)%128) == 0) adcPrev = 99999;
00101
00102 if ( iPrev != in.end() ) adcPrev = iPrev->second;
00103 if ( iNext != in.end() ) adcNext = iNext->second;
00104 int adcMaxNeigh = std::max(adcPrev, adcNext);
00105 if(vrb>0) {
00106 std::cout << "adcPrev= " << adcPrev << " adcNext= " << adcNext << " adcMaxNeigh= " << adcMaxNeigh << std::endl;
00107 }
00108
00109
00110 iPrev2 = in.find(strip - 2);
00111 iNext2 = in.find(strip + 2);
00112
00113 int adcPrev2 = -99999;
00114 int adcNext2 = -99999;
00115 if ( ((strip)%128) == 126) adcNext2 = 99999;
00116 if ( ((strip)%128) == 1) adcPrev2 = 99999;
00117 if ( iPrev2 != in.end() ) adcPrev2 = iPrev2->second;
00118 if ( iNext2 != in.end() ) adcNext2 = iNext2->second;
00119
00120 if(vrb>0) {
00121 std::cout << "adcPrev2= " << adcPrev2 << " adcNext2= " << adcNext2 << std::endl;
00122 std::cout << "To be accepted or not? adc= " << adc << " >= theFEDlowThresh=" << theFEDlowThresh << std::endl;
00123 }
00124
00125 bool accept = false;
00126 switch (theFEDalgorithm) {
00127
00128 case 1:
00129 accept = (adc >= theFEDlowThresh);
00130 break;
00131
00132 case 2:
00133 accept = (adc >= theFEDhighThresh || (adc >= theFEDlowThresh &&
00134 adcMaxNeigh >= theFEDlowThresh));
00135 break;
00136
00137 case 3:
00138 accept = (adc >= theFEDhighThresh || (adc >= theFEDlowThresh &&
00139 adcMaxNeigh >= theFEDhighThresh));
00140 break;
00141
00142 case 4:
00143 accept = ((adc >= theFEDhighThresh) ||
00144 ((adc >= theFEDlowThresh) &&
00145 (adcMaxNeigh >= theFEDlowThresh)) ||
00146 ((adc < theFEDlowThresh) &&
00147 (((adcPrev >= theFEDhighThresh) &&
00148 (adcNext >= theFEDhighThresh)) ||
00149 ((adcPrev >= theFEDhighThresh) &&
00150 (adcNext >= theFEDlowThresh) &&
00151 (adcNext2 >= theFEDlowThresh)) ||
00152 ((adcNext >= theFEDhighThresh) &&
00153 (adcPrev >= theFEDlowThresh) &&
00154 (adcPrev2 >= theFEDlowThresh)) ||
00155 ((adcNext >= theFEDlowThresh) &&
00156 (adcNext2 >= theFEDlowThresh) &&
00157 (adcPrev >= theFEDlowThresh) &&
00158 (adcPrev2 >= theFEDlowThresh)))));
00159 break;
00160 }
00161
00162
00163
00164
00165
00166
00167 if (accept) {
00168 selectedSignal[strip] = adc;
00169
00170 if(vrb>0) {
00171 std::cout << "selected strips = " << strip << " adc= " << adc << std::endl;
00172 }
00173 }
00174 }
00175
00176 if(vrb>0) {
00177 std::cout << "last line of trkFEDclusterizer: return selectedSignal" << std::endl;
00178 }
00179 return selectedSignal;
00180 }
00181