56 pedsPSet_(iConfig.getParameter<edm::
ParameterSet>(
"PedestalsPSet")),
65 edm::LogInfo(
"SiStripMonitorPedestals") <<
"SiStripMonitorPedestals "
66 <<
" Constructing....... ";
73 edm::LogInfo(
"SiStripMonitorPedestals") <<
"SiStripMonitorPedestals "
74 <<
" Destructing...... ";
95 edm::LogInfo(
"SiStripMonitorPedestals") <<
"SiStripMonitorPedestals::beginRun: "
96 <<
" Creating MEs for new Cabling ";
99 edm::LogInfo(
"SiStripMonitorPedestals") <<
"SiStripMonitorPedestals::beginRun: "
100 <<
" Resetting MEs ";
101 for (std::map<uint32_t, ModMEs >::const_iterator idet =
PedMEs.begin() ; idet!=
PedMEs.end() ; idet++) {
111 std::vector<uint32_t> SelectedDetIds;
117 detcabling->addActiveDetectorsRawIds(SelectedDetIds);
124 edm::LogInfo(
"SiStripMonitorPedestals") <<
"SiStripMonitorPedestals::createMEs: "
125 <<
"Number of Detector Present in cabling " << SelectedDetIds.size();
127 for (std::vector<uint32_t>::const_iterator idetid=SelectedDetIds.begin(), iEnd=SelectedDetIds.end();idetid!=iEnd;++idetid){
129 uint32_t
detid = *idetid;
132 if (detid == 0 || detid == 0xFFFFFFFF){
133 edm::LogError(
"SiStripMonitorPedestals") <<
"SiStripMonitorPedestals::createMEs: "
134 <<
"Wrong DetId !!!!!! " << detid <<
" Neglecting !!!!!! ";
138 unsigned int apv_pairs =
detcabling->nApvPairs(detid);
141 if (apv_pairs < 1 || apv_pairs > 3) {
142 edm::LogError(
"SiStripMonitorPedestals") <<
"SiStripMonitorPedestals::createMEs: Wrong APV Pairs => detId "
143 << detid <<
" APV pairs " << apv_pairs <<
" Neglecting !!!!!! ";
146 unsigned int napvs = apv_pairs * 2;
147 unsigned int nStrip = napvs * 128;
177 hid = hidmanager.
createHistoId(
"PedestalFromCondDB",
"det", detid);
180 (local_modmes.
PedsPerStripDB)->setAxisTitle(
"Pedestal from CondDB(ADC) vs Strip Number",1);
182 hid = hidmanager.
createHistoId(
"NoiseFromCondDB",
"det", detid);
185 (local_modmes.
CMSubNoisePerStripDB)->setAxisTitle(
"CMSubNoise from CondDB(ADC) vs Strip Number",1);
187 hid = hidmanager.
createHistoId(
"BadStripFlagCondDB",
"det", detid);
190 (local_modmes.
BadStripsDB)->setAxisTitle(
"Strip Flag from CondDB(ADC) vs Strip Number",1);
197 (local_modmes.
PedsPerStrip)->setAxisTitle(
"Pedestal (ADC) vs Strip Number ",1);
199 hid = hidmanager.
createHistoId(
"PedsDistribution",
"det", detid);
203 (local_modmes.
PedsDistribution)->setAxisTitle(
"Mean Pedestal Value (ADC)",2);
205 hid = hidmanager.
createHistoId(
"PedsEvolution",
"det", detid);
209 (local_modmes.
PedsEvolution)->setAxisTitle(
"Iteration Number",2);
212 hid = hidmanager.
createHistoId(
"CMSubNoisePerStrip",
"det", detid);
215 (local_modmes.
CMSubNoisePerStrip)->setAxisTitle(
"CMSubNoise (ADC) vs Strip Number",1);
217 hid = hidmanager.
createHistoId(
"RawNoisePerStrip",
"det", detid);
220 (local_modmes.
RawNoisePerStrip)->setAxisTitle(
"RawNoise(ADC) vs Strip Number",1);
222 hid = hidmanager.
createHistoId(
"CMSubNoiseProfile",
"det", detid);
225 (local_modmes.
CMSubNoiseProfile)->setAxisTitle(
"Mean of CMSubNoise (ADC) vs Strip Number",1);
227 hid = hidmanager.
createHistoId(
"RawNoiseProfile",
"det", detid);
230 (local_modmes.
RawNoiseProfile)->setAxisTitle(
"Mean of RawNoise (ADC) vs Strip Number",1);
235 (local_modmes.
NoisyStrips)->setAxisTitle(
"Strip Number",1);
236 (local_modmes.
NoisyStrips)->setAxisTitle(
"Flag Value",2);
238 hid = hidmanager.
createHistoId(
"NoisyStripDistribution",
"det", detid);
244 hid = hidmanager.
createHistoId(
"CMDistribution",
"det", detid);
247 (local_modmes.
CMDistribution)->setAxisTitle(
"Common Mode (ADC) vs APV Number",1);
249 hid = hidmanager.
createHistoId(
"CMSlopeDistribution",
"det", detid);
257 PedMEs.insert( std::make_pair(detid, local_modmes));
261 edm::LogInfo(
"SiStripMonitorPedestals") <<
"SiStripMonitorPedestals::createMEs: Number of DETS used "
269 "SiStripMonitorPedestals::analyze: Run " <<
283 std::string digiType =
"VirginRaw";
285 iEvent.
getByLabel(digiProducer, digiType, digi_collection);
292 for (std::map<uint32_t, ModMEs >::const_iterator
i =
PedMEs.begin() ;
i!=
PedMEs.end() ;
i++) {
295 std::vector< edm::DetSet<SiStripRawDigi> >::const_iterator digis = digi_collection->find( detid );
296 if (digis == digi_collection->end() ||
297 digis->data.size() == 0 ||
298 digis->data.size() > 768) {
299 if (digis == digi_collection->end()) {
300 edm::LogError(
"SiStripMonitorPedestals") <<
" SiStripMonitorPedestals::analyze: Event " <<
nEvTot_
301 <<
" DetId " << detid <<
" at the end of Digi Collection!!!";
303 edm::LogError(
"SiStripMonitorPedestals") <<
" [SiStripMonitorPedestals::analyze: Event " <<
nEvTot_
304 <<
" DetId " << detid <<
" # of Digis " << digis->data.size() ;
306 std::vector<const FedChannelConnection *> fed_conns =
detcabling->getConnections(detid);
307 for (
unsigned int k = 0;
k < fed_conns.size() ;
k++) {
308 if (
k==0)
edm::LogError(
"SiStripMonitorPedestals") <<
" SiStripMonitorPedestals::analyze: Fed Id " <<
309 fed_conns[
k]->fedId() <<
" Channel " << fed_conns[
k]->fedCh();
310 else edm::LogError(
"SiStripMonitorPedestals") <<
" SiStripMonitorPedestals::analyze: Channel " <<
311 fed_conns[
k]->fedCh();
317 if ( digis->data.empty() ) {
318 edm::LogError(
"MonitorDigi_tmp") <<
"[SiStripRawDigiToRaw::createFedBuffers] Zero digis found!";
326 std::vector<float>
tmp;
332 for (std::vector<float>::const_iterator iped=tmp.begin(); iped!=tmp.end();iped++) {
333 int iapv = int (ibin/numberCMBlocks);
340 std::vector<float>
tmp;
344 for (std::vector<float>::const_iterator it=tmp.begin(); it!=tmp.end();it++) {
355 std::vector<float>
tmp;
359 int numberOfApvs = int(tmp.size()/128.);
360 for(
int i=0;
i<numberOfApvs;
i++){
361 std::vector<float> myPedPerApv;
364 avarage = accumulate(myPedPerApv.begin(), myPedPerApv.end(), avarage);
365 avarage = avarage/128.;
371 for (std::vector<float>::const_iterator iped=tmp.begin(); iped!=tmp.end();iped++) {
372 int napv = int(ibin / 128.);
374 float last_value = (local_modmes.
PedsPerStrip)->getBinContent(ibin);
375 if(last_value != 0.){
376 (local_modmes.
PedsPerStrip)->setBinContent(ibin,(static_cast<float>(*iped) + last_value)/2.);
378 (local_modmes.
PedsPerStrip)->setBinContent(ibin,static_cast<float>(*iped));
388 for (std::vector<float>::const_iterator iped=tmp.begin(); iped!=tmp.end();iped++) {
393 if(last_value != 0.){
394 (local_modmes.
CMSubNoisePerStrip)->setBinContent(ibin,(static_cast<float>(*iped)+last_value)/2.);
406 for (std::vector<float>::const_iterator iped=tmp.begin(); iped!=tmp.end();iped++) {
408 (local_modmes.
RawNoiseProfile)->
Fill(static_cast<double>(ibin*1.),
static_cast<float>(*iped));
410 if(last_value != 0.){
411 (local_modmes.
RawNoisePerStrip)->setBinContent(ibin,(static_cast<float>(*iped)+last_value)/2.);
413 (local_modmes.
RawNoisePerStrip)->setBinContent(ibin,static_cast<float>(*iped));
422 for (TkApvMask::MaskType::const_iterator iped=temp.begin(); iped!=temp.end();iped++) {
449 if (outputMEsInRootFile) {
459 edm::LogInfo(
"SiStripMonitorPedestals") <<
"SiStripMonitorPedestals::EndJob: "
466 std::map<uint32_t, ModMEs >::iterator
pos =
PedMEs.find(idet);
467 if (pos !=
PedMEs.end()) {
468 ModMEs mod_me = pos->second;
500 std::string quality_label =
conf_.
getParameter<std::string>(
"StripQualityLabel");
503 for (std::map<uint32_t, ModMEs >::const_iterator
i =
PedMEs.begin() ;
i!=
PedMEs.end() ;
i++) {
504 uint32_t
detid =
i->first;
505 ModMEs local_modmes =
i->second;
506 edm::LogInfo(
"SiStripMonitorPedestals") <<
" SiStripMonitorPedestals::analyze: " <<
507 " Get Ped/Noise/Bad Strips from CondDb for DetId " <<
detid;
508 int nStrip =
detcabling->nApvPairs(detid) * 256;
514 for(
int istrip=0;istrip<nStrip;++istrip){
517 (local_modmes.
PedsPerStripDB)->
Fill(istrip+1,pedestalHandle->getPed(istrip,pedRange));
520 edm::LogError(
"SiStripMonitorPedestals") <<
"[SiStripMonitorPedestals::analyze] cms::Exception accessing SiStripPedestalsService_.getPedestal("<<detid<<
","<<istrip<<
") : " <<
" " << e.
what() ;
528 edm::LogError(
"SiStripMonitorPedestals") <<
"[SiStripMonitorPedestals::analyze] cms::Exception accessing SiStripNoiseService_.getNoise("<<detid<<
","<<istrip<<
") : " <<
" " << e.
what() ;
532 (local_modmes.
BadStripsDB)->
Fill(istrip+1,qualityHandle->IsStripBad(qualityRange,istrip)?1.:0.);
537 edm::LogError(
"SiStripMonitorPedestals") <<
"[SiStripMonitorPedestals::analyze] cms::Exception accessing SiStripNoiseService_.getDisable("<<detid<<
","<<istrip<<
") : " <<
" " << e.
what() ;
std::vector< StripMaskType > MaskType
virtual void endRun(edm::Run const &run, edm::EventSetup const &eSetup)
virtual char const * what() const
T getParameter(std::string const &) const
EventNumber_t event() const
void fillCondDBMEs(edm::EventSetup const &eSetup)
edm::ESHandle< SiStripDetCabling > detcabling
MonitorElement * RawNoiseProfile
virtual void analyze(const edm::Event &, const edm::EventSetup &)
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
MonitorElement * CMDistribution
void getPedestal(uint32_t det_id, int apvNumber, ApvAnalysis::PedestalType &peds)
#define DEFINE_FWK_MODULE(type)
void save(const std::string &filename, const std::string &path="", const std::string &pattern="", const std::string &rewrite="", SaveReferenceTag ref=SaveWithReference, int minStatus=dqm::qstatus::STATUS_OK, const std::string &fileupdate="RECREATE")
void getCommonModeSlope(uint32_t det_id, ApvAnalysis::PedestalType &tmp)
void getNoise(uint32_t det_id, int apvNumber, ApvAnalysis::PedestalType &noise)
void update(uint32_t det_id, const edm::DetSet< SiStripRawDigi > &in)
void getMask(uint32_t det_id, TkApvMask::MaskType &tmp)
std::pair< ContainerIterator, ContainerIterator > Range
virtual void beginRun(edm::Run const &run, edm::EventSetup const &eSetup)
MonitorElement * CMSubNoisePerStrip
static const std::string RunMode1
void getRawNoise(uint32_t det_id, int apvNumber, ApvAnalysis::PedestalType &noise)
void tag(MonitorElement *me, unsigned int myTag)
edm::ParameterSet pedsPSet_
MonitorElement * RawNoisePerStrip
MonitorElement * PedsEvolution
MonitorElement * PedsPerStrip
void Fill(HcalDetId &id, double val, std::vector< TH2F > &depth)
static const std::string RunMode3
bool instantiateApvs(uint32_t det_id, int numberOfApvs)
SiStripMonitorPedestals(const edm::ParameterSet &)
~SiStripMonitorPedestals()
ApvAnalysisFactory * apvFactory_
MonitorElement * bookProfile(const char *name, const char *title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, const char *option="s")
MonitorElement * PedsDistribution
MonitorElement * CMSubNoiseProfile
void setDetectorFolder(uint32_t rawdetid=0)
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
void getCommonMode(uint32_t det_id, ApvAnalysis::PedestalType &tmp)
MonitorElement * CMSlopeDistribution
MonitorElement * PedsPerStripDB
MonitorElement * NoisyStripDistribution
std::string createHistoId(std::string description, std::string id_type, uint32_t component_id)
MonitorElement * CMSubNoisePerStripDB
std::vector< std::vector< double > > tmp
unsigned long long m_cacheID_
std::pair< ContainerIterator, ContainerIterator > Range
static const std::string RunMode2
MonitorElement * BadStripsDB
std::string outPutFileName
std::pair< ContainerIterator, ContainerIterator > Range
MonitorElement * book2D(const char *name, const char *title, int nchX, double lowX, double highX, int nchY, double lowY, double highY)
Book 2D histogram.
void Reset(void)
reset ME (ie. contents, errors, etc)
void resetMEs(uint32_t idet)
std::map< uint32_t, ModMEs > PedMEs
MonitorElement * NoisyStrips