CMS 3D CMS Logo

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

#include <IORawData/SiPixelInputSources/src/PixelSLinkDataInputSource.cc>

Inheritance diagram for PixelSLinkDataInputSource:
edm::ExternalInputSource edm::ConfigurableInputSource edm::InputSource edm::ProductRegistryHelper

Public Member Functions

 PixelSLinkDataInputSource (const edm::ParameterSet &pset, const edm::InputSourceDescription &desc)
 
bool produce (edm::Event &event)
 
virtual ~PixelSLinkDataInputSource ()
 
- Public Member Functions inherited from edm::ExternalInputSource
InputFileCatalogcatalog ()
 
 ExternalInputSource (ParameterSet const &pset, InputSourceDescription const &desc, bool realData=true)
 
std::vector< std::string > const & fileNames () const
 
std::vector< std::string > const & logicalFileNames () const
 
virtual ~ExternalInputSource ()
 
- Public Member Functions inherited from edm::ConfigurableInputSource
 ConfigurableInputSource (ParameterSet const &pset, InputSourceDescription const &desc, bool realData=true)
 
EventNumber_t event () const
 
unsigned int eventCreationDelay () const
 
LuminosityBlockNumber_t luminosityBlock () const
 
unsigned int numberEventsInLumi () const
 
unsigned int numberEventsInRun () const
 
unsigned int numberEventsInThisLumi () const
 
unsigned int numberEventsInThisRun () const
 
TimeValue_t presentTime () const
 
RunNumber_t run () const
 
unsigned int timeBetweenEvents () const
 
virtual ~ConfigurableInputSource ()
 
- Public Member Functions inherited from edm::InputSource
boost::shared_ptr
< ActivityRegistry
actReg () const
 Accessor for Activity Registry. More...
 
void closeFile (boost::shared_ptr< FileBlock >)
 close current file More...
 
void doBeginJob ()
 Called by framework at beginning of job. More...
 
void doBeginLumi (LuminosityBlockPrincipal &lbp)
 Called by framework at beginning of lumi block. More...
 
void doBeginRun (RunPrincipal &rp)
 Called by framework at beginning of run. More...
 
void doEndJob ()
 Called by framework at end of job. More...
 
void doEndLumi (LuminosityBlockPrincipal &lbp)
 Called by framework at end of lumi block. More...
 
void doEndRun (RunPrincipal &rp)
 Called by framework at end of run. More...
 
void doPostForkReacquireResources (boost::shared_ptr< multicore::MessageReceiverForSource >)
 
void doPreForkReleaseResources ()
 Called by the framework before forking the process. More...
 
ProcessingController::ForwardState forwardState () const
 
bool goToEvent (EventID const &eventID)
 
 InputSource (ParameterSet const &, InputSourceDescription const &)
 Constructor. More...
 
void issueReports (EventID const &eventID)
 issue an event report More...
 
LuminosityBlockNumber_t luminosityBlock () const
 Accessor for current luminosity block number. More...
 
boost::shared_ptr
< LuminosityBlockAuxiliary
luminosityBlockAuxiliary () const
 Called by the framework to merge or insert lumi in principal cache. More...
 
int markLumi ()
 Mark lumi as read. More...
 
int markRun ()
 Mark run as read. More...
 
int maxEvents () const
 
int maxLuminosityBlocks () const
 
ModuleDescription const & moduleDescription () const
 Accessor for 'module' description. More...
 
ItemType nextItemType ()
 
bool const primary () const
 Accessor for primary input source flag. More...
 
ProcessConfiguration const & processConfiguration () const
 Accessor for Process Configuration. More...
 
std::string const & processGUID () const
 Accessor for global process identifier. More...
 
ProcessHistoryID const & processHistoryID () const
 Accessor for the input process history ID of the current run. More...
 
ProcessingMode processingMode () const
 RunsLumisAndEvents (default), RunsAndLumis, or Runs. More...
 
boost::shared_ptr
< ProductRegistry const > 
productRegistry () const
 Accessor for product registry. More...
 
bool randomAccess () const
 
void readAndCacheLumi ()
 Read next luminosity block. More...
 
void readAndCacheRun ()
 Read next run. More...
 
EventPrincipalreadEvent (boost::shared_ptr< LuminosityBlockPrincipal > lbCache)
 
EventPrincipalreadEvent (EventID const &)
 Read a specific event. More...
 
boost::shared_ptr< FileBlockreadFile ()
 Read next file. More...
 
boost::shared_ptr
< LuminosityBlockAuxiliary
readLuminosityBlockAuxiliary ()
 Read next luminosity block Auxilary. More...
 
boost::shared_ptr< RunAuxiliaryreadRunAuxiliary ()
 Read next run Auxiliary. More...
 
void registerProducts ()
 Register any produced products. More...
 
int remainingEvents () const
 
int remainingLuminosityBlocks () const
 
void repeat ()
 Reset the remaining number of events/lumis to the maximum number. More...
 
ProcessingController::ReverseState reverseState () const
 
void rewind ()
 Begin again at the first event. More...
 
RunNumber_t run () const
 Accessor for current run number. More...
 
boost::shared_ptr< RunAuxiliaryrunAuxiliary () const
 Called by the framework to merge or insert run in principal cache. More...
 
void setLuminosityBlockNumber_t (LuminosityBlockNumber_t lb)
 Set the luminosity block ID. More...
 
void setRunNumber (RunNumber_t r)
 Set the run number. More...
 
void skipEvents (int offset)
 
Timestamp const & timestamp () const
 Accessor for the current time, as seen by the input source. More...
 
void wakeUp ()
 Wake up the input source. More...
 
virtual ~InputSource ()
 Destructor. More...
 

Private Member Functions

int getEventNumberFromFillWords (std::vector< uint64_t > data, uint32_t &totword)
 
uint32_t synchronizeEvents ()
 

Private Attributes

uint32_t m_currenteventnumber
 
uint32_t m_currenttriggernumber
 
uint64_t m_data
 
int32_t m_eventnumber_shift
 
int m_fedid
 
uint32_t m_fileindex
 
uint32_t m_globaleventnumber
 
int m_runnumber
 
std::auto_ptr< Storagestorage
 

Additional Inherited Members

- Public Types inherited from edm::InputSource
enum  ItemType {
  IsInvalid, IsStop, IsFile, IsRun,
  IsLumi, IsEvent, IsRepeat
}
 
enum  ProcessingMode { Runs, RunsAndLumis, RunsLumisAndEvents }
 
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Static Public Member Functions inherited from edm::ExternalInputSource
static void fillDescription (ParameterSetDescription &desc)
 
- Static Public Member Functions inherited from edm::ConfigurableInputSource
static void fillDescription (ParameterSetDescription &desc)
 
- Static Public Member Functions inherited from edm::InputSource
static const std::string & baseType ()
 
static void fillDescription (ParameterSetDescription &desc)
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::ConfigurableInputSource
void reallyReadEvent ()
 
void setEventNumber (EventNumber_t e)
 
void setTime (TimeValue_t t)
 
- Protected Member Functions inherited from edm::InputSource
void decreaseRemainingEventsBy (int iSkipped)
 
EventPrincipal *const eventPrincipalCache ()
 
boost::shared_ptr
< LuminosityBlockPrincipal >
const 
luminosityBlockPrincipal () const
 
PrincipalCache const & principalCache () const
 
PrincipalCacheprincipalCache ()
 
ProductRegistryproductRegistryUpdate () const
 
void reset () const
 
void resetLuminosityBlockAuxiliary () const
 
void resetRunAuxiliary () const
 
boost::shared_ptr
< RunPrincipal > const 
runPrincipal () const
 
void setLuminosityBlockAuxiliary (LuminosityBlockAuxiliary *lbp)
 
void setLumiPrematurelyRead ()
 
void setRunAuxiliary (RunAuxiliary *rp)
 
void setRunPrematurelyRead ()
 
void setTimestamp (Timestamp const &theTime)
 To set the current time, as seen by the input source. More...
 
ItemType state () const
 

Detailed Description

Description: <one line="" class="" summary>="">

Implementation: <Notes on="" implementation>="">

Definition at line 35 of file PixelSLinkDataInputSource.h.

Constructor & Destructor Documentation

PixelSLinkDataInputSource::PixelSLinkDataInputSource ( const edm::ParameterSet pset,
const edm::InputSourceDescription desc 
)
explicit

Definition at line 118 of file PixelSLinkDataInputSource.cc.

References CastorDataFrameFilter_impl::check(), StorageFactory::enableAccounting(), edm::ExternalInputSource::fileNames(), StorageFactory::get(), m_currenteventnumber, m_data, m_fileindex, m_runnumber, Storage::read(), edm::InputSource::setRunNumber(), findQualityFiles::size, and storage.

119  :
120  ExternalInputSource(pset,desc),
121  m_fedid(pset.getUntrackedParameter<int>("fedid")),
122  m_fileindex(0),
123  m_runnumber(pset.getUntrackedParameter<int>("runNumber",-1)),
127 {
128  produces<FEDRawDataCollection>();
129 
130  if (m_fileindex>=fileNames().size()) {
131  edm::LogInfo("") << "no more file to read " << std::endl;
132  return;// ???
133  }
134  std::string currentfilename = fileNames()[m_fileindex];
135  edm::LogInfo("") << "now examining file "<< currentfilename ;
136  m_fileindex++;
137  // reading both castor and other ('normal'/dcap) files.
138  IOOffset size = -1;
140 
141  edm::LogInfo("PixelSLinkDataInputSource") << " unsigned long int size = " << sizeof(unsigned long int) <<"\n unsigned long size = " << sizeof(unsigned long)<<"\n unsigned long long size = " << sizeof(unsigned long long) << "\n uint32_t size = " << sizeof(uint32_t) << "\n uint64_t size = " << sizeof(uint64_t) << std::endl;
142 
143  bool exists = StorageFactory::get() -> check(currentfilename.c_str(), &size);
144 
145  edm::LogInfo("PixelSLinkDataInputSource") << "file size " << size << std::endl;
146 
147  if(!exists){
148  edm::LogInfo("") << "file " << currentfilename << " cannot be found.";
149  return;
150  }
151  // now open the file stream:
152  storage.reset(StorageFactory::get()->open(currentfilename.c_str()));
153  // (throw if storage is 0)
154 
155  // check run number by opening up data file...
156 
157  Storage & temp_file = *storage;
158  // IOSize n =
159  temp_file.read((char*)&m_data,8);
160  // setRunNumber(m_runnumber);
161  if((m_data >> 60) != 0x5){
162  uint32_t runnum = m_data;
163  if(m_runnumber!=-1)
164  edm::LogInfo("") << "WARNING: observed run number encoded in S-Link dump. Overwriting run number as defined in .cfg file!!! Run number now set to " << runnum << " (was " << m_runnumber << ")";
165  m_runnumber=runnum;
166  }
167  if(m_runnumber!=0)
169  temp_file.read((char*)&m_data,8);
170  m_currenteventnumber = (m_data >> 32)&0x00ffffff ;
171 }
T getUntrackedParameter(std::string const &, T const &) const
bool enableAccounting(bool enabled)
virtual IOSize read(void *into, IOSize n, IOOffset pos)
Definition: Storage.cc:17
Definition: Storage.h:8
static StorageFactory * get(void)
bool check(const DataFrame &df, bool capcheck, bool dvercheck)
unsigned long long uint64_t
Definition: Time.h:15
int64_t IOOffset
Definition: IOTypes.h:19
void setRunNumber(RunNumber_t r)
Set the run number.
Definition: InputSource.h:149
std::auto_ptr< Storage > storage
ExternalInputSource(ParameterSet const &pset, InputSourceDescription const &desc, bool realData=true)
std::vector< std::string > const & fileNames() const
tuple size
Write out results.
PixelSLinkDataInputSource::~PixelSLinkDataInputSource ( )
virtual

Definition at line 174 of file PixelSLinkDataInputSource.cc.

174  {
175 
176 
177 }

Member Function Documentation

int PixelSLinkDataInputSource::getEventNumberFromFillWords ( std::vector< uint64_t >  data,
uint32_t &  totword 
)
private

Definition at line 34 of file PixelSLinkDataInputSource.cc.

References ntuplemaker::status.

34  {
35  // buffer validity, should already be pretty clean as this is exactly what goes into the FEDRawDataobject.
36 
37  // code copied directly from A. Ryd's fill word checker in PixelFEDInterface::PwordSlink64
38 
39  int fif2cnt=0;
40  int dumcnt=0;
41  int gapcnt=0;
42  uint32_t gap[9];
43  uint32_t dum[9];
44  uint32_t word[2]={0,0};
45  uint32_t chan=0;
46  uint32_t roc=0;
47 
48  const uint32_t rocmsk = 0x3e00000;
49  const uint32_t chnlmsk = 0xfc000000;
50 
51  for(int jk=1;jk<9;jk++)gap[jk]=0;
52  for(int jk=1;jk<9;jk++)dum[jk]=0;
53 
54  int fifcnt=1;
55  for(size_t kk=0; kk<buffer.size(); ++kk)
56  {
57 
58  word[0] = (uint32_t) buffer[kk];
59  word[1] = (uint32_t) (buffer[kk]>>32);
60 
61  for(size_t iw=0; iw<2; iw++)
62  {
63  chan= ((word[iw]&chnlmsk)>>26);
64  roc= ((word[iw]&rocmsk)>>21);
65 
66  //count non-error words
67  if(roc<25){
68  if((chan>4)&&(chan<10)&&(fifcnt!=2)) {fif2cnt=0;fifcnt=2;}
69  if((chan>9)&&(chan<14)&&(fifcnt!=3)) {fif2cnt=0;fifcnt=3;}
70  if((chan>13)&&(chan<19)&&(fifcnt!=4)){fif2cnt=0;fifcnt=4;}
71  if((chan>18)&&(chan<23)&&(fifcnt!=5)){fif2cnt=0;fifcnt=5;}
72  if((chan>22)&&(chan<28)&&(fifcnt!=6)){fif2cnt=0;fifcnt=6;}
73  if((chan>27)&&(chan<32)&&(fifcnt!=7)){fif2cnt=0;fifcnt=7;}
74  if((chan>31)&&(fifcnt!=8)){fif2cnt=0;fifcnt=8;}
75  fif2cnt++;
76  }
77  if(roc==26){gap[fifcnt]=(0x1000+(word[iw]&0xff));gapcnt++;}
78 
79  if((roc==27)&&((fif2cnt+dumcnt)<6)){dumcnt++;dum[fifcnt]=(0x1000+(word[iw]&0xff));}
80  else if((roc==27)&&((fif2cnt+dumcnt)>6)){dumcnt=1;fif2cnt=0;fifcnt++;}
81  }
82 
83  //word check complete
84  if(((fif2cnt+dumcnt)==6)&&(dumcnt>0)) //done with this fifo
85  {dumcnt=0;fif2cnt=0;fifcnt++;}
86  if((gapcnt>0)&&((dumcnt+fif2cnt)>5))//done with this fifo
87  {gapcnt=0;fifcnt++;fif2cnt=0;dumcnt=0;}
88  else if((gapcnt>0)&&((dumcnt+fif2cnt)<6)) gapcnt=0;
89 
90  }//end of fifo-3 word loop-see what we got!
91 
92  int status=0;
93 
94  if(gap[1]>0) {totword=(gap[1]&0xff);status=1;}
95  else if(gap[2]>0){totword=(gap[2]&0xff);status=1;}
96  else if(dum[1]>0){totword=(dum[1]&0xff);status=1;}
97  else if(dum[2]>0){totword=(dum[2]&0xff);status=1;}
98 
99  if(gap[3]>0) {totword=totword|((gap[3]&0xff)<<8);status=status|0x2;}
100  else if(gap[4]>0){totword=totword|((gap[4]&0xff)<<8);status=status|0x2;}
101  else if(dum[3]>0){totword=totword|((dum[3]&0xff)<<8);status=status|0x2;}
102  else if(dum[4]>0){totword=totword|((dum[4]&0xff)<<8);status=status|0x2;}
103 
104  if(gap[5]>0) {totword=totword|((gap[5]&0xff)<<16);status=status|0x4;}
105  else if(gap[6]>0){totword=totword|((gap[6]&0xff)<<16);status=status|0x4;}
106  else if(dum[5]>0){totword=totword|((dum[5]&0xff)<<16);status=status|0x4;}
107  else if(dum[6]>0){totword=totword|((dum[6]&0xff)<<16);status=status|0x4;}
108 
109  if(gap[7]>0){totword=totword|((gap[7]&0xff)<<24);status=status|0x8;}
110  else if(gap[8]>0){totword=totword|((gap[8]&0xff)<<24);status=status|0x8;}
111  else if(dum[7]>0){totword=totword|((dum[7]&0xff)<<24);status=status|0x8;}
112  else if(dum[8]>0){totword=totword|((dum[8]&0xff)<<24);status=status|0x8;}
113  return(status);
114 
115 }
tuple status
Definition: ntuplemaker.py:245
bool PixelSLinkDataInputSource::produce ( edm::Event event)
virtual

Implements edm::ConfigurableInputSource.

Definition at line 179 of file PixelSLinkDataInputSource.cc.

References prof2calltree::count, i, m_currenteventnumber, m_currenttriggernumber, m_data, m_eventnumber_shift, m_fedid, n, Storage::read(), edm::ConfigurableInputSource::setEventNumber(), storage, and synchronizeEvents().

179  {
180  bool lastevent=false;
181  Storage & m_file = *storage;
182 
183  // create product (raw data)
184  std::auto_ptr<FEDRawDataCollection> buffers( new FEDRawDataCollection );
185 
186  // uint32_t currenteventnumber = (m_data >> 32)&0x00ffffff;
187  uint32_t eventnumber =(m_data >> 32)&0x00ffffff ;
188 
189  do{
190  std::vector<uint64_t> buffer;
191 
192 
193 
194  uint16_t count=0;
195  eventnumber = (m_data >> 32)&0x00ffffff ;
196  if(m_currenteventnumber==0)
197  m_currenteventnumber=eventnumber;
198  edm::LogInfo("PixelSLinkDataInputSource::produce()") << "**** event number = " << eventnumber << " global event number " << m_currenteventnumber << " data " << std::hex << m_data << std::dec << std::endl;
199  while ((m_data >> 60) != 0x5){
200  // std::cout << std::hex << m_data << std::dec << std::endl;
201  if (count==0){
202  edm::LogWarning("") << "DATA CORRUPTION!" ;
203  edm::LogWarning("") << "Expected to find header, but read: 0x"
204  << std::hex<<m_data<<std::dec ;
205  }
206 
207  count++;
208  int n=m_file.read((char*)&m_data,8);
209  edm::LogWarning("") << "next data " << std::hex << m_data << std::dec << std::endl;
210 
211  if (n!=8) {
212  edm::LogInfo("") << "End of input file" ;
213  return false;
214  }
215  }
216 
217 
218  if (count>0) {
219  edm::LogWarning("")<<"Had to read "<<count<<" words before finding header!"<<std::endl;
220  }
221 
222  if (m_fedid>-1) {
223  m_data=(m_data&0xfffffffffff000ffLL)|((m_fedid&0xfff)<<8);
224  }
225 
226  uint16_t fed_id=(m_data>>8)&0xfff;
227  // std::cout << "fed id = " << fed_id << std::endl;
228  buffer.push_back(m_data);
229 
230  do{
231  m_file.read((char*)&m_data,8);
232  buffer.push_back(m_data);
233  }
234  while((m_data >> 60) != 0xa);
235  // std::cout << "read " << buffer.size() << " long words" << std::endl;
236 
237  std::auto_ptr<FEDRawData> rawData(new FEDRawData(8*buffer.size()));
238  // FEDRawData * rawData = new FEDRawData(8*buffer.size());
239  unsigned char* dataptr=rawData->data();
240 
241  for (uint16_t i=0;i<buffer.size();i++){
242  ((uint64_t *)dataptr)[i]=buffer[i];
243  }
244  uint32_t thetriggernumber=0;
245  int nfillwords = 0;//getEventNumberFromFillWords(buffer,thetriggernumber);
246 
247  if(nfillwords>0){
248  LogInfo("") << "n fill words = " << nfillwords << ", trigger numbers: " << thetriggernumber << "," << m_currenttriggernumber << std::endl;
249  m_eventnumber_shift = thetriggernumber - m_currenttriggernumber;
250  }
251  m_currenttriggernumber = thetriggernumber;
252  FEDRawData& fedRawData = buffers->FEDData( fed_id );
253  fedRawData=*rawData;
254 
255  // read the first data member of the next blob to check on event number
256  int n =m_file.read((char*)&m_data,8);
257  if (n==0) {
258  edm::LogInfo("") << "End of input file" ;
259  lastevent=true;
260  }
261  m_currenteventnumber = (m_data >> 32)&0x00ffffff ;
262  if(m_currenteventnumber<eventnumber)
263  LogError("PixelSLinkDataInputSource") << " error, the previous event number (" << eventnumber << ") is LARGER than the next event number (" << m_currenteventnumber << ")" << std::endl;
264 
265  }
266  while( eventnumber == m_currenteventnumber);
267 
268  uint32_t realeventno = synchronizeEvents();
269  setEventNumber(realeventno);
270  event.put(buffers);
271  // if(lastevent)
272  // return true;
273  return true;
274 }
int i
Definition: DBlmapReader.cc:9
virtual IOSize read(void *into, IOSize n, IOOffset pos)
Definition: Storage.cc:17
Definition: Storage.h:8
unsigned long long uint64_t
Definition: Time.h:15
void setEventNumber(EventNumber_t e)
std::auto_ptr< Storage > storage
uint32_t PixelSLinkDataInputSource::synchronizeEvents ( )
private

Definition at line 277 of file PixelSLinkDataInputSource.cc.

References m_currenteventnumber, and query::result.

Referenced by produce().

277  {
278  int32_t result= m_currenteventnumber -1;
279 
280  return(uint32_t) result;
281 }
tuple result
Definition: query.py:137

Member Data Documentation

uint32_t PixelSLinkDataInputSource::m_currenteventnumber
private
uint32_t PixelSLinkDataInputSource::m_currenttriggernumber
private

Definition at line 55 of file PixelSLinkDataInputSource.h.

Referenced by produce().

uint64_t PixelSLinkDataInputSource::m_data
private

Definition at line 53 of file PixelSLinkDataInputSource.h.

Referenced by PixelSLinkDataInputSource(), and produce().

int32_t PixelSLinkDataInputSource::m_eventnumber_shift
private

Definition at line 57 of file PixelSLinkDataInputSource.h.

Referenced by produce().

int PixelSLinkDataInputSource::m_fedid
private

Definition at line 49 of file PixelSLinkDataInputSource.h.

Referenced by produce().

uint32_t PixelSLinkDataInputSource::m_fileindex
private

Definition at line 50 of file PixelSLinkDataInputSource.h.

Referenced by PixelSLinkDataInputSource().

uint32_t PixelSLinkDataInputSource::m_globaleventnumber
private

Definition at line 56 of file PixelSLinkDataInputSource.h.

int PixelSLinkDataInputSource::m_runnumber
private

Definition at line 52 of file PixelSLinkDataInputSource.h.

Referenced by PixelSLinkDataInputSource().

std::auto_ptr<Storage> PixelSLinkDataInputSource::storage
private

Definition at line 51 of file PixelSLinkDataInputSource.h.

Referenced by PixelSLinkDataInputSource(), and produce().