CMS 3D CMS Logo

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 edm::EDConsumerBase

Public Member Functions

 RctDigiToSourceCardText (const edm::ParameterSet &)
 
 ~RctDigiToSourceCardText ()
 
- 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
 
 ~EDAnalyzer () override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
virtual ~EDConsumerBase () noexcept(false)
 

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
 
- 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

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 43 of file RctDigiToSourceCardText.h.

Constructor & Destructor Documentation

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

Definition at line 27 of file RctDigiToSourceCardText.cc.

References Exception, m_file, m_scRouting, m_textFileName, and MillePedeFileConverter_cfg::out.

27  :
28  m_rctInputLabel(iConfig.getParameter<edm::InputTag>("RctInputLabel")),
29  m_textFileName(iConfig.getParameter<std::string>("TextFileName")),
30  m_nevt(0)
31 {
32  // Open the output file
33  m_file.open(m_textFileName.c_str(),std::ios::out);
34 
35  if(!m_file.good())
36  {
37  throw cms::Exception("RctDigiToSourceCardTextFileOpenError")
38  << "RctDigiToSourceCardText::RctDigiToSourceCardText : "
39  << " couldn't open the file " << m_textFileName << " for writing" << std::endl;
40  }
41 
42  // Make a SC routing object
44 }
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.
unsigned short m_nevt
event counter
SourceCardRouting m_scRouting
source card router
RctDigiToSourceCardText::~RctDigiToSourceCardText ( )

Definition at line 47 of file RctDigiToSourceCardText.cc.

References m_file.

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

Member Function Documentation

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

Definition at line 54 of file RctDigiToSourceCardText.cc.

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

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

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

unsigned short RctDigiToSourceCardText::m_nevt
private

event counter

Definition at line 61 of file RctDigiToSourceCardText.h.

Referenced by analyze().

edm::InputTag RctDigiToSourceCardText::m_rctInputLabel
private

Label for RCT digis.

Definition at line 52 of file RctDigiToSourceCardText.h.

Referenced by analyze().

SourceCardRouting RctDigiToSourceCardText::m_scRouting
private

source card router

Definition at line 64 of file RctDigiToSourceCardText.h.

Referenced by analyze(), and RctDigiToSourceCardText().

std::string RctDigiToSourceCardText::m_textFileName
private

Name out output file.

Definition at line 55 of file RctDigiToSourceCardText.h.

Referenced by RctDigiToSourceCardText().