CMS 3D CMS Logo

recycleTccEmu.cc File Reference

The TCC memory for FE data emulation takes a fixed number, 2048, of events. More...

#include <iostream>
#include <string>
#include <fstream>
#include <sstream>
#include <inttypes.h>
#include <iomanip>

Go to the source code of this file.

Functions

int main (int argc, char *argv[])

Variables

uint16_t mem [nChs][nEvts]
const int nChs = 68
const int nEvts = 2048


Detailed Description

The TCC memory for FE data emulation takes a fixed number, 2048, of events.

This standalone application completes a FE emulation data file with an arbitrary number of events (<=2048) in order to have the required 2048 events. The N initial events are repeated till having 2048 events. In general the number of initial events is choosen as a divider of 2048.

Definition in file recycleTccEmu.cc.


Function Documentation

int main ( int  argc,
char *  argv[] 
)

Definition at line 22 of file recycleTccEmu.cc.

References GenMuonPlsPt100GeV_cfg::cout, dummy, cmsRelvalreport::exit, in, mem, nChs, nEvts, out, and s.

00022                                 {
00023   if((argc>=2 && (argv[1]=="-h" | argv[1]=="--help"))
00024       || argc!=3){
00025     cout << "Usage: recycleTccEmu infile outfile\n";
00026     return 1;
00027   }
00028   
00029   string ifilename = argv[1];
00030   string ofilename = argv[2];
00031   
00032   for(int iCh=0; iCh<nChs; ++iCh){
00033     for(int iEvts = 0; iEvts<nEvts; ++iEvts){
00034       mem[iCh][iEvts] = 0xFFFF;
00035     }
00036   }
00037   
00038   ifstream in(ifilename.c_str());
00039   int chnb;
00040   int bcnb;
00041   int val ;
00042   int dummy ;
00043   int oldLineCnt = 0;  
00044   
00045   //reads input file:
00046   if(in){
00047     while(!in.eof()) {
00048       in >>dec>> chnb >> bcnb >>hex>> val >> dummy ;
00049       mem[chnb-1][bcnb] = val&0x7FF;
00050       if(mem[chnb-1][bcnb]!=val){
00051         cout << "Invalid Et value at line " << oldLineCnt+1 << ".\n";
00052         exit(1);
00053       }
00054       // cout<<"Channel: "<< dec <<chnb <<", BX: "
00055       // << dec << bcnb << " filled with val:"<< hex<< mem[chnb-1][bcnb]
00056       // << dec << endl;
00057       ++oldLineCnt;
00058     }
00059   } else{
00060     cout << "Failed to open file " << ifilename << "\n";
00061   }
00062 
00063   in.close();
00064   ofstream out(ofilename.c_str());
00065   
00066   if(!out){
00067     cout << "Failed to open file '" << ofilename
00068          << "' in write mode.\n";
00069     return 1;
00070   }
00071   
00072   
00073   bool singleOldEventCnt = true;
00074   int oldEventCnt[nChs];
00075   //fills output file:
00076   for(int iCh = 0; iCh<nChs; ++iCh){
00077     int evtcnt = 0;
00078     //find first not initialized events:
00079     while(evtcnt<nEvts && mem[iCh][evtcnt]!=0xFFFF){++evtcnt;}
00080     //cout << "ch " << iCh << " event count: " << evtcnt << "\n";
00081     oldEventCnt[iCh] = evtcnt;
00082     if(oldEventCnt[0]!=oldEventCnt[iCh]) singleOldEventCnt = false;
00083     if(evtcnt==0){
00084       cout << "Error: no data found for channel "<< iCh << "\n";
00085     }
00086     //clones data of channel iCh
00087     for(int ievt = evtcnt; ievt<nEvts; ++ievt){
00088       if(mem[iCh][ievt]!=0xFFFF){
00089         cout << "Error: memory offset of channel " << iCh
00090              << " events are not contiguous.\n";
00091         exit(1);
00092       }
00093       mem[iCh][ievt] = mem[iCh][ievt%evtcnt];
00094     }
00095     
00096     for(int ievt=0; ievt<nEvts; ++ievt){
00097       out << iCh+1 << "\t" << ievt
00098           << "\t" << hex << "0x" << setfill('0') << setw(4)
00099           << mem[iCh][ievt]
00100           << setfill(' ') << dec << "\t0"
00101           << "\n";
00102     }
00103   }
00104 
00105   //warning for aperiodic case:
00106   if(singleOldEventCnt && (nEvts%oldEventCnt[0]!=0)){
00107     cout << "Warning: ouput event count (2048) is not a mulitple of input "
00108       "event counts\n" ;
00109   }
00110   if(!singleOldEventCnt){
00111     stringstream s;
00112     for(int iCh=0; iCh<nChs; ++iCh){
00113       if(nEvts%oldEventCnt[iCh]){
00114         s << (s.str().size()==0?"":", ") << iCh;
00115       }
00116     }
00117     if(s.str().size()!=0)
00118       cout << "Warning: ouput event count (2048) for channel"
00119            << (s.str().size()>1?"s":"") << " "
00120            << s.str()
00121            << " is not a mulitple of input event counts\n" ;
00122   }
00123   
00124   if(!singleOldEventCnt){
00125     cout << "Info: in the input file the event count depends on the channel";
00126   }
00127 }


Variable Documentation

uint16_t mem[nChs][nEvts]

Definition at line 12 of file recycleTccEmu.cc.

Referenced by pool::PFNCatalog::connect(), reco::findMethod(), main(), and xmas2dqm::wse::XmasToDQM::WriteMemoryCallback().

const int nChs = 68

Definition at line 10 of file recycleTccEmu.cc.

Referenced by main().

const int nEvts = 2048

Definition at line 11 of file recycleTccEmu.cc.

Referenced by main().


Generated on Tue Jun 9 17:55:44 2009 for CMSSW by  doxygen 1.5.4