CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
RctDigiToRctText Class Reference

#include <RctDigiToRctText.h>

Inheritance diagram for RctDigiToRctText:
edm::EDAnalyzer edm::EDConsumerBase

Public Member Functions

 RctDigiToRctText (const edm::ParameterSet &)
 
 ~RctDigiToRctText ()
 
- Public Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Member Functions

virtual void analyze (const edm::Event &, const edm::EventSetup &)
 

Private Attributes

std::ofstream fdebug
 handle for debug file More...
 
std::ofstream m_file [NUM_RCT_CRATES]
 handles for output files More...
 
bool m_hexUpperCase
 write upper case hex words More...
 
edm::InputTag m_rctInputLabel
 label for RCT digis More...
 
std::string m_textFileName
 basename for output files More...
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

Definition at line 32 of file RctDigiToRctText.h.

Constructor & Destructor Documentation

RctDigiToRctText::RctDigiToRctText ( const edm::ParameterSet iConfig)
explicit

open output text files

open info|debug file

Definition at line 12 of file RctDigiToRctText.cc.

References Exception, fdebug, MillePedeFileConverter_cfg::fileName, i, m_file, m_textFileName, NUM_RCT_CRATES, dbtoconf::out, and AlCaHLTBitMon_QueryRunRegistry::string.

12  :
13  m_rctInputLabel(iConfig.getParameter<edm::InputTag>("RctInputLabel")),
14  m_textFileName(iConfig.getParameter<std::string>("TextFileName")),
15  m_hexUpperCase(iConfig.getParameter<bool>("HexUpperCase")) {
16 
18  for (unsigned i=0; i<NUM_RCT_CRATES; i++){
19  std::stringstream fileStream;
20  fileStream << m_textFileName << std::setw(2) << std::setfill('0') << i << ".txt";
21  std::string fileName(fileStream.str());
22  m_file[i].open(fileName.c_str(),std::ios::out);
23 
24  if(!m_file[i].good()) {
25  throw cms::Exception("RctDigiToRctTextTextFileOpenError")
26  << "RctDigiToRctText::RctDigiToRctText : "
27  << " couldn't create the file " << fileName << std::endl;
28  }
29  }
30 
32  fdebug.open("rctdigitorcttext_debug.txt", std::ios::out);
33 
34 }
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
static const unsigned NUM_RCT_CRATES
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
tuple out
Definition: dbtoconf.py:99
std::string m_textFileName
basename for output files
std::ofstream fdebug
handle for debug file
RctDigiToRctText::~RctDigiToRctText ( )

close files

Definition at line 37 of file RctDigiToRctText.cc.

References fdebug, i, m_file, and NUM_RCT_CRATES.

37  {
39  for (unsigned i=0; i<NUM_RCT_CRATES; i++)
40  m_file[i].close();
41  fdebug.close();
42 }
int i
Definition: DBlmapReader.cc:9
static const unsigned NUM_RCT_CRATES
std::ofstream m_file[NUM_RCT_CRATES]
handles for output files
std::ofstream fdebug
handle for debug file

Member Function Documentation

void RctDigiToRctText::analyze ( const edm::Event iEvent,
const edm::EventSetup iSetup 
)
privatevirtual

count bunch crossing

get the RCT data

debug flags and stream

— ELECTRONS —

debug

— 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, TauDecayModes::dec, Exception, fdebug, edm::Event::getByLabel(), hi::HF, i, j, LogDebug, m_file, m_hexUpperCase, m_rctInputLabel, nevt, NUM_RCT_CRATES, metsig::tau, and tmp.

46  {
47 
49  static int nevt = -1;
50  nevt++;
51 
55  iEvent.getByLabel(m_rctInputLabel, em);
56  iEvent.getByLabel(m_rctInputLabel, rgn);
57 
59  bool ldebug = false;
60  bool debug_NOTEMPTY[18]={0};
61  for(int i=0; i<18; i++) debug_NOTEMPTY[i]=false;
62  std::stringstream dstrm;
63 
64 
66 
67  unsigned long int CAND[18][8];
68  int n_iso [18]={0};
69  int n_niso[18]={0};
70  bool iso;
71  int id;
72 
73  for(L1CaloEmCollection::const_iterator iem=em->begin(); iem!=em->end(); iem++){
74 
75  int crate = iem->rctCrate();
76  iso = iem->isolated();
77  unsigned data = iem->raw();
78 
79  id = iso ? n_iso[crate]++ : 4 + n_niso[crate]++;
80 
81  CAND[crate][id] = data;
82 
84  if(crate>17 || id > 7)
85  throw cms::Exception("RctDigiToRctTextElectronIndexOutBounds")
86  << "out of bounds indices crate:" << crate << "id:" << id << std::endl;
87  if(ldebug&&data!=0)
88  debug_NOTEMPTY[crate] = true;
89  dstrm.str("");
90  dstrm << "electron "
91  << " bx:" << nevt
92  << " crate:" << crate
93  << " iso:" << iso
94  << " raw:" << data
95  << " \t cand:" << *iem;
96  if(debug_NOTEMPTY[crate]) fdebug << dstrm.str() << std::endl;
97  }
98 
99 
101 
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}}};
108 
109  for (L1CaloRegionCollection::const_iterator irgn=rgn->begin(); irgn!=rgn->end(); irgn++){
110 
111  int crate = irgn->rctCrate();
112  int card = irgn->rctCard();
113  int rgnidx= irgn->rctRegionIndex();
114 
115  dstrm.str("");
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();
122  // debug info
123  dstrm << hex
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()
132  << dec;
133  if(ldebug) LogDebug("Regions") << dstrm.str();
134  } else {
135  HF [crate][irgn->id().rctEta()-7][irgn->id().rctPhi()]=irgn->et();
136  // debug info
137  dstrm << hex
138  << "Et=" << irgn->et()
139  << " FGrain=" << irgn->fineGrain()
140  << " Eta=" << irgn->id().rctEta()
141  << " Phi=" << irgn->id().rctPhi()
142  << " Crate=" << irgn->rctCrate()
143  << dec;
144  if(ldebug) LogDebug("HFRegions") << dstrm.str();
145  }
146 
147 
148  if(ldebug &&irgn->et()!=0) debug_NOTEMPTY[crate] = true; //debug
149  if(debug_NOTEMPTY[crate]) {
150  fdebug << "region"
151  << " bx:" << nevt
152  << " crate:" << crate
153  << "\t";
154  fdebug << dstrm.str() << std::endl;
155  }
156  }
157 
158 
159  std::stringstream sstrm;
160  if(m_hexUpperCase)
161  sstrm << std::uppercase;
162  else
163  sstrm.unsetf(std::ios::uppercase);
164 
165 
167 
168  for (unsigned crate=0; crate<NUM_RCT_CRATES; crate++){
169 
170  sstrm.str("");
171  sstrm << "Crossing " << nevt << std::endl;
172 
173  for(int j=0; j<8; j++) {
174  sstrm << setw(3) << setfill('0') << hex << (CAND[crate][j] & 0x3ff);
175  if(j<7) sstrm << " ";
176  }
177  sstrm << setfill(' ') << dec;
178  m_file[crate] << sstrm.str() << std::endl;
179 
180  // debug
181  if(debug_NOTEMPTY[crate]) fdebug << sstrm.str() << std::endl;
182  if(ldebug) LogDebug("Electrons") << sstrm.str() << std::endl;
183 
184  }
185 
186 
188 
189  for (unsigned crate=0; crate<NUM_RCT_CRATES; crate++){
190 
192  sstrm.str("");
193  for (int card=0; card<7; card++){
194  for (int j=0; j<2; j++){
195  sstrm << " " << MIPbits[crate][card][j];
196  }
197  }
198  m_file[crate] << sstrm.str() << std::endl;
199  if(debug_NOTEMPTY[crate]) fdebug << sstrm.str() << std::endl; //debug
200 
202  sstrm.str("");
203  for (int card=0; card<7; card++){
204  for (int j=0; j<2; j++){
205  sstrm << " " << QIEbits[crate][card][j];
206  }
207  }
208  m_file[crate] << sstrm.str() << std::endl;
209  if(debug_NOTEMPTY[crate]) fdebug << sstrm.str() << std::endl; //debug
210 
212  sstrm.str("");
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];
219  //ovf = ovf || (et>=0x400);
220  tmp = ((tau & 0x1) << 11) | ((ovf &0x1)<<10) | ((et & 0x3ff));
221  sstrm << " " << setw(3) << setfill('0') << hex << tmp;
222 
223  }
224  }
225  m_file[crate] << sstrm.str() << std::endl;
226  if(debug_NOTEMPTY[crate]) fdebug << sstrm.str() << std::endl << std::endl; //debug
227 
228 
230  sstrm.str("");
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;
235  }
236  }
237  m_file[crate] << sstrm.str() << std::endl;
238  if(debug_NOTEMPTY[crate]) fdebug << sstrm.str() << std::endl; //debug
239  sstrm << setfill(' ') << dec;
240 
241  }// end crate loop
242 
243 
245  for (unsigned i=0; i<NUM_RCT_CRATES; i++)
246  m_file[i] << std::flush;
247 
248  fdebug << std::flush;
249 
250 }
#define LogDebug(id)
int i
Definition: DBlmapReader.cc:9
static const unsigned NUM_RCT_CRATES
bool m_hexUpperCase
write upper case hex words
edm::InputTag m_rctInputLabel
label for RCT digis
int j
Definition: DBlmapReader.cc:9
std::ofstream m_file[NUM_RCT_CRATES]
handles for output files
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:413
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
std::ofstream fdebug
handle for debug file

Member Data Documentation

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().

edm::InputTag RctDigiToRctText::m_rctInputLabel
private

label for RCT digis

Definition at line 43 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().