19 #include "CLHEP/Random/RandFlat.h"
20 #include "CLHEP/Random/RandGaussQ.h"
26 :theDischargeNoiseRate(0),
27 theIonFeedbackFirstPeakRate(0),
28 theIonFeedbackSecondPeakRate(0),
35 string pName = filepath.fullPath();
37 if (pName.find(
".") == 0)
56 std::cerr <<
"HPD Handle Object is not valid!" << endl;
81 }
else if (zside == -1) {
84 cerr <<
" ZSide Calculation Error." << endl;
93 std::cerr <<
" HPD Name in the library is not valid." << std::endl;
104 CLHEP::RandFlat::shootArray(engine, 144, rndm);
106 for (
int i = 0;
i < 144; ++
i) {
118 CLHEP::RandFlat::shootArray(engine, 144, rndm);
119 for (
int i = 0;
i < 144; ++
i) {
126 int iPhi = (CLHEP::RandFlat::shootInt(engine, 144)) + 1;
134 vector <pair< HcalDetId, const float *> >
result;
144 for (
unsigned int i = 0;
i < data->
size(); ++
i) {
154 vector <pair< HcalDetId, const float *> >
result;
163 for (
unsigned int i = 0;
i < data->
size(); ++
i) {
166 const float* _data_ =
const_cast<const float*
>(data_);
175 vector < pair < HcalDetId, const float *> >
result;
186 for (
unsigned int i = 0;
i < data->
size(); ++
i) {
189 const float* _data_ =
const_cast<const float*
>(data_);
198 vector < pair < HcalDetId, const float *> >
result;
209 for (
unsigned int i = 0;
i < data->
size(); ++
i) {
220 double GeVperfC = 0.177;
221 double PedSigma = 0.8;
224 int iphi = (
id.ieta() > 0) ? (
id.iphi()) : (
id.iphi() + 72);
229 rateInTail = rateInTail * bias;
230 rateInSecondTail = rateInSecondTail * bias;
232 edm::LogError(
"HPDNoise") <<
"HPDNoise: ion feedback error (biased or unbiased selection)." << bias <<
" failed";
234 <<
"Usage of " << bias <<
" fails\n";
236 double Charge = energy / GeVperfC;
249 double p4 = 2.06117e+01;
250 double p5 = 1.09239e+01;
254 double p7 = 5.45548e+01;
255 double p8 = 1.59696e+01;
257 if (Charge > 3 * PedSigma) {
258 int npe = int (Charge / pe2Charge);
262 for (
int j = 0;
j < npe; ++
j) {
263 double probability = CLHEP::RandFlat::shoot(engine);
265 if (probability < rateInTail) {
266 if (probability < rateInSecondTail) {
268 noise += b * p8 + p7;
271 noise += b * p5 +
p4;
277 noise += CLHEP::RandGaussQ::shoot(engine, 0, 2 * PedSigma);
279 return (noise * GeVperfC);
285 bool isAccepted =
false;
286 vector < int >::iterator phi_iter;
296 if(timeSliceId == -1 || (timeSliceId>=10))
return;
298 float Data[10] = {0.,0.,0.,0.,0.,0.,0.,0.,0.,0.};
299 for(
int i=0;
i<10;++
i){
304 for(
int i=0;
i<10;++
i){
316 for(
int i=0;
i<10;++
i){
318 int newIdx = timeSliceId+
k;
321 data[newIdx] = Data[ts_max+
k];
339 y = CLHEP::RandFlat::shoot(engine);
340 z = CLHEP::RandFlat::shoot(engine);
341 x = z * 6.28318530717958623;
342 r = TMath::Sqrt(-2 * TMath::Log(y));
343 a = r * TMath::Sin(x);
344 b = r * TMath::Cos(x);
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
std::vector< float > theIonFeedbackFirstPeakRate
const HPDNoiseDataFrame & getDataFrame(size_t i) const
retrive frame for the given index
const float * getFrame() const
array of 10 charges corresponding to one channel
float dischargeRate(Handle fHandle) const
discharge rate for the instance
HPDNoiseLibraryReader(const edm::ParameterSet &)
Handle getHandle(const std::string &fName)
get handle to access data for one HPD instance
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
std::vector< std::pair< HcalDetId, const float * > > getBiasedNoisyHcalDetIds(CLHEP::HepRandomEngine *)
unsigned long totalEntries(Handle fHandle) const
total number of noise events for the HPD instance in the library
std::vector< int > theNoisyPhi
void Rannor(double &a, double &b, CLHEP::HepRandomEngine *)
float ionFeedbackSecondPeakRate(Handle fHandle) const
std::vector< float > theIonFeedbackSecondPeakRate
bool valid(Handle fHandle) const
test if handle is valid
double getIonFeedbackNoise(HcalDetId id, double energy, double bias, CLHEP::HepRandomEngine *)
std::vector< std::string > theNames
HcalDetId id() const
detId for the frame
void getBiasedNoisyPhis(CLHEP::HepRandomEngine *)
std::vector< std::string > allNames() const
all HPD instances in the library
std::vector< float > theDischargeNoiseRate
HPDNoiseData * getNoiseData(int iphi, CLHEP::HepRandomEngine *)
float ionFeedbackFirstPeakRate(Handle fHandle) const
ionfeedback rate for the instance
char data[epos_bytes_allocation]
bool IsNoiseApplicable(int iphi)
void getEntry(Handle fHandle, HPDNoiseData **fData)
retrive one entry from the sequentially
void getNoisyPhis(CLHEP::HepRandomEngine *)
std::vector< std::pair< HcalDetId, const float * > > getNoisyHcalDetIds(CLHEP::HepRandomEngine *)
unsigned size() const
number of noise channels in the event
void shuffleData(int timeSliceId, float *&data)
HPDNoiseReader * theReader