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

Public Member Functions

 EcalPnGraphs (const edm::ParameterSet &ps)
 
 ~EcalPnGraphs ()
 
- Public Member Functions inherited from edm::EDAnalyzer
 EDAnalyzer ()
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 

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
 
typedef WorkerT< EDAnalyzerWorkerType
 
- 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::EDAnalyzer
CurrentProcessingContext const * currentContext () const
 

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

Date:
2011/10/10 09:05:21
Revision:
1.4
Author
K. Kaadze
G. Franzoni

Definition at line 33 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, and numPn.

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

117  {
118 //=============================================================================
119  //delete *;
120 }

Member Function Documentation

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

Implements edm::EDAnalyzer.

Definition at line 129 of file EcalPnGraphs.cc.

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

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

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

Reimplemented from edm::EDAnalyzer.

Definition at line 212 of file EcalPnGraphs.cc.

References fileName, first_Pn, graphs, intToString(), and root_file.

212  {
213 //=============================================================================
214  fileName += ( std::string("_Pn") + intToString(first_Pn) );
215  fileName += ".graph.root";
216 
217  root_file = new TFile( fileName.c_str() , "RECREATE" );
218  std::vector<TGraph>::iterator gr_it;
219  for ( gr_it = graphs.begin(); gr_it != graphs.end(); gr_it++ ) (*gr_it).Write();
220  root_file->Close();
221 
222  edm::LogInfo("EcalPnGraphs") << "DONE!.... " ;
223 }
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 199 of file EcalPnGraphs.cc.

Referenced by analyze(), and endJob().

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

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(), and endJob().

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.