CMS 3D CMS Logo

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

#include <FileReaderDDU.h>

Public Types

enum  {
  Header =1, Trailer =2, DDUoversize =4, FFFF =8,
  Unknown =16, EndOfStream =32
}
 
enum  {
  Type1 =Header|Trailer, Type2 =Header, Type3 =Header|DDUoversize, Type4 =Trailer,
  Type5 =Unknown, Type6 =Unknown|DDUoversize, Type7 =FFFF
}
 

Public Member Functions

void accept (unsigned int criteria) throw ()
 
 FileReaderDDU (void)
 
size_t next (const unsigned short *&buf, int prescaling=1) throw (std::runtime_error)
 
int open (const char *filename) throw (std::runtime_error)
 
size_t read (const unsigned short *&buf) throw (std::runtime_error)
 
void reject (unsigned int criteria) throw ()
 
void select (unsigned int criteria) throw ()
 
unsigned int status (void) const throw ()
 
virtual ~FileReaderDDU (void)
 

Private Attributes

unsigned int acceptCriteria
 
unsigned long long * end
 
unsigned int eventStatus
 
int fd
 
unsigned long long file_buffer [4000]
 
unsigned long long * file_buffer_end
 
unsigned short raw_event [200000]
 
unsigned int rejectCriteria
 
unsigned int selectCriteria
 
unsigned long long word_0
 
unsigned long long word_1
 
unsigned long long word_2
 

Detailed Description

Definition at line 7 of file FileReaderDDU.h.

Member Enumeration Documentation

anonymous enum
Enumerator
Header 
Trailer 
DDUoversize 
FFFF 
Unknown 
EndOfStream 

Definition at line 17 of file FileReaderDDU.h.

anonymous enum

Constructor & Destructor Documentation

FileReaderDDU::FileReaderDDU ( void  )

Definition at line 16 of file FileReaderDDU.cc.

References acceptCriteria, DDUoversize, end, eventStatus, fd, FFFF, file_buffer, file_buffer_end, raw_event, rejectCriteria, selectCriteria, AlCaHLTBitMon_QueryRunRegistry::string, Trailer, Unknown, word_0, word_1, and word_2.

16  {
17  if( sizeof(unsigned long long)!=8 || sizeof(unsigned short)!=2 )
18  throw std::runtime_error(std::string("Wrong platform: sizeof(unsigned long long)!=8 || sizeof(unsigned short)!=2"));
19  end = (file_buffer_end = file_buffer + sizeof(file_buffer)/sizeof(unsigned long long));
20  bzero(raw_event, sizeof(raw_event) );
21  bzero(file_buffer,sizeof(file_buffer));
22  word_0=0; word_1=0; word_2=0;
23  eventStatus = 0;
26  acceptCriteria = 0x3F; // Everything
27  fd = 0;
28 }
unsigned int rejectCriteria
Definition: FileReaderDDU.h:20
unsigned long long word_2
Definition: FileReaderDDU.h:11
unsigned short raw_event[200000]
Definition: FileReaderDDU.h:9
unsigned int acceptCriteria
Definition: FileReaderDDU.h:20
unsigned long long word_0
Definition: FileReaderDDU.h:11
unsigned long long * file_buffer_end
Definition: FileReaderDDU.h:14
unsigned int eventStatus
Definition: FileReaderDDU.h:20
unsigned long long file_buffer[4000]
Definition: FileReaderDDU.h:12
unsigned int selectCriteria
Definition: FileReaderDDU.h:20
unsigned long long word_1
Definition: FileReaderDDU.h:11
unsigned long long * end
Definition: FileReaderDDU.h:14
FileReaderDDU::~FileReaderDDU ( void  )
virtual

Definition at line 30 of file FileReaderDDU.cc.

References fd.

30 { if( fd ) close(fd); }

Member Function Documentation

void FileReaderDDU::accept ( unsigned int  criteria)
throw (
)
inline

Definition at line 29 of file FileReaderDDU.h.

References acceptCriteria.

Referenced by Vispa.Gui.BoxContentDialog.BoxContentDialog::apply(), and Vispa.Plugins.ConfigEditor.ToolDialog.ToolDialog::apply().

29 { acceptCriteria = criteria; } // return all events satisfying any of criteria
unsigned int acceptCriteria
Definition: FileReaderDDU.h:20
size_t FileReaderDDU::next ( const unsigned short *&  buf,
int  prescaling = 1 
)
throw (std::runtime_error
)

Definition at line 124 of file FileReaderDDU.cc.

References i, SiPixelLorentzAngle_cfi::read, and findQualityFiles::size.

Referenced by CSCFileReader::readRUI().

124  {
125  size_t size=0;
126  for(int i=0; i<prescaling; i++){
127  do {
128  if( (size = read(buf)) == 0 ) break;
130  }
131  return size;
132 }
unsigned int rejectCriteria
Definition: FileReaderDDU.h:20
int i
Definition: DBlmapReader.cc:9
size_t read(const unsigned short *&buf)
unsigned int acceptCriteria
Definition: FileReaderDDU.h:20
unsigned int eventStatus
Definition: FileReaderDDU.h:20
unsigned int selectCriteria
Definition: FileReaderDDU.h:20
tuple size
Write out results.
int FileReaderDDU::open ( const char *  filename)
throw (std::runtime_error
)

Definition at line 32 of file FileReaderDDU.cc.

References python.multivaluedict::append(), lut2db_cfg::filename, O_LARGEFILE, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by CSCFileReader::CSCFileReader(), and CSCFileReader::readRUI().

32  {
33  if( fd ) close(fd);
34  fd = ::open(filename,O_RDONLY|O_LARGEFILE);
35  if( fd == -1 ) throw ( std::runtime_error(std::string("Error opening ").append(filename).append(" data file.")) );
36  return fd;
37 }
#define O_LARGEFILE
tuple filename
Definition: lut2db_cfg.py:20
int open(const char *filename)
size_t FileReaderDDU::read ( const unsigned short *&  buf)
throw (std::runtime_error
)

Definition at line 39 of file FileReaderDDU.cc.

References end, event(), SiPixelLorentzAngle_cfi::read, dqm_diff::start, and Unknown.

39  {
40  // Check for ubnormal situation
41  if( end>file_buffer_end || end<file_buffer ) throw ( std::runtime_error("Error of reading") );
42  if( !fd ) throw ( std::runtime_error("Open some file first") );
43 
44  unsigned long long *start = end;
45  unsigned short *event = raw_event;
46 
47  eventStatus = 0;
48  size_t dduWordCount = 0;
49  end = 0;
50 
51  while( !end && dduWordCount<50000 ){
52  unsigned long long *dduWord = start;
53  unsigned long long preHeader = 0;
54 
55  // Did we reach end of current buffer and want to read next block?
56  // If it was first time and we don't have file buffer then we won't get inside
57  while( dduWord<file_buffer_end && dduWordCount<50000 ){
58  word_0 = word_1; // delay by 2 DDU words
59  word_1 = word_2; // delay by 1 DDU word
60  word_2 = *dduWord;// current DDU word
61  if( (word_2&0xFFFFFFFFFFFF0000LL)==0x8000000180000000LL ){
62  if( eventStatus&Header ){ // Second header
63  word_2 = word_1; // Fall back to get rigth preHeader next time
64  end = dduWord; // Even if we end with preHeader of next evet put it to the end of this event too
65  break;
66  }
67  if( dduWordCount>1 ){ // Extra words between trailer and header
68  if( (word_0&0xFFFFFFFFFFFF0000LL)==0xFFFFFFFFFFFF0000LL ) eventStatus |= FFFF;
69  word_2 = word_1; // Fall back to get rigth preHeader next time
70  end = dduWord;
71  break;
72  }
74  if( event==raw_event ) preHeader = word_1; // If preHeader not yet in event then put it there
75  start = dduWord;
76  }
77  if( (word_0&0xFFFFFFFFFFFF0000LL)==0x8000FFFF80000000LL ){
79  end = ++dduWord;
80  break;
81  }
82  // Increase counters by one DDU word
83  dduWord++;
84  dduWordCount++;
85  }
86 
87  // If have DDU Header
88  if( preHeader ){
89  // Need to account first word of DDU Header
90  memcpy(event,&preHeader,sizeof(preHeader));
91  event += sizeof(preHeader)/sizeof(unsigned short);
92  }
93 
94  // Take care of the rest
95  memcpy(event,start,(dduWord-start)*sizeof(unsigned long long));
96  event += (dduWord-start)*sizeof(unsigned long long)/sizeof(unsigned short);
97 
98  // If reach max length
99  if( dduWordCount==50000 ){ end = dduWord; break; }
100 
101  if( !end ){
102  // Need to read next block for the rest of this event
103  ssize_t length = ::read(fd,file_buffer,sizeof(file_buffer));
104  if( length==-1 ) throw ( std::runtime_error("Error of reading") );
105  if( length== 0 ){
107  end = (file_buffer_end = file_buffer + sizeof(file_buffer)/sizeof(unsigned long long));
108  break;
109  }
110  file_buffer_end = file_buffer + length/sizeof(unsigned long long);
111 
112  // Will start from the beginning of new buffer next time we read it
113  start = file_buffer;
114  }
115  }
116 
117  if( !end ) eventStatus |= DDUoversize;
118  if( !(eventStatus&Header) && !(eventStatus&Trailer) && !(eventStatus&FFFF) ) eventStatus |= Unknown;
119 
120  buf = (const unsigned short*)raw_event;
121  return (eventStatus&FFFF?event-raw_event-4:event-raw_event);
122 }
tuple start
Check for commandline option errors.
Definition: dqm_diff.py:58
unsigned long long word_2
Definition: FileReaderDDU.h:11
size_t read(const unsigned short *&buf)
unsigned short raw_event[200000]
Definition: FileReaderDDU.h:9
unsigned long long word_0
Definition: FileReaderDDU.h:11
unsigned long long * file_buffer_end
Definition: FileReaderDDU.h:14
unsigned int eventStatus
Definition: FileReaderDDU.h:20
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
unsigned long long file_buffer[4000]
Definition: FileReaderDDU.h:12
unsigned long long word_1
Definition: FileReaderDDU.h:11
unsigned long long * end
Definition: FileReaderDDU.h:14
void FileReaderDDU::reject ( unsigned int  criteria)
throw (
)
inline

Definition at line 30 of file FileReaderDDU.h.

References rejectCriteria.

Referenced by CSCFileReader::CSCFileReader(), and Vispa.Plugins.ConfigEditor.ToolDialog.ToolDialog::keyPressEvent().

30 { rejectCriteria = criteria; } // return events not satisfying any of criteria
unsigned int rejectCriteria
Definition: FileReaderDDU.h:20
void FileReaderDDU::select ( unsigned int  criteria)
throw (
)
inline

Definition at line 28 of file FileReaderDDU.h.

References selectCriteria.

Referenced by CSCFileReader::CSCFileReader().

28 { selectCriteria = criteria; } // return events satisfying all criteria
unsigned int selectCriteria
Definition: FileReaderDDU.h:20
unsigned int FileReaderDDU::status ( void  ) const
throw (
)
inline

Definition at line 32 of file FileReaderDDU.h.

References eventStatus.

32 { return eventStatus; }
unsigned int eventStatus
Definition: FileReaderDDU.h:20

Member Data Documentation

unsigned int FileReaderDDU::acceptCriteria
private

Definition at line 20 of file FileReaderDDU.h.

Referenced by accept(), and FileReaderDDU().

unsigned long long* FileReaderDDU::end
private
unsigned int FileReaderDDU::eventStatus
private

Definition at line 20 of file FileReaderDDU.h.

Referenced by FileReaderDDU(), and status().

int FileReaderDDU::fd
private
unsigned long long FileReaderDDU::file_buffer[4000]
private

Definition at line 12 of file FileReaderDDU.h.

Referenced by FileReaderDDU().

unsigned long long * FileReaderDDU::file_buffer_end
private

Definition at line 14 of file FileReaderDDU.h.

Referenced by FileReaderDDU().

unsigned short FileReaderDDU::raw_event[200000]
private

Definition at line 9 of file FileReaderDDU.h.

Referenced by FileReaderDDU().

unsigned int FileReaderDDU::rejectCriteria
private

Definition at line 20 of file FileReaderDDU.h.

Referenced by FileReaderDDU(), and reject().

unsigned int FileReaderDDU::selectCriteria
private

Definition at line 20 of file FileReaderDDU.h.

Referenced by FileReaderDDU(), and select().

unsigned long long FileReaderDDU::word_0
private

Definition at line 11 of file FileReaderDDU.h.

Referenced by FileReaderDDU().

unsigned long long FileReaderDDU::word_1
private

Definition at line 11 of file FileReaderDDU.h.

Referenced by FileReaderDDU().

unsigned long long FileReaderDDU::word_2
private

Definition at line 11 of file FileReaderDDU.h.

Referenced by FileReaderDDU().