CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
L1RCTSaveInput.cc
Go to the documentation of this file.
1 #include <memory>
2 #include <string>
3 #include <iostream>
4 #include <fstream>
5 using std::ostream;
6 using std::cout;
7 using std::cerr;
8 using std::endl;
9 
10 #include <iomanip>
11 
17 
19 
23 
28 
29 // also include old-style scales -- same as L1RCTProducer?
33 
36 
41 
44 
46  fileName(conf.getUntrackedParameter<std::string>("rctTestInputFile")),
47  rctLookupTables(new L1RCTLookupTables),
48  rct(new L1RCT(rctLookupTables)),
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 }
62 
64 {
65  if(rct != 0) delete rct;
66  if(rctLookupTables != 0) delete rctLookupTables;
67 }
68 
69 void
71  const edm::EventSetup& eventSetup)
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
L1RCTSaveInput(const edm::ParameterSet &)
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
std::string fileName
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
bool isValid() const
Definition: HandleBase.h:76
void setL1CaloEtScale(const L1CaloEtScale *etScale)
tuple conf
Definition: dbtoconf.py:185
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
Definition: L1RCT.h:20
UInt_t nEvents
Definition: hcalCalib.cc:43
virtual void analyze(const edm::Event &, const edm::EventSetup &)
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