CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Public Attributes | Private Attributes
CSCFileDumper Class Reference

#include <CSCFileDumper.h>

Inheritance diagram for CSCFileDumper:
edm::EDAnalyzer edm::EDConsumerBase

Public Member Functions

void analyze (const edm::Event &e, const edm::EventSetup &c)
 
 CSCFileDumper (const edm::ParameterSet &pset)
 
virtual ~CSCFileDumper (void)
 
- Public Member Functions inherited from edm::EDAnalyzer
 EDAnalyzer ()
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndex indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndex > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndex > &) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Public Attributes

std::map< int, FILE * > dump_files
 
std::string events
 
std::set< unsigned long > eventsToDump
 
int fedID_first
 
int fedID_last
 
std::string output
 

Private Attributes

std::string source_
 

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
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
CurrentProcessingContext const * currentContext () const
 
- 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 13 of file CSCFileDumper.h.

Constructor & Destructor Documentation

CSCFileDumper::CSCFileDumper ( const edm::ParameterSet pset)

Definition at line 23 of file CSCFileDumper.cc.

References event(), events, eventsToDump, fedID_first, fedID_last, edm::ParameterSet::getUntrackedParameter(), FEDNumbering::MAXCSCTFFEDID, FEDNumbering::MINCSCFEDID, output, source_, AlCaHLTBitMon_QueryRunRegistry::string, and tmp.

24 {
25  output = pset.getUntrackedParameter<std::string>("output");
28  events = pset.getUntrackedParameter<std::string>("events","");
29  source_ = pset.getUntrackedParameter<std::string>("source","rawDataCollector");
30 
31  if( events.length() ){
32  for(size_t pos1=0,pos2=events.find(",");;pos1=pos2+1,pos2=events.find(",",pos2+1)){
33  if( pos2!=std::string::npos ){
34  long event=0;
35  if( sscanf(events.substr(pos1,pos2-pos1).c_str(),"%ld",&event) == 1 && event>=0 )
36  eventsToDump.insert((unsigned long)event);
37  else
38  edm::LogError("CSCFileDumper")<<" cannot parse events ("<<events<<") parameter: "<<events.substr(pos1,pos2-pos1);
39  } else {
40  long event=0;
41  if( sscanf(events.substr(pos1,events.length()-pos1).c_str(),"%ld",&event) == 1 && event>=0 )
42  eventsToDump.insert((unsigned long)event);
43  else
44  edm::LogError("CSCFileDumper")<<" cannot parse events ("<<events<<") parameter: "<<events.substr(pos1,events.length()-pos1);
45  break;
46  }
47  }
48  std::ostringstream tmp;
49  for(std::set<unsigned long>::const_iterator evt=eventsToDump.begin(); evt!=eventsToDump.end(); evt++) tmp<<*evt<<" ";
50  edm::LogInfo("CSCFileDumper")<<" Following events will be dumped: "<<tmp.str();
51  } else
52  edm::LogInfo("CSCFileDumper")<<" All events will be dumped";
53 }
T getUntrackedParameter(std::string const &, T const &) const
std::string events
Definition: CSCFileDumper.h:19
std::string output
Definition: CSCFileDumper.h:19
std::set< unsigned long > eventsToDump
Definition: CSCFileDumper.h:16
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
std::string source_
Definition: CSCFileDumper.h:29
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
CSCFileDumper::~CSCFileDumper ( void  )
virtual

Definition at line 55 of file CSCFileDumper.cc.

References dump_files.

55  {
56  std::map<int,FILE*>::const_iterator stream = dump_files.begin();
57  while( stream != dump_files.end() ){
58  fclose(stream->second);
59  stream++;
60  }
61 }
std::map< int, FILE * > dump_files
Definition: CSCFileDumper.h:15

Member Function Documentation

void CSCFileDumper::analyze ( const edm::Event e,
const edm::EventSetup c 
)
virtual

Take a reference to this FED's data

Implements edm::EDAnalyzer.

Definition at line 63 of file CSCFileDumper.cc.

References FEDRawData::data(), dump_files, edm::EventID::event(), eventsToDump, fedID_first, fedID_last, mergeVDriftHistosByStation::file, edm::Event::getByLabel(), edm::EventBase::id(), mergeVDriftHistosByStation::name, NULL, output, lumiPlot::rawdata, FEDRawData::size(), findQualityFiles::size, and source_.

63  {
64  // Get a handle to the FED data collection
66 
67  // Get a handle to the FED data collection
68  e.getByLabel(source_, rawdata);
69 
70  for(int id=fedID_first; id<=fedID_last; ++id){ //for each of our DCCs
71  std::map<int,FILE*>::const_iterator stream = dump_files.find(id);
72  if( stream == dump_files.end() ){
73  std::ostringstream name;
74  name<<output<<"_"<<id<<std::ends;
75  FILE *file;
76  if( (file = fopen(name.str().c_str(),"wt"))==NULL ){
77  edm::LogError("CSCFileDumper")<<"Cannot open the file: "<<name.str();
78  continue;
79  } else
80  dump_files[id] = file;
81  stream = dump_files.find(id);
82  }
83 
85  const FEDRawData& fedData = rawdata->FEDData(id);
86  unsigned short int length = fedData.size();
87 
88  if( length && ( eventsToDump.empty() || eventsToDump.find( (unsigned long)e.id().event() )!=eventsToDump.end() ) ){
89  //std::cout<<"Event found for fed id:"<<id<<std::endl;
90  // Event buffer
91  size_t size=length/2;
92  const unsigned short *buf = (unsigned short *)fedData.data();
93  fwrite(buf,2,size,stream->second);
94  }
95  }
96 }
EventNumber_t event() const
Definition: EventID.h:44
#define NULL
Definition: scimark2.h:8
std::string output
Definition: CSCFileDumper.h:19
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:49
std::set< unsigned long > eventsToDump
Definition: CSCFileDumper.h:16
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:361
std::string source_
Definition: CSCFileDumper.h:29
edm::EventID id() const
Definition: EventBase.h:56
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:29
dictionary rawdata
Definition: lumiPlot.py:393
tuple size
Write out results.
std::map< int, FILE * > dump_files
Definition: CSCFileDumper.h:15

Member Data Documentation

std::map<int,FILE*> CSCFileDumper::dump_files

Definition at line 15 of file CSCFileDumper.h.

Referenced by analyze(), and ~CSCFileDumper().

std::string CSCFileDumper::events

Definition at line 19 of file CSCFileDumper.h.

Referenced by CSCFileDumper().

std::set<unsigned long> CSCFileDumper::eventsToDump

Definition at line 16 of file CSCFileDumper.h.

Referenced by analyze(), and CSCFileDumper().

int CSCFileDumper::fedID_first

Definition at line 20 of file CSCFileDumper.h.

Referenced by analyze(), and CSCFileDumper().

int CSCFileDumper::fedID_last

Definition at line 20 of file CSCFileDumper.h.

Referenced by analyze(), and CSCFileDumper().

std::string CSCFileDumper::output

Definition at line 19 of file CSCFileDumper.h.

Referenced by analyze(), and CSCFileDumper().

std::string CSCFileDumper::source_
private