23 :theDischargeNoiseRate(0),
24 theIonFeedbackFirstPeakRate(0),
25 theIonFeedbackSecondPeakRate(0),
35 string pName = filepath.fullPath();
37 if (pName.find(
".") == 0)
59 "process CorrNoise = {"
60 "service = RandomNumberGeneratorService" "{" "untracked uint32 sourceSeed = 123456789" "}" "}";
71 throw cms::Exception(
"Configuration") <<
"HcalHPDNoiseLibrary requires the RandomNumberGeneratorService\n"
72 "which is not present in the configuration file. You must add the service\n"
73 "in the configuration file or remove the modules that require it.";
96 std::cerr <<
"HPD Handle Object is not valid!" << endl;
121 }
else if (zside == -1) {
124 cerr <<
" ZSide Calculation Error." << endl;
133 std::cerr <<
" HPD Name in the library is not valid." << std::endl;
146 for (
int i = 0;
i < 144; ++
i) {
159 for (
int i = 0;
i < 144; ++
i) {
174 vector <pair< HcalDetId, const float *> >
result;
184 for (
unsigned int i = 0;
i < data->
size(); ++
i) {
187 result.push_back(tmp_pair);
195 vector <pair< HcalDetId, const float *> >
result;
204 for (
unsigned int i = 0;
i < data->
size(); ++
i) {
207 const float* _data_ =
const_cast<const float*
>(data_);
208 pair < HcalDetId, const float *>tmp_pair(data->
getDataFrame(
i).
id(), _data_);
209 result.push_back(tmp_pair);
217 vector < pair < HcalDetId, const float *> >
result;
228 for (
unsigned int i = 0;
i < data->
size(); ++
i) {
231 const float* _data_ =
const_cast<const float*
>(data_);
232 pair < HcalDetId, const float *>tmp_pair(data->
getDataFrame(
i).
id(), _data_);
233 result.push_back(tmp_pair);
241 vector < pair < HcalDetId, const float *> >
result;
252 for (
unsigned int i = 0;
i < data->
size(); ++
i) {
255 result.push_back(tmp_pair);
265 double GeVperfC = 0.177;
266 double PedSigma = 0.8;
269 int iphi = (
id.ieta() > 0) ? (
id.iphi()) : (
id.iphi() + 72);
274 rateInTail = rateInTail * bias;
275 rateInSecondTail = rateInSecondTail * bias;
277 edm::LogError(
"HPDNoise") <<
"HPDNoise: ion feedback error (biased or unbiased selection)." << bias <<
" failed";
279 <<
"Usage of " << bias <<
" fails\n";
281 double Charge = energy / GeVperfC;
294 double p4 = 2.06117e+01;
295 double p5 = 1.09239e+01;
299 double p7 = 5.45548e+01;
300 double p8 = 1.59696e+01;
302 if (Charge > 3 * PedSigma) {
303 int npe = int (Charge / pe2Charge);
307 for (
int j = 0;
j < npe; ++
j) {
310 if (probability < rateInTail) {
311 if (probability < rateInSecondTail) {
313 noise += b * p8 + p7;
316 noise += b * p5 +
p4;
324 return (noise * GeVperfC);
330 bool isAccepted =
false;
331 vector < int >::iterator phi_iter;
341 if(timeSliceId == -1 || (timeSliceId>=10))
return;
343 float Data[10] = {0.,0.,0.,0.,0.,0.,0.,0.,0.,0.};
344 for(
int i=0;
i<10;++
i){
349 for(
int i=0;
i<10;++
i){
361 for(
int i=0;
i<10;++
i){
363 int newIdx = timeSliceId+
k;
366 data[newIdx] = Data[ts_max+
k];
386 x = z * 6.28318530717958623;
387 r = TMath::Sqrt(-2 * TMath::Log(y));
388 a = r * TMath::Sin(x);
389 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
static PluginManager & configure(const Config &)
const float * getFrame() const
array of 10 charges corresponding to one channel
float dischargeRate(Handle fHandle) const
discharge rate for the instance
CLHEP::RandGaussQ * theRandGaussQ
HPDNoiseLibraryReader(const edm::ParameterSet &)
std::vector< std::pair< HcalDetId, const float * > > getBiasedNoisyHcalDetIds()
Handle getHandle(const std::string &fName)
get handle to access data for one HPD instance
double getIonFeedbackNoise(HcalDetId id, double energy, double bias)
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
unsigned long totalEntries(Handle fHandle) const
total number of noise events for the HPD instance in the library
static bool isAvailable()
std::vector< int > theNoisyPhi
float ionFeedbackSecondPeakRate(Handle fHandle) const
std::vector< float > theIonFeedbackSecondPeakRate
static ServiceToken createServicesFromConfig(std::string const &config)
bool valid(Handle fHandle) const
test if handle is valid
static void initializeServices()
PluginManager::Config config()
const T & max(const T &a, const T &b)
std::vector< std::string > theNames
std::pair< std::string, MonitorElement * > entry
virtual CLHEP::HepRandomEngine & getEngine() const =0
Use this to get the random number engine, this is the only function most users should call...
HcalDetId id() const
detId for the frame
std::vector< std::pair< HcalDetId, const float * > > getNoisyHcalDetIds()
std::vector< std::string > allNames() const
all HPD instances in the library
void Rannor(double &a, double &b)
std::vector< float > theDischargeNoiseRate
CLHEP::RandFlat * theRandFlat
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
HPDNoiseData * getNoiseData(int iphi)
unsigned size() const
number of noise channels in the event
void getBiasedNoisyPhis()
void shuffleData(int timeSliceId, float *&data)
HPDNoiseReader * theReader