CMS 3D CMS Logo

RctDigiToSourceCardText.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: RctDigiToSourceCardText
4 // Class: RctDigiToSourceCardText
5 //
13 //
14 // Original Author: Alex Tapper
15 // Created: Fri Feb 16 14:52:19 CET 2007
16 //
17 //
18 
20 #include "FWCore/ServiceRegistry/interface/Service.h" // Framework services
22 
23 using namespace edm;
24 using namespace std;
25 
26 // Set constant
27 const static int NUM_RCT_CRATES = 18;
28 
30  : m_rctInputLabel(iConfig.getParameter<edm::InputTag>("RctInputLabel")),
31  m_textFileName(iConfig.getParameter<std::string>("TextFileName")),
32  m_nevt(0) {
33  // Open the output file
34  m_file.open(m_textFileName.c_str(), std::ios::out);
35 
36  if (!m_file.good()) {
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 }
45 
47  // Close the output file
48  m_file.close();
49 }
50 
51 // ------------ method called to for each event ------------
53  // get the RCT data
56  iEvent.getByLabel(m_rctInputLabel, em);
57  iEvent.getByLabel(m_rctInputLabel, rgn);
58 
59  // General variables
60  int RoutingMode;
61  unsigned short logicalCardID;
62  std::string dataString;
63 
64  // Arrays to hold electron variables
65  unsigned short eIsoRank[18][4] = {{0}};
66  unsigned short eIsoCardId[18][4] = {{0}};
67  unsigned short eIsoRegionId[18][4] = {{0}};
68  unsigned short eNonIsoRank[18][4] = {{0}};
69  unsigned short eNonIsoCardId[18][4] = {{0}};
70  unsigned short eNonIsoRegionId[18][4] = {{0}};
71 
72  // Fill electrons
73  unsigned numIsoEM[18] = {0};
74  unsigned numNonIsoEM[18] = {0};
75 
76  for (L1CaloEmCollection::const_iterator iem = em->begin(); iem != em->end(); iem++) {
77  if (iem->isolated()) {
78  eIsoRank[iem->rctCrate()][numIsoEM[iem->rctCrate()]] = iem->rank();
79  eIsoCardId[iem->rctCrate()][numIsoEM[iem->rctCrate()]] = iem->rctCard();
80  eIsoRegionId[iem->rctCrate()][numIsoEM[iem->rctCrate()]] = iem->rctRegion();
81  numIsoEM[iem->rctCrate()]++;
82  } else {
83  eNonIsoRank[iem->rctCrate()][numNonIsoEM[iem->rctCrate()]] = iem->rank();
84  eNonIsoCardId[iem->rctCrate()][numNonIsoEM[iem->rctCrate()]] = iem->rctCard();
85  eNonIsoRegionId[iem->rctCrate()][numNonIsoEM[iem->rctCrate()]] = iem->rctRegion();
86  numNonIsoEM[iem->rctCrate()]++;
87  }
88  // Debug info
89  LogDebug("Electrons") << "Rank=" << iem->rank() << " Card=" << iem->rctCard() << " Region=" << iem->rctRegion()
90  << " Crate=" << iem->rctCrate() << " Isolated=" << iem->isolated();
91  }
92 
93  // Arrays to hold region variables
94  unsigned short RC[18][7][2] = {{{0}}};
95  unsigned short RCof[18][7][2] = {{{0}}};
96  unsigned short RCtau[18][7][2] = {{{0}}};
97  unsigned short HF[18][4][2] = {{{0}}};
98  unsigned short HFQ[18][4][2] = {{{0}}};
99  unsigned short MIPbits[18][7][2] = {{{0}}};
100  unsigned short Qbits[18][7][2] = {{{0}}};
101 
102  // Fill regions
103  for (L1CaloRegionCollection::const_iterator irgn = rgn->begin(); irgn != rgn->end(); irgn++) {
104  if (irgn->id().isHf()) {
105  HF[irgn->rctCrate()][irgn->id().rctEta() - 7][irgn->id().rctPhi()] = irgn->et();
106  HFQ[irgn->rctCrate()][irgn->id().rctEta() - 7][irgn->id().rctPhi()] = irgn->fineGrain();
107  // Debug info
108  LogDebug("HFRegions") << "Et=" << irgn->et() << " FineGrain=" << irgn->fineGrain()
109  << " Eta=" << irgn->id().rctEta() << " Phi=" << irgn->id().rctPhi()
110  << " Crate=" << irgn->rctCrate();
111  } else {
112  RC[irgn->rctCrate()][irgn->rctCard()][irgn->rctRegionIndex()] = irgn->et();
113  RCof[irgn->rctCrate()][irgn->rctCard()][irgn->rctRegionIndex()] = irgn->overFlow();
114  RCtau[irgn->rctCrate()][irgn->rctCard()][irgn->rctRegionIndex()] = irgn->tauVeto();
115  MIPbits[irgn->rctCrate()][irgn->rctCard()][irgn->rctRegionIndex()] = irgn->mip();
116  Qbits[irgn->rctCrate()][irgn->rctCard()][irgn->rctRegionIndex()] = irgn->quiet();
117  // Debug info
118  LogDebug("Regions") << "Et=" << irgn->et() << " OverFlow=" << irgn->overFlow() << " tauVeto=" << irgn->tauVeto()
119  << " mip=" << irgn->mip() << " quiet=" << irgn->quiet() << " Card=" << irgn->rctCard()
120  << " Region=" << irgn->rctRegionIndex() << " Crate=" << irgn->rctCrate();
121  }
122  }
123 
124  for (int crate = 0; crate < NUM_RCT_CRATES; crate++) {
125  // Logical Card ID = Source Card number
126  RoutingMode = 0;
127  m_scRouting.RoutingModetoLogicalCardID(logicalCardID, RoutingMode, crate);
128 
129  // Convert electrons to SC format
130  m_scRouting.EMUtoSTRING(logicalCardID,
131  m_nevt,
132  eIsoRank[crate],
133  eIsoCardId[crate],
134  eIsoRegionId[crate],
135  eNonIsoRank[crate],
136  eNonIsoCardId[crate],
137  eNonIsoRegionId[crate],
138  MIPbits[crate],
139  Qbits[crate],
140  dataString);
141 
142  // Write electrons
143  m_file << dataString;
144 
145  // Logical Card ID = Source Card number
146  RoutingMode = 1;
147  m_scRouting.RoutingModetoLogicalCardID(logicalCardID, RoutingMode, crate);
148 
149  // Convert regions to SC format
151  logicalCardID, m_nevt, RC[crate], RCof[crate], RCtau[crate], HF[crate], HFQ[crate], dataString);
152 
153  // Write regions
154  m_file << dataString;
155 
156  // Logical Card ID = Source Card number
157  RoutingMode = 2;
158  m_scRouting.RoutingModetoLogicalCardID(logicalCardID, RoutingMode, crate);
159 
160  // Convert regions to SC format
161  m_scRouting.RC012toSTRING(logicalCardID, m_nevt, RC[crate], RCof[crate], RCtau[crate], dataString);
162 
163  // Write regions
164  m_file << dataString;
165 
166  // This is to 9 only as this is the shared source card
167  if (crate < 9) {
168  // Logical Card ID = Source Card number
169  RoutingMode = 3;
170  m_scRouting.RoutingModetoLogicalCardID(logicalCardID, RoutingMode, crate);
171 
172  // Convert regions to SC format
173  m_scRouting.RC234toSTRING(logicalCardID,
174  m_nevt,
175  RC[crate],
176  RCof[crate],
177  RCtau[crate],
178  RC[crate + 9],
179  RCof[crate + 9],
180  RCtau[crate + 9],
181  dataString);
182 
183  // Write regions
184  m_file << dataString;
185  }
186  }
187 
188  // Force write to file
189  m_file << flush;
190 
191  m_nevt++;
192 }
MessageLogger.h
RctDigiToSourceCardText::m_rctInputLabel
edm::InputTag m_rctInputLabel
Label for RCT digis.
Definition: RctDigiToSourceCardText.h:53
edm
HLT enums.
Definition: AlignableModifier.h:19
RctDigiToSourceCardText::~RctDigiToSourceCardText
~RctDigiToSourceCardText() override
Definition: RctDigiToSourceCardText.cc:46
SourceCardRouting::RC012toSTRING
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
Definition: SourceCardRouting.cc:651
RctDigiToSourceCardText::m_file
std::ofstream m_file
file handle
Definition: RctDigiToSourceCardText.h:59
edm::Handle
Definition: AssociativeIterator.h:50
SourceCardRouting
Definition: SourceCardRouting.h:13
SourceCardRouting::RC56HFtoSTRING
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
Definition: SourceCardRouting.cc:635
SourceCardRouting::EMUtoSTRING
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
Definition: SourceCardRouting.cc:615
RctDigiToSourceCardText::m_textFileName
std::string m_textFileName
Name out output file.
Definition: RctDigiToSourceCardText.h:56
Service.h
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
RctDigiToSourceCardText::RctDigiToSourceCardText
RctDigiToSourceCardText(const edm::ParameterSet &)
Definition: RctDigiToSourceCardText.cc:29
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:233
edm::ParameterSet
Definition: ParameterSet.h:47
RctDigiToSourceCardText.h
SourceCardRouting::RC234toSTRING
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
Definition: SourceCardRouting.cc:665
iEvent
int iEvent
Definition: GenABIO.cc:224
edm::EventSetup
Definition: EventSetup.h:58
RctDigiToSourceCardText::m_nevt
unsigned short m_nevt
event counter
Definition: RctDigiToSourceCardText.h:62
std
Definition: JetResolutionObject.h:76
NUM_RCT_CRATES
const static int NUM_RCT_CRATES
Definition: RctDigiToSourceCardText.cc:27
Exception
Definition: hltDiff.cc:245
RctDigiToSourceCardText::m_scRouting
SourceCardRouting m_scRouting
source card router
Definition: RctDigiToSourceCardText.h:65
MillePedeFileConverter_cfg.out
out
Definition: MillePedeFileConverter_cfg.py:31
edm::Event
Definition: Event.h:73
SourceCardRouting::RoutingModetoLogicalCardID
void RoutingModetoLogicalCardID(unsigned short &logicalCardID, int &RoutingMode, int &RCTCrateNumber) const
Definition: SourceCardRouting.cc:750
DigiToRawDM_cff.HF
HF
Definition: DigiToRawDM_cff.py:22
edm::InputTag
Definition: InputTag.h:15
RctDigiToSourceCardText::analyze
void analyze(const edm::Event &, const edm::EventSetup &) override
Definition: RctDigiToSourceCardText.cc:52