CMS 3D CMS Logo

Functions | Variables
recycleTccEmu.cc File Reference
#include <iostream>
#include <fstream>
#include <sstream>
#include <cinttypes>
#include <iomanip>
#include <cstdlib>
#include <cstdio>
#include <cstring>

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[] 
)

CALO JETS


PF JETS

Definition at line 23 of file recycleTccEmu.cc.

References gather_cfg::cout, TauDecayModes::dec, cmsRelvalreport::exit, recoMuon::in, mem, nChs, nEvts, MillePedeFileConverter_cfg::out, alignCSCRings::s, and heppy_batch::val.

23  {
24  if((argc>=2 && ( (strcmp(argv[1],"-h")==0) || (strcmp(argv[1],"--help")==0) ))
25  || argc!=3){
26  cout << "Usage: recycleTccEmu infile outfile\n";
27  return 1;
28  }
29 
30  string ifilename = argv[1];
31  string ofilename = argv[2];
32 
33  for(int iCh=0; iCh<nChs; ++iCh){
34  for(int iEvts = 0; iEvts<nEvts; ++iEvts){
35  mem[iCh][iEvts] = 0xFFFF;
36  }
37  }
38 
39  ifstream in(ifilename.c_str());
40  int chnb;
41  int bcnb;
42  int val ;
43  int dummy ;
44  int oldLineCnt = 0;
45 
46  //reads input file:
47  if(in){
48  while(!in.eof()) {
49  in >>dec>> chnb >> bcnb >>hex>> val >> dummy ;
50  mem[chnb-1][bcnb] = val&0x7FF;
51  if(mem[chnb-1][bcnb]!=val){
52  cout << "Invalid Et value at line " << oldLineCnt+1 << ".\n";
53  exit(1);
54  }
55  // cout<<"Channel: "<< dec <<chnb <<", BX: "
56  // << dec << bcnb << " filled with val:"<< hex<< mem[chnb-1][bcnb]
57  // << dec << endl;
58  ++oldLineCnt;
59  }
60  } else{
61  cout << "Failed to open file " << ifilename << "\n";
62  }
63 
64  in.close();
65  ofstream out(ofilename.c_str());
66 
67  if(!out){
68  cout << "Failed to open file '" << ofilename
69  << "' in write mode.\n";
70  return 1;
71  }
72 
73 
74  bool singleOldEventCnt = true;
75  int oldEventCnt[nChs];
76  //fills output file:
77  for(int iCh = 0; iCh<nChs; ++iCh){
78  int evtcnt = 0;
79  //find first not initialized events:
80  while(evtcnt<nEvts && mem[iCh][evtcnt]!=0xFFFF){++evtcnt;}
81  //cout << "ch " << iCh << " event count: " << evtcnt << "\n";
82  oldEventCnt[iCh] = evtcnt;
83  if(oldEventCnt[0]!=oldEventCnt[iCh]) singleOldEventCnt = false;
84  if(evtcnt==0){
85  cout << "Error: no data found for channel "<< iCh << "\n";
86  }
87  //clones data of channel iCh
88  for(int ievt = evtcnt; ievt<nEvts; ++ievt){
89  if(mem[iCh][ievt]!=0xFFFF){
90  cout << "Error: memory offset of channel " << iCh
91  << " events are not contiguous.\n";
92  exit(1);
93  }
94  mem[iCh][ievt] = mem[iCh][ievt%evtcnt];
95  }
96 
97  for(int ievt=0; ievt<nEvts; ++ievt){
98  out << iCh+1 << "\t" << ievt
99  << "\t" << hex << "0x" << setfill('0') << setw(4)
100  << mem[iCh][ievt]
101  << setfill(' ') << dec << "\t0"
102  << "\n";
103  }
104  }
105 
106  //warning for aperiodic case:
107  if(singleOldEventCnt && (nEvts%oldEventCnt[0]!=0)){
108  cout << "Warning: ouput event count (2048) is not a mulitple of input "
109  "event counts\n" ;
110  }
111  if(!singleOldEventCnt){
112  stringstream s;
113  for(int iCh=0; iCh<nChs; ++iCh){
114  if(nEvts%oldEventCnt[iCh]){
115  s << (s.str().empty()?"":", ") << iCh;
116  }
117  }
118  if(!s.str().empty())
119  cout << "Warning: ouput event count (2048) for channel"
120  << (s.str().size()>1?"s":"") << " "
121  << s.str()
122  << " is not a mulitple of input event counts\n" ;
123  }
124 
125  if(!singleOldEventCnt){
126  cout << "Info: in the input file the event count depends on the channel";
127  }
128 }
const int nChs
uint16_t mem[nChs][nEvts]
const int nEvts

Variable Documentation

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

Definition at line 11 of file recycleTccEmu.cc.

Referenced by EcalSRCondTools::importSrpConfigFile(), and main().

const int nEvts = 2048