CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Member Functions | Private Attributes
CTPPSPixGainCalibsESAnalyzer Class Reference
Inheritance diagram for CTPPSPixGainCalibsESAnalyzer:
edm::one::EDAnalyzer<> edm::one::EDAnalyzerBase edm::EDConsumerBase

Public Member Functions

void analyze (const edm::Event &e, const edm::EventSetup &c) override
 
 CTPPSPixGainCalibsESAnalyzer (edm::ParameterSet const &p)
 
 CTPPSPixGainCalibsESAnalyzer (int i)
 
void setReadablePlaneNames ()
 
 ~CTPPSPixGainCalibsESAnalyzer () override
 
- Public Member Functions inherited from edm::one::EDAnalyzer<>
 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
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESProxyIndex > 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
 
bool registeredToConsumeMany (TypeID const &, 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::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Attributes

std::map< uint32_t, std::string > detId_readable
 
std::string m_outfilename
 
edm::ESGetToken
< CTPPSPixelGainCalibrations,
CTPPSPixelGainCalibrationsRcd
tokenCalibration_
 

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< B > consumes (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 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<Transition Tr = Transition::Event>
constexpr auto esConsumes () noexcept
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag) noexcept
 
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 15 of file CTPPSPixGainCalibsESAnalyzer.cc.

Constructor & Destructor Documentation

CTPPSPixGainCalibsESAnalyzer::CTPPSPixGainCalibsESAnalyzer ( edm::ParameterSet const &  p)
inlineexplicit

Definition at line 17 of file CTPPSPixGainCalibsESAnalyzer.cc.

References setReadablePlaneNames().

18  : m_outfilename(p.getUntrackedParameter<std::string>("outputrootfile", "output.root")),
19  tokenCalibration_(esConsumes<CTPPSPixelGainCalibrations, CTPPSPixelGainCalibrationsRcd>()) {
21  }
edm::ESGetToken< CTPPSPixelGainCalibrations, CTPPSPixelGainCalibrationsRcd > tokenCalibration_
CTPPSPixGainCalibsESAnalyzer::CTPPSPixGainCalibsESAnalyzer ( int  i)
inlineexplicit

Definition at line 22 of file CTPPSPixGainCalibsESAnalyzer.cc.

References setReadablePlaneNames().

22  {
23  //std::cout<<"CTPPSPixGainCalibsESAnalyzer "<<i<<std::endl;
25  }
CTPPSPixGainCalibsESAnalyzer::~CTPPSPixGainCalibsESAnalyzer ( )
inlineoverride

Definition at line 26 of file CTPPSPixGainCalibsESAnalyzer.cc.

26  {
27  //std::cout<<"~CTPPSPixGainCalibsESAnalyzer "<<std::endl;
28  }

Member Function Documentation

void CTPPSPixGainCalibsESAnalyzer::analyze ( const edm::Event e,
const edm::EventSetup c 
)
overridevirtual

Implements edm::one::EDAnalyzerBase.

Definition at line 66 of file CTPPSPixGainCalibsESAnalyzer.cc.

References detId_readable, edm::EventID::event(), edm::eventsetup::heterocontainer::HCTypeTag::findType(), CTPPSPixelGainCalibrations::getCalibMap(), CTPPSPixelGainCalibration::getGain(), CTPPSPixelGainCalibrations::getGainCalibration(), edm::EventSetup::getHandle(), CTPPSPixelGainCalibration::getIEnd(), CTPPSPixelGainCalibration::getNCols(), CTPPSPixelGainCalibration::getNRows(), CTPPSPixelGainCalibration::getPed(), edm::EventBase::id(), CTPPSPixelGainCalibration::isDead(), CTPPSPixelGainCalibration::isNoisy(), m_outfilename, edm::ESHandle< class >::product(), edm::EventID::run(), CTPPSPixelGainCalibrations::size(), AlCaHLTBitMon_QueryRunRegistry::string, tokenCalibration_, and edm::eventsetup::EventSetupRecordKey::type().

66  {
67  edm::LogPrint("CTPPSPixGainCalibsReader") << "###CTPPSPixGainCalibsESAnalyzer::analyze";
68  edm::LogPrint("CTPPSPixGainCalibsReader") << " I AM IN RUN NUMBER " << e.id().run();
69  edm::LogPrint("CTPPSPixGainCalibsReader") << " ---EVENT NUMBER " << e.id().event();
71  edm::eventsetup::EventSetupRecordKey::TypeTag::findType("CTPPSPixelGainCalibrationsRcd"));
72  if (recordKey.type() == edm::eventsetup::EventSetupRecordKey::TypeTag()) {
73  //record not found
74  edm::LogPrint("CTPPSPixGainCalibsReader") << "Record \"CTPPSPixelGainCalibrationsRcd"
75  << "\" does not exist ";
76  }
77  //this part gets the handle of the event source and the record (i.e. the Database)
79  edm::LogPrint("CTPPSPixGainCalibsReader") << "got eshandle";
80  edm::LogPrint("CTPPSPixGainCalibsReader") << "got context";
81  const CTPPSPixelGainCalibrations* pPixelGainCalibrations = calhandle.product();
82  edm::LogPrint("CTPPSPixGainCalibsReader") << "got CTPPSPixelGainCalibrations* ";
83  edm::LogPrint("CTPPSPixGainCalibsReader") << "print pointer address : ";
84  edm::LogPrint("CTPPSPixGainCalibsReader") << pPixelGainCalibrations;
85 
86  TFile myfile(m_outfilename.c_str(), "RECREATE");
87  myfile.cd();
88 
89  // the pPixelGainCalibrations object contains the map of detIds to pixel gains and pedestals for current run
90  // we get the map just to loop over the contents, but from here on it should be as the code (reconstruction etc) needs.
91  // Probably best to check that the key (detid) is in the list before calling the data
92 
93  edm::LogPrint("CTPPSPixGainCalibsReader") << "Size " << pPixelGainCalibrations->size();
94  const CTPPSPixelGainCalibrations::CalibMap& mymap = pPixelGainCalibrations->getCalibMap(); //just to get the keys?
95 
96  for (CTPPSPixelGainCalibrations::CalibMap::const_iterator it = mymap.begin(); it != mymap.end(); ++it) {
97  uint32_t detId = it->first;
98 
99  edm::LogPrint("CTPPSPixGainCalibsReader")
100  << "Address of detId = " << (&detId) << " and of it = " << (&it) << " and of it->first = " << (&(it->first));
101 
102  edm::LogPrint("CTPPSPixGainCalibsReader") << "Content of pPixelGainCalibrations for key: detId= " << detId;
103  CTPPSPixelGainCalibration mycalibs0 = pPixelGainCalibrations->getGainCalibration(detId);
104  const CTPPSPixelGainCalibration& mycalibs = it->second;
105 
106  edm::LogPrint("CTPPSPixGainCalibsReader")
107  << "Address of mycalibs0 = " << (&mycalibs0) << " and of mycalibs = " << (&mycalibs) << " and of it->second "
108  << (&(it->second));
109 
110  std::string namep("pedsFromDB_" + detId_readable[detId]);
111  std::string nameg("gainsFromDB_" + detId_readable[detId]);
112  std::string tlp("Pedestals for " + detId_readable[detId] + "; column; row");
113  std::string tlg("Gains for " + detId_readable[detId] + "; column; row");
114  TH2D mypeds(namep.c_str(), tlp.c_str(), 156, 0., 156., 160, 0., 160.);
115  TH2D mygains(nameg.c_str(), tlg.c_str(), 156, 0., 156., 160, 0., 160.);
116 
117  int ncols = mycalibs.getNCols();
118  int npix = mycalibs.getIEnd();
119  int nrows = mycalibs.getNRows(); //should be == 160
120  edm::LogPrint("CTPPSPixGainCalibsReader") << "Here ncols = " << ncols << " nrows =" << nrows << " npix=" << npix;
121  for (int jrow = 0; jrow < nrows; ++jrow)
122  for (int icol = 0; icol < ncols; ++icol) {
123  if (mycalibs.isDead(icol + jrow * ncols)) {
124  edm::LogPrint("CTPPSPixGainCalibsReader") << "Dead Pixel icol =" << icol << " jrow =" << jrow;
125  continue;
126  }
127  if (mycalibs.isNoisy(icol + jrow * ncols)) {
128  edm::LogPrint("CTPPSPixGainCalibsReader") << "Noisy Pixel icol =" << icol << " jrow =" << jrow;
129  continue;
130  }
131  mygains.Fill(icol, jrow, mycalibs.getGain(icol, jrow));
132  mypeds.Fill(icol, jrow, mycalibs.getPed(icol, jrow));
133  }
134 
135  mypeds.Write();
136  mygains.Write();
137  }
138  myfile.Write();
139  myfile.Close();
140 }
RunNumber_t run() const
Definition: EventID.h:38
EventNumber_t event() const
Definition: EventID.h:40
const CalibMap & getCalibMap() const
edm::ESGetToken< CTPPSPixelGainCalibrations, CTPPSPixelGainCalibrationsRcd > tokenCalibration_
bool isDead(const uint32_t ipix) const
const CTPPSPixelGainCalibration & getGainCalibration(const uint32_t &detid) const
std::map< uint32_t, std::string > detId_readable
std::map< uint32_t, CTPPSPixelGainCalibration > CalibMap
Log< level::Warning, true > LogPrint
T const * product() const
Definition: ESHandle.h:86
heterocontainer::HCTypeTag TypeTag
edm::EventID id() const
Definition: EventBase.h:59
float getPed(const int &col, const int &row) const
bool isNoisy(const uint32_t ipix) const
float getGain(const int &col, const int &row) const
static HCTypeTag findType(char const *iTypeName)
find a type based on the types name, if not found will return default HCTypeTag
Definition: HCTypeTag.cc:121
void CTPPSPixGainCalibsESAnalyzer::setReadablePlaneNames ( )

Definition at line 39 of file CTPPSPixGainCalibsESAnalyzer.cc.

References detId_readable.

Referenced by CTPPSPixGainCalibsESAnalyzer().

39  {
40  detId_readable[2014838784] = "Arm_0_Sec_45_St_0_Pot_3_Plane_0";
41  detId_readable[2014904320] = "Arm_0_Sec_45_St_0_Pot_3_Plane_1";
42  detId_readable[2014969856] = "Arm_0_Sec_45_St_0_Pot_3_Plane_2";
43  detId_readable[2015035392] = "Arm_0_Sec_45_St_0_Pot_3_Plane_3";
44  detId_readable[2015100928] = "Arm_0_Sec_45_St_0_Pot_3_Plane_4";
45  detId_readable[2015166464] = "Arm_0_Sec_45_St_0_Pot_3_Plane_5";
46  detId_readable[2023227392] = "Arm_0_Sec_45_St_2_Pot_3_Plane_0";
47  detId_readable[2023292928] = "Arm_0_Sec_45_St_2_Pot_3_Plane_1";
48  detId_readable[2023358464] = "Arm_0_Sec_45_St_2_Pot_3_Plane_2";
49  detId_readable[2023424000] = "Arm_0_Sec_45_St_2_Pot_3_Plane_3";
50  detId_readable[2023489536] = "Arm_0_Sec_45_St_2_Pot_3_Plane_4";
51  detId_readable[2023555072] = "Arm_0_Sec_45_St_2_Pot_3_Plane_5";
52  detId_readable[2031616000] = "Arm_1_Sec_56_St_0_Pot_3_Plane_0";
53  detId_readable[2031681536] = "Arm_1_Sec_56_St_0_Pot_3_Plane_1";
54  detId_readable[2031747072] = "Arm_1_Sec_56_St_0_Pot_3_Plane_2";
55  detId_readable[2031812608] = "Arm_1_Sec_56_St_0_Pot_3_Plane_3";
56  detId_readable[2031878144] = "Arm_1_Sec_56_St_0_Pot_3_Plane_4";
57  detId_readable[2031943680] = "Arm_1_Sec_56_St_0_Pot_3_Plane_5";
58  detId_readable[2040004608] = "Arm_1_Sec_56_St_2_Pot_3_Plane_0";
59  detId_readable[2040070144] = "Arm_1_Sec_56_St_2_Pot_3_Plane_1";
60  detId_readable[2040135680] = "Arm_1_Sec_56_St_2_Pot_3_Plane_2";
61  detId_readable[2040201216] = "Arm_1_Sec_56_St_2_Pot_3_Plane_3";
62  detId_readable[2040266752] = "Arm_1_Sec_56_St_2_Pot_3_Plane_4";
63  detId_readable[2040332288] = "Arm_1_Sec_56_St_2_Pot_3_Plane_5";
64 }
std::map< uint32_t, std::string > detId_readable

Member Data Documentation

std::map<uint32_t, std::string> CTPPSPixGainCalibsESAnalyzer::detId_readable
private

Definition at line 33 of file CTPPSPixGainCalibsESAnalyzer.cc.

Referenced by analyze(), and setReadablePlaneNames().

std::string CTPPSPixGainCalibsESAnalyzer::m_outfilename
private

Definition at line 34 of file CTPPSPixGainCalibsESAnalyzer.cc.

Referenced by analyze().

edm::ESGetToken<CTPPSPixelGainCalibrations, CTPPSPixelGainCalibrationsRcd> CTPPSPixGainCalibsESAnalyzer::tokenCalibration_
private

Definition at line 36 of file CTPPSPixGainCalibsESAnalyzer.cc.

Referenced by analyze().