35 { 1,2,2,2,2,2,2,2,2 },
36 { 1,1,2,2,2,2,2,2,2 },
37 { 1,1,1,2,2,2,2,2,2 },
38 { 1,1,1,1,2,2,2,2,2 },
39 { 1,1,1,1,0,2,2,2,2 },
40 { 1,1,1,1,1,2,2,2,2 },
41 { 1,1,1,1,1,1,2,2,2 },
42 { 1,1,1,1,1,1,1,2,2 },
43 { 1,1,1,1,1,1,1,1,2 },
55 std::vector<l1t::Jet> &
jets, std::vector<l1t::Jet> & alljets) {
58 create(towers, jets, alljets, params_->jetPUSType());
61 calibrate(jets, 10/params_->jetLsb());
67 std::vector<l1t::Jet> & alljets,
std::string PUSubMethod) {
72 for (
int etaSide=1; etaSide>=-1; etaSide-=2) {
75 std::vector<int> ringGroup1, ringGroup2, ringGroup3, ringGroup4;
77 if ( ! ((
i-1)%4) ) ringGroup1.push_back(
i * etaSide );
78 else if ( ! ((
i-2)%4) ) ringGroup2.push_back(
i * etaSide );
79 else if ( ! ((
i-3)%4) ) ringGroup3.push_back(
i * etaSide );
80 else if ( ! ((
i-4)%4) ) ringGroup4.push_back(
i * etaSide );
82 std::vector< std::vector<int> > theRings = { ringGroup1, ringGroup2, ringGroup3, ringGroup4 };
85 std::vector<l1t::Jet> jetsHalf;
88 for (
unsigned ringGroupIt=1; ringGroupIt<=theRings.size(); ringGroupIt++ ) {
91 std::vector<l1t::Jet> jetsAccu;
94 for (
unsigned ringIt=0; ringIt<theRings.at(ringGroupIt-1).size(); ringIt++ ) {
96 int ieta = theRings.at(ringGroupIt-1).at(ringIt);
99 std::vector<l1t::Jet> jetsRing;
102 for (
int iphi=phiMin; iphi<=phiMax; ++iphi ) {
105 if (jetsRing.size()==18)
break;
110 int seedEt = tow.
hwPt();
112 bool vetoCandidate =
false;
115 if(iEt < floor(params_->jetSeedThreshold()/params_->towerLsbSum()))
continue;
118 for(
int deta = -4; deta < 5; ++deta ) {
119 for(
int dphi = -4; dphi < 5; ++dphi ) {
122 int ietaTest = ieta+deta;
123 int iphiTest = iphi+dphi;
126 while ( iphiTest > phiMax ) iphiTest -= phiMax;
127 while ( iphiTest < phiMin ) iphiTest += phiMax;
130 if (ieta > 0 && ietaTest <=0) ietaTest -= 1;
131 if (ieta < 0 && ietaTest >=0) ietaTest += 1;
135 towEt = towTest.
hwPt();
137 if (
mask_[8-(dphi+4)][deta+4] == 0)
continue;
138 else if (
mask_[8-(dphi+4)][deta+4] == 1) vetoCandidate = (seedEt < towEt);
139 else if (
mask_[8-(dphi+4)][deta+4] == 2) vetoCandidate = (seedEt <= towEt);
141 if (vetoCandidate)
break;
145 if(vetoCandidate)
break;
149 if (!vetoCandidate) {
151 if (PUSubMethod ==
"Donut") iEt -= donutPUEstimate(ieta, iphi, 5, towers);
152 if (PUSubMethod ==
"ChunkyDonut") iEt -= chunkyDonutPUEstimate(ieta, iphi, 5, towers);
154 if (iEt<=0)
continue;
159 jetsRing.push_back(jet);
160 alljets.push_back(jet);
167 start_ = jetsRing.begin();
168 end_ = jetsRing.end();
170 if (jetsRing.size()>6) jetsRing.resize(6);
173 std::vector<l1t::Jet> jetsSort;
174 jetsSort.insert(jetsSort.end(), jetsAccu.begin(), jetsAccu.end());
175 jetsSort.insert(jetsSort.end(), jetsRing.begin(), jetsRing.end());
178 start_ = jetsSort.begin();
179 end_ = jetsSort.end();
181 if (jetsSort.size()>6) jetsSort.resize(6);
189 jetsHalf.insert(jetsHalf.end(), jetsAccu.begin(), jetsAccu.end());
194 start_ = jetsHalf.begin();
195 end_ = jetsHalf.end();
197 if (jetsHalf.size()>6) jetsHalf.resize(6);
200 jets.insert(jets.end(), jetsHalf.begin(), jetsHalf.end());
215 std::vector<int>
ring(4,0);
217 int iphiUp = jetPhi +
size;
218 while ( iphiUp > phiMax ) iphiUp -= phiMax;
219 int iphiDown = jetPhi -
size;
220 while ( iphiDown < phiMin ) iphiDown += phiMax;
222 int ietaUp = (jetEta + size >
etaMax) ? 999 : jetEta+size;
223 int ietaDown = (jetEta - size <
etaMin) ? 999 : jetEta-size;
225 for (
int ieta = jetEta - size+1; ieta < jetEta +
size; ++ieta)
228 if (ieta > etaMax || ieta <
etaMin)
continue;
231 if (jetEta > 0 && ieta <=0){
233 }
else if (jetEta < 0 && ieta >=0){
240 int towEt = tow.
hwPt();
249 for (
int iphi = jetPhi - size+1; iphi < jetPhi +
size; ++iphi)
253 while ( towerPhi > phiMax ) towerPhi -= phiMax;
254 while ( towerPhi < phiMin ) towerPhi += phiMax;
257 int towEt = tow.
hwPt();
266 std::sort(ring.begin(), ring.end(), std::greater<int>());
268 return 4*( ring[1]+ring[2] );
278 std::vector<int>
ring(4,0);
284 for (
int stripIt=0; stripIt<nStrips; stripIt++) {
286 int iphiUp = jetPhi + size + stripIt;
287 int iphiDown = jetPhi - size - stripIt;
288 while ( iphiUp > phiMax ) iphiUp -= phiMax;
289 while ( iphiDown < phiMin ) iphiDown += phiMax;
291 int ietaUp = jetEta + size + stripIt;
292 int ietaDown = jetEta - size - stripIt;
293 if ( jetEta<0 && ietaUp>=0 ) ietaUp += 1;
294 if ( jetEta>0 && ietaDown<=0 ) ietaDown -= 1;
297 for (
int ieta=jetEta-size+1; ieta<jetEta+
size; ++ieta) {
299 if (ieta>etaMax || ieta<
etaMin)
continue;
302 if (jetEta>0 && towEta<=0) towEta-=1;
303 if (jetEta<0 && towEta>=0) towEta+=1;
306 int towEt = towPhiUp.
hwPt();
310 towEt = towPhiDown.
hwPt();
316 for (
int iphi=jetPhi-size+1; iphi<jetPhi+
size; ++iphi) {
319 while ( towPhi > phiMax ) towPhi -= phiMax;
320 while ( towPhi < phiMin ) towPhi += phiMax;
322 if (ietaUp>=
etaMin && ietaUp<=etaMax) {
324 int towEt = towEtaUp.
hwPt();
328 if (ietaDown>=
etaMin && ietaDown<=etaMax) {
330 int towEt = towEtaDown.
hwPt();
339 std::sort(ring.begin(), ring.end(), std::greater<int>());
340 return ( ring[1]+ring[2] );
348 if( params_->jetCalibrationType() ==
"function6PtParams22EtaBins" ){
354 if( params_->jetCalibrationParams().size() != 132){
355 edm::LogError(
"l1t|stage 2") <<
"Invalid input vector to calo params. Input vector of size: " <<
356 params_->jetCalibrationParams().size() <<
" Require size: 132 Not calibrating Stage 2 Jets" << std::endl;
361 for(std::vector<l1t::Jet>::iterator
jet = jets.begin();
jet!=jets.end();
jet++){
364 if(
jet->hwPt() < calibThreshold)
continue;
370 for(
int rct=0; rct<22; rct++){
372 for(
int i=0;
i<3;
i++){
377 for(
int i=0;
i<4;
i++){
386 etaBin = ttToRct[
jet->hwEta() + 40 ];
388 etaBin = ttToRct[
jet->hwEta() + 39 ];
393 ptValue[0] =
jet->hwPt()*params_->jetLsb();
397 for(
int i=0;
i<6;
i++){
398 params[
i] = params_->jetCalibrationParams()[etaBin*6 +
i];
405 double correction = calibFit(ptValue,params);
413 }
else if( params_->jetCalibrationType() ==
"function6PtParams80EtaBins" ) {
415 if( params_->jetCalibrationParams().size() != 480){
416 edm::LogError(
"l1t|stage 2") <<
"Invalid input vector to calo params. Input vector of size: " <<
417 params_->jetCalibrationParams().size() <<
" Require size: 480 Not calibrating Stage 2 Jets" << std::endl;
422 for(std::vector<l1t::Jet>::iterator
jet = jets.begin();
jet!=jets.end();
jet++){
426 etaBin =
jet->hwEta() + 40;
428 etaBin =
jet->hwEta() + 39;
434 ptValue[0] =
jet->hwPt()*params_->jetLsb();
438 for(
int i=0;
i<6;
i++){
439 params[
i] = params_->jetCalibrationParams()[etaBin*6 +
i];
444 double correction = calibFit(ptValue,params);
451 }
else if( params_->jetCalibrationType() ==
"lut6PtBins22EtaBins" ) {
453 edm::LogError(
"l1t|stage 2") <<
"No LUT implementation for the calibration yet" << std::endl;
457 if(params_->jetCalibrationType() !=
"None" && params_->jetCalibrationType() !=
"none")
458 edm::LogError(
"l1t|stage 2") <<
"Invalid calibration type in calo params. Not calibrating Stage 2 Jets" << std::endl;
469 double logX =
log(v[0]);
471 double term1 = par[1] / ( logX * logX + par[2] );
472 double term2 = par[3] *
exp( -par[4]*((logX - par[5])*(logX - par[5])) );
475 double f = par[0] + term1 + term2;
void calibrate(std::vector< Jet > &jets, int calibThreshold)
std::vector< l1t::Jet >::iterator end_
Stage2Layer2JetAlgorithmFirmwareImp1(CaloParamsHelper *params)
bool operator>(l1t::Jet &a, l1t::Jet &b)
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
std::vector< l1t::Jet >::iterator start_
int donutPUEstimate(int jetEta, int jetPhi, int size, const std::vector< l1t::CaloTower > &towers)
double calibFit(double *, double *)
virtual void processEvent(const std::vector< CaloTower > &towers, std::vector< Jet > &jets, std::vector< Jet > &alljets)
void create(const std::vector< CaloTower > &towers, std::vector< Jet > &jets, std::vector< Jet > &alljets, std::string PUSubMethod)
virtual ~Stage2Layer2JetAlgorithmFirmwareImp1()
tuple size
Write out results.
int chunkyDonutPUEstimate(int jetEta, int jetPhi, int pos, const std::vector< l1t::CaloTower > &towers)