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 
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
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
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
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:86
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:121
Definition: L1RCT.h:20
UInt_t nEvents
Definition: hcalCalib.cc:42
virtual void analyze(const edm::Event &, const edm::EventSetup &)
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