CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
L1RCTSaveInput Class Reference

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

Inheritance diagram for L1RCTSaveInput:
edm::EDAnalyzer edm::EDConsumerBase

Public Member Functions

void analyze (const edm::Event &, const edm::EventSetup &) override
 
 L1RCTSaveInput (const edm::ParameterSet &)
 
 ~L1RCTSaveInput () override
 
- Public Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
SerialTaskQueueglobalLuminosityBlocksQueue ()
 
SerialTaskQueueglobalRunsQueue ()
 
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
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
virtual ~EDConsumerBase () noexcept(false)
 

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
 
- 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 &)
 
static bool wantsGlobalLuminosityBlocks ()
 
static bool wantsGlobalRuns ()
 
static bool wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 
- 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: 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 38 of file L1RCTSaveInput.h.

Constructor & Destructor Documentation

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

Definition at line 45 of file L1RCTSaveInput.cc.

References MessageLogger_cfi::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 ( )
override

Definition at line 63 of file L1RCTSaveInput.cc.

References rct, and rctLookupTables.

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

Member Function Documentation

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

Definition at line 70 of file L1RCTSaveInput.cc.

References EnergyCorrector::c, gather_cfg::cout, TauDecayModes::dec, L1RCT::digiInput(), MillePedeFileConverter_cfg::e, digitizers_cfi::ecal, EcalBarrel, L1RCT::ecalCompressedET(), ecalDigisLabel, EcalEndcap, L1RCT::ecalFineGrainBit(), edm::EventSetup::get(), EcalTPGScale::getTPGInGeV(), digitizers_cfi::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< T >::product(), alignCSCRings::r, rct, rctLookupTables, alignCSCRings::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 
88  {
89  // use old-style scales
91  eventSetup.get<CaloTPGRecord>().get(transcoder);
92  const CaloTPGTranscoder* h_tpg = transcoder.product();
93 
94  EcalTPGScale* e_tpg = new EcalTPGScale();
95  e_tpg->setEventSetup(eventSetup);
96 
97  L1CaloEcalScale* ecalScale = new L1CaloEcalScale();
98  L1CaloHcalScale* hcalScale = new L1CaloHcalScale();
99 
100  // create input scales, werner's code
101  // ECAL
102  std::cout << "ECAL Pos " << L1CaloEcalScale::nBinRank << std::endl ;
103  for( unsigned short ieta = 1 ; ieta <= L1CaloEcalScale::nBinEta; ++ieta )
104  {
105  for( unsigned short irank = 0 ; irank < L1CaloEcalScale::nBinRank; ++irank )
106  {
107  std::cout << ieta << " " << irank ;
108  EcalSubdetector subdet = ( ieta <= 17 ) ? EcalBarrel : EcalEndcap ;
109  double etGeVPos =
110  e_tpg->getTPGInGeV
111  ( irank, EcalTrigTowerDetId(1, // +ve eta
112  subdet,
113  ieta,
114  1 )); // dummy phi value
115  ecalScale->setBin( irank, ieta, 1, etGeVPos ) ;
116  std::cout << etGeVPos << ", " ;
117  }
118  std::cout << std::endl ;
119  }
120  std::cout << std::endl ;
121 
122  std::cout << "ECAL Neg" << std::endl ;
123  for( unsigned short ieta = 1 ; ieta <= L1CaloEcalScale::nBinEta; ++ieta )
124  {
125  for( unsigned short irank = 0 ; irank < L1CaloEcalScale::nBinRank; ++irank )
126  {
127  EcalSubdetector subdet = ( ieta <= 17 ) ? EcalBarrel : EcalEndcap ;
128 
129  std::cout << ieta << " " << irank ;
130  double etGeVNeg =
131  e_tpg->getTPGInGeV
132  ( irank,
133  EcalTrigTowerDetId(-1, // -ve eta
134  subdet,
135  ieta,
136  2 )); // dummy phi value
137  ecalScale->setBin( irank, ieta, -1, etGeVNeg ) ;
138  std::cout << etGeVNeg << ", " ;
139  }
140  std::cout << std::endl ;
141  }
142  std::cout << std::endl ;
143 
144  // HCAL
145  std::cout << "HCAL" << std::endl ;
146  for( unsigned short ieta = 1 ; ieta <= L1CaloHcalScale::nBinEta; ++ieta )
147  {
148  for( unsigned short irank = 0 ; irank < L1CaloHcalScale::nBinRank; ++irank )
149  {
150  double etGeV = h_tpg->hcaletValue( ieta, irank ) ;
151 
152  hcalScale->setBin( irank, ieta, 1, etGeV ) ;
153  hcalScale->setBin( irank, ieta, -1, etGeV ) ;
154  std::cout << etGeV << ", " ;
155  std::cout << std::endl ;
156  }
157  std::cout << std::endl ;
158  }
159 
160  // set the input scales
161  rctLookupTables->setEcalScale(ecalScale);
162  rctLookupTables->setHcalScale(hcalScale);
163 
164  delete e_tpg;
165 
166  }
167  else
168  {
170  eventSetup.get<L1CaloHcalScaleRcd>().get(hcalScale);
171  const L1CaloHcalScale* h = hcalScale.product();
173  eventSetup.get<L1CaloEcalScaleRcd>().get(ecalScale);
174  const L1CaloEcalScale* e = ecalScale.product();
175 
178 
179  }
180 
183  event.getByLabel(ecalDigisLabel, ecal);
184  event.getByLabel(hcalDigisLabel, hcal);
187  if (ecal.isValid()) { ecalColl = *ecal; }
188  if (hcal.isValid()) { hcalColl = *hcal; }
189  rct->digiInput(ecalColl, hcalColl);
190  static int nEvents = 0;
191  if(nEvents == 0)
192  {
193  ofs
194  << "Crate = 0-17" << std::endl
195  << "Card = 0-7 within the crate" << std::endl
196  << "Tower = 0-31 covers 4 x 8 covered by the card" << std::endl
197  << "EMAddr(0:8) = EMFGBit(0:0)+CompressedEMET(1:8)" << std::endl
198  << "HDAddr(0:8) = HDFGBit(0:0)+CompressedHDET(1:8) - note: HDFGBit(0:0) is not part of the hardware LUT address" << std::endl
199  << "LutOut(0:17)= LinearEMET(0:6)+HoEFGVetoBit(7:7)+LinearJetET(8:16)+ActivityBit(17:17)" << std::endl
200  << "Event" << "\t"
201  << "Crate" << "\t"
202  << "Card" << "\t"
203  << "Tower" << "\t"
204  << "EMAddr" << "\t"
205  << "HDAddr" << "\t"
206  << "LUTOut"
207  << std::endl;
208  }
209  if(nEvents < 64)
210  {
211  for(unsigned short iCrate = 0; iCrate < 18; iCrate++)
212  {
213  for(unsigned short iCard = 0; iCard < 7; iCard++)
214  {
215  // tower numbered from 0-31
216  for(unsigned short iTower = 0; iTower < 32; iTower++)
217  {
218  unsigned short ecal = rct->ecalCompressedET(iCrate, iCard, iTower);
219  unsigned short hcal = rct->hcalCompressedET(iCrate, iCard, iTower);
220  unsigned short fgbit = rct->ecalFineGrainBit(iCrate, iCard, iTower);
221  unsigned short mubit = rct->hcalFineGrainBit(iCrate, iCard, iTower);
222  unsigned long lutOutput = rctLookupTables->lookup(ecal, hcal, fgbit, iCrate, iCard, iTower);
223  ofs
224  << std::hex
225  << nEvents << "\t"
226  << iCrate << "\t"
227  << iCard << "\t"
228  << iTower << "\t"
229  << ecal * 2 + fgbit << "\t"
230  << hcal * 2 + mubit << "\t"
231  << lutOutput
232  << std::dec
233  << std::endl;
234  }
235  }
236  }
237  }
238  nEvents++;
239 }
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:74
void setL1CaloEtScale(const L1CaloEtScale *etScale)
std::ofstream ofs
const T & get() const
Definition: EventSetup.h:59
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
virtual double hcaletValue(const int &ieta, const int &iphi, const int &version, const int &compressedValue) const =0
UInt_t nEvents
Definition: hcalCalib.cc:42
EcalSubdetector
T const * product() const
Definition: ESHandle.h:86
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
edm::InputTag hcalDigisLabel

Member Data Documentation

edm::InputTag L1RCTSaveInput::ecalDigisLabel
private

Definition at line 49 of file L1RCTSaveInput.h.

Referenced by analyze().

std::string L1RCTSaveInput::fileName
private

Definition at line 44 of file L1RCTSaveInput.h.

Referenced by L1RCTSaveInput().

edm::InputTag L1RCTSaveInput::hcalDigisLabel
private

Definition at line 50 of file L1RCTSaveInput.h.

Referenced by analyze().

std::ofstream L1RCTSaveInput::ofs
private

Definition at line 52 of file L1RCTSaveInput.h.

Referenced by analyze(), and L1RCTSaveInput().

L1RCT* L1RCTSaveInput::rct
private

Definition at line 46 of file L1RCTSaveInput.h.

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

L1RCTLookupTables* L1RCTSaveInput::rctLookupTables
private

Definition at line 45 of file L1RCTSaveInput.h.

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

bool L1RCTSaveInput::useDebugTpgScales
private

Definition at line 51 of file L1RCTSaveInput.h.

Referenced by analyze().

bool L1RCTSaveInput::useEcal
private

Definition at line 47 of file L1RCTSaveInput.h.

bool L1RCTSaveInput::useHcal
private

Definition at line 48 of file L1RCTSaveInput.h.