CMS 3D CMS Logo

RPCSimAverage Class Reference

Class for the RPC strip response simulation based on a parametrized model (ORCA-based). More...

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

Inheritance diagram for RPCSimAverage:

RPCSim

List of all members.

Public Member Functions

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

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 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

Class for the RPC strip response simulation based on a parametrized model (ORCA-based).

Author:
Raffaello Trentadue -- INFN Bari

Definition at line 30 of file RPCSimAverage.h.


Constructor & Destructor Documentation

RPCSimAverage::RPCSimAverage ( const edm::ParameterSet config  ) 

Definition at line 48 of file RPCSimAverage.cc.

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

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

RPCSimAverage::~RPCSimAverage (  ) 

Definition at line 90 of file RPCSimAverage.cc.

00090 {}


Member Function Documentation

int RPCSimAverage::getClSize ( float  posX  ) 

Definition at line 92 of file RPCSimAverage.cc.

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

Referenced by simulate().

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

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

Implements RPCSim.

Definition at line 45 of file RPCSimAverage.h.

00045 {};

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

Implements RPCSim.

Definition at line 141 of file RPCSimAverage.cc.

References _rpcSync, aveEff, RPCRoll::centreOfStrip(), edm::DetSet< T >::clear(), e, flatDistribution, getClSize(), RPCSim::getRPCSimSetUp(), RPCSynchronizer::getSimHitBx(), i, RPCRoll::id(), 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().

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

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

Implements RPCSim.

Definition at line 215 of file RPCSimAverage.cc.

References flatDistribution, gate, i, RPCRoll::id(), TrapezoidalStripTopology::localPosition(), RectangularStripTopology::localPosition(), N_hits, nbxing, RPCRoll::nstrips(), poissonDistribution_, rate, RPCDetId::region(), rndEngine, strip(), RectangularStripTopology::stripLength(), TrapezoidalStripTopology::stripLength(), RPCSim::strips, RPCRoll::topology(), and x.

00216 {
00217 
00218   RPCDetId rpcId = roll->id();
00219   int nstrips = roll->nstrips();
00220   double area = 0.0;
00221   
00222   if ( rpcId.region() == 0 )
00223     {
00224       const RectangularStripTopology* top_ = dynamic_cast<const
00225         RectangularStripTopology*>(&(roll->topology()));
00226       float xmin = (top_->localPosition(0.)).x();
00227       float xmax = (top_->localPosition((float)roll->nstrips())).x();
00228       float striplength = (top_->stripLength());
00229       area = striplength*(xmax-xmin);
00230     }
00231   else
00232     {
00233       const TrapezoidalStripTopology* top_=dynamic_cast<const TrapezoidalStripTopology*>(&(roll->topology()));
00234       float xmin = (top_->localPosition(0.)).x();
00235       float xmax = (top_->localPosition((float)roll->nstrips())).x();
00236       float striplength = (top_->stripLength());
00237       area = striplength*(xmax-xmin);
00238     }
00239   
00240   double ave = rate*nbxing*gate*area*1.0e-9;
00241   poissonDistribution_ = new CLHEP::RandPoissonQ(rndEngine, ave);
00242   N_hits = poissonDistribution_->fire();
00243 
00244   for (int i = 0; i < N_hits; i++ ){
00245 
00246     flatDistribution = new CLHEP::RandFlat(rndEngine, 1,nstrips);
00247     int strip = static_cast<int>(flatDistribution->fire());
00248     int time_hit;
00249 
00250     flatDistribution = new CLHEP::RandFlat(rndEngine, (nbxing*gate)/gate);
00251     time_hit = (static_cast<int>(flatDistribution->fire())) - nbxing/2;
00252     
00253     std::pair<int, int> digi(strip,time_hit);
00254     strips.insert(digi);
00255   }
00256 
00257 }


Member Data Documentation

RPCSynchronizer* RPCSimAverage::_rpcSync [private]

Definition at line 66 of file RPCSimAverage.h.

Referenced by RPCSimAverage(), and simulate().

double RPCSimAverage::aveCls [private]

Definition at line 48 of file RPCSimAverage.h.

Referenced by RPCSimAverage().

double RPCSimAverage::aveEff [private]

Definition at line 45 of file RPCSimAverage.h.

Referenced by RPCSimAverage(), and simulate().

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

Definition at line 62 of file RPCSimAverage.h.

Referenced by getClSize().

double RPCSimAverage::dtimCs [private]

Definition at line 51 of file RPCSimAverage.h.

Referenced by RPCSimAverage().

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

Definition at line 69 of file RPCSimAverage.h.

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

double RPCSimAverage::gate [private]

Definition at line 60 of file RPCSimAverage.h.

Referenced by RPCSimAverage(), and simulateNoise().

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

Definition at line 64 of file RPCSimAverage.h.

double RPCSimAverage::lbGate [private]

Definition at line 54 of file RPCSimAverage.h.

Referenced by RPCSimAverage().

int RPCSimAverage::N_hits [private]

Definition at line 57 of file RPCSimAverage.h.

Referenced by simulateNoise().

int RPCSimAverage::nbxing [private]

Definition at line 58 of file RPCSimAverage.h.

Referenced by RPCSimAverage(), and simulateNoise().

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

Definition at line 70 of file RPCSimAverage.h.

Referenced by simulateNoise().

double RPCSimAverage::rate [private]

Definition at line 59 of file RPCSimAverage.h.

Referenced by RPCSimAverage(), and simulateNoise().

double RPCSimAverage::resEle [private]

Definition at line 52 of file RPCSimAverage.h.

Referenced by RPCSimAverage().

double RPCSimAverage::resRPC [private]

Definition at line 49 of file RPCSimAverage.h.

Referenced by RPCSimAverage().

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

Definition at line 68 of file RPCSimAverage.h.

Referenced by RPCSimAverage(), and simulateNoise().

bool RPCSimAverage::rpcdigiprint [private]

Definition at line 55 of file RPCSimAverage.h.

Referenced by RPCSimAverage().

double RPCSimAverage::sspeed [private]

Definition at line 53 of file RPCSimAverage.h.

Referenced by RPCSimAverage().

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

Definition at line 63 of file RPCSimAverage.h.

Referenced by getClSize().

double RPCSimAverage::timOff [private]

Definition at line 50 of file RPCSimAverage.h.

Referenced by RPCSimAverage().


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