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 Attributes
L1RCTSaveInput Class Reference

#include <src/L1RCTSaveInput/src/L1RCTSaveInput.cc>

Inheritance diagram for L1RCTSaveInput:
edm::EDAnalyzer

Public Member Functions

virtual void analyze (const edm::Event &, const edm::EventSetup &)
 
 L1RCTSaveInput (const edm::ParameterSet &)
 
 ~L1RCTSaveInput ()
 
- Public Member Functions inherited from edm::EDAnalyzer
 EDAnalyzer ()
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 

Private Attributes

edm::InputTag ecalDigisLabel
 
std::string fileName
 
edm::InputTag hcalDigisLabel
 
std::ofstream ofs
 
L1RCTrct
 
L1RCTLookupTablesrctLookupTables
 
bool useDebugTpgScales
 
bool useEcal
 
bool useHcal
 

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)
 
- Protected Member Functions inherited from edm::EDAnalyzer
CurrentProcessingContext const * currentContext () const
 

Detailed Description

Description: Saves the input event from TPGs for loading simulated events in hardware

Implementation: Kind of kludgy – should think of a better way in future

Definition at line 39 of file L1RCTSaveInput.h.

Constructor & Destructor Documentation

L1RCTSaveInput::L1RCTSaveInput ( const edm::ParameterSet conf)
explicit

Definition at line 45 of file L1RCTSaveInput.cc.

References benchmark_cfg::cerr, cmsRelvalreport::exit, fileName, and ofs.

45  :
46  fileName(conf.getUntrackedParameter<std::string>("rctTestInputFile")),
49  useEcal(conf.getParameter<bool>("useEcal")),
50  useHcal(conf.getParameter<bool>("useHcal")),
51  ecalDigisLabel(conf.getParameter<edm::InputTag>("ecalDigisLabel")),
52  hcalDigisLabel(conf.getParameter<edm::InputTag>("hcalDigisLabel")),
53  useDebugTpgScales(conf.getParameter<bool>("useDebugTpgScales"))
54 {
55  ofs.open(fileName.c_str(), std::ios::app);
56  if(!ofs)
57  {
58  std::cerr << "Could not create " << fileName << std::endl;
59  exit(1);
60  }
61 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
edm::InputTag ecalDigisLabel
L1RCTLookupTables * rctLookupTables
std::string fileName
std::ofstream ofs
Definition: L1RCT.h:20
edm::InputTag hcalDigisLabel
L1RCTSaveInput::~L1RCTSaveInput ( )

Definition at line 63 of file L1RCTSaveInput.cc.

References rct, and rctLookupTables.

64 {
65  if(rct != 0) delete rct;
66  if(rctLookupTables != 0) delete rctLookupTables;
67 }
L1RCTLookupTables * rctLookupTables

Member Function Documentation

void L1RCTSaveInput::analyze ( const edm::Event event,
const edm::EventSetup eventSetup 
)
virtual

Implements edm::EDAnalyzer.

Definition at line 70 of file L1RCTSaveInput.cc.

References trackerHits::c, gather_cfg::cout, L1RCT::digiInput(), patCandidatesForDimuonsSequences_cff::ecal, EcalBarrel, L1RCT::ecalCompressedET(), ecalDigisLabel, EcalEndcap, L1RCT::ecalFineGrainBit(), edm::EventSetup::get(), EcalTPGScale::getTPGInGeV(), h, patCandidatesForDimuonsSequences_cff::hcal, L1RCT::hcalCompressedET(), hcalDigisLabel, CaloTPGTranscoder::hcaletValue(), L1RCT::hcalFineGrainBit(), edm::HandleBase::isValid(), L1RCTLookupTables::lookup(), L1CaloEcalScale::nBinEta, L1CaloHcalScale::nBinEta, L1CaloHcalScale::nBinRank, L1CaloEcalScale::nBinRank, nEvents, ofs, edm::ESHandle< class >::product(), csvReporter::r, rct, rctLookupTables, asciidump::s, L1CaloHcalScale::setBin(), L1CaloEcalScale::setBin(), L1RCTLookupTables::setChannelMask(), L1RCTLookupTables::setEcalScale(), EcalTPGScale::setEventSetup(), L1RCTLookupTables::setHcalScale(), L1RCTLookupTables::setL1CaloEtScale(), L1RCTLookupTables::setRCTParameters(), and useDebugTpgScales.

72 {
73  edm::ESHandle<L1RCTParameters> rctParameters;
74  eventSetup.get<L1RCTParametersRcd>().get(rctParameters);
75  const L1RCTParameters* r = rctParameters.product();
77  eventSetup.get<L1RCTChannelMaskRcd>().get(channelMask);
78  const L1RCTChannelMask* c = channelMask.product();
80  eventSetup.get<L1EmEtScaleRcd>().get(emScale);
81  const L1CaloEtScale* s = emScale.product();
82 
86 
87  // use dummies to get delete right when creating new scales from old
88  L1CaloEcalScale* dummyE(0);
89  L1CaloHcalScale* dummyH(0);
90 
92  {
93  // use old-style scales
95  eventSetup.get<CaloTPGRecord>().get(transcoder);
96  const CaloTPGTranscoder* h_tpg = transcoder.product();
97 
98  EcalTPGScale* e_tpg = new EcalTPGScale();
99  e_tpg->setEventSetup(eventSetup);
100 
101  L1CaloEcalScale* ecalScale = new L1CaloEcalScale();
102  L1CaloHcalScale* hcalScale = new L1CaloHcalScale();
103 
104  // create input scales, werner's code
105  // ECAL
106  std::cout << "ECAL Pos " << L1CaloEcalScale::nBinRank << std::endl ;
107  for( unsigned short ieta = 1 ; ieta <= L1CaloEcalScale::nBinEta; ++ieta )
108  {
109  for( unsigned short irank = 0 ; irank < L1CaloEcalScale::nBinRank; ++irank )
110  {
111  std::cout << ieta << " " << irank ;
112  EcalSubdetector subdet = ( ieta <= 17 ) ? EcalBarrel : EcalEndcap ;
113  double etGeVPos =
114  e_tpg->getTPGInGeV
115  ( irank, EcalTrigTowerDetId(1, // +ve eta
116  subdet,
117  ieta,
118  1 )); // dummy phi value
119  ecalScale->setBin( irank, ieta, 1, etGeVPos ) ;
120  std::cout << etGeVPos << ", " ;
121  }
122  std::cout << std::endl ;
123  }
124  std::cout << std::endl ;
125 
126  std::cout << "ECAL Neg" << std::endl ;
127  for( unsigned short ieta = 1 ; ieta <= L1CaloEcalScale::nBinEta; ++ieta )
128  {
129  for( unsigned short irank = 0 ; irank < L1CaloEcalScale::nBinRank; ++irank )
130  {
131  EcalSubdetector subdet = ( ieta <= 17 ) ? EcalBarrel : EcalEndcap ;
132 
133  std::cout << ieta << " " << irank ;
134  double etGeVNeg =
135  e_tpg->getTPGInGeV
136  ( irank,
137  EcalTrigTowerDetId(-1, // -ve eta
138  subdet,
139  ieta,
140  2 )); // dummy phi value
141  ecalScale->setBin( irank, ieta, -1, etGeVNeg ) ;
142  std::cout << etGeVNeg << ", " ;
143  }
144  std::cout << std::endl ;
145  }
146  std::cout << std::endl ;
147 
148  // HCAL
149  std::cout << "HCAL" << std::endl ;
150  for( unsigned short ieta = 1 ; ieta <= L1CaloHcalScale::nBinEta; ++ieta )
151  {
152  for( unsigned short irank = 0 ; irank < L1CaloHcalScale::nBinRank; ++irank )
153  {
154  double etGeV = h_tpg->hcaletValue( ieta, irank ) ;
155 
156  hcalScale->setBin( irank, ieta, 1, etGeV ) ;
157  hcalScale->setBin( irank, ieta, -1, etGeV ) ;
158  std::cout << etGeV << ", " ;
159  std::cout << std::endl ;
160  }
161  std::cout << std::endl ;
162  }
163 
164  // set the input scales
165  rctLookupTables->setEcalScale(ecalScale);
166  rctLookupTables->setHcalScale(hcalScale);
167 
168  dummyE = ecalScale;
169  dummyH = hcalScale;
170 
171  delete e_tpg;
172 
173  }
174  else
175  {
177  eventSetup.get<L1CaloHcalScaleRcd>().get(hcalScale);
178  const L1CaloHcalScale* h = hcalScale.product();
180  eventSetup.get<L1CaloEcalScaleRcd>().get(ecalScale);
181  const L1CaloEcalScale* e = ecalScale.product();
182 
185 
186  }
187 
190  event.getByLabel(ecalDigisLabel, ecal);
191  event.getByLabel(hcalDigisLabel, hcal);
194  if (ecal.isValid()) { ecalColl = *ecal; }
195  if (hcal.isValid()) { hcalColl = *hcal; }
196  rct->digiInput(ecalColl, hcalColl);
197  static int nEvents = 0;
198  if(nEvents == 0)
199  {
200  ofs
201  << "Crate = 0-17" << std::endl
202  << "Card = 0-7 within the crate" << std::endl
203  << "Tower = 0-31 covers 4 x 8 covered by the card" << std::endl
204  << "EMAddr(0:8) = EMFGBit(0:0)+CompressedEMET(1:8)" << std::endl
205  << "HDAddr(0:8) = HDFGBit(0:0)+CompressedHDET(1:8) - note: HDFGBit(0:0) is not part of the hardware LUT address" << std::endl
206  << "LutOut(0:17)= LinearEMET(0:6)+HoEFGVetoBit(7:7)+LinearJetET(8:16)+ActivityBit(17:17)" << std::endl
207  << "Event" << "\t"
208  << "Crate" << "\t"
209  << "Card" << "\t"
210  << "Tower" << "\t"
211  << "EMAddr" << "\t"
212  << "HDAddr" << "\t"
213  << "LUTOut"
214  << std::endl;
215  }
216  if(nEvents < 64)
217  {
218  for(unsigned short iCrate = 0; iCrate < 18; iCrate++)
219  {
220  for(unsigned short iCard = 0; iCard < 7; iCard++)
221  {
222  // tower numbered from 0-31
223  for(unsigned short iTower = 0; iTower < 32; iTower++)
224  {
225  unsigned short ecal = rct->ecalCompressedET(iCrate, iCard, iTower);
226  unsigned short hcal = rct->hcalCompressedET(iCrate, iCard, iTower);
227  unsigned short fgbit = rct->ecalFineGrainBit(iCrate, iCard, iTower);
228  unsigned short mubit = rct->hcalFineGrainBit(iCrate, iCard, iTower);
229  unsigned long lutOutput = rctLookupTables->lookup(ecal, hcal, fgbit, iCrate, iCard, iTower);
230  ofs
231  << std::hex
232  << nEvents << "\t"
233  << iCrate << "\t"
234  << iCard << "\t"
235  << iTower << "\t"
236  << ecal * 2 + fgbit << "\t"
237  << hcal * 2 + mubit << "\t"
238  << lutOutput
239  << std::dec
240  << std::endl;
241  }
242  }
243  }
244  }
245  nEvents++;
246 }
void setEventSetup(const edm::EventSetup &evtSetup)
Definition: EcalTPGScale.cc:19
unsigned short hcalCompressedET(int crate, int card, int tower)
Definition: L1RCT.h:82
edm::InputTag ecalDigisLabel
void setBin(unsigned short rank, unsigned short eta, short etaSign, double et)
set scale element; use this to create non-linear scales
L1RCTLookupTables * rctLookupTables
void setBin(unsigned short rank, unsigned short eta, short etaSign, double et)
set scale element; use this to create non-linear scales
unsigned short hcalFineGrainBit(int crate, int card, int tower)
Definition: L1RCT.h:84
double getTPGInGeV(const EcalTriggerPrimitiveDigi &tpDigi)
Definition: EcalTPGScale.cc:24
void setHcalScale(const L1CaloHcalScale *hcalScale)
unsigned short ecalFineGrainBit(int crate, int card, int tower)
Definition: L1RCT.h:80
unsigned short ecalCompressedET(int crate, int card, int tower)
Definition: L1RCT.h:78
static const unsigned short nBinRank
bool isValid() const
Definition: HandleBase.h:76
void setL1CaloEtScale(const L1CaloEtScale *etScale)
std::ofstream ofs
const T & get() const
Definition: EventSetup.h:55
T const * product() const
Definition: ESHandle.h:62
void setEcalScale(const L1CaloEcalScale *ecalScale)
void setRCTParameters(const L1RCTParameters *rctParameters)
static const unsigned short nBinRank
void digiInput(const EcalTrigPrimDigiCollection &ecalCollection, const HcalTrigPrimDigiCollection &hcalCollection)
Definition: L1RCT.cc:116
static const unsigned short nBinEta
static const unsigned short nBinEta
tuple cout
Definition: gather_cfg.py:41
string s
Definition: asciidump.py:422
UInt_t nEvents
Definition: hcalCalib.cc:43
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
EcalSubdetector
void setChannelMask(const L1RCTChannelMask *channelMask)
unsigned int lookup(unsigned short ecalInput, unsigned short hcalInput, unsigned short fgbit, unsigned short crtNo, unsigned short crdNo, unsigned short twrNo) const
virtual double hcaletValue(const int &ieta, const int &compET) const =0
edm::InputTag hcalDigisLabel

Member Data Documentation

edm::InputTag L1RCTSaveInput::ecalDigisLabel
private

Definition at line 50 of file L1RCTSaveInput.h.

Referenced by analyze().

std::string L1RCTSaveInput::fileName
private

Definition at line 45 of file L1RCTSaveInput.h.

Referenced by L1RCTSaveInput().

edm::InputTag L1RCTSaveInput::hcalDigisLabel
private

Definition at line 51 of file L1RCTSaveInput.h.

Referenced by analyze().

std::ofstream L1RCTSaveInput::ofs
private

Definition at line 53 of file L1RCTSaveInput.h.

Referenced by analyze(), and L1RCTSaveInput().

L1RCT* L1RCTSaveInput::rct
private

Definition at line 47 of file L1RCTSaveInput.h.

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

L1RCTLookupTables* L1RCTSaveInput::rctLookupTables
private

Definition at line 46 of file L1RCTSaveInput.h.

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

bool L1RCTSaveInput::useDebugTpgScales
private

Definition at line 52 of file L1RCTSaveInput.h.

Referenced by analyze().

bool L1RCTSaveInput::useEcal
private

Definition at line 48 of file L1RCTSaveInput.h.

bool L1RCTSaveInput::useHcal
private

Definition at line 49 of file L1RCTSaveInput.h.