CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ZeroSuppressFP420.cc
Go to the documentation of this file.
1 // File: ZeroSuppressFP420.cc
3 // Date: 12.2006
4 // Description: ZeroSuppressFP420 for FP420
5 // Modifications:
9 
10 ZeroSuppressFP420::ZeroSuppressFP420(const edm::ParameterSet& conf, float noise) : conf_(conf), theNumFEDalgos(4)
11 {
14  verbosity = conf_.getUntrackedParameter<int>("VerbosityLevel");
15  //initParams();
16  if(verbosity>0) {
17  std::cout << "ZeroSuppressFP420: constructor: noiseInAdc= " << noiseInAdc << std::endl;
18  }
19 }
20 
21 /*
22  * The zero suppression algorithm, implemented in the trkFEDclusterizer method.
23  * The class publically inherits from the ZSuppressFP420 class, which requires
24  * the use of a method named zeroSuppress.
25  */
26 
28 {
29  verbosity = conf_.getUntrackedParameter<int>("VerbosityLevel");
30  algoConf = conf_.getParameter<int>("FedFP420Algorithm"); //FedFP420Algorithm: =1 (,2,3,4)
31  lowthreshConf = conf_.getParameter<double>("FedFP420LowThreshold"); // FedFP420LowThreshold =3.
32  highthreshConf = conf_.getParameter<double>("FedFP420HighThreshold"); // FedFP420HighThreshold =4.
33 
34  /*
35  * There are four possible algorithms, the default of which (4)
36  * has different thresholds for isolated channels and ones in clusters.
37  * It also merges clusters (single or multi channels) that are only separated
38  * by one hole. This channel is selected as signal even though it is below
39  * both thresholds.
40  */
41 
43  theFEDlowThresh = lowthreshConf * noiseInAdc;
44  theFEDhighThresh = highthreshConf * noiseInAdc;
45 
46  if(verbosity>0) {
47  std::cout << "ZeroSuppressFP420: initParams: !!! theFEDalgorithm= " << theFEDalgorithm << std::endl;
48  std::cout << " lowthreshConf= " << lowthreshConf << " highthreshConf= " << highthreshConf << " theFEDlowThresh= " << theFEDlowThresh << " theFEDhighThresh= " << theFEDhighThresh << std::endl;
49  }
50 
51  //Check zero suppress algorithm
52  if (theFEDalgorithm < 1 || theFEDalgorithm > theNumFEDalgos) {
53  edm::LogError("FP420DigiInfo")<<"ZeroSuppressFP420 FATAL ERROR: Unknown zero suppress algorithm "<<theFEDalgorithm;
54  exit(1);
55  }
56 
57  //Check thresholds
59  edm::LogError("FP420DigiInfo")<<"ZeroSuppressFP420 FATAL ERROR: Low threshold exceeds high threshold: "<<theFEDlowThresh<<" > "<<theFEDhighThresh;
60  exit(2);
61  }
62 }
63 
65 {
66  return trkFEDclusterizer(notZeroSuppressedMap, vrb);
67  if(vrb>0) {
68  std::cout << "zeroSuppress: return trkFEDclusterizer(notZeroSuppressedMap)" << std::endl;
69  }
70 }
71 
72 //This performs the zero suppression
74 {
75  const std::string s2("ZeroSuppressFP420::trkFEDclusterizer1");
76 
77  DigitalMapType selectedSignal;
78  register DigitalMapType::const_iterator i, iPrev, iNext, iPrev2, iNext2;
79 
80  if(vrb>0) {
81  std::cout << "Before For loop" << std::endl;
82  }
83 
84  for (i = in.begin(); i != in.end(); i++) {
85 
86  //Find adc values for neighbouring strips
87  int strip = i->first;
88  int adc = i->second;
89  iPrev = in.find(strip - 1);
90  iNext = in.find(strip + 1);
91  if(vrb>0) {
92  std::cout << "Inside For loop trkFEDclusterizer: strip= " << strip << " adc= " << adc << std::endl;
93  }
94  //Set values for channels just outside module to infinity.
95  //This is to avoid losing channels at the edges,
96  //which otherwise would pass cuts if strips were next to each other.
97  int adcPrev = -99999;
98  int adcNext = -99999;
99  if ( ((strip)%128) == 127) adcNext = 99999;
100  if ( ((strip)%128) == 0) adcPrev = 99999;
101  //Otherwise if channel was found then find it's ADC count.
102  if ( iPrev != in.end() ) adcPrev = iPrev->second;
103  if ( iNext != in.end() ) adcNext = iNext->second;
104  int adcMaxNeigh = std::max(adcPrev, adcNext);
105  if(vrb>0) {
106  std::cout << "adcPrev= " << adcPrev << " adcNext= " << adcNext << " adcMaxNeigh= " << adcMaxNeigh << std::endl;
107  }
108 
109  //Find adc values for next neighbouring channes
110  iPrev2 = in.find(strip - 2);
111  iNext2 = in.find(strip + 2);
112  //See above
113  int adcPrev2 = -99999;
114  int adcNext2 = -99999;
115  if ( ((strip)%128) == 126) adcNext2 = 99999;
116  if ( ((strip)%128) == 1) adcPrev2 = 99999;
117  if ( iPrev2 != in.end() ) adcPrev2 = iPrev2->second;
118  if ( iNext2 != in.end() ) adcNext2 = iNext2->second;
119 
120  if(vrb>0) {
121  std::cout << "adcPrev2= " << adcPrev2 << " adcNext2= " << adcNext2 << std::endl;
122  std::cout << "To be accepted or not? adc= " << adc << " >= theFEDlowThresh=" << theFEDlowThresh << std::endl;
123  }
124  // Decide if this channel should be accepted.
125  bool accept = false;
126  switch (theFEDalgorithm) {
127 
128  case 1:
129  accept = (adc >= theFEDlowThresh);
130  break;
131 
132  case 2:
133  accept = (adc >= theFEDhighThresh || (adc >= theFEDlowThresh &&
134  adcMaxNeigh >= theFEDlowThresh));
135  break;
136 
137  case 3:
138  accept = (adc >= theFEDhighThresh || (adc >= theFEDlowThresh &&
139  adcMaxNeigh >= theFEDhighThresh));
140  break;
141 
142  case 4:
143  accept = ((adc >= theFEDhighThresh) || //Test for adc>highThresh (same as algorithm 2)
144  ((adc >= theFEDlowThresh) && //Test for adc>lowThresh, with neighbour adc>lowThresh (same as algorithm 2)
145  (adcMaxNeigh >= theFEDlowThresh)) ||
146  ((adc < theFEDlowThresh) && //Test for adc<lowThresh
147  (((adcPrev >= theFEDhighThresh) && //with both neighbours>highThresh
148  (adcNext >= theFEDhighThresh)) ||
149  ((adcPrev >= theFEDhighThresh) && //OR with previous neighbour>highThresh and
150  (adcNext >= theFEDlowThresh) && //both the next neighbours>lowThresh
151  (adcNext2 >= theFEDlowThresh)) ||
152  ((adcNext >= theFEDhighThresh) && //OR with next neighbour>highThresh and
153  (adcPrev >= theFEDlowThresh) && //both the previous neighbours>lowThresh
154  (adcPrev2 >= theFEDlowThresh)) ||
155  ((adcNext >= theFEDlowThresh) && //OR with both next neighbours>lowThresh and
156  (adcNext2 >= theFEDlowThresh) && //both the previous neighbours>lowThresh
157  (adcPrev >= theFEDlowThresh) &&
158  (adcPrev2 >= theFEDlowThresh)))));
159  break;
160  }
161 
162  /*
163  * When a channel satisfying only the lower threshold is at the edge of an APV or module,
164  * the trkFEDclusterizer method assumes that every channel just outside an APV or module has a hit on it.
165  * This is to avoid channel inefficiencies at the edges of APVs and modules.
166  */
167  if (accept) {
168  selectedSignal[strip] = adc;
169 
170  if(vrb>0) {
171  std::cout << "selected strips = " << strip << " adc= " << adc << std::endl;
172  }
173  }
174  }
175 
176  if(vrb>0) {
177  std::cout << "last line of trkFEDclusterizer: return selectedSignal" << std::endl;
178  }
179  return selectedSignal;
180 }
181 
int adc(sample_type sample)
get the ADC sample (12 bits)
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
int i
Definition: DBlmapReader.cc:9
edm::ParameterSet conf_
ZeroSuppressFP420(const edm::ParameterSet &conf, float noise)
bool accept(const edm::Event &event, const edm::TriggerResults &triggerTable, const std::string &triggerPath)
Definition: TopDQMHelpers.h:24
tuple s2
Definition: indexGen.py:106
ZSuppressFP420::DigitalMapType trkFEDclusterizer(const DigitalMapType &, int)
DConverterFP420::DigitalMapType DigitalMapType
ZSuppressFP420::DigitalMapType zeroSuppress(const DigitalMapType &, int)
tuple conf
Definition: dbtoconf.py:185
tuple cout
Definition: gather_cfg.py:121
void initParams(const edm::ParameterSet &conf_)
if(conf.exists("allCellsPositionCalc"))