13 m_rctInputLabel(iConfig.getParameter<edm::InputTag>(
"RctInputLabel")),
14 m_textFileName(iConfig.getParameter<std::
string>(
"TextFileName")),
15 m_hexUpperCase(iConfig.getParameter<bool>(
"HexUpperCase")) {
19 std::stringstream fileStream;
20 fileStream <<
m_textFileName << std::setw(2) << std::setfill(
'0') <<
i <<
".txt";
26 <<
"RctDigiToRctText::RctDigiToRctText : "
27 <<
" couldn't create the file " <<
fileName << std::endl;
60 bool debug_NOTEMPTY[18]={0};
61 for(
int i=0;
i<18;
i++) debug_NOTEMPTY[
i]=
false;
62 std::stringstream dstrm;
67 unsigned long int CAND[18][8];
73 for(L1CaloEmCollection::const_iterator iem=em->begin(); iem!=em->end(); iem++){
75 int crate = iem->rctCrate();
76 iso = iem->isolated();
77 unsigned data = iem->raw();
79 id = iso ? n_iso[crate]++ : 4 + n_niso[crate]++;
81 CAND[crate][id] =
data;
84 if(crate>17 ||
id > 7)
86 <<
"out of bounds indices crate:" << crate <<
"id:" <<
id << std::endl;
88 debug_NOTEMPTY[crate] =
true;
95 <<
" \t cand:" << *iem;
96 if(debug_NOTEMPTY[crate])
fdebug << dstrm.str() << std::endl;
102 unsigned short MIPbits [18][7][2] = {{{0}}};
103 unsigned short QIEbits [18][7][2] = {{{0}}};
104 unsigned short RC [18][7][2] = {{{0}}};
105 unsigned short RCof [18][7][2] = {{{0}}};
106 unsigned short RCtau [18][7][2] = {{{0}}};
107 unsigned short HF [18][4][2] = {{{0}}};
109 for (L1CaloRegionCollection::const_iterator irgn=rgn->begin(); irgn!=rgn->end(); irgn++){
111 int crate = irgn->rctCrate();
112 int card = irgn->rctCard();
113 int rgnidx= irgn->rctRegionIndex();
116 if (!irgn->id().isHf()){
117 RC [crate][card][rgnidx]=irgn->et();
118 RCof [crate][card][rgnidx]=irgn->overFlow();
119 RCtau [crate][card][rgnidx]=irgn->tauVeto();
120 MIPbits[crate][card][rgnidx]=irgn->mip();
121 QIEbits[crate][card][rgnidx]=irgn->quiet();
124 <<
"Et=" << irgn->et()
125 <<
" OverFlow=" << irgn->overFlow()
126 <<
" tauVeto=" << irgn->tauVeto()
127 <<
" mip=" << irgn->mip()
128 <<
" quiet=" << irgn->quiet()
129 <<
" Card=" << irgn->rctCard()
130 <<
" Region=" << irgn->rctRegionIndex()
131 <<
" Crate=" << irgn->rctCrate()
133 if(ldebug)
LogDebug(
"Regions") << dstrm.str();
135 HF [crate][irgn->id().rctEta()-7][irgn->id().rctPhi()]=irgn->et();
138 <<
"Et=" << irgn->et()
139 <<
" FGrain=" << irgn->fineGrain()
140 <<
" Eta=" << irgn->id().rctEta()
141 <<
" Phi=" << irgn->id().rctPhi()
142 <<
" Crate=" << irgn->rctCrate()
144 if(ldebug)
LogDebug(
"HFRegions") << dstrm.str();
148 if(ldebug &&irgn->et()!=0) debug_NOTEMPTY[crate] =
true;
149 if(debug_NOTEMPTY[crate]) {
152 <<
" crate:" << crate
154 fdebug << dstrm.str() << std::endl;
159 std::stringstream sstrm;
161 sstrm << std::uppercase;
163 sstrm.unsetf(std::ios::uppercase);
171 sstrm <<
"Crossing " << nevt << std::endl;
173 for(
int j=0;
j<8;
j++) {
174 sstrm << setw(3) << setfill(
'0') << hex << (CAND[crate][
j] & 0x3ff);
175 if(
j<7) sstrm <<
" ";
177 sstrm << setfill(
' ') << dec;
178 m_file[crate] << sstrm.str() << std::endl;
181 if(debug_NOTEMPTY[crate])
fdebug << sstrm.str() << std::endl;
182 if(ldebug)
LogDebug(
"Electrons") << sstrm.str() << std::endl;
193 for (
int card=0; card<7; card++){
194 for (
int j=0;
j<2;
j++){
195 sstrm <<
" " << MIPbits[crate][card][
j];
198 m_file[crate] << sstrm.str() << std::endl;
199 if(debug_NOTEMPTY[crate])
fdebug << sstrm.str() << std::endl;
203 for (
int card=0; card<7; card++){
204 for (
int j=0;
j<2;
j++){
205 sstrm <<
" " << QIEbits[crate][card][
j];
208 m_file[crate] << sstrm.str() << std::endl;
209 if(debug_NOTEMPTY[crate])
fdebug << sstrm.str() << std::endl;
213 for (
int card=0; card<7; card++){
214 for (
int j=0;
j<2;
j++){
215 unsigned long int tmp;
216 unsigned et = RC [crate][card][
j];
217 unsigned ovf = RCof [crate][card][
j];
218 unsigned tau = RCtau[crate][card][
j];
220 tmp = ((tau & 0x1) << 11) | ((ovf &0x1)<<10) | ((et & 0x3ff));
221 sstrm <<
" " << setw(3) << setfill(
'0') << hex <<
tmp;
225 m_file[crate] << sstrm.str() << std::endl;
226 if(debug_NOTEMPTY[crate])
fdebug << sstrm.str() << std::endl << std::endl;
231 for (
int ip=0; ip<2; ip++){
232 for (
int ie=0; ie<4; ie++){
233 unsigned et = HF[crate][ie][ip] & 0xff;
234 sstrm <<
" " << setw(2) << setfill(
'0') << hex << et;
237 m_file[crate] << sstrm.str() << std::endl;
238 if(debug_NOTEMPTY[crate])
fdebug << sstrm.str() << std::endl;
239 sstrm << setfill(
' ') << dec;
static const unsigned NUM_RCT_CRATES
virtual void analyze(const edm::Event &, const edm::EventSetup &)
bool m_hexUpperCase
write upper case hex words
edm::InputTag m_rctInputLabel
label for RCT digis
std::ofstream m_file[NUM_RCT_CRATES]
handles for output files
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
RctDigiToRctText(const edm::ParameterSet &)
std::vector< std::vector< double > > tmp
std::string m_textFileName
basename for output files
char data[epos_bytes_allocation]
std::ofstream fdebug
handle for debug file