CMS 3D CMS Logo

RPCSimAverageNoiseEff Class Reference

#include <SimMuon/RPCDigitizer/src/RPCSimAverageNoiseEff.h>

Inheritance diagram for RPCSimAverageNoiseEff:

RPCSim

List of all members.

Public Member Functions

int getClSize (float posX)
 RPCSimAverageNoiseEff (const edm::ParameterSet &config)
void simulate (const RPCRoll *roll, const edm::PSimHitContainer &rpcHits)
void simulateNoise (const RPCRoll *)
 ~RPCSimAverageNoiseEff ()

Private Member Functions

void init ()

Private Attributes

RPCSynchronizer_rpcSync
double aveCls
double aveEff
std::map< int, std::vector
< double > > 
clsMap
double dtimCs
CLHEP::RandFlat * flatDistribution
double frate
double gate
std::ifstream * infile
double lbGate
int N_hits
int nbxing
CLHEP::RandPoissonQ * poissonDistribution_
double rate
double resEle
double resRPC
CLHEP::HepRandomEngine * rndEngine
bool rpcdigiprint
double sspeed
std::vector< double > sum_clsize
double timOff


Detailed Description

Definition at line 31 of file RPCSimAverageNoiseEff.h.


Constructor & Destructor Documentation

RPCSimAverageNoiseEff::RPCSimAverageNoiseEff ( const edm::ParameterSet config  ) 

Definition at line 50 of file RPCSimAverageNoiseEff.cc.

References _rpcSync, aveCls, aveEff, GenMuonPlsPt100GeV_cfg::cout, dtimCs, lat::endl(), Exception, flatDistribution, frate, gate, edm::ParameterSet::getParameter(), edm::Service< T >::isAvailable(), lbGate, nbxing, rate, resEle, resRPC, rndEngine, rpcdigiprint, sspeed, and timOff.

00050                                                                           : 
00051   RPCSim(config)
00052 {
00053   _rpcSync = new RPCSynchronizer(config);
00054 
00055   aveEff = config.getParameter<double>("averageEfficiency");
00056   aveCls = config.getParameter<double>("averageClusterSize");
00057   resRPC = config.getParameter<double>("timeResolution");
00058   timOff = config.getParameter<double>("timingRPCOffset");
00059   dtimCs = config.getParameter<double>("deltatimeAdjacentStrip");
00060   resEle = config.getParameter<double>("timeJitter");
00061   sspeed = config.getParameter<double>("signalPropagationSpeed");
00062   lbGate = config.getParameter<double>("linkGateWidth");
00063   rpcdigiprint = config.getParameter<bool>("printOutDigitizer");
00064 
00065   rate=config.getParameter<double>("Rate");
00066   nbxing=config.getParameter<int>("Nbxing");
00067   gate=config.getParameter<double>("Gate");
00068   frate=config.getParameter<double>("Frate");
00069 
00070   if (rpcdigiprint) {
00071     std::cout <<"Average Efficiency        = "<<aveEff<<std::endl;
00072     std::cout <<"Average Cluster Size      = "<<aveCls<<" strips"<<std::endl;
00073     std::cout <<"RPC Time Resolution       = "<<resRPC<<" ns"<<std::endl;
00074     std::cout <<"RPC Signal formation time = "<<timOff<<" ns"<<std::endl;
00075     std::cout <<"RPC adjacent strip delay  = "<<dtimCs<<" ns"<<std::endl;
00076     std::cout <<"Electronic Jitter         = "<<resEle<<" ns"<<std::endl;
00077     std::cout <<"Signal propagation time   = "<<sspeed<<" x c"<<std::endl;
00078     std::cout <<"Link Board Gate Width     = "<<lbGate<<" ns"<<std::endl;
00079   }
00080 
00081   edm::Service<edm::RandomNumberGenerator> rng;
00082   if ( ! rng.isAvailable()) {
00083     throw cms::Exception("Configuration")
00084       << "RPCDigitizer requires the RandomNumberGeneratorService\n"
00085       "which is not present in the configuration file.  You must add the service\n"
00086       "in the configuration file or remove the modules that require it.";
00087   }
00088   
00089   rndEngine = &(rng->getEngine());
00090   flatDistribution = new CLHEP::RandFlat(rndEngine);
00091 }

RPCSimAverageNoiseEff::~RPCSimAverageNoiseEff (  ) 

Definition at line 93 of file RPCSimAverageNoiseEff.cc.

00093 {}


Member Function Documentation

int RPCSimAverageNoiseEff::getClSize ( float  posX  ) 

Definition at line 95 of file RPCSimAverageNoiseEff.cc.

References clsMap, flatDistribution, stor::func(), RPCSimSetUp::getClsMap(), RPCSim::getRPCSimSetUp(), iter, max, min, and sum_clsize.

Referenced by simulate().

00096 {
00097 
00098   std::map< int, std::vector<double> > clsMap = getRPCSimSetUp()->getClsMap();
00099 
00100   int cnt = 1;
00101   int min = 1;
00102   int max = 1;
00103   double func=0.0;
00104   std::vector<double> sum_clsize;
00105 
00106   double rr_cl = flatDistribution->fire(1);
00107   if(0.0 <= posX && posX < 0.2)  {
00108     func = (clsMap[1])[(clsMap[1]).size()-1]*(rr_cl);
00109     sum_clsize = clsMap[1];
00110   }
00111   if(0.2 <= posX && posX < 0.4) {
00112     func = (clsMap[2])[(clsMap[2]).size()-1]*(rr_cl);
00113     sum_clsize = clsMap[2];
00114   }
00115   if(0.4 <= posX && posX < 0.6) {
00116     func = (clsMap[3])[(clsMap[3]).size()-1]*(rr_cl);
00117     sum_clsize = clsMap[3];
00118   }
00119   if(0.6 <= posX && posX < 0.8) {
00120     func = (clsMap[4])[(clsMap[4]).size()-1]*(rr_cl);
00121     sum_clsize = clsMap[4];
00122   }
00123   if(0.8 <= posX && posX < 1.0)  {
00124     func = (clsMap[5])[(clsMap[5]).size()-1]*(rr_cl);
00125     sum_clsize = clsMap[5];
00126   }
00127 
00128   for(vector<double>::iterator iter = sum_clsize.begin();
00129       iter != sum_clsize.end(); ++iter){
00130     cnt++;
00131     if(func > (*iter)){
00132       min = cnt;
00133     }
00134     else if(func < (*iter)){
00135       max = cnt;
00136       break;
00137     }
00138   }
00139   return min;
00140 }

void RPCSimAverageNoiseEff::init ( void   )  [inline, private, virtual]

Implements RPCSim.

Definition at line 45 of file RPCSimAverageNoiseEff.h.

00045 {};

void RPCSimAverageNoiseEff::simulate ( const RPCRoll roll,
const edm::PSimHitContainer rpcHits 
) [virtual]

Implements RPCSim.

Definition at line 143 of file RPCSimAverageNoiseEff.cc.

References _rpcSync, funct::abs(), RPCRoll::centreOfStrip(), Topology::channel(), edm::DetSet< T >::clear(), e, flatDistribution, getClSize(), RPCSim::getRPCSimSetUp(), RPCSynchronizer::getSimHitBx(), i, RPCRoll::id(), RPCGeomServ::name(), RPCRoll::nstrips(), DetId::rawId(), RPCSynchronizer::setRPCSimSetUp(), RPCRoll::specs(), RPCRoll::strip(), RPCSim::strips, RPCSim::theDetectorHitMap, RPCSim::theRpcDigiSimLinks, RPCRollSpecs::topology(), w, and PV3DBase< T, PVType, FrameType >::x().

00145 {
00146 
00147   _rpcSync->setRPCSimSetUp(getRPCSimSetUp());
00148   theRpcDigiSimLinks.clear();
00149   theDetectorHitMap.clear();
00150   theRpcDigiSimLinks = RPCDigiSimLinks(roll->id().rawId());
00151 
00152   RPCDetId rpcId = roll->id();
00153   RPCGeomServ RPCname(rpcId);
00154   std::string nameRoll = RPCname.name();
00155 
00156   const Topology& topology=roll->specs()->topology();
00157 
00158   for (edm::PSimHitContainer::const_iterator _hit = rpcHits.begin();
00159        _hit != rpcHits.end(); ++_hit){
00160 
00161     if(abs(_hit-> particleType()) != 13) continue;
00162 
00163     // Here I hould check if the RPC are up side down;
00164     const LocalPoint& entr=_hit->entryPoint();
00165 
00166     int time_hit = _rpcSync->getSimHitBx(&(*_hit));
00167     float posX = roll->strip(_hit->localPosition()) - static_cast<int>(roll->strip(_hit->localPosition()));
00168 
00169     std::vector<float> veff = (getRPCSimSetUp())->getEff(rpcId.rawId());
00170 
00171     // Effinciecy
00172     int centralStrip = topology.channel(entr)+1;;
00173     float fire = flatDistribution->fire(1);
00174 
00175     if (fire < veff[centralStrip-1]) {
00176 
00177       int fstrip=centralStrip;
00178       int lstrip=centralStrip;
00179 
00180       // Compute the cluster size
00181       double w = flatDistribution->fire(1);
00182       if (w < 1.e-10) w=1.e-10;
00183       int clsize = this->getClSize(posX);
00184 
00185       std::vector<int> cls;
00186       cls.push_back(centralStrip);
00187       if (clsize > 1){
00188         for (int cl = 0; cl < (clsize-1)/2; cl++)
00189           if (centralStrip - cl -1 >= 1  ){
00190             fstrip = centralStrip-cl-1;
00191             cls.push_back(fstrip);
00192           }
00193         for (int cl = 0; cl < (clsize-1)/2; cl++)
00194           if (centralStrip + cl + 1 <= roll->nstrips() ){
00195             lstrip = centralStrip+cl+1;
00196             cls.push_back(lstrip);
00197           }
00198         if (clsize%2 == 0 ){
00199           // insert the last strip according to the 
00200           // simhit position in the central strip 
00201           double deltaw=roll->centreOfStrip(centralStrip).x()-entr.x();
00202           if (deltaw<0.) {
00203             if (lstrip < roll->nstrips() ){
00204               lstrip++;
00205               cls.push_back(lstrip);
00206             }
00207           }else{
00208             if (fstrip > 1 ){
00209               fstrip--;
00210               cls.push_back(fstrip);
00211             }
00212           }
00213         }
00214       }
00215 
00216       for (std::vector<int>::iterator i=cls.begin(); i!=cls.end();i++){
00217         // Check the timing of the adjacent strip
00218         if(*i != centralStrip){
00219           if(flatDistribution->fire(1) < veff[*i-1]){
00220             std::pair<int, int> digi(*i,time_hit);
00221             strips.insert(digi);
00222 
00223             theDetectorHitMap.insert(DetectorHitMap::value_type(digi,&(*_hit)));
00224           }
00225         } 
00226         else {
00227           std::pair<int, int> digi(*i,time_hit);
00228           theDetectorHitMap.insert(DetectorHitMap::value_type(digi,&(*_hit)));
00229 
00230           strips.insert(digi);
00231         }
00232       }
00233     }
00234   }
00235 }

void RPCSimAverageNoiseEff::simulateNoise ( const RPCRoll roll  )  [virtual]

Implements RPCSim.

Definition at line 237 of file RPCSimAverageNoiseEff.cc.

References flatDistribution, frate, gate, RPCSim::getRPCSimSetUp(), i, RPCRoll::id(), j, TrapezoidalStripTopology::localPosition(), RectangularStripTopology::localPosition(), N_hits, RPCGeomServ::name(), nbxing, RPCRoll::nstrips(), poissonDistribution_, DetId::rawId(), RPCDetId::region(), rndEngine, RectangularStripTopology::stripLength(), TrapezoidalStripTopology::stripLength(), RPCSim::strips, RPCRoll::topology(), and x.

00238 {
00239 
00240   RPCDetId rpcId = roll->id();
00241 
00242   RPCGeomServ RPCname(rpcId);
00243   std::string nameRoll = RPCname.name();
00244 
00245   std::vector<float> vnoise = (getRPCSimSetUp())->getNoise(rpcId.rawId());
00246   std::vector<float> veff = (getRPCSimSetUp())->getEff(rpcId.rawId());
00247 
00248   unsigned int nstrips = roll->nstrips();
00249   double area = 0.0;
00250   
00251   if ( rpcId.region() == 0 )
00252     {
00253       const RectangularStripTopology* top_ = dynamic_cast<const
00254         RectangularStripTopology*>(&(roll->topology()));
00255       float xmin = (top_->localPosition(0.)).x();
00256       float xmax = (top_->localPosition((float)roll->nstrips())).x();
00257       float striplength = (top_->stripLength());
00258       area = striplength*(xmax-xmin);
00259     }
00260   else
00261     {
00262       const TrapezoidalStripTopology* top_=dynamic_cast<const TrapezoidalStripTopology*>(&(roll->topology()));
00263       float xmin = (top_->localPosition(0.)).x();
00264       float xmax = (top_->localPosition((float)roll->nstrips())).x();
00265       float striplength = (top_->stripLength());
00266       area = striplength*(xmax-xmin);
00267     }
00268 
00269   for(unsigned int j = 0; j < vnoise.size(); ++j){
00270     
00271     if(j >= nstrips) break; 
00272     if(veff[j] == 0) continue;
00273 
00274     double ave = vnoise[j]*nbxing*gate*area*1.0e-9*frate;
00275     poissonDistribution_ = new CLHEP::RandPoissonQ(rndEngine, ave);
00276     N_hits = poissonDistribution_->fire();
00277 
00278     for (int i = 0; i < N_hits; i++ ){
00279       flatDistribution = new CLHEP::RandFlat(rndEngine, (nbxing*gate)/gate);
00280       int time_hit = (static_cast<int>(flatDistribution->fire())) - nbxing/2;
00281       std::pair<int, int> digi(j+1,time_hit);
00282       strips.insert(digi);
00283     }
00284   }
00285 }


Member Data Documentation

RPCSynchronizer* RPCSimAverageNoiseEff::_rpcSync [private]

Definition at line 67 of file RPCSimAverageNoiseEff.h.

Referenced by RPCSimAverageNoiseEff(), and simulate().

double RPCSimAverageNoiseEff::aveCls [private]

Definition at line 48 of file RPCSimAverageNoiseEff.h.

Referenced by RPCSimAverageNoiseEff().

double RPCSimAverageNoiseEff::aveEff [private]

Definition at line 45 of file RPCSimAverageNoiseEff.h.

Referenced by RPCSimAverageNoiseEff().

std::map< int, std::vector<double> > RPCSimAverageNoiseEff::clsMap [private]

Definition at line 63 of file RPCSimAverageNoiseEff.h.

Referenced by getClSize().

double RPCSimAverageNoiseEff::dtimCs [private]

Definition at line 51 of file RPCSimAverageNoiseEff.h.

Referenced by RPCSimAverageNoiseEff().

CLHEP::RandFlat* RPCSimAverageNoiseEff::flatDistribution [private]

Definition at line 70 of file RPCSimAverageNoiseEff.h.

Referenced by getClSize(), RPCSimAverageNoiseEff(), simulate(), and simulateNoise().

double RPCSimAverageNoiseEff::frate [private]

Definition at line 61 of file RPCSimAverageNoiseEff.h.

Referenced by RPCSimAverageNoiseEff(), and simulateNoise().

double RPCSimAverageNoiseEff::gate [private]

Definition at line 60 of file RPCSimAverageNoiseEff.h.

Referenced by RPCSimAverageNoiseEff(), and simulateNoise().

std::ifstream* RPCSimAverageNoiseEff::infile [private]

Definition at line 65 of file RPCSimAverageNoiseEff.h.

double RPCSimAverageNoiseEff::lbGate [private]

Definition at line 54 of file RPCSimAverageNoiseEff.h.

Referenced by RPCSimAverageNoiseEff().

int RPCSimAverageNoiseEff::N_hits [private]

Definition at line 57 of file RPCSimAverageNoiseEff.h.

Referenced by simulateNoise().

int RPCSimAverageNoiseEff::nbxing [private]

Definition at line 58 of file RPCSimAverageNoiseEff.h.

Referenced by RPCSimAverageNoiseEff(), and simulateNoise().

CLHEP::RandPoissonQ* RPCSimAverageNoiseEff::poissonDistribution_ [private]

Definition at line 71 of file RPCSimAverageNoiseEff.h.

Referenced by simulateNoise().

double RPCSimAverageNoiseEff::rate [private]

Definition at line 59 of file RPCSimAverageNoiseEff.h.

Referenced by RPCSimAverageNoiseEff().

double RPCSimAverageNoiseEff::resEle [private]

Definition at line 52 of file RPCSimAverageNoiseEff.h.

Referenced by RPCSimAverageNoiseEff().

double RPCSimAverageNoiseEff::resRPC [private]

Definition at line 49 of file RPCSimAverageNoiseEff.h.

Referenced by RPCSimAverageNoiseEff().

CLHEP::HepRandomEngine* RPCSimAverageNoiseEff::rndEngine [private]

Definition at line 69 of file RPCSimAverageNoiseEff.h.

Referenced by RPCSimAverageNoiseEff(), and simulateNoise().

bool RPCSimAverageNoiseEff::rpcdigiprint [private]

Definition at line 55 of file RPCSimAverageNoiseEff.h.

Referenced by RPCSimAverageNoiseEff().

double RPCSimAverageNoiseEff::sspeed [private]

Definition at line 53 of file RPCSimAverageNoiseEff.h.

Referenced by RPCSimAverageNoiseEff().

std::vector<double> RPCSimAverageNoiseEff::sum_clsize [private]

Definition at line 64 of file RPCSimAverageNoiseEff.h.

Referenced by getClSize().

double RPCSimAverageNoiseEff::timOff [private]

Definition at line 50 of file RPCSimAverageNoiseEff.h.

Referenced by RPCSimAverageNoiseEff().


The documentation for this class was generated from the following files:
Generated on Tue Jun 9 18:31:11 2009 for CMSSW by  doxygen 1.5.4