CMS 3D CMS Logo

FP420DigiMain.cc
Go to the documentation of this file.
1 // File: FP420DigiMain.cc
3 // Date: 12.2006
4 // Description: FP420DigiMain for FP420
5 // Modifications:
10 
13 
15 
16 #include "CLHEP/Random/RandFlat.h"
17 #include "CLHEP/Random/RandGauss.h"
20 #include <gsl/gsl_sf_erf.h>
21 
22 #include <iostream>
23 #include <vector>
24 using namespace std;
25 
26 //#define CBOLTZ (1.38E-23)
27 //#define e_SI (1.6E-19)
28 
29 FP420DigiMain::FP420DigiMain(const edm::ParameterSet &conf) : conf_(conf) {
30  edm::LogInfo("SimRomanPotSimFP420") << "Creating a FP420DigiMain";
31  ndigis = 0;
32  verbosity = conf_.getUntrackedParameter<int>("VerbosityLevel");
33  theElectronPerADC = conf_.getParameter<double>("ElectronFP420PerAdc");
34  theThreshold = conf_.getParameter<double>("AdcFP420Threshold");
35  noNoise = conf_.getParameter<bool>("NoFP420Noise");
36  addNoisyPixels = conf_.getParameter<bool>("AddNoisyPixels");
37  thez420 = conf_.getParameter<double>("z420");
38  thezD2 = conf_.getParameter<double>("zD2");
39  thezD3 = conf_.getParameter<double>("zD3");
40  theApplyTofCut = conf_.getParameter<bool>("ApplyTofCut");
41  tofCut = conf_.getParameter<double>("LowtofCutAndTo200ns");
42  // sn0 = 3;// number of stations
43  // pn0 = 6;// number of superplanes
44  // rn0 = 3; // number of sensors in superlayer
45  xytype = 2;
46 
47  edm::LogInfo("SimRomanPotSimFP420") << "theApplyTofCut=" << theApplyTofCut << " tofCut=" << tofCut << "\n"
48  << "FP420DigiMain theElectronPerADC=" << theElectronPerADC
49  << " theThreshold=" << theThreshold << " noNoise=" << noNoise;
50 
51  // X (or Y)define type of sensor (xytype=1 or 2 used to derive it: 1-Y, 2-X)
52  // for every type there is normal pixel size=0.05 and Wide 0.400 mm
53  Thick300 = 0.300; // = 0.300 mm normalized to 300micron Silicon
54  // ENC= 2160.; // EquivalentNoiseCharge300um = 2160. +
55  // other sources of noise
56  ENC = 960.; // EquivalentNoiseCharge300um = 2160. + other sources of
57  // noise
58 
59  ldriftX = 0.050; // in mm(xytype=1)
60  ldriftY = 0.050; // in mm(xytype=2)
61  moduleThickness = 0.250; // mm(xytype=1)(xytype=2)
62 
63  pitchY = 0.050; // in mm(xytype=1)
64  pitchX = 0.050; // in mm(xytype=2)
65  // numStripsY = 200; // Y plate number of strips:200*0.050=10mm
66  // (xytype=1) numStripsX = 400; // X plate number of
67  // strips:400*0.050=20mm (xytype=2)
68  numStripsY = 144; // Y plate number of strips:144*0.050=7.2mm (xytype=1)
69  numStripsX = 160; // X plate number of strips:160*0.050=8.0mm (xytype=2)
70 
71  pitchYW = 0.400; // in mm(xytype=1)
72  pitchXW = 0.400; // in mm(xytype=2)
73  // numStripsYW = 50; // Y plate number of W strips:50 *0.400=20mm
74  // (xytype=1) - W have ortogonal projection numStripsXW = 25; // X
75  // plate number of W strips:25 *0.400=10mm (xytype=2) - W have ortogonal
76  // projection
77  numStripsYW = 20; // Y plate number of W strips:20 *0.400=8.0mm (xytype=1) - W
78  // have ortogonal projection
79  numStripsXW = 18; // X plate number of W strips:18 *0.400=7.2mm (xytype=2) - W
80  // have ortogonal projection
81 
82  // tofCut = 1350.; // Cut on the particle TOF range = 1380 - 1500
83  elossCut = 0.00003; // Cut on the particle TOF = 100 or 50
84 
85  edm::LogInfo("SimRomanPotSimFP420") << "FP420DigiMain moduleThickness=" << moduleThickness;
86 
87  float noiseRMS = ENC * moduleThickness / Thick300;
88 
90  // Y:
91  if (xytype == 1) {
92  numStrips = numStripsY; // Y plate number of strips:200*0.050=10mm -->
93  // 100*0.100=10mm
94  pitch = pitchY;
95  ldrift = ldriftX; // because drift is in local coordinates which 90 degree
96  // rotated ( for correct timeNormalization & noiseRMS
97  // calculations)
98  numStripsW = numStripsYW; // Y plate number of strips:200*0.050=10mm -->
99  // 100*0.100=10mm
100  pitchW = pitchYW;
101  }
102  // X:
103  if (xytype == 2) {
104  numStrips = numStripsX; // X plate number of strips:400*0.050=20mm -->
105  // 200*0.100=20mm
106  pitch = pitchX;
107  ldrift = ldriftY; // because drift is in local coordinates which 90 degree
108  // rotated ( for correct timeNormalization & noiseRMS
109  // calculations)
110  numStripsW = numStripsXW; // X plate number of strips:400*0.050=20mm -->
111  // 200*0.100=20mm
112  pitchW = pitchXW;
113  }
114 
117  int numPixels = numStrips * numStripsW;
120  thePileUpFP420 = new PileUpFP420();
122 
123  edm::LogInfo("SimRomanPotSimFP420") << "FP420DigiMain end of constructor";
124 }
125 
127  delete theGNoiseFP420;
128  delete theZSuppressFP420;
129  delete theHitDigitizerFP420;
130  delete thePileUpFP420;
131  delete theDConverterFP420;
132 }
133 
134 // Run the algorithm
135 // ------------------
136 
137 vector<HDigiFP420> FP420DigiMain::run(const std::vector<PSimHit> &input, const G4ThreeVector &bfield, unsigned int iu) {
139  bool first = true;
140 
141  // main loop
142  //
143  // First: loop on the SimHits
144  //
145  std::vector<PSimHit>::const_iterator simHitIter = input.begin();
146  std::vector<PSimHit>::const_iterator simHitIterEnd = input.end();
147  for (; simHitIter != simHitIterEnd; ++simHitIter) {
148  const PSimHit ihit = *simHitIter;
149 
150  if (first) {
151  // detID = ihit.detUnitId();
152  first = false;
153  }
154 
155  // main part here:
156  double losenergy = ihit.energyLoss();
157  float tof = ihit.tof();
158 
159  if (verbosity > 1) {
160  unsigned int unitID = ihit.detUnitId();
161  std::cout << " *******FP420DigiMain: intindex= " << iu << std::endl;
162  std::cout << " tof= " << tof << " EnergyLoss= " << losenergy << " pabs= " << ihit.pabs() << std::endl;
163  std::cout << " EntryLocalP x= " << ihit.entryPoint().x() << " EntryLocalP y= " << ihit.entryPoint().y()
164  << std::endl;
165  std::cout << " ExitLocalP x= " << ihit.exitPoint().x() << " ExitLocalP y= " << ihit.exitPoint().y() << std::endl;
166  std::cout << " EntryLocalP z= " << ihit.entryPoint().z() << " ExitLocalP z= " << ihit.exitPoint().z()
167  << std::endl;
168  std::cout << " unitID= " << unitID << " xytype= " << xytype << " particleType= " << ihit.particleType()
169  << " trackId= " << ihit.trackId() << std::endl;
170  // std::cout << " det= " << det << " sector= " << sector << " zmodule=
171  // " << zmodule << std::endl;
172  std::cout << " bfield= " << bfield << std::endl;
173  }
174  if (verbosity > 0) {
175  std::cout << " *******FP420DigiMain: theApplyTofCut= " << theApplyTofCut << std::endl;
176  std::cout << " tof= " << tof << " EnergyLoss= " << losenergy << " pabs= " << ihit.pabs() << std::endl;
177  std::cout << " particleType= " << ihit.particleType() << std::endl;
178  }
179 
180  if ((!(theApplyTofCut) || (theApplyTofCut && abs(tof) > tofCut && abs(tof) < (tofCut + 200.))) &&
181  losenergy > elossCut) {
182  if (verbosity > 0)
183  std::cout << " inside tof: OK " << std::endl;
184 
187 
188  thePileUpFP420->add(_temp, ihit, verbosity);
189  }
190  // main part end (AZ)
191  } // for
192  // main loop end (AZ)
193 
196 
197  PileUpFP420::signal_map_type afterNoise;
198 
199  if (noNoise) {
200  afterNoise = theSignal;
201  } else {
202  afterNoise = theGNoiseFP420->addNoise(theSignal);
203  // add_noise();
204  }
205  digis.clear();
206 
207  push_digis(theZSuppressFP420->zeroSuppress(theDConverterFP420->convert(afterNoise), verbosity), theLink, afterNoise);
208 
209  return digis; // to HDigiFP420
210 }
211 
213  const HitToDigisMapType &htd,
214  const PileUpFP420::signal_map_type &afterNoise) {
215  //
216  if (verbosity > 0) {
217  std::cout << " ****FP420DigiMain: push_digis start: do for loop dm.size()=" << dm.size() << std::endl;
218  }
219 
220  digis.reserve(50);
221  digis.clear();
222  // link_coll.clear();
223  for (DigitalMapType::const_iterator i = dm.begin(); i != dm.end(); i++) {
224  // Load digis
225  // push to digis the content of first and second words of HDigiFP420 vector
226  // for every strip pointer (*i)
227  digis.push_back(HDigiFP420((*i).first, (*i).second));
228  ndigis++;
229  // very useful check:
230  if (verbosity > 0) {
231  std::cout << " ****FP420DigiMain:push_digis: ndigis = " << ndigis << std::endl;
232  std::cout << "push_digis: strip = " << (*i).first << " adc = " << (*i).second << std::endl;
233  }
234  }
235 
237 
238  // reworked to access the fraction of amplitude per simhit
239 
240  for (HitToDigisMapType::const_iterator mi = htd.begin(); mi != htd.end(); mi++) {
241  //
242  if (dm.find((*mi).first) != dm.end()) {
243  // --- For each channel, sum up the signals from a simtrack
244  //
245  map<const PSimHit *, Amplitude> totalAmplitudePerSimHit;
246  for (std::vector<std::pair<const PSimHit *, Amplitude>>::const_iterator simul = (*mi).second.begin();
247  simul != (*mi).second.end();
248  simul++) {
249  totalAmplitudePerSimHit[(*simul).first] += (*simul).second;
250  }
251  /*
252  //--- include the noise as well
253 
254  PileUpFP420::signal_map_type& temp1 =
255  const_cast<PileUpFP420::signal_map_type&>(afterNoise); float
256  totalAmplitude1 = temp1[(*mi).first];
257 
258  //--- digisimlink
259  for (std::map<const PSimHit *, Amplitude>::const_iterator iter =
260  totalAmplitudePerSimHit.begin(); iter != totalAmplitudePerSimHit.end();
261  iter++){
262 
263  float threshold = 0.;
264  if (totalAmplitudePerSimHit[(*iter).first]/totalAmplitude1 >= threshold) {
265  float fraction = totalAmplitudePerSimHit[(*iter).first]/totalAmplitude1;
266 
267  //Noise fluctuation could make fraction>1. Unphysical, set it by hand.
268  if(fraction >1.) fraction = 1.;
269 
270  link_coll.push_back(StripDigiSimLink( (*mi).first, //channel
271  ((*iter).first)->trackId(), //simhit
272  fraction)); //fraction
273  }//if
274  }//for
275  */
276  //
277  } // if
278  } // for
279 }
HitDigitizerFP420::processHit
hit_map_type processHit(const PSimHit &, const G4ThreeVector &, int, int, double, int, double, double, int)
Definition: HitDigitizerFP420.cc:126
FP420DigiMain::theZSuppressFP420
ZeroSuppressFP420 * theZSuppressFP420
Definition: FP420DigiMain.h:155
FP420DigiMain::numStripsW
int numStripsW
Definition: FP420DigiMain.h:165
mps_fire.i
i
Definition: mps_fire.py:355
input
static const std::string input
Definition: EdmProvDump.cc:48
MessageLogger.h
FP420DigiMain::numStripsY
int numStripsY
Definition: FP420DigiMain.h:161
FP420DigiMain::~FP420DigiMain
~FP420DigiMain()
Definition: FP420DigiMain.cc:126
FP420DigiMain::push_digis
void push_digis(const DigitalMapType &, const HitToDigisMapType &, const PileUpFP420::signal_map_type &)
Definition: FP420DigiMain.cc:212
FP420DigiMain::ldriftY
double ldriftY
Definition: FP420DigiMain.h:96
PV3DBase::x
T x() const
Definition: PV3DBase.h:59
FP420DigiMain::theDConverterFP420
DigiConverterFP420 * theDConverterFP420
Definition: FP420DigiMain.h:156
FP420DigiMain::thePileUpFP420
PileUpFP420 * thePileUpFP420
Definition: FP420DigiMain.h:153
FP420DigiMain::ldrift
double ldrift
Definition: FP420DigiMain.h:97
FP420DigiMain::digis
std::vector< HDigiFP420 > digis
Definition: FP420DigiMain.h:194
FP420DigiMain::noNoise
bool noNoise
Definition: FP420DigiMain.h:80
gather_cfg.cout
cout
Definition: gather_cfg.py:144
FP420DigiMain::DigitalMapType
DConverterFP420::DigitalMapType DigitalMapType
Definition: FP420DigiMain.h:36
PSimHitContainer.h
FP420DigiMain::pitchX
double pitchX
Definition: FP420DigiMain.h:88
edm::LogInfo
Definition: MessageLogger.h:254
ChargeDrifterFP420.h
PSimHit::tof
float tof() const
deprecated name for timeOfFlight()
Definition: PSimHit.h:76
ZeroSuppressFP420::zeroSuppress
ZSuppressFP420::DigitalMapType zeroSuppress(const DigitalMapType &, int) override
Definition: ZeroSuppressFP420.cc:66
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
ChargeDividerFP420.h
FP420DigiMain::conf_
edm::ParameterSet conf_
Definition: FP420DigiMain.h:54
FP420DigiMain::thezD2
double thezD2
Definition: FP420DigiMain.h:72
FP420DigiMain::tofCut
double tofCut
Definition: FP420DigiMain.h:85
dqmdumpme.first
first
Definition: dqmdumpme.py:55
PSimHit::entryPoint
Local3DPoint entryPoint() const
Entry point in the local Det frame.
Definition: PSimHit.h:43
FP420DigiMain::pitchY
double pitchY
Definition: FP420DigiMain.h:89
PileUpFP420::reset
void reset()
Definition: PileUpFP420.h:20
FP420DigiMain::Thick300
float Thick300
Definition: FP420DigiMain.h:62
PSimHit::detUnitId
unsigned int detUnitId() const
Definition: PSimHit.h:97
FP420DigiMain::pitchW
double pitchW
Definition: FP420DigiMain.h:93
FP420DigiMain::xytype
int xytype
Definition: FP420DigiMain.h:57
PV3DBase::z
T z() const
Definition: PV3DBase.h:61
HitDigitizerFP420::hit_map_type
std::map< int, float, std::less< int > > hit_map_type
Definition: HitDigitizerFP420.h:18
PSimHit::pabs
float pabs() const
fast and more accurate access to momentumAtEntry().mag()
Definition: PSimHit.h:67
GaussNoiseFP420
Definition: GaussNoiseFP420.h:7
PSimHit.h
FP420DigiMain::FP420DigiMain
FP420DigiMain(const edm::ParameterSet &conf)
Definition: FP420DigiMain.cc:29
PSimHit::exitPoint
Local3DPoint exitPoint() const
Exit point in the local Det frame.
Definition: PSimHit.h:46
HDigiFP420
Definition: HDigiFP420.h:4
FP420DigiMain::theGNoiseFP420
GaussNoiseFP420 * theGNoiseFP420
Definition: FP420DigiMain.h:152
DigiConverterFP420::convert
DigitalMapType convert(const signal_map_type &) override
Definition: DigiConverterFP420.cc:35
FP420DigiMain::theHitDigitizerFP420
HitDigitizerFP420 * theHitDigitizerFP420
Definition: FP420DigiMain.h:154
FP420DigiMain::moduleThickness
float moduleThickness
Definition: FP420DigiMain.h:168
FP420DigiMain::run
std::vector< HDigiFP420 > run(const std::vector< PSimHit > &input, const G4ThreeVector &, unsigned int)
Definition: FP420DigiMain.cc:137
FP420DigiMain::pitch
double pitch
Definition: FP420DigiMain.h:90
FP420DigiMain::numStripsYW
int numStripsYW
Definition: FP420DigiMain.h:164
FP420DigiMain::numStripsXW
int numStripsXW
Definition: FP420DigiMain.h:163
edm::ParameterSet
Definition: ParameterSet.h:36
FP420DigiMain::theElectronPerADC
float theElectronPerADC
Definition: FP420DigiMain.h:70
PileUpFP420::add
virtual void add(const HitDigitizerFP420::hit_map_type &, const PSimHit &hit, int)
Definition: PileUpFP420.cc:13
PileUpFP420::signal_map_type
std::map< int, Amplitude, std::less< int > > signal_map_type
Definition: PileUpFP420.h:13
FP420DigiMain::addNoisyPixels
bool addNoisyPixels
Definition: FP420DigiMain.h:81
FP420DigiMain::numStrips
int numStrips
Definition: FP420DigiMain.h:162
FP420DigiMain::elossCut
float elossCut
Definition: FP420DigiMain.h:84
FP420DigiMain::theThreshold
float theThreshold
Definition: FP420DigiMain.h:86
FP420DigiMain::HitToDigisMapType
PileUpFP420::HitToDigisMapType HitToDigisMapType
Definition: FP420DigiMain.h:37
PV3DBase::y
T y() const
Definition: PV3DBase.h:60
FP420DigiMain::numStripsX
int numStripsX
Definition: FP420DigiMain.h:160
symbols.dm
dm
Definition: symbols.py:66
FP420DigiMain::thez420
double thez420
Definition: FP420DigiMain.h:71
PileUpFP420
Definition: PileUpFP420.h:10
HitDigitizerFP420
Definition: HitDigitizerFP420.h:16
ZeroSuppressFP420
Definition: ZeroSuppressFP420.h:7
FP420DigiMain::pitchYW
double pitchYW
Definition: FP420DigiMain.h:92
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
FP420DigiMain::pitchXW
double pitchXW
Definition: FP420DigiMain.h:91
FP420DigiMain::verbosity
int verbosity
Definition: FP420DigiMain.h:57
std
Definition: JetResolutionObject.h:76
PSimHit::energyLoss
float energyLoss() const
The energy deposit in the PSimHit, in ???.
Definition: PSimHit.h:79
PSimHit::particleType
int particleType() const
Definition: PSimHit.h:89
PileUpFP420::dumpSignal
signal_map_type dumpSignal()
Definition: PileUpFP420.h:24
FP420DigiMain::ndigis
int ndigis
Definition: FP420DigiMain.h:51
PSimHit::trackId
unsigned int trackId() const
Definition: PSimHit.h:106
FP420DigiMain::ENC
float ENC
Definition: FP420DigiMain.h:74
PileUpFP420::HitToDigisMapType
std::map< int, std::vector< std::pair< const PSimHit *, Amplitude > >, std::less< int > > HitToDigisMapType
Definition: PileUpFP420.h:14
DigiConverterFP420
Definition: DigiConverterFP420.h:6
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
PileUpFP420::dumpLink
HitToDigisMapType dumpLink()
Definition: PileUpFP420.h:25
ParameterSet.h
PSimHit
Definition: PSimHit.h:15
HDigiFP420.h
GaussNoiseFP420::addNoise
PileUpFP420::signal_map_type addNoise(const PileUpFP420::signal_map_type &) override
Definition: GaussNoiseFP420.cc:14
FP420DigiMain::theApplyTofCut
bool theApplyTofCut
Definition: FP420DigiMain.h:82
FP420DigiMain.h
FP420DigiMain::thezD3
double thezD3
Definition: FP420DigiMain.h:73
FP420DigiMain::ldriftX
double ldriftX
Definition: FP420DigiMain.h:95