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
 
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)
 

Protected Attributes

int abscissa [50]
 
edm::EDGetTokenT< EcalPnDiodeDigiCollectiondigiProducer_
 
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 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, 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_ = consumes<EcalPnDiodeDigiCollection>(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  edm::LogVerbatim("EcalTools") << "[EcalPnGraphs] pn number : " << (*fedIter)
78  << " found in listFeds. Valid range is [601-654]. Returning.";
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  edm::LogVerbatim("EcalTools") << "[EcalPnGraphs] pn number : " << (*intIter)
91  << " found in listPns. Valid range is 1-10. Returning.";
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 }
Log< level::Info, true > LogVerbatim
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
int abscissa[50]
Definition: EcalPnGraphs.h:54
int getFedFromSlice(std::string)
Definition: EcalFedMap.cc:96
std::vector< int > feds_
Definition: EcalPnGraphs.h:37
T getUntrackedParameter(std::string const &, T const &) const
std::string fileName
Definition: EcalPnGraphs.h:45
EcalFedMap * fedMap
Definition: EcalPnGraphs.h:32
Log< level::Info, false > LogInfo
std::vector< std::string > ebs_
Definition: EcalPnGraphs.h:38
std::vector< int > listPns
Definition: EcalPnGraphs.h:49
edm::EDGetTokenT< EcalPnDiodeDigiCollection > digiProducer_
Definition: EcalPnGraphs.h:35

◆ ~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(), edm::HandleBase::isValid(), 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
133  const edm::Handle<EcalPnDiodeDigiCollection>& pn_digis = e.getHandle(digiProducer_);
134  if (!pn_digis.isValid()) {
135  edm::LogError("EcalPnGraphs") << "PNs were not found!";
136  }
137 
138  // getting the list of all the Pns which will be dumped on TGraph
139  // - listPns is the list as given by the user
140  // -numPn is the number of Pns (centered at Pn from listPns) for which graphs are required
141  std::vector<int>::iterator pn_it;
142  for (pn_it = listPns.begin(); pn_it != listPns.end(); pn_it++) {
143  int ipn = (*pn_it);
144  int hpn = numPn;
145 
146  for (int u = (-hpn); u <= hpn; u++) {
147  int ipn_c = ipn + u;
148  if (ipn_c < 1 || ipn_c > 10)
149  continue;
150  std::vector<int>::iterator notInList = find(listAllPns.begin(), listAllPns.end(), ipn_c);
151  if (notInList == listAllPns.end()) {
152  listAllPns.push_back(ipn_c);
153  }
154  }
155  }
156 
157  //Loop over PN digis
158  for (EcalPnDiodeDigiCollection::const_iterator pnItr = pn_digis->begin(); pnItr != pn_digis->end(); ++pnItr) {
159  //Get PNid of a digi
160  int ipn = (*pnItr).id().iPnId();
161  //Get DCC id where the digi is from
162  int ieb = EcalPnDiodeDetId((*pnItr).id()).iDCCId();
163 
164  //Make sure that these are PnDigis from the requested FEDid
165  int FEDid = ieb + 600;
166 
167  std::vector<int>::iterator fedIter = find(feds_.begin(), feds_.end(), FEDid);
168 
169  if (fedIter == feds_.end()) {
170  edm::LogWarning("EcalPnGraphs") << "For Event " << eventCounter
171  << " PnDigis are not found from requested SM!. returning...";
172  return;
173  }
174  // selecting desired Pns only
175  std::vector<int>::iterator iPnIter;
176  iPnIter = find(listAllPns.begin(), listAllPns.end(), ipn);
177  if (iPnIter == listAllPns.end())
178  continue;
179 
180  for (int i = 0; i < (*pnItr).size() && i < 50; ++i) {
181  ordinate[i] = (*pnItr).sample(i).adc();
182  }
183  //make grapn of ph digis
184  TGraph oneGraph(50, abscissa, ordinate);
186  title = "Graph_ev" + intToString(eventCounter) + "_FED" + intToString(FEDid) + "_ipn" + intToString(ipn);
187  oneGraph.SetTitle(title.c_str());
188  oneGraph.SetName(title.c_str());
189  graphs.push_back(oneGraph);
190 
191  } // loop over Pn digis
192 }
int abscissa[50]
Definition: EcalPnGraphs.h:54
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:37
const_iterator begin() const
std::vector< TGraph > graphs
Definition: EcalPnGraphs.h:57
int ordinate[50]
Definition: EcalPnGraphs.h:55
const_iterator end() const
std::vector< int > listAllPns
Definition: EcalPnGraphs.h:50
bool isValid() const
Definition: HandleBase.h:70
std::vector< int > listPns
Definition: EcalPnGraphs.h:49
Log< level::Warning, false > LogWarning
edm::EDGetTokenT< EcalPnDiodeDigiCollection > digiProducer_
Definition: EcalPnGraphs.h:35

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

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

Referenced by o2olib.O2ORunMgr::executeJob().

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

◆ intToString()

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

Definition at line 194 of file EcalPnGraphs.cc.

References EgammaValidation_cff::num.

Referenced by analyze(), and endJob().

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

Member Data Documentation

◆ abscissa

int EcalPnGraphs::abscissa[50]
protected

Definition at line 54 of file EcalPnGraphs.h.

Referenced by analyze(), and EcalPnGraphs().

◆ digiProducer_

edm::EDGetTokenT<EcalPnDiodeDigiCollection> EcalPnGraphs::digiProducer_
protected

Definition at line 35 of file EcalPnGraphs.h.

Referenced by analyze(), and EcalPnGraphs().

◆ ebs_

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

Definition at line 38 of file EcalPnGraphs.h.

Referenced by EcalPnGraphs().

◆ eventCounter

int EcalPnGraphs::eventCounter
protected

Definition at line 41 of file EcalPnGraphs.h.

Referenced by analyze(), and EcalPnGraphs().

◆ fedMap

EcalFedMap* EcalPnGraphs::fedMap
private

Definition at line 32 of file EcalPnGraphs.h.

Referenced by EcalPnGraphs().

◆ feds_

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

Definition at line 37 of file EcalPnGraphs.h.

Referenced by analyze(), and EcalPnGraphs().

◆ fileName

std::string EcalPnGraphs::fileName
protected

Definition at line 45 of file EcalPnGraphs.h.

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

◆ first_Pn

int EcalPnGraphs::first_Pn
protected

Definition at line 42 of file EcalPnGraphs.h.

Referenced by EcalPnGraphs(), and endJob().

◆ graphs

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

Definition at line 57 of file EcalPnGraphs.h.

Referenced by analyze(), and endJob().

◆ inputIsOk

bool EcalPnGraphs::inputIsOk
protected

Definition at line 43 of file EcalPnGraphs.h.

Referenced by analyze(), and EcalPnGraphs().

◆ listAllChannels

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

Definition at line 48 of file EcalPnGraphs.h.

◆ listAllPns

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

Definition at line 50 of file EcalPnGraphs.h.

Referenced by analyze().

◆ listChannels

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

Definition at line 47 of file EcalPnGraphs.h.

◆ listPns

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

Definition at line 49 of file EcalPnGraphs.h.

Referenced by analyze(), and EcalPnGraphs().

◆ numPn

int EcalPnGraphs::numPn
protected

Definition at line 52 of file EcalPnGraphs.h.

Referenced by analyze(), and EcalPnGraphs().

◆ ordinate

int EcalPnGraphs::ordinate[50]
protected

Definition at line 55 of file EcalPnGraphs.h.

Referenced by analyze().

◆ root_file

TFile* EcalPnGraphs::root_file
protected

Definition at line 59 of file EcalPnGraphs.h.

Referenced by endJob().

◆ verbosity

int EcalPnGraphs::verbosity
protected

Definition at line 40 of file EcalPnGraphs.h.