#include <EcalPnGraphs.h>
Public Member Functions | |
EcalPnGraphs (const edm::ParameterSet &ps) | |
~EcalPnGraphs () | |
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 | |
EcalFedMap * | fedMap |
Definition at line 22 of file EcalPnGraphs.h.
EcalPnGraphs::EcalPnGraphs | ( | const edm::ParameterSet & | ps | ) |
module dumping TGraph with 50 data frames from Pn Diodes
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, numPn, and AlCaHLTBitMon_QueryRunRegistry::string.
{ //============================================================================= digiProducer_ = ps.getParameter<std::string>("digiProducer"); fileName = ps.getUntrackedParameter<std::string >("fileName", std::string("toto") ); first_Pn = 0; listPns = ps.getUntrackedParameter<std::vector<int> >("listPns", std::vector<int>()); numPn = ps.getUntrackedParameter< int >("numPn"); std::vector<int> listDefaults; listDefaults.push_back(-1); feds_ = ps.getUntrackedParameter<std::vector<int> > ("requestedFeds",listDefaults); bool fedIsGiven = false; std::vector<std::string> ebDefaults; ebDefaults.push_back("none"); ebs_ = ps.getUntrackedParameter<std::vector<std::string> >("requestedEbs",ebDefaults); //FEDs and EBs if ( feds_[0] != -1 ) { edm::LogInfo("EcalPnGraphs") << "FED id is given! Goining to beginJob! "; fedIsGiven = true; }else { feds_.clear(); if ( ebs_[0] !="none" ) { //EB id is given and convert to FED id fedMap = new EcalFedMap(); for (std::vector<std::string>::const_iterator ebItr = ebs_.begin(); ebItr!= ebs_.end(); ++ebItr) { feds_.push_back(fedMap->getFedFromSlice(*ebItr)); } delete fedMap; } else { //Select all FEDs in the Event for ( int i=601; i<655; ++i){ feds_.push_back(i); } } } // consistency checks checks inputIsOk = true; //check with FEDs if ( fedIsGiven ) { std::vector<int>::iterator fedIter; for (fedIter = feds_.begin(); fedIter!=feds_.end(); ++fedIter) { if ( (*fedIter) < 601 || (*fedIter) > 654) { std::cout << "[EcalPnGraphs] pn number : " << (*fedIter) << " found in listFeds. " << " Valid range is [601-654]. Returning." << std::endl; inputIsOk = false; return; } } } //Check with Pns if ( listPns[0] != -1 ) { std::vector<int>::iterator intIter; for (intIter = listPns.begin(); intIter != listPns.end(); intIter++) { if ( ((*intIter) < 1) || (10 < (*intIter)) ) { std::cout << "[EcalPnGraphs] pn number : " << (*intIter) << " found in listPns. " << " Valid range is 1-10. Returning." << std::endl; inputIsOk = false; return; } if (!first_Pn ) first_Pn = (*intIter); } } else { listPns.clear(); listPns.push_back(5); listPns.push_back(6); } // setting the abcissa array once for all for (int i=0; i<50; i++) abscissa[i] = i; // local event counter (in general different from LV1) eventCounter =0; }
EcalPnGraphs::~EcalPnGraphs | ( | ) |
Definition at line 117 of file EcalPnGraphs.cc.
{ //============================================================================= //delete *; }
void EcalPnGraphs::analyze | ( | const edm::Event & | e, |
const edm::EventSetup & | c | ||
) | [private, virtual] |
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, AlCaHLTBitMon_QueryRunRegistry::string, and indexGen::title.
{ //============================================================================= eventCounter++; if (!inputIsOk) return; // retrieving crystal PN diodes from Event edm::Handle<EcalPnDiodeDigiCollection> pn_digis; try { e.getByLabel(digiProducer_, pn_digis); } catch (cms::Exception& ex) { edm::LogError("EcalPnGraphs") << "PNs were not found!"; } // getting the list of all the Pns which will be dumped on TGraph // - listPns is the list as given by the user // -numPn is the number of Pns (centered at Pn from listPns) for which graphs are required std::vector<int>::iterator pn_it; for ( pn_it = listPns.begin(); pn_it != listPns.end() ; pn_it++ ) { int ipn = (*pn_it); int hpn = numPn; for (int u = (-hpn) ; u<=hpn; u++){ int ipn_c = ipn + u; if (ipn_c < 1 || ipn_c > 10) continue; std::vector<int>::iterator notInList = find(listAllPns.begin(), listAllPns.end(), ipn_c); if ( notInList == listAllPns.end() ) { listAllPns.push_back ( ipn_c ); } } } //Loop over PN digis for ( EcalPnDiodeDigiCollection::const_iterator pnItr = pn_digis->begin(); pnItr != pn_digis->end(); ++pnItr ) { //Get PNid of a digi int ipn = (*pnItr).id().iPnId(); //Get DCC id where the digi is from int ieb = EcalPnDiodeDetId((*pnItr).id()).iDCCId(); //Make sure that these are PnDigis from the requested FEDid int FEDid = ieb + 600; std::vector<int>::iterator fedIter = find(feds_.begin(), feds_.end(), FEDid); if ( fedIter == feds_.end() ) { edm::LogWarning("EcalPnGraphs")<< "For Event " << eventCounter << " PnDigis are not found from requested SM!. returning..."; return; } // selecting desired Pns only std::vector<int>::iterator iPnIter; iPnIter = find( listAllPns.begin() , listAllPns.end() , ipn); if (iPnIter == listAllPns.end()) continue; for ( int i=0; i< (*pnItr).size() && i<50; ++i ) { ordinate[i] = (*pnItr).sample(i).adc(); } //make grapn of ph digis TGraph oneGraph(50, abscissa,ordinate); std::string title; title = "Graph_ev" + intToString( eventCounter ) + "_FED" + intToString( FEDid ) + "_ipn" + intToString( ipn ); oneGraph.SetTitle(title.c_str()); oneGraph.SetName(title.c_str()); graphs.push_back(oneGraph); }// loop over Pn digis }
void EcalPnGraphs::beginJob | ( | void | ) | [private, virtual] |
Reimplemented from edm::EDAnalyzer.
Definition at line 123 of file EcalPnGraphs.cc.
{ //============================================================================= edm::LogInfo("EcalPhGraphs") << "entering beginJob! " ; }
void EcalPnGraphs::endJob | ( | void | ) | [private, virtual] |
Reimplemented from edm::EDAnalyzer.
Definition at line 212 of file EcalPnGraphs.cc.
References fileName, first_Pn, graphs, intToString(), root_file, and AlCaHLTBitMon_QueryRunRegistry::string.
{ //============================================================================= fileName += ( std::string("_Pn") + intToString(first_Pn) ); fileName += ".graph.root"; root_file = new TFile( fileName.c_str() , "RECREATE" ); std::vector<TGraph>::iterator gr_it; for ( gr_it = graphs.begin(); gr_it != graphs.end(); gr_it++ ) (*gr_it).Write(); root_file->Close(); edm::LogInfo("EcalPnGraphs") << "DONE!.... " ; }
std::string EcalPnGraphs::intToString | ( | int | num | ) | [private] |
Definition at line 199 of file EcalPnGraphs.cc.
Referenced by analyze(), and endJob().
{ // // outputs the number into the string stream and then flushes // the buffer (makes sure the output is put into the stream) // std::ostringstream myStream; //creates an ostringstream object myStream << num << std::flush; return(myStream.str()); //returns the string form of the stringstream object }
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.
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.