CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_2_SLHC4_patch1/src/SimCalorimetry/HcalSimAlgos/interface/HPDNoiseLibraryReader.h

Go to the documentation of this file.
00001 
00002 // --------------------------------------------------------
00003 // A class to read HPD noise from the library.
00004 // The deliverable of the class is the collection of
00005 // noisy HcalDetIds with associated noise in units of fC for
00006 // 10 time samples. During the library production a higher
00007 // theshold is used to find a noisy HPD. A lower threshold is
00008 // used to eliminate adding unnecessary quite channels to HPD 
00009 // noise event collection. Therefore user may not see whole 18 
00010 // channels for noisy HPD.
00011 //
00012 // Project: HPD noise library reader
00013 // Author: T.Yetkin University of Iowa, Feb. 7, 2008
00014 // $Id: HPDNoiseLibraryReader.h,v 1.4 2012/08/28 14:50:42 yana Exp $
00015 // --------------------------------------------------------
00016 
00017 #ifndef HcalSimAlgos_HPDNoiseLibraryReader_h
00018 #define HcalSimAlgos_HPDNoiseLibraryReader_h
00019 
00020 #include <memory>
00021 #include <utility>
00022 #include <iostream>
00023 #include <vector>
00024 #include <string>
00025 
00026 #include "FWCore/ParameterSet/interface/FileInPath.h"
00027 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00028 #include "FWCore/Utilities/interface/RandomNumberGenerator.h"
00029 #include "FWCore/ServiceRegistry/interface/Service.h"
00030 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00031 #include "FWCore/PluginManager/interface/PluginManager.h"
00032 #include "FWCore/PluginManager/interface/standard.h"
00033 #include "FWCore/Utilities/interface/Exception.h"
00034 // Hcal Geometry
00035 #include "DataFormats/HcalDetId/interface/HcalDetId.h"
00036 // HPD Noise Data Frame
00037 #include "SimCalorimetry/HcalSimAlgos/interface/HPDNoiseReader.h"
00038 #include "SimCalorimetry/HcalSimAlgos/interface/HPDNoiseData.h"
00039 // CLHEP Random numbers
00040 #include "CLHEP/Random/RandFlat.h"
00041 #include "CLHEP/Random/RandGaussQ.h"
00042 #include "TMath.h"
00043 
00044 class HPDNoiseLibraryReader{
00045   
00046   public:
00047     HPDNoiseLibraryReader(const edm::ParameterSet&);
00048     ~HPDNoiseLibraryReader();
00049     // collection of noisy detIds 
00050     std::vector<std::pair <HcalDetId, const float* > > getNoisyHcalDetIds();
00051     // collection of noisy detIds. At least one HcalDetId is alwasy noiosy
00052     std::vector<std::pair <HcalDetId, const float* > > getBiasedNoisyHcalDetIds();
00053 
00054 
00055     std::vector<std::pair <HcalDetId, const float* > > getNoisyHcalDetIds(int timeSliceId);
00056     // collection of noisy detIds. At least one HcalDetId is alwasy noiosy
00057     std::vector < std::pair < HcalDetId, const float *> >getBiasedNoisyHcalDetIds(int timeSliceId);
00064     double getIonFeedbackNoise(HcalDetId id, double energy, double bias);
00065     // to be used for standalone tests (from R. Wilkinson)
00066     // taken from SimGeneral/NoiseGenerators/interface/CorrelatedNoisifier.h
00067     static void initializeServices();
00068   protected:
00069     void setRandomEngine();
00070     void setRandomEngine(CLHEP::HepRandomEngine & engine);
00071   private:
00072     HPDNoiseData* getNoiseData(int iphi);
00073     // reads external file provided by the user in /data directrory
00074     // and fill rate for each HPD.
00075     void fillRates();
00076     // compares noise rates for each HPD with randomly thrown numbers
00077     // and returns the collection of Phis.
00078     void getNoisyPhis();
00079     // same as above. The only difference is that at least one phi is
00080     // always noisy
00081     void getBiasedNoisyPhis();
00082     // check if noise is applicable the the HPD
00083     bool IsNoiseApplicable(int iphi);
00084     
00085     //normal random number
00086     void Rannor(double &a, double &b);
00087     
00088     // clear phi vector
00089     void clearPhi();
00090     // use int iphi to create HPD names
00091     std::string itos(int i);    // convert int to string
00092     
00093     void shuffleData(int timeSliceId, float* &data);
00094   
00095   public: 
00096     //members
00097     std::vector<float> theDischargeNoiseRate;
00098     std::vector<float> theIonFeedbackFirstPeakRate;
00099     std::vector<float> theIonFeedbackSecondPeakRate;
00100     std::vector<int>   theNoisyPhi;
00101     CLHEP::RandFlat *     theRandFlat;
00102     CLHEP::RandGaussQ*    theRandGaussQ; 
00103     HPDNoiseReader* theReader;
00104     std::vector <std::string> theNames;
00105     std::string theHPDName;
00106     
00107 };
00108 #endif