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
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
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)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
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 339 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().

339  {
340 
341  unsigned int I=0;
342  TH1F* Proj = nullptr;
343  double FitResults[6];
344  double MPVmean = 300;
345 
346  if ( Charge_Vs_Index==nullptr ) {
347  edm::LogError("SiStripGainsPCLHarvester") << "Harvesting: could not execute algoComputeMPVandGain method because "
348  << m_calibrationMode <<" statistics cannot be retrieved.\n"
349  << "Please check if input contains "
350  << m_calibrationMode <<" data." << std::endl;
351  return;
352  }
353 
354  TH2S *chvsidx = (Charge_Vs_Index)->getTH2S();
355 
356  printf("Progressing Bar :0%% 20%% 40%% 60%% 80%% 100%%\n");
357  printf("Fitting Charge Distribution :");
358  int TreeStep = APVsColl.size()/50;
359 
360  for(auto it = APVsColl.begin();it!=APVsColl.end();it++,I++){
361 
362  if(I%TreeStep==0){printf(".");fflush(stdout);}
363  std::shared_ptr<stAPVGain> APV = it->second;
364  if(APV->Bin<0) APV->Bin = chvsidx->GetXaxis()->FindBin(APV->Index);
365 
366  if(APV->isMasked){APV->Gain=APV->PreviousGain; MASKED++; continue;}
367 
368  Proj = (TH1F*)(chvsidx->ProjectionY("",chvsidx->GetXaxis()->FindBin(APV->Index),chvsidx->GetXaxis()->FindBin(APV->Index),"e"));
369  if(!Proj)continue;
370 
371  if(CalibrationLevel==0){
372  }else if(CalibrationLevel==1){
373  int SecondAPVId = APV->APVId;
374  if(SecondAPVId%2==0){ SecondAPVId = SecondAPVId+1; }else{ SecondAPVId = SecondAPVId-1; }
375  std::shared_ptr<stAPVGain> APV2 = APVsColl[(APV->DetId<<4) | SecondAPVId];
376  if(APV2->Bin<0) APV2->Bin = chvsidx->GetXaxis()->FindBin(APV2->Index);
377  TH1F* Proj2 = (TH1F*)(chvsidx->ProjectionY("",APV2->Bin,APV2->Bin,"e"));
378  if(Proj2){Proj->Add(Proj2,1);delete Proj2;}
379  }else if(CalibrationLevel==2){
380  for(unsigned int i=0;i<16;i++){ //loop up to 6APV for Strip and up to 16 for Pixels
381  auto tmpit = APVsColl.find((APV->DetId<<4) | i);
382  if(tmpit==APVsColl.end())continue;
383  std::shared_ptr<stAPVGain> APV2 = tmpit->second;
384  if(APV2->DetId != APV->DetId || APV2->APVId == APV->APVId)continue;
385  if(APV2->Bin<0) APV2->Bin = chvsidx->GetXaxis()->FindBin(APV2->Index);
386  TH1F* Proj2 = (TH1F*)(chvsidx->ProjectionY("",APV2->Bin,APV2->Bin,"e"));
387  if(Proj2){Proj->Add(Proj2,1);delete Proj2;}
388  }
389  } else {
390  CalibrationLevel = 0;
391  printf("Unknown Calibration Level, will assume %i\n",CalibrationLevel);
392  }
393 
394  getPeakOfLandau(Proj,FitResults);
395  APV->FitMPV = FitResults[0];
396  APV->FitMPVErr = FitResults[1];
397  APV->FitWidth = FitResults[2];
398  APV->FitWidthErr = FitResults[3];
399  APV->FitChi2 = FitResults[4];
400  APV->FitNorm = FitResults[5];
401  APV->NEntries = Proj->GetEntries();
402 
403  if(IsGoodLandauFit(FitResults)){
404  APV->Gain = APV->FitMPV / MPVmean;
405  if(APV->SubDet>2)GOOD++;
406  }else{
407  APV->Gain = APV->PreviousGain;
408  if(APV->SubDet>2)BAD++;
409  }
410  if(APV->Gain<=0) APV->Gain = 1;
411 
412  delete Proj;
413  }printf("\n");
414 }
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(), constexpr, 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  static constexpr float defaultGainTick = 690./640.;
78 
79  this->checkBookAPVColls(iSetup); // check whether APV colls are booked and do so if not yet done
80  this->checkAndRetrieveTopology(iSetup);
81 
82  edm::ESHandle<SiStripGain> gainHandle;
83  iSetup.get<SiStripGainRcd>().get(gainHandle);
84  if(!gainHandle.isValid()){edm::LogError("SiStripGainPCLHarvester")<< "gainHandle is not valid\n"; exit(0);}
85 
86  edm::ESHandle<SiStripQuality> SiStripQuality_;
87  iSetup.get<SiStripQualityRcd>().get(SiStripQuality_);
88 
89  for(unsigned int a=0;a<APVsCollOrdered.size();a++){
90 
91  std::shared_ptr<stAPVGain> APV = APVsCollOrdered[a];
92 
93  if(APV->SubDet==PixelSubdetector::PixelBarrel || APV->SubDet==PixelSubdetector::PixelEndcap) continue;
94 
95  APV->isMasked = SiStripQuality_->IsApvBad(APV->DetId,APV->APVId);
96 
97  if(gainHandle->getNumberOfTags()!=2){edm::LogError("SiStripGainPCLHarvester")<< "NUMBER OF GAIN TAG IS EXPECTED TO BE 2\n";fflush(stdout);exit(0);};
98  float newPreviousGain = gainHandle->getApvGain(APV->APVId,gainHandle->getRange(APV->DetId, 1),1);
99  if(APV->PreviousGain!=1 and newPreviousGain!=APV->PreviousGain)edm::LogWarning("SiStripGainPCLHarvester")<< "WARNING: ParticleGain in the global tag changed\n";
100  APV->PreviousGain = newPreviousGain;
101 
102  float newPreviousGainTick = APV->isMasked ? defaultGainTick : gainHandle->getApvGain(APV->APVId,gainHandle->getRange(APV->DetId, 0),0);
103  if(APV->PreviousGainTick!=1 and newPreviousGainTick!=APV->PreviousGainTick){
104  edm::LogWarning("SiStripGainPCLHarvester")<< "WARNING: TickMarkGain in the global tag changed\n"<< std::endl
105  <<" APV->SubDet: "<< APV->SubDet << " APV->APVId:" << APV->APVId << std::endl
106  <<" APV->PreviousGainTick: "<<APV->PreviousGainTick<<" newPreviousGainTick: "<<newPreviousGainTick<<std::endl;
107  }
108  APV->PreviousGainTick = newPreviousGainTick;
109  }
110 }
bool IsApvBad(const uint32_t &detid, const short &apvNb) const
size_t getNumberOfTags() const
Definition: SiStripGain.h:95
static float getApvGain(const uint16_t &apv, const SiStripApvGain::Range &range)
Definition: SiStripGain.h:76
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:44
#define constexpr
const SiStripApvGain::Range getRange(uint32_t detID) const
Definition: SiStripGain.h:71
void SiStripGainsPCLHarvester::checkAndRetrieveTopology ( const edm::EventSetup setup)
privatevirtual

Definition at line 567 of file SiStripGainsPCLHarvester.cc.

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

Referenced by beginRun().

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

Definition at line 457 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().

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

113  {
114 
115  edm::LogInfo("SiStripGainsPCLHarvester") << "Starting harvesting statistics" << std::endl;
116 
117  std::string DQM_dir = m_DQMdir;
118 
119  std::string stag = *(std::find(dqm_tag_.begin(), dqm_tag_.end(),m_calibrationMode));
120  if(!stag.empty() && stag[0]!='_') stag.insert(0,1,'_');
121 
122  std::string cvi = DQM_dir + std::string("/Charge_Vs_Index") + stag;
123 
124  MonitorElement* Charge_Vs_Index = igetter_.get(cvi);
125 
126  if (Charge_Vs_Index==nullptr) {
127  edm::LogError("SiStripGainsPCLHarvester") << "Harvesting: could not retrieve " << cvi.c_str()
128  << ", statistics will not be summed!" << std::endl;
129  } else {
130  edm::LogInfo("SiStripGainsPCLHarvester") << "Harvesting "
131  << (Charge_Vs_Index)->getTH2S()->GetEntries() << " more clusters" << std::endl;
132  }
133 
134  algoComputeMPVandGain(Charge_Vs_Index);
135  std::unique_ptr<SiStripApvGain> theAPVGains = this->getNewObject(Charge_Vs_Index);
136 
137  // write out the APVGains record
139 
140  if( doStoreOnDB ){
141  if( poolDbService.isAvailable() )
142  poolDbService->writeOne(theAPVGains.get(), poolDbService->currentTime(),m_Record);
143  else
144  throw std::runtime_error("PoolDBService required.");
145  } else {
146  edm::LogInfo("SiStripGainsPCLHarvester") << "Will not produce payload!" << std::endl;
147  }
148 
149 
150  //Collect the statistics for monitoring and validation
151  gainQualityMonitor(ibooker_,Charge_Vs_Index);
152 
153 }
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:40
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 662 of file SiStripGainsPCLHarvester.cc.

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

Definition at line 653 of file SiStripGainsPCLHarvester.cc.

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

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

Definition at line 157 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().

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

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

Referenced by dqmEndJob().

609 {
610  std::unique_ptr<SiStripApvGain> obj = std::unique_ptr<SiStripApvGain>(new SiStripApvGain());
611 
612  if(!produceTagFilter(Charge_Vs_Index)){
613  edm::LogWarning("SiStripGainsPCLHarvester")<< "getNewObject -> will not produce a paylaod because produceTagFilter returned false " << std::endl;
614  return obj;
615  } else {
616  doStoreOnDB=true;
617  }
618 
619  std::vector<float> theSiStripVector;
620  unsigned int PreviousDetId = 0;
621  for(unsigned int a=0;a<APVsCollOrdered.size();a++){
622  std::shared_ptr<stAPVGain> APV = APVsCollOrdered[a];
623  if(APV==nullptr){ printf("Bug\n"); continue; }
624  if(APV->SubDet<=2)continue;
625  if(APV->DetId != PreviousDetId){
626  if(!theSiStripVector.empty()){
627  SiStripApvGain::Range range(theSiStripVector.begin(),theSiStripVector.end());
628  if ( !obj->put(PreviousDetId,range) ) printf("Bug to put detId = %i\n",PreviousDetId);
629  }
630  theSiStripVector.clear();
631  PreviousDetId = APV->DetId;
632  }
633  theSiStripVector.push_back(APV->Gain);
634 
635  LogDebug("SiStripGainsPCLHarvester")<<" DetId: "<<APV->DetId
636  <<" APV: "<<APV->APVId
637  <<" Gain: "<<APV->Gain
638  <<std::endl;
639 
640  }
641  if(!theSiStripVector.empty()){
642  SiStripApvGain::Range range(theSiStripVector.begin(),theSiStripVector.end());
643  if ( !obj->put(PreviousDetId,range) ) printf("Bug to put detId = %i\n",PreviousDetId);
644  }
645 
646  return obj;
647 }
#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 418 of file SiStripGainsPCLHarvester.cc.

References MinNrEntries.

Referenced by algoComputeMPVandGain().

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

Definition at line 446 of file SiStripGainsPCLHarvester.cc.

Referenced by algoComputeMPVandGain().

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

Definition at line 576 of file SiStripGainsPCLHarvester.cc.

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

Referenced by getNewObject().

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