#include <SimCalorimetry/EcalSelectiveReadoutProducers/interface/EcalSelectiveReadoutProducer.h>
Public Member Functions | |
EcalSelectiveReadoutProducer (const edm::ParameterSet ¶ms) | |
Constructor. | |
virtual void | produce (edm::Event &event, const edm::EventSetup &eventSetup) |
Produces the EDM products. | |
virtual | ~EcalSelectiveReadoutProducer () |
Destructor. | |
Static Public Member Functions | |
static void | printSrFlags (std::ostream &os, const EBSrFlagCollection &ebSrFlags, const EESrFlagCollection &eeSrFlags, int iEvent=-1, bool withHeader=true) |
Help function to print SR flags. | |
Private Member Functions | |
void | checkGeometry (const edm::EventSetup &eventSetup) |
call these once an event, to make sure everything is up-to-date | |
void | checkTriggerMap (const edm::EventSetup &eventSetup) |
void | checkWeights (const edm::Event &evt, const edm::ProductID &noZSDigiId) const |
Sanity check on the DCC FIR filter weights. | |
bool | getBinOfMax (const edm::Event &evt, const edm::ProductID &noZsDigiId, int &binOfMax) const |
Gets the value of the digitizer binOfMaximum parameter. | |
const EBDigiCollection * | getEBDigis (edm::Event &event) const |
const EEDigiCollection * | getEEDigis (edm::Event &event) const |
const EcalTrigPrimDigiCollection * | getTrigPrims (edm::Event &event) const |
void | printTTFlags (const EcalTrigPrimDigiCollection &tp, std::ostream &os) const |
Private Attributes | |
std::string | digiProducer_ |
int | dumpFlags_ |
Number of event whose TT and SR flags must be dumped into a file. | |
std::string | ebdigiCollection_ |
std::string | ebSrFlagCollection_ |
std::string | ebSRPdigiCollection_ |
std::string | eedigiCollection_ |
std::string | eeSrFlagCollection_ |
std::string | eeSRPdigiCollection_ |
edm::ParameterSet | params_ |
std::auto_ptr < EcalSelectiveReadoutSuppressor > | suppressor_ |
const CaloGeometry * | theGeometry |
const EcalTrigTowerConstituentsMap * | theTriggerTowerMap |
bool | trigPrimBypass_ |
std::string | trigPrimCollection_ |
std::string | trigPrimProducer_ |
bool | writeSrFlags_ |
Definition at line 15 of file EcalSelectiveReadoutProducer.h.
EcalSelectiveReadoutProducer::EcalSelectiveReadoutProducer | ( | const edm::ParameterSet & | params | ) | [explicit] |
Constructor.
params | seletive readout parameters |
Definition at line 15 of file EcalSelectiveReadoutProducer.cc.
References digiProducer_, dumpFlags_, ebdigiCollection_, ebSrFlagCollection_, ebSRPdigiCollection_, eedigiCollection_, eeSrFlagCollection_, eeSRPdigiCollection_, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), suppressor_, theGeometry, theTriggerTowerMap, trigPrimBypass_, trigPrimCollection_, trigPrimProducer_, and writeSrFlags_.
00016 : params_(params) 00017 { 00018 //sets up parameters: 00019 digiProducer_ = params.getParameter<string>("digiProducer"); 00020 ebdigiCollection_ = params.getParameter<std::string>("EBdigiCollection"); 00021 eedigiCollection_ = params.getParameter<std::string>("EEdigiCollection"); 00022 ebSRPdigiCollection_ = params.getParameter<std::string>("EBSRPdigiCollection"); 00023 eeSRPdigiCollection_ = params.getParameter<std::string>("EESRPdigiCollection"); 00024 ebSrFlagCollection_ = params.getParameter<std::string>("EBSrFlagCollection"); 00025 eeSrFlagCollection_ = params.getParameter<std::string>("EESrFlagCollection"); 00026 trigPrimProducer_ = params.getParameter<string>("trigPrimProducer"); 00027 trigPrimCollection_ = params.getParameter<string>("trigPrimCollection"); 00028 trigPrimBypass_ = params.getParameter<bool>("trigPrimBypass"); 00029 dumpFlags_ = params.getUntrackedParameter<int>("dumpFlags", 0); 00030 writeSrFlags_ = params.getUntrackedParameter<bool>("writeSrFlags",false); 00031 //instantiates the selective readout algorithm: 00032 suppressor_ = auto_ptr<EcalSelectiveReadoutSuppressor>(new EcalSelectiveReadoutSuppressor(params)); 00033 //declares the products made by this producer: 00034 produces<EBDigiCollection>(ebSRPdigiCollection_); 00035 produces<EEDigiCollection>(eeSRPdigiCollection_); 00036 00037 if ( writeSrFlags_ ) { 00038 produces<EBSrFlagCollection>(ebSrFlagCollection_); 00039 produces<EESrFlagCollection>(eeSrFlagCollection_); 00040 } 00041 00042 theGeometry = 0; 00043 theTriggerTowerMap = 0; 00044 00045 }
EcalSelectiveReadoutProducer::~EcalSelectiveReadoutProducer | ( | ) | [virtual] |
void EcalSelectiveReadoutProducer::checkGeometry | ( | const edm::EventSetup & | eventSetup | ) | [private] |
call these once an event, to make sure everything is up-to-date
Definition at line 153 of file EcalSelectiveReadoutProducer.cc.
References edm::EventSetup::get(), suppressor_, and theGeometry.
Referenced by produce().
00154 { 00155 edm::ESHandle<CaloGeometry> hGeometry; 00156 eventSetup.get<CaloGeometryRecord>().get(hGeometry); 00157 00158 const CaloGeometry * pGeometry = &*hGeometry; 00159 00160 // see if we need to update 00161 if(pGeometry != theGeometry) { 00162 theGeometry = pGeometry; 00163 suppressor_->setGeometry(theGeometry); 00164 } 00165 }
void EcalSelectiveReadoutProducer::checkTriggerMap | ( | const edm::EventSetup & | eventSetup | ) | [private] |
Definition at line 168 of file EcalSelectiveReadoutProducer.cc.
References edm::EventSetup::get(), suppressor_, and theTriggerTowerMap.
Referenced by produce().
00169 { 00170 00171 edm::ESHandle<EcalTrigTowerConstituentsMap> eTTmap; 00172 eventSetup.get<IdealGeometryRecord>().get(eTTmap); 00173 00174 const EcalTrigTowerConstituentsMap * pMap = &*eTTmap; 00175 00176 // see if we need to update 00177 if(pMap!= theTriggerTowerMap) { 00178 theTriggerTowerMap = pMap; 00179 suppressor_->setTriggerMap(theTriggerTowerMap); 00180 } 00181 }
void EcalSelectiveReadoutProducer::checkWeights | ( | const edm::Event & | evt, | |
const edm::ProductID & | noZSDigiId | |||
) | const [private] |
Sanity check on the DCC FIR filter weights.
Log warning or error message if an unexpected weight set is found. In principle it is checked that the maximum weight is applied to the expected maximum sample.
Definition at line 220 of file EcalSelectiveReadoutProducer.cc.
References getBinOfMax(), EcalSelectiveReadoutSuppressor::getFIRTapCount(), edm::ParameterSet::getParameter(), i, params_, and weights.
Referenced by getEBDigis(), and getEEDigis().
00221 { 00222 const vector<double> & weights = params_.getParameter<vector<double> >("dccNormalizedWeights"); 00223 int nFIRTaps = EcalSelectiveReadoutSuppressor::getFIRTapCount(); 00224 static bool warnWeightCnt = true; 00225 if((int)weights.size() > nFIRTaps && warnWeightCnt){ 00226 edm::LogWarning("Configuration") << "The list of DCC zero suppression FIR " 00227 "weights given in parameter dccNormalizedWeights is longer " 00228 "than the expected depth of the FIR filter :(" << nFIRTaps << "). " 00229 "The last weights will be discarded."; 00230 warnWeightCnt = false; //it's not needed to repeat the warning. 00231 } 00232 00233 if(weights.size()>0){ 00234 int iMaxWeight = 0; 00235 double maxWeight = weights[iMaxWeight]; 00236 //looks for index of maximum weight 00237 for(unsigned i=0; i<weights.size(); ++i){ 00238 if(weights[i]>maxWeight){ 00239 iMaxWeight = i; 00240 maxWeight = weights[iMaxWeight]; 00241 } 00242 } 00243 00244 //position of time sample whose maximum weight is applied: 00245 int maxWeightBin = params_.getParameter<int>("ecalDccZs1stSample") 00246 + iMaxWeight; 00247 00248 //gets the bin of maximum (in case of raw data it will not exist) 00249 int binOfMax = 0; 00250 bool rc = getBinOfMax(evt, noZsDigiId, binOfMax); 00251 00252 if(rc && maxWeightBin!=binOfMax){ 00253 edm::LogWarning("Configuration") 00254 << "The maximum weight of DCC zero suppression FIR filter is not " 00255 "applied to the expected maximum sample(" << binOfMax 00256 << (binOfMax==1?"st":(binOfMax==2?"nd":(binOfMax==3?"rd":"th"))) 00257 << " time sample). This may indicate faulty 'dccNormalizedWeights' " 00258 "or 'ecalDccZs1sSample' parameters."; 00259 } 00260 } 00261 }
bool EcalSelectiveReadoutProducer::getBinOfMax | ( | const edm::Event & | evt, | |
const edm::ProductID & | noZsDigiId, | |||
int & | binOfMax | |||
) | const [private] |
Gets the value of the digitizer binOfMaximum parameter.
noZsDigiId | product ID of the non-suppressed digis | |
binOfMax | [out] set the parameter value if found |
Definition at line 264 of file EcalSelectiveReadoutProducer.cc.
References find(), edm::ParameterSet::getParameter(), edm::ParameterSet::getParameterNames(), edm::getParameterSet(), edm::Event::getProvenance(), p, edm::Provenance::psetID(), and HLT_VtxMuL3::result.
Referenced by checkWeights().
00266 { 00267 bool rc; 00268 const edm::Provenance p=evt.getProvenance(noZsDigiId); 00269 edm::ParameterSet result = getParameterSet(p.psetID()); 00270 vector<string> ebDigiParamList = result.getParameterNames(); 00271 string bofm("binOfMaximum"); 00272 if(find(ebDigiParamList.begin(), ebDigiParamList.end(), bofm) 00273 != ebDigiParamList.end()){//bofm found 00274 binOfMax=result.getParameter<int>("binOfMaximum"); 00275 rc = true; 00276 } else{ 00277 rc = false; 00278 } 00279 return rc; 00280 }
const EBDigiCollection * EcalSelectiveReadoutProducer::getEBDigis | ( | edm::Event & | event | ) | const [private] |
Definition at line 113 of file EcalSelectiveReadoutProducer.cc.
References checkWeights(), digiProducer_, ebdigiCollection_, edm::Handle< T >::id(), edm::Handle< T >::product(), and HLT_VtxMuL3::result.
Referenced by produce().
00114 { 00115 edm::Handle<EBDigiCollection> hEBDigis; 00116 event.getByLabel(digiProducer_, ebdigiCollection_, hEBDigis); 00117 //product() method is called before id() in order to get an exception 00118 //if the handle is not available (check not done by id() method). 00119 const EBDigiCollection* result = hEBDigis.product(); 00120 static bool firstCall= true; 00121 if(firstCall){ 00122 checkWeights(event, hEBDigis.id()); 00123 firstCall = false; 00124 } 00125 return result; 00126 }
const EEDigiCollection * EcalSelectiveReadoutProducer::getEEDigis | ( | edm::Event & | event | ) | const [private] |
Definition at line 129 of file EcalSelectiveReadoutProducer.cc.
References checkWeights(), digiProducer_, eedigiCollection_, edm::Handle< T >::id(), edm::Handle< T >::product(), and HLT_VtxMuL3::result.
Referenced by produce().
00130 { 00131 edm::Handle<EEDigiCollection> hEEDigis; 00132 event.getByLabel(digiProducer_, eedigiCollection_, hEEDigis); 00133 //product() method is called before id() in order to get an exception 00134 //if the handle is not available (check not done by id() method). 00135 const EEDigiCollection* result = hEEDigis.product(); 00136 static bool firstCall = true; 00137 if(firstCall){ 00138 checkWeights(event, hEEDigis.id()); 00139 firstCall = false; 00140 } 00141 return result; 00142 }
const EcalTrigPrimDigiCollection * EcalSelectiveReadoutProducer::getTrigPrims | ( | edm::Event & | event | ) | const [private] |
Definition at line 145 of file EcalSelectiveReadoutProducer.cc.
References edm::Handle< T >::product(), trigPrimCollection_, and trigPrimProducer_.
Referenced by produce().
00146 { 00147 edm::Handle<EcalTrigPrimDigiCollection> hTPDigis; 00148 event.getByLabel(trigPrimProducer_, trigPrimCollection_, hTPDigis); 00149 return hTPDigis.product(); 00150 }
static void EcalSelectiveReadoutProducer::printSrFlags | ( | std::ostream & | os, | |
const EBSrFlagCollection & | ebSrFlags, | |||
const EESrFlagCollection & | eeSrFlags, | |||
int | iEvent = -1 , |
|||
bool | withHeader = true | |||
) | [static] |
void EcalSelectiveReadoutProducer::printTTFlags | ( | const EcalTrigPrimDigiCollection & | tp, | |
std::ostream & | os | |||
) | const [private] |
void EcalSelectiveReadoutProducer::produce | ( | edm::Event & | event, | |
const edm::EventSetup & | eventSetup | |||
) | [virtual] |
Produces the EDM products.
CMS | event | |
eventSetup | event conditions |
Implements edm::EDProducer.
Definition at line 54 of file EcalSelectiveReadoutProducer.cc.
References checkGeometry(), checkTriggerMap(), dumpFlags_, ebSrFlagCollection_, ebSRPdigiCollection_, eeSrFlagCollection_, eeSRPdigiCollection_, getEBDigis(), getEEDigis(), getTrigPrims(), iEvent, printSrFlags(), suppressor_, trigPrimBypass_, and writeSrFlags_.
00055 { 00056 // check that everything is up-to-date 00057 checkGeometry(eventSetup); 00058 checkTriggerMap(eventSetup); 00059 00060 //gets the trigger primitives: 00061 EcalTrigPrimDigiCollection emptyTPColl; 00062 const EcalTrigPrimDigiCollection* trigPrims = 00063 trigPrimBypass_?&emptyTPColl:getTrigPrims(event); 00064 00065 00066 //gets the digis from the events: 00067 const EBDigiCollection* ebDigis = getEBDigis(event); 00068 const EEDigiCollection* eeDigis = getEEDigis(event); 00069 00070 //runs the selective readout algorithm: 00071 auto_ptr<EBDigiCollection> selectedEBDigis(new EBDigiCollection); 00072 auto_ptr<EEDigiCollection> selectedEEDigis(new EEDigiCollection); 00073 auto_ptr<EBSrFlagCollection> ebSrFlags(new EBSrFlagCollection); 00074 auto_ptr<EESrFlagCollection> eeSrFlags(new EESrFlagCollection); 00075 00076 suppressor_->run(eventSetup, *trigPrims, *ebDigis, *eeDigis, 00077 *selectedEBDigis, *selectedEEDigis, 00078 *ebSrFlags, *eeSrFlags); 00079 00080 static int iEvent = 1; 00081 if(dumpFlags_>=iEvent){ 00082 ofstream ttfFile("TTF.txt", (iEvent==1?ios::trunc:ios::app)); 00083 suppressor_->printTTFlags(ttfFile, iEvent, 00084 iEvent==1?true:false); 00085 00086 ofstream srfFile("SRF.txt", (iEvent==1?ios::trunc:ios::app)); 00087 if(iEvent==1){ 00088 suppressor_->getEcalSelectiveReadout()->printHeader(srfFile); 00089 } 00090 srfFile << "# Event " << iEvent << "\n"; 00091 suppressor_->getEcalSelectiveReadout()->print(srfFile); 00092 srfFile << "\n"; 00093 00094 ofstream afFile("AF.txt", (iEvent==1?ios::trunc:ios::app)); 00095 printSrFlags(afFile, *ebSrFlags, *eeSrFlags, iEvent, 00096 iEvent==1?true:false); 00097 } 00098 00099 ++iEvent; //event counter 00100 00101 //puts the selected digis into the event: 00102 event.put(selectedEBDigis, ebSRPdigiCollection_); 00103 event.put(selectedEEDigis, eeSRPdigiCollection_); 00104 00105 //puts the SR flags into the event: 00106 if ( writeSrFlags_ ) { 00107 event.put(ebSrFlags, ebSrFlagCollection_); 00108 event.put(eeSrFlags, eeSrFlagCollection_); 00109 } 00110 }
std::string EcalSelectiveReadoutProducer::digiProducer_ [private] |
Definition at line 90 of file EcalSelectiveReadoutProducer.h.
Referenced by EcalSelectiveReadoutProducer(), getEBDigis(), and getEEDigis().
int EcalSelectiveReadoutProducer::dumpFlags_ [private] |
Number of event whose TT and SR flags must be dumped into a file.
Definition at line 109 of file EcalSelectiveReadoutProducer.h.
Referenced by EcalSelectiveReadoutProducer(), and produce().
std::string EcalSelectiveReadoutProducer::ebdigiCollection_ [private] |
Definition at line 91 of file EcalSelectiveReadoutProducer.h.
Referenced by EcalSelectiveReadoutProducer(), and getEBDigis().
std::string EcalSelectiveReadoutProducer::ebSrFlagCollection_ [private] |
Definition at line 95 of file EcalSelectiveReadoutProducer.h.
Referenced by EcalSelectiveReadoutProducer(), and produce().
std::string EcalSelectiveReadoutProducer::ebSRPdigiCollection_ [private] |
Definition at line 93 of file EcalSelectiveReadoutProducer.h.
Referenced by EcalSelectiveReadoutProducer(), and produce().
std::string EcalSelectiveReadoutProducer::eedigiCollection_ [private] |
Definition at line 92 of file EcalSelectiveReadoutProducer.h.
Referenced by EcalSelectiveReadoutProducer(), and getEEDigis().
std::string EcalSelectiveReadoutProducer::eeSrFlagCollection_ [private] |
Definition at line 96 of file EcalSelectiveReadoutProducer.h.
Referenced by EcalSelectiveReadoutProducer(), and produce().
std::string EcalSelectiveReadoutProducer::eeSRPdigiCollection_ [private] |
Definition at line 94 of file EcalSelectiveReadoutProducer.h.
Referenced by EcalSelectiveReadoutProducer(), and produce().
std::auto_ptr<EcalSelectiveReadoutSuppressor> EcalSelectiveReadoutProducer::suppressor_ [private] |
Definition at line 89 of file EcalSelectiveReadoutProducer.h.
Referenced by checkGeometry(), checkTriggerMap(), EcalSelectiveReadoutProducer(), and produce().
const CaloGeometry* EcalSelectiveReadoutProducer::theGeometry [private] |
Definition at line 101 of file EcalSelectiveReadoutProducer.h.
Referenced by checkGeometry(), and EcalSelectiveReadoutProducer().
Definition at line 102 of file EcalSelectiveReadoutProducer.h.
Referenced by checkTriggerMap(), and EcalSelectiveReadoutProducer().
Definition at line 105 of file EcalSelectiveReadoutProducer.h.
Referenced by EcalSelectiveReadoutProducer(), and produce().
std::string EcalSelectiveReadoutProducer::trigPrimCollection_ [private] |
Definition at line 98 of file EcalSelectiveReadoutProducer.h.
Referenced by EcalSelectiveReadoutProducer(), and getTrigPrims().
std::string EcalSelectiveReadoutProducer::trigPrimProducer_ [private] |
Definition at line 97 of file EcalSelectiveReadoutProducer.h.
Referenced by EcalSelectiveReadoutProducer(), and getTrigPrims().
Definition at line 112 of file EcalSelectiveReadoutProducer.h.
Referenced by EcalSelectiveReadoutProducer(), and produce().