test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 ()
 
- Public Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

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

virtual void analyze (const edm::Event &e, const edm::EventSetup &c)
 
virtual void beginJob ()
 
virtual void endJob ()
 
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 &)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
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 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)
 

Detailed Description

Definition at line 22 of file EcalPnGraphs.h.

Constructor & Destructor Documentation

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

module dumping TGraph with 50 data frames from Pn Diodes

Author
K. Kaadze
G. Franzoni

Definition at line 31 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(), i, inputIsOk, listPns, numPn, and AlCaHLTBitMon_QueryRunRegistry::string.

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

Definition at line 115 of file EcalPnGraphs.cc.

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

Member Function Documentation

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

Implements edm::EDAnalyzer.

Definition at line 127 of file EcalPnGraphs.cc.

References abscissa, digiProducer_, eventCounter, feds_, spr::find(), edm::Event::getByLabel(), graphs, i, inputIsOk, intToString(), listAllPns, listPns, numPn, ordinate, AlCaHLTBitMon_QueryRunRegistry::string, and indexGen::title.

127  {
128 //=============================================================================
129 
130  eventCounter++;
131  if (!inputIsOk) 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  {
147  int ipn = (*pn_it);
148  int hpn = numPn;
149 
150  for (int u = (-hpn) ; u<=hpn; u++){
151  int ipn_c = ipn + u;
152  if (ipn_c < 1 || ipn_c > 10) 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 << " 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()) continue;
180 
181  for ( int i=0; i< (*pnItr).size() && i<50; ++i ) {
182  ordinate[i] = (*pnItr).sample(i).adc();
183  }
184  //make grapn of ph digis
185  TGraph oneGraph(50, abscissa,ordinate);
187  title = "Graph_ev" + intToString( eventCounter )
188  + "_FED" + intToString( FEDid )
189  + "_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 }
int i
Definition: DBlmapReader.cc:9
int abscissa[50]
Definition: EcalPnGraphs.h:67
std::vector< EcalPnDiodeDigi >::const_iterator const_iterator
std::string intToString(int num)
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
std::vector< int > feds_
Definition: EcalPnGraphs.h:46
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:420
std::vector< TGraph > graphs
Definition: EcalPnGraphs.h:70
int ordinate[50]
Definition: EcalPnGraphs.h:68
std::string digiProducer_
Definition: EcalPnGraphs.h:44
std::vector< int > listAllPns
Definition: EcalPnGraphs.h:63
std::vector< int > listPns
Definition: EcalPnGraphs.h:62
void EcalPnGraphs::beginJob ( void  )
privatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 121 of file EcalPnGraphs.cc.

121  {
122 //=============================================================================
123  edm::LogInfo("EcalPhGraphs") << "entering beginJob! " ;
124 }
void EcalPnGraphs::endJob ( void  )
privatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 210 of file EcalPnGraphs.cc.

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

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

Definition at line 197 of file EcalPnGraphs.cc.

Referenced by analyze(), and endJob().

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

Member Data Documentation

int EcalPnGraphs::abscissa[50]
protected

Definition at line 67 of file EcalPnGraphs.h.

Referenced by analyze(), and EcalPnGraphs().

std::string EcalPnGraphs::digiProducer_
protected

Definition at line 44 of file EcalPnGraphs.h.

Referenced by analyze(), and EcalPnGraphs().

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

Definition at line 47 of file EcalPnGraphs.h.

Referenced by EcalPnGraphs().

int EcalPnGraphs::eventCounter
protected

Definition at line 50 of file EcalPnGraphs.h.

Referenced by analyze(), and EcalPnGraphs().

EcalFedMap* EcalPnGraphs::fedMap
private

Definition at line 38 of file EcalPnGraphs.h.

Referenced by EcalPnGraphs().

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

Definition at line 46 of file EcalPnGraphs.h.

Referenced by analyze(), and EcalPnGraphs().

std::string EcalPnGraphs::fileName
protected

Definition at line 58 of file EcalPnGraphs.h.

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

int EcalPnGraphs::first_Pn
protected

Definition at line 53 of file EcalPnGraphs.h.

Referenced by EcalPnGraphs(), and endJob().

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

Definition at line 70 of file EcalPnGraphs.h.

Referenced by analyze(), and endJob().

bool EcalPnGraphs::inputIsOk
protected

Definition at line 56 of file EcalPnGraphs.h.

Referenced by analyze(), and EcalPnGraphs().

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

Definition at line 61 of file EcalPnGraphs.h.

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

Definition at line 63 of file EcalPnGraphs.h.

Referenced by analyze().

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

Definition at line 60 of file EcalPnGraphs.h.

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

Definition at line 62 of file EcalPnGraphs.h.

Referenced by analyze(), and EcalPnGraphs().

int EcalPnGraphs::numPn
protected

Definition at line 65 of file EcalPnGraphs.h.

Referenced by analyze(), and EcalPnGraphs().

int EcalPnGraphs::ordinate[50]
protected

Definition at line 68 of file EcalPnGraphs.h.

Referenced by analyze().

TFile* EcalPnGraphs::root_file
protected

Definition at line 72 of file EcalPnGraphs.h.

Referenced by endJob().

int EcalPnGraphs::verbosity
protected

Definition at line 49 of file EcalPnGraphs.h.