Go to the documentation of this file.00001
00002
00003
00004
00005
00007 #include <vector>
00008 #include <iostream>
00009 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00010 #include "FWCore/Framework/interface/ESHandle.h"
00011
00012 #include "RecoRomanPot/RecoFP420/interface/FP420ClusterMain.h"
00013 #include "DataFormats/FP420Digi/interface/HDigiFP420.h"
00014 #include "DataFormats/FP420Cluster/interface/ClusterFP420.h"
00015 #include "RecoRomanPot/RecoFP420/interface/ClusterProducerFP420.h"
00016 #include "RecoRomanPot/RecoFP420/interface/ClusterNoiseFP420.h"
00017
00018 #include "CLHEP/Random/RandFlat.h"
00019
00020 using namespace std;
00021
00022
00023 FP420ClusterMain::FP420ClusterMain(const edm::ParameterSet& conf, int dn, int sn, int pn, int rn):conf_(conf),dn0(dn),sn0(sn),pn0(pn),rn0(rn) {
00024
00025 verbosity = conf_.getUntrackedParameter<int>("VerbosityLevel");
00026 ElectronPerADC_ = conf_.getParameter<double>("ElectronFP420PerAdc");
00027 clusterMode_ = conf_.getParameter<std::string>("ClusterModeFP420");
00028 ChannelThreshold = conf_.getParameter<double>("ChannelFP420Threshold");
00029 SeedThreshold = conf_.getParameter<double>("SeedFP420Threshold");
00030 ClusterThreshold = conf_.getParameter<double>("ClusterFP420Threshold");
00031 MaxVoidsInCluster = conf_.getParameter<int>("MaxVoidsFP420InCluster");
00032
00033 if (verbosity > 0) {
00034 std::cout << "FP420ClusterMain constructor: ElectronPerADC = " << ElectronPerADC_ << std::endl;
00035 std::cout << " clusterMode = " << clusterMode_ << std::endl;
00036 std::cout << " ChannelThreshold = " << ChannelThreshold << std::endl;
00037 std::cout << " SeedThreshold = " << SeedThreshold << std::endl;
00038 std::cout << " ClusterThreshold = " << ClusterThreshold << std::endl;
00039 std::cout << " MaxVoidsInCluster = " << MaxVoidsInCluster << std::endl;
00040 }
00041 xytype=2;
00042 ENC_ = 960.;
00043 Thick300 = 0.300;
00044 BadElectrodeProbability_ = 0.002;
00045
00046 UseNoiseBadElectrodeFlagFromDB_ = false;
00047
00048
00049
00050 ldriftX = 0.050;
00051 ldriftY = 0.050;
00052 pitchY= 0.050;
00053 pitchX= 0.050;
00054 moduleThicknessY = 0.250;
00055 moduleThicknessX = 0.250;
00056
00057
00058
00059 numStripsY = 144;
00060 numStripsX = 160;
00061
00062
00063
00064 numStripsYW = 20;
00065 numStripsXW = 18;
00066
00067
00068
00069
00070
00071 theFP420NumberingScheme = new FP420NumberingScheme();
00072
00073
00074 if (verbosity > 1) {
00075 std::cout << "FP420ClusterMain constructor: sn0 = " << sn0 << " pn0=" << pn0 << " dn0=" << dn0 << " rn0=" << rn0 << std::endl;
00076 std::cout << "FP420ClusterMain constructor: ENC = " << ENC_ << std::endl;
00077 std::cout << " Thick300 = " << Thick300 << std::endl;
00078 std::cout << " BadElectrodeProbability = " << BadElectrodeProbability_ << std::endl;
00079 std::cout << " ldriftX = " << ldriftX << " ldriftY = " << ldriftY << std::endl;
00080 std::cout << " pitchY = " << pitchY << " pitchX = " << pitchX << std::endl;
00081 std::cout << " numStripsY = " << numStripsY << " numStripsX = " << numStripsX << std::endl;
00082 std::cout << " moduleThicknessY = " << moduleThicknessY << " moduleThicknessX = " << moduleThicknessX << std::endl;
00083 }
00084
00085 if (UseNoiseBadElectrodeFlagFromDB_==false){
00086 if (verbosity > 0) {
00087 std::cout << "using a SingleNoiseValue and good electrode flags" << std::endl;
00088 }
00089 } else {
00090 if (verbosity > 0) {
00091 std::cout << "using Noise and BadElectrode flags accessed from DB" << std::endl;
00092 }
00093 }
00094
00095 if ( clusterMode_ == "ClusterProducerFP420" ) {
00096
00097
00098
00099
00100
00101
00102 threeThreshold_ = new ClusterProducerFP420(ChannelThreshold,
00103 SeedThreshold,
00104 ClusterThreshold,
00105 MaxVoidsInCluster);
00106 validClusterizer_ = true;
00107 } else {
00108 std::cout << "ERROR:FP420ClusterMain: No valid clusterizer selected" << std::endl;
00109 validClusterizer_ = false;
00110 }
00111 }
00112
00113 FP420ClusterMain::~FP420ClusterMain() {
00114 if ( threeThreshold_ != 0 ) {
00115 delete threeThreshold_;
00116 }
00117 }
00118
00119
00120
00121
00122 void FP420ClusterMain::run(edm::Handle<DigiCollectionFP420> &input, std::auto_ptr<ClusterCollectionFP420> &soutput,
00123 std::vector<ClusterNoiseFP420>& electrodnoise)
00124
00125 {
00126
00127
00128
00129
00130
00131
00132 if (verbosity > 0) {
00133 std::cout << "FP420ClusterMain: OK1" << std::endl;
00134 }
00135 if ( validClusterizer_ ) {
00136
00137 int number_detunits = 0;
00138 int number_localelectroderechits = 0;
00139
00140
00141
00142
00143
00144
00145
00146 bool first = true;
00147
00148 for (int det=1; det<dn0; det++) {
00149 for (int sector=1; sector<sn0; sector++) {
00150 for (int zmodule=1; zmodule<pn0; zmodule++) {
00151 for (int zside=1; zside<rn0; zside++) {
00152
00153 unsigned int detID = theFP420NumberingScheme->FP420NumberingScheme::packMYIndex(rn0, pn0, sn0, det, zside, sector, zmodule);
00154 if (verbosity > 0) {
00155 std::cout << " FP420ClusterMain:1 run loop index no iu = " << detID << std::endl;
00156 }
00157
00158 if (xytype ==1) {
00159 numStrips = numStripsY*numStripsYW;
00160 moduleThickness = moduleThicknessY;
00161 pitch= pitchY;
00162 ldrift = ldriftX;
00163 }
00164
00165 if (xytype ==2) {
00166 numStrips = numStripsX*numStripsXW;
00167 moduleThickness = moduleThicknessX;
00168 pitch= pitchX;
00169 ldrift = ldriftY;
00170 }
00171
00172
00173
00174
00175 ++number_detunits;
00176
00177
00178
00179
00180
00181 DigiCollectionFP420::Range digiRange;
00182 std::vector<HDigiFP420> dcollector;
00183
00184 if (verbosity > 0) {
00185 std::cout << " FP420ClusterMain:2 number_detunits = " << number_detunits << std::endl;
00186 }
00187 digiRange = input->get(detID);
00188
00189
00190
00191 if (verbosity > 0) {
00192 std::cout << " FP420ClusterMain: input->get DONE dcollector.size()=" << dcollector.size() << std::endl;
00193 }
00194
00195 DigiCollectionFP420::ContainerIterator sort_begin = digiRange.first;
00196 DigiCollectionFP420::ContainerIterator sort_end = digiRange.second;
00197 for ( ;sort_begin != sort_end; ++sort_begin ) {
00198 dcollector.push_back(*sort_begin);
00199 }
00200 if (dcollector.size()>0) {
00201
00202 DigiCollectionFP420::ContainerIterator digiRangeIteratorBegin = digiRange.first;
00203 DigiCollectionFP420::ContainerIterator digiRangeIteratorEnd = digiRange.second;
00204 if (verbosity > 0) {
00205 std::cout << " FP420ClusterMain: channel Begin = " << (digiRangeIteratorBegin)->channel() << std::endl;
00206 std::cout << " FP420ClusterMain: channel end = " << (digiRangeIteratorEnd-1)->channel() << std::endl;
00207 }
00208 if (verbosity > 0) {
00209 std::cout << " FP420ClusterMain:3 noise treatment " << std::endl;
00210 }
00211 if ( clusterMode_ == "ClusterProducerFP420" ) {
00212
00213 std::vector<ClusterFP420> collector;
00214
00215
00216 if (UseNoiseBadElectrodeFlagFromDB_==false){
00217
00218
00219
00220
00221
00222 float noise = ENC_*moduleThickness/Thick300/ElectronPerADC_;
00223
00224
00225
00226 ElectrodNoiseVector vnoise;
00227 ClusterNoiseFP420::ElectrodData theElectrodData;
00228
00229 if (verbosity > 0) {
00230 std::cout << " FP420ClusterMain:4 numStrips = " << numStrips << std::endl;
00231 }
00232 for(int electrode=0; electrode < numStrips; ++electrode){
00233
00234 bool badFlag= CLHEP::RandFlat::shoot(1.) < BadElectrodeProbability_ ? true : false;
00235 theElectrodData.setData(noise,badFlag);
00236 vnoise.push_back(theElectrodData);
00237 }
00238
00239 if (verbosity > 0) {
00240 std::cout << " FP420ClusterMain:5 BadElectrodeProbability added " << std::endl;
00241 }
00242
00243 collector.clear();
00244
00245
00246
00247 collector = threeThreshold_->clusterizeDetUnitPixels(digiRangeIteratorBegin,digiRangeIteratorEnd,detID,vnoise,xytype,verbosity);
00248
00249 if (verbosity > 0) {
00250 std::cout << " FP420ClusterMain:6 threeThreshold OK " << std::endl;
00251 }
00252
00253
00254 } else {
00255
00256
00257
00258
00259
00260
00261
00262
00263
00264
00265
00266
00267
00268 }
00269
00270 if (collector.size()>0){
00271 ClusterCollectionFP420::Range inputRange;
00272 inputRange.first = collector.begin();
00273 inputRange.second = collector.end();
00274
00275 if (verbosity > 0) {
00276 std::cout << " FP420ClusterMain:7 collector.size()>0 " << std::endl;
00277 }
00278 if ( first ) {
00279
00280 first = false;
00281 unsigned int detID0 = 0;
00282 if (verbosity > 0) {
00283 std::cout << " FP420ClusterMain:8 first soutput->put " << std::endl;
00284 }
00285 soutput->put(inputRange,detID0);
00286 }
00287
00288
00289 if (verbosity > 0) {
00290 std::cout << " FP420ClusterMain:9 soutput->put " << std::endl;
00291 }
00292 soutput->put(inputRange,detID);
00293
00294 number_localelectroderechits += collector.size();
00295 }
00296 }
00297 if (verbosity > 0) {
00298 std::cout << "[FP420ClusterMain] execution in mode " << clusterMode_ << " generating " << number_localelectroderechits << " ClusterFP420s in " << number_detunits << " DetUnits." << std::endl;
00299 }
00300 }
00301 }
00302 }
00303 }
00304 }
00305
00306 if (verbosity == -50 ) {
00307
00308
00309 for (int det=1; det<dn0; det++) {
00310 for (int sector=1; sector<sn0; sector++) {
00311 for (int zmodule=1; zmodule<pn0; zmodule++) {
00312 for (int zside=1; zside<rn0; zside++) {
00313
00314 unsigned int iu = theFP420NumberingScheme->FP420NumberingScheme::packMYIndex(rn0, pn0, sn0, det, zside, sector, zmodule);
00315 std::cout <<" iu = " << iu <<" sector = " << sector <<" zmodule = " << zmodule <<" zside = " << zside << " det=" << det << std::endl;
00316 std::vector<ClusterFP420> collector;
00317 collector.clear();
00318 ClusterCollectionFP420::Range outputRange;
00319 outputRange = soutput->get(iu);
00320
00321 ClusterCollectionFP420::ContainerIterator sort_begin = outputRange.first;
00322 ClusterCollectionFP420::ContainerIterator sort_end = outputRange.second;
00323 for ( ;sort_begin != sort_end; ++sort_begin ) {
00324 collector.push_back(*sort_begin);
00325 }
00326 std::cout <<" ===" << std::endl;
00327 std::cout <<" ===" << std::endl;
00328 std::cout <<" =========== FP420ClusterMain:check: iu= " << iu << " zside = " << zside << std::endl;
00329 std::cout <<" ======renew collector size = " << collector.size() << std::endl;
00330 std::cout <<" ===" << std::endl;
00331 std::cout <<" ===" << std::endl;
00332 std::vector<ClusterFP420>::const_iterator simHitIter = collector.begin();
00333 std::vector<ClusterFP420>::const_iterator simHitIterEnd = collector.end();
00334
00335 for (;simHitIter != simHitIterEnd; ++simHitIter) {
00336 const ClusterFP420 icluster = *simHitIter;
00337
00338 std::cout << " ===== size of cluster= " << icluster.amplitudes().size() << std::endl;
00339 std::cout <<" ===" << std::endl;
00340 std::cout << " ===== firstStrip = " << icluster.firstStrip() << " barycenter = " << icluster.barycenter() << " barycenterW = " << icluster.barycenterW() << std::endl;
00341 std::cout <<" ===" << std::endl;
00342 for(unsigned int i = 0; i < icluster.amplitudes().size(); i++ ) {
00343 std::cout << "i = " << i << " amplitudes = " << icluster.amplitudes()[i] << std::endl;
00344 }
00345 std::cout <<" ===" << std::endl;
00346 std::cout <<" ===" << std::endl;
00347 std::cout <<" =======================" << std::endl;
00348
00349 }
00350
00351
00352
00353
00354
00355
00356
00357
00358
00359
00360 }
00361 }
00362 }
00363 }
00364
00365
00366 std::cout <<"======= FP420ClusterMain: end of check " << std::endl;
00367
00368 }
00369
00370
00371
00372 }
00373 }