CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
SiStripGainsPCLHarvester Class Reference

#include <SiStripGainsPCLHarvester.h>

Inheritance diagram for SiStripGainsPCLHarvester:
DQMEDHarvester edm::one::EDProducer< edm::Accumulator, edm::EndLuminosityBlockProducer, edm::EndRunProducer, edm::one::WatchLuminosityBlocks, edm::one::WatchRuns, edm::one::SharedResources > edm::one::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

void beginRun (edm::Run const &run, edm::EventSetup const &isetup) override
 
void endRun (edm::Run const &run, edm::EventSetup const &isetup) override
 
 SiStripGainsPCLHarvester (const edm::ParameterSet &ps)
 
- Public Member Functions inherited from DQMEDHarvester
void accumulate (edm::Event const &ev, edm::EventSetup const &es) final
 
void beginLuminosityBlock (edm::LuminosityBlock const &, edm::EventSetup const &) final
 
void beginRun (edm::Run const &, edm::EventSetup const &) override
 
 DQMEDHarvester ()
 
virtual void dqmEndLuminosityBlock (DQMStore::IBooker &, DQMStore::IGetter &, edm::LuminosityBlock const &, edm::EventSetup const &)
 
void endJob () final
 
void endLuminosityBlock (edm::LuminosityBlock const &, edm::EventSetup const &) final
 
void endLuminosityBlockProduce (edm::LuminosityBlock &, edm::EventSetup const &) final
 
void endRun (edm::Run const &, edm::EventSetup const &) override
 
void endRunProduce (edm::Run &run, edm::EventSetup const &setup) override
 
 ~DQMEDHarvester () override=default
 
- Public Member Functions inherited from edm::one::EDProducer< edm::Accumulator, edm::EndLuminosityBlockProducer, edm::EndRunProducer, edm::one::WatchLuminosityBlocks, edm::one::WatchRuns, edm::one::SharedResources >
 EDProducer ()=default
 
SerialTaskQueueglobalLuminosityBlocksQueue () final
 
SerialTaskQueueglobalRunsQueue () final
 
bool hasAbilityToProduceInLumis () const final
 
bool hasAbilityToProduceInRuns () const final
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
- Public Member Functions inherited from edm::one::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
bool wantsStreamLuminosityBlocks () const
 
bool wantsStreamRuns () const
 
 ~EDProducerBase () override
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
std::vector< edm::ProductResolverIndex > const & putTokenIndexToProductResolverIndex () const
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription const &)> registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, ModuleToResolverIndicies const &iIndicies, std::string const &moduleLabel)
 
 ~ProducerBase () noexcept(false) override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
virtual ~EDConsumerBase () noexcept(false)
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 
- Static Public Member Functions inherited from edm::one::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 

Private Member Functions

void algoComputeMPVandGain (const MonitorElement *Charge_Vs_Index)
 
virtual void checkAndRetrieveTopology (const edm::EventSetup &setup)
 
virtual void checkBookAPVColls (const edm::EventSetup &setup)
 
void dqmEndJob (DQMStore::IBooker &ibooker_, DQMStore::IGetter &igetter_) override
 
void gainQualityMonitor (DQMStore::IBooker &ibooker_, const MonitorElement *Charge_Vs_Index) const
 
std::unique_ptr< SiStripApvGaingetNewObject (const MonitorElement *Charge_Vs_Index)
 
void getPeakOfLandau (TH1 *InputHisto, double *FitResults, double LowRange=50, double HighRange=5400)
 
bool IsGoodLandauFit (double *FitResults)
 
bool produceTagFilter (const MonitorElement *Charge_Vs_Index)
 
int statCollectionFromMode (const char *tag) const
 

Private Attributes

std::unordered_map< unsigned int, std::shared_ptr< stAPVGain > > APVsColl
 
std::vector< std::shared_ptr< stAPVGain > > APVsCollOrdered
 
unsigned int BAD
 
const TrackerGeometrybareTkGeomPtr_
 
int CalibrationLevel
 
bool doChargeMonitorPerPlane
 
bool doStoreOnDB
 
std::vector< std::string > dqm_tag_
 
unsigned int GOOD
 
std::string m_calibrationMode
 
std::string m_DQMdir
 
std::string m_Record
 
unsigned int MASKED
 
double MinNrEntries
 
int NPixelDets
 
int NStripAPVs
 
double tagCondition_GoodFrac
 
double tagCondition_NClusters
 
edm::ESHandle< TrackerGeometrytkGeom_
 
const TrackerTopologytTopo_
 
std::vector< std::string > VChargeHisto
 

Additional Inherited Members

- Public Types inherited from edm::one::EDProducerBase
typedef EDProducerBase ModuleType
 
- Public Types inherited from edm::ProducerBase
using ModuleToResolverIndicies = std::unordered_multimap< std::string, std::tuple< edm::TypeID const *, const char *, edm::ProductResolverIndex >>
 
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
- Protected Attributes inherited from DQMEDHarvester
edm::EDPutTokenT< DQMTokenlumiToken_
 
edm::EDPutTokenT< DQMTokenrunToken_
 

Detailed Description

Description: Harvests output of SiStripGainsPCLWorker and creates histograms and Gains Payload

Definition at line 45 of file SiStripGainsPCLHarvester.h.

Constructor & Destructor Documentation

SiStripGainsPCLHarvester::SiStripGainsPCLHarvester ( const edm::ParameterSet ps)
explicit

Definition at line 37 of file SiStripGainsPCLHarvester.cc.

References CalibrationLevel, doChargeMonitorPerPlane, dqm_tag_, edm::ParameterSet::getUntrackedParameter(), m_calibrationMode, m_DQMdir, m_Record, MinNrEntries, AlCaHLTBitMon_QueryRunRegistry::string, tagCondition_GoodFrac, tagCondition_NClusters, and VChargeHisto.

37  :
38  doStoreOnDB(false),
39  GOOD(0),
40  BAD(0),
41  MASKED(0),
42  NStripAPVs(0),
43  NPixelDets(0),
44  bareTkGeomPtr_(nullptr),
45  tTopo_(nullptr)
46 {
47 
48  m_Record = ps.getUntrackedParameter<std::string> ("Record" , "SiStripApvGainRcd");
49  CalibrationLevel = ps.getUntrackedParameter<int> ("CalibrationLevel" , 0);
50  MinNrEntries = ps.getUntrackedParameter<double> ("minNrEntries" , 20);
51  m_DQMdir = ps.getUntrackedParameter<std::string> ("DQMdir" , "AlCaReco/SiStripGains");
52  m_calibrationMode = ps.getUntrackedParameter<std::string> ("calibrationMode" , "StdBunch");
53  tagCondition_NClusters = ps.getUntrackedParameter<double> ("NClustersForTagProd", 2E8);
54  tagCondition_GoodFrac = ps.getUntrackedParameter<double> ("GoodFracForTagProd" , 0.95);
55  doChargeMonitorPerPlane = ps.getUntrackedParameter<bool> ("doChargeMonitorPerPlane" , false);
56  VChargeHisto = ps.getUntrackedParameter<std::vector<std::string> > ("ChargeHisto");
57 
58  //Set the monitoring element tag and store
59  dqm_tag_.reserve(7);
60  dqm_tag_.clear();
61  dqm_tag_.push_back( "StdBunch" ); // statistic collection from Standard Collision Bunch @ 3.8 T
62  dqm_tag_.push_back( "StdBunch0T" ); // statistic collection from Standard Collision Bunch @ 0 T
63  dqm_tag_.push_back( "AagBunch" ); // statistic collection from First Collision After Abort Gap @ 3.8 T
64  dqm_tag_.push_back( "AagBunch0T" ); // statistic collection from First Collision After Abort Gap @ 0 T
65  dqm_tag_.push_back( "IsoMuon" ); // statistic collection from Isolated Muon @ 3.8 T
66  dqm_tag_.push_back( "IsoMuon0T" ); // statistic collection from Isolated Muon @ 0 T
67  dqm_tag_.push_back( "Harvest" ); // statistic collection: Harvest
68 
69 }
T getUntrackedParameter(std::string const &, T const &) const
const TrackerTopology * tTopo_
std::vector< std::string > dqm_tag_
std::vector< std::string > VChargeHisto
const TrackerGeometry * bareTkGeomPtr_

Member Function Documentation

void SiStripGainsPCLHarvester::algoComputeMPVandGain ( const MonitorElement Charge_Vs_Index)
private

Definition at line 338 of file SiStripGainsPCLHarvester.cc.

References sistrip::APV, APVsColl, BAD, CalibrationLevel, getPeakOfLandau(), GOOD, Exhume::I, mps_fire::i, IsGoodLandauFit(), m_calibrationMode, MASKED, and mps_setup::stdout.

Referenced by dqmEndJob().

338  {
339 
340  unsigned int I=0;
341  TH1F* Proj = nullptr;
342  double FitResults[6];
343  double MPVmean = 300;
344 
345  if ( Charge_Vs_Index==nullptr ) {
346  edm::LogError("SiStripGainsPCLHarvester") << "Harvesting: could not execute algoComputeMPVandGain method because "
347  << m_calibrationMode <<" statistics cannot be retrieved.\n"
348  << "Please check if input contains "
349  << m_calibrationMode <<" data." << std::endl;
350  return;
351  }
352 
353  TH2S *chvsidx = (Charge_Vs_Index)->getTH2S();
354 
355  printf("Progressing Bar :0%% 20%% 40%% 60%% 80%% 100%%\n");
356  printf("Fitting Charge Distribution :");
357  int TreeStep = APVsColl.size()/50;
358 
359  for(auto it = APVsColl.begin();it!=APVsColl.end();it++,I++){
360 
361  if(I%TreeStep==0){printf(".");fflush(stdout);}
362  std::shared_ptr<stAPVGain> APV = it->second;
363  if(APV->Bin<0) APV->Bin = chvsidx->GetXaxis()->FindBin(APV->Index);
364 
365  if(APV->isMasked){APV->Gain=APV->PreviousGain; MASKED++; continue;}
366 
367  Proj = (TH1F*)(chvsidx->ProjectionY("",chvsidx->GetXaxis()->FindBin(APV->Index),chvsidx->GetXaxis()->FindBin(APV->Index),"e"));
368  if(!Proj)continue;
369 
370  if(CalibrationLevel==0){
371  }else if(CalibrationLevel==1){
372  int SecondAPVId = APV->APVId;
373  if(SecondAPVId%2==0){ SecondAPVId = SecondAPVId+1; }else{ SecondAPVId = SecondAPVId-1; }
374  std::shared_ptr<stAPVGain> APV2 = APVsColl[(APV->DetId<<4) | SecondAPVId];
375  if(APV2->Bin<0) APV2->Bin = chvsidx->GetXaxis()->FindBin(APV2->Index);
376  TH1F* Proj2 = (TH1F*)(chvsidx->ProjectionY("",APV2->Bin,APV2->Bin,"e"));
377  if(Proj2){Proj->Add(Proj2,1);delete Proj2;}
378  }else if(CalibrationLevel==2){
379  for(unsigned int i=0;i<16;i++){ //loop up to 6APV for Strip and up to 16 for Pixels
380  auto tmpit = APVsColl.find((APV->DetId<<4) | i);
381  if(tmpit==APVsColl.end())continue;
382  std::shared_ptr<stAPVGain> APV2 = tmpit->second;
383  if(APV2->DetId != APV->DetId || APV2->APVId == APV->APVId)continue;
384  if(APV2->Bin<0) APV2->Bin = chvsidx->GetXaxis()->FindBin(APV2->Index);
385  TH1F* Proj2 = (TH1F*)(chvsidx->ProjectionY("",APV2->Bin,APV2->Bin,"e"));
386  if(Proj2){Proj->Add(Proj2,1);delete Proj2;}
387  }
388  } else {
389  CalibrationLevel = 0;
390  printf("Unknown Calibration Level, will assume %i\n",CalibrationLevel);
391  }
392 
393  getPeakOfLandau(Proj,FitResults);
394  APV->FitMPV = FitResults[0];
395  APV->FitMPVErr = FitResults[1];
396  APV->FitWidth = FitResults[2];
397  APV->FitWidthErr = FitResults[3];
398  APV->FitChi2 = FitResults[4];
399  APV->FitNorm = FitResults[5];
400  APV->NEntries = Proj->GetEntries();
401 
402  if(IsGoodLandauFit(FitResults)){
403  APV->Gain = APV->FitMPV / MPVmean;
404  if(APV->SubDet>2)GOOD++;
405  }else{
406  APV->Gain = APV->PreviousGain;
407  if(APV->SubDet>2)BAD++;
408  }
409  if(APV->Gain<=0) APV->Gain = 1;
410 
411  delete Proj;
412  }printf("\n");
413 }
void getPeakOfLandau(TH1 *InputHisto, double *FitResults, double LowRange=50, double HighRange=5400)
const std::complex< double > I
Definition: I.h:8
bool IsGoodLandauFit(double *FitResults)
std::unordered_map< unsigned int, std::shared_ptr< stAPVGain > > APVsColl
void SiStripGainsPCLHarvester::beginRun ( edm::Run const &  run,
edm::EventSetup const &  isetup 
)
override

Definition at line 74 of file SiStripGainsPCLHarvester.cc.

References a, sistrip::APV, APVsCollOrdered, checkAndRetrieveTopology(), checkBookAPVColls(), cmsRelvalreport::exit, edm::EventSetup::get(), SiStripGain::getApvGain(), SiStripGain::getNumberOfTags(), SiStripGain::getRange(), SiStripQuality::IsApvBad(), edm::ESHandleBase::isValid(), PixelSubdetector::PixelBarrel, PixelSubdetector::PixelEndcap, and mps_setup::stdout.

75 {
76  using namespace edm;
77 
78  this->checkBookAPVColls(iSetup); // check whether APV colls are booked and do so if not yet done
79  this->checkAndRetrieveTopology(iSetup);
80 
81  edm::ESHandle<SiStripGain> gainHandle;
82  iSetup.get<SiStripGainRcd>().get(gainHandle);
83  if(!gainHandle.isValid()){edm::LogError("SiStripGainPCLHarvester")<< "gainHandle is not valid\n"; exit(0);}
84 
85  edm::ESHandle<SiStripQuality> SiStripQuality_;
86  iSetup.get<SiStripQualityRcd>().get(SiStripQuality_);
87 
88  for(unsigned int a=0;a<APVsCollOrdered.size();a++){
89 
90  std::shared_ptr<stAPVGain> APV = APVsCollOrdered[a];
91 
92  if(APV->SubDet==PixelSubdetector::PixelBarrel || APV->SubDet==PixelSubdetector::PixelEndcap) continue;
93 
94  APV->isMasked = SiStripQuality_->IsApvBad(APV->DetId,APV->APVId);
95 
96  if(gainHandle->getNumberOfTags()!=2){edm::LogError("SiStripGainPCLHarvester")<< "NUMBER OF GAIN TAG IS EXPECTED TO BE 2\n";fflush(stdout);exit(0);};
97  float newPreviousGain = gainHandle->getApvGain(APV->APVId,gainHandle->getRange(APV->DetId, 1),1);
98  if(APV->PreviousGain!=1 and newPreviousGain!=APV->PreviousGain)edm::LogWarning("SiStripGainPCLHarvester")<< "WARNING: ParticleGain in the global tag changed\n";
99  APV->PreviousGain = newPreviousGain;
100 
101  float newPreviousGainTick = gainHandle->getApvGain(APV->APVId,gainHandle->getRange(APV->DetId, 0),0);
102  if(APV->PreviousGainTick!=1 and newPreviousGainTick!=APV->PreviousGainTick){
103  edm::LogWarning("SiStripGainPCLHarvester")<< "WARNING: TickMarkGain in the global tag changed\n"<< std::endl
104  <<" APV->SubDet: "<< APV->SubDet << " APV->APVId:" << APV->APVId << std::endl
105  <<" APV->PreviousGainTick: "<<APV->PreviousGainTick<<" newPreviousGainTick: "<<newPreviousGainTick<<std::endl;
106  }
107  APV->PreviousGainTick = newPreviousGainTick;
108  }
109 }
bool IsApvBad(const uint32_t &detid, const short &apvNb) const
size_t getNumberOfTags() const
Definition: SiStripGain.h:91
static float getApvGain(const uint16_t &apv, const SiStripApvGain::Range &range)
Definition: SiStripGain.h:73
virtual void checkAndRetrieveTopology(const edm::EventSetup &setup)
virtual void checkBookAPVColls(const edm::EventSetup &setup)
std::vector< std::shared_ptr< stAPVGain > > APVsCollOrdered
HLT enums.
double a
Definition: hdecay.h:121
bool isValid() const
Definition: ESHandle.h:47
const SiStripApvGain::Range getRange(uint32_t detID) const
Definition: SiStripGain.h:70
void SiStripGainsPCLHarvester::checkAndRetrieveTopology ( const edm::EventSetup setup)
privatevirtual

Definition at line 566 of file SiStripGainsPCLHarvester.cc.

References edm::EventSetup::get(), edm::ESHandle< T >::product(), and tTopo_.

Referenced by beginRun().

566  {
567  if( !tTopo_ ) {
569  setup.get<TrackerTopologyRcd>().get( TopoHandle );
570  tTopo_ = TopoHandle.product();
571  }
572 }
const TrackerTopology * tTopo_
T get() const
Definition: EventSetup.h:62
T const * product() const
Definition: ESHandle.h:86
void SiStripGainsPCLHarvester::checkBookAPVColls ( const edm::EventSetup setup)
privatevirtual

Definition at line 456 of file SiStripGainsPCLHarvester.cc.

References sistrip::APV, APVsColl, APVsCollOrdered, bareTkGeomPtr_, TrackerGeometry::dets(), edm::EventSetup::get(), mps_fire::i, PixelTopology::ncolumns(), NPixelDets, PixelTopology::nrows(), NStripAPVs, StripTopology::nstrips(), PixelSubdetector::PixelBarrel, PixelSubdetector::PixelEndcap, DetId::rawId(), ntupleEnum::SubDet, DetId::subdetId(), StripSubdetector::TEC, StripSubdetector::TIB, StripSubdetector::TID, tkGeom_, and StripSubdetector::TOB.

Referenced by beginRun().

456  {
457 
458  es.get<TrackerDigiGeometryRecord>().get( tkGeom_ );
459  const TrackerGeometry *newBareTkGeomPtr = &(*tkGeom_);
460  if (newBareTkGeomPtr == bareTkGeomPtr_) return; // already filled APVColls, nothing changed
461 
462  if (!bareTkGeomPtr_) { // pointer not yet set: called the first time => fill the APVColls
463  auto const & Det = newBareTkGeomPtr->dets();
464 
465  unsigned int Index=0;
466 
467  for(unsigned int i=0;i<Det.size();i++){
468 
469  DetId Detid = Det[i]->geographicalId();
470  int SubDet = Detid.subdetId();
471 
472  if( SubDet == StripSubdetector::TIB || SubDet == StripSubdetector::TID ||
473  SubDet == StripSubdetector::TOB || SubDet == StripSubdetector::TEC ){
474 
475  auto DetUnit = dynamic_cast<const StripGeomDetUnit*> (Det[i]);
476  if(!DetUnit)continue;
477 
478  const StripTopology& Topo = DetUnit->specificTopology();
479  unsigned int NAPV = Topo.nstrips()/128;
480 
481  for(unsigned int j=0;j<NAPV;j++){
482  auto APV = std::make_shared<stAPVGain>();
483  APV->Index = Index;
484  APV->Bin = -1;
485  APV->DetId = Detid.rawId();
486  APV->APVId = j;
487  APV->SubDet = SubDet;
488  APV->FitMPV = -1;
489  APV->FitMPVErr = -1;
490  APV->FitWidth = -1;
491  APV->FitWidthErr = -1;
492  APV->FitChi2 = -1;
493  APV->FitNorm = -1;
494  APV->Gain = -1;
495  APV->PreviousGain = 1;
496  APV->PreviousGainTick = 1;
497  APV->x = DetUnit->position().basicVector().x();
498  APV->y = DetUnit->position().basicVector().y();
499  APV->z = DetUnit->position().basicVector().z();
500  APV->Eta = DetUnit->position().basicVector().eta();
501  APV->Phi = DetUnit->position().basicVector().phi();
502  APV->R = DetUnit->position().basicVector().transverse();
503  APV->Thickness = DetUnit->surface().bounds().thickness();
504  APV->NEntries = 0;
505  APV->isMasked = false;
506 
507  APVsCollOrdered.push_back(APV);
508  APVsColl[(APV->DetId<<4) | APV->APVId] = APV;
509  Index++;
510  NStripAPVs++;
511  } // loop on APVs
512  } // if is Strips
513  } // loop on dets
514 
515  for(unsigned int i=0;i<Det.size();i++){ //Make two loop such that the Pixel information is added at the end --> make transition simpler
516  DetId Detid = Det[i]->geographicalId();
517  int SubDet = Detid.subdetId();
519  auto DetUnit = dynamic_cast<const PixelGeomDetUnit*> (Det[i]);
520  if(!DetUnit) continue;
521 
522  const PixelTopology& Topo = DetUnit->specificTopology();
523  unsigned int NROCRow = Topo.nrows()/(80.);
524  unsigned int NROCCol = Topo.ncolumns()/(52.);
525 
526  for(unsigned int j=0;j<NROCRow;j++){
527  for(unsigned int i=0;i<NROCCol;i++){
528  auto APV = std::make_shared<stAPVGain>();
529  APV->Index = Index;
530  APV->Bin = -1;
531  APV->DetId = Detid.rawId();
532  APV->APVId = (j<<3 | i);
533  APV->SubDet = SubDet;
534  APV->FitMPV = -1;
535  APV->FitMPVErr = -1;
536  APV->FitWidth = -1;
537  APV->FitWidthErr = -1;
538  APV->FitChi2 = -1;
539  APV->Gain = -1;
540  APV->PreviousGain = 1;
541  APV->PreviousGainTick = 1;
542  APV->x = DetUnit->position().basicVector().x();
543  APV->y = DetUnit->position().basicVector().y();
544  APV->z = DetUnit->position().basicVector().z();
545  APV->Eta = DetUnit->position().basicVector().eta();
546  APV->Phi = DetUnit->position().basicVector().phi();
547  APV->R = DetUnit->position().basicVector().transverse();
548  APV->Thickness = DetUnit->surface().bounds().thickness();
549  APV->isMasked = false; //SiPixelQuality_->IsModuleBad(Detid.rawId());
550  APV->NEntries = 0;
551 
552  APVsCollOrdered.push_back(APV);
553  APVsColl[(APV->DetId<<4) | APV->APVId] = APV;
554  Index++;
555  NPixelDets++;
556 
557  } // loop on ROC cols
558  } // loop on ROC rows
559  } // if Pixel
560  } // loop on Dets
561  } //if (!bareTkGeomPtr_) ...
562  bareTkGeomPtr_ = newBareTkGeomPtr;
563 }
virtual int nrows() const =0
edm::ESHandle< TrackerGeometry > tkGeom_
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:47
const DetContainer & dets() const override
Returm a vector of all GeomDet (including all GeomDetUnits)
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:41
Definition: DetId.h:18
virtual int nstrips() const =0
const TrackerGeometry * bareTkGeomPtr_
std::vector< std::shared_ptr< stAPVGain > > APVsCollOrdered
virtual int ncolumns() const =0
std::unordered_map< unsigned int, std::shared_ptr< stAPVGain > > APVsColl
void SiStripGainsPCLHarvester::dqmEndJob ( DQMStore::IBooker ibooker_,
DQMStore::IGetter igetter_ 
)
overrideprivatevirtual

Implements DQMEDHarvester.

Definition at line 112 of file SiStripGainsPCLHarvester.cc.

References algoComputeMPVandGain(), cond::service::PoolDBOutputService::currentTime(), doStoreOnDB, dqm_tag_, spr::find(), gainQualityMonitor(), DQMStore::IGetter::get(), getNewObject(), edm::Service< T >::isAvailable(), m_calibrationMode, m_DQMdir, m_Record, AlCaHLTBitMon_QueryRunRegistry::string, and cond::service::PoolDBOutputService::writeOne().

112  {
113 
114  edm::LogInfo("SiStripGainsPCLHarvester") << "Starting harvesting statistics" << std::endl;
115 
116  std::string DQM_dir = m_DQMdir;
117 
118  std::string stag = *(std::find(dqm_tag_.begin(), dqm_tag_.end(),m_calibrationMode));
119  if(!stag.empty() && stag[0]!='_') stag.insert(0,1,'_');
120 
121  std::string cvi = DQM_dir + std::string("/Charge_Vs_Index") + stag;
122 
123  MonitorElement* Charge_Vs_Index = igetter_.get(cvi);
124 
125  if (Charge_Vs_Index==nullptr) {
126  edm::LogError("SiStripGainsPCLHarvester") << "Harvesting: could not retrieve " << cvi.c_str()
127  << ", statistics will not be summed!" << std::endl;
128  } else {
129  edm::LogInfo("SiStripGainsPCLHarvester") << "Harvesting "
130  << (Charge_Vs_Index)->getTH2S()->GetEntries() << " more clusters" << std::endl;
131  }
132 
133  algoComputeMPVandGain(Charge_Vs_Index);
134  std::unique_ptr<SiStripApvGain> theAPVGains = this->getNewObject(Charge_Vs_Index);
135 
136  // write out the APVGains record
138 
139  if( doStoreOnDB ){
140  if( poolDbService.isAvailable() )
141  poolDbService->writeOne(theAPVGains.get(), poolDbService->currentTime(),m_Record);
142  else
143  throw std::runtime_error("PoolDBService required.");
144  } else {
145  edm::LogInfo("SiStripGainsPCLHarvester") << "Will not produce payload!" << std::endl;
146  }
147 
148 
149  //Collect the statistics for monitoring and validation
150  gainQualityMonitor(ibooker_,Charge_Vs_Index);
151 
152 }
std::unique_ptr< SiStripApvGain > getNewObject(const MonitorElement *Charge_Vs_Index)
std::vector< std::string > dqm_tag_
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:20
void algoComputeMPVandGain(const MonitorElement *Charge_Vs_Index)
bool isAvailable() const
Definition: Service.h:46
void writeOne(T *payload, Time_t time, const std::string &recordName, bool withlogging=false)
MonitorElement * get(std::string const &path)
Definition: DQMStore.cc:303
void gainQualityMonitor(DQMStore::IBooker &ibooker_, const MonitorElement *Charge_Vs_Index) const
void SiStripGainsPCLHarvester::endRun ( edm::Run const &  run,
edm::EventSetup const &  isetup 
)
override

Definition at line 661 of file SiStripGainsPCLHarvester.cc.

661  {
662 }
void SiStripGainsPCLHarvester::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 652 of file SiStripGainsPCLHarvester.cc.

References edm::ConfigurationDescriptions::addDefault(), and edm::ParameterSetDescription::setUnknown().

652  {
653 
655  desc.setUnknown();
656  descriptions.addDefault(desc);
657 
658 }
void addDefault(ParameterSetDescription const &psetDescription)
void SiStripGainsPCLHarvester::gainQualityMonitor ( DQMStore::IBooker ibooker_,
const MonitorElement Charge_Vs_Index 
) const
private

Definition at line 156 of file SiStripGainsPCLHarvester.cc.

References a, sistrip::APV, APVsCollOrdered, stringResolutionProvider_cfi::bin, DQMStore::IBooker::book1DD(), DQMStore::IBooker::book2DD(), DetId::DetId(), doChargeMonitorPerPlane, MillePedeFileConverter_cfg::e, reco::tau::disc::Eta(), APVGain::FetchMonitor(), MonitorElement::Fill(), plotBeamSpotDB::first, g4SimHits_cfi::Gain, h, mps_fire::i, APVGain::monHnames(), colinearityKinematic::Phi, dttmaxenums::R, edm::second(), DQMStore::IBooker::setCurrentFolder(), ntupleEnum::SubDet, APVGain::subdetectorId(), APVGain::subdetectorPlane(), APVGain::subdetectorSide(), tTopo_, VChargeHisto, and z.

Referenced by dqmEndJob().

156  {
157  ibooker_.setCurrentFolder("AlCaReco/SiStripGainsHarvesting/");
158 
159 
160  std::vector<APVGain::APVmon> new_charge_histos;
161  std::vector<std::pair<std::string,std::string>> cnames = APVGain::monHnames(VChargeHisto,doChargeMonitorPerPlane,"newG2");
162  for (unsigned int i=0;i<cnames.size();i++){
163  MonitorElement* monitor = ibooker_.book1DD( (cnames[i]).first, (cnames[i]).second.c_str(), 100 , 0. , 1000. );
164  int id = APVGain::subdetectorId((cnames[i]).first);
165  int side = APVGain::subdetectorSide((cnames[i]).first);
166  int plane = APVGain::subdetectorPlane((cnames[i]).first);
167  new_charge_histos.push_back( APVGain::APVmon(id,side,plane,monitor) );
168  }
169 
170  int MPVbin = 300;
171  float MPVmin = 0.;
172  float MPVmax = 600.;
173 
174  MonitorElement* MPV_Vs_EtaTIB = ibooker_.book2DD("MPVvsEtaTIB" ,"MPV vs Eta TIB" ,50,-3.0,3.0,MPVbin,MPVmin,MPVmax);
175  MonitorElement* MPV_Vs_EtaTID = ibooker_.book2DD("MPVvsEtaTID" ,"MPV vs Eta TID" ,50,-3.0,3.0,MPVbin,MPVmin,MPVmax);
176  MonitorElement* MPV_Vs_EtaTOB = ibooker_.book2DD("MPVvsEtaTOB" ,"MPV vs Eta TOB" ,50,-3.0,3.0,MPVbin,MPVmin,MPVmax);
177  MonitorElement* MPV_Vs_EtaTEC = ibooker_.book2DD("MPVvsEtaTEC" ,"MPV vs Eta TEC" ,50,-3.0,3.0,MPVbin,MPVmin,MPVmax);
178  MonitorElement* MPV_Vs_EtaTECthin = ibooker_.book2DD("MPVvsEtaTEC1","MPV vs Eta TEC-thin" ,50,-3.0,3.0,MPVbin,MPVmin,MPVmax);
179  MonitorElement* MPV_Vs_EtaTECthick = ibooker_.book2DD("MPVvsEtaTEC2","MPV vs Eta TEC-thick",50,-3.0,3.0,MPVbin,MPVmin,MPVmax);
180 
181  MonitorElement* MPV_Vs_PhiTIB = ibooker_.book2DD("MPVvsPhiTIB" ,"MPV vs Phi TIB" ,50,-3.4,3.4,MPVbin,MPVmin,MPVmax);
182  MonitorElement* MPV_Vs_PhiTID = ibooker_.book2DD("MPVvsPhiTID" ,"MPV vs Phi TID" ,50,-3.4,3.4,MPVbin,MPVmin,MPVmax);
183  MonitorElement* MPV_Vs_PhiTOB = ibooker_.book2DD("MPVvsPhiTOB" ,"MPV vs Phi TOB" ,50,-3.4,3.4,MPVbin,MPVmin,MPVmax);
184  MonitorElement* MPV_Vs_PhiTEC = ibooker_.book2DD("MPVvsPhiTEC" ,"MPV vs Phi TEC" ,50,-3.4,3.4,MPVbin,MPVmin,MPVmax);
185  MonitorElement* MPV_Vs_PhiTECthin = ibooker_.book2DD("MPVvsPhiTEC1","MPV vs Phi TEC-thin ",50,-3.4,3.4,MPVbin,MPVmin,MPVmax);
186  MonitorElement* MPV_Vs_PhiTECthick = ibooker_.book2DD("MPVvsPhiTEC2","MPV vs Phi TEC-thick",50,-3.4,3.4,MPVbin,MPVmin,MPVmax);
187 
188  MonitorElement* NoMPVfit = ibooker_.book2DD("NoMPVfit" ,"Modules with bad Landau Fit",350, -350, 350, 240, 0, 120);
189  MonitorElement* NoMPVmasked = ibooker_.book2DD("NoMPVmasked" ,"Masked Modules" ,350, -350, 350, 240, 0, 120);
190 
191  MonitorElement* Gains = ibooker_.book1DD("Gains" ,"Gains" , 300, 0, 2);
192  MonitorElement* MPVs = ibooker_.book1DD("MPVs" ,"MPVs" , MPVbin,MPVmin,MPVmax);
193  MonitorElement* MPVs320 = ibooker_.book1DD("MPV_320" ,"MPV 320 thickness", MPVbin,MPVmin,MPVmax);
194  MonitorElement* MPVs500 = ibooker_.book1DD("MPV_500" ,"MPV 500 thickness", MPVbin,MPVmin,MPVmax);
195  MonitorElement* MPVsTIB = ibooker_.book1DD("MPV_TIB" ,"MPV TIB" , MPVbin,MPVmin,MPVmax);
196  MonitorElement* MPVsTID = ibooker_.book1DD("MPV_TID" ,"MPV TID" , MPVbin,MPVmin,MPVmax);
197  MonitorElement* MPVsTIDP = ibooker_.book1DD("MPV_TIDP" ,"MPV TIDP" , MPVbin,MPVmin,MPVmax);
198  MonitorElement* MPVsTIDM = ibooker_.book1DD("MPV_TIDM" ,"MPV TIDM" , MPVbin,MPVmin,MPVmax);
199  MonitorElement* MPVsTOB = ibooker_.book1DD("MPV_TOB" ,"MPV TOB" , MPVbin,MPVmin,MPVmax);
200  MonitorElement* MPVsTEC = ibooker_.book1DD("MPV_TEC" ,"MPV TEC" , MPVbin,MPVmin,MPVmax);
201  MonitorElement* MPVsTECP = ibooker_.book1DD("MPV_TECP" ,"MPV TECP" , MPVbin,MPVmin,MPVmax);
202  MonitorElement* MPVsTECM = ibooker_.book1DD("MPV_TECM" ,"MPV TECM" , MPVbin,MPVmin,MPVmax);
203  MonitorElement* MPVsTECthin = ibooker_.book1DD("MPV_TEC1" ,"MPV TEC thin" , MPVbin,MPVmin,MPVmax);
204  MonitorElement* MPVsTECthick = ibooker_.book1DD("MPV_TEC2" ,"MPV TEC thick" , MPVbin,MPVmin,MPVmax);
205  MonitorElement* MPVsTECP1 = ibooker_.book1DD("MPV_TECP1" ,"MPV TECP thin " , MPVbin,MPVmin,MPVmax);
206  MonitorElement* MPVsTECP2 = ibooker_.book1DD("MPV_TECP2" ,"MPV TECP thick" , MPVbin,MPVmin,MPVmax);
207  MonitorElement* MPVsTECM1 = ibooker_.book1DD("MPV_TECM1" ,"MPV TECM thin" , MPVbin,MPVmin,MPVmax);
208  MonitorElement* MPVsTECM2 = ibooker_.book1DD("MPV_TECM2" ,"MPV TECM thick" , MPVbin,MPVmin,MPVmax);
209 
210  MonitorElement* MPVError = ibooker_.book1DD("MPVError" ,"MPV Error" , 150, 0, 150);
211  MonitorElement* MPVErrorVsMPV = ibooker_.book2DD("MPVErrorVsMPV" ,"MPV Error vs MPV" , 300, 0, 600, 150, 0, 150);
212  MonitorElement* MPVErrorVsEta = ibooker_.book2DD("MPVErrorVsEta" ,"MPV Error vs Eta" , 50, -3.0, 3.0, 150, 0, 150);
213  MonitorElement* MPVErrorVsPhi = ibooker_.book2DD("MPVErrorVsPhi" ,"MPV Error vs Phi" , 50, -3.4, 3.4, 150, 0, 150);
214  MonitorElement* MPVErrorVsN = ibooker_.book2DD("MPVErrorVsN" ,"MPV Error vs N" , 500, 0, 1000, 150, 0, 150);
215 
216  MonitorElement* DiffWRTPrevGainTIB = ibooker_.book1DD("DiffWRTPrevGainTIB" ,"Diff w.r.t. PrevGain TIB" , 250, 0,2);
217  MonitorElement* DiffWRTPrevGainTID = ibooker_.book1DD("DiffWRTPrevGainTID" ,"Diff w.r.t. PrevGain TID" , 250, 0,2);
218  MonitorElement* DiffWRTPrevGainTOB = ibooker_.book1DD("DiffWRTPrevGainTOB" ,"Diff w.r.t. PrevGain TOB" , 250, 0,2);
219  MonitorElement* DiffWRTPrevGainTEC = ibooker_.book1DD("DiffWRTPrevGainTEC" ,"Diff w.r.t. PrevGain TEC" , 250, 0,2);
220 
221  MonitorElement* GainVsPrevGainTIB = ibooker_.book2DD("GainVsPrevGainTIB" ,"Gain vs PrevGain TIB" , 100, 0,2, 100, 0,2);
222  MonitorElement* GainVsPrevGainTID = ibooker_.book2DD("GainVsPrevGainTID" ,"Gain vs PrevGain TID" , 100, 0,2, 100, 0,2);
223  MonitorElement* GainVsPrevGainTOB = ibooker_.book2DD("GainVsPrevGainTOB" ,"Gain vs PrevGain TOB" , 100, 0,2, 100, 0,2);
224  MonitorElement* GainVsPrevGainTEC = ibooker_.book2DD("GainVsPrevGainTEC" ,"Gain vs PrevGain TEC" , 100, 0,2, 100, 0,2);
225 
226 
227  for(unsigned int a=0;a<APVsCollOrdered.size();a++){
228 
229  std::shared_ptr<stAPVGain> APV = APVsCollOrdered[a];
230  if(APV==nullptr)continue;
231 
232  unsigned int Index = APV->Index;
233  unsigned int SubDet = APV->SubDet;
234  unsigned int DetId = APV->DetId;
235  float z = APV->z;
236  float Eta = APV->Eta;
237  float R = APV->R;
238  float Phi = APV->Phi;
239  float Thickness = APV->Thickness;
240  double FitMPV = APV->FitMPV;
241  double FitMPVErr = APV->FitMPVErr;
242  double Gain = APV->Gain;
243  double NEntries = APV->NEntries;
244  double PreviousGain = APV->PreviousGain;
245 
246  if (SubDet<3) continue; // avoid to loop over Pixel det id
247 
248  if (Gain!=1.) {
249  std::vector<MonitorElement*> charge_histos = APVGain::FetchMonitor(new_charge_histos, DetId, tTopo_);
250  TH2S *chvsidx = (Charge_Vs_Index)->getTH2S();
251  int bin = chvsidx->GetXaxis()->FindBin(Index);
252  TH1D* Proj = chvsidx->ProjectionY("proj",bin,bin);
253  for (int binId=0; binId<Proj->GetXaxis()->GetNbins();binId++) {
254  double new_charge = Proj->GetXaxis()->GetBinCenter(binId) / Gain;
255  if (Proj->GetBinContent(binId)!=0.) {
256  for (unsigned int h=0;h<charge_histos.size();h++) {
257  TH1D* chisto = (charge_histos[h])->getTH1D();
258  for (int e=0;e<Proj->GetBinContent(binId);e++) chisto->Fill(new_charge);
259  }
260  }
261  }
262  }
263 
264 
265  if (FitMPV<=0.) { // No fit of MPV
266  if (APV->isMasked) NoMPVmasked->Fill(z,R);
267  else NoMPVfit->Fill(z,R);
268 
269  } else { // Fit of MPV
270  if(FitMPV>0.) Gains->Fill(Gain);
271 
272  MPVs->Fill(FitMPV);
273  if(Thickness<0.04) MPVs320->Fill(FitMPV);
274  if(Thickness>0.04) MPVs500->Fill(FitMPV);
275 
276  MPVError->Fill(FitMPVErr);
277  MPVErrorVsMPV->Fill(FitMPV,FitMPVErr);
278  MPVErrorVsEta->Fill(Eta,FitMPVErr);
279  MPVErrorVsPhi->Fill(Phi,FitMPVErr);
280  MPVErrorVsN->Fill(NEntries,FitMPVErr);
281 
282  if(SubDet==3) {
283  MPV_Vs_EtaTIB->Fill(Eta,FitMPV);
284  MPV_Vs_PhiTIB->Fill(Phi,FitMPV);
285  MPVsTIB->Fill(FitMPV);
286 
287  } else if(SubDet==4) {
288  MPV_Vs_EtaTID->Fill(Eta,FitMPV);
289  MPV_Vs_PhiTID->Fill(Phi,FitMPV);
290  MPVsTID->Fill(FitMPV);
291  if(Eta<0.) MPVsTIDM->Fill(FitMPV);
292  if(Eta>0.) MPVsTIDP->Fill(FitMPV);
293 
294  } else if (SubDet==5) {
295  MPV_Vs_EtaTOB->Fill(Eta,FitMPV);
296  MPV_Vs_PhiTOB->Fill(Phi,FitMPV);
297  MPVsTOB->Fill(FitMPV);
298 
299  } else if (SubDet==6) {
300  MPV_Vs_EtaTEC->Fill(Eta,FitMPV);
301  MPV_Vs_PhiTEC->Fill(Phi,FitMPV);
302  MPVsTEC->Fill(FitMPV);
303  if(Eta<0.) MPVsTECM->Fill(FitMPV);
304  if(Eta>0.) MPVsTECP->Fill(FitMPV);
305  if(Thickness<0.04) {
306  MPV_Vs_EtaTECthin->Fill(Eta,FitMPV);
307  MPV_Vs_PhiTECthin->Fill(Phi,FitMPV);
308  MPVsTECthin->Fill(FitMPV);
309  if(Eta>0.) MPVsTECP1->Fill(FitMPV);
310  if(Eta<0.) MPVsTECM1->Fill(FitMPV);
311  }
312  if(Thickness>0.04) {
313  MPV_Vs_EtaTECthick->Fill(Eta,FitMPV);
314  MPV_Vs_PhiTECthick->Fill(Phi,FitMPV);
315  MPVsTECthick->Fill(FitMPV);
316  if(Eta>0.) MPVsTECP2->Fill(FitMPV);
317  if(Eta<0.) MPVsTECM2->Fill(FitMPV);
318  }
319  }
320  }
321 
322  if(SubDet==3 && PreviousGain!=0. ) DiffWRTPrevGainTIB->Fill(Gain/PreviousGain);
323  else if(SubDet==4 && PreviousGain!=0. ) DiffWRTPrevGainTID->Fill(Gain/PreviousGain);
324  else if(SubDet==5 && PreviousGain!=0. ) DiffWRTPrevGainTOB->Fill(Gain/PreviousGain);
325  else if(SubDet==6 && PreviousGain!=0. ) DiffWRTPrevGainTEC->Fill(Gain/PreviousGain);
326 
327  if(SubDet==3 ) GainVsPrevGainTIB->Fill(PreviousGain,Gain);
328  else if(SubDet==4 ) GainVsPrevGainTID->Fill(PreviousGain,Gain);
329  else if(SubDet==5 ) GainVsPrevGainTOB->Fill(PreviousGain,Gain);
330  else if(SubDet==6 ) GainVsPrevGainTEC->Fill(PreviousGain,Gain);
331 
332  }
333 }
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
const TrackerTopology * tTopo_
int subdetectorPlane(uint32_t, const TrackerTopology *)
void Fill(long long x)
U second(std::pair< T, U > const &p)
std::vector< MonitorElement * > FetchMonitor(std::vector< APVmon >, uint32_t, const TrackerTopology *topo=0)
void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:268
std::vector< std::string > VChargeHisto
bin
set the eta bin as selection string.
Definition: DetId.h:18
int subdetectorSide(uint32_t, const TrackerTopology *)
std::vector< std::shared_ptr< stAPVGain > > APVsCollOrdered
double a
Definition: hdecay.h:121
MonitorElement * book2DD(Args &&...args)
Definition: DQMStore.h:111
std::vector< std::pair< std::string, std::string > > monHnames(std::vector< std::string >, bool, const char *tag)
MonitorElement * book1DD(Args &&...args)
Definition: DQMStore.h:108
int subdetectorId(uint32_t)
constexpr DetId()
Create an empty or null id (also for persistence)
Definition: DetId.h:30
std::unique_ptr< SiStripApvGain > SiStripGainsPCLHarvester::getNewObject ( const MonitorElement Charge_Vs_Index)
private

Definition at line 607 of file SiStripGainsPCLHarvester.cc.

References a, sistrip::APV, APVsCollOrdered, doStoreOnDB, LogDebug, GetRecoTauVFromDQM_MC_cff::obj, and produceTagFilter().

Referenced by dqmEndJob().

608 {
609  std::unique_ptr<SiStripApvGain> obj = std::unique_ptr<SiStripApvGain>(new SiStripApvGain());
610 
611  if(!produceTagFilter(Charge_Vs_Index)){
612  edm::LogWarning("SiStripGainsPCLHarvester")<< "getNewObject -> will not produce a paylaod because produceTagFilter returned false " << std::endl;
613  return obj;
614  } else {
615  doStoreOnDB=true;
616  }
617 
618  std::vector<float> theSiStripVector;
619  unsigned int PreviousDetId = 0;
620  for(unsigned int a=0;a<APVsCollOrdered.size();a++){
621  std::shared_ptr<stAPVGain> APV = APVsCollOrdered[a];
622  if(APV==nullptr){ printf("Bug\n"); continue; }
623  if(APV->SubDet<=2)continue;
624  if(APV->DetId != PreviousDetId){
625  if(!theSiStripVector.empty()){
626  SiStripApvGain::Range range(theSiStripVector.begin(),theSiStripVector.end());
627  if ( !obj->put(PreviousDetId,range) ) printf("Bug to put detId = %i\n",PreviousDetId);
628  }
629  theSiStripVector.clear();
630  PreviousDetId = APV->DetId;
631  }
632  theSiStripVector.push_back(APV->Gain);
633 
634  LogDebug("SiStripGainsPCLHarvester")<<" DetId: "<<APV->DetId
635  <<" APV: "<<APV->APVId
636  <<" Gain: "<<APV->Gain
637  <<std::endl;
638 
639  }
640  if(!theSiStripVector.empty()){
641  SiStripApvGain::Range range(theSiStripVector.begin(),theSiStripVector.end());
642  if ( !obj->put(PreviousDetId,range) ) printf("Bug to put detId = %i\n",PreviousDetId);
643  }
644 
645  return obj;
646 }
#define LogDebug(id)
bool produceTagFilter(const MonitorElement *Charge_Vs_Index)
std::pair< ContainerIterator, ContainerIterator > Range
std::vector< std::shared_ptr< stAPVGain > > APVsCollOrdered
double a
Definition: hdecay.h:121
void SiStripGainsPCLHarvester::getPeakOfLandau ( TH1 *  InputHisto,
double *  FitResults,
double  LowRange = 50,
double  HighRange = 5400 
)
private

Definition at line 417 of file SiStripGainsPCLHarvester.cc.

References MinNrEntries.

Referenced by algoComputeMPVandGain().

418 {
419  FitResults[0] = -0.5; //MPV
420  FitResults[1] = 0; //MPV error
421  FitResults[2] = -0.5; //Width
422  FitResults[3] = 0; //Width error
423  FitResults[4] = -0.5; //Fit Chi2/NDF
424  FitResults[5] = 0; //Normalization
425 
426  if( InputHisto->GetEntries() < MinNrEntries)return;
427 
428  // perform fit with standard landau
429  TF1 MyLandau("MyLandau","landau",LowRange, HighRange);
430  MyLandau.SetParameter(1,300);
431  InputHisto->Fit(&MyLandau,"0QR WW");
432 
433  // MPV is parameter 1 (0=constant, 1=MPV, 2=Sigma)
434  FitResults[0] = MyLandau.GetParameter(1); //MPV
435  FitResults[1] = MyLandau.GetParError(1); //MPV error
436  FitResults[2] = MyLandau.GetParameter(2); //Width
437  FitResults[3] = MyLandau.GetParError(2); //Width error
438  FitResults[4] = MyLandau.GetChisquare() / MyLandau.GetNDF(); //Fit Chi2/NDF
439  FitResults[5] = MyLandau.GetParameter(0);
440 
441 }
bool SiStripGainsPCLHarvester::IsGoodLandauFit ( double *  FitResults)
private

Definition at line 445 of file SiStripGainsPCLHarvester.cc.

Referenced by algoComputeMPVandGain().

445  {
446  if(FitResults[0] <= 0 )return false;
447  // if(FitResults[1] > MaxMPVError )return false;
448  // if(FitResults[4] > MaxChi2OverNDF)return false;
449  return true;
450 }
bool SiStripGainsPCLHarvester::produceTagFilter ( const MonitorElement Charge_Vs_Index)
private

Definition at line 575 of file SiStripGainsPCLHarvester.cc.

References BAD, GOOD, funct::integral(), m_calibrationMode, NStripAPVs, tagCondition_GoodFrac, and tagCondition_NClusters.

Referenced by getNewObject().

575  {
576 
577  // The goal of this function is to check wether or not there is enough statistics
578  // to produce a meaningful tag for the DB
579 
580  if( Charge_Vs_Index==nullptr ) {
581  edm::LogError("SiStripGainsPCLHarvester") << "produceTagFilter -> Return false: could not retrieve the "
582  << m_calibrationMode <<" statistics.\n"
583  << "Please check if input contains "
584  << m_calibrationMode << " data." << std::endl;
585  return false;
586  }
587 
588 
589  float integral = (Charge_Vs_Index)->getTH2S()->Integral();
590  if( (Charge_Vs_Index)->getTH2S()->Integral(0,NStripAPVs+1, 0, 99999 ) < tagCondition_NClusters) {
591  edm::LogWarning("SiStripGainsPCLHarvester")
592  << "calibrationMode -> " << m_calibrationMode << "\n"
593  << "produceTagFilter -> Return false: Statistics is too low : " << integral << std::endl;
594  return false;
595  }
596  if((1.0 * GOOD) / (GOOD+BAD) < tagCondition_GoodFrac) {
597  edm::LogWarning("SiStripGainsPCLHarvester")
598  << "calibrationMode -> " << m_calibrationMode << "\n"
599  << "produceTagFilter -> Return false: ratio of GOOD/TOTAL is too low: " << (1.0 * GOOD) / (GOOD+BAD) << std::endl;
600  return false;
601  }
602  return true;
603 }
Integral< F, X >::type integral(const F &f)
Definition: Integral.h:69
int SiStripGainsPCLHarvester::statCollectionFromMode ( const char *  tag) const
private

Member Data Documentation

std::unordered_map<unsigned int, std::shared_ptr<stAPVGain> > SiStripGainsPCLHarvester::APVsColl
private

Definition at line 97 of file SiStripGainsPCLHarvester.h.

Referenced by algoComputeMPVandGain(), and checkBookAPVColls().

std::vector<std::shared_ptr<stAPVGain> > SiStripGainsPCLHarvester::APVsCollOrdered
private
unsigned int SiStripGainsPCLHarvester::BAD
private

Definition at line 72 of file SiStripGainsPCLHarvester.h.

Referenced by algoComputeMPVandGain(), and produceTagFilter().

const TrackerGeometry* SiStripGainsPCLHarvester::bareTkGeomPtr_
private

Definition at line 93 of file SiStripGainsPCLHarvester.h.

Referenced by checkBookAPVColls().

int SiStripGainsPCLHarvester::CalibrationLevel
private

Definition at line 90 of file SiStripGainsPCLHarvester.h.

Referenced by algoComputeMPVandGain(), and SiStripGainsPCLHarvester().

bool SiStripGainsPCLHarvester::doChargeMonitorPerPlane
private

Charge monitor per detector plane

Definition at line 70 of file SiStripGainsPCLHarvester.h.

Referenced by gainQualityMonitor(), and SiStripGainsPCLHarvester().

bool SiStripGainsPCLHarvester::doStoreOnDB
private

Definition at line 69 of file SiStripGainsPCLHarvester.h.

Referenced by dqmEndJob(), and getNewObject().

std::vector<std::string> SiStripGainsPCLHarvester::dqm_tag_
private

Definition at line 88 of file SiStripGainsPCLHarvester.h.

Referenced by dqmEndJob(), and SiStripGainsPCLHarvester().

unsigned int SiStripGainsPCLHarvester::GOOD
private

Definition at line 71 of file SiStripGainsPCLHarvester.h.

Referenced by algoComputeMPVandGain(), and produceTagFilter().

std::string SiStripGainsPCLHarvester::m_calibrationMode
private

Type of statistics for the calibration

Definition at line 85 of file SiStripGainsPCLHarvester.h.

Referenced by algoComputeMPVandGain(), dqmEndJob(), produceTagFilter(), and SiStripGainsPCLHarvester().

std::string SiStripGainsPCLHarvester::m_DQMdir
private

DQM folder hosting the charge statistics and the monitor plots

Definition at line 84 of file SiStripGainsPCLHarvester.h.

Referenced by dqmEndJob(), and SiStripGainsPCLHarvester().

std::string SiStripGainsPCLHarvester::m_Record
private

Definition at line 82 of file SiStripGainsPCLHarvester.h.

Referenced by dqmEndJob(), and SiStripGainsPCLHarvester().

unsigned int SiStripGainsPCLHarvester::MASKED
private

Definition at line 73 of file SiStripGainsPCLHarvester.h.

Referenced by algoComputeMPVandGain().

double SiStripGainsPCLHarvester::MinNrEntries
private

Definition at line 80 of file SiStripGainsPCLHarvester.h.

Referenced by getPeakOfLandau(), and SiStripGainsPCLHarvester().

int SiStripGainsPCLHarvester::NPixelDets
private

Definition at line 79 of file SiStripGainsPCLHarvester.h.

Referenced by checkBookAPVColls().

int SiStripGainsPCLHarvester::NStripAPVs
private

Definition at line 78 of file SiStripGainsPCLHarvester.h.

Referenced by checkBookAPVColls(), and produceTagFilter().

double SiStripGainsPCLHarvester::tagCondition_GoodFrac
private

Definition at line 76 of file SiStripGainsPCLHarvester.h.

Referenced by produceTagFilter(), and SiStripGainsPCLHarvester().

double SiStripGainsPCLHarvester::tagCondition_NClusters
private

Definition at line 75 of file SiStripGainsPCLHarvester.h.

Referenced by produceTagFilter(), and SiStripGainsPCLHarvester().

edm::ESHandle<TrackerGeometry> SiStripGainsPCLHarvester::tkGeom_
private

Definition at line 92 of file SiStripGainsPCLHarvester.h.

Referenced by checkBookAPVColls().

const TrackerTopology* SiStripGainsPCLHarvester::tTopo_
private

Definition at line 94 of file SiStripGainsPCLHarvester.h.

Referenced by checkAndRetrieveTopology(), and gainQualityMonitor().

std::vector<std::string> SiStripGainsPCLHarvester::VChargeHisto
private

Charge monitor plots to be output

Definition at line 86 of file SiStripGainsPCLHarvester.h.

Referenced by gainQualityMonitor(), and SiStripGainsPCLHarvester().