CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_2_SLHC4_patch1/src/SimMuon/GEMDigitizer/src/GEMSimSetUp.cc

Go to the documentation of this file.
00001 #include "SimMuon/GEMDigitizer/src/GEMSimSetUp.h"
00002 #include "Geometry/GEMGeometry/interface/GEMGeometry.h"
00003 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00004 
00005 GEMSimSetUp::GEMSimSetUp(const edm::ParameterSet& config)
00006 {
00007   auto pset = config.getParameter<edm::ParameterSet>("digiModelConfig");
00008 
00009   averageEfficiency_ = pset.getParameter<double>("averageEfficiency");
00010   averageNoiseRate_ = pset.getParameter<double>("averageNoiseRate");
00011   timeCalibrationOffset_ = pset.getParameter<double>("timeCalibrationOffset");
00012   numberOfStripsPerPartition_ = pset.getParameter<int>("numberOfStripsPerPartition");
00013 }
00014 
00015 void GEMSimSetUp::setup(std::vector<RPCStripNoises::NoiseItem> &vnoise,
00016                         std::vector<float> &vcluster)
00017 {
00018   std::cout << "GEMSimSetUp::setup()" << std::endl;
00019   unsigned int counter = 1;
00020   unsigned int row = 1;
00021   std::vector<float> sum_clsize;
00022 
00023   for(unsigned int n = 0; n < vcluster.size(); ++n)
00024     {
00025       sum_clsize.push_back(vcluster[n]);
00026 
00027       if(counter == row * 20)
00028         {
00029           clusterMap_[row] = sum_clsize;
00030           row++;
00031           sum_clsize.clear();
00032         }
00033       counter++;
00034     }
00035 
00036   setupNoiseAndEfficiency(vnoise);
00037 }
00038 
00039 
00040 void GEMSimSetUp::setup(std::vector<RPCStripNoises::NoiseItem> &vnoise,
00041                         std::vector<RPCClusterSize::ClusterSizeItem> &vClusterSize)
00042 {
00043   int clusterCounter = 1;
00044   std::vector<float> clusterVect;
00045 
00046   for(auto cluster: vClusterSize)
00047     {
00048       clusterVect.push_back(cluster.clusterSize);
00049       if( !(clusterCounter % 100) && clusterCounter != 0 )
00050         {
00051           mapDetClusterMap_[cluster.dpid] = clusterVect;
00052           clusterVect.clear();
00053           clusterCounter = 0;
00054         }
00055       ++clusterCounter;
00056     }
00057 
00058   setupNoiseAndEfficiency(vnoise);
00059 }
00060 
00061 
00062 // setup the noise vector
00063 void GEMSimSetUp::setup()
00064 {
00065   /*
00066     Container for the noise items. Its total size is 331776
00067     - 2 stations
00068     - 2 layers/station
00069     - 36 chambers/layer
00070     - 6 eta partitions/chamber
00071     - 384 strips/eta partition
00072   */ 
00073   std::vector<RPCStripNoises::NoiseItem> vnoise;
00074   vnoise.reserve(geometry_->dets().size() * numberOfStripsPerPartition_);
00075 
00076   // Loop over the detIds                                                                                                                                             
00077   for(const auto &det: geometry_->dets())
00078     {
00079       GEMEtaPartition* roll = dynamic_cast< GEMEtaPartition* >( det );
00080       
00081       // check for valid rolls     
00082       if(roll == nullptr) continue;
00083 
00084       const int nStrips = roll->nstrips();
00085       if (numberOfStripsPerPartition_ != nStrips)
00086         {
00087           throw cms::Exception("DataCorrupt") 
00088             << "GEMSimSetUp::setup() - numberOfStripsPerPartition given in configuration "
00089             <<numberOfStripsPerPartition_ <<" is not the same as in geometry "<<nStrips;
00090         }
00091       
00092       // Loop over the strips                                                                                                                                          
00093       for(int iStrip=0; iStrip <= nStrips-1; ++iStrip)
00094         {
00095           // construct noise item for each strip
00096           RPCStripNoises::NoiseItem noise;
00097           noise.dpid = roll->id();
00098           noise.eff = averageEfficiency_;
00099           noise.noise = averageNoiseRate_;
00100           noise.time = timeCalibrationOffset_;
00101           
00102           // add noise item to noise vector                                                                                                                         
00103           vnoise.push_back(noise);
00104         }
00105       setupTimeCalibration(det->geographicalId(),timeCalibrationOffset_);
00106     }
00107   setupNoiseAndEfficiency(vnoise);
00108 }
00109 
00110 // return the vector of noise values for a particular chamber
00111 const std::vector<float>& GEMSimSetUp::getNoise(uint32_t id)
00112 {
00113   auto iter = mapDetIdNoise_.find(id);
00114   if(iter == mapDetIdNoise_.end())
00115   {
00116     throw cms::Exception("DataCorrupt") 
00117       << "GEMSimSetUp::getNoise() - no noise information for DetId "<<id<< "\n";
00118   }
00119   return iter->second;
00120 }
00121 
00122 // return the vector of efficiency values for a particular chamber
00123 const std::vector<float>& GEMSimSetUp::getEfficiency(uint32_t id)
00124 {
00125   auto iter = mapDetIdEfficiency_.find(id);
00126   if(iter == mapDetIdEfficiency_.end())
00127   {
00128     throw cms::Exception("DataCorrupt") 
00129       << "GEMSimSetUp::getEfficiency() - no efficiency information for DetId "<<id<< "\n";
00130   }
00131   if((iter->second).size() != (unsigned) numberOfStripsPerPartition_)
00132   {
00133     throw cms::Exception("DataCorrupt") 
00134       << "GEMSimSetUp::getEfficiency() - efficiency information in a wrong format for DetId "<<id<< "\n";
00135   }
00136   return iter->second;
00137 }
00138 
00139 // return the time calibration for this chamber
00140 float GEMSimSetUp::getTime(uint32_t id)
00141 {
00142   GEMDetId detid(id);
00143   auto iter = bxmap_.find(detid);
00144   if(iter == bxmap_.end())
00145     {
00146       throw cms::Exception("DataCorrupt") 
00147         << "GEMSimSetUp::getTime() - no timing information for gemid.rawId() "<<detid.rawId()<< "\n";
00148     }
00149   return iter->second;
00150 }
00151 
00152 
00153 const std::map< int, std::vector<float> >& GEMSimSetUp::getClusterMap()
00154 {
00155   if(clusterMap_.size() != 5)
00156     {
00157       throw cms::Exception("DataCorrupt") 
00158         << "GEMSimSetUp::getClusterMap() - cluster size has the wrong format.\n";
00159     }
00160   return clusterMap_;
00161 }
00162 
00163 
00164 const std::vector<float>& GEMSimSetUp::getCluster(uint32_t id)
00165 {
00166   auto iter = mapDetClusterMap_.find(id);
00167   if(iter == mapDetClusterMap_.end())
00168   {
00169     throw cms::Exception("DataCorrupt") 
00170       << "GEMSimSetUp::getCluster() - no cluster size information for DetId "<<id<< "\n";
00171   }
00172   if((iter->second).size() != 100)
00173   {
00174    throw cms::Exception("DataCorrupt") 
00175       << "GEMSimSetUp::getCluster() - cluster size information in a wrong format for DetId "<<id<< "\n";
00176   }
00177   return iter->second;
00178 }
00179 
00180 
00181 void GEMSimSetUp::setupNoiseAndEfficiency(std::vector<RPCStripNoises::NoiseItem> &vnoise)
00182 {
00183   unsigned int iStrip = 0; 
00184   uint32_t roll = 0; 
00185   std::vector<float> vEfficiency, vNoise;
00186   vEfficiency.clear();
00187   vNoise.clear();
00188 
00189   // loop over the noise vector
00190   for(auto noise: vnoise)
00191     {
00192       if(iStrip % numberOfStripsPerPartition_ == 0)
00193         {
00194           // the first strip of new chamber
00195           if(iStrip > 0)
00196             {
00197               // fill map with noise and efficiency vectors of the previous chamber
00198               mapDetIdNoise_[roll] = vNoise;
00199               mapDetIdEfficiency_[roll] = vEfficiency;
00200               // clear the vectors and start over
00201               vEfficiency.clear();
00202               vNoise.clear();
00203               vNoise.push_back(noise.noise);
00204               vEfficiency.push_back(noise.eff);
00205             }
00206           // the very first strip in the collection
00207           else if (iStrip == 0 )
00208             {
00209               // nothing to add to map yet
00210               vNoise.push_back(noise.noise);
00211               vEfficiency.push_back(noise.eff);
00212             }
00213         }
00214       // the very last strip in the collection
00215       else if (iStrip == vnoise.size() - 1 )
00216         {
00217           roll = noise.dpid;
00218           vNoise.push_back(noise.noise);
00219           vEfficiency.push_back(noise.eff);
00220           // fill map with noise and efficiency vectors of the last chamber
00221           mapDetIdNoise_[roll]= vNoise;
00222           mapDetIdEfficiency_[roll] = vEfficiency;
00223         }
00224       // a regular strip
00225       else
00226         {
00227           roll = noise.dpid;
00228           vNoise.push_back(noise.noise);
00229           vEfficiency.push_back(noise.eff);
00230         }
00231       iStrip++;
00232     }
00233 }
00234 
00235 
00236 // set up the time calibration for each detId
00237 void GEMSimSetUp::setupTimeCalibration(GEMDetId id, float timing)
00238 {
00239   bxmap_[id] = timing;      
00240 }
00241 
00242 
00243 
00244