-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
first version of class for jet withs towers.
- Loading branch information
stadie
committed
Dec 27, 2008
1 parent
85fa378
commit 9ca80f1
Showing
5 changed files
with
255 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
// | ||
// Class for jets with towers | ||
// | ||
// first version: Hartmut Stadie 2008/12/25 | ||
// $Id: Jet.h,v 1.1 2008/12/16 15:21:27 stadie Exp $ | ||
// | ||
#include"JetWithTowers.h" | ||
|
||
#include "TLorentzVector.h" | ||
|
||
JetWithTowers::JetWithTowers(double Et, double EmEt, double HadEt, | ||
double OutEt, double E,double eta,double phi, | ||
Flavor flavor, | ||
double const(*func)(TMeasurement *const x, double *const par), | ||
double err, double* firstpar, int id, int npars) | ||
: Jet(Et,EmEt,HadEt,OutEt,E,eta,phi,flavor,func,err,firstpar,id,npars), | ||
njetpars(npars),ntowerpars(0) | ||
{ | ||
} | ||
|
||
JetWithTowers::~JetWithTowers() | ||
{ | ||
for(TowerCollIter i = towers.begin() ; i != towers.end() ; ++i) { | ||
delete *i; | ||
} | ||
} | ||
|
||
void JetWithTowers::ChangeParAddress(double* oldpar, double* newpar) | ||
{ | ||
Jet::ChangeParAddress(oldpar,newpar); | ||
for(TowerCollIter i = towers.begin() ; i != towers.end() ; ++i) { | ||
(*i)->ChangeParAddress(oldpar,newpar); | ||
towerpars[(*i)->FirstPar()] = (*i)->Par(); | ||
} | ||
} | ||
|
||
double JetWithTowers::correctedEt(double Et) const | ||
{ | ||
double cet = 0; | ||
for(TowerCollConstIter i = towers.begin() ; i != towers.end() ; ++i) { | ||
cet += (*i)->projectionToJetAxis() * (*i)->correctedEt((*i)->Et()); | ||
} | ||
//std::cout << "jet ET:" << pt << " sum of tower:" << cet << "\n"; | ||
double ccet = 0; | ||
for(TowerCollConstIter i = towers.begin() ; i != towers.end() ; ++i) { | ||
ccet += (*i)->projectionToJetAxis() * | ||
(*i)->correctedEt((*i)->lastCorrectedEt()/cet * Et); | ||
} | ||
//std::cout << "scale ET:" << Et << " cor. sum of tower:" << ccet << "\n"; | ||
return Jet::correctedEt(ccet); | ||
} | ||
|
||
|
||
//varies the i'th parameter for this jet by eps and returns its overall | ||
// parameter id and sets the Et for the par + eps and par - eps result | ||
int JetWithTowers::varyPar(int i, double eps, double Et, double scale, | ||
double& upperEt, double& lowerEt) | ||
{ | ||
if(i < njetpars) return Jet::varyPar(i,eps,Et,scale,upperEt,lowerEt); | ||
int towid = (i - njetpars)/ntowerpars; | ||
int towpar = (i - njetpars) % ntowerpars; | ||
//std::cout << "I: " << i << " tow:" << towid << "; " << towpar << std::endl; | ||
std::map<int,double*>::const_iterator iter = towerpars.begin(); | ||
for(int i = 0 ; i < towid ; ++i) ++iter; | ||
double *p = iter->second; | ||
int id = iter->first; | ||
//std::cout << "alternating par:" << id + towpar << " = " << p[towpar] << std::endl; | ||
double orig = p[towpar]; | ||
p[towpar] += eps; | ||
upperEt = expectedEt(Et,scale,true); | ||
p[towpar] = orig - eps; | ||
lowerEt = expectedEt(Et,scale,true); | ||
p[towpar] = orig; | ||
return id + towpar; | ||
} | ||
|
||
|
||
|
||
void JetWithTowers::addTower(double Et, double EmEt, double HadEt , | ||
double OutEt, double E,double eta,double phi, | ||
double const(*func)(TMeasurement *const x, double *const par), | ||
double err, double* firstpar, int id, int npars) | ||
{ | ||
TLorentzVector jet, towp; | ||
jet.SetPtEtaPhiM(TMeasurement::pt,TMeasurement::eta,TMeasurement::phi,0); | ||
towp.SetPtEtaPhiM(Et,eta,phi,0); | ||
jet -= towp; | ||
double projection = (TMeasurement::pt-jet.Et())/Et; | ||
projection = 1.0; | ||
//std::cout << "Jet:" << jet.Eta() << ", " << jet.Phi() | ||
// << " tower:" << towp.Eta() << ", " << towp.Phi() << " :" | ||
// << projection << std::endl; | ||
towers.push_back(new Tower(Et,EmEt,HadEt,OutEt,E,eta,phi,projection,func, | ||
err,firstpar,id,npars)); | ||
ntowerpars = npars; | ||
towerpars[id] = firstpar; | ||
Jet::npar = njetpars + towerpars.size() * ntowerpars; | ||
//std::cout << "tower:" << Et << " projected:" << projection * Et << std::endl; | ||
} | ||
|
||
|
||
|
||
JetWithTowers::Tower::Tower(double Et, double EmEt, double HadEt , | ||
double OutEt, double E,double eta,double phi, | ||
double alpha,double const(*func)(TMeasurement *const x, double *const par), | ||
double err, double* firstpar, int id, int npars) | ||
: TMeasurement(Et,EmEt,HadEt,OutEt,E,eta,phi), alpha(alpha), par(firstpar), | ||
npar(npars), parid(id), error(err),f(func) | ||
{ | ||
temp = *this; | ||
} | ||
|
||
double JetWithTowers::Tower::correctedEt(double Et) const | ||
{ | ||
//assume that only the hadronic energy gets modified! | ||
temp.pt = Et; | ||
temp.HadF = Et - OutF - EMF; | ||
temp.E = TMeasurement::E * Et/pt; | ||
lastCorEt = f(&temp,par); | ||
//std::cout << pt << ", " << Et << ":" << lastCorEt << " par:" << par[0] << std::endl; | ||
return lastCorEt; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
// | ||
// Class for jets with towers | ||
// | ||
// first version: Hartmut Stadie 2008/12/25 | ||
// $Id: Jet.h,v 1.1 2008/12/16 15:21:27 stadie Exp $ | ||
// | ||
#ifndef JETWITHTOWERS_H | ||
#define JETWITHTOWERS_H | ||
|
||
#include"Jet.h" | ||
|
||
#include <vector> | ||
#include <map> | ||
|
||
class JetWithTowers : public Jet | ||
{ | ||
public: | ||
JetWithTowers(double Et, double EmEt, double HadEt ,double OutEt, double E, | ||
double eta,double phi, Flavor flavor, | ||
double const(*func)(TMeasurement *const x, double *const par), | ||
double err, double* firstpar, int id, int npars); | ||
virtual ~JetWithTowers(); | ||
virtual void ChangeParAddress(double* oldpar, double* newpar); | ||
virtual double correctedEt(double Et) const; | ||
//varies the i'th parameter for this jet by eps and returns its overall | ||
// parameter id and sets the Et for the par + eps and par - eps result | ||
virtual int varyPar(int i, double eps, double Et, double scale, double& upperEt, double& lowerEt); | ||
void addTower(double Et, double EmEt, double HadEt ,double OutEt, double E, | ||
double eta,double phi, | ||
double const(*func)(TMeasurement *const x, double *const par), | ||
double err, double* firstpar, int id, int npars); | ||
protected: | ||
class Tower : public TMeasurement { | ||
public: | ||
Tower(double Et, double EmEt, double HadEt ,double OutEt, double E, | ||
double eta,double phi, double alpha, | ||
double const(*func)(TMeasurement *const x, double *const par), | ||
double err, double* firstpar, int id, int npars); | ||
double Et() const {return pt;} | ||
double EmEt() const {return EMF;} | ||
double HadEt() const {return HadF;} | ||
double OutEt() const {return OutF;} | ||
double E() const {return TMeasurement::E;} | ||
double eta() const {return TMeasurement::eta;} | ||
double phi() const {return TMeasurement::phi;} | ||
double projectionToJetAxis() const {return alpha;} | ||
void ChangeParAddress(double* oldpar, double* newpar) {par += newpar - oldpar;} | ||
double correctedEt(double Et) const; | ||
double lastCorrectedEt() const { return lastCorEt;} | ||
double Error() const {return error;} | ||
int nPar() const {return npar;} | ||
int FirstPar() const {return parid;} | ||
double *Par() const {return par;} | ||
private: | ||
double alpha; | ||
double* par;//address to first parameter for this jet | ||
int npar,parid; | ||
double error; | ||
mutable TMeasurement temp; | ||
mutable double lastCorEt; | ||
double const(*f)(TMeasurement *const x, double *const par); | ||
}; | ||
typedef std::vector<Tower*> TowerColl; | ||
typedef TowerColl::iterator TowerCollIter; | ||
typedef TowerColl::const_iterator TowerCollConstIter; | ||
TowerColl towers; | ||
int njetpars,ntowerpars; | ||
std::map<int,double*> towerpars; | ||
}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.