#include <FastSimulation/CaloRecHitsProducer/interface/EcalBarrelRecHitsMaker.h>
Public Member Functions | |
EcalBarrelRecHitsMaker (edm::ParameterSet const &p, edm::ParameterSet const &p2, const RandomEngine *) | |
void | init (const edm::EventSetup &es, bool dodigis, bool doMiscalib) |
void | loadEcalBarrelRecHits (edm::Event &iEvent, EBRecHitCollection &ecalHits, EBDigiCollection &ecaldigis) |
~EcalBarrelRecHitsMaker () | |
Private Member Functions | |
void | clean () |
void | geVtoGainAdc (float e, unsigned &gain, unsigned &adc) const |
void | loadPCaloHits (const edm::Event &iEvent) |
Private Attributes | |
float | adcToGeV_ |
std::vector< uint32_t > | barrelRawId_ |
double | calibfactor_ |
bool | doDigis_ |
bool | doMisCalib_ |
float | geVToAdc1_ |
float | geVToAdc2_ |
float | geVToAdc3_ |
edm::InputTag | inputCol_ |
unsigned | maxAdc_ |
unsigned | minAdc_ |
double | noise_ |
bool | noisified_ |
const RandomEngine * | random_ |
double | refactor_ |
double | refactor_mean_ |
float | sat_ |
float | t1_ |
float | t2_ |
std::vector< float > | theCalibConstants_ |
std::vector< float > | theCalorimeterHits_ |
std::vector< int > | theFiredCells_ |
double | threshold_ |
Definition at line 17 of file EcalBarrelRecHitsMaker.h.
EcalBarrelRecHitsMaker::EcalBarrelRecHitsMaker | ( | edm::ParameterSet const & | p, | |
edm::ParameterSet const & | p2, | |||
const RandomEngine * | myrandom | |||
) |
Definition at line 18 of file EcalBarrelRecHitsMaker.cc.
References adcToGeV_, c1, calibfactor_, edm::ParameterSet::getParameter(), geVToAdc1_, geVToAdc2_, geVToAdc3_, inputCol_, int, maxAdc_, minAdc_, noise_, noisified_, refactor_, refactor_mean_, sat_, t1_, t2_, theCalorimeterHits_, and threshold_.
00021 : random_(myrandom) 00022 { 00023 edm::ParameterSet RecHitsParameters = p.getParameter<edm::ParameterSet>("ECALBarrel"); 00024 inputCol_=RecHitsParameters.getParameter<edm::InputTag>("MixedSimHits"); 00025 noise_ = RecHitsParameters.getParameter<double>("Noise"); 00026 threshold_ = RecHitsParameters.getParameter<double>("Threshold"); 00027 refactor_ = RecHitsParameters.getParameter<double> ("Refactor"); 00028 refactor_mean_ = RecHitsParameters.getParameter<double> ("Refactor_mean"); 00029 theCalorimeterHits_.resize(62000,0.); 00030 noisified_ = (noise_==0.); 00031 double c1=pcalib.getParameter<double>("EBs25notContainment"); 00032 calibfactor_=1./c1; 00033 adcToGeV_= 0.035; 00034 minAdc_ = 200; 00035 maxAdc_ = 4085; 00036 00037 geVToAdc1_ = 1./adcToGeV_; 00038 geVToAdc2_ = geVToAdc1_/2.; 00039 geVToAdc3_ = geVToAdc1_/12.; 00040 00041 t1_ = ((int)maxAdc_-(int)minAdc_)*adcToGeV_; 00042 t2_ = 2.* t1_ ; 00043 00044 // Saturation value. Not needed in the digitization 00045 sat_ = 12.*t1_*calibfactor_; 00046 }
EcalBarrelRecHitsMaker::~EcalBarrelRecHitsMaker | ( | ) |
void EcalBarrelRecHitsMaker::clean | ( | ) | [private] |
Definition at line 53 of file EcalBarrelRecHitsMaker.cc.
References noise_, noisified_, size, theCalorimeterHits_, and theFiredCells_.
Referenced by loadEcalBarrelRecHits().
00054 { 00055 // std::cout << " clean " << std::endl; 00056 unsigned size=theFiredCells_.size(); 00057 for(unsigned ic=0;ic<size;++ic) 00058 { 00059 theCalorimeterHits_[theFiredCells_[ic]] = 0.; 00060 } 00061 theFiredCells_.clear(); 00062 // If the noise is set to 0. No need to simulate it. 00063 noisified_ = (noise_==0.); 00064 // std::cout << " Finished to clean " << std::endl; 00065 }
void EcalBarrelRecHitsMaker::geVtoGainAdc | ( | float | e, | |
unsigned & | gain, | |||
unsigned & | adc | |||
) | const [private] |
Definition at line 207 of file EcalBarrelRecHitsMaker.cc.
References geVToAdc1_, geVToAdc2_, geVToAdc3_, maxAdc_, min, minAdc_, t1_, and t2_.
Referenced by loadEcalBarrelRecHits().
00208 { 00209 if(e<t1_) 00210 { 00211 gain = 1; // x1 00212 // std::cout << " E " << e << std::endl; 00213 adc = minAdc_ + (unsigned)(e*geVToAdc1_); 00214 // std::cout << " e*geVtoAdc1_ " << e*geVToAdc1_ << " " <<(unsigned)(e*geVToAdc1_) << std::endl; 00215 } 00216 else if (e<t2_) 00217 { 00218 gain = 2; 00219 adc = minAdc_ + (unsigned)(e*geVToAdc2_); 00220 } 00221 else 00222 { 00223 gain = 3; 00224 adc = std::min(minAdc_+(unsigned)(e*geVToAdc3_),maxAdc_); 00225 } 00226 }
void EcalBarrelRecHitsMaker::init | ( | const edm::EventSetup & | es, | |
bool | dodigis, | |||
bool | doMiscalib | |||
) |
Definition at line 161 of file EcalBarrelRecHitsMaker.cc.
References EcalCondObjectContainer< T >::barrelItems(), barrelRawId_, doDigis_, doMisCalib_, DetId::Ecal, EcalBarrel, edm::EventSetup::get(), CaloSubdetectorGeometry::getValidDetIds(), it, edm::ESHandle< T >::product(), refactor_, refactor_mean_, size, funct::sqrt(), and theCalibConstants_.
Referenced by CaloRecHitsProducer::beginRun().
00162 { 00163 doDigis_=doDigis; 00164 doMisCalib_=doMiscalib; 00165 barrelRawId_.resize(62000); 00166 if (doMisCalib_) theCalibConstants_.resize(62000); 00167 edm::ESHandle<CaloGeometry> pG; 00168 es.get<CaloGeometryRecord>().get(pG); 00169 00170 const EcalBarrelGeometry * myEcalBarrelGeometry = dynamic_cast<const EcalBarrelGeometry*>(pG->getSubdetectorGeometry(DetId::Ecal,EcalBarrel)); 00171 // std::cout << " Got the geometry " << myEcalBarrelGeometry << std::endl; 00172 const std::vector<DetId>& vec(myEcalBarrelGeometry->getValidDetIds(DetId::Ecal,EcalBarrel)); 00173 unsigned size=vec.size(); 00174 for(unsigned ic=0; ic<size; ++ic) 00175 { 00176 barrelRawId_[EBDetId(vec[ic]).hashedIndex()]=vec[ic].rawId(); 00177 } 00178 // std::cout << " Made the array " << std::endl; 00179 00180 // Stores the miscalibration constants 00181 if(doMisCalib_) 00182 { 00183 float rms=0.; 00184 unsigned ncells=0; 00185 // Intercalib constants 00186 edm::ESHandle<EcalIntercalibConstants> pIcal; 00187 es.get<EcalIntercalibConstantsRcd>().get(pIcal); 00188 const EcalIntercalibConstants* ical = pIcal.product(); 00189 00190 theCalibConstants_ = ical->barrelItems(); 00191 std::vector<float>::iterator it=theCalibConstants_.begin(); 00192 std::vector<float>::iterator itend=theCalibConstants_.end(); 00193 00194 for ( ; it != itend; ++it ) { 00195 00196 // Apply Refactor & refactor_mean 00197 *it= refactor_mean_+(*it-1.)*refactor_; 00198 rms+=(*it-1.)*(*it-1.); 00199 ++ncells; 00200 } 00201 rms = std::sqrt(rms) / (float)ncells; 00202 // The following should be on LogInfo 00203 //std::cout << " Found " << ncells << " cells in the barrel calibration map. RMS is " << rms << std::endl; 00204 } 00205 }
void EcalBarrelRecHitsMaker::loadEcalBarrelRecHits | ( | edm::Event & | iEvent, | |
EBRecHitCollection & | ecalHits, | |||
EBDigiCollection & | ecaldigis | |||
) |
Definition at line 67 of file EcalBarrelRecHitsMaker.cc.
References ecalMGPA::adc(), edm::DataFrameContainer::back(), barrelRawId_, clean(), doDigis_, relval_parameters_module::energy, RandomEngine::gaussShoot(), geVtoGainAdc(), loadPCaloHits(), noise_, noisified_, edm::DataFrameContainer::push_back(), edm::SortedCollection< T, SORT >::push_back(), random_, edm::SortedCollection< T, SORT >::reserve(), edm::DataFrameContainer::reserve(), sat_, theCalorimeterHits_, theFiredCells_, and threshold_.
Referenced by CaloRecHitsProducer::produce().
00068 { 00069 00070 clean(); 00071 loadPCaloHits(iEvent); 00072 00073 unsigned nhit=theFiredCells_.size(); 00074 // std::cout << " loadEcalBarrelRecHits " << nhit << std::endl; 00075 unsigned gain, adc; 00076 ecalDigis.reserve(nhit); 00077 ecalHits.reserve(nhit); 00078 for(unsigned ihit=0;ihit<nhit;++ihit) 00079 { 00080 unsigned icell = theFiredCells_[ihit]; 00081 00082 EBDetId myDetId(barrelRawId_[icell]); 00083 00084 if(doDigis_) 00085 { 00086 ecalDigis.push_back( myDetId ); 00087 EBDataFrame myDataFrame( ecalDigis.back() ); 00088 // myDataFrame.setSize(1); // now useless - by construction fixed at 1 frame - FIXME 00089 // The real work is in the following line 00090 geVtoGainAdc(theCalorimeterHits_[icell],gain,adc); 00091 myDataFrame.setSample(0,EcalMGPASample(adc,gain)); 00092 00093 // std::cout << "myDataFrame" << myDataFrame.sample(0).raw() << std::endl; 00094 //ecalDigis.push_back(myDataFrame); 00095 } 00096 00097 // std::cout << " The Fired Cell " << icell << std::endl; 00098 // It is safer to update the orignal array in case this methods is called several times 00099 if (!noisified_ ) theCalorimeterHits_[icell] += random_->gaussShoot(0.,noise_); 00100 00101 // std::cout << "Noise ok " << std::endl; 00102 00103 // If the energy+noise is below the threshold, a hit is nevertheless created, otherwise, there is a risk that a "noisy" hit 00104 // is afterwards put in this cell which would not be correct. 00105 float energy=theCalorimeterHits_[icell]; 00106 if ( energy <threshold_ ) 00107 { 00108 theCalorimeterHits_[icell]=0.; 00109 energy=0.; 00110 } 00111 else if (energy > sat_) 00112 { 00113 theCalorimeterHits_[icell]=sat_; 00114 energy=sat_; 00115 } 00116 // std::cout << " Threshold ok " << std::endl; 00117 //std::cout << " Raw Id " << barrelRawId_[icell] << std::endl; 00118 // std::cout << " Adding " << icell << " " << barrelRawId_[icell] << " " << energy << std::endl; 00119 ecalHits.push_back(EcalRecHit(myDetId,energy,0.)); 00120 // std::cout << " Hit stored " << std::endl; 00121 } 00122 // std::cout << " Done " << std::endl; 00123 noisified_ = true; 00124 }
void EcalBarrelRecHitsMaker::loadPCaloHits | ( | const edm::Event & | iEvent | ) | [private] |
Definition at line 126 of file EcalBarrelRecHitsMaker.cc.
References MixCollection< T >::begin(), calib, calibfactor_, doMisCalib_, relval_parameters_module::energy, edm::Event::getByLabel(), inputCol_, edm::Handle< T >::product(), theCalibConstants_, theCalorimeterHits_, and theFiredCells_.
Referenced by loadEcalBarrelRecHits().
00127 { 00128 00129 edm::Handle<CrossingFrame<PCaloHit> > cf; 00130 iEvent.getByLabel(inputCol_,cf); 00131 std::auto_ptr<MixCollection<PCaloHit> > colcalo(new MixCollection<PCaloHit>(cf.product(),std::pair<int,int>(0,0) )); 00132 00133 00134 theFiredCells_.reserve(colcalo->size()); 00135 00136 MixCollection<PCaloHit>::iterator cficalo; 00137 MixCollection<PCaloHit>::iterator cficaloend=colcalo->end(); 00138 00139 float calib=1.; 00140 for (cficalo=colcalo->begin(); cficalo!=cficaloend;cficalo++) 00141 { 00142 00143 unsigned hashedindex = EBDetId(cficalo->id()).hashedIndex(); 00144 // Check if the hit already exists 00145 if(theCalorimeterHits_[hashedindex]==0.) 00146 { 00147 theFiredCells_.push_back(hashedindex); 00148 } 00149 // the famous 1/0.97 calibration factor is applied here ! 00150 calib=calibfactor_; 00151 // the miscalibration is applied here: 00152 if(doMisCalib_) calib*=theCalibConstants_[hashedindex]; 00153 // cficalo->energy can be 0 (a 7x7 grid is always built), in this case, one should not kill the cell (for later noise injection), but it should 00154 // be added only once. This is a dirty trick. 00155 float energy=(cficalo->energy()==0.) ? 0.000001 : cficalo->energy() ; 00156 theCalorimeterHits_[hashedindex]+=energy*calib; 00157 00158 } 00159 }
float EcalBarrelRecHitsMaker::adcToGeV_ [private] |
std::vector<uint32_t> EcalBarrelRecHitsMaker::barrelRawId_ [private] |
Definition at line 52 of file EcalBarrelRecHitsMaker.h.
Referenced by init(), and loadEcalBarrelRecHits().
double EcalBarrelRecHitsMaker::calibfactor_ [private] |
Definition at line 39 of file EcalBarrelRecHitsMaker.h.
Referenced by EcalBarrelRecHitsMaker(), and loadPCaloHits().
bool EcalBarrelRecHitsMaker::doDigis_ [private] |
Definition at line 32 of file EcalBarrelRecHitsMaker.h.
Referenced by init(), and loadEcalBarrelRecHits().
bool EcalBarrelRecHitsMaker::doMisCalib_ [private] |
float EcalBarrelRecHitsMaker::geVToAdc1_ [private] |
Definition at line 54 of file EcalBarrelRecHitsMaker.h.
Referenced by EcalBarrelRecHitsMaker(), and geVtoGainAdc().
float EcalBarrelRecHitsMaker::geVToAdc2_ [private] |
Definition at line 54 of file EcalBarrelRecHitsMaker.h.
Referenced by EcalBarrelRecHitsMaker(), and geVtoGainAdc().
float EcalBarrelRecHitsMaker::geVToAdc3_ [private] |
Definition at line 54 of file EcalBarrelRecHitsMaker.h.
Referenced by EcalBarrelRecHitsMaker(), and geVtoGainAdc().
Definition at line 42 of file EcalBarrelRecHitsMaker.h.
Referenced by EcalBarrelRecHitsMaker(), and loadPCaloHits().
unsigned EcalBarrelRecHitsMaker::maxAdc_ [private] |
Definition at line 56 of file EcalBarrelRecHitsMaker.h.
Referenced by EcalBarrelRecHitsMaker(), and geVtoGainAdc().
unsigned EcalBarrelRecHitsMaker::minAdc_ [private] |
Definition at line 55 of file EcalBarrelRecHitsMaker.h.
Referenced by EcalBarrelRecHitsMaker(), and geVtoGainAdc().
double EcalBarrelRecHitsMaker::noise_ [private] |
Definition at line 38 of file EcalBarrelRecHitsMaker.h.
Referenced by clean(), EcalBarrelRecHitsMaker(), and loadEcalBarrelRecHits().
bool EcalBarrelRecHitsMaker::noisified_ [private] |
Definition at line 41 of file EcalBarrelRecHitsMaker.h.
Referenced by clean(), EcalBarrelRecHitsMaker(), and loadEcalBarrelRecHits().
const RandomEngine* EcalBarrelRecHitsMaker::random_ [private] |
double EcalBarrelRecHitsMaker::refactor_ [private] |
Definition at line 34 of file EcalBarrelRecHitsMaker.h.
Referenced by EcalBarrelRecHitsMaker(), and init().
double EcalBarrelRecHitsMaker::refactor_mean_ [private] |
Definition at line 35 of file EcalBarrelRecHitsMaker.h.
Referenced by EcalBarrelRecHitsMaker(), and init().
float EcalBarrelRecHitsMaker::sat_ [private] |
Definition at line 57 of file EcalBarrelRecHitsMaker.h.
Referenced by EcalBarrelRecHitsMaker(), and loadEcalBarrelRecHits().
float EcalBarrelRecHitsMaker::t1_ [private] |
Definition at line 57 of file EcalBarrelRecHitsMaker.h.
Referenced by EcalBarrelRecHitsMaker(), and geVtoGainAdc().
float EcalBarrelRecHitsMaker::t2_ [private] |
Definition at line 57 of file EcalBarrelRecHitsMaker.h.
Referenced by EcalBarrelRecHitsMaker(), and geVtoGainAdc().
std::vector<float> EcalBarrelRecHitsMaker::theCalibConstants_ [private] |
std::vector<float> EcalBarrelRecHitsMaker::theCalorimeterHits_ [private] |
Definition at line 44 of file EcalBarrelRecHitsMaker.h.
Referenced by clean(), EcalBarrelRecHitsMaker(), loadEcalBarrelRecHits(), and loadPCaloHits().
std::vector<int> EcalBarrelRecHitsMaker::theFiredCells_ [private] |
Definition at line 46 of file EcalBarrelRecHitsMaker.h.
Referenced by clean(), loadEcalBarrelRecHits(), and loadPCaloHits().
double EcalBarrelRecHitsMaker::threshold_ [private] |
Definition at line 37 of file EcalBarrelRecHitsMaker.h.
Referenced by EcalBarrelRecHitsMaker(), and loadEcalBarrelRecHits().