CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
SiStripApvGainReader Class Reference
Inheritance diagram for SiStripApvGainReader:
edm::one::EDAnalyzer< edm::one::SharedResources > edm::one::EDAnalyzerBase edm::EDConsumerBase

Public Member Functions

void analyze (const edm::Event &, const edm::EventSetup &) override
 
 SiStripApvGainReader (const edm::ParameterSet &)
 
 ~SiStripApvGainReader () override=default
 
- Public Member Functions inherited from edm::one::EDAnalyzer< edm::one::SharedResources >
 EDAnalyzer ()=default
 
 EDAnalyzer (const EDAnalyzer &)=delete
 
SerialTaskQueueglobalLuminosityBlocksQueue () final
 
SerialTaskQueueglobalRunsQueue () final
 
const EDAnalyzeroperator= (const EDAnalyzer &)=delete
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
bool wantsInputProcessBlocks () const final
 
bool wantsProcessBlocks () const final
 
- Public Member Functions inherited from edm::one::EDAnalyzerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzerBase ()
 
ModuleDescription const & moduleDescription () const
 
bool wantsStreamLuminosityBlocks () const
 
bool wantsStreamRuns () const
 
 ~EDAnalyzerBase () 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
 
ESResolverIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESResolverIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex > const & esGetTokenRecordIndicesVector (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::array< std::vector< ModuleDescription const *> *, NumBranchTypes > &modulesAll, std::vector< ModuleProcessName > &modulesInPreviousProcesses, 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
 
void selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProductResolverIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Attributes

int apvId_ = 0
 
int detId_ = 0
 
const std::string formatedOutput_
 
edm::Service< TFileServicefs_
 
double gain_ = 0
 
const edm::ESGetToken< SiStripGain, SiStripGainRcdgainToken_
 
const uint32_t gainType_
 
int id_ = 0
 
const bool printdebug_
 
TTree * tree_ = nullptr
 

Additional Inherited Members

- Public Types inherited from edm::one::EDAnalyzerBase
typedef EDAnalyzerBase ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::one::EDAnalyzerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< Bconsumes (edm::InputTag tag) noexcept
 
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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes ()
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag)
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
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)
 
void resetItemsToGetFrom (BranchType iType)
 

Detailed Description

Definition at line 27 of file SiStripApvGainReader.cc.

Constructor & Destructor Documentation

◆ SiStripApvGainReader()

SiStripApvGainReader::SiStripApvGainReader ( const edm::ParameterSet iConfig)
explicit

Definition at line 48 of file SiStripApvGainReader.cc.

References apvId_, detId_, fs_, gain_, id_, edm::Service< T >::isAvailable(), TFileService::kSharedResource, TFileService::make(), and tree_.

49  : printdebug_(iConfig.getUntrackedParameter<bool>("printDebug", true)),
50  formatedOutput_(iConfig.getUntrackedParameter<std::string>("outputFile", "")),
51  gainType_(iConfig.getUntrackedParameter<uint32_t>("gainType", 1)),
53  usesResource(TFileService::kSharedResource);
54 
55  if (fs_.isAvailable()) {
56  tree_ = fs_->make<TTree>("Gains", "Gains");
57 
58  tree_->Branch("Index", &id_, "Index/I");
59  tree_->Branch("DetId", &detId_, "DetId/I");
60  tree_->Branch("APVId", &apvId_, "APVId/I");
61  tree_->Branch("Gain", &gain_, "Gain/D");
62  }
63 }
static const std::string kSharedResource
Definition: TFileService.h:76
T getUntrackedParameter(std::string const &, T const &) const
const std::string formatedOutput_
edm::Service< TFileService > fs_
T * make(const Args &...args) const
make new ROOT object
Definition: TFileService.h:64
const edm::ESGetToken< SiStripGain, SiStripGainRcd > gainToken_
bool isAvailable() const
Definition: Service.h:40

◆ ~SiStripApvGainReader()

SiStripApvGainReader::~SiStripApvGainReader ( )
overridedefault

Member Function Documentation

◆ analyze()

void SiStripApvGainReader::analyze ( const edm::Event e,
const edm::EventSetup iSetup 
)
overridevirtual

Implements edm::one::EDAnalyzerBase.

Definition at line 65 of file SiStripApvGainReader.cc.

References apvId_, detId_, formatedOutput_, gain_, gainToken_, gainType_, edm::EventSetup::getData(), l1ctLayer2EG_cff::id, id_, printdebug_, FastTimerService_cff::range, and tree_.

65  {
66  const auto& stripApvGain = iSetup.getData(gainToken_);
67  edm::LogInfo("SiStripApvGainReader") << "[SiStripApvGainReader::analyze] End Reading SiStripApvGain" << std::endl;
68  std::vector<uint32_t> detid;
69  stripApvGain.getDetIds(detid);
70  edm::LogInfo("Number of detids ") << detid.size() << std::endl;
71 
72  FILE* pFile = nullptr;
73  if (!formatedOutput_.empty())
74  pFile = fopen(formatedOutput_.c_str(), "w");
75  for (size_t id = 0; id < detid.size(); id++) {
76  SiStripApvGain::Range range = stripApvGain.getRange(detid[id], gainType_);
77  if (printdebug_) {
78  int apv = 0;
79  for (int it = 0; it < range.second - range.first; it++) {
80  edm::LogInfo("SiStripApvGainReader")
81  << "detid " << detid[id] << " \t " << apv++ << " \t " << stripApvGain.getApvGain(it, range) << std::endl;
82  id_++;
83 
84  if (tree_) {
85  detId_ = detid[id];
86  apvId_ = apv;
87  gain_ = stripApvGain.getApvGain(it, range);
88  tree_->Fill();
89  }
90  }
91  }
92 
93  if (pFile) {
94  fprintf(pFile, "%i ", detid[id]);
95  for (int it = 0; it < range.second - range.first; it++) {
96  fprintf(pFile, "%f ", stripApvGain.getApvGain(it, range));
97  }
98  fprintf(pFile, "\n");
99  }
100  }
101 
102  if (pFile)
103  fclose(pFile);
104 }
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
Definition: EventSetup.h:119
const std::string formatedOutput_
std::pair< ContainerIterator, ContainerIterator > Range
Log< level::Info, false > LogInfo
const edm::ESGetToken< SiStripGain, SiStripGainRcd > gainToken_

Member Data Documentation

◆ apvId_

int SiStripApvGainReader::apvId_ = 0
private

Definition at line 42 of file SiStripApvGainReader.cc.

Referenced by analyze(), and SiStripApvGainReader().

◆ detId_

int SiStripApvGainReader::detId_ = 0
private

Definition at line 42 of file SiStripApvGainReader.cc.

Referenced by analyze(), and SiStripApvGainReader().

◆ formatedOutput_

const std::string SiStripApvGainReader::formatedOutput_
private

Definition at line 37 of file SiStripApvGainReader.cc.

Referenced by analyze().

◆ fs_

edm::Service<TFileService> SiStripApvGainReader::fs_
private

Definition at line 40 of file SiStripApvGainReader.cc.

Referenced by SiStripApvGainReader().

◆ gain_

double SiStripApvGainReader::gain_ = 0
private

Definition at line 43 of file SiStripApvGainReader.cc.

Referenced by analyze(), and SiStripApvGainReader().

◆ gainToken_

const edm::ESGetToken<SiStripGain, SiStripGainRcd> SiStripApvGainReader::gainToken_
private

Definition at line 39 of file SiStripApvGainReader.cc.

Referenced by analyze().

◆ gainType_

const uint32_t SiStripApvGainReader::gainType_
private

Definition at line 38 of file SiStripApvGainReader.cc.

Referenced by analyze().

◆ id_

int SiStripApvGainReader::id_ = 0
private

Definition at line 42 of file SiStripApvGainReader.cc.

Referenced by analyze(), and SiStripApvGainReader().

◆ printdebug_

const bool SiStripApvGainReader::printdebug_
private

Definition at line 36 of file SiStripApvGainReader.cc.

Referenced by analyze().

◆ tree_

TTree* SiStripApvGainReader::tree_ = nullptr
private

Definition at line 41 of file SiStripApvGainReader.cc.

Referenced by analyze(), and SiStripApvGainReader().