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
RctDigiToSourceCardText Class Reference

#include <L1Trigger/TextToDigi/interface/RctDigiToSourceCardText.h>

Inheritance diagram for RctDigiToSourceCardText:
edm::EDAnalyzer

Public Member Functions

 RctDigiToSourceCardText (const edm::ParameterSet &)
 
 ~RctDigiToSourceCardText ()
 
- Public Member Functions inherited from edm::EDAnalyzer
 EDAnalyzer ()
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 

Private Member Functions

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

Private Attributes

std::ofstream m_file
 file handle More...
 
unsigned short m_nevt
 event counter More...
 
edm::InputTag m_rctInputLabel
 Label for RCT digis. More...
 
SourceCardRouting m_scRouting
 source card router More...
 
std::string m_textFileName
 Name out output file. More...
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
typedef WorkerT< EDAnalyzerWorkerType
 
- 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::EDAnalyzer
CurrentProcessingContext const * currentContext () const
 

Detailed Description

Description: Input RCT digis and output GCT text file to be loaded into the source cards for pattern tests.

Description: Input RCT digis and output text file to be loaded into the source cards for pattern tests.

Implementation: <Notes on="" implementation>="">

Definition at line 44 of file RctDigiToSourceCardText.h.

Constructor & Destructor Documentation

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

Definition at line 28 of file RctDigiToSourceCardText.cc.

References edm::hlt::Exception, m_file, m_scRouting, m_textFileName, and dbtoconf::out.

28  :
29  m_rctInputLabel(iConfig.getParameter<edm::InputTag>("RctInputLabel")),
30  m_textFileName(iConfig.getParameter<std::string>("TextFileName")),
31  m_nevt(0)
32 {
33  // Open the output file
34  m_file.open(m_textFileName.c_str(),std::ios::out);
35 
36  if(!m_file.good())
37  {
38  throw cms::Exception("RctDigiToSourceCardTextFileOpenError")
39  << "RctDigiToSourceCardText::RctDigiToSourceCardText : "
40  << " couldn't open the file " << m_textFileName << " for writing" << std::endl;
41  }
42 
43  // Make a SC routing object
45 }
T getParameter(std::string const &) const
std::ofstream m_file
file handle
edm::InputTag m_rctInputLabel
Label for RCT digis.
std::string m_textFileName
Name out output file.
tuple out
Definition: dbtoconf.py:99
unsigned short m_nevt
event counter
SourceCardRouting m_scRouting
source card router
RctDigiToSourceCardText::~RctDigiToSourceCardText ( )

Definition at line 48 of file RctDigiToSourceCardText.cc.

References m_file.

49 {
50  // Close the output file
51  m_file.close();
52 }
std::ofstream m_file
file handle

Member Function Documentation

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

Implements edm::EDAnalyzer.

Definition at line 55 of file RctDigiToSourceCardText.cc.

References SourceCardRouting::EMUtoSTRING(), edm::Event::getByLabel(), LogDebug, m_file, m_nevt, m_rctInputLabel, m_scRouting, NUM_RCT_CRATES, SourceCardRouting::RC012toSTRING(), SourceCardRouting::RC234toSTRING(), SourceCardRouting::RC56HFtoSTRING(), and SourceCardRouting::RoutingModetoLogicalCardID().

56 {
57 
58  // get the RCT data
61  iEvent.getByLabel(m_rctInputLabel, em);
62  iEvent.getByLabel(m_rctInputLabel, rgn);
63 
64  // General variables
65  int RoutingMode;
66  unsigned short logicalCardID;
67  std::string dataString;
68 
69  // Arrays to hold electron variables
70  unsigned short eIsoRank[18][4]={{0}};
71  unsigned short eIsoCardId[18][4]={{0}};
72  unsigned short eIsoRegionId[18][4]={{0}};
73  unsigned short eNonIsoRank[18][4]={{0}};
74  unsigned short eNonIsoCardId[18][4]={{0}};
75  unsigned short eNonIsoRegionId[18][4]={{0}};
76 
77  // Fill electrons
78  unsigned numIsoEM[18]={0};
79  unsigned numNonIsoEM[18]={0};
80 
81  for (L1CaloEmCollection::const_iterator iem=em->begin(); iem!=em->end(); iem++){
82  if (iem->isolated()){
83  eIsoRank[iem->rctCrate()][numIsoEM[iem->rctCrate()]]=iem->rank();
84  eIsoCardId[iem->rctCrate()][numIsoEM[iem->rctCrate()]]=iem->rctCard();
85  eIsoRegionId[iem->rctCrate()][numIsoEM[iem->rctCrate()]]=iem->rctRegion();
86  numIsoEM[iem->rctCrate()]++;
87  } else {
88  eNonIsoRank[iem->rctCrate()][numNonIsoEM[iem->rctCrate()]]=iem->rank();
89  eNonIsoCardId[iem->rctCrate()][numNonIsoEM[iem->rctCrate()]]=iem->rctCard();
90  eNonIsoRegionId[iem->rctCrate()][numNonIsoEM[iem->rctCrate()]]=iem->rctRegion();
91  numNonIsoEM[iem->rctCrate()]++;
92  }
93  // Debug info
94  LogDebug("Electrons") << "Rank=" << iem->rank()
95  << " Card=" << iem->rctCard()
96  << " Region=" << iem->rctRegion()
97  << " Crate=" << iem->rctCrate()
98  << " Isolated=" << iem->isolated();
99  }
100 
101  // Arrays to hold region variables
102  unsigned short RC[18][7][2]={{{0}}};
103  unsigned short RCof[18][7][2]={{{0}}};
104  unsigned short RCtau[18][7][2]={{{0}}};
105  unsigned short HF[18][4][2]={{{0}}};
106  unsigned short HFQ[18][4][2]={{{0}}};
107  unsigned short MIPbits[18][7][2]={{{0}}};
108  unsigned short Qbits[18][7][2]={{{0}}};
109 
110  // Fill regions
111  for (L1CaloRegionCollection::const_iterator irgn=rgn->begin(); irgn!=rgn->end(); irgn++){
112  if (irgn->id().isHf()){
113  HF[irgn->rctCrate()][irgn->id().rctEta()-7][irgn->id().rctPhi()]=irgn->et();
114  HFQ[irgn->rctCrate()][irgn->id().rctEta()-7][irgn->id().rctPhi()]=irgn->fineGrain();
115  // Debug info
116  LogDebug("HFRegions") << "Et=" << irgn->et()
117  << " FineGrain=" << irgn->fineGrain()
118  << " Eta=" << irgn->id().rctEta()
119  << " Phi=" << irgn->id().rctPhi()
120  << " Crate=" << irgn->rctCrate();
121  } else {
122  RC[irgn->rctCrate()][irgn->rctCard()][irgn->rctRegionIndex()]=irgn->et();
123  RCof[irgn->rctCrate()][irgn->rctCard()][irgn->rctRegionIndex()]=irgn->overFlow();
124  RCtau[irgn->rctCrate()][irgn->rctCard()][irgn->rctRegionIndex()]=irgn->tauVeto();
125  MIPbits[irgn->rctCrate()][irgn->rctCard()][irgn->rctRegionIndex()]=irgn->mip();
126  Qbits[irgn->rctCrate()][irgn->rctCard()][irgn->rctRegionIndex()]=irgn->quiet();
127  // Debug info
128  LogDebug("Regions") << "Et=" << irgn->et()
129  << " OverFlow=" << irgn->overFlow()
130  << " tauVeto=" << irgn->tauVeto()
131  << " mip=" << irgn->mip()
132  << " quiet=" << irgn->quiet()
133  << " Card=" << irgn->rctCard()
134  << " Region=" << irgn->rctRegionIndex()
135  << " Crate=" << irgn->rctCrate();
136  }
137  }
138 
139  for (int crate=0; crate<NUM_RCT_CRATES; crate++){
140 
141  // Logical Card ID = Source Card number
142  RoutingMode=0;
143  m_scRouting.RoutingModetoLogicalCardID(logicalCardID,RoutingMode,crate);
144 
145  // Convert electrons to SC format
146  m_scRouting.EMUtoSTRING(logicalCardID,
147  m_nevt,
148  eIsoRank[crate],
149  eIsoCardId[crate],
150  eIsoRegionId[crate],
151  eNonIsoRank[crate],
152  eNonIsoCardId[crate],
153  eNonIsoRegionId[crate],
154  MIPbits[crate],
155  Qbits[crate],
156  dataString);
157 
158  // Write electrons
159  m_file << dataString;
160 
161  // Logical Card ID = Source Card number
162  RoutingMode=1;
163  m_scRouting.RoutingModetoLogicalCardID(logicalCardID,RoutingMode,crate);
164 
165  // Convert regions to SC format
166  m_scRouting.RC56HFtoSTRING(logicalCardID,
167  m_nevt,
168  RC[crate],
169  RCof[crate],
170  RCtau[crate],
171  HF[crate],
172  HFQ[crate],
173  dataString);
174 
175  // Write regions
176  m_file << dataString;
177 
178  // Logical Card ID = Source Card number
179  RoutingMode=2;
180  m_scRouting.RoutingModetoLogicalCardID(logicalCardID,RoutingMode,crate);
181 
182  // Convert regions to SC format
183  m_scRouting.RC012toSTRING(logicalCardID,
184  m_nevt,
185  RC[crate],
186  RCof[crate],
187  RCtau[crate],
188  dataString);
189 
190  // Write regions
191  m_file << dataString;
192 
193  // This is to 9 only as this is the shared source card
194  if (crate<9){
195  // Logical Card ID = Source Card number
196  RoutingMode=3;
197  m_scRouting.RoutingModetoLogicalCardID(logicalCardID,RoutingMode,crate);
198 
199  // Convert regions to SC format
200  m_scRouting.RC234toSTRING(logicalCardID,
201  m_nevt,
202  RC[crate],
203  RCof[crate],
204  RCtau[crate],
205  RC[crate+9],
206  RCof[crate+9],
207  RCtau[crate+9],
208  dataString);
209 
210  // Write regions
211  m_file << dataString;
212  }
213 
214  }
215 
216  // Force write to file
217  m_file << flush;
218 
219  m_nevt++;
220 }
#define LogDebug(id)
void RC012toSTRING(unsigned short &logicalCardID, unsigned short &eventNumber, unsigned short(&RC)[7][2], unsigned short(&RCof)[7][2], unsigned short(&RCtau)[7][2], std::string &dataString) const
std::ofstream m_file
file handle
edm::InputTag m_rctInputLabel
Label for RCT digis.
void RC234toSTRING(unsigned short &logicalCardID, unsigned short &eventNumber, unsigned short(&RC)[7][2], unsigned short(&RCof)[7][2], unsigned short(&RCtau)[7][2], unsigned short(&sisterRC)[7][2], unsigned short(&sisterRCof)[7][2], unsigned short(&sisterRCtau)[7][2], std::string &dataString) const
void RoutingModetoLogicalCardID(unsigned short &logicalCardID, int &RoutingMode, int &RCTCrateNumber) const
void EMUtoSTRING(unsigned short &logicalCardID, unsigned short &eventNumber, unsigned short(&eIsoRank)[4], unsigned short(&eIsoCardId)[4], unsigned short(&eIsoRegionId)[4], unsigned short(&eNonIsoRank)[4], unsigned short(&eNonIsoCardId)[4], unsigned short(&eNonIsoRegionId)[4], unsigned short(&MIPbits)[7][2], unsigned short(&Qbits)[7][2], std::string &dataString) const
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
unsigned short m_nevt
event counter
void RC56HFtoSTRING(unsigned short &logicalCardID, unsigned short &eventNumber, unsigned short(&RC)[7][2], unsigned short(&RCof)[7][2], unsigned short(&RCtau)[7][2], unsigned short(&HF)[4][2], unsigned short(&HFQ)[4][2], std::string &dataString) const
SourceCardRouting m_scRouting
source card router
static const int NUM_RCT_CRATES

Member Data Documentation

std::ofstream RctDigiToSourceCardText::m_file
private

file handle

Definition at line 59 of file RctDigiToSourceCardText.h.

Referenced by analyze(), RctDigiToSourceCardText(), and ~RctDigiToSourceCardText().

unsigned short RctDigiToSourceCardText::m_nevt
private

event counter

Definition at line 62 of file RctDigiToSourceCardText.h.

Referenced by analyze().

edm::InputTag RctDigiToSourceCardText::m_rctInputLabel
private

Label for RCT digis.

Definition at line 53 of file RctDigiToSourceCardText.h.

Referenced by analyze().

SourceCardRouting RctDigiToSourceCardText::m_scRouting
private

source card router

Definition at line 65 of file RctDigiToSourceCardText.h.

Referenced by analyze(), and RctDigiToSourceCardText().

std::string RctDigiToSourceCardText::m_textFileName
private

Name out output file.

Definition at line 56 of file RctDigiToSourceCardText.h.

Referenced by RctDigiToSourceCardText().