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::EDAnalyzer edm::EDConsumerBase

Public Member Functions

 EcalPnGraphs (const edm::ParameterSet &ps)
 
 ~EcalPnGraphs () override
 
- Public Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
SerialTaskQueueglobalLuminosityBlocksQueue ()
 
SerialTaskQueueglobalRunsQueue ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
 ~EDAnalyzer () 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 &&)=default
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
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
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
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)
 

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::EDAnalyzer
typedef EDAnalyzer ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
static bool wantsGlobalLuminosityBlocks ()
 
static bool wantsGlobalRuns ()
 
static bool wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (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)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 

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 30 of file EcalPnGraphs.cc.

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

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.

◆ ~EcalPnGraphs()

EcalPnGraphs::~EcalPnGraphs ( )
override

Definition at line 114 of file EcalPnGraphs.cc.

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

Member Function Documentation

◆ analyze()

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

Implements edm::EDAnalyzer.

Definition at line 126 of file EcalPnGraphs.cc.

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

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 overlapproblemtsosanalyzer_cfi::title.

◆ beginJob()

void EcalPnGraphs::beginJob ( void  )
overrideprivatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 120 of file EcalPnGraphs.cc.

120  {
121  //=============================================================================
122  edm::LogInfo("EcalPhGraphs") << "entering beginJob! ";
123 }

◆ endJob()

void EcalPnGraphs::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 209 of file EcalPnGraphs.cc.

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

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

Referenced by o2olib.O2ORunMgr::executeJob().

◆ intToString()

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

Definition at line 197 of file EcalPnGraphs.cc.

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

References EgammaValidation_cff::num.

Referenced by analyze(), and endJob().

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.

EcalPnGraphs::numPn
int numPn
Definition: EcalPnGraphs.h:59
EcalPnGraphs::intToString
std::string intToString(int num)
Definition: EcalPnGraphs.cc:197
mps_fire.i
i
Definition: mps_fire.py:355
edm::SortedCollection::const_iterator
std::vector< T >::const_iterator const_iterator
Definition: SortedCollection.h:80
EcalPnGraphs::feds_
std::vector< int > feds_
Definition: EcalPnGraphs.h:41
EcalPnGraphs::eventCounter
int eventCounter
Definition: EcalPnGraphs.h:45
EcalPnGraphs::root_file
TFile * root_file
Definition: EcalPnGraphs.h:66
gather_cfg.cout
cout
Definition: gather_cfg.py:144
edm::LogInfo
Definition: MessageLogger.h:254
EcalPnGraphs::fileName
std::string fileName
Definition: EcalPnGraphs.h:52
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
EcalPnDiodeDetId
Definition: EcalPnDiodeDetId.h:22
spr::find
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
edm::Handle
Definition: AssociativeIterator.h:50
EcalPnGraphs::ordinate
int ordinate[50]
Definition: EcalPnGraphs.h:62
EcalPnGraphs::fedMap
EcalFedMap * fedMap
Definition: EcalPnGraphs.h:34
edm::SortedCollection::begin
const_iterator begin() const
Definition: SortedCollection.h:262
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::LogWarning
Definition: MessageLogger.h:141
EcalPnGraphs::ebs_
std::vector< std::string > ebs_
Definition: EcalPnGraphs.h:42
EcalPnGraphs::listAllPns
std::vector< int > listAllPns
Definition: EcalPnGraphs.h:57
edm::LogError
Definition: MessageLogger.h:183
edm::SortedCollection::end
const_iterator end() const
Definition: SortedCollection.h:267
EcalPnGraphs::first_Pn
int first_Pn
Definition: EcalPnGraphs.h:48
EcalPnGraphs::listPns
std::vector< int > listPns
Definition: EcalPnGraphs.h:56
EgammaValidation_cff.num
num
Definition: EgammaValidation_cff.py:34
overlapproblemtsosanalyzer_cfi.title
title
Definition: overlapproblemtsosanalyzer_cfi.py:7
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
EcalFedMap
Definition: EcalFedMap.h:7
EcalPnGraphs::digiProducer_
std::string digiProducer_
Definition: EcalPnGraphs.h:39
EcalPnGraphs::graphs
std::vector< TGraph > graphs
Definition: EcalPnGraphs.h:64
EcalFedMap::getFedFromSlice
int getFedFromSlice(std::string)
Definition: EcalFedMap.cc:96
cms::Exception
Definition: Exception.h:70
EcalPnGraphs::inputIsOk
bool inputIsOk
Definition: EcalPnGraphs.h:50
EcalPnGraphs::abscissa
int abscissa[50]
Definition: EcalPnGraphs.h:61
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37