#include <L1Trigger/TextToDigi/plugins/RctDigiToRctText.h>
Public Member Functions | |
RctDigiToRctText (const edm::ParameterSet &) | |
~RctDigiToRctText () | |
Private Member Functions | |
virtual void | analyze (const edm::Event &, const edm::EventSetup &) |
Private Attributes | |
std::ofstream | fdebug |
handle for debug file | |
std::ofstream | m_file [NUM_RCT_CRATES] |
handles for output files | |
bool | m_hexUpperCase |
write upper case hex words | |
edm::InputTag | m_rctInputLabel |
label for RCT digis | |
std::string | m_textFileName |
basename for output files |
Definition at line 32 of file RctDigiToRctText.h.
RctDigiToRctText::RctDigiToRctText | ( | const edm::ParameterSet & | iConfig | ) | [explicit] |
open output text files
open info|debug file
Definition at line 12 of file RctDigiToRctText.cc.
References lat::endl(), Exception, fdebug, aod_PYTHIA_cfg::fileName, i, m_file, m_textFileName, NUM_RCT_CRATES, and out.
00012 : 00013 m_rctInputLabel(iConfig.getParameter<edm::InputTag>("RctInputLabel")), 00014 m_textFileName(iConfig.getParameter<std::string>("TextFileName")), 00015 m_hexUpperCase(iConfig.getParameter<bool>("HexUpperCase")) { 00016 00018 for (unsigned i=0; i<NUM_RCT_CRATES; i++){ 00019 std::stringstream fileStream; 00020 fileStream << m_textFileName << std::setw(2) << std::setfill('0') << i << ".txt"; 00021 std::string fileName(fileStream.str()); 00022 m_file[i].open(fileName.c_str(),std::ios::out); 00023 00024 if(!m_file[i].good()) { 00025 throw cms::Exception("RctDigiToRctTextTextFileOpenError") 00026 << "RctDigiToRctText::RctDigiToRctText : " 00027 << " couldn't create the file " << fileName << endl; 00028 } 00029 } 00030 00032 fdebug.open("rctdigitorcttext_debug.txt", std::ios::out); 00033 00034 }
RctDigiToRctText::~RctDigiToRctText | ( | ) |
close files
Definition at line 37 of file RctDigiToRctText.cc.
References fdebug, i, m_file, and NUM_RCT_CRATES.
00037 { 00039 for (unsigned i=0; i<NUM_RCT_CRATES; i++) 00040 m_file[i].close(); 00041 fdebug.close(); 00042 }
void RctDigiToRctText::analyze | ( | const edm::Event & | iEvent, | |
const edm::EventSetup & | iSetup | |||
) | [private, virtual] |
count bunch crossing
get the RCT data
debug flags and stream
--- ELECTRONS ---
--- REGIONS ---
print electrons
print regions
mip bits
quiet bits
region info
HF
flush data to files
Implements edm::EDAnalyzer.
Definition at line 46 of file RctDigiToRctText.cc.
References data, em, lat::endl(), Exception, fdebug, flush(), edm::Event::getByLabel(), i, id, j, LogDebug, m_file, m_hexUpperCase, m_rctInputLabel, NUM_RCT_CRATES, rgn, metsig::tau, and tmp.
00046 { 00047 00049 static int nevt = -1; 00050 nevt++; 00051 00053 edm::Handle<L1CaloEmCollection> em; 00054 edm::Handle<L1CaloRegionCollection> rgn; 00055 iEvent.getByLabel(m_rctInputLabel, em); 00056 iEvent.getByLabel(m_rctInputLabel, rgn); 00057 00059 bool ldebug = false; 00060 bool debug_NOTEMPTY[18]={0}; 00061 for(int i=0; i<18; i++) debug_NOTEMPTY[i]=false; 00062 std::stringstream dstrm; 00063 00064 00066 00067 unsigned long int CAND[18][8]; 00068 int n_iso [18]={0}; 00069 int n_niso[18]={0}; 00070 bool iso; 00071 int id; 00072 00073 for(L1CaloEmCollection::const_iterator iem=em->begin(); iem!=em->end(); iem++){ 00074 00075 int crate = iem->rctCrate(); 00076 iso = iem->isolated(); 00077 unsigned data = iem->raw(); 00078 00079 id = iso ? n_iso[crate]++ : 4 + n_niso[crate]++; 00080 00081 CAND[crate][id] = data; 00082 00084 if(crate>17 || id > 7) 00085 throw cms::Exception("RctDigiToRctTextElectronIndexOutBounds") 00086 << "out of bounds indices crate:" << crate << "id:" << id << endl; 00087 if(ldebug&&data!=0) 00088 debug_NOTEMPTY[crate] = true; 00089 dstrm.str(""); 00090 dstrm << "electron " 00091 << " bx:" << nevt 00092 << " crate:" << crate 00093 << " iso:" << iso 00094 << " raw:" << data 00095 << " \t cand:" << *iem; 00096 if(debug_NOTEMPTY[crate]) fdebug << dstrm.str() << endl; 00097 } 00098 00099 00101 00102 unsigned short MIPbits [18][7][2] = {{{0}}}; 00103 unsigned short QIEbits [18][7][2] = {{{0}}}; 00104 unsigned short RC [18][7][2] = {{{0}}}; 00105 unsigned short RCof [18][7][2] = {{{0}}}; 00106 unsigned short RCtau [18][7][2] = {{{0}}}; 00107 unsigned short HF [18][4][2] = {{{0}}}; 00108 00109 for (L1CaloRegionCollection::const_iterator irgn=rgn->begin(); irgn!=rgn->end(); irgn++){ 00110 00111 int crate = irgn->rctCrate(); 00112 int card = irgn->rctCard(); 00113 int rgnidx= irgn->rctRegionIndex(); 00114 00115 dstrm.str(""); 00116 if (!irgn->id().isHf()){ 00117 RC [crate][card][rgnidx]=irgn->et(); 00118 RCof [crate][card][rgnidx]=irgn->overFlow(); 00119 RCtau [crate][card][rgnidx]=irgn->tauVeto(); 00120 MIPbits[crate][card][rgnidx]=irgn->mip(); 00121 QIEbits[crate][card][rgnidx]=irgn->quiet(); 00122 // debug info 00123 dstrm << hex 00124 << "Et=" << irgn->et() 00125 << " OverFlow=" << irgn->overFlow() 00126 << " tauVeto=" << irgn->tauVeto() 00127 << " mip=" << irgn->mip() 00128 << " quiet=" << irgn->quiet() 00129 << " Card=" << irgn->rctCard() 00130 << " Region=" << irgn->rctRegionIndex() 00131 << " Crate=" << irgn->rctCrate() 00132 << dec; 00133 if(ldebug) LogDebug("Regions") << dstrm.str(); 00134 } else { 00135 HF [crate][irgn->id().rctEta()-7][irgn->id().rctPhi()]=irgn->et(); 00136 // debug info 00137 dstrm << hex 00138 << "Et=" << irgn->et() 00139 << " FGrain=" << irgn->fineGrain() 00140 << " Eta=" << irgn->id().rctEta() 00141 << " Phi=" << irgn->id().rctPhi() 00142 << " Crate=" << irgn->rctCrate() 00143 << dec; 00144 if(ldebug) LogDebug("HFRegions") << dstrm.str(); 00145 } 00146 00147 00148 if(ldebug &&irgn->et()!=0) debug_NOTEMPTY[crate] = true; //debug 00149 if(debug_NOTEMPTY[crate]) { 00150 fdebug << "region" 00151 << " bx:" << nevt 00152 << " crate:" << crate 00153 << "\t"; 00154 fdebug << dstrm.str() << endl; 00155 } 00156 } 00157 00158 00159 std::stringstream sstrm; 00160 if(m_hexUpperCase) 00161 sstrm << std::uppercase; 00162 else 00163 sstrm.unsetf(std::ios::uppercase); 00164 00165 00167 00168 for (unsigned crate=0; crate<NUM_RCT_CRATES; crate++){ 00169 00170 sstrm.str(""); 00171 sstrm << "Crossing " << nevt << endl; 00172 00173 for(int j=0; j<8; j++) { 00174 sstrm << setw(3) << setfill('0') << hex << (CAND[crate][j] & 0x3ff); 00175 if(j<7) sstrm << " "; 00176 } 00177 sstrm << setfill(' ') << dec; 00178 m_file[crate] << sstrm.str() << endl; 00179 00180 // debug 00181 if(debug_NOTEMPTY[crate]) fdebug << sstrm.str() << endl; 00182 if(ldebug) LogDebug("Electrons") << sstrm.str() << endl; 00183 00184 } 00185 00186 00188 00189 for (unsigned crate=0; crate<NUM_RCT_CRATES; crate++){ 00190 00192 sstrm.str(""); 00193 for (int card=0; card<7; card++){ 00194 for (int j=0; j<2; j++){ 00195 sstrm << " " << MIPbits[crate][card][j]; 00196 } 00197 } 00198 m_file[crate] << sstrm.str() << endl; 00199 if(debug_NOTEMPTY[crate]) fdebug << sstrm.str() << endl; //debug 00200 00202 sstrm.str(""); 00203 for (int card=0; card<7; card++){ 00204 for (int j=0; j<2; j++){ 00205 sstrm << " " << QIEbits[crate][card][j]; 00206 } 00207 } 00208 m_file[crate] << sstrm.str() << endl; 00209 if(debug_NOTEMPTY[crate]) fdebug << sstrm.str() << endl; //debug 00210 00212 sstrm.str(""); 00213 for (int card=0; card<7; card++){ 00214 for (int j=0; j<2; j++){ 00215 unsigned long int tmp; 00216 unsigned et = RC [crate][card][j]; 00217 unsigned ovf = RCof [crate][card][j]; 00218 unsigned tau = RCtau[crate][card][j]; 00219 //ovf = ovf || (et>=0x400); 00220 tmp = ((tau & 0x1) << 11) | ((ovf &0x1)<<10) | ((et & 0x3ff)); 00221 sstrm << " " << setw(3) << setfill('0') << hex << tmp; 00222 00223 } 00224 } 00225 m_file[crate] << sstrm.str() << endl; 00226 if(debug_NOTEMPTY[crate]) fdebug << sstrm.str() << endl << endl; //debug 00227 00228 00230 sstrm.str(""); 00231 for (int ip=0; ip<2; ip++){ 00232 for (int ie=0; ie<4; ie++){ 00233 unsigned et = HF[crate][ie][ip] & 0xff; 00234 sstrm << " " << setw(2) << setfill('0') << hex << et; 00235 } 00236 } 00237 m_file[crate] << sstrm.str() << endl; 00238 if(debug_NOTEMPTY[crate]) fdebug << sstrm.str() << endl; //debug 00239 sstrm << setfill(' ') << dec; 00240 00241 }// end crate loop 00242 00243 00245 for (unsigned i=0; i<NUM_RCT_CRATES; i++) 00246 m_file[i] << std::flush; 00247 00248 fdebug << std::flush; 00249 00250 }
std::ofstream RctDigiToRctText::fdebug [private] |
handle for debug file
Definition at line 55 of file RctDigiToRctText.h.
Referenced by analyze(), RctDigiToRctText(), and ~RctDigiToRctText().
std::ofstream RctDigiToRctText::m_file[NUM_RCT_CRATES] [private] |
handles for output files
Definition at line 52 of file RctDigiToRctText.h.
Referenced by analyze(), RctDigiToRctText(), and ~RctDigiToRctText().
bool RctDigiToRctText::m_hexUpperCase [private] |
write upper case hex words
Definition at line 49 of file RctDigiToRctText.h.
Referenced by analyze().
std::string RctDigiToRctText::m_textFileName [private] |
basename for output files
Definition at line 46 of file RctDigiToRctText.h.
Referenced by RctDigiToRctText().