CMS 3D CMS Logo

FP420ClusterMain.cc
Go to the documentation of this file.
1 // File: FP420ClusterMain.cc
3 // Date: 12.2006
4 // Description: FP420ClusterMain for FP420
5 // Modifications:
7 #include <vector>
8 #include <iostream>
11 
17 
18 #include "CLHEP/Random/RandFlat.h"
19 
20 using namespace std;
21 
22 FP420ClusterMain::FP420ClusterMain(const edm::ParameterSet& conf, int dn, int sn, int pn, int rn)
23  : conf_(conf), dn0(dn), sn0(sn), pn0(pn), rn0(rn) {
24  verbosity = conf_.getUntrackedParameter<int>("VerbosityLevel");
25  ElectronPerADC_ = conf_.getParameter<double>("ElectronFP420PerAdc");
26  clusterMode_ = conf_.getParameter<std::string>("ClusterModeFP420");
27  ChannelThreshold = conf_.getParameter<double>("ChannelFP420Threshold"); //6
28  SeedThreshold = conf_.getParameter<double>("SeedFP420Threshold"); //7
29  ClusterThreshold = conf_.getParameter<double>("ClusterFP420Threshold"); //7
30  MaxVoidsInCluster = conf_.getParameter<int>("MaxVoidsFP420InCluster"); //1
31 
32  if (verbosity > 0) {
33  std::cout << "FP420ClusterMain constructor: ElectronPerADC = " << ElectronPerADC_ << std::endl;
34  std::cout << " clusterMode = " << clusterMode_ << std::endl;
35  std::cout << " ChannelThreshold = " << ChannelThreshold << std::endl;
36  std::cout << " SeedThreshold = " << SeedThreshold << std::endl;
37  std::cout << " ClusterThreshold = " << ClusterThreshold << std::endl;
38  std::cout << " MaxVoidsInCluster = " << MaxVoidsInCluster << std::endl;
39  }
40  xytype = 2; // only X types of planes
41  ENC_ = 960.; //
42  Thick300 = 0.300;
44  //UseNoiseBadElectrodeFlagFromDB_ = true;
46  //
47  // pitches and ldriftes:
48  //
49  ldriftX = 0.050;
50  ldriftY = 0.050; // was 0.040
51  pitchY = 0.050; // was 0.040
52  pitchX = 0.050;
53  moduleThicknessY = 0.250; // mm
54  moduleThicknessX = 0.250; // mm
55 
56  //numStripsY = 200; // Y plate number of strips:200*0.050=10mm (xytype=1)
57  //numStripsX = 400; // X plate number of strips:400*0.050=20mm (xytype=2)
58  numStripsY = 144; // Y plate number of strips:144*0.050=7.2mm (xytype=1)
59  numStripsX = 160; // X plate number of strips:160*0.050=8.0mm (xytype=2)
60 
61  //numStripsYW = 50; // Y plate number of W strips:50 *0.400=20mm (xytype=1) - W have ortogonal projection
62  //numStripsXW = 25; // X plate number of W strips:25 *0.400=10mm (xytype=2) - W have ortogonal projection
63  numStripsYW = 20; // Y plate number of W strips:20 *0.400=8.0mm (xytype=1) - W have ortogonal projection
64  numStripsXW = 18; // X plate number of W strips:18 *0.400=7.2mm (xytype=2) - W have ortogonal projection
65 
66  // sn0 = 4;
67  // pn0 = 9;
68 
69  if (verbosity > 1) {
70  std::cout << "FP420ClusterMain constructor: sn0 = " << sn0 << " pn0=" << pn0 << " dn0=" << dn0 << " rn0=" << rn0
71  << std::endl;
72  std::cout << "FP420ClusterMain constructor: ENC = " << ENC_ << std::endl;
73  std::cout << " Thick300 = " << Thick300 << std::endl;
74  std::cout << " BadElectrodeProbability = " << BadElectrodeProbability_ << std::endl;
75  std::cout << " ldriftX = " << ldriftX << " ldriftY = " << ldriftY << std::endl;
76  std::cout << " pitchY = " << pitchY << " pitchX = " << pitchX << std::endl;
77  std::cout << " numStripsY = " << numStripsY << " numStripsX = " << numStripsX << std::endl;
78  std::cout << " moduleThicknessY = " << moduleThicknessY << " moduleThicknessX = " << moduleThicknessX << std::endl;
79  }
80 
81  if (UseNoiseBadElectrodeFlagFromDB_ == false) {
82  if (verbosity > 0) {
83  std::cout << "using a SingleNoiseValue and good electrode flags" << std::endl;
84  }
85  } else {
86  if (verbosity > 0) {
87  std::cout << "using Noise and BadElectrode flags accessed from DB" << std::endl;
88  }
89  }
90 
91  if (clusterMode_ == "ClusterProducerFP420") {
92  // ChannelThreshold = 6.0;// was 2.6.0 7 18
93  // SeedThreshold = 7.0;//was 3.7.0 8 20
94  // ClusterThreshold = 7.0;// was 2. 7.0 8 20
95  // MaxVoidsInCluster = 1;
97  validClusterizer_ = true;
98  } else {
99  std::cout << "ERROR:FP420ClusterMain: No valid clusterizer selected" << std::endl;
100  validClusterizer_ = false;
101  }
102 }
103 
105  if (threeThreshold_ != nullptr) {
106  delete threeThreshold_;
107  }
108 }
109 
110 //void FP420ClusterMain::run(const DigiCollectionFP420 *input, ClusterCollectionFP420 *soutput,
111 // const std::vector<ClusterNoiseFP420>& electrodnoise)
113  ClusterCollectionFP420* soutput,
114  std::vector<ClusterNoiseFP420>& electrodnoise)
115 
116 {
117  // unpack from iu:
118  // int sScale = 20, zScale=2;
119  // int sector = (iu-1)/sScale + 1 ;
120  // int zmodule = (iu - (sector - 1)*sScale - 1) /zScale + 1 ;
121  // int zside = iu - (sector - 1)*sScale - (zmodule - 1)*zScale ;
122 
123  if (verbosity > 0) {
124  std::cout << "FP420ClusterMain: OK1" << std::endl;
125  }
126  if (validClusterizer_) {
127  int number_detunits = 0;
128  int number_localelectroderechits = 0;
129 
130  // get vector of detunit ids
131  // const std::vector<unsigned int> detIDs = input->detIDs();
132 
133  // to be used in put (besause of 0 in cluster collection for: 1) 1st cluster and 2) case of no cluster)
134  // ignore 0, but to save info for 1st cluster record it second time on place 1 .
135 
136  bool first = true;
137  // loop over detunits
138  for (int det = 1; det < dn0; det++) {
139  for (int sector = 1; sector < sn0; sector++) {
140  for (int zmodule = 1; zmodule < pn0; zmodule++) {
141  for (int zside = 1; zside < rn0; zside++) {
142  // intindex is a continues numbering of FP420
143  unsigned int detID = FP420NumberingScheme::packMYIndex(rn0, pn0, sn0, det, zside, sector, zmodule);
144  if (verbosity > 0) {
145  std::cout << " FP420ClusterMain:1 run loop index no iu = " << detID << std::endl;
146  }
147  // Y:
148  if (xytype == 1) {
151  pitch = pitchY;
152  ldrift = ldriftX;
153  }
154  // X:
155  if (xytype == 2) {
158  pitch = pitchX;
159  ldrift = ldriftY;
160  }
161 
162  // for ( std::vector<unsigned int>::const_iterator detunit_iterator = detIDs.begin(); detunit_iterator != detIDs.end(); ++detunit_iterator ) {
163  // unsigned int detID = *detunit_iterator;
164  ++number_detunits;
165 
166  // .
167  // GET DIGI collection !!!!
168  // .
169  // const DigiCollectionFP420::Range digiRange = input->get(detID);
170  DigiCollectionFP420::Range digiRange;
171  std::vector<HDigiFP420> dcollector;
172  // if (dcollector.size()>0){
173  if (verbosity > 0) {
174  std::cout << " FP420ClusterMain:2 number_detunits = " << number_detunits << std::endl;
175  }
176  digiRange = input->get(detID);
177  //digiRange = input.get(detID);
178  // }
179 
180  if (verbosity > 0) {
181  std::cout << " FP420ClusterMain: input->get DONE dcollector.size()=" << dcollector.size() << std::endl;
182  }
183 
184  DigiCollectionFP420::ContainerIterator sort_begin = digiRange.first;
185  DigiCollectionFP420::ContainerIterator sort_end = digiRange.second;
186  for (; sort_begin != sort_end; ++sort_begin) {
187  dcollector.push_back(*sort_begin);
188  } // for
189  if (!dcollector.empty()) {
190  DigiCollectionFP420::ContainerIterator digiRangeIteratorBegin = digiRange.first;
191  DigiCollectionFP420::ContainerIterator digiRangeIteratorEnd = digiRange.second;
192  if (verbosity > 0) {
193  std::cout << " FP420ClusterMain: channel Begin = " << (digiRangeIteratorBegin)->channel() << std::endl;
194  std::cout << " FP420ClusterMain: channel end = " << (digiRangeIteratorEnd - 1)->channel() << std::endl;
195  }
196  if (verbosity > 0) {
197  std::cout << " FP420ClusterMain:3 noise treatment " << std::endl;
198  }
199  if (clusterMode_ == "ClusterProducerFP420") {
200  std::vector<ClusterFP420> collector;
201  // std::vector<ClusterFP420> collector;
202 
203  if (UseNoiseBadElectrodeFlagFromDB_ == false) {
204  //Case of SingleValueNoise flags for all electrodes of a Detector
205 
206  //float noise = ENC_*ldrift/Thick300/ElectronPerADC_;//Noise is proportional to charge collection path
207  float noise =
208  ENC_ * moduleThickness / Thick300 / ElectronPerADC_; //Noise is proportional to moduleThickness
209 
210  //vector<float> noiseVec(numElectrodes,noise);
211  //Construct a ElectrodNoiseVector ( in order to be compliant with the DB access)
212  ElectrodNoiseVector vnoise;
213  ClusterNoiseFP420::ElectrodData theElectrodData;
214 
215  if (verbosity > 0) {
216  std::cout << " FP420ClusterMain:4 numStrips = " << numStrips << std::endl;
217  }
218  for (int electrode = 0; electrode < numStrips; ++electrode) {
219  // discard randomly bad electrode with probability BadElectrodeProbability_
220  bool badFlag = CLHEP::RandFlat::shoot(1.) < BadElectrodeProbability_ ? true : false;
221  theElectrodData.setData(noise, badFlag);
222  vnoise.push_back(theElectrodData); // fill vector vnoise
223  } // for
224 
225  if (verbosity > 0) {
226  std::cout << " FP420ClusterMain:5 BadElectrodeProbability added " << std::endl;
227  }
228  //clusterizeDetUnit or clusterizeDetUnitPixels !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
229  collector.clear();
230  // std::vector<ClusterFP420> collector;
231  // collector = threeThreshold_->clusterizeDetUnit(digiRangeIteratorBegin,digiRangeIteratorEnd,detID,vnoise);
232  // if (dcollector.size()>0){
234  digiRangeIteratorBegin, digiRangeIteratorEnd, detID, vnoise, xytype, verbosity);
235  // }
236  if (verbosity > 0) {
237  std::cout << " FP420ClusterMain:6 threeThreshold OK " << std::endl;
238  }
239 
240  } else {
241  //Case of Noise and BadElectrode flags access from DB
242  /*
243  const ElectrodNoiseVector& vnoise = electrodnoise->getElectrodNoiseVector(detID);
244 
245  if (vnoise.size() <= 0) {
246  std::cout << "WARNING requested Noise Vector for detID " << detID << " that isn't in map " << std::endl;
247  continue;
248  }
249  collector.clear();
250  collector = threeThreshold_->clusterizeDetUnit(digiRangeIteratorBegin,digiRangeIteratorEnd,detID,vnoise);
251  */
252 
253  } // if (UseNoiseBadElectrodeFlagFromDB
254 
255  if (!collector.empty()) {
257  inputRange.first = collector.begin();
258  inputRange.second = collector.end();
259 
260  if (verbosity > 0) {
261  std::cout << " FP420ClusterMain:7 collector.size()>0 " << std::endl;
262  }
263  if (first) {
264  // use it only if ClusterCollectionFP420 is the ClusterCollection of one event, otherwise, do not use (loose 1st cl. of 1st event only)
265  first = false;
266  unsigned int detID0 = 0;
267  if (verbosity > 0) {
268  std::cout << " FP420ClusterMain:8 first soutput->put " << std::endl;
269  }
270  soutput->put(inputRange, detID0); // !!! put into adress 0 for detID which will not be used never
271  } //if ( first )
272 
273  // !!! put
274  if (verbosity > 0) {
275  std::cout << " FP420ClusterMain:9 soutput->put " << std::endl;
276  }
277  soutput->put(inputRange, detID);
278 
279  number_localelectroderechits += collector.size();
280  } // if (collector.size
281  } // if ( clusterMode
282  if (verbosity > 0) {
283  std::cout << "[FP420ClusterMain] execution in mode " << clusterMode_ << " generating "
284  << number_localelectroderechits << " ClusterFP420s in " << number_detunits << " DetUnits."
285  << std::endl;
286  } //if (verb
287  } // if (dcollector.siz
288  } //for
289  } //for
290  } //for
291  } //for
292 
293  if (verbosity == -50) {
294  // check of access to the collector:
295  for (int det = 1; det < dn0; det++) {
296  for (int sector = 1; sector < sn0; sector++) {
297  for (int zmodule = 1; zmodule < pn0; zmodule++) {
298  for (int zside = 1; zside < rn0; zside++) {
299  // intindex is a continues numbering of FP420
300  unsigned int iu = FP420NumberingScheme::packMYIndex(rn0, pn0, sn0, det, zside, sector, zmodule);
301  std::cout << " iu = " << iu << " sector = " << sector << " zmodule = " << zmodule << " zside = " << zside
302  << " det=" << det << std::endl;
303  std::vector<ClusterFP420> collector;
304  collector.clear();
305  ClusterCollectionFP420::Range outputRange;
306  outputRange = soutput->get(iu);
307  // fill output in collector vector (for may be sorting? or other checks)
308  ClusterCollectionFP420::ContainerIterator sort_begin = outputRange.first;
309  ClusterCollectionFP420::ContainerIterator sort_end = outputRange.second;
310  for (; sort_begin != sort_end; ++sort_begin) {
311  collector.push_back(*sort_begin);
312  } // for
313  std::cout << " ===" << std::endl;
314  std::cout << " ===" << std::endl;
315  std::cout << " =========== FP420ClusterMain:check: iu= " << iu << " zside = " << zside << std::endl;
316  std::cout << " ======renew collector size = " << collector.size() << std::endl;
317  std::cout << " ===" << std::endl;
318  std::cout << " ===" << std::endl;
319  std::vector<ClusterFP420>::const_iterator simHitIter = collector.begin();
320  std::vector<ClusterFP420>::const_iterator simHitIterEnd = collector.end();
321  // loop in #clusters
322  for (; simHitIter != simHitIterEnd; ++simHitIter) {
323  const ClusterFP420 icluster = *simHitIter;
324  // if(icluster.amplitudes().size()>390) {
325  std::cout << " ===== size of cluster= " << icluster.amplitudes().size() << std::endl;
326  std::cout << " ===" << std::endl;
327  std::cout << " ===== firstStrip = " << icluster.firstStrip()
328  << " barycenter = " << icluster.barycenter() << " barycenterW = " << icluster.barycenterW()
329  << std::endl;
330  std::cout << " ===" << std::endl;
331  for (unsigned int i = 0; i < icluster.amplitudes().size(); i++) {
332  std::cout << "i = " << i << " amplitudes = " << icluster.amplitudes()[i] << std::endl;
333  } // for ampl
334  std::cout << " ===" << std::endl;
335  std::cout << " ===" << std::endl;
336  std::cout << " =======================" << std::endl;
337  // }// if(icluster.amplitudes().size()>390
338  } //for cl
339 
340  /*
341  for (DigitalMapType::const_iterator i=collector.begin(); i!=collector.end(); i++) {
342  std::cout << "DigitizerFP420:check: HDigiFP420:: " << std::endl;
343  std::cout << " strip number is as (*i).first = " << (*i).first << " adc is in (*i).second = " << (*i).second << std::endl;
344  }
345  */
346 
347  //==================================
348 
349  } // for
350  } // for
351  } // for
352  } // for
353 
354  // end of check of access to the strip collection
355  std::cout << "======= FP420ClusterMain: end of check " << std::endl;
356 
357  } // if (verbosit
358 
359  } // if ( validClusterizer_
360 }
FP420ClusterMain::dn0
int dn0
Definition: FP420ClusterMain.h:76
ClusterNoiseFP420::ElectrodData
Definition: ClusterNoiseFP420.h:18
ClusterFP420::barycenterW
float barycenterW() const
Definition: ClusterFP420.h:33
mps_fire.i
i
Definition: mps_fire.py:428
input
static const std::string input
Definition: EdmProvDump.cc:48
ESHandle.h
FP420ClusterMain::ENC_
double ENC_
Definition: FP420ClusterMain.h:51
FP420ClusterMain::pn0
int pn0
Definition: FP420ClusterMain.h:80
ecaldqm::zside
int zside(DetId const &)
Definition: EcalDQMCommonUtils.cc:189
FP420ClusterMain::moduleThicknessY
float moduleThicknessY
Definition: FP420ClusterMain.h:67
gather_cfg.cout
cout
Definition: gather_cfg.py:144
FP420ClusterMain::rn0
int rn0
Definition: FP420ClusterMain.h:82
ClusterProducerFP420.h
FP420ClusterMain::~FP420ClusterMain
~FP420ClusterMain()
Definition: FP420ClusterMain.cc:104
ClusterCollectionFP420
Definition: ClusterCollectionFP420.h:9
FP420ClusterMain::FP420ClusterMain
FP420ClusterMain(const edm::ParameterSet &conf, int dn, int sn, int pn, int rn)
Definition: FP420ClusterMain.cc:22
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
FP420ClusterMain::Thick300
float Thick300
Definition: FP420ClusterMain.h:73
FP420ClusterMain::validClusterizer_
bool validClusterizer_
Definition: FP420ClusterMain.h:49
edm::Handle
Definition: AssociativeIterator.h:50
FP420ClusterMain::numStripsX
int numStripsX
Definition: FP420ClusterMain.h:69
FP420ClusterMain::pitch
double pitch
Definition: FP420ClusterMain.h:65
pileupCalc.inputRange
inputRange
Definition: pileupCalc.py:218
DigiCollectionFP420::ContainerIterator
std::vector< HDigiFP420 >::const_iterator ContainerIterator
Definition: DigiCollectionFP420.h:16
ElectrodNoiseVector
std::vector< ClusterNoiseFP420::ElectrodData > ElectrodNoiseVector
Definition: ClusterNoiseFP420.h:45
FP420ClusterMain::conf_
edm::ParameterSet conf_
Definition: FP420ClusterMain.h:47
FP420ClusterMain::run
void run(edm::Handle< DigiCollectionFP420 > &input, ClusterCollectionFP420 *soutput, std::vector< ClusterNoiseFP420 > &noise)
Runs the algorithm.
Definition: FP420ClusterMain.cc:112
FP420ClusterMain::ChannelThreshold
double ChannelThreshold
Definition: FP420ClusterMain.h:55
FP420ClusterMain::xytype
int xytype
Definition: FP420ClusterMain.h:84
FP420ClusterMain::ElectronPerADC_
double ElectronPerADC_
Definition: FP420ClusterMain.h:50
FP420ClusterMain::clusterMode_
std::string clusterMode_
Definition: FP420ClusterMain.h:44
ClusterFP420::firstStrip
short firstStrip() const
Definition: ClusterFP420.h:20
FP420ClusterMain::moduleThicknessX
float moduleThicknessX
Definition: FP420ClusterMain.h:66
first
auto first
Definition: CAHitNtupletGeneratorKernelsImpl.h:112
FP420NumberingScheme::packMYIndex
static unsigned packMYIndex(int rn0, int pn0, int sn0, int det, int zside, int sector, int zmodule)
Definition: FP420NumberingScheme.h:37
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
funct::true
true
Definition: Factorize.h:173
FP420ClusterMain::MaxVoidsInCluster
int MaxVoidsInCluster
Definition: FP420ClusterMain.h:58
FP420ClusterMain::ClusterThreshold
double ClusterThreshold
Definition: FP420ClusterMain.h:57
edm::ParameterSet
Definition: ParameterSet.h:47
FP420ClusterMain::verbosity
int verbosity
Definition: FP420ClusterMain.h:86
ClusterNoiseFP420.h
FP420ClusterMain::ldriftY
double ldriftY
Definition: FP420ClusterMain.h:61
ClusterFP420::barycenter
float barycenter() const
Definition: ClusterFP420.h:30
FP420ClusterMain::numStripsYW
int numStripsYW
Definition: FP420ClusterMain.h:70
ClusterFP420::amplitudes
const std::vector< short > & amplitudes() const
Definition: ClusterFP420.h:28
gpuVertexFinder::noise
__shared__ int noise
Definition: gpuFitVertices.h:50
FP420ClusterMain::ldrift
double ldrift
Definition: FP420ClusterMain.h:62
FP420ClusterMain::SeedThreshold
double SeedThreshold
Definition: FP420ClusterMain.h:56
FP420ClusterMain::pitchY
double pitchY
Definition: FP420ClusterMain.h:64
ClusterFP420.h
ClusterNoiseFP420::ElectrodData::setData
void setData(short data)
Definition: ClusterNoiseFP420.h:22
ClusterProducerFP420::clusterizeDetUnitPixels
std::vector< ClusterFP420 > clusterizeDetUnitPixels(HDigiFP420Iter begin, HDigiFP420Iter end, unsigned int detid, const ElectrodNoiseVector &vnoise, unsigned int xytype, int verb)
Definition: ClusterProducerFP420.cc:179
FP420ClusterMain::UseNoiseBadElectrodeFlagFromDB_
bool UseNoiseBadElectrodeFlagFromDB_
Definition: FP420ClusterMain.h:53
std
Definition: JetResolutionObject.h:76
DigiCollectionFP420::Range
std::pair< ContainerIterator, ContainerIterator > Range
Definition: DigiCollectionFP420.h:17
FP420ClusterMain::numStripsXW
int numStripsXW
Definition: FP420ClusterMain.h:69
FP420ClusterMain::pitchX
double pitchX
Definition: FP420ClusterMain.h:63
FP420ClusterMain::moduleThickness
float moduleThickness
Definition: FP420ClusterMain.h:68
ClusterCollectionFP420::get
const Range get(unsigned int detID) const
Definition: ClusterCollectionFP420.cc:69
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
FP420ClusterMain::BadElectrodeProbability_
double BadElectrodeProbability_
Definition: FP420ClusterMain.h:52
ClusterCollectionFP420::ContainerIterator
std::vector< ClusterFP420 >::const_iterator ContainerIterator
Definition: ClusterCollectionFP420.h:11
FP420ClusterMain::ldriftX
double ldriftX
Definition: FP420ClusterMain.h:60
FP420ClusterMain.h
FP420ClusterMain::sn0
int sn0
Definition: FP420ClusterMain.h:78
ParameterSet.h
HDigiFP420.h
FP420ClusterMain::numStripsY
int numStripsY
Definition: FP420ClusterMain.h:70
ClusterFP420
Definition: ClusterFP420.h:7
ClusterCollectionFP420::Range
std::pair< ContainerIterator, ContainerIterator > Range
Definition: ClusterCollectionFP420.h:12
FP420ClusterMain::threeThreshold_
ClusterProducerFP420 * threeThreshold_
Definition: FP420ClusterMain.h:43
ClusterProducerFP420
Definition: ClusterProducerFP420.h:13
ClusterCollectionFP420::put
void put(Range input, unsigned int detID)
Definition: ClusterCollectionFP420.cc:13
FP420ClusterMain::numStrips
int numStrips
Definition: FP420ClusterMain.h:71