CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Stage1Layer2JetAlgorithmImpSimpleHW.cc
Go to the documentation of this file.
1 
8 // This is a simple algorithm for use in comparing with early versions of the Stage1 firmware
9 
15 
16 #include <bitset>
17 #include <iostream>
18 
19 using namespace std;
20 using namespace l1t;
21 
22 Stage1Layer2JetAlgorithmImpSimpleHW::Stage1Layer2JetAlgorithmImpSimpleHW(CaloParamsHelper* params) : params_(params)
23 {
24 }
25 
27 
28 void Stage1Layer2JetAlgorithmImpSimpleHW::processEvent(const std::vector<l1t::CaloRegion> & regions,
29  const std::vector<l1t::CaloEmCand> & EMCands,
30  std::vector<l1t::Jet> * jets,
31  std::vector<l1t::Jet> * debugJets){
32 
33  std::vector<l1t::CaloRegion> *subRegions = new std::vector<l1t::CaloRegion>();
34  std::vector<l1t::Jet> *preGtEtaJets = new std::vector<l1t::Jet>();
35  std::vector<l1t::Jet> *calibratedRankedJets = new std::vector<l1t::Jet>();
36  std::vector<l1t::Jet> *sortedJets = new std::vector<l1t::Jet>();
37 
38  double towerLsb = params_->towerLsbSum();
39  int jetSeedThreshold = floor( params_->jetSeedThreshold()/towerLsb + 0.5);
40 
41  RegionCorrection(regions, subRegions, params_);
42 
43  slidingWindowJetFinder(jetSeedThreshold, subRegions, preGtEtaJets);
44 
45  calibrateAndRankJets(params_, preGtEtaJets, calibratedRankedJets);
46 
47  SortJets(calibratedRankedJets, sortedJets);
48 
49  JetToGtEtaScales(params_, sortedJets, jets);
50  JetToGtEtaScales(params_, preGtEtaJets, debugJets);
51  //JetToGtPtScales(params_, preGtJets, jets);
52 
53  const bool verbose = false;
54  const bool hex = false;
55  if(verbose)
56  {
57  int cJets = 0;
58  int fJets = 0;
59  printf("Jets Central\n");
60  //printf("pt\teta\tphi\n");
61  for(std::vector<l1t::Jet>::const_iterator itJet = jets->begin();
62  itJet != jets->end(); ++itJet){
63  if((itJet->hwQual() & 2) == 2) continue;
64  cJets++;
65  if(!hex)
66  {
67  unsigned int packed = pack15bits(itJet->hwPt(), itJet->hwEta(), itJet->hwPhi());
68  cout << bitset<15>(packed).to_string() << endl;
69  } else {
70  uint32_t output = itJet->hwPt() + (itJet->hwEta() << 6) + (itJet->hwPhi() << 10);
71  std::cout << std::hex << std::setw(4) << std::setfill('0') << output << std::endl;
72  }
73  if(cJets == 4) break;
74  }
75 
76  printf("Jets Forward\n");
77  //printf("pt\teta\tphi\n");
78  for(std::vector<l1t::Jet>::const_iterator itJet = jets->begin();
79  itJet != jets->end(); ++itJet){
80  if((itJet->hwQual() & 2) != 2) continue;
81  fJets++;
82  if(!hex)
83  {
84  unsigned int packed = pack15bits(itJet->hwPt(), itJet->hwEta(), itJet->hwPhi());
85  cout << bitset<15>(packed).to_string() << endl;
86  } else {
87  uint32_t output = itJet->hwPt() + (itJet->hwEta() << 6) + (itJet->hwPhi() << 10);
88  std::cout << std::hex << std::setw(4) << std::setfill('0') << output << std::endl;
89  }
90 
91  if(fJets == 4) break;
92  }
93  }
94 
95  delete subRegions;
96  delete preGtEtaJets;
97  delete calibratedRankedJets;
98  delete sortedJets;
99 }
void RegionCorrection(const std::vector< l1t::CaloRegion > &regions, std::vector< l1t::CaloRegion > *subRegions, CaloParamsHelper *params)
------— New region correction (PUsub, no response correction at the moment) --------— ...
virtual void processEvent(const std::vector< l1t::CaloRegion > &regions, const std::vector< l1t::CaloEmCand > &EMCands, std::vector< l1t::Jet > *jets, std::vector< l1t::Jet > *preGtJets)
void calibrateAndRankJets(CaloParamsHelper *params, const std::vector< l1t::Jet > *input, std::vector< l1t::Jet > *output)
void SortJets(std::vector< l1t::Jet > *input, std::vector< l1t::Jet > *output)
std::string to_string(const T &t)
Definition: Logger.cc:26
vector< PseudoJet > jets
void JetToGtEtaScales(CaloParamsHelper *params, const std::vector< l1t::Jet > *input, std::vector< l1t::Jet > *output)
unsigned int pack15bits(int pt, int eta, int phi)
void slidingWindowJetFinder(const int, const std::vector< l1t::CaloRegion > *regions, std::vector< l1t::Jet > *uncalibjets)
double towerLsbSum() const
tuple cout
Definition: gather_cfg.py:121
double jetSeedThreshold() const