#include <L1Trigger/TextToDigi/src/RctTextToRctDigi.h>
Public Member Functions | |
RctTextToRctDigi (const edm::ParameterSet &) | |
~RctTextToRctDigi () | |
Private Member Functions | |
void | bxSynchro (int &, int) |
Synchronize bunch crossing. | |
virtual void | produce (edm::Event &, const edm::EventSetup &) |
void | putEmptyDigi (edm::Event &) |
Create empty digi collection. | |
Private Attributes | |
std::ifstream | m_file [18] |
file handle | |
int | m_fileEventOffset |
Number of events to be offset wrt input. | |
int | m_nevt |
Event counter. | |
std::string | m_textFileName |
Name out input file. |
Definition at line 40 of file RctTextToRctDigi.h.
RctTextToRctDigi::RctTextToRctDigi | ( | const edm::ParameterSet & | iConfig | ) | [explicit] |
Definition at line 42 of file RctTextToRctDigi.cc.
References lat::endl(), aod_PYTHIA_cfg::fileName, i, in, LogDebug, m_file, m_textFileName, and NUM_RCT_CRATES.
00042 : 00043 m_textFileName(iConfig.getParameter<std::string>("TextFileName")), 00044 m_fileEventOffset(iConfig.getParameter<int>("FileEventOffset")), 00045 m_nevt(0) 00046 { 00047 // Produces collections 00048 produces<L1CaloEmCollection>(); 00049 produces<L1CaloRegionCollection>(); 00050 00051 // Open the input files 00052 for (unsigned i=0; i<NUM_RCT_CRATES; i++){ 00053 stringstream fileStream; 00054 fileStream << m_textFileName << std::setw(2) << std::setfill('0') << i << ".txt"; 00055 string fileName(fileStream.str()); 00056 m_file[i].open(fileName.c_str(),ios::in); 00057 00058 if(!m_file[i].good()) 00059 { 00060 //throw cms::Exception("RctTextToRctDigiTextFileOpenError") 00061 LogDebug("RctTextToRctDigi") 00062 << "RctTextToRctDigi::RctTextToRctDigi : " 00063 << " couldn't open the file " << fileName << "...skipping!" << endl; 00064 } 00065 } 00066 }
RctTextToRctDigi::~RctTextToRctDigi | ( | ) |
Definition at line 68 of file RctTextToRctDigi.cc.
References i, m_file, and NUM_RCT_CRATES.
00069 { 00070 // Close the input files 00071 for (unsigned i=0; i<NUM_RCT_CRATES; i++){ 00072 m_file[i].close(); 00073 } 00074 }
Synchronize bunch crossing.
Syncronize bunch crossing number/n.
Definition at line 95 of file RctTextToRctDigi.cc.
References lat::endl(), Exception, j, m_file, m_fileEventOffset, m_nevt, and tmp.
Referenced by produce().
00095 { 00096 string tmp; 00097 // bypass bx input until correct bx is reached 00098 while(bx<m_nevt+m_fileEventOffset) { 00099 for (int j=0; j<6; j++){ 00100 getline(m_file[crate],tmp); 00101 } 00102 m_file[crate] >> tmp >> bx; 00103 if(tmp!="Crossing") 00104 throw cms::Exception("RctTextToRctDigiTextFileReadError") 00105 << "RctTextToRctDigi::bxSynchro : " 00106 << " something screwy happened Crossing!=" << tmp << endl; 00107 } 00108 }
void RctTextToRctDigi::produce | ( | edm::Event & | iEvent, | |
const edm::EventSetup & | iSetup | |||
) | [private, virtual] |
Synchronize bunch crossing
Implements edm::EDProducer.
Definition at line 111 of file RctTextToRctDigi.cc.
References bxSynchro(), em, lat::endl(), outputToXml::eof, Exception, i, j, LogDebug, m_file, m_fileEventOffset, m_nevt, m_textFileName, NUM_RCT_CRATES, edm::Event::put(), putEmptyDigi(), rgn, and tmp.
00112 { 00113 00114 // Skip event if required 00115 if (m_nevt < m_fileEventOffset){ 00116 //string tmp; 00117 //for (int i=0; i<6; i++){ 00118 // getline(m_file[i],tmp); 00119 //} 00120 putEmptyDigi(iEvent); 00121 m_nevt++; 00122 return; 00123 } 00124 00125 // New collections 00126 auto_ptr<L1CaloEmCollection> em (new L1CaloEmCollection); 00127 auto_ptr<L1CaloRegionCollection> rgn (new L1CaloRegionCollection); 00128 00129 // Loop over RCT crates 00130 for (unsigned i=0; i<NUM_RCT_CRATES; i++){ 00131 00132 if(!m_file[i].good()) { 00133 continue; 00134 } 00135 00136 // Check we're not at the end of the file 00137 if(m_file[i].eof()) 00138 { 00139 //throw cms::Exception("RctTextToRctDigiTextFileReadError") 00140 LogDebug("RctTextToRctDigi") 00141 << "RctTextToRctDigi::produce : " 00142 << " unexpected end of file " << m_textFileName << i 00143 << " adding empty collection for event !" 00144 << endl; 00145 putEmptyDigi(iEvent); 00146 continue; 00147 } 00148 00149 // Check we're at the start of an event 00150 string tmp; 00151 m_file[i]>> tmp; 00152 if(tmp!="Crossing") 00153 { 00154 throw cms::Exception("RctTextToRctDigiTextFileReadError") 00155 << "RctTextToRctDigi::produce : " 00156 << " something screwy happened Crossing!=" << tmp << endl; 00157 } 00158 00159 // Read BX number 00160 dec(m_file[i]); 00161 int BXNum; 00162 m_file[i]>>BXNum; 00163 00165 bxSynchro(BXNum,i); 00166 00167 if(BXNum!=m_nevt+m_fileEventOffset) 00168 throw cms::Exception("RctTextToRctDigiTextSyncError") 00169 << "RctTextToRctDigi::produce : " 00170 << " something screwy happened " 00171 << "evt:" << m_nevt << " != bx:" << BXNum << " + " << m_fileEventOffset 00172 << endl; 00173 00174 // Buffers 00175 unsigned long int uLongBuffer; 00176 bool mipBitBuffer[14],qBitBuffer[14]; 00177 00178 // All in hex from now on 00179 hex(m_file[i]); 00180 00181 // Isolated electrons 00182 for (unsigned j=0; j<4; j++){ 00183 m_file[i] >> uLongBuffer; 00184 em->push_back(L1CaloEmCand(uLongBuffer, i, true, j,BXNum,0)); 00185 } 00186 00187 // Non-isolated electrons 00188 for (unsigned j=0; j<4; j++){ 00189 m_file[i] >> uLongBuffer; 00190 em->push_back(L1CaloEmCand(uLongBuffer, i, false, j,BXNum,0)); 00191 } 00192 00193 // MIP bits 00194 for (unsigned j=0; j<14; j++){ 00195 m_file[i] >> mipBitBuffer[j]; 00196 } 00197 00198 // Quiet bits 00199 for (unsigned j=0; j<14; j++){ 00200 m_file[i] >> qBitBuffer[j]; 00201 } 00202 00203 // Barrel and endcap regions 00204 for (unsigned j=0; j<14; j++){ 00205 m_file[i] >> uLongBuffer; 00206 00207 unsigned et = uLongBuffer & 0x3ff; // put the first 10 bits of rawData into the Et 00208 uLongBuffer >>= 10; // shift the remaining bits down to remove the 10 bits of Et 00209 00210 bool overFlow = ((uLongBuffer & 0x1) != 0); //LSB is now overflow bit 00211 bool tauVeto = (((uLongBuffer & 0x2) >> 1) != 0); //2nd bit is tauveto 00212 00213 rgn->push_back(L1CaloRegion(et,overFlow,tauVeto,mipBitBuffer[j],qBitBuffer[j],i,j/2,j%2)); 00214 } 00215 00216 // HF 00217 for (unsigned j=0; j<8; j++){ 00218 m_file[i] >> uLongBuffer; 00219 00220 unsigned et = uLongBuffer & 0xff; // put the first 8 bits into the Et 00221 00222 rgn->push_back(L1CaloRegion(et,true,i,j)); 00223 } 00224 00225 dec(m_file[i]); 00226 } 00227 00228 iEvent.put(em); 00229 iEvent.put(rgn); 00230 00231 m_nevt++; 00232 }
void RctTextToRctDigi::putEmptyDigi | ( | edm::Event & | iEvent | ) | [private] |
Create empty digi collection.
Append empty digi collection/n.
Definition at line 77 of file RctTextToRctDigi.cc.
References em, i, j, NUM_RCT_CRATES, edm::Event::put(), and rgn.
Referenced by produce().
00077 { 00078 auto_ptr<L1CaloEmCollection> em (new L1CaloEmCollection); 00079 auto_ptr<L1CaloRegionCollection> rgn (new L1CaloRegionCollection); 00080 for (unsigned i=0; i<NUM_RCT_CRATES; i++){ 00081 for (unsigned j=0; j<4; j++) { 00082 em->push_back(L1CaloEmCand(0, i, true)); 00083 em->push_back(L1CaloEmCand(0, i, false)); 00084 } 00085 for (unsigned j=0; j<14; j++) 00086 rgn->push_back(L1CaloRegion(0,false,false,false,false,i,j/2,j%2)); 00087 for (unsigned j=0; j<8; j++) 00088 rgn->push_back(L1CaloRegion(0,true,i,j)); 00089 } 00090 iEvent.put(em); 00091 iEvent.put(rgn); 00092 }
std::ifstream RctTextToRctDigi::m_file[18] [private] |
file handle
Definition at line 64 of file RctTextToRctDigi.h.
Referenced by bxSynchro(), produce(), RctTextToRctDigi(), and ~RctTextToRctDigi().
int RctTextToRctDigi::m_fileEventOffset [private] |
Number of events to be offset wrt input.
Definition at line 58 of file RctTextToRctDigi.h.
Referenced by bxSynchro(), and produce().
int RctTextToRctDigi::m_nevt [private] |
Event counter.
Definition at line 61 of file RctTextToRctDigi.h.
Referenced by bxSynchro(), and produce().
std::string RctTextToRctDigi::m_textFileName [private] |
Name out input file.
Definition at line 55 of file RctTextToRctDigi.h.
Referenced by produce(), and RctTextToRctDigi().