Go to the documentation of this file.00001
00002
00003
00004
00005
00007 #include "SimDataFormats/TrackingHit/interface/PSimHit.h"
00008 #include "SimDataFormats/TrackingHit/interface/PSimHitContainer.h"
00009
00010
00011
00012
00013 #include "SimRomanPot/SimFP420/interface/FP420DigiMain.h"
00014
00015 #include "SimRomanPot/SimFP420/interface/ChargeDrifterFP420.h"
00016 #include "SimRomanPot/SimFP420/interface/ChargeDividerFP420.h"
00017
00018
00019 #include "DataFormats/FP420Digi/interface/HDigiFP420.h"
00020
00021
00022
00023
00024
00025
00026
00027 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00028 #include <gsl/gsl_sf_erf.h>
00029 #include "CLHEP/Random/RandGauss.h"
00030 #include "CLHEP/Random/RandFlat.h"
00031 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00032
00033 #include <vector>
00034 #include <iostream>
00035 using namespace std;
00036
00037
00038
00039
00040
00041
00042 FP420DigiMain::FP420DigiMain(const edm::ParameterSet& conf):conf_(conf){
00043 std::cout << "Creating a FP420DigiMain" << std::endl;
00044 ndigis=0;
00045 verbosity = conf_.getUntrackedParameter<int>("VerbosityLevel");
00046 theElectronPerADC= conf_.getParameter<double>("ElectronFP420PerAdc");
00047 theThreshold = conf_.getParameter<double>("AdcFP420Threshold");
00048 noNoise = conf_.getParameter<bool>("NoFP420Noise");
00049 addNoisyPixels = conf_.getParameter<bool>("AddNoisyPixels");
00050 thez420 = conf_.getParameter<double>("z420");
00051 thezD2 = conf_.getParameter<double>("zD2");
00052 thezD3 = conf_.getParameter<double>("zD3");
00053 theApplyTofCut = conf_.getParameter<bool>("ApplyTofCut");
00054 tofCut = conf_.getParameter<double>("LowtofCutAndTo200ns");
00055
00056
00057
00058 xytype = 2;
00059 if(verbosity>0) {
00060 std::cout << "theApplyTofCut=" << theApplyTofCut << " tofCut=" << tofCut << std::endl;
00061 std::cout << "FP420DigiMain theElectronPerADC=" << theElectronPerADC << " theThreshold=" << theThreshold << " noNoise=" << noNoise << std::endl;
00062 }
00063
00064
00065 Thick300 = 0.300;
00066
00067 ENC= 960.;
00068
00069 ldriftX = 0.050;
00070 ldriftY = 0.050;
00071 moduleThickness = 0.250;
00072
00073 pitchY= 0.050;
00074 pitchX= 0.050;
00075
00076
00077 numStripsY = 144;
00078 numStripsX = 160;
00079
00080 pitchYW= 0.400;
00081 pitchXW= 0.400;
00082
00083
00084 numStripsYW = 20;
00085 numStripsXW = 18;
00086
00087
00088 elossCut = 0.00003;
00089
00090 if(verbosity>0) std::cout << "FP420DigiMain moduleThickness=" << moduleThickness << std::endl;
00091
00092 theFP420NumberingScheme = new FP420NumberingScheme();
00093
00094 float noiseRMS = ENC*moduleThickness/Thick300;
00095
00096
00097
00099
00100 if (xytype ==1) {
00101 numStrips = numStripsY;
00102 pitch= pitchY;
00103 ldrift = ldriftX;
00104 numStripsW = numStripsYW;
00105 pitchW= pitchYW;
00106 }
00107
00108 if (xytype ==2) {
00109 numStrips = numStripsX;
00110 pitch= pitchX;
00111 ldrift = ldriftY;
00112 numStripsW = numStripsXW;
00113 pitchW= pitchXW;
00114 }
00115
00116
00117
00118
00119 theHitDigitizerFP420 = new HitDigitizerFP420(moduleThickness,ldrift,ldriftY,ldriftX,thez420,thezD2,thezD3,verbosity);
00120 int numPixels = numStrips*numStripsW;
00121 theGNoiseFP420 = new GaussNoiseFP420(numPixels,noiseRMS,theThreshold,addNoisyPixels,verbosity);
00122
00124
00125
00126
00127
00128 theZSuppressFP420 = new ZeroSuppressFP420(conf_,noiseRMS/theElectronPerADC);
00129 thePileUpFP420 = new PileUpFP420();
00130 theDConverterFP420 = new DigiConverterFP420(theElectronPerADC,verbosity);
00131
00132 if(verbosity>0) std::cout << "FP420DigiMain end of constructor" << std::endl;
00133
00134 }
00135
00136
00137
00138
00139
00140
00141
00142 FP420DigiMain::~FP420DigiMain(){
00143 if(verbosity>0) {
00144 std::cout << "Destroying a FP420DigiMain" << std::endl;
00145 }
00146 delete theGNoiseFP420;
00147 delete theZSuppressFP420;
00148 delete theHitDigitizerFP420;
00149 delete thePileUpFP420;
00150 delete theDConverterFP420;
00151
00152 }
00153
00154
00155
00156
00157
00158
00159 vector <HDigiFP420> FP420DigiMain::run(const std::vector<PSimHit> &input,
00160 G4ThreeVector bfield, unsigned int iu ) {
00161
00162
00163
00164
00165
00166
00167 thePileUpFP420->reset();
00168
00169
00170 bool first = true;
00171
00172
00173
00174
00175
00176 std::vector<PSimHit>::const_iterator simHitIter = input.begin();
00177 std::vector<PSimHit>::const_iterator simHitIterEnd = input.end();
00178 for (;simHitIter != simHitIterEnd; ++simHitIter) {
00179
00180 const PSimHit ihit = *simHitIter;
00181
00182 if ( first ) {
00183
00184 first = false;
00185 }
00186
00187
00188 double losenergy = ihit.energyLoss();
00189 float tof = ihit.tof();
00190
00191 if(verbosity>1) {
00192 unsigned int unitID = ihit.detUnitId();
00193 std::cout << " *******FP420DigiMain: intindex= " << iu << std::endl;
00194 std::cout << " tof= " << tof << " EnergyLoss= " << losenergy << " pabs= " << ihit.pabs() << std::endl;
00195 std::cout << " EntryLocalP x= " << ihit.entryPoint().x() << " EntryLocalP y= " << ihit.entryPoint().y() << std::endl;
00196 std::cout << " ExitLocalP x= " << ihit.exitPoint().x() << " ExitLocalP y= " << ihit.exitPoint().y() << std::endl;
00197 std::cout << " EntryLocalP z= " << ihit.entryPoint().z() << " ExitLocalP z= " << ihit.exitPoint().z() << std::endl;
00198 std::cout << " unitID= " << unitID << " xytype= " << xytype << " particleType= " << ihit.particleType() << " trackId= " << ihit.trackId() << std::endl;
00199
00200 std::cout << " bfield= " << bfield << std::endl;
00201 }
00202 if(verbosity>0) {
00203 std::cout << " *******FP420DigiMain: theApplyTofCut= " << theApplyTofCut << std::endl;
00204 std::cout << " tof= " << tof << " EnergyLoss= " << losenergy << " pabs= " << ihit.pabs() << std::endl;
00205 std::cout << " particleType= " << ihit.particleType() << std::endl;
00206 }
00207
00208
00209
00210
00211 if ( ( !(theApplyTofCut) || ( theApplyTofCut && abs(tof) > tofCut && abs(tof) < (tofCut+200.)) ) && losenergy > elossCut) {
00212
00213
00214 if(verbosity>0) std::cout << " inside tof: OK " << std::endl;
00215
00216
00217
00218 HitDigitizerFP420::hit_map_type _temp = theHitDigitizerFP420->processHit(ihit,bfield,xytype,numStrips,pitch,numStripsW,pitchW,moduleThickness,verbosity);
00219
00220
00221
00222 thePileUpFP420->add(_temp,ihit,verbosity);
00223
00224 }
00225
00226 else {
00227
00228 }
00229
00230 }
00231
00232
00233 PileUpFP420::signal_map_type theSignal = thePileUpFP420->dumpSignal();
00234 PileUpFP420::HitToDigisMapType theLink = thePileUpFP420->dumpLink();
00235
00236
00237 PileUpFP420::signal_map_type afterNoise;
00238
00239 if (noNoise) {
00240 afterNoise = theSignal;
00241 } else {
00242 afterNoise = theGNoiseFP420->addNoise(theSignal);
00243
00244 }
00245
00246
00247
00248
00249
00250
00251 digis.clear();
00252
00253
00254
00255
00256 push_digis(theZSuppressFP420->zeroSuppress(theDConverterFP420->convert(afterNoise),verbosity),
00257 theLink,afterNoise);
00258
00259
00260
00261 return digis;
00262 }
00263
00264
00265
00266
00267
00268 void FP420DigiMain::push_digis(const DigitalMapType& dm,
00269 const HitToDigisMapType& htd,
00270 const PileUpFP420::signal_map_type& afterNoise
00271 ) {
00272
00273 if(verbosity>0) {
00274 std::cout << " ****FP420DigiMain: push_digis start: do for loop dm.size()=" << dm.size() << std::endl;
00275 }
00276
00277
00278 digis.reserve(50);
00279 digis.clear();
00280
00281 for ( DigitalMapType::const_iterator i=dm.begin(); i!=dm.end(); i++) {
00282
00283
00284
00285 digis.push_back( HDigiFP420( (*i).first, (*i).second));
00286 ndigis++;
00287
00288 if(verbosity>0) {
00289 std::cout << " ****FP420DigiMain:push_digis: ndigis = " << ndigis << std::endl;
00290 std::cout << "push_digis: strip = " << (*i).first << " adc = " << (*i).second << std::endl;
00291 }
00292
00293 }
00294
00296
00297
00298
00299
00300
00301
00302
00303
00304
00305
00306
00307
00308
00309
00310
00311
00312
00313
00314
00315
00316
00317
00318
00319
00320
00321
00323
00324
00325
00326 for ( HitToDigisMapType::const_iterator mi=htd.begin(); mi!=htd.end(); mi++) {
00327
00328 if ((*((const_cast<DigitalMapType * >(&dm)))).find((*mi).first) != (*((const_cast<DigitalMapType * >(&dm)))).end() ){
00329
00330
00331 map<const PSimHit *, Amplitude> totalAmplitudePerSimHit;
00332 for (std::vector < std::pair < const PSimHit*, Amplitude > >::const_iterator simul =
00333 (*mi).second.begin() ; simul != (*mi).second.end(); simul ++){
00334 totalAmplitudePerSimHit[(*simul).first] += (*simul).second;
00335 }
00336
00337
00338
00339
00340
00341
00342
00343
00344
00345
00346
00347
00348
00349
00350
00351
00352
00353
00354
00355
00356
00357
00358
00359
00360 }
00361 }
00362
00363
00365
00366
00367
00368 }