CMS 3D CMS Logo

List of all members | Public Member Functions | Protected Attributes | Private Member Functions | Private Attributes
EcalPnGraphs Class Reference

#include <EcalPnGraphs.h>

Inheritance diagram for EcalPnGraphs:
edm::one::EDAnalyzer<> edm::one::EDAnalyzerBase edm::EDConsumerBase

Public Member Functions

 EcalPnGraphs (const edm::ParameterSet &ps)
 
 ~EcalPnGraphs () 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)
 

Protected Attributes

int abscissa [50]
 
std::string digiProducer_
 
std::vector< std::string > ebs_
 
int eventCounter
 
std::vector< int > feds_
 
std::string fileName
 
int first_Pn
 
std::vector< TGraph > graphs
 
bool inputIsOk
 
std::vector< int > listAllChannels
 
std::vector< int > listAllPns
 
std::vector< int > listChannels
 
std::vector< int > listPns
 
int numPn
 
int ordinate [50]
 
TFile * root_file
 
int verbosity
 

Private Member Functions

void analyze (const edm::Event &e, const edm::EventSetup &c) override
 
void beginJob () override
 
void endJob () override
 
std::string intToString (int num)
 

Private Attributes

EcalFedMapfedMap
 

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 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 ()
 
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 20 of file EcalPnGraphs.h.

Constructor & Destructor Documentation

◆ EcalPnGraphs()

EcalPnGraphs::EcalPnGraphs ( const edm::ParameterSet ps)

module dumping TGraph with 50 data frames from Pn Diodes

Author
K. Kaadze
G. Franzoni

Definition at line 29 of file EcalPnGraphs.cc.

References abscissa, gather_cfg::cout, digiProducer_, ebs_, eventCounter, fedMap, feds_, fileName, first_Pn, EcalFedMap::getFedFromSlice(), edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), mps_fire::i, inputIsOk, listPns, numPn, and AlCaHLTBitMon_QueryRunRegistry::string.

29  {
30  //=============================================================================
31 
32  digiProducer_ = ps.getParameter<std::string>("digiProducer");
33  fileName = ps.getUntrackedParameter<std::string>("fileName", std::string("toto"));
34 
35  first_Pn = 0;
36 
37  listPns = ps.getUntrackedParameter<std::vector<int> >("listPns", std::vector<int>());
38  numPn = ps.getUntrackedParameter<int>("numPn");
39 
40  std::vector<int> listDefaults;
41  listDefaults.push_back(-1);
42  feds_ = ps.getUntrackedParameter<std::vector<int> >("requestedFeds", listDefaults);
43  bool fedIsGiven = false;
44 
45  std::vector<std::string> ebDefaults;
46  ebDefaults.push_back("none");
47  ebs_ = ps.getUntrackedParameter<std::vector<std::string> >("requestedEbs", ebDefaults);
48 
49  //FEDs and EBs
50  if (feds_[0] != -1) {
51  edm::LogInfo("EcalPnGraphs") << "FED id is given! Goining to beginJob! ";
52  fedIsGiven = true;
53  } else {
54  feds_.clear();
55  if (ebs_[0] != "none") {
56  //EB id is given and convert to FED id
57  fedMap = new EcalFedMap();
58  for (std::vector<std::string>::const_iterator ebItr = ebs_.begin(); ebItr != ebs_.end(); ++ebItr) {
59  feds_.push_back(fedMap->getFedFromSlice(*ebItr));
60  }
61  delete fedMap;
62  } else {
63  //Select all FEDs in the Event
64  for (int i = 601; i < 655; ++i) {
65  feds_.push_back(i);
66  }
67  }
68  }
69 
70  // consistency checks checks
71  inputIsOk = true;
72  //check with FEDs
73  if (fedIsGiven) {
74  std::vector<int>::iterator fedIter;
75  for (fedIter = feds_.begin(); fedIter != feds_.end(); ++fedIter) {
76  if ((*fedIter) < 601 || (*fedIter) > 654) {
77  std::cout << "[EcalPnGraphs] pn number : " << (*fedIter) << " found in listFeds. "
78  << " Valid range is [601-654]. Returning." << std::endl;
79  inputIsOk = false;
80  return;
81  }
82  }
83  }
84 
85  //Check with Pns
86  if (listPns[0] != -1) {
87  std::vector<int>::iterator intIter;
88  for (intIter = listPns.begin(); intIter != listPns.end(); intIter++) {
89  if (((*intIter) < 1) || (10 < (*intIter))) {
90  std::cout << "[EcalPnGraphs] pn number : " << (*intIter) << " found in listPns. "
91  << " Valid range is 1-10. Returning." << std::endl;
92  inputIsOk = false;
93  return;
94  }
95  if (!first_Pn)
96  first_Pn = (*intIter);
97  }
98  } else {
99  listPns.clear();
100  listPns.push_back(5);
101  listPns.push_back(6);
102  }
103 
104  // setting the abcissa array once for all
105  for (int i = 0; i < 50; i++)
106  abscissa[i] = i;
107 
108  // local event counter (in general different from LV1)
109  eventCounter = 0;
110 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
int abscissa[50]
Definition: EcalPnGraphs.h:61
int getFedFromSlice(std::string)
Definition: EcalFedMap.cc:96
std::vector< int > feds_
Definition: EcalPnGraphs.h:41
T getUntrackedParameter(std::string const &, T const &) const
std::string fileName
Definition: EcalPnGraphs.h:52
EcalFedMap * fedMap
Definition: EcalPnGraphs.h:34
Log< level::Info, false > LogInfo
std::string digiProducer_
Definition: EcalPnGraphs.h:39
std::vector< std::string > ebs_
Definition: EcalPnGraphs.h:42
std::vector< int > listPns
Definition: EcalPnGraphs.h:56

◆ ~EcalPnGraphs()

EcalPnGraphs::~EcalPnGraphs ( )
override

Definition at line 113 of file EcalPnGraphs.cc.

113  {
114  //=============================================================================
115  //delete *;
116 }

Member Function Documentation

◆ analyze()

void EcalPnGraphs::analyze ( const edm::Event e,
const edm::EventSetup c 
)
overrideprivatevirtual

Implements edm::one::EDAnalyzerBase.

Definition at line 125 of file EcalPnGraphs.cc.

References abscissa, edm::SortedCollection< T, SORT >::begin(), digiProducer_, MillePedeFileConverter_cfg::e, edm::SortedCollection< T, SORT >::end(), eventCounter, feds_, spr::find(), graphs, mps_fire::i, inputIsOk, intToString(), listAllPns, listPns, numPn, ordinate, AlCaHLTBitMon_QueryRunRegistry::string, and runGCPTkAlMap::title.

125  {
126  //=============================================================================
127 
128  eventCounter++;
129  if (!inputIsOk)
130  return;
131 
132  // retrieving crystal PN diodes from Event
134  try {
135  e.getByLabel(digiProducer_, pn_digis);
136  } catch (cms::Exception& ex) {
137  edm::LogError("EcalPnGraphs") << "PNs were not found!";
138  }
139 
140  // getting the list of all the Pns which will be dumped on TGraph
141  // - listPns is the list as given by the user
142  // -numPn is the number of Pns (centered at Pn from listPns) for which graphs are required
143  std::vector<int>::iterator pn_it;
144  for (pn_it = listPns.begin(); pn_it != listPns.end(); pn_it++) {
145  int ipn = (*pn_it);
146  int hpn = numPn;
147 
148  for (int u = (-hpn); u <= hpn; u++) {
149  int ipn_c = ipn + u;
150  if (ipn_c < 1 || ipn_c > 10)
151  continue;
152  std::vector<int>::iterator notInList = find(listAllPns.begin(), listAllPns.end(), ipn_c);
153  if (notInList == listAllPns.end()) {
154  listAllPns.push_back(ipn_c);
155  }
156  }
157  }
158 
159  //Loop over PN digis
160  for (EcalPnDiodeDigiCollection::const_iterator pnItr = pn_digis->begin(); pnItr != pn_digis->end(); ++pnItr) {
161  //Get PNid of a digi
162  int ipn = (*pnItr).id().iPnId();
163  //Get DCC id where the digi is from
164  int ieb = EcalPnDiodeDetId((*pnItr).id()).iDCCId();
165 
166  //Make sure that these are PnDigis from the requested FEDid
167  int FEDid = ieb + 600;
168 
169  std::vector<int>::iterator fedIter = find(feds_.begin(), feds_.end(), FEDid);
170 
171  if (fedIter == feds_.end()) {
172  edm::LogWarning("EcalPnGraphs") << "For Event " << eventCounter
173  << " PnDigis are not found from requested SM!. returning...";
174  return;
175  }
176  // selecting desired Pns only
177  std::vector<int>::iterator iPnIter;
178  iPnIter = find(listAllPns.begin(), listAllPns.end(), ipn);
179  if (iPnIter == listAllPns.end())
180  continue;
181 
182  for (int i = 0; i < (*pnItr).size() && i < 50; ++i) {
183  ordinate[i] = (*pnItr).sample(i).adc();
184  }
185  //make grapn of ph digis
186  TGraph oneGraph(50, abscissa, ordinate);
188  title = "Graph_ev" + intToString(eventCounter) + "_FED" + intToString(FEDid) + "_ipn" + intToString(ipn);
189  oneGraph.SetTitle(title.c_str());
190  oneGraph.SetName(title.c_str());
191  graphs.push_back(oneGraph);
192 
193  } // loop over Pn digis
194 }
int abscissa[50]
Definition: EcalPnGraphs.h:61
std::vector< T >::const_iterator const_iterator
std::string intToString(int num)
Log< level::Error, false > LogError
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
std::vector< int > feds_
Definition: EcalPnGraphs.h:41
const_iterator begin() const
std::vector< TGraph > graphs
Definition: EcalPnGraphs.h:64
int ordinate[50]
Definition: EcalPnGraphs.h:62
const_iterator end() const
std::string digiProducer_
Definition: EcalPnGraphs.h:39
std::vector< int > listAllPns
Definition: EcalPnGraphs.h:57
std::vector< int > listPns
Definition: EcalPnGraphs.h:56
Log< level::Warning, false > LogWarning

◆ beginJob()

void EcalPnGraphs::beginJob ( )
overrideprivatevirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 119 of file EcalPnGraphs.cc.

119  {
120  //=============================================================================
121  edm::LogInfo("EcalPhGraphs") << "entering beginJob! ";
122 }
Log< level::Info, false > LogInfo

◆ endJob()

void EcalPnGraphs::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 208 of file EcalPnGraphs.cc.

References fileName, first_Pn, graphs, intToString(), root_file, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by o2olib.O2ORunMgr::executeJob().

208  {
209  //=============================================================================
210  fileName += (std::string("_Pn") + intToString(first_Pn));
211  fileName += ".graph.root";
212 
213  root_file = new TFile(fileName.c_str(), "RECREATE");
214  std::vector<TGraph>::iterator gr_it;
215  for (gr_it = graphs.begin(); gr_it != graphs.end(); gr_it++)
216  (*gr_it).Write();
217  root_file->Close();
218 
219  edm::LogInfo("EcalPnGraphs") << "DONE!.... ";
220 }
std::string intToString(int num)
std::string fileName
Definition: EcalPnGraphs.h:52
std::vector< TGraph > graphs
Definition: EcalPnGraphs.h:64
Log< level::Info, false > LogInfo
TFile * root_file
Definition: EcalPnGraphs.h:66

◆ intToString()

std::string EcalPnGraphs::intToString ( int  num)
private

Definition at line 196 of file EcalPnGraphs.cc.

References EgammaValidation_cff::num.

Referenced by analyze(), and endJob().

196  {
197  //
198  // outputs the number into the string stream and then flushes
199  // the buffer (makes sure the output is put into the stream)
200  //
201  std::ostringstream myStream; //creates an ostringstream object
202  myStream << num << std::flush;
203 
204  return (myStream.str()); //returns the string form of the stringstream object
205 }

Member Data Documentation

◆ abscissa

int EcalPnGraphs::abscissa[50]
protected

Definition at line 61 of file EcalPnGraphs.h.

Referenced by analyze(), and EcalPnGraphs().

◆ digiProducer_

std::string EcalPnGraphs::digiProducer_
protected

Definition at line 39 of file EcalPnGraphs.h.

Referenced by analyze(), and EcalPnGraphs().

◆ ebs_

std::vector<std::string> EcalPnGraphs::ebs_
protected

Definition at line 42 of file EcalPnGraphs.h.

Referenced by EcalPnGraphs().

◆ eventCounter

int EcalPnGraphs::eventCounter
protected

Definition at line 45 of file EcalPnGraphs.h.

Referenced by analyze(), and EcalPnGraphs().

◆ fedMap

EcalFedMap* EcalPnGraphs::fedMap
private

Definition at line 34 of file EcalPnGraphs.h.

Referenced by EcalPnGraphs().

◆ feds_

std::vector<int> EcalPnGraphs::feds_
protected

Definition at line 41 of file EcalPnGraphs.h.

Referenced by analyze(), and EcalPnGraphs().

◆ fileName

std::string EcalPnGraphs::fileName
protected

Definition at line 52 of file EcalPnGraphs.h.

Referenced by EcalPnGraphs(), endJob(), and readConfig.fileINI::read().

◆ first_Pn

int EcalPnGraphs::first_Pn
protected

Definition at line 48 of file EcalPnGraphs.h.

Referenced by EcalPnGraphs(), and endJob().

◆ graphs

std::vector<TGraph> EcalPnGraphs::graphs
protected

Definition at line 64 of file EcalPnGraphs.h.

Referenced by analyze(), and endJob().

◆ inputIsOk

bool EcalPnGraphs::inputIsOk
protected

Definition at line 50 of file EcalPnGraphs.h.

Referenced by analyze(), and EcalPnGraphs().

◆ listAllChannels

std::vector<int> EcalPnGraphs::listAllChannels
protected

Definition at line 55 of file EcalPnGraphs.h.

◆ listAllPns

std::vector<int> EcalPnGraphs::listAllPns
protected

Definition at line 57 of file EcalPnGraphs.h.

Referenced by analyze().

◆ listChannels

std::vector<int> EcalPnGraphs::listChannels
protected

Definition at line 54 of file EcalPnGraphs.h.

◆ listPns

std::vector<int> EcalPnGraphs::listPns
protected

Definition at line 56 of file EcalPnGraphs.h.

Referenced by analyze(), and EcalPnGraphs().

◆ numPn

int EcalPnGraphs::numPn
protected

Definition at line 59 of file EcalPnGraphs.h.

Referenced by analyze(), and EcalPnGraphs().

◆ ordinate

int EcalPnGraphs::ordinate[50]
protected

Definition at line 62 of file EcalPnGraphs.h.

Referenced by analyze().

◆ root_file

TFile* EcalPnGraphs::root_file
protected

Definition at line 66 of file EcalPnGraphs.h.

Referenced by endJob().

◆ verbosity

int EcalPnGraphs::verbosity
protected

Definition at line 44 of file EcalPnGraphs.h.