From b9a6a391ed3febcac5882e9a516677fe940dbf7a Mon Sep 17 00:00:00 2001 From: hristov Date: Sun, 8 May 2005 04:39:07 +0000 Subject: [PATCH] Version of the jet analysis module from v4-01-Release --- JETAN/AliJFCluster.cxx | 187 ++ JETAN/AliJFCluster.h | 82 + JETAN/AliJFClusterDifference.cxx | 81 + JETAN/AliJFClusterDifference.h | 57 + JETAN/AliJFJet.cxx | 56 + JETAN/AliJFJet.h | 164 ++ JETAN/AliJFJetCalorimeterTrigger.cxx | 196 ++ JETAN/AliJFJetCalorimeterTrigger.h | 41 + JETAN/AliJFJetCalorimeterTriggerResult.cxx | 27 + JETAN/AliJFJetCalorimeterTriggerResult.h | 47 + JETAN/AliJFJetFinder.cxx | 48 + JETAN/AliJFJetFinder.h | 57 + JETAN/AliJFJetTrigger.cxx | 47 + JETAN/AliJFJetTrigger.h | 26 + JETAN/AliJFJetTriggerResult.cxx | 28 + JETAN/AliJFJetTriggerResult.h | 44 + JETAN/AliJFKtJet.cxx | 258 +++ JETAN/AliJFKtJet.h | 27 + JETAN/AliJFKtJetFinder.cxx | 196 ++ JETAN/AliJFKtJetFinder.h | 42 + JETAN/AliJFMCJet.cxx | 95 + JETAN/AliJFMCJet.h | 25 + JETAN/AliJFMCJetFinder.cxx | 98 + JETAN/AliJFMCJetFinder.h | 33 + JETAN/AliJFMixEvent.cxx | 253 ++ JETAN/AliJFMixEvent.h | 68 + JETAN/AliJFParticlesCut.cxx | 106 + JETAN/AliJFParticlesCut.h | 54 + JETAN/AliJFPreCluster.cxx | 89 + JETAN/AliJFPreCluster.h | 45 + JETAN/AliJFTower.cxx | 8 + JETAN/AliJFTower.h | 156 ++ JETAN/AliJetParticlesReader.cxx | 2 +- JETAN/AliJetParticlesReaderESD.cxx | 2 +- JETAN/AliJetParticlesReaderHLT.cxx | 9 +- JETAN/AliTkChargedJet.cxx | 86 + JETAN/AliTkChargedJet.h | 43 + JETAN/AliTkChargedJetFinder.cxx | 589 +++++ JETAN/AliTkChargedJetFinder.h | 167 ++ JETAN/AliTkConeJet.cxx | 626 +++++ JETAN/AliTkConeJet.h | 110 + JETAN/AliTkConeJetEvent.cxx | 55 + JETAN/AliTkConeJetEvent.h | 68 + JETAN/AliTkConeJetFinder.cxx | 605 +++++ JETAN/AliTkConeJetFinder.h | 178 ++ JETAN/AliTkConeJetFinderV2.cxx | 938 ++++++++ JETAN/AliTkConeJetFinderV2.h | 282 +++ JETAN/AliTkEtaPhiVector.cxx | 15 + JETAN/AliTkEtaPhiVector.h | 59 + JETAN/AliTkHijingAna.cxx | 230 ++ JETAN/AliTkHijingAna.h | 57 + JETAN/AliTkJetTrigger.cxx | 331 +++ JETAN/AliTkJetTrigger.h | 95 + JETAN/AliTkJetTriggerDecision.cxx | 11 + JETAN/AliTkJetTriggerDecision.h | 28 + JETAN/AliTkJetTriggerEvent.cxx | 59 + JETAN/AliTkJetTriggerEvent.h | 28 + JETAN/AliTkJetTriggerSettings.cxx | 23 + JETAN/AliTkJetTriggerSettings.h | 28 + JETAN/AliTkKtJetFinder.cxx | 459 ++++ JETAN/AliTkKtJetFinder.h | 140 ++ JETAN/AliTkTowerV2.cxx | 170 ++ JETAN/AliTkTowerV2.h | 59 + JETAN/JetFinderLinkDef.h | 24 + JETAN/Makefile | 446 ---- JETAN/TkJetFinderLinkDef.h | 28 + JETAN/anaAliJets.C | 2418 ++++++++++++++++++++ JETAN/anaTracks.C | 563 +++++ JETAN/createEvents.C | 545 +++++ JETAN/findJets.C | 181 ++ JETAN/findJetsMixed.C | 136 ++ JETAN/libJETAN.pkg | 2 + JETAN/libJetFinder.pkg | 16 + JETAN/libTkJetFinder.pkg | 15 + JETAN/rootlogon.C | 48 + JETAN/testJets.C | 184 ++ 76 files changed, 12443 insertions(+), 456 deletions(-) create mode 100644 JETAN/AliJFCluster.cxx create mode 100644 JETAN/AliJFCluster.h create mode 100644 JETAN/AliJFClusterDifference.cxx create mode 100644 JETAN/AliJFClusterDifference.h create mode 100644 JETAN/AliJFJet.cxx create mode 100644 JETAN/AliJFJet.h create mode 100644 JETAN/AliJFJetCalorimeterTrigger.cxx create mode 100644 JETAN/AliJFJetCalorimeterTrigger.h create mode 100644 JETAN/AliJFJetCalorimeterTriggerResult.cxx create mode 100644 JETAN/AliJFJetCalorimeterTriggerResult.h create mode 100644 JETAN/AliJFJetFinder.cxx create mode 100644 JETAN/AliJFJetFinder.h create mode 100644 JETAN/AliJFJetTrigger.cxx create mode 100644 JETAN/AliJFJetTrigger.h create mode 100644 JETAN/AliJFJetTriggerResult.cxx create mode 100644 JETAN/AliJFJetTriggerResult.h create mode 100644 JETAN/AliJFKtJet.cxx create mode 100644 JETAN/AliJFKtJet.h create mode 100644 JETAN/AliJFKtJetFinder.cxx create mode 100644 JETAN/AliJFKtJetFinder.h create mode 100644 JETAN/AliJFMCJet.cxx create mode 100644 JETAN/AliJFMCJet.h create mode 100644 JETAN/AliJFMCJetFinder.cxx create mode 100644 JETAN/AliJFMCJetFinder.h create mode 100644 JETAN/AliJFMixEvent.cxx create mode 100644 JETAN/AliJFMixEvent.h create mode 100644 JETAN/AliJFParticlesCut.cxx create mode 100644 JETAN/AliJFParticlesCut.h create mode 100644 JETAN/AliJFPreCluster.cxx create mode 100644 JETAN/AliJFPreCluster.h create mode 100644 JETAN/AliJFTower.cxx create mode 100644 JETAN/AliJFTower.h create mode 100644 JETAN/AliTkChargedJet.cxx create mode 100644 JETAN/AliTkChargedJet.h create mode 100644 JETAN/AliTkChargedJetFinder.cxx create mode 100644 JETAN/AliTkChargedJetFinder.h create mode 100644 JETAN/AliTkConeJet.cxx create mode 100644 JETAN/AliTkConeJet.h create mode 100644 JETAN/AliTkConeJetEvent.cxx create mode 100644 JETAN/AliTkConeJetEvent.h create mode 100644 JETAN/AliTkConeJetFinder.cxx create mode 100644 JETAN/AliTkConeJetFinder.h create mode 100644 JETAN/AliTkConeJetFinderV2.cxx create mode 100644 JETAN/AliTkConeJetFinderV2.h create mode 100644 JETAN/AliTkEtaPhiVector.cxx create mode 100644 JETAN/AliTkEtaPhiVector.h create mode 100644 JETAN/AliTkHijingAna.cxx create mode 100644 JETAN/AliTkHijingAna.h create mode 100644 JETAN/AliTkJetTrigger.cxx create mode 100644 JETAN/AliTkJetTrigger.h create mode 100644 JETAN/AliTkJetTriggerDecision.cxx create mode 100644 JETAN/AliTkJetTriggerDecision.h create mode 100644 JETAN/AliTkJetTriggerEvent.cxx create mode 100644 JETAN/AliTkJetTriggerEvent.h create mode 100644 JETAN/AliTkJetTriggerSettings.cxx create mode 100644 JETAN/AliTkJetTriggerSettings.h create mode 100644 JETAN/AliTkKtJetFinder.cxx create mode 100644 JETAN/AliTkKtJetFinder.h create mode 100644 JETAN/AliTkTowerV2.cxx create mode 100644 JETAN/AliTkTowerV2.h create mode 100644 JETAN/JetFinderLinkDef.h delete mode 100644 JETAN/Makefile create mode 100644 JETAN/TkJetFinderLinkDef.h create mode 100644 JETAN/anaAliJets.C create mode 100644 JETAN/anaTracks.C create mode 100644 JETAN/createEvents.C create mode 100644 JETAN/findJets.C create mode 100644 JETAN/findJetsMixed.C create mode 100644 JETAN/libJetFinder.pkg create mode 100644 JETAN/libTkJetFinder.pkg create mode 100644 JETAN/rootlogon.C create mode 100644 JETAN/testJets.C diff --git a/JETAN/AliJFCluster.cxx b/JETAN/AliJFCluster.cxx new file mode 100644 index 00000000000..39fa18c23eb --- /dev/null +++ b/JETAN/AliJFCluster.cxx @@ -0,0 +1,187 @@ +// $Id$ + +#include +#include + +#include +#include + +#include "AliJFCluster.h" + +ClassImp(AliJFCluster) + +AliJFCluster::AliJFCluster(Int_t n) : fStatus(0),fNMerge(0),fPx(0),fPy(0),fPz(0),fE(0), + fY(0),fPhi(0),fPt2(0),fPt2dD(0),fList(n) +{ +} + +AliJFCluster::AliJFCluster(const AliJFCluster ©) +{ + fStatus=copy.GetStatus(); + fNMerge=copy.GetNMerge(); + fPx=copy.GetPx(); + fPy=copy.GetPy(); + fPz=copy.GetPz(); + fE=copy.GetE(); + fY=copy.GetY(); + fPhi=copy.GetPhi(); + fPt2=copy.GetPt2(); + fPt2dD=copy.GetPt2D(); + fList=*copy.GetClusterList(); +} + +AliJFCluster::AliJFCluster(AliJFPreCluster ©) +{ + fStatus=1; //valid + fNMerge=0; + fPx=copy.GetPx(); + fPy=copy.GetPy(); + fPz=copy.GetPz(); + fE=copy.GetE(); + + SetValues(); + fList.push_back(©); +} + +AliJFCluster::AliJFCluster(AliJFPreCluster *precluster) +{ + fStatus=1; //valid + fNMerge=0; + SetValues(precluster->GetPx(),fPy=precluster->GetPy(),fPz=precluster->GetPz(),fE=precluster->GetE()); + fList.push_back(precluster); +} + +AliJFCluster::~AliJFCluster() +{ + fList.erase(fList.begin(),fList.end()); +} + +AliJFCluster& AliJFCluster::operator=(const AliJFCluster &rhs) +{ + fStatus=rhs.GetStatus(); + fNMerge=rhs.GetNMerge(); + fPx=rhs.GetPx(); + fPy=rhs.GetPy(); + fPz=rhs.GetPz(); + fE=rhs.GetE(); + fY=rhs.GetY(); + fPhi=rhs.GetPhi(); + fPt2=rhs.GetPt2(); + fPt2dD=rhs.GetPt2D(); + fList=*rhs.GetClusterList(); + return *this; +} + +AliJFCluster& AliJFCluster::operator=(AliJFPreCluster &rhs) +{ + fStatus=1; //valid + fNMerge=0; + fPx=rhs.GetPx(); + fPy=rhs.GetPy(); + fPz=rhs.GetPz(); + fE=rhs.GetE(); + + SetValues(); + fList.push_back(&rhs); + return *this; +} + +AliJFCluster& AliJFCluster::operator+=(AliJFCluster &rhs) //mark rhs as being merged! +{ + if(!rhs.IsValid()){ + cerr << "Cluster cannot be combined with invalid cluster:" << endl; + cerr << *this << endl; + cerr << rhs << endl; + return *this; + } + + AddValues(rhs.GetPx(),fPy=rhs.GetPy(),fPz=rhs.GetPz(),fE=rhs.GetE()); + vector tmp=*rhs.GetClusterList(); + for(vector::iterator i=tmp.begin();i!=tmp.end();i++){ + fList.push_back(*i); + } + + rhs.MarkIsMerged(); //change even rhs! + + return *this; +} + +AliJFCluster& AliJFCluster::operator+=(AliJFPreCluster &rhs) +{ + AddValues(rhs.GetPx(),rhs.GetPy(),rhs.GetPz(),rhs.GetE()); + fList.push_back(&rhs); + + return *this; +} + +ostream& operator<<(ostream& o, const AliJFCluster &c) +{ + o << c.GetStatus() << ": " << c.GetPx() << " " << c.GetPy() << " " << c.GetPz() << " " << c.GetE(); + + return o; +} + +void AliJFCluster::CombineCluster(AliJFCluster &rhs) //mark rhs as being merged! +{ + if(!rhs.IsValid()){ + cerr << "Error AliJFCluster: Cluster cannot be combined with invalid cluster:" << endl; + cerr << *this << endl; + cerr << rhs << endl; + return; + } + AddValues(rhs.GetPx(),fPy=rhs.GetPy(),rhs.GetPz(),rhs.GetE()); + vector tmp=*rhs.GetClusterList(); + for(vector::iterator i=tmp.begin();i!=tmp.end();i++){ + fList.push_back(*i); + } + + rhs.MarkIsMerged(); //change even rhs! +} + +void AliJFCluster::Print() +{ + cout << "Cluster " << " " << *this << endl; + Int_t n=0; + for(vector::iterator i=fList.begin();i!=fList.end();i++){ + n++; + cout << "PreCluster " << n << ": " << *(*i) << endl; + } +} + +void AliJFCluster::SetValues(Float_t px, Float_t py, Float_t pz, Float_t E) +{ + fPx=px; + fPy=py; + fPz=pz; + fE=E; + + SetValues(); +} + +void AliJFCluster::SetValues() +{ + if(IsValid()){ + fPt2=fPx*fPx+fPy*fPy; + if(fE<0) fE=TMath::Sqrt(fPt2+fPz*fPz); + fPt2dD=fPt2/D2; + fPhi=TMath::Pi()+TMath::ATan2(-fPy,-fPx); + fY=0.5*TMath::Log((fE+fPz)/(fE-fPz)); + if(fY>10) fY=10; + else if(fY<-10) fY=-10; + } else { + fPt2=fPt2dD=fPhi=fY=0; + } +} + +void AliJFCluster::AddValues(Float_t px, Float_t py, Float_t pz, Float_t E) +{ + fNMerge++; + fPx+=px; + fPy+=py; + fPz+=pz; + fE+=E; + + SetValues(); +} + +Float_t AliJFCluster::D2=1.0; diff --git a/JETAN/AliJFCluster.h b/JETAN/AliJFCluster.h new file mode 100644 index 00000000000..cacab8cf8cb --- /dev/null +++ b/JETAN/AliJFCluster.h @@ -0,0 +1,82 @@ +// $Id$ + +#ifndef ALIJFCLUSTERH +#define ALIJFCLUSTERH + +#include +#include +#include + +#include "AliJFPreCluster.h" + +class AliJFCluster +{ + public: + AliJFCluster(Int_t n=100); + AliJFCluster(const AliJFCluster ©); + AliJFCluster(AliJFPreCluster ©); + AliJFCluster(AliJFPreCluster *precluster); + virtual ~AliJFCluster(); + + AliJFCluster& operator=(const AliJFCluster &rhs); + AliJFCluster& operator=(AliJFPreCluster &rhs); + AliJFCluster& operator+=(AliJFCluster &rhs); + AliJFCluster& operator+=(AliJFPreCluster &rhs); + friend ostream& operator<< (ostream &o, const AliJFCluster &c); + + void CombineCluster(AliJFCluster &rhs); + + inline Int_t const GetStatus() const {return fStatus;} + inline Int_t const GetNMerge() const {return fNMerge;} + inline Bool_t const IsValid() const {return(fStatus==1 ? kTRUE:kFALSE);} + inline Bool_t const IsMerged() const {return(fStatus==10 ? kTRUE:kFALSE);} + inline Bool_t const IsJet() const {return(fStatus==100 ? kTRUE:kFALSE);} + inline Bool_t const IsInValid() const {return(fStatus<=0 ? kTRUE:kFALSE);} + + inline Float_t const GetPx() const {return fPx ;} + inline Float_t const GetPy() const {return fPy ;} + inline Float_t const GetPz() const {return fPz ;} + inline Float_t const GetE() const {return fE ;} + inline Float_t const GetY() const {return fY ;} + inline Float_t const GetPhi() const {return fPhi ;} + inline Float_t const GetPt2() const {return fPt2 ;} + inline Float_t const GetPt2D() const {return fPt2dD;} + + Int_t const GetNCombinedCluster() const {return fList.size();}; + vector const * GetClusterList() const {return &fList;} + + inline void MarkIsValid() {fStatus=1 ;} + inline void MarkIsMerged() {fStatus=10 ;} + inline void MarkIsJet() {fStatus=100;} + inline void MarkIsInValid() {fStatus=-1 ;} + inline void SetStatus(Int_t s){fStatus=s ;} + + void Print(); + + static void SetD(Float_t D_){D2=D_*D_;} + + protected: + void SetValues(); + + void SetValues(Float_t px, Float_t py, Float_t pz, Float_t E=-1); + void AddValues(Float_t px, Float_t py, Float_t pz, Float_t E); + + Int_t fStatus; + Int_t fNMerge; + Float_t fPx; + Float_t fPy; + Float_t fPz; + Float_t fE; + Float_t fY; + Float_t fPhi; + Float_t fPt2; + Float_t fPt2dD; + + vector fList; //-> + + static Float_t D2; //static D*D for K_t comparison + + ClassDef(AliJFCluster,1) //AliJFCluster class +}; + +#endif /*ALIJFCLUSTERH*/ diff --git a/JETAN/AliJFClusterDifference.cxx b/JETAN/AliJFClusterDifference.cxx new file mode 100644 index 00000000000..e4bf79d5102 --- /dev/null +++ b/JETAN/AliJFClusterDifference.cxx @@ -0,0 +1,81 @@ +// $Id$ + +#include + +#include +#include + +#include "AliJFCluster.h" +#include "AliJFClusterDifference.h" + + +ClassImp(AliJFClusterDifference) + +AliJFClusterDifference::AliJFClusterDifference() : + fNLastMerge(0),fI(NULL),fJ(NULL),fDij(0) +{ +} + +AliJFClusterDifference::AliJFClusterDifference(const AliJFClusterDifference ©) +{ + fNLastMerge=copy.GetNLastMerge(); + fDij=copy.GetDij(); + fI=copy.GetI(); + fJ=copy.GetJ(); +} + +AliJFClusterDifference::AliJFClusterDifference(Float_t dij_, AliJFCluster *i_,AliJFCluster *j_) : + fNLastMerge(0),fI(i_),fJ(j_),fDij(dij_) +{ +} + +AliJFClusterDifference::AliJFClusterDifference(AliJFCluster *i_,AliJFCluster *j_) : + fNLastMerge(0),fI(i_),fJ(j_),fDij(0) +{ + SetValues(i_,j_); +} + +Float_t AliJFClusterDifference::SetValues(AliJFCluster *i_,AliJFCluster *j_) +{ + fI=i_; + fJ=j_; + fDij=0; + fNLastMerge=0; + + if(IsValidPointer()&&IsValid()){ + //cout << "valid"; + if(IsDiagonal()){ + fDij=fI->GetPt2(); + fNLastMerge=fI->GetNMerge(); + //cout << " and diagonal" << endl; + } else { + Float_t ret1=fI->GetPt2D(); + Float_t ret2=fJ->GetPt2D(); + if(ret1>ret2) fDij=ret2; + else fDij=ret1; + + Float_t diff1=fI->GetY()-fJ->GetY(); + Float_t diff2=TMath::Abs(fI->GetPhi()-fJ->GetPhi()); + if(diff2>TMath::Pi()) diff2=2*TMath::Pi()-diff2; + fDij*=(diff1*diff1+diff2*diff2); + } + } + + return fDij; +} + +AliJFClusterDifference& AliJFClusterDifference::operator=(const AliJFClusterDifference ©) +{ + fDij=copy.GetDij(); + fI=copy.GetI(); + fJ=copy.GetJ(); + return *this; +} + +ostream& operator<<(ostream &o, const AliJFClusterDifference &j) +{ + o << j.fDij << ": " << j.fI << " " << j.fJ << endl; + + return o; +} + diff --git a/JETAN/AliJFClusterDifference.h b/JETAN/AliJFClusterDifference.h new file mode 100644 index 00000000000..4435426dc39 --- /dev/null +++ b/JETAN/AliJFClusterDifference.h @@ -0,0 +1,57 @@ +// $Id$ + +#ifndef ALIJFCLUSTERDIFFERENCEH +#define ALIJFCLUSTERDIFFERENCEH + +#include +#include "AliJFCluster.h" + +class AliJFClusterDifference +{ + public: + AliJFClusterDifference(); + AliJFClusterDifference(const AliJFClusterDifference ©); + AliJFClusterDifference(AliJFCluster *i, AliJFCluster *j); + AliJFClusterDifference(Float_t dij,AliJFCluster *i, AliJFCluster *j); + //virtual ~AliJFClusterDifference(); + + AliJFClusterDifference& operator=(const AliJFClusterDifference ©); + friend ostream& operator<<(ostream &o, const AliJFClusterDifference &j); + friend bool operator< (const AliJFClusterDifference &a, const AliJFClusterDifference &b); + friend bool operator==(const AliJFClusterDifference &a, const AliJFClusterDifference &b); + + inline Int_t GetNLastMerge() const {return fNLastMerge;} + inline AliJFCluster* GetI() const {return fI;} + inline AliJFCluster* GetJ() const {return fJ;} + inline Float_t GetDij() const {return fDij;} + + inline Bool_t IsDiagonal() const {return (fI==fJ ? kTRUE:kFALSE);} + inline Bool_t IsValid() const {return (fI->IsValid()&&fJ->IsValid());} + inline Bool_t IsValidDiagonal() const {return ((fI->IsValid())&&(fI->GetNMerge()==fNLastMerge));} + inline Bool_t IsValidEntry() const { + if(IsDiagonal()) return IsValidDiagonal(); + else return IsValid(); + } + inline Bool_t IsValidPointer() const {return (fI!=NULL && fJ!=NULL ? kTRUE:kFALSE);} + + Float_t SetValues(AliJFCluster *i,AliJFCluster *j); + + protected: + Int_t fNLastMerge; + AliJFCluster *fI; + AliJFCluster *fJ; + Float_t fDij; + + ClassDef(AliJFClusterDifference,0) //AliJFClusterDifference Class +}; + +inline bool operator<(const AliJFClusterDifference &a, const AliJFClusterDifference &b){ + return (a.GetDij() + +#include "AliJFJet.h" + +ClassImp(AliJFJet) + +AliJFJet::AliJFJet(Int_t n) : TObject(), + fNJet(0),fN(0),fNCharged(0),fNNeutral(0),fNEM(0), + fPhi(0),fEta(0),fY(0),fPt(0), + fPx(0),fPy(0),fPz(0),fE(0), + fPtSum(0),fPhiSum(0),fEtaSum(0), + fPhiC(0),fEtaC(0),fYC(0),fPtC(0), + fPxC(0),fPyC(0),fPzC(0),fEC(0), + fPtSumC(0),fPhiSumC(0),fEtaSumC(0), + fPhiN(0),fEtaN(0),fYN(0),fPtN(0), + fPxN(0),fPyN(0),fPzN(0),fEN(0), + fPtSumN(0),fPhiSumN(0),fEtaSumN(0), + fPhiEM(0),fEtaEM(0),fYEM(0),fPtEM(0), + fPxEM(0),fPyEM(0),fPzEM(0),fEEM(0), + fPtSumEM(0),fPhiSumEM(0),fEtaSumEM(0), + fMaxParticle(),fMaxParticleC(),fMaxParticleN(),fMaxParticleEM(), + fParticles("TParticle",n),fIsUpdated(kTRUE) +{ +} + +AliJFJet::~AliJFJet() +{ +} + +Int_t AliJFJet::Compare(const TObject *obj) const +{ + Double_t val=((AliJFJet*)obj)->GetPt(); + + if(fPt>val) return 1; + else if (fPtNext()) != NULL){ + cout << i++ << ": " << p->Energy() << endl; + } +} diff --git a/JETAN/AliJFJet.h b/JETAN/AliJFJet.h new file mode 100644 index 00000000000..59fda5f8ab2 --- /dev/null +++ b/JETAN/AliJFJet.h @@ -0,0 +1,164 @@ +// $Id$ + +#ifndef ALIJFJETH +#define ALIJFJETH + +#ifndef ROOT_TObject +#include +#endif + +#include +#include +#include + +class AliJFJet: public TObject +{ + public: + AliJFJet(Int_t n=250); + virtual ~AliJFJet(); + + inline Double_t GetPhi() {if(!fIsUpdated) Update(); return fPhi;} + inline Double_t GetEta() {if(!fIsUpdated) Update(); return fEta;} + inline Double_t GetY() {if(!fIsUpdated) Update(); return fY;} + inline Double_t GetPt() {if(!fIsUpdated) Update(); return fPt;} + inline Double_t GetPx() {if(!fIsUpdated) Update(); return fPx;} + inline Double_t GetPy() {if(!fIsUpdated) Update(); return fPy;} + inline Double_t GetPz() {if(!fIsUpdated) Update(); return fPz;} + inline Double_t GetE() {if(!fIsUpdated) Update(); return fE;} + inline Double_t GetE_() {if(!fIsUpdated) Update(); return fE_;} + inline Double_t GetPtSum() {if(!fIsUpdated) Update(); return fPtSum;} + inline Double_t GetPhiSum(){if(!fIsUpdated) Update(); return fPhiSum;} + inline Double_t GetEtaSum(){if(!fIsUpdated) Update(); return fEtaSum;} + + inline Double_t GetPhiC() {if(!fIsUpdated) Update(); return fPhiC;} + inline Double_t GetEtaC() {if(!fIsUpdated) Update(); return fEtaC;} + inline Double_t GetYC() {if(!fIsUpdated) Update(); return fYC;} + inline Double_t GetPtC() {if(!fIsUpdated) Update(); return fPtC;} + inline Double_t GetPxC() {if(!fIsUpdated) Update(); return fPxC;} + inline Double_t GetPyC() {if(!fIsUpdated) Update(); return fPyC;} + inline Double_t GetPzC() {if(!fIsUpdated) Update(); return fPzC;} + inline Double_t GetEC() {if(!fIsUpdated) Update(); return fEC;} + inline Double_t GetE_C() {if(!fIsUpdated) Update(); return fE_C;} + inline Double_t GetPtSumC() {if(!fIsUpdated) Update(); return fPtSumC;} + inline Double_t GetPhiSumC(){if(!fIsUpdated) Update(); return fPhiSumC;} + inline Double_t GetEtaSumC(){if(!fIsUpdated) Update(); return fEtaSumC;} + + inline Double_t GetPhiN() {if(!fIsUpdated) Update(); return fPhiN;} + inline Double_t GetEtaN() {if(!fIsUpdated) Update(); return fEtaN;} + inline Double_t GetYN() {if(!fIsUpdated) Update(); return fYN;} + inline Double_t GetPtN() {if(!fIsUpdated) Update(); return fPtN;} + inline Double_t GetPxN() {if(!fIsUpdated) Update(); return fPxN;} + inline Double_t GetPyN() {if(!fIsUpdated) Update(); return fPyN;} + inline Double_t GetPzN() {if(!fIsUpdated) Update(); return fPzN;} + inline Double_t GetEN() {if(!fIsUpdated) Update(); return fEN;} + inline Double_t GetE_N() {if(!fIsUpdated) Update(); return fE_N;} + inline Double_t GetPtSumN() {if(!fIsUpdated) Update(); return fPtSumN;} + inline Double_t GetPhiSumN(){if(!fIsUpdated) Update(); return fPhiSumN;} + inline Double_t GetEtaSumN(){if(!fIsUpdated) Update(); return fEtaSumN;} + + inline Double_t GetPhiEM() {if(!fIsUpdated) Update(); return fPhiEM;} + inline Double_t GetEtaEM() {if(!fIsUpdated) Update(); return fEtaEM;} + inline Double_t GetYEM() {if(!fIsUpdated) Update(); return fYEM;} + inline Double_t GetPtEM() {if(!fIsUpdated) Update(); return fPtEM;} + inline Double_t GetPxEM() {if(!fIsUpdated) Update(); return fPxEM;} + inline Double_t GetPyEM() {if(!fIsUpdated) Update(); return fPyEM;} + inline Double_t GetPzEM() {if(!fIsUpdated) Update(); return fPzEM;} + inline Double_t GetEEM() {if(!fIsUpdated) Update(); return fEEM;} + inline Double_t GetE_EM() {if(!fIsUpdated) Update(); return fE_EM;} + inline Double_t GetPtSumEM() {if(!fIsUpdated) Update(); return fPtSumEM;} + inline Double_t GetPhiSumEM(){if(!fIsUpdated) Update(); return fPhiSumEM;} + inline Double_t GetEtaSumEM(){if(!fIsUpdated) Update(); return fEtaSumEM;} + + inline Int_t GetNCharged() {if(!fIsUpdated) Update(); return fNCharged;} + inline Int_t GetNNeutral() {if(!fIsUpdated) Update(); return fNNeutral;} + inline Int_t GetNEM() {if(!fIsUpdated) Update(); return fNEM;} + + inline const Int_t GetNPart() const {return fN;} + inline const Int_t GetNJet () const {return fNJet;} + + TParticle* const GetMaxParticle() {return &fMaxParticle;} + TClonesArray* const GetParticles() {return &fParticles;} + + inline void SetNJet(Int_t n) {fNJet=n;} + virtual void Update(){}; + + virtual void Debug(); + virtual void Clean(); + + void Print(Option_t *) const {cout << "Jet " << (int)fNJet << ": " << fPtSum << " " << (int)fN << endl;} + ULong_t Hash() const {return fNJet;} + Bool_t IsEqual(const TObject *obj) const {return fNJet == ((AliJFJet*)obj)->GetNJet();} + Bool_t IsSortable() const {return kTRUE;} + Int_t Compare(const TObject *obj) const; + + protected: + Int_t fNJet; + Int_t fN; + Int_t fNCharged; + Int_t fNNeutral; + Int_t fNEM; + + Double_t fPhi; + Double_t fEta; + Double_t fY; + Double_t fPt; + Double_t fPx; + Double_t fPy; + Double_t fPz; + Double_t fE; + Double_t fE_; //energy without mass + Double_t fPtSum; + Double_t fPhiSum; + Double_t fEtaSum; + + Double_t fPhiC; + Double_t fEtaC; + Double_t fYC; + Double_t fPtC; + Double_t fPxC; + Double_t fPyC; + Double_t fPzC; + Double_t fEC; + Double_t fE_C; //energy without mass + Double_t fPtSumC; + Double_t fPhiSumC; + Double_t fEtaSumC; + + Double_t fPhiN; + Double_t fEtaN; + Double_t fYN; + Double_t fPtN; + Double_t fPxN; + Double_t fPyN; + Double_t fPzN; + Double_t fEN; + Double_t fE_N; //energy without mass + Double_t fPtSumN; + Double_t fPhiSumN; + Double_t fEtaSumN; + + Double_t fPhiEM; + Double_t fEtaEM; + Double_t fYEM; + Double_t fPtEM; + Double_t fPxEM; + Double_t fPyEM; + Double_t fPzEM; + Double_t fEEM; + Double_t fE_EM; //energy without mass + Double_t fPtSumEM; + Double_t fPhiSumEM; + Double_t fEtaSumEM; + + TParticle fMaxParticle; + TParticle fMaxParticleC; + TParticle fMaxParticleN; + TParticle fMaxParticleEM; + TClonesArray fParticles; + + Bool_t fIsUpdated; + + ClassDef(AliJFJet,1) //AliJFJet class +}; + +#endif /*ALIJFJETH*/ diff --git a/JETAN/AliJFJetCalorimeterTrigger.cxx b/JETAN/AliJFJetCalorimeterTrigger.cxx new file mode 100644 index 00000000000..e47424df5cf --- /dev/null +++ b/JETAN/AliJFJetCalorimeterTrigger.cxx @@ -0,0 +1,196 @@ +// $Id$ + +#include + +#include +#include +#include +#include +#include + +#include "AliJFJetCalorimeterTrigger.h" +#include "AliJFJetCalorimeterTriggerResult.h" + +ClassImp(AliJFJetCalorimeterTrigger) + +AliJFJetCalorimeterTrigger::AliJFJetCalorimeterTrigger(Int_t n) : AliJFJetTrigger(n), + fRin(0.2),fRmid(0.7),fRout(1.0), + fPhiBins(25),fEtaBins(25) +{ + fAin=TMath::Pi()*fRin*fRin; + fAout=TMath::Pi()*(fRout*fRout-fRin*fRin); +} + +AliJFJetCalorimeterTrigger::~AliJFJetCalorimeterTrigger() +{ + Clean(); +} + +Int_t AliJFJetCalorimeterTrigger::Init(TClonesArray *particles) +{ + if(particles==NULL) return -1; + + TIterator *iter=particles->MakeIterator(); + TParticle *p; + Int_t ret=0; + + while((p=(TParticle*)iter->Next()) != NULL){ + if(IsAcceptedParticle(p)){ + new((*fParticles)[ret]) TParticle(*p); + ret++; + } + } + delete iter; + + fSeedPlane=new TH2F("seedplane","seedplane",fEtaBins,fEtaMin,fEtaMax,fPhiBins,fPhiMin,fPhiMax); + + return ret; +} + +Int_t AliJFJetCalorimeterTrigger::Run() +{ + TIterator *iter=fParticles->MakeIterator(); + TParticle *p; + while((p=(TParticle*)iter->Next()) != NULL){ + fSeedPlane->Fill(p->Eta(),p->Phi(),p->Pt()); + } + delete iter; + + fSeedPlane->Sumw2(); + Float_t thr=fSeedPlane->GetSumOfWeights()/fEtaBins/fPhiBins; + + //Find Maxima + Int_t n=0; + Float_t *mbin=new Float_t[Int_t(fEtaBins*fPhiBins)]; + Float_t *mphi=new Float_t[Int_t(fEtaBins*fPhiBins)]; + Float_t *meta=new Float_t[Int_t(fEtaBins*fPhiBins)]; + for(Int_t eta=1; eta<=fEtaBins; eta++) { + for(Int_t phi=1; phi<=fPhiBins; phi++) { + Int_t bin5=fSeedPlane->GetBin(eta,phi); + + Double_t val5=fSeedPlane->GetBinContent(bin5); + Double_t val8=0,val2=0,val4=0,val6=0,val7=0,val9=0,val3=0,val1=0; + + Int_t phiplusone=phi+1; + if(phiplusone>fPhiBins) phiplusone=0; + Int_t phiminusone=phi-1; + if(phiminusone<1) phiminusone=fPhiBins; + + val4=fSeedPlane->GetBinContent(fSeedPlane->GetBin(eta,phiminusone)); + val6=fSeedPlane->GetBinContent(fSeedPlane->GetBin(eta,phiplusone)); + + if(eta>1){ + val2=fSeedPlane->GetBinContent(fSeedPlane->GetBin(eta-1,phi)); + val3=fSeedPlane->GetBinContent(fSeedPlane->GetBin(eta-1,phiplusone)); + val1=fSeedPlane->GetBinContent(fSeedPlane->GetBin(eta-1,phiminusone)); + } + if(etaGetBinContent(fSeedPlane->GetBin(eta+1,phi)); + val7=fSeedPlane->GetBinContent(fSeedPlane->GetBin(eta+1,phiminusone)); + val9=fSeedPlane->GetBinContent(fSeedPlane->GetBin(eta+1,phiplusone)); + } + + if((val5>val1)&&(val5>val2)&&(val5>val3)&&(val5>val4)&& + (val5>val6)&&(val5>val7)&&(val5>val8)&&(val5>val9)&& + (val5>thr)){ + meta[n]=fSeedPlane->GetXaxis()->GetBinCenter(eta); + mphi[n]=fSeedPlane->GetYaxis()->GetBinCenter(phi); + mbin[n]=val5; + n++; + } + } + } + + Float_t *binweight=new Float_t[fNJetsMax]; + Float_t *phicenter=new Float_t[fNJetsMax]; + Float_t *etacenter=new Float_t[fNJetsMax]; + for(Int_t i=0;iMakeIterator(); + while((p=(TParticle*)iter->Next()) != NULL){ + Float_t pe=p->Eta(); + Float_t pp=p->Phi(); + Float_t pt=p->Pt(); + + for(Int_t i=0;ifRmid2)&&(rad + +class TH2F; + +class AliJFJetCalorimeterTrigger : public AliJFJetTrigger +{ + public: + AliJFJetCalorimeterTrigger(Int_t n=50); + virtual ~AliJFJetCalorimeterTrigger(); + + Int_t Init(TClonesArray *particles); + Int_t Run(); + + void Clean(); + void Debug(){}; + + void SetRadius(Float_t in=0.2,Float_t mid=0.7,Float_t out=1.0); + void SetBins(Int_t phis=25,Int_t etas=25); + + protected: + Float_t fRin; + Float_t fRmid; + Float_t fRout; + Float_t fAin; + Float_t fAout; + + Int_t fPhiBins; + Int_t fEtaBins; + + TH2F *fSeedPlane; //! + + ClassDef(AliJFJetCalorimeterTrigger,1) //AliJFJetCalorimeterTrigger class +}; + +#endif /*ALIJFJETCALORIMETERTRIGGERH*/ diff --git a/JETAN/AliJFJetCalorimeterTriggerResult.cxx b/JETAN/AliJFJetCalorimeterTriggerResult.cxx new file mode 100644 index 00000000000..63bdb7bba2d --- /dev/null +++ b/JETAN/AliJFJetCalorimeterTriggerResult.cxx @@ -0,0 +1,27 @@ +// $Id$ + +#include +#include "AliJFJetCalorimeterTriggerResult.h" + +ClassImp(AliJFJetCalorimeterTriggerResult) + +AliJFJetCalorimeterTriggerResult::AliJFJetCalorimeterTriggerResult() + : AliJFJetTriggerResult(), + fCenterPhi(0),fCenterEta(0),fCenterEt(0),fThreshEt(0), + fInnerEt(0),fOuterEt(0),fRin(0),fRmid(0), + fRout(0),fPhiBins(0),fEtaBins(0) +{ +} + +AliJFJetCalorimeterTriggerResult::AliJFJetCalorimeterTriggerResult(Float_t PtMin,Float_t PtMax,Float_t PhiMin,Float_t PhiMax,Float_t EtaMin,Float_t EtaMax,Bool_t Neutral,Bool_t EM,Bool_t Charged,Float_t CPhi,Float_t CEta,Float_t CEt,Float_t CThr,Float_t Inner,Float_t Outer,Float_t Rin,Float_t Rmid,Float_t Rout,Int_t PhiBins,Int_t EtaBins) + : AliJFJetTriggerResult(PtMin,PtMax,PhiMin,PhiMax,EtaMin,EtaMax,Neutral,EM,Charged), + fCenterPhi(CPhi),fCenterEta(CEta),fCenterEt(CEt),fThreshEt(CThr), + fInnerEt(Inner),fOuterEt(Outer),fRin(Rin),fRmid(Rmid), + fRout(Rout),fPhiBins(PhiBins),fEtaBins(EtaBins) +{ +} + + +AliJFJetCalorimeterTriggerResult::~AliJFJetCalorimeterTriggerResult() +{ +} diff --git a/JETAN/AliJFJetCalorimeterTriggerResult.h b/JETAN/AliJFJetCalorimeterTriggerResult.h new file mode 100644 index 00000000000..8f2c1a2c6d0 --- /dev/null +++ b/JETAN/AliJFJetCalorimeterTriggerResult.h @@ -0,0 +1,47 @@ +// $Id$ + +#ifndef ALIJFJETCALORIMETERTRIGGERRESULTH +#define ALIJFJETCALORIMETERTRIGGERRESULTH + +#include "AliJFJetTriggerResult.h" + +class AliJFJetCalorimeterTriggerResult : public AliJFJetTriggerResult +{ + public: + AliJFJetCalorimeterTriggerResult(); + AliJFJetCalorimeterTriggerResult(Float_t PtMin,Float_t PtMax,Float_t PhiMin,Float_t PhiMax,Float_t EtaMin,Float_t EtaMax,Bool_t Neutral,Bool_t EM,Bool_t Charged,Float_t CPhi,Float_t CEta,Float_t CEt,Float_t CThr,Float_t Inner,Float_t Outer,Float_t Rin,Float_t Rmid,Float_t Rout,Int_t PhiBins,Int_t EtaBins); + + virtual ~AliJFJetCalorimeterTriggerResult(); + + Float_t GetCenterPhi() const {return fCenterPhi;} + Float_t GetCenterEta() const {return fCenterEta;} + Float_t GetCenterEt() const {return fCenterEt;} + Float_t GetThreshEt() const {return fThreshEt;} + Float_t GetInnerEt() const {return fInnerEt;} + Float_t GetOuterEt() const {return fOuterEt;} + Float_t GetRin() const {return fRin;} + Float_t GetRmid() const {return fRmid;} + Float_t GetRout() const {return fRout;} + Int_t GetPhiBins() const {return fPhiBins;} + Int_t GetEtaBins() const {return fEtaBins;} + + protected: + Float_t fCenterPhi; + Float_t fCenterEta; + Float_t fCenterEt; + Float_t fThreshEt; + Float_t fInnerEt; + Float_t fOuterEt; + + Float_t fRin; + Float_t fRmid; + Float_t fRout; + + Int_t fPhiBins; + Int_t fEtaBins; + + + ClassDef(AliJFJetCalorimeterTriggerResult,1) //AliJFJetCalorimeterTriggerResult class +}; + +#endif /*ALIJFJETCALORIMETERTRIGGERRESULTH*/ diff --git a/JETAN/AliJFJetFinder.cxx b/JETAN/AliJFJetFinder.cxx new file mode 100644 index 00000000000..86a59b9648e --- /dev/null +++ b/JETAN/AliJFJetFinder.cxx @@ -0,0 +1,48 @@ +// $Id$ + +#include + +#include +#include +#include + +#include "AliJFJetFinder.h" + +ClassImp(AliJFJetFinder) + +AliJFJetFinder::AliJFJetFinder(Int_t n) : fNJets(0),fNJetsMax(n),fJets(n), + fPtMin(0),fPtMax(1000), + fEtaMin(-1),fEtaMax(1), + fPhiMin(0),fPhiMax(6.4), + fNeutral(kTRUE),fCharged(kTRUE),fEM(kTRUE) +{ +} + +AliJFJetFinder::~AliJFJetFinder() +{ +} + +Bool_t AliJFJetFinder::IsAcceptedParticle(TParticle *p) +{ + if(p->GetStatusCode()%100!=1) return kFALSE; + + return kTRUE; +} + +void AliJFJetFinder::SetPtCut(Float_t ptmin, Float_t ptmax) +{ + fPtMin=ptmin; + fPtMax=ptmax; +} + +void AliJFJetFinder::SetPhiCut(Float_t phimin, Float_t phimax) +{ + fPhiMin=phimin; + fPhiMax=phimax; +} + +void AliJFJetFinder::SetEtaCut(Float_t emin, Float_t emax) +{ + fEtaMin=emin; + fEtaMax=emax; +} diff --git a/JETAN/AliJFJetFinder.h b/JETAN/AliJFJetFinder.h new file mode 100644 index 00000000000..673a9bf50c5 --- /dev/null +++ b/JETAN/AliJFJetFinder.h @@ -0,0 +1,57 @@ +// $Id$ + +#ifndef ALIJFJETFINDERH +#define ALIJFJETFINDERH + +#include + +class TCollection; +class TParticle; +class JFTower; + +class AliJFJetFinder +{ + public: + AliJFJetFinder(Int_t n=50); + virtual ~AliJFJetFinder(); + + virtual Int_t Init(TClonesArray */*particles*/){return 0;} + virtual Int_t Run(){return 0;} + + inline TObjArray* GetJets() {return &fJets;} + inline Int_t const GetNJets() const {return fNJets;} + + virtual Bool_t IsAcceptedParticle(TParticle *p); + virtual Bool_t IsAcceptedTower(JFTower*){return kFALSE;} + + virtual void Debug(){}; + virtual void Clean(){fJets.Delete();fNJets=0;} + + void SetPtCut(Float_t ptmin=0, Float_t ptmax=1000); + void SetPhiCut(Float_t phi=6.4){SetPhiCut(0,phi);} + void SetPhiCut(Float_t phimin, Float_t phimax); + void SetEtaCut(Float_t e=1){SetEtaCut(-e,e);} + void SetEtaCut(Float_t emin, Float_t emax); + void SetNeutral(Bool_t b=kTRUE){fNeutral=b;} + void SetCharged(Bool_t b=kTRUE){fCharged=b;} + void SetEM(Bool_t b=kTRUE){fEM=b;} + + protected: + Int_t fNJets; + Int_t fNJetsMax; + TObjArray fJets; + + Float_t fPtMin; + Float_t fPtMax; + Float_t fEtaMin; + Float_t fEtaMax; + Float_t fPhiMin; + Float_t fPhiMax; + Bool_t fNeutral; + Bool_t fCharged; + Bool_t fEM; + + ClassDef(AliJFJetFinder,1) //AliJFJetFinder class +}; + +#endif /*ALIJFJETFINDERH*/ diff --git a/JETAN/AliJFJetTrigger.cxx b/JETAN/AliJFJetTrigger.cxx new file mode 100644 index 00000000000..3395b91ed2a --- /dev/null +++ b/JETAN/AliJFJetTrigger.cxx @@ -0,0 +1,47 @@ +// $Id$ + +#include + +#include +#include +#include + +#include "AliJFJetTrigger.h" + +ClassImp(AliJFJetTrigger) + +AliJFJetTrigger::AliJFJetTrigger(Int_t n) : AliJFJetFinder(n) +{ + fParticles=new TClonesArray("TParticle",100000); +} + +AliJFJetTrigger::~AliJFJetTrigger() +{ + delete fParticles; +} + +Bool_t AliJFJetTrigger::IsAcceptedParticle(TParticle *p) +{ + if(p->GetStatusCode()%100!=1) return kFALSE; + + Int_t pcode=p->GetPdgCode(); + + if((!fEM) && ((pcode==11)||(pcode==-11)||(pcode==22))) return kFALSE; + + TParticlePDG *pdg=p->GetPDG(); + Float_t ch=pdg->Charge(); + if((!fCharged)&&(ch)) return kFALSE; + if((!fNeutral)&&(!ch)) return kFALSE; + + Float_t eta=p->Eta(); + if((etafEtaMax)) return kFALSE; + + Float_t phi=p->Phi(); + if((phifPhiMax)) return kFALSE; + + Float_t pt=p->Pt(); + if((ptfPtMax)) return kFALSE; + + return kTRUE; +} + diff --git a/JETAN/AliJFJetTrigger.h b/JETAN/AliJFJetTrigger.h new file mode 100644 index 00000000000..f287ca48382 --- /dev/null +++ b/JETAN/AliJFJetTrigger.h @@ -0,0 +1,26 @@ +// $Id$ + +#ifndef ALIJFJETTRIGGERH +#define ALIJFJETTRIGGERH + +#include +#include "AliJFJetFinder.h" + +class AliJFJetTrigger : public AliJFJetFinder +{ + public: + AliJFJetTrigger(Int_t n=50); + virtual ~AliJFJetTrigger(); + + Bool_t IsAcceptedParticle(TParticle *p); + + void Clean(){fParticles->Delete();} + + protected: + + TClonesArray *fParticles; + + ClassDef(AliJFJetTrigger,1) //AliJFJetTrigger class +}; + +#endif /*ALIJFJETTRIGGERH*/ diff --git a/JETAN/AliJFJetTriggerResult.cxx b/JETAN/AliJFJetTriggerResult.cxx new file mode 100644 index 00000000000..1026866d769 --- /dev/null +++ b/JETAN/AliJFJetTriggerResult.cxx @@ -0,0 +1,28 @@ +// $Id$ + +#include +#include "AliJFJetTriggerResult.h" + +ClassImp(AliJFJetTriggerResult) + +AliJFJetTriggerResult::AliJFJetTriggerResult() : TObject(), + fPtMin(0),fPtMax(0), + fEtaMin(0),fEtaMax(0), + fPhiMin(0),fPhiMax(0), + fNeutral(kTRUE),fCharged(kTRUE),fEM(kTRUE) +{ +} + +AliJFJetTriggerResult::AliJFJetTriggerResult(Float_t PtMin,Float_t PtMax,Float_t EtaMin,Float_t EtaMax,Float_t PhiMin,Float_t PhiMax,Bool_t Neutral,Bool_t EM,Bool_t Charged) : TObject(), + fPtMin(PtMin),fPtMax(PtMax), + fEtaMin(EtaMin),fEtaMax(EtaMax), + fPhiMin(PhiMin),fPhiMax(PhiMax), + fNeutral(Neutral),fCharged(Charged),fEM(EM) + +{ +} + + +AliJFJetTriggerResult::~AliJFJetTriggerResult() +{ +} diff --git a/JETAN/AliJFJetTriggerResult.h b/JETAN/AliJFJetTriggerResult.h new file mode 100644 index 00000000000..223485304e9 --- /dev/null +++ b/JETAN/AliJFJetTriggerResult.h @@ -0,0 +1,44 @@ +// $Id$ + +#ifndef ALIJFJETTRIGGERRESULTH +#define ALIJFJETTRIGGERRESULTH + +#ifndef ROOT_TObject +#include +#endif + + +class AliJFJetTriggerResult : public TObject +{ + public: + AliJFJetTriggerResult(); + AliJFJetTriggerResult(Float_t PtMin,Float_t PtMax,Float_t EtaMin,Float_t EtaMax,Float_t PhiMin,Float_t PhiMax,Bool_t Neutral,Bool_t EM,Bool_t Charged); + virtual ~AliJFJetTriggerResult(); + + Float_t GetPtMin() const {return fPtMin;} + Float_t GetPtMax() const {return fPtMax;} + Float_t GetEtaMin() const {return fEtaMin;} + Float_t GetEtaMax() const {return fEtaMax;} + Float_t GetPhiMin() const {return fPhiMin;} + Float_t GetPhiMax() const {return fPhiMax;} + Bool_t IsNeutral() const {return fNeutral;} + Bool_t IsCharged() const {return fCharged;} + Bool_t IsEM() const {return fEM;} + + + protected: + + Float_t fPtMin; + Float_t fPtMax; + Float_t fEtaMin; + Float_t fEtaMax; + Float_t fPhiMin; + Float_t fPhiMax; + Bool_t fNeutral; + Bool_t fCharged; + Bool_t fEM; + + ClassDef(AliJFJetTriggerResult,1) //AliJFJetTriggerResult class +}; + +#endif /*ALIJFJETTRIGGERRESULTH*/ diff --git a/JETAN/AliJFKtJet.cxx b/JETAN/AliJFKtJet.cxx new file mode 100644 index 00000000000..ffee64f20f9 --- /dev/null +++ b/JETAN/AliJFKtJet.cxx @@ -0,0 +1,258 @@ +// $Id$ + +#include +#include + +#include +#include +#include +#include + +#include "AliJFKtJet.h" +#include "AliJFPreCluster.h" +#include "AliJFCluster.h" + +ClassImp(AliJFKtJet) + +AliJFKtJet::AliJFKtJet(Int_t n) : AliJFJet(n) + +{ +} + +AliJFKtJet::~AliJFKtJet() +{ + Clean(); +} + +void AliJFKtJet::AddJet(AliJFCluster *c) +{ + if(!c) return; + if(!c->IsJet()){ + cerr << "AliJFKtJet Error: Something is strange here, supposed to add a jet!" << endl; + return ; + } + + vector clist=*c->GetClusterList(); + for(vector::iterator i=clist.begin();i!=clist.end();i++){ + + //Get particles inside PreCluster + TClonesArray *ps=(*i)->GetParticles(); + + //Copy Particles inside PreCluster + TIterator *iter=ps->MakeIterator(); + TParticle *p; + while((p=(TParticle*)iter->Next()) != NULL){ + new (fParticles[fN]) TParticle(*p); + + fN++; + } + } + + fIsUpdated=kFALSE; +} + +void AliJFKtJet::Update() +{ + if(fIsUpdated) return; + + fIsUpdated=kTRUE; + + fPhi=0; + fEta=0; + fY=0; + fPt=0; + fPx=0; + fPy=0; + fPz=0; + fE=0; + fE_=0; + fPtSum=0; + fPhiSum=0; + fEtaSum=0; + + fPhiC=0; + fEtaC=0; + fYC=0; + fPtC=0; + fPxC=0; + fPyC=0; + fPzC=0; + fEC=0; + fE_C=0; + fPtSumC=0; + fPhiSumC=0; + fEtaSumC=0; + + fPhiN=0; + fEtaN=0; + fYN=0; + fPtN=0; + fPxN=0; + fPyN=0; + fPzN=0; + fEN=0; + fE_N=0; + fPtSumN=0; + fPhiSumN=0; + fEtaSumN=0; + + fPhiEM=0; + fEtaEM=0; + fYEM=0; + fPtEM=0; + fPxEM=0; + fPyEM=0; + fPzEM=0; + fEEM=0; + fE_EM=0; + fPtSumEM=0; + fPhiSumEM=0; + fEtaSumEM=0; + + fNCharged=0; + fNNeutral=0; + fNEM=0; + + Float_t fMaxParticlePt=0; + Float_t fMaxParticlePtC=0; + Float_t fMaxParticlePtN=0; + Float_t fMaxParticlePtEM=0; + + //loop over particles in jet + Int_t N=0; + TParticle *p; + TIterator *iter=fParticles.MakeIterator(); + while((p=(TParticle*)iter->Next()) != NULL){ + N++; + + Float_t px=p->Px(); + Float_t py=p->Py(); + Float_t pz=p->Pz(); + Float_t E=p->Energy(); + Float_t E_=TMath::Sqrt(px*px+py*py+pz*pz); //massless particles + Float_t pt=p->Pt(); + Float_t phi=p->Phi(); + Float_t eta=p->Eta(); + + fPx+=px; + fPy+=py; + fPz+=pz; + fE+=E; + fE_+=E_; + + fPtSum+=pt; + fPhiSum+=phi*pt; + fEtaSum+=eta*pt; + + if(pt>fMaxParticlePt){ + fMaxParticlePt=pt; + fMaxParticle=*p; + } + + Int_t pcode=p->GetPdgCode(); + if((pcode==11)||(pcode==-11)||(pcode==22)){ //EM Particle; + fNEM++; + + fPxEM+=px; + fPyEM+=py; + fPzEM+=pz; + fEEM+=E; + fE_EM+=E_; + + fPtSumEM+=pt; + fPhiSumEM+=phi*pt; + fEtaSumEM+=eta*pt; + + if(pt>fMaxParticlePtEM){ + fMaxParticlePtEM=pt; + fMaxParticleEM=*p; + } + } else if(p->GetPDG()->Charge()) {//Charged Particle + fNCharged++; + + fPxC+=px; + fPyC+=py; + fPzC+=pz; + fEC+=E; + fE_C+=E_; + fPtSumC+=pt; + fPhiSumC+=phi*pt; + fEtaSumC+=eta*pt; + + if(pt>fMaxParticlePtC){ + fMaxParticlePtC=pt; + fMaxParticleC=*p; + } + } else { //Neutral Particle + fNNeutral++; + + fPxN+=px; + fPyN+=py; + fPzN+=pz; + fEN+=E; + fE_N+=E_; + fPtSumN+=pt; + fPhiSumN+=phi*pt; + fEtaSumN+=eta*pt; + + if(pt>fMaxParticlePtN){ + fMaxParticlePtN=pt; + fMaxParticleN=*p; + } + } + } //end loop + + fPt=TMath::Sqrt(fPx*fPx+fPy*fPy); + //fPhi=TMath::ATan(fPy/fPx); + fPhi=TMath::Pi()+TMath::ATan2(-fPy,-fPx); + fY=0.5*TMath::Log((fE+fPz)/(fE-fPz)); + fEta=0.5*TMath::Log((fE_+fPz)/(fE_-fPz)); + + fPtC=TMath::Sqrt(fPxC*fPxC+fPyC*fPyC); + //fPhiC=TMath::ATan(fPyC/fPxC); + fPhiC=TMath::Pi()+TMath::ATan2(-fPyC,-fPxC); + fYC=0.5*TMath::Log((fEC+fPzC)/(fEC-fPzC)); + fEtaC=0.5*TMath::Log((fE_C+fPzC)/(fE_C-fPzC)); + + fPtN=TMath::Sqrt(fPxN*fPxN+fPyN*fPyN); + //fPhiN=TMath::ATan(fPyN/fPxN); + fPhiN=TMath::Pi()+TMath::ATan2(-fPyN,-fPxN); + fYN=0.5*TMath::Log((fEN+fPz)/(fEN-fPz)); + fEtaN=0.5*TMath::Log((fE_N+fPz)/(fE_N-fPz)); + + fPtEM=TMath::Sqrt(fPxEM*fPxEM+fPyEM*fPyEM); + //fPhiEM=TMath::ATan(fPyEM/fPxEM); + fPhiEM=TMath::Pi()+TMath::ATan2(-fPyEM,-fPxEM); + fYEM=0.5*TMath::Log((fEEM+fPz)/(fEEM-fPz)); + fEtaEM=0.5*TMath::Log((fE_EM+fPz)/(fE_EM-fPz)); + + fPhiSum/=fPtSum; + fEtaSum/=fPtSum; + fPhiSumEM/=fPtSumEM; + fEtaSumEM/=fPtSumEM; + fPhiSumC/=fPtSumC; + fEtaSumC/=fPtSumC; + fPhiSumN/=fPtSumN; + fEtaSumN/=fPtSumN; + + //Do some simple checks + if(N!=fN){ + cerr << "Fatal Error: Particles in Jets don't match!" << endl; + exit(1); + } + if(fNCharged+fNNeutral+fNEM!=fN){ + cerr << "Fatal Error: Particles in Jets don't sum up!" << endl; + exit(1); + } +} + +/* +void AliJFKtJet::Debug() +{ +} + +void AliJFKtJet::Clean() +{ + ::Clean(); +} +*/ diff --git a/JETAN/AliJFKtJet.h b/JETAN/AliJFKtJet.h new file mode 100644 index 00000000000..afdee080713 --- /dev/null +++ b/JETAN/AliJFKtJet.h @@ -0,0 +1,27 @@ +// $Id$ + +#ifndef ALIJFKTJETH +#define ALIJFKTJETH + +#include "AliJFJet.h" + +class AliJFCluster; + +class AliJFKtJet : public AliJFJet +{ + public: + AliJFKtJet(Int_t n=250); + virtual ~AliJFKtJet(); + + void AddJet(AliJFCluster *c); + void Update(); + + //void Debug(); + //void Clean(); + + protected: + + ClassDef(AliJFKtJet,1) //AliJFKtJet class +}; + +#endif /*ALIJFKTJETH*/ diff --git a/JETAN/AliJFKtJetFinder.cxx b/JETAN/AliJFKtJetFinder.cxx new file mode 100644 index 00000000000..220cdc724c9 --- /dev/null +++ b/JETAN/AliJFKtJetFinder.cxx @@ -0,0 +1,196 @@ +// $Id$ + +/* Kt Jet finder class ala hep-ex/0005012 + for CDF/D0 Run II */ + +#include +#include +#include + +#include +#include +#include +#include +#include + +#include "AliJFPreCluster.h" +#include "AliJFCluster.h" +#include "AliJFClusterDifference.h" +#include "AliJFKtJet.h" +#include "AliJFKtJetFinder.h" + +ClassImp(AliJFKtJetFinder) + +AliJFKtJetFinder::AliJFKtJetFinder(Int_t n) : AliJFJetFinder(n) +{ +} + +AliJFKtJetFinder::~AliJFKtJetFinder() +{ + Clean(); +} + +Bool_t AliJFKtJetFinder::IsAcceptedParticle(TParticle *p) +{ + if(p->GetStatusCode()%100!=1) return kFALSE; + + Int_t pcode=p->GetPdgCode(); + + if((!fEM) && ((pcode==11)||(pcode==-11)||(pcode==22))) return kFALSE; + + TParticlePDG *pdg=p->GetPDG(); + Float_t ch=pdg->Charge(); + if((!fCharged)&&(ch)) return kFALSE; + if((!fNeutral)&&(!ch)) return kFALSE; + + Float_t eta=p->Eta(); + if((etafEtaMax)) return kFALSE; + + Float_t phi=p->Phi(); + if((phifPhiMax)) return kFALSE; + + Float_t pt=p->Pt(); + if((ptfPtMax)) return kFALSE; + + return kTRUE; +} + +Int_t AliJFKtJetFinder::Init(TClonesArray *particles) +{ //create precluster according to particles + //each precluster corresponds to a particle + //in the accepted range + if(particles==NULL) return -1; + + TIterator *iter=particles->MakeIterator(); + TParticle *p; + Int_t ret=0; + + while((p=(TParticle*)iter->Next()) != NULL){ + if(IsAcceptedParticle(p)){ + ret++; + + //fPreClusterList.push_back(new AliJFPreCluster(p)); + fPreClusterList.push_back(new AliJFPreCluster(p->Px(),p->Py(),p->Pz(),-1,p)); + } + } + +#if 0 + for(vector::iterator c=fPreClusterList.begin();c!=fPreClusterList.end();c++){ + cout << *(*c) << endl; + } + //exit(1); +#endif + + for(vector::iterator i=fPreClusterList.begin();i!=fPreClusterList.end();i++){ + fClusterList.push_back(new AliJFCluster(*(*i))); + } + +#if 0 + for(vector::iterator c=fClusterList.begin();c!=fClusterList.end();c++){ + cout << *(*c) << endl; + } + //exit(1); +#endif + + AliJFClusterDifference diff; + for(vector::iterator i=fClusterList.begin();i!=fClusterList.end();i++){ + for(vector::iterator j=i;j!=fClusterList.end();j++){ + diff.SetValues(*i,*j); + fClusterDiffSet.insert(diff); + } + } + +#if 0 + for(multiset::iterator pos=fClusterDiffSet.begin();pos!=fClusterDiffSet.end();pos++){ + cout << *pos << endl; + } + //exit(1); +#endif + + return ret; +} + +Int_t AliJFKtJetFinder::Run() +{ + //loop over stored diffence objects until set is empty + while(!fClusterDiffSet.empty()){ + //get first element of sorted set + multiset::iterator pos=fClusterDiffSet.begin(); + + //cout << pos->GetDij() << endl; + if((!pos->IsValidPointer())||(!pos->IsValidEntry())){ //delete old value left in set + fClusterDiffSet.erase(pos); + + continue; + } + + //get information on stored difference + AliJFCluster *i=pos->GetI(); + AliJFCluster *j=pos->GetJ(); + bool isjetfound=pos->IsDiagonal(); + fClusterDiffSet.erase(pos); //take it out + + if(isjetfound){ //found jet + i->MarkIsJet(); + + if(fNJets==fNJetsMax){ + fNJetsMax+=fNJets; + fJets.Expand(fNJetsMax); + } + + fJets.AddAt(new AliJFKtJet(),fNJets); + fJet=(AliJFKtJet*)fJets.At(fNJets); + fJet->SetNJet(++fNJets); + fJet->AddJet(i); + fJet->Update(); + + } else { //combine cluster and make new difference objects + i->CombineCluster(*j); + + AliJFClusterDifference diff; //create and insert new difference objects + for(vector::iterator c=fClusterList.begin();c!=fClusterList.end();c++){ + if((*c)->IsValid()) { + diff.SetValues(i,*c); + fClusterDiffSet.insert(diff); + } + } + } //end if combine cluster + } //end while + + fJets.Sort(); + //fJets.Print(); + + return fNJets; +} + +void AliJFKtJetFinder::Debug() +{ + for(vector::iterator c=fPreClusterList.begin();c!=fPreClusterList.end();c++){ + cout << *(*c) << endl; + } + + for(vector::iterator c=fClusterList.begin();c!=fClusterList.end();c++){ + //(*c)->Print(); + } + +} + +void AliJFKtJetFinder::Clean() +{ + if(!fPreClusterList.empty()){ + for(vector::iterator i=fPreClusterList.begin();i!=fPreClusterList.end();i++){ + delete (*i); + } + fPreClusterList.erase(fPreClusterList.begin(),fPreClusterList.end()); + } + if(!fClusterList.empty()){ + for(vector::iterator i=fClusterList.begin();i!=fClusterList.end();i++){ + delete (*i); + } + fClusterList.erase(fClusterList.begin(),fClusterList.end()); + } + + if(!fClusterDiffSet.empty()) fClusterDiffSet.clear(); + + AliJFJetFinder::Clean(); +} diff --git a/JETAN/AliJFKtJetFinder.h b/JETAN/AliJFKtJetFinder.h new file mode 100644 index 00000000000..f2c8ba6debb --- /dev/null +++ b/JETAN/AliJFKtJetFinder.h @@ -0,0 +1,42 @@ +#ifndef ALIJFKTJETFINDERH +#define ALIJFKTJETFINDERH + +#include +#include +#include + +#include "AliJFJetFinder.h" + +class TClonesArray; +class TParticle; +class AliJFPreCluster; +class AliJFCluster; +class AliJFClusterDifference; +class AliJFKtJet; +//class multiset; +class AliJFKtJetFinder : public AliJFJetFinder +{ + public: + AliJFKtJetFinder(Int_t n=50); + virtual ~AliJFKtJetFinder(); + + Int_t Init(TClonesArray *particles); + Int_t Run(); + + Bool_t IsAcceptedParticle(TParticle *p); + //Bool_t IsAcceptedTower(JFTower*); + + void Debug(); + void Clean(); + + protected: + vector fPreClusterList; //! + vector fClusterList; //! + multiset fClusterDiffSet; //! + + AliJFKtJet *fJet; //! + + ClassDef(AliJFKtJetFinder,1) //AliJFKtJetFinder class +}; + +#endif /*ALIJFKTJETFINDERH*/ diff --git a/JETAN/AliJFMCJet.cxx b/JETAN/AliJFMCJet.cxx new file mode 100644 index 00000000000..69e9359c8b7 --- /dev/null +++ b/JETAN/AliJFMCJet.cxx @@ -0,0 +1,95 @@ +// $Id$ + +#include + +#include +#include +#include +#include + +#include "AliJFMCJet.h" + +ClassImp(AliJFMCJet) + +AliJFMCJet::AliJFMCJet(Int_t n) : AliJFJet(n) +{ +} + +AliJFMCJet::~AliJFMCJet() +{ + Clean(); +} + +void AliJFMCJet::AddParticle(TParticle *p) +{ + if(!p) return; + + new(fParticles[fN]) TParticle(*p); + fN++; + fIsUpdated=kFALSE; +} + +void AliJFMCJet::Clean() +{ + fParticles.Delete(); +} + +void AliJFMCJet::Update() +{ + if(fIsUpdated) return; + + fIsUpdated=kTRUE; + + fPhi=0; + fEta=0; + fY=0; + fPt=0; + fPx=0; + fPy=0; + fPz=0; + fE=0; + fE_=0; + + // Float_t fMaxParticlePt=0; + + TIterator *iter=fParticles.MakeIterator(); + TParticle *p; + + while((p=(TParticle*)iter->Next()) != NULL){ + + Float_t px=p->Px(); + Float_t py=p->Py(); + Float_t pz=p->Pz(); + Float_t E=p->Energy(); + Float_t E_=TMath::Sqrt(px*px+py*py+pz*pz); //massless particles + // Float_t pt=p->Pt(); + + fPx+=px; + fPy+=py; + fPz+=pz; + fE+=E; + fE_+=E_; + /* to do: max particle, charge particle, etc. + if(pt>fMaxParticlePt){ + fMaxParticlePt=pt; + fMaxParticle=*p; + } + */ + } + + fPt=TMath::Sqrt(fPx*fPx+fPy*fPy); + fPhi=TMath::ATan(fPy/fPx); + fEta=0.5*TMath::Log((fE+fPz)/(fE-fPz)); + fY=0.5*TMath::Log((fE_+fPz)/(fE_-fPz)); +} + +void AliJFMCJet::Debug() +{ + TIterator *iter=fParticles.MakeIterator(); + TParticle *p; + + Int_t i=0; + while((p=(TParticle*)iter->Next()) != NULL){ + cout << i++ << ": " << p->Energy() << endl; + } +} diff --git a/JETAN/AliJFMCJet.h b/JETAN/AliJFMCJet.h new file mode 100644 index 00000000000..3b4522cd263 --- /dev/null +++ b/JETAN/AliJFMCJet.h @@ -0,0 +1,25 @@ +// $Id$ + +#ifndef ALIJFMCJETH +#define ALIJFMCJETH + +#include "AliJFJet.h" + +class AliJFMCJet : public AliJFJet +{ + public: + AliJFMCJet(Int_t n=250); + virtual ~AliJFMCJet(); + + void AddParticle(TParticle *p); + void Update(); + + void Debug(); + void Clean(); + + protected: + + ClassDef(AliJFMCJet,1) //AliJFMCJet class +}; + +#endif /*ALIJFMCJETH*/ diff --git a/JETAN/AliJFMCJetFinder.cxx b/JETAN/AliJFMCJetFinder.cxx new file mode 100644 index 00000000000..025be2ca968 --- /dev/null +++ b/JETAN/AliJFMCJetFinder.cxx @@ -0,0 +1,98 @@ +// $Id$ + +#include + +#include +#include +#include + +#include "AliJFMCJet.h" +#include "AliJFMCJetFinder.h" + +ClassImp(AliJFMCJetFinder) + +AliJFMCJetFinder::AliJFMCJetFinder(Int_t n) : AliJFJetFinder(n), fParticles(NULL), fJet(NULL) +{ +} + +AliJFMCJetFinder::~AliJFMCJetFinder() +{ + Clean(); +} + +Int_t AliJFMCJetFinder::Init(TClonesArray *particles) +{ + if(particles==NULL) return 0; + + fParticles=particles; + return fParticles->GetEntries(); +} + +Int_t AliJFMCJetFinder::Run() +{ + if(fParticles==NULL) return 0; + + TIterator *iter=fParticles->MakeIterator(); + TParticle *p; + + while((p=(TParticle*)iter->Next()) != NULL){ + if(p->GetPdgCode()==92){ + fJets.AddAt(new AliJFMCJet(),fNJets); + fJet=(AliJFMCJet*)fJets.At(fNJets); + fJet->SetNJet(++fNJets); + FollowDaughters(p->GetFirstDaughter(),p->GetLastDaughter()); + //cout << "Add new Jet " << fNJets << "with " << fJet->GetE() << " " << fJet->GetE_() << " " << fJet->GetNPart() << endl; + fJet->Update(); + } + } + + fJets.Sort(); + //fJets.Print(); + + return fNJets; +} + +void AliJFMCJetFinder::Debug() +{ + TIterator *iter=fJets.MakeIterator(); + AliJFMCJet *j; + + while((j=(AliJFMCJet*)iter->Next()) != NULL){ + j->Update(); + //cout << j << ": " << j->GetNPart() << " " << j->GetNJet() << " " << j->GetPtMax() << endl; + j->Print(""); + } + + /* + for(Int_t i=0;iAt(i); + cout << i << ": " << j->GetNPart()<< " " << j->GetNJet() << endl; + } + */ +} + +void AliJFMCJetFinder::FollowDaughters(Int_t first, Int_t last) +{ + if(lastAt(i); + if(p->GetStatusCode()!=1){ + FollowDaughters(p->GetFirstDaughter(),p->GetLastDaughter()); + } + else { + if(!IsAcceptedParticle(p)) continue; + + fJet->AddParticle(p); + //p->Print(); + } + } +} + +/* + void AliJFMCJetFinder::Clean() + { + } +*/ diff --git a/JETAN/AliJFMCJetFinder.h b/JETAN/AliJFMCJetFinder.h new file mode 100644 index 00000000000..c25d120656a --- /dev/null +++ b/JETAN/AliJFMCJetFinder.h @@ -0,0 +1,33 @@ +// $Id$ + +#ifndef ALIJFMCJETFINDERH +#define ALIJFMCJETFINDERH + +#include "AliJFJetFinder.h" +#include +class TClonesArray; +class TParticle; +class AliJFMCJet; + +class AliJFMCJetFinder : public AliJFJetFinder +{ + public: + AliJFMCJetFinder(Int_t n=25); + virtual ~AliJFMCJetFinder(); + + Int_t Init(TClonesArray *particles); + Int_t Run(); + + void Debug(); + //void Clean(); + + protected: + void FollowDaughters(Int_t first, Int_t last); + + TClonesArray *fParticles; //! + AliJFMCJet *fJet; //! + + ClassDef(AliJFMCJetFinder,1) //AliJFMCJetFinder class +}; + +#endif /*ALIJFMCJETFINDERH*/ diff --git a/JETAN/AliJFMixEvent.cxx b/JETAN/AliJFMixEvent.cxx new file mode 100644 index 00000000000..3e90ad14ac7 --- /dev/null +++ b/JETAN/AliJFMixEvent.cxx @@ -0,0 +1,253 @@ +// $Id$ + +#include + +#include +#include +#include +#include +#include + +#include "AliJFMixEvent.h" + +AliJFMixEvent::AliJFMixEvent(Char_t *file1, Char_t *file2) : + fStatus(-1),fEvent1(-1),fEvent2(-1),fMaxEvent1(-1),fMaxEvent2(-1), + fMarkPythia(0),fTree1(0),fTree2(0),fFile1(0), + fFile2(0),fBranch1(0),fBranch2(0), + fParticles1(0),fParticles2(0),fMixedParticles(0) +{ + Init(file1,file2); +} + +AliJFMixEvent::AliJFMixEvent(Char_t *files1, Char_t *tname1, Char_t *files2=0, Char_t *tname2=0) : + fStatus(-1),fEvent1(-1),fEvent2(-1),fMaxEvent1(-1),fMaxEvent2(-1), + fMarkPythia(0),fTree1(0),fTree2(0),fFile1(0), + fFile2(0),fBranch1(0),fBranch2(0), + fParticles1(0),fParticles2(0),fMixedParticles(0) +{ + InitChains(files1,tname1,files2,tname2); +} + +AliJFMixEvent::~AliJFMixEvent() +{ + Clean(); +} + +void AliJFMixEvent::Init(Char_t *file1, Char_t *file2) +{ + Clean(); + + if (!file1) { + cerr << "Error AliJFMixEvent:: Must give at least one filename!" << endl; + return; + } + + fFile1 = NULL; + fFile1 = new TFile(file1,"READ"); + if (!fFile1 || !(fFile1->IsOpen())) { + cerr << "Error AliJFMixEvent:: Couldn't open input file " << file1 << endl; + return; + } + + fFile2 = NULL; + if(file2!=0){ + fFile2 = new TFile(file2,"READ"); + if (!fFile2 || !(fFile2->IsOpen())) { + cerr << "Error AliJFMixEvent:: Couldn't open input file " << file2 << endl; + return; + } + } + + Int_t prealloc1=100000; + fTree1 = NULL; + fTree1 = (TTree *)fFile1->Get("hijing"); + if (!fTree1){ + fTree1 = (TTree *)fFile1->Get("pythia"); + prealloc1=10000; + } + if (!fTree1) { + cerr << "Error AliJFMixEvent:: Didn't find a TParticle tree for " << file1 << endl; + return; + } + fMaxEvent1=(Int_t)fTree1->GetEntries(); + + Int_t prealloc2=0; + fTree2 = NULL; + if(file2!=0){ + prealloc2=100000; + fTree2 = (TTree *)fFile2->Get("hijing"); + if (!fTree2){ + fTree2 = (TTree *)fFile2->Get("pythia"); + prealloc2=10000; + } + if (!fTree2) { + cerr << "Error AliJFMixEvent:: Didn't find a TParticle tree for " << file2 << endl; + return; + } + fMaxEvent2=(Int_t)fTree2->GetEntries(); + } + + fParticles1=new TClonesArray("TParticle",prealloc1); + if(file2!=0) fParticles2=new TClonesArray("TParticle",prealloc2); + fMixedParticles=new TClonesArray("TParticle",prealloc1+prealloc2); + + fBranch1=fTree1->GetBranch("particles"); + fBranch1->SetAddress(&fParticles1); + + if(file2!=0){ + fBranch2=fTree2->GetBranch("particles"); + fBranch2->SetAddress(&fParticles2); + } + + fStatus=0; +} + +void AliJFMixEvent::InitChains(Char_t *files1, Char_t *tname1, Char_t *files2, Char_t *tname2) +{ + Clean(); + + if (!files1 || !tname1) { + cerr << "Error AliJFMixEvent:: Must give at least one file/tree name!" << endl; + return; + } + + Int_t prealloc1=100000; + Int_t prealloc2=0; + + fTree1=new TChain(tname1); + ((TChain*)fTree1)->Add(files1); + fParticles1=new TClonesArray("TParticle",prealloc1); + fTree1->SetBranchAddress("particles",&fParticles1); + fMaxEvent1=(Int_t)fTree1->GetEntries(); + + if (files2 && tname2) { + prealloc2=100000; + fTree2=new TChain(tname2); + ((TChain*)fTree2)->Add(files2); + fParticles2=new TClonesArray("TParticle",prealloc2); + fTree2->SetBranchAddress("particles",&fParticles2); + fMaxEvent2=(Int_t)fTree2->GetEntries(); + } + + fMixedParticles=new TClonesArray("TParticle",prealloc1+prealloc2); + fStatus=0; +} + +void AliJFMixEvent::Clean() +{ + fStatus=-1; //not initialized! + + fEvent1=-1; + fEvent2=-1; + fMaxEvent1=-1; + fMaxEvent2=-1; + + if(fParticles1) delete fParticles1; + fParticles1=NULL; + + if(fParticles2) delete fParticles2; + fParticles2=NULL; + + if(fMixedParticles) delete fMixedParticles; + fMixedParticles=NULL; + + if(fTree1) delete fTree1; + fTree1=NULL; + + if(fTree2) delete fTree2; + fTree2=NULL; + + if(fFile1) delete fFile1; + fFile1=NULL; + + if(fFile2) delete fFile2; + fFile2=NULL; +} + +Int_t AliJFMixEvent::CreateMixedEvent(Int_t i,Int_t j) +{ + if(fStatus<0) return -1; + if(i<0 || j<0) return -1; + if((i>=fMaxEvent1)||((fTree2)&&(j>=fMaxEvent2))) return -1; + + if(fEvent1!=i){ + fTree1->GetEvent(i); + fEvent1=i; + } + + if(fTree2){ + if(fEvent2!=j){ + fTree2->GetEvent(j); + fEvent2=j; + } + } + return MixEvent(); +} + +Int_t AliJFMixEvent::CreateNextMixedEvent() +{ + if(fStatus<0) return -1; + + if(fStatus==0) { //load first data samples + fEvent1=0; + fTree1->GetEvent(0); + fEvent2=0; + if(fTree2) fTree2->GetEvent(0); + } else { //continue loading + fEvent1++; + if(fEvent1==fMaxEvent1){ + fEvent1=0; + + if(fTree2){ + fEvent2++; + if(fEvent2==fMaxEvent2) + fEvent2=0; + fTree2->GetEvent(fEvent2); + } + } + + fTree1->GetEvent(fEvent1); + } + + return MixEvent(); +} + +Int_t AliJFMixEvent::MixEvent() +{ + Int_t n1=fParticles1->GetEntries(); + Int_t n2=0; + if(fTree2) n2=fParticles2->GetEntries(); + + fMixedParticles->ExpandCreateFast(n1+n2); + Int_t n=0; + TParticle *particle; + TIterator *i=fParticles1->MakeIterator(); + while ((particle = (TParticle *) i->Next()) != NULL) { + if(fMarkPythia){ + particle->SetWeight(-123); //mark pythia particles + } + new ((*fMixedParticles)[n]) TParticle(*particle); + n++; + } + if(fTree2){ + i=fParticles2->MakeIterator(); + while ((particle = (TParticle *) i->Next()) != NULL) { + new((*fMixedParticles)[n]) TParticle(*particle); + n++; + } + } + fStatus++; + + return n; +} + +void AliJFMixEvent::Debug() +{ + if(!fMixedParticles) return; + + TParticle *p; + TIterator *iter=fMixedParticles->MakeIterator(); + while ((p = (TParticle *) iter->Next()) != NULL) { + p->Print(); + } +} diff --git a/JETAN/AliJFMixEvent.h b/JETAN/AliJFMixEvent.h new file mode 100644 index 00000000000..fa38de0a24b --- /dev/null +++ b/JETAN/AliJFMixEvent.h @@ -0,0 +1,68 @@ +#ifndef ALIJFMIXEVENTH +#define ALIJFMIXEVENTH + +#include + +class TTree; +class TBranch; +class TBranch; +class TFile; +class TClonesArray; + +class AliJFMixEvent +{ + public: + AliJFMixEvent(Char_t *file1, Char_t *file2=0); + AliJFMixEvent(Char_t *files1, Char_t *tname1, Char_t *files2, Char_t *tname2); + virtual ~AliJFMixEvent(); + + void Init(Char_t *file1, Char_t *file2=0); + void InitChains(Char_t *files1, Char_t *tname1, Char_t *files2=0, Char_t *tname2=0); + void Clean(); + + Int_t CreateNextMixedEvent(); + Int_t CreateMixedEvent(Int_t i=0,Int_t j=0); + + TClonesArray* const GetMixedParticles() {return fMixedParticles;} + TClonesArray* const GetParticles () {return fParticles1;} + TClonesArray* const GetParticles2() {return fParticles2;} + + Int_t const GetCurNEvent1() const {return fEvent1;} + Int_t const GetCurNEvent2() const {return fEvent2;} + Int_t const GetMaxNEvent1() const {return fMaxEvent1;} + Int_t const GetMaxNEvent2() const {return fMaxEvent2;} + Int_t const GetStatus() const {return fStatus;} + + void Debug(); + void SetMarkPythia(Bool_t b){fMarkPythia=b;} + + protected: + Int_t MixEvent(); + + Int_t fStatus; //positive if initialized + + Int_t fEvent1; + Int_t fEvent2; + Int_t fMaxEvent1; + Int_t fMaxEvent2; + + Bool_t fMarkPythia; //true if pythia particles + //will be marked + + TTree *fTree1; //! + TTree *fTree2; //! + + TFile *fFile1; //! + TFile *fFile2; //! + + TBranch *fBranch1; //! + TBranch *fBranch2; //! + + TClonesArray *fParticles1; //! + TClonesArray *fParticles2; //! + TClonesArray *fMixedParticles; //! + + ClassDef(AliJFMixEvent,1) //AliJFMixEvent class +}; + +#endif /*ALIJFMIXEVENTH*/ diff --git a/JETAN/AliJFParticlesCut.cxx b/JETAN/AliJFParticlesCut.cxx new file mode 100644 index 00000000000..bc932fde0d2 --- /dev/null +++ b/JETAN/AliJFParticlesCut.cxx @@ -0,0 +1,106 @@ +// $Id$ + +#include + +#include +#include +#include + +#include "AliJFParticlesCut.h" + + +AliJFParticlesCut::AliJFParticlesCut(TClonesArray *p) + : fPtMin(0),fPtMax(1000), + fEtaMin(-1),fEtaMax(1), + fPhiMin(0),fPhiMax(2*TMath::Pi()), + fNeutral(kTRUE),fCharged(kTRUE),fEM(kTRUE), + fParts(0) +{ + SetParticles(p); +} + +Int_t AliJFParticlesCut::Cut() +{ + if(fParts==0) return -1; + + Int_t n=0; + TParticle *particle; + TIterator *iter = fParts->MakeIterator(); + while ((particle = (TParticle *) iter->Next()) != NULL) { + if(IsAcceptedParticle(particle)) n++; + else fParts->Remove(particle); + } //end loop particles + + delete iter; + return n; +} + +Int_t AliJFParticlesCut::Cut(TClonesArray *p) +{ + SetParticles(p); + return Cut(); +} + +TH2F* AliJFParticlesCut::CreateHistogram(Char_t *title,Char_t *text,Int_t phibins,Int_t etabins) +{ + if(fParts==0) return 0; + + TH2F *h=new TH2F(title,text,etabins,fEtaMin,fEtaMax,phibins,fPhiMin,fPhiMax); + TParticle *particle; + TIterator *iter = fParts->MakeIterator(); + while ((particle = (TParticle *) iter->Next()) != NULL) { + if(IsAcceptedParticle(particle)){ + h->Fill(particle->Eta(),particle->Phi(),particle->Pt()); + } + } //end loop particles + + //h->GetZaxis()->SetTitle("Pt"); + return h; +} + +Bool_t AliJFParticlesCut::IsAcceptedParticle(TParticle *p) +{ +#ifndef ALICEINTERFACE + if(p->GetStatusCode()%100!=1) return kFALSE; +#endif + + Int_t pcode=p->GetPdgCode(); + + if ((pcode==11)||(pcode==-11)||(pcode==22)) { + if(!fEM) return kFALSE; + } else { + TParticlePDG *pdg=p->GetPDG(); + Float_t ch=pdg->Charge(); + if((!fCharged)&&(ch)) return kFALSE; + if((!fNeutral)&&(!ch)) return kFALSE; + } + + Float_t eta=p->Eta(); + if((etafEtaMax)) return kFALSE; + + Float_t phi=p->Phi(); + if((phifPhiMax)) return kFALSE; + + Float_t pt=p->Pt(); + if((ptfPtMax)) return kFALSE; + + return kTRUE; +} + +void AliJFParticlesCut::SetPtCut(Float_t ptmin, Float_t ptmax) +{ + fPtMin=ptmin; + fPtMax=ptmax; +} + +void AliJFParticlesCut::SetPhiCut(Float_t phimin, Float_t phimax) +{ + fPhiMin=phimin; + fPhiMax=phimax; +} + +void AliJFParticlesCut::SetEtaCut(Float_t emin, Float_t emax) +{ + fEtaMin=emin; + fEtaMax=emax; +} diff --git a/JETAN/AliJFParticlesCut.h b/JETAN/AliJFParticlesCut.h new file mode 100644 index 00000000000..57cdb554e85 --- /dev/null +++ b/JETAN/AliJFParticlesCut.h @@ -0,0 +1,54 @@ +// $Id$ + +#ifndef ALIJFPARTICLESCUTH +#define ALIJFPARTICLESCUTH + +#include + +class TParticle; +class TClonesArray; +class TH2F; + +class AliJFParticlesCut +{ + public: + AliJFParticlesCut(TClonesArray *p=0); + virtual ~AliJFParticlesCut(){}; + + void SetPtCut(Float_t ptmin=0, Float_t ptmax=1000); + void SetPhiCut(Float_t phi=2*TMath::Pi()){SetPhiCut(0,phi);} + void SetPhiCut(Float_t phimin, Float_t phimax); + void SetEtaCut(Float_t e=1){SetEtaCut(-e,e);} + void SetEtaCut(Float_t emin, Float_t emax); + void SetNeutral(Bool_t b=kTRUE){fNeutral=b;} + void SetCharged(Bool_t b=kTRUE){fCharged=b;} + void SetEM(Bool_t b=kTRUE){fEM=b;} + + void SetParticles(TClonesArray *p){fParts=p;} + TClonesArray* GetParticles(TClonesArray */*p*/){return fParts;} + + Int_t Cut(); + Int_t Cut(TClonesArray *p); + + TH2F* CreateHistogram(Char_t *title,Char_t *text,Int_t phibins=100,Int_t etabins=100); + + Bool_t IsAcceptedParticle(TParticle *p); + + protected: + Float_t fPtMin; + Float_t fPtMax; + Float_t fEtaMin; + Float_t fEtaMax; + Float_t fPhiMin; + Float_t fPhiMax; + Bool_t fNeutral; + Bool_t fCharged; + Bool_t fEM; + + TClonesArray *fParts; + + ClassDef(AliJFParticlesCut,1) //AliJFParticlesCut class + +}; + +#endif /*ALIJFPARTICLESCUTH*/ diff --git a/JETAN/AliJFPreCluster.cxx b/JETAN/AliJFPreCluster.cxx new file mode 100644 index 00000000000..e25404458c0 --- /dev/null +++ b/JETAN/AliJFPreCluster.cxx @@ -0,0 +1,89 @@ +// $Id$ + +#include + +#include +#include + +#include "AliJFPreCluster.h" + +ClassImp(AliJFPreCluster) + +AliJFPreCluster::AliJFPreCluster() : fPx(0),fPy(0),fPz(0),fE(0),fParticles("TParticle",0) +{ +} + +AliJFPreCluster::AliJFPreCluster(const AliJFPreCluster ©) : + fPx(0),fPy(0),fPz(0),fE(0),fParticles("TParticle",0) +{ + fPx=copy.GetPx(); + fPy=copy.GetPy(); + fPz=copy.GetPz(); + fE=copy.GetE(); + fParticles.Expand(copy.GetParticles()->GetEntries()); + fParticles.AddAll((TClonesArray*)copy.GetParticles()); +} + +AliJFPreCluster::AliJFPreCluster(const TParticle *p) : + fPx(0),fPy(0),fPz(0),fE(0),fParticles("TParticle",0) +{ + fPx=p->Px(); + fPy=p->Py(); + fPz=p->Pz(); + fE=p->Energy(); + fParticles.Expand(1); + fParticles[0]=new TParticle(*p); +} + +AliJFPreCluster::AliJFPreCluster(Float_t px, Float_t py, Float_t pz, Float_t E, const TParticle *p) : + fPx(px),fPy(py),fPz(pz),fE(E),fParticles("TParticle",0) +{ + if(fE<0) fE=TMath::Sqrt(fPx*fPx+fPy*fPy+fPz*fPz); + fParticles.Expand(1); + fParticles[0]=new TParticle(*p); +} + +AliJFPreCluster::AliJFPreCluster(Float_t px, Float_t py, Float_t pz, Float_t E, TClonesArray *parts) : + fPx(px),fPy(py),fPz(pz),fE(E),fParticles("TParticle",0) +{ + if(fE<0) fE=TMath::Sqrt(fPx*fPx+fPy*fPy+fPz*fPz); + fParticles.Expand(parts->GetEntries()); + fParticles.AddAll(parts); +} + +AliJFPreCluster::~AliJFPreCluster() +{ + fParticles.Delete(); +} + +AliJFPreCluster& AliJFPreCluster::operator=(const AliJFPreCluster &rhs) +{ + fPx=rhs.GetPx(); + fPy=rhs.GetPy(); + fPz=rhs.GetPz(); + fE=rhs.GetE(); + fParticles.Delete(); + fParticles.Expand(rhs.GetParticles()->GetEntries()); + fParticles.AddAll((TClonesArray*)rhs.GetParticles()); + + return *this; +} + +ostream& operator<<(ostream& o, const AliJFPreCluster &c) +{ + o << c.GetPx() << " " << c.GetPy() << " " << c.GetPz() << " " << c.GetE(); + + return o; +} + +/* +void AliJFPreCluster::SetValues(Float_t px, Float_t py, Float_t pz, Float_t E) +{ + fPx=px; + fPy=py; + fPz=pz; + fE=E; + + if(fE<0) fE=TMath::Sqrt(fPx*fPx+fPy+fPy+fPz*fPz); +} +*/ diff --git a/JETAN/AliJFPreCluster.h b/JETAN/AliJFPreCluster.h new file mode 100644 index 00000000000..0901c1d0a07 --- /dev/null +++ b/JETAN/AliJFPreCluster.h @@ -0,0 +1,45 @@ +// $Id$ + +#ifndef ALIJFPRECLUSTERH +#define ALIJFPRECLUSTERH + + +#include + +class TParticle; + +class AliJFPreCluster +{ + public: + AliJFPreCluster(); + AliJFPreCluster(const AliJFPreCluster ©); + AliJFPreCluster(const TParticle *p); + AliJFPreCluster(Float_t px, Float_t py, Float_t pz, Float_t E, const TParticle *p); + AliJFPreCluster(Float_t px, Float_t py, Float_t pz, Float_t E, TClonesArray *parts); + virtual ~AliJFPreCluster(); + + AliJFPreCluster& operator=(const AliJFPreCluster &rhs); + friend ostream& operator<< (ostream &o, const AliJFPreCluster &c); + + inline Float_t const GetPx() const {return fPx ;} + inline Float_t const GetPy() const {return fPy ;} + inline Float_t const GetPz() const {return fPz ;} + inline Float_t const GetE() const {return fE ;} + + inline const TClonesArray* GetParticles() const {return &fParticles;} + TClonesArray* GetParticles() {return &fParticles;} + + protected: + //void SetValues(Float_t px, Float_t py, Float_t pz, Float_t E=-1); + + Float_t fPx; + Float_t fPy; + Float_t fPz; + Float_t fE; + + TClonesArray fParticles; + + ClassDef(AliJFPreCluster,1) //AliJFPreCluster class +}; + +#endif /*ALIJFPRECLUSTERH*/ diff --git a/JETAN/AliJFTower.cxx b/JETAN/AliJFTower.cxx new file mode 100644 index 00000000000..10f7a8471b8 --- /dev/null +++ b/JETAN/AliJFTower.cxx @@ -0,0 +1,8 @@ +// $Id$ + +#include "AliJFTower.h" + +ClassImp(AliJFTower) + + + diff --git a/JETAN/AliJFTower.h b/JETAN/AliJFTower.h new file mode 100644 index 00000000000..11aec785861 --- /dev/null +++ b/JETAN/AliJFTower.h @@ -0,0 +1,156 @@ +// $Id$ + +#ifndef ALIJFTOWERH +#define ALIJFTOWERH + +#include + +class AliJFTower +{ + public: + AliJFTower(){}; + virtual ~AliJFTower(){}; + + /* + AliJFTower(const tower& t); + AliJFTower(Float_t phimin, Float_t phimax, Float_t etamin, Float_t etamax); + + AliJFTower& operator+=(const Float_t E); + */ + + protected: + Float_t fEtaMin; + Float_t fEtaMax; + Float_t fEtaCenter; + Float_t fPhiMin; + Float_t fPhiMax; + Float_t fPhiCenter; + Float_t fEt; + + ClassDef(AliJFTower,1) +}; + +#endif /*JFTOWERH*/ + +#if 0 +// includes +#include "TROOT.h" +#include "TClonesArray.h" +#include "TParticle.h" +#include "TH2.h" +#include "TCanvas.h" +#include "TFile.h" + +#include +#include +#include + +// classes +class tower { + public: + tower(); + tower(const tower& t); + tower(Float_t phimin, Float_t phimax, Float_t etamin, Float_t etamax); + Float_t eta_min; + Float_t eta_max; + Float_t eta_center; + Float_t phi_min; + Float_t phi_max; + Float_t phi_center; + Float_t Et; + tower& operator+=(const Float_t E); +}; + +ostream& operator<<(ostream& s,const tower& t); + +class seedpoint { + public: + Float_t eta; + Float_t phi; +}; + +ostream& operator<<(ostream& s,const seedpoint& t); + +class protojet { + public: + protojet() { eta = -999; phi = -999; Et = -999; } + protojet(const protojet& p) { eta=p.eta; phi=p.phi; Et=p.Et; } + protojet(const protojet * p) { eta=p->eta; phi=p->phi; Et=p->Et; } + Float_t eta; + Float_t phi; + Float_t Et; + bool operator<(const protojet &p1) const {return (Et < p1.Et);} + bool operator==(const protojet &p1); +}; + +ostream& operator<<(ostream& s,const protojet& p); + +class TkConeJetFinderV2 : public TObject { + public: + // some test stuff - I delete it later... + void test(); + void testAddTowers(); + void testAddProtojet(); + void testAssocProtojetTower(); + + // constructor + TkConeJetFinderV2() : TObject() {} + + // run control + void defaultSettings(); + void init(); + void initEvent(TClonesArray *particles,Int_t type = 1); + void run(); + void finishEvent(); + void finish(); + + // real physics functions... + void createTowers(Int_t nPhiTower,Float_t phiMin,Float_t phiMax, + Int_t nEtaTower,Float_t etaMin,Float_t etaMax); + void fillTowersFromTParticles(TClonesArray *particles); + void createSeedPoints(Float_t EtCut); + void findProtojets(Float_t radius); + void findJets(); + + // analysis functions... + void createHistos(); + void createEventHistos(); + void clearEventHistos(); + void writeEventHistos(); + void writeHistos(); + + protected: + private: + // containers to save info... + vector *towers; + Int_t mEtaBins; + Float_t mEtaMin; + Float_t mEtaMax; + Float_t mEtaWidth; + Int_t mPhiBins; + Float_t mPhiMin; + Float_t mPhiMax; + Float_t mPhiWidth; + + //vector::iterator + Int_t findTower(Float_t phi, Float_t eta); + Bool_t isTParticleAccepted(TParticle *particle); + + list seedPoints; + Float_t mEtCut; + + list protojets; + + multimap assocTowers; + list jets; + + TObjArray mHistos; + TObjArray mEventHistos; + TFile *histFile; + void fillTowerHist(); + + ClassDef(TkConeJetFinderV2,1) +}; +#endif + + diff --git a/JETAN/AliJetParticlesReader.cxx b/JETAN/AliJetParticlesReader.cxx index 321d9ce4b43..3d6702a2ce2 100644 --- a/JETAN/AliJetParticlesReader.cxx +++ b/JETAN/AliJetParticlesReader.cxx @@ -83,7 +83,7 @@ Int_t AliJetParticlesReader::Next() //here we have event if(fTree && fEventParticles){ if(fNewTree){ - fTree->Branch("particles","AliJetEventParticles",&fEventParticles,32000,1); + fTree->Branch("particles","AliJetEventParticles",&fEventParticles,32000,99); fNewTree=0; } fEventParticles->SetEventNr(fCurrentDir*1000+fCurrentEvent); diff --git a/JETAN/AliJetParticlesReaderESD.cxx b/JETAN/AliJetParticlesReaderESD.cxx index bb0d9d5a4fa..2a6351187ef 100644 --- a/JETAN/AliJetParticlesReaderESD.cxx +++ b/JETAN/AliJetParticlesReaderESD.cxx @@ -324,7 +324,7 @@ void AliJetParticlesReaderESD::PrintESDtrack(const AliESDtrack *kesdtrack) const if((status & AliESDtrack::kTRDout) == AliESDtrack::kTRDout) cout << "TRDout "; if((status & AliESDtrack::kTRDrefit) == AliESDtrack::kTRDrefit) cout << "TRDrefit "; if((status & AliESDtrack::kTRDpid) == AliESDtrack::kTRDpid) cout << "TRDpid "; - if((status & AliESDtrack::kTRDbackup) == AliESDtrack::kTRDbackup) cout << "TRDbackup "; + // if((status & AliESDtrack::kTRDbackup) == AliESDtrack::kTRDbackup) cout << "TRDbackup "; if((status & AliESDtrack::kTRDStop) == AliESDtrack::kTRDStop) cout << "TRDstop "; if((status & AliESDtrack::kTOFin) == AliESDtrack::kTOFin) cout << "TOFin "; diff --git a/JETAN/AliJetParticlesReaderHLT.cxx b/JETAN/AliJetParticlesReaderHLT.cxx index ad15bfd761c..46b22a522c3 100644 --- a/JETAN/AliJetParticlesReaderHLT.cxx +++ b/JETAN/AliJetParticlesReaderHLT.cxx @@ -18,7 +18,6 @@ #include #include #include -#include #include #include #include @@ -149,17 +148,11 @@ Int_t AliJetParticlesReaderHLT::ReadESD(AliESD* esd) if(0&&fTrackerType){ #if 0 //kesdtrack->SetCharge(-kesdtrack->GetCharge()); - try { Double_t mom[3]; - AliL3ITStrack l3(*kesdtrack,0); - if(!l3.GetPxPyPzAt(0,mom)) continue; + if(!kesdtrack->GetPxPyPzAt(0,mom)) continue; px=mom[0]; py=mom[1]; pz=mom[2]; - } catch (const Char_t *msg) { - //Warning("Clusters2Tracks",msg); - continue; - } #else AliL3Track l3; //if(!kesdtrack->ComesFromMainVertex()) continue; diff --git a/JETAN/AliTkChargedJet.cxx b/JETAN/AliTkChargedJet.cxx new file mode 100644 index 00000000000..c33ea228e1b --- /dev/null +++ b/JETAN/AliTkChargedJet.cxx @@ -0,0 +1,86 @@ +// $Id$ + +#include +#include +#include +#include + +#include "AliTkChargedJet.h" + +//------------------------------------------------------------------------- +// implemenatation of AliTkChargedJet +//------------------------------------------------------------------------- +ClassImp(AliTkChargedJet) + +AliTkChargedJet::AliTkChargedJet() : TObject() +{ + fEta=-999; + fPhi=-999; + fPt=-999; + fParticles=new TClonesArray("TParticle",1000); +} + +AliTkChargedJet::AliTkChargedJet(jet j) : TObject() +{ + // save center of the jet (eg. of seed particle) + AliTkEtaPhiVector center = j.getCentroid(); + fEta = center.Eta(); + fPhi = center.Phi(); + fPt = j.getPt(); + fNParticles = j.getNParticles(); + + fParticles = j.getParticles(); + if (fParticles->GetEntries() != j.getNParticles()) { + cerr << "AliTkChargedJet: cannot happen!" << endl; + } +} + +AliTkChargedJet::~AliTkChargedJet() +{ + if(fParticles) { + fParticles->Clear(); + delete fParticles; + } +} + +Float_t AliTkChargedJet::getPtInRadius(Float_t r) const +{ + Float_t pt = 0.0; + Float_t rSq = r*r; + AliTkEtaPhiVector center(this->getEta(), this->getPhi()); + TIterator *iter = this->fParticles->MakeIterator(); + TParticle *particle; + while ((particle = (TParticle *) iter->Next()) != NULL) { + AliTkEtaPhiVector v(particle->Eta(),particle->Phi()); + if (center.diffSq(v) < rSq) { + pt += particle->Pt(); + } + } + return pt; +} + +Int_t AliTkChargedJet::getParticlesInRadius(Float_t r) const +{ + Int_t part = 0; + Float_t rSq = r*r; + AliTkEtaPhiVector center(this->getEta(), this->getPhi()); + TIterator *iter = this->fParticles->MakeIterator(); + TParticle *particle; + while ((particle = (TParticle *) iter->Next()) != NULL) { + AliTkEtaPhiVector v(particle->Eta(),particle->Phi()); + if (center.diffSq(v) < rSq) { + part ++; + } + } + return part; +} + +Int_t AliTkChargedJet::getNChargedInRadius(Float_t /*r*/) const +{ + return -1; +} + +Int_t AliTkChargedJet::getNNeutralInRadius(Float_t /*r*/) const +{ + return -1; +} diff --git a/JETAN/AliTkChargedJet.h b/JETAN/AliTkChargedJet.h new file mode 100644 index 00000000000..228e446c934 --- /dev/null +++ b/JETAN/AliTkChargedJet.h @@ -0,0 +1,43 @@ +// $Id$ + +#ifndef ALITKCHARGEDJET_H +#define ALITKCHARGEDJET_H + +#include +#include +#include +#include "AliTkChargedJetFinder.h" + +class TClonesArray; +class TParticle; + +class AliTkChargedJet : public TObject { + + public: + AliTkChargedJet(); + AliTkChargedJet(jet); + ~AliTkChargedJet(); + + Float_t getEta() const { return fEta; } + Float_t getPhi() const { return fPhi; } + Float_t getPt() const { return fPt; } + Int_t getNParticles() const { return fNParticles; } + + TClonesArray *getParticles() const { return fParticles; } + + Float_t getPtInRadius(Float_t r) const; + Int_t getParticlesInRadius(Float_t r) const; + Int_t getNChargedInRadius(Float_t r) const; + Int_t getNNeutralInRadius(Float_t r) const; + + private: + + Float_t fEta; + Float_t fPhi; + Float_t fPt; + Int_t fNParticles; + TClonesArray *fParticles; //-> + + ClassDef(AliTkChargedJet,1) +}; +#endif diff --git a/JETAN/AliTkChargedJetFinder.cxx b/JETAN/AliTkChargedJetFinder.cxx new file mode 100644 index 00000000000..df50dcc8791 --- /dev/null +++ b/JETAN/AliTkChargedJetFinder.cxx @@ -0,0 +1,589 @@ +// $Id$ +//-------------------------------------------------------------------------- +// AliTkChargedJetFinder.cxx +// implementation of a simple jet finder for charged particles +// based on CDF PRD 65, 092002 (2002) +// T. Kollegger 10/12/2002 +//-------------------------------------------------------------------------- + +#include +//----------------------------------------------------------------------- +// STL includes +#include +#include +//----------------------------------------------------------------------- +// ROOT includes +#include +#include +#include +#include +#include +#include +#include +//-------------------------------------------------------------------------- +#include "AliTkEtaPhiVector.h" +#ifdef DOCHAERGED +#include "TkChargedJet.h" +#else +#include "AliTkConeJet.h" +#include "AliTkConeJetEvent.h" +#include "AliTkTowerV2.h" +#endif +//-------------------------------------------------------------------------- +#ifdef ALICEINTERFACE +#include +#include +#include +#endif +//------------------------------------------------------------------------- +#include "AliTkChargedJetFinder.h" + +//------------------------------------------------------------------------ +// implementation of the jet helper class +//------------------------------------------------------------------------ + +jet::jet(){ + fPt=-999; + fEta=-999; + fPhi=-999; + fNParticles=0; +} + +AliTkEtaPhiVector jet::getCentroid() const +{ + return AliTkEtaPhiVector(fEta,fPhi); +} + +void jet::addParticle(TParticle *particle) +{ + // add a particle to the jet + fParticles.push_back(particle); + if(fNParticles==0) { + fEta=particle->Eta(); + fPhi=particle->Phi(); + fPt=0; + } + fPt+=particle->Pt(); + fNParticles++; +} + +Double_t jet::getPt() const +{ +#if 1 + return fPt; +#else + // returns the pt of the jet + Double_t pt = 0.0; + + // loop over all particles which are assigned to the jet... + // and sum the pt of them + for(list::const_iterator i = particles.begin(); + i != particles.end(); ++i) { + TParticle *particle = *i; + pt += particle->Pt(); + } + + return pt; +#endif +} + +Int_t jet::getNParticles() const +{ + return fNParticles; +} + +TParticle *jet::getParticle(Int_t i) const +{ + if ((i < 0) || ((UInt_t)i > fParticles.size()-1)) { + cerr << "jet:: out of range" << i << endl; + return NULL; + } + list::const_iterator iter = fParticles.begin(); + for(Int_t pos = 0; pos < i+1; pos++) { + ++iter; + } + return (*iter); +} + +TClonesArray *jet::getParticles() const +{ + TClonesArray *parts = new TClonesArray("TParticle",this->getNParticles()); + Int_t i = 0; + for(list::const_iterator iter = fParticles.begin(); + iter != fParticles.end(); ++iter, i++) { + TParticle *particle = *iter; + if (particle == NULL) { + cerr << "jet: What's wrong? NULL pointer in particles" << endl; + continue; + } + new ((*parts)[i]) TParticle(*particle); + } + return parts; +} + +Double_t jet::getDiff(TParticle *particle) const +{ + // calculate the difference between jet center and particle in eta-phi space + return sqrt(getDiffSq(particle)); +} + +Double_t jet::getDiffSq(TParticle *particle) const +{ + // calculate the square of the difference between jet center + // and particle in eta-phi space + AliTkEtaPhiVector jetCenter = getCentroid(); + AliTkEtaPhiVector particlePos(particle->Eta(),particle->Phi()); + return jetCenter.diffSq(particlePos); +} + +ostream& operator<< (ostream& s,jet& j) +{ + return s << "jet: position " << j.getCentroid() + << " #particles=" << j.getNParticles() + << " pT=" << j.getPt(); +} + + +//------------------------------------------------------------------------ +// implementation of the jet finder class +//------------------------------------------------------------------------ + +ClassImp(AliTkChargedJetFinder) + +AliTkChargedJetFinder::AliTkChargedJetFinder() : TObject() +{ + fOutput=0; + fR=0; + fRSq=0; + fEtaMin=0; + fEtaMax=0; + fPtCut=0; + fPtSeed=0; + fMinJetPt=0; + +#ifdef DOCHARGED + fMyTJet=0; +#else + fEvoutevent=0; +#endif + +#ifdef DOHISTOS + // histograms... + fOutput_name=0; + fHistos=0; + fHistoutfile=0; +#endif + + fEvout_name=0; + fEvoutfile=0; + fEvouttree=0; + +#ifdef ALICEINTERFACE + fAliParticles=0; +#endif + + defaultSettings(); +} + +AliTkChargedJetFinder::~AliTkChargedJetFinder() +{ + if(fEvoutevent) delete fEvoutevent; + if(fEvoutfile) delete fEvoutfile; + if(fEvout_name) delete[] fEvout_name; +#ifdef ALICEINTERFACE + if(fAliParticles) delete fAliParticles; +#endif +#ifdef DOHISTOS + if(fHistos) delete fHistos; + if(fHistoutFile) delete fHistoutFile; + if(fOutput_name) delete[] fOutput_name; +#endif +} + +void AliTkChargedJetFinder::defaultSettings() +{ + // default settings for a first study... + // jet finder radius + setFinderR(0.7); + // lower bound of eta range + setEtaMin(-1); + // high bound of eta range + setEtaMax(1); + // seed value + setPtSeed(5); + // minimum jet value + setMinJetPt(5); + + fEvout_name=0; + setEvOutFilename("$JF_DATADIR/charged_jets.evout.root"); +#ifdef DOHISTOS + fOutput_name=0; + setHistFilename("$JF_DATADIR/charged_jets.hist.root"); +#endif +} + +void AliTkChargedJetFinder::init() +{ +#ifdef DOHISTOS + // initalization of the jet finder + fHistos = new TObjArray(10); + TH1F *hist = new TH1F("ncharged","charged tracks",31,-0.5,30.5); + hist->GetXaxis()->SetTitle("n_{charged} tracks"); + hist->GetYaxis()->SetTitle("entries"); + fHistos->Add(hist); + hist = new TH1F("jet_pt","jet p_{T}",100,0,100); + hist->GetXaxis()->SetTitle("p_{T} (GeV/c)"); + hist->GetYaxis()->SetTitle("entries"); + fHistos->Add(hist); + + // declare all histograms + if (fOutput_name) { + if(fOutput) cout << "Writing summary output to " << getHistFilename() << endl; + fHistoutfile = new TFile(getHistFilename(),"RECREATE"); + } +#endif + +#ifdef DOCHARGED + if (fEvout_name) { + if(fOutput) cout << "Writing event output to " << getEvOutFilename() << endl; + fEvoutfile = new TFile(getEvOutFilename(),"RECREATE"); + fMyTJet = new TkChargedJet(); + fEvouttree = new TTree("jets",""); + fEvouttree->Branch("jet","TkChargedJet",&(this->fMyTJet)); + } +#else + fEvoutfile = 0; + fEvouttree = 0; + fEvoutevent = new AliTkConeJetEvent(); + + if (getEvOutFilename()) { + if(fOutput) cout << "Writing finder output to " << getEvOutFilename() << endl; + fEvoutfile = new TFile(getEvOutFilename(),"RECREATE"); + fEvouttree = new TTree("jets","TKConeJetFinderV2 jets"); + fEvouttree->Branch("ConeFinder","AliTkConeJetEvent",&(this->fEvoutevent),32000,0); + } +#endif +} + +void AliTkChargedJetFinder::initEvent(TClonesArray *newParticles,Int_t type) +{ + // initalizes the jet finder for a new event +#ifndef DOCHARGED + if(fEvoutevent){ + fEvoutevent->Clear(); + fEvoutevent->setRadius(fR); + fEvoutevent->setEtCut(fPtSeed); + fEvoutevent->setPtCut(fPtCut); + fEvoutevent->setDesc(*new TString("AliTkChargedJetFinder")); + } +#endif + + // delete old particle list and old jets + fParticles.erase(fParticles.begin(),fParticles.end()); + fJets.erase(fJets.begin(),fJets.end()); + + TParticle *particle; + TIterator *iter = newParticles->MakeIterator(); +#ifdef testptr + list::const_iterator siter; +#endif + + // create new particle list + switch (type) { + case 1: + // TParticles in TClonesArray + while ((particle = (TParticle *) iter->Next()) != NULL) { + if (isTParticleAccepted(particle)) { + addParticle(particle); + } + } + if(fOutput) cout << "found particles for jets: " << fParticles.size() << endl; + break; + case 2: + cerr << "AliTkChargedJetFinder: don't know how to fill Et hist from TClonesArray with type " << type << endl; + ; + break; + } +#ifdef testptr + for (siter=particles.begin(); siter != particles.end(); ++siter) { + cout << "particle eta=" << (*siter)->Eta() + << " phi=" << (*siter)->Phi() + << " pT=" << (*siter)->Pt() + << " pointer=" << (*siter) + << endl; + } +#endif +} + +#ifdef ALICEINTERFACE +void AliTkChargedJetFinder::initEvent(const AliJetEventParticles *p,TString desc) +{ + if(fEvoutevent){ + fEvoutevent->Clear(); + fEvoutevent->setRadius(fR); + fEvoutevent->setEtCut(fPtSeed); + fEvoutevent->setPtCut(fPtCut); + fEvoutevent->setDesc(desc); + //fEvoutevent->setJetParticles(p); + } + + // delete old particle list and old jets + fParticles.erase(fParticles.begin(),fParticles.end()); + fJets.erase(fJets.begin(),fJets.end()); + + const TClonesArray *particles=p->GetParticles(); + if(fAliParticles) fAliParticles->Clear(); + else fAliParticles=new TClonesArray("TParticle",0); + fAliParticles->Expand(particles->GetEntriesFast()); + + // loop over all particles... + Int_t i=0; + AliJetParticle *aliparticle = NULL; + TIterator *iter = particles->MakeIterator(); + while ((aliparticle = (AliJetParticle *) iter->Next()) != NULL) { + Float_t pt=aliparticle->Pt(); + if(ptPx(),aliparticle->Py(), + aliparticle->Pz(),aliparticle->Energy(),0,0,0,0); + //mark particle (-123 for Pythia) + particle->SetWeight(aliparticle->GetType()); + //particle is accepted through reader + addParticle(particle); + i++; + } + delete iter; +} +#endif + +void AliTkChargedJetFinder::run() +{ + // loop over particles as long as there are + // some which are not assigned to a jet + if (fParticles.empty()) { + return; + } + + list::iterator iter; + while (!fParticles.empty()) { + // get particle with highest pT... + iter = fParticles.begin(); + if((*iter)->Pt()::iterator highjet = findHighestJet(); + if (highjet == NULL) { + cerr << "AliTkChargedJetFinder:: no jet found - no output! " << endl; + return; + } + if(fOutput) { + cout << "high jet ncharged=" << (*highjet).getNParticles() + << " pt=" << (*highjet).getPt() << endl; + cout << *highjet << endl; + } + +#ifdef DOHISTOS + // write out event histograms + if ((*highjet).getPt() > 30) { + ((TH1F *)fHistos->At(0))->Fill((*highjet).getNParticles()); + } + ((TH1F *)fHistos->At(1))->Fill((*highjet).getPt()); +#endif + + TkChargedJet *jet = new TkChargedJet(*highjet); + if ((fEvoutfile) && (fEvoutfile->IsOpen())) { + delete fMyTJet; + if (jet) { + fMyTJet = jet; + } else { + fMyTJet = new TkChargedJet(); + } + fEvoutfile->cd(); + fEvouttree->Fill(); + } +#else /******************************************************/ + if (fEvoutevent){ + AliTkConeJet *conejet = new AliTkConeJet(); + AliTkTowerV2 *myTower = new AliTkTowerV2(); + list::iterator iter; + for (iter = fJets.begin(); + iter != fJets.end(); ++iter) { + + Float_t jetet=(*iter).getPt(); + if(jetetClear(); + conejet->setEta((*iter).Eta()); + conejet->setPhi((*iter).Phi()); + conejet->setEt(jetet); + + myTower->Clear(); + myTower->setEta((*iter).Eta()); + myTower->setPhi((*iter).Phi()); + myTower->setEt(jetet); + myTower->setParticleList((*iter).getParticles()); + conejet->addTower(myTower); + conejet->calculateValues(); + fEvoutevent->addJet(conejet); + } + fEvoutevent->sortJets(); + fEvoutevent->Print(""); + if (fEvouttree) + fEvouttree->Fill(); + delete conejet; + delete myTower; + } +#endif +} + +void AliTkChargedJetFinder::finish() +{ +#ifdef DOHISTOS + // write out histograms + if ((fHistoutfile) && (fHistoutfile->IsOpen())) { + fHistoutfile->cd(); + ((TH1F *)fHistos->At(0))->Write(); + ((TH1F *)fHistos->At(1))->Write(); + fHistoutfile->Write(); + fHistoutfile->Close(); + } +#endif + if ((fEvoutfile) && (fEvoutfile->IsOpen())) { + fEvoutfile->cd(); + fEvouttree->Write(); +#ifdef DOHISTOS + ((TH1F *)fHistos->At(0))->Write(); +#endif + fEvoutfile->Write(); + fEvoutfile->Close(); + } +} + +void AliTkChargedJetFinder::setEvOutFilename(const Char_t *filename) +{ + if (!fEvout_name) { + fEvout_name = new Char_t[4096]; + } + strcpy(fEvout_name,filename); +} + +#ifdef DOHISTOS +void AliTkChargedJetFinder::setHistFilename(const Char_t *filename) +{ + if (!fOutput_name) { + fOutput_name = new Char_t[4096]; + } + strcpy(fOutput_name,filename); +} +#endif + +bool AliTkChargedJetFinder::isTParticleAccepted(TParticle *particle) +{ + // particle cuts... + + // check if particle is stable + if (particle->GetStatusCode() != 1) return false; + + // check for charge + TParticlePDG *partPDG; + partPDG = particle->GetPDG(); + if (partPDG->Charge() == 0) { + return false; + } + + // check eta range + if ((particle->Eta() < fEtaMin) || (particle->Eta() > fEtaMax)) { + return false; + } + + return true; +} + +void AliTkChargedJetFinder::addParticle(TParticle *particle) +{ + // add particle at right position + // first point to speed up program, use a sorted tree for example... + + // if first particle, store at beginning + if (fParticles.empty()) { + fParticles.push_front(particle); + return; + } + + // search insert position + list::iterator iter; + for (iter = fParticles.begin(); iter != fParticles.end(); ++iter) { + if ((*iter)->Pt() < particle->Pt()) { + fParticles.insert(iter,particle); + break; + } + } +} + +list::iterator AliTkChargedJetFinder::findHighestJet() +{ + list::iterator iter; + list::iterator high; + + if (fJets.empty()) { + return NULL; + } + + high = fJets.begin(); + for (iter = fJets.begin(); iter != fJets.end(); ++iter) { + //cout << *iter << endl; + if ((*iter).getPt() > (*high).getPt()) { + high = iter; + } + } + return high; +} + +void AliTkChargedJetFinder::checkJets() +{ + list::iterator i; + list::iterator j; + for (i = fJets.begin(); i != fJets.end(); ++i) { + for (j = i, ++j; j != fJets.end(); ++j) { + AliTkEtaPhiVector v1 = (*i).getCentroid(); + AliTkEtaPhiVector v2 = (*j).getCentroid(); + Double_t diff = v1.diff(v2); + if (diff < fR) { + cerr << "AliTkChargedJetFinder: Something is wrong - jets to close..." << endl; + cerr << v1 << " pt=" << (*i).getPt() << " -- " + << v2 << " pt=" << (*j).getPt() << endl; + } + } + } +} diff --git a/JETAN/AliTkChargedJetFinder.h b/JETAN/AliTkChargedJetFinder.h new file mode 100644 index 00000000000..9656c997774 --- /dev/null +++ b/JETAN/AliTkChargedJetFinder.h @@ -0,0 +1,167 @@ +// $Id$ + +#ifndef ALITKCHARGEDJETFINDER_H +#define ALITKCHARGEDJETFINDER_H + +//if defined use Torstens version +//#define DOCHARGED + +//if defined produce some debugging histos +#ifdef DOCHARGED +//#define DOHISTOS +#endif + +#include +#include +#include + +#include "AliTkEtaPhiVector.h" +#ifdef DOCHARGED +#include "TkChargedJet.h" +#else +#include "AliTkConeJetEvent.h" +#endif + +#ifdef ALICEINTERFACE +#include +#endif + +class TTree; +class TFile; +class TClonesArray; +class TParticle; +class TObjArray; + +//------------------------------------------------------------------------ +// Faster Helper Class (charged jets) +//------------------------------------------------------------------------- +class jet { + + public: + jet(); + + Float_t Eta() const {return fEta;} + Float_t Phi() const {return fPhi;} + AliTkEtaPhiVector getCentroid() const; + + Double_t getPt() const; + Int_t getNParticles() const; + TParticle *getParticle(Int_t i) const; + TClonesArray *getParticles() const; + Double_t getDiff(TParticle *particle) const; + Double_t getDiffSq(TParticle *particle) const; + + void addParticle(TParticle *particle); + friend ostream& operator<<(ostream& s, jet& j); + + private: + list fParticles; + Double_t fPt; + Double_t fEta; + Double_t fPhi; + Int_t fNParticles; +}; + +//------------------------------------------------------------------------ +// Finder Class (charged jets) +//------------------------------------------------------------------------- + +class AliTkChargedJetFinder : public TObject { + + public: + AliTkChargedJetFinder(); + virtual ~AliTkChargedJetFinder(); + + void defaultSettings(); + void setSettings(Int_t /*phibins*/,Int_t /*etabins*/) {;} + void init(); + void initEvent(TClonesArray *newParticles,Int_t type = 1); +#ifdef ALICEINTERFACE + void initEvent(const AliJetEventParticles *p,TString desc); +#endif + void run(); + void finishEvent(); + void finish(); + + void setEtMinJet(Float_t et) { fMinJetPt=et; } //minimum jet energy required + void setEtCut(Float_t et) { setPtSeed(et); } //min et for seedpoints + void setPtCut(Float_t pt) { fPtCut=pt; } //set pt cut + void setOutput(Bool_t out) { fOutput=out; } + void setRadius(Float_t r=0.7) { setFinderR(r); } + + void setFinderR(Float_t r) { fR=r;fRSq = r*r; } + Float_t getFinderR() const { return fR; } + void setEtaMin(Float_t eta) { fEtaMin = eta; } + Float_t getEtaMin() const { return fEtaMin; } + void setEtaMax(Float_t eta) { fEtaMax = eta; } + Float_t getEtaMax() const { return fEtaMax; } + void setPtSeed(Float_t s) { fPtSeed=s;} + Float_t getPtSeed() const { return fPtSeed; } + void setMinJetPt(Float_t s) { fMinJetPt=s;} + Float_t getMinJetPt() const { return fMinJetPt; } + + void setEvOutFilename(const Char_t *filename); + const Char_t *getEvOutFilename() { return fEvout_name; } +#ifdef DOHISTOS + void setHistFilename(const Char_t *filename); + const Char_t *getHistFilename() { return fOutput_name; } +#endif + + Bool_t getOutput() const {return fOutput;} + Int_t getNTowers() const {return 0;} + Int_t getNEtaBins() const {return 0;} + Float_t getEtaWidth() const {return 0;} + Int_t getPhiBins() const {return 0;} + Float_t getPhiMin() const {return 0;} + Float_t getPhiMax() const {return 2 * TMath::Pi();} + Float_t getPhiWidth() const {return 0;} + Float_t getEtCut() const {return fPtSeed;}; + Float_t getPtCut() const {return fPtCut;}; + Float_t getEtMinJet() const {return fMinJetPt;} + Float_t getRadius() const {return fR;} + + private: + Int_t fOutput; + list fParticles; //! + list fJets; //! + + // parameter for jetfinder + Float_t fR; + Float_t fRSq; + Float_t fEtaMin; + Float_t fEtaMax; + Float_t fPtCut; + Float_t fPtSeed; + Float_t fMinJetPt; + +#ifdef DOCHARGED + TkChargedJet *fMyTJet; //! +#else + AliTkConeJetEvent *fEvoutevent; //! +#endif + +#ifdef DOHISTOS + // histograms... + Char_t *fOutput_name; //! + TObjArray *fHistos; //! + TFile *fHistoutfile; //! +#endif + + Char_t *fEvout_name; //! + TFile *fEvoutfile; //! + TTree *fEvouttree; //! + +#ifdef ALICEINTERFACE + TClonesArray *fAliParticles; //! +#endif + + bool isTParticleAccepted(TParticle *particle); + void addParticle(TParticle *particle); + list::iterator findHighestJet(); + void checkJets(); + + ClassDef(AliTkChargedJetFinder,2) +}; +//------------------------------------------------------------------------- + +#endif diff --git a/JETAN/AliTkConeJet.cxx b/JETAN/AliTkConeJet.cxx new file mode 100644 index 00000000000..1e91b5cb025 --- /dev/null +++ b/JETAN/AliTkConeJet.cxx @@ -0,0 +1,626 @@ +//$Id$ + +#include +#include +#include +#include +#include + +#include "AliTkTowerV2.h" +#include "AliTkConeJet.h" + +#define Ntowers__ 100 + +AliTkConeJet::AliTkConeJet() : TObject(), + fEta(-999),fPhi(-999),fEt(-999),fType(0), + fNTowers(0),fTowers(0),fPtCut(0.), + fCEta(-999),fCPhi(-999),fCEt(-999), + fPLength(0.),fXAxis(0.),fYAxis(0.),fZAxis(0.), + fPtLead(0.),fLeadPart(0),fNParts(0),fParts(0) +{ + fTowers = new TClonesArray("AliTkTowerV2",Ntowers__); +} + +AliTkConeJet::AliTkConeJet(Float_t pt, Float_t eta, Float_t phi,Int_t type) + : TObject(), + fEta(eta),fPhi(phi),fEt(pt),fType(type), + fNTowers(0),fTowers(0),fPtCut(0.), + fCEta(eta),fCPhi(phi),fCEt(pt), + fPLength(0.),fXAxis(0.),fYAxis(0.),fZAxis(0.), + fPtLead(0.),fLeadPart(0),fNParts(0),fParts(0) +{ + fTowers = new TClonesArray("AliTkTowerV2",0); +} + +AliTkConeJet::AliTkConeJet(const AliTkConeJet &j) + : TObject(), + fEta(-999), fPhi(-999), fEt(-999),fType(0), + fNTowers(0),fTowers(0),fPtCut(0.), + fCEta(-999),fCPhi(-999),fCEt(-999), + fPLength(0.),fXAxis(0.),fYAxis(0.),fZAxis(0.), + fPtLead(0.),fLeadPart(0),fNParts(0),fParts(0) +{ + fEta = j.getEta(); + fPhi = j.getPhi(); + fEt = j.getEt(); + fCEta = j.getCEta(); + fCPhi = j.getCPhi(); + fCEt = j.getCEt(); + fNTowers = j.getNTowers(); + fPtCut = j.getPtCut(); + fCEta = j.getCEta(); + fCPhi = j.getCPhi(); + fCEt = j.getCEt(); + fPLength = j.getPLength(); + fXAxis = j.getXAxis(); + fYAxis = j.getYAxis(); + fZAxis = j.getZAxis(); + fPtLead = j.getPtLead(); + fLeadPart = new TParticle(*j.getLeadPart()); + fNParts = j.getNParts(); + + // need to build a copy of the old TClonesArray... + fTowers = new TClonesArray("AliTkTowerV2",Ntowers__); + TClonesArray *otherTowers = j.getTowerList(); + AliTkTowerV2 *myTower; + TIterator *iter = otherTowers->MakeIterator(); + Int_t i =0; + while ((myTower = (AliTkTowerV2 *) iter->Next()) != NULL) { + new ((*fTowers)[i]) AliTkTowerV2(*myTower); + i++; + } + if(i!=fNTowers) + cerr << "AliTkConeJet: should not happen " << i << " " << fNTowers << endl; + delete iter; + + // need to build a copy of the old TClonesArray... + fParts = new TClonesArray("TParticle",j.getNParts()); + TClonesArray *otherParts = j.getParts(); + TParticle *myParticle; + iter = otherParts->MakeIterator(); + i =0; + while ((myParticle = (TParticle *) iter->Next()) != NULL) { + new ((*fParts)[i]) TParticle(*myParticle); + i++; + } + if(i!=fNParts) + cerr << "AliTkConeJet: should not happen " << i << " " << fNParts << endl; + delete iter; +} + +AliTkConeJet::~AliTkConeJet() +{ + delete fTowers; + if(fLeadPart) delete fLeadPart; + if(fParts) delete fParts; +} + +void AliTkConeJet::addTower(AliTkTowerV2 *tower) +{ + new ((*fTowers)[fNTowers]) AliTkTowerV2(*tower); + fNTowers++; +} + +void AliTkConeJet::Clear(Option_t *option) +{ + TObject::Clear(option); + fTowers->Delete(); + fNTowers=0; + if(fParts) delete fParts; + fParts=0; + if(fLeadPart) delete fLeadPart; + fLeadPart=0; + fEta=-999; + fPhi=-999; + fEt=-999; + fPtCut=0.; + fCEta=-999; + fCPhi=-999; + fCEt=-999; + fPLength=0.; + fXAxis=0.; + fYAxis=0.; + fZAxis=0.; + fPtLead=0.; + fLeadPart=0; + fNParts=0; + fParts=0; +} + +void AliTkConeJet::calculateFromParticles(Float_t &et, Float_t &eta, Float_t &phi, Float_t ptcut) +{ + Float_t px=0.,py=0.,pz=0.; + TIterator *titer = fTowers->MakeIterator(); + AliTkTowerV2 *tower = NULL; + while ((tower = (AliTkTowerV2 *)titer->Next()) != NULL) { + TClonesArray *particles = tower->getParticleList(); + TParticle *particle = NULL; + TIterator *part = particles->MakeIterator(); + while ((particle = (TParticle *)part->Next()) != NULL) { + if(particle->Pt()Px(); + py+=particle->Py(); + pz+=particle->Pz(); + } + delete part; + } + delete titer; + + et = TMath::Sqrt(px*px+py*py); + Float_t p = TMath::Sqrt(px*px+py*py+pz*pz); + Float_t theta = (pz==0)?TMath::PiOver2():TMath::ACos(pz/p); + phi = TMath::Pi()+TMath::ATan2(-py,-px); + eta = -TMath::Log(TMath::Tan(theta/2.)); +} + +/* or take e = p_t * cosh(eta) */ +Float_t AliTkConeJet::getE(Float_t ptcut) const +{ + Float_t e=0.; + + TIterator *iter = fTowers->MakeIterator(); + AliTkTowerV2 *tower = NULL; + while ((tower = (AliTkTowerV2 *)iter->Next()) != NULL) { + TClonesArray *particles = tower->getParticleList(); + TParticle *particle = NULL; + TIterator *part = particles->MakeIterator(); + while ((particle = (TParticle *)part->Next()) != NULL) { + if(particle->Pt()P(); + } + delete part; + } + delete iter; + return e; +} + +/* or take e = p_t * cosh(eta) */ +Float_t AliTkConeJet::getECharged(Float_t ptcut) const +{ + Float_t e=0.; + + TIterator *iter = fTowers->MakeIterator(); + AliTkTowerV2 *tower = NULL; + while ((tower = (AliTkTowerV2 *)iter->Next()) != NULL) { + TClonesArray *particles = tower->getChargedParticleList(); + TParticle *particle = NULL; + TIterator *part = particles->MakeIterator(); + while ((particle = (TParticle *)part->Next()) != NULL) { + if(particle->Pt()P(); + } + particles->Delete(); + delete particles; + delete part; + } + delete iter; + return e; +} + +Float_t AliTkConeJet::getEtCharged() const +{ + Float_t EtCharged = 0; + TIterator *iter = fTowers->MakeIterator(); + AliTkTowerV2 *tower = NULL; + while ((tower = (AliTkTowerV2 *)iter->Next()) != NULL) { + EtCharged += tower->getEtCharged(); + } + delete iter; + return EtCharged; +} + +/* use to get fake rate if + in mixed case particles were marked */ +Float_t AliTkConeJet::getEtChargedMarked(Float_t ptcut) const +{ + Float_t et=0.; + + TIterator *iter = fTowers->MakeIterator(); + AliTkTowerV2 *tower = NULL; + while ((tower = (AliTkTowerV2 *)iter->Next()) != NULL) { + TClonesArray *particles = tower->getChargedParticleList(); + TParticle *particle = NULL; + TIterator *part = particles->MakeIterator(); + while ((particle = (TParticle *)part->Next()) != NULL) { + if(particle->GetWeight()>-100) continue; //(-123) + if(particle->Pt()Pt(); + } + particles->Delete(); + delete particles; + delete part; + } + delete iter; + return et; +} + +/* use to get fake rate if + in mixed case particles were marked */ +Float_t AliTkConeJet::getEtMarked(Float_t ptcut) const +{ + Float_t et=0.; + TIterator *iter = fTowers->MakeIterator(); + AliTkTowerV2 *tower = NULL; + while ((tower = (AliTkTowerV2 *)iter->Next()) != NULL) { + TClonesArray *particles = tower->getParticleList(); + TParticle *particle = NULL; + TIterator *part = particles->MakeIterator(); + while ((particle = (TParticle *)part->Next()) != NULL) { + if(particle->GetWeight()>-100) continue; //(-123) + if(particle->Pt()Pt(); + } + delete part; + } + delete iter; + return et; +} + +Float_t AliTkConeJet::getEtMarkedFrac(Float_t ptcut) const +{ + Float_t et=0.,etall=0.; + TIterator *iter = fTowers->MakeIterator(); + AliTkTowerV2 *tower = NULL; + while ((tower = (AliTkTowerV2 *)iter->Next()) != NULL) { + TClonesArray *particles = tower->getParticleList(); + TParticle *particle = NULL; + TIterator *part = particles->MakeIterator(); + while ((particle = (TParticle *)part->Next()) != NULL) { + if(particle->Pt()Pt(); + if(particle->GetWeight()>-100) continue; //(-123) + et+=particle->Pt(); + } + delete part; + } + delete iter; + if(etall>0) return et/etall; + return 1; +} + +Float_t AliTkConeJet::getEtEM() const +{ + Float_t EtEM = 0; + TIterator *iter = fTowers->MakeIterator(); + AliTkTowerV2 *tower = NULL; + while ((tower = (AliTkTowerV2 *)iter->Next()) != NULL) { + EtEM += tower->getEtEM(); + } + delete iter; + return EtEM; +} + +TClonesArray *AliTkConeJet::getParticles(Float_t ptcut) const +{ + TClonesArray *allParticles = new TClonesArray("TParticle",10000); + Int_t nParticles = 0; + TIterator *iter = fTowers->MakeIterator(); + AliTkTowerV2 *tower = NULL; + while ((tower = (AliTkTowerV2 *)iter->Next()) != NULL) { + TClonesArray *particles = tower->getParticleList(); + TParticle *particle = NULL; + TIterator *part = particles->MakeIterator(); + while ((particle = (TParticle *)part->Next()) != NULL) { + if(particle->Pt()MakeIterator(); + AliTkTowerV2 *tower = NULL; + while ((tower = (AliTkTowerV2 *)iter->Next()) != NULL) { + TClonesArray *particles = tower->getChargedParticleList(); + TParticle *particle = NULL; + TIterator *part = particles->MakeIterator(); + while ((particle = (TParticle *)part->Next()) != NULL) { + if(particle->Pt()Delete(); + delete particles; + delete part; + } + delete iter; + return chargedParticles; +} + +TClonesArray *AliTkConeJet::getNeutralParticles(Float_t ptcut) const +{ + TClonesArray *neutralParticles = new TClonesArray("TParticle",10000); + Int_t nNeutralParticles = 0; + TIterator *iter = fTowers->MakeIterator(); + AliTkTowerV2 *tower = NULL; + while ((tower = (AliTkTowerV2 *)iter->Next()) != NULL) { + TClonesArray *particles = tower->getNeutralParticleList(); + TParticle *particle = NULL; + TIterator *part = particles->MakeIterator(); + while ((particle = (TParticle *)part->Next()) != NULL) { + if(particle->Pt()Delete(); + delete particles; + delete part; + } + delete iter; + return neutralParticles; +} + +Int_t AliTkConeJet::getNParticles() const +{ + Int_t n = -1; + TClonesArray *p = getParticles(); + n = p->GetEntries(); + p->Delete(); + delete p; + return n; +} + +Int_t AliTkConeJet::getNChargedParticles() const +{ + Int_t n = -1; + TClonesArray *p = getChargedParticles(); + n = p->GetEntries(); + p->Delete(); + delete p; + return n; +} + +Int_t AliTkConeJet::getNNeutralParticles() const +{ + Int_t n = -1; + TClonesArray *p = getNeutralParticles(); + n = p->GetEntries(); + p->Delete(); + delete p; + return n; +} + +Int_t AliTkConeJet::getNParticles(Float_t ptCut) const +{ + Int_t n = 0; + TClonesArray *particles = getParticles(); + TIterator *iter = particles->MakeIterator(); + TParticle *particle; + while ((particle = (TParticle *)iter->Next()) != NULL) { + if (particle->Pt() > ptCut) { + n++; + } + } + delete iter; + particles->Delete(); + delete particles; + return n; +} + +Int_t AliTkConeJet::getNChargedParticles(Float_t ptCut) const +{ + Int_t n = 0; + TClonesArray *particles = getChargedParticles(); + TIterator *iter = particles->MakeIterator(); + TParticle *particle; + while ((particle = (TParticle *)iter->Next()) != NULL) { + if (particle->Pt() > ptCut) { + n++; + } + } + delete iter; + particles->Delete(); + delete particles; + return n; +} + +Int_t AliTkConeJet::getNNeutralParticles(Float_t ptCut) const +{ + Int_t n = 0; + TClonesArray *particles = getNeutralParticles(); + TIterator *iter = particles->MakeIterator(); + TParticle *particle; + while ((particle = (TParticle *)iter->Next()) != NULL) { + if (particle->Pt() > ptCut) { + n++; + } + } + delete iter; + particles->Delete(); + delete particles; + return n; +} + +void AliTkConeJet::getAxis(Float_t &x,Float_t &y,Float_t &z,Float_t ptcut) const +{ + x=0.; + y=0.; + z=0.; + + TIterator *iter = fTowers->MakeIterator(); + AliTkTowerV2 *tower = NULL; + while ((tower = (AliTkTowerV2 *)iter->Next()) != NULL) { + TClonesArray *particles = tower->getParticleList(); + TParticle *particle = NULL; + TIterator *part = particles->MakeIterator(); + while ((particle = (TParticle *)part->Next()) != NULL) { + if(particle->Pt()Px(); + y+=particle->Py(); + z+=particle->Pz(); + } + delete part; + } + delete iter; +} + +void AliTkConeJet::getChAxis(Float_t &x,Float_t &y,Float_t &z,Float_t ptcut) const +{ + x=0.; + y=0.; + z=0.; + + TIterator *iter = fTowers->MakeIterator(); + AliTkTowerV2 *tower = NULL; + while ((tower = (AliTkTowerV2 *)iter->Next()) != NULL) { + TClonesArray *particles = tower->getChargedParticleList(); + TParticle *particle = NULL; + TIterator *part = particles->MakeIterator(); + while ((particle = (TParticle *)part->Next()) != NULL) { + if(particle->Pt()Px(); + y+=particle->Py(); + z+=particle->Pz(); + } + particles->Delete(); + delete particles; + delete part; + } + delete iter; + Float_t length=TMath::Sqrt(x*x+y*y+z*z); + if(length!=0){ + x/=length; + y/=length; + z/=length; + } +} + +TParticle* AliTkConeJet::getLeadingPart(Float_t ptcut) const +{ + TParticle* plead=new TParticle; + Float_t ptlead=0; + + TIterator *iter = fTowers->MakeIterator(); + AliTkTowerV2 *tower = NULL; + while ((tower = (AliTkTowerV2 *)iter->Next()) != NULL) { + TClonesArray *particles = tower->getParticleList(); + TParticle *particle = NULL; + TIterator *part = particles->MakeIterator(); + while ((particle = (TParticle *)part->Next()) != NULL) { + if(particle->Pt()Pt()>ptlead){ + ptlead=particle->Pt(); + delete plead; + plead=new TParticle(*particle); + } + } + delete part; + } + delete iter; + return plead; +} + +TParticle* AliTkConeJet::getLeadingChPart(Float_t ptcut) const +{ + TParticle* plead=new TParticle; + Float_t ptlead=0; + + TIterator *iter = fTowers->MakeIterator(); + AliTkTowerV2 *tower = NULL; + while ((tower = (AliTkTowerV2 *)iter->Next()) != NULL) { + TClonesArray *particles = tower->getChargedParticleList(); + TParticle *particle = NULL; + TIterator *part = particles->MakeIterator(); + while ((particle = (TParticle *)part->Next()) != NULL) { + if(particle->Pt()Pt()>ptlead){ + ptlead=particle->Pt(); + delete plead; + plead=new TParticle(*particle); + } + } + particles->Delete(); + delete particles; + delete part; + } + delete iter; + return plead; +} + +void AliTkConeJet::calculateValues(Float_t ptcut) +{ + fPtCut=ptcut; + if(fParts) delete fParts; + fParts=new TClonesArray("TParticle",fNTowers*25); + + Float_t px=0.,py=0.,pz=0.; + TParticle* plead=new TParticle; + Float_t ptlead=0; + Int_t counter=0; + TIterator *titer = fTowers->MakeIterator(); + AliTkTowerV2 *tower = NULL; + while ((tower = (AliTkTowerV2 *)titer->Next()) != NULL) { + TClonesArray *particles = tower->getParticleList(); + + TParticle *particle = NULL; + TIterator *part = particles->MakeIterator(); + while ((particle = (TParticle *)part->Next()) != NULL) { + if(particle->Pt()Px(); + py+=particle->Py(); + pz+=particle->Pz(); + new ((*fParts)[counter]) TParticle(*particle); + counter++; + if(particle->Pt()>ptlead){ + ptlead=particle->Pt(); + delete plead; + plead=new TParticle(*particle); + } + } + delete part; + } + delete titer; + + fCEt = TMath::Sqrt(px*px+py*py); + Float_t p = TMath::Sqrt(px*px+py*py+pz*pz); + fPLength = p; + //Float_t theta = ((pz==0)||(p==0))?TMath::PiOver2():TMath::ACos(pz/p); + fCPhi = TMath::Pi()+TMath::ATan2(-py,-px); + //fCEta = (theta==0)?-100:TMath::Log(TMath::Tan(theta/2.)); + fCEta = (p==pz)?-100:0.5*TMath::Log((p+pz)/(p-pz)); + if(p){ + fXAxis= px/p; + fYAxis= py/p; + fZAxis= pz/p; + } + fPtLead=ptlead; + if(fLeadPart) delete fLeadPart; + fLeadPart=new TParticle(*plead); + delete plead; + fNParts=counter; +} + +Int_t AliTkConeJet::Compare(const TObject *obj) const +{ + Double_t val=((AliTkConeJet*)obj)->getEt(); + + if(fEt>val) return -1; //qsort is ascending + else if (fEt + + /* properties here are calculated for particles + regardless of their charge */ + Float_t fPtCut; //pt cut at which properties where calculated + Float_t fCEta; //calculated from particles + Float_t fCPhi; + Float_t fCEt; + Float_t fPLength; //length of axis + Float_t fXAxis; //axis + Float_t fYAxis; + Float_t fZAxis; + Float_t fPtLead; //leading particle pt + TParticle *fLeadPart; //-> + Int_t fNParts; //number of parts in all towers + TClonesArray *fParts; //-> + + ClassDef(AliTkConeJet,3) //AliTkConeJet class +}; + +ostream& operator<<(ostream& s,const AliTkConeJet& t); +#endif diff --git a/JETAN/AliTkConeJetEvent.cxx b/JETAN/AliTkConeJetEvent.cxx new file mode 100644 index 00000000000..834dac7ac94 --- /dev/null +++ b/JETAN/AliTkConeJetEvent.cxx @@ -0,0 +1,55 @@ +//$Id$ + +#include +#include +#include +#include +#include + +#include "AliTkTowerV2.h" +#include "AliTkConeJet.h" +#include "AliTkConeJetEvent.h" + +#define Njets__ 100 + +ClassImp(AliTkConeJetEvent) + +AliTkConeJetEvent::AliTkConeJetEvent() : TObject(), + fNJets(0),fJets(0), +#ifdef ALICEINTERFACE + fParticles(0), +#endif + fDesc(""),fRadius(0.),fPtCut(0.),fEtCut(0.) +{ + fJets = new TClonesArray("AliTkConeJet",Njets__); +} + +AliTkConeJetEvent::~AliTkConeJetEvent() +{ + delete fJets; +#ifdef ALICEINTERFACE + if(fParticles) delete fParticles; +#endif +} + +void AliTkConeJetEvent::Clear(Option_t *option) +{ + TObject::Clear(option); + delete fJets; + fJets = new TClonesArray("AliTkConeJet",Njets__); + //fJets->Clear("C"); // I really dont understand this!!! + fNJets=0; +#ifdef ALICEINTERFACE + if(fParticles) delete fParticles; + fParticles=0; +#endif +} + +void AliTkConeJetEvent::addJet(AliTkConeJet *jet) +{ + if (!jet) { + return; + } + new ((*fJets)[fNJets]) AliTkConeJet(*jet); + fNJets++; +} diff --git a/JETAN/AliTkConeJetEvent.h b/JETAN/AliTkConeJetEvent.h new file mode 100644 index 00000000000..d1a899cf008 --- /dev/null +++ b/JETAN/AliTkConeJetEvent.h @@ -0,0 +1,68 @@ +// $Id$ + +#ifndef ALITKCONEJETEVENT_H +#define ALITKCONEJETEVENT_H + +#include +#include +#include +#include +#include "AliTkConeJet.h" +#ifdef ALICEINTERFACE +#include +#endif + +class AliTkConeJetEvent : public TObject { + public: + AliTkConeJetEvent(); + ~AliTkConeJetEvent(); + + void addJet(AliTkConeJet *jet); + void sortJets(){if(fNJets>1) fJets->Sort(fNJets);} + void Clear(Option_t *option=""); + + Int_t getNJets() const { return fNJets; } + TClonesArray *getJets() const { return fJets; } +#ifdef ALICEINTERFACE + void setJetParticles(const AliJetEventParticles* p) { + if(fParticles) delete fParticles; + if(!p) { + fParticles=new AliJetEventParticles(0); + fParticles->SetHeader(*new TString("--- no event here, use aliev instead ---")); + } else + fParticles=new AliJetEventParticles(*p); + } + AliJetEventParticles* getJetParticles() const { return fParticles; } +#endif + + void Print(Option_t *) const { + cout << "AliTkConeJetEvent " << fNJets << endl; + for(Int_t i=0;iAt(i) << endl; + } + + void setRadius(Float_t r) {fRadius=r;} + void setPtCut(Float_t p) {fPtCut=p;} + void setEtCut(Float_t p) {fEtCut=p;} + void setDesc(TString &s) {fDesc=s;} + + Float_t getRadius() const {return fRadius;} + Float_t getPtCut() const {return fPtCut;} + Float_t getEtCut() const {return fEtCut;} + TString getDesc() const {return fDesc;} + + private: + Int_t fNJets; + TClonesArray *fJets; //-> +#ifdef ALICEINTERFACE + AliJetEventParticles *fParticles; //-> +#endif + + TString fDesc; //description to remember event + Float_t fRadius; //radius used in the finder + Float_t fPtCut; //pT cut used on original event + Float_t fEtCut; //jet Et cut used in the finder + + ClassDef(AliTkConeJetEvent,3) +}; +#endif diff --git a/JETAN/AliTkConeJetFinder.cxx b/JETAN/AliTkConeJetFinder.cxx new file mode 100644 index 00000000000..ce921e5c599 --- /dev/null +++ b/JETAN/AliTkConeJetFinder.cxx @@ -0,0 +1,605 @@ +//$Id$ +/************************************************************************** + * AliTkConeJetFinder.cxx * + * Thorsten Kollegger GetXaxis()->SetTitle("#eta"); + hEtHist->GetYaxis()->SetTitle("#phi (rad)"); + hEtHist->GetZaxis()->SetTitle("E_{t} in bins (GeV)"); + + // create histogram to hold Et cone centeres around tower center + hEtConeHist = new TH2D("Cone_EtHist","Cone_EtHist", + nEtaBins,nEtaMin,nEtaMax, + nPhiBins,nPhiMin,nPhiMax); + hEtConeHist->GetXaxis()->SetTitle("#eta"); + hEtConeHist->GetYaxis()->SetTitle("#phi (rad)"); + hEtConeHist->GetZaxis()->SetTitle("E_{t} in cones (GeV)"); + + // create histogram to show the stable protojets before merging + hStableProtoJetHist = new TH2D("StableProtoJetHist","StableProtoJetHist", + nEtaBins,nEtaMin,nEtaMax, + nPhiBins,nPhiMin,nPhiMax); + hStableProtoJetHist->GetXaxis()->SetTitle("#eta"); + hStableProtoJetHist->GetYaxis()->SetTitle("#phi (rad)"); + hStableProtoJetHist->GetZaxis()->SetTitle("E_{t} in stable cones (GeV)"); + + hTowerEt = new TH2D("tower_EtCheck","tower EtCheck", + nEtaBins,nEtaMin,nEtaMax, + nPhiBins,nPhiMin,nPhiMax); + hTowerEt->GetXaxis()->SetTitle("#eta"); + hTowerEt->GetYaxis()->SetTitle("#phi (rad)"); + hTowerEt->GetZaxis()->SetTitle("E_{t} in bins (GeV)"); + +} + +void AliTkConeJetFinder::InitEvent() { + // called at each events + // clears the jet finder for the next event + + // clear tower array - only Et + for (Int_t i = 0; i < nTower; i++) { + towers[i].Et = 0.; + } + + // clear protojet list + protojets->Clear(); + + // clear control histograms + hEtHist->Reset(); + hEtConeHist->Reset(); + hTowerEt->Reset(); + hStableProtoJetHist->Reset(); + +} + +void AliTkConeJetFinder::FillEtHistFromTParticles(TClonesArray *particles) { + // input TClonesArray with TParticles, e.g. from PYTHIA + // fills the Et grid from these particles + if (!particles) { + return; + } + TParticle *particle = NULL; + Float_t Et = 0; + + // loop over all particles... + TIterator *iter = particles->MakeIterator(); + while ((particle = (TParticle *) iter->Next()) != NULL) { + // check if particle is accepted + if (isTParticleAccepted(particle)) { + // calculate Et for a massless particle... + Et = TMath::Sqrt(particle->Pt()*particle->Pt()); + // idea for Et check: Et = E *sin(theta); + Int_t tower = findTower(particle->Eta(),particle->Phi()); + if (tower >= 0) { + towers[tower].Et += Et; + } else { +// cerr << "Couldn't find tower!!! eta=" +// << particle->Eta() << " phi=" << particle->Phi() +// << endl; + } + // and to the histogram for control reasons + AddEtHist(particle->Eta(),particle->Phi(),Et); + } + } + + // at this point we have filled all towers... + // let's make sure tower info is right + for (Int_t i = 0; i < nTower; i++) { + Float_t etacenter = (towers[i].etaMin + towers[i].etaMax)/2.; + Float_t phicenter = (towers[i].phiMin + towers[i].phiMax)/2.; + hTowerEt->Fill(etacenter,phicenter,towers[i].Et); + } + +} + +Bool_t AliTkConeJetFinder::isTParticleAccepted(TParticle *particle) { + // check if particle is accepted + // makes sense to write this into a own class, but now I'm lazy + + // check if particle is stable -> a detectable particle + if (particle->GetStatusCode() != 1) { + return kFALSE; + } + // and now just for fun + TParticlePDG *partPDG; + partPDG = particle->GetPDG(); +// if (partPDG->Charge() == 0) { +// cout << partPDG->GetName() << endl; +// return kFALSE; +// } + + // default case: accept + return kTRUE; +} + +void AliTkConeJetFinder::AddEtHist(Float_t eta, Float_t phi, Double_t Et) { + // add particle/tower withEt at position eta,phi to the current Et grid... + if (hEtHist) { + Double_t oldEt; + // get the Et already stored in the bin eta,phi + oldEt = hEtHist->GetBinContent(hEtHist->GetXaxis()->FindFixBin(eta), + hEtHist->GetYaxis()->FindFixBin(phi)); + // add the new one + Et += oldEt; + // and set the bin to the sum of old+new Et. + hEtHist->SetBinContent(hEtHist->GetXaxis()->FindFixBin(eta), + hEtHist->GetYaxis()->FindFixBin(phi), + Et); + } +} + +Int_t AliTkConeJetFinder::run() { + Int_t status; + status = FindProtoJets(); + cout << "Found " << protojets->GetEntries() << " stable protojets" + << endl; + return status; +} + +Int_t AliTkConeJetFinder::FindProtoJets() { + Float_t etaTower; + Float_t phiTower; + + Float_t eta; + Float_t phi; + Float_t Et; + + Float_t etaDiff; + Float_t phiDiff; + + AliTkProtoJet protojet; + + // let's take each tower as seed + // this means seedless search... + // introduce later step with seed+midpoints... + for (Int_t i=0; i < nTower; i++) { + // loop over all towers + etaTower = (towers[i].etaMax+towers[i].etaMin)/2.; + phiTower = (towers[i].phiMax+towers[i].phiMin)/2.; + + eta = etaTower; + phi = phiTower; + + // let's calculate a protojet with centered around tower center + if ((CalculateConeCentroid(&eta,&phi,&Et) > 0)) { + // ok, we found a valid centroid around tower pos + // let's fill the initial seed into the EtConeHist + hEtConeHist->Fill(etaTower,phiTower,Et); + // let's calculate the vector to the weighted cone center + etaDiff = (eta - etaTower)*(eta - etaTower); + phiDiff = calcPhiDiff(phi,phiTower); + + // let's iterate the proto-jet while it's in the tower boundaries + // or it is stable + // or the maximum number of iterations is reached + Bool_t isStable = kFALSE; + Bool_t isInTower = isProtoJetInTower(i,eta,phi); + //Bool_t isInTower = isProtoJetInTower(etaBin,phiBin,eta,phi); + Int_t nIterations = 0; + Float_t etaOld; + Float_t phiOld; + + // make const variables private members and set in default... + const Int_t nMaxIterations = 100; + while ((nIterations < nMaxIterations) && + (!isStable) && + (isInTower)) { + etaOld = eta; + phiOld = phi; + CalculateConeCentroid(&eta,&phi,&Et); + etaDiff = (eta - etaOld)*(eta - etaOld); + phiDiff = calcPhiDiff(phi,phiOld)*calcPhiDiff(phi,phiOld); + // and check protojet again... + isStable = isProtoJetStable(etaDiff,phiDiff); + // we allow the jet to flow away... + //isInTower = kTRUE; + // we force protojets to stay in tower + isInTower = isProtoJetInTower(i,eta,phi); + nIterations++; + } + + if ((isStable) || (nIterations == nMaxIterations)) { +// cout << "Found a stable protojet at eta=" << eta +// << " phi=" << phi << " with Et=" << Et << endl; + if (nIterations == nMaxIterations) { + cout << "To many iterations on protojet" << endl; + } + // create a new protojet object + AliTkProtoJet *protojet = new AliTkProtoJet(); + protojet->eta = eta; + protojet->phi = phi; + protojet->Et = Et; + + // let's check if we allready found this protojet + TIter *iter = new TIter(protojets); + AliTkProtoJet *pj; + Bool_t wasFound = kFALSE; + while ((pj = (AliTkProtoJet *) iter->Next()) && !wasFound) { + wasFound = protojet->IsEqual(pj); + } + + // and add it to the list of protojets... + if (!wasFound) { + protojets->Add(protojet); + //cout << protojet->Et << endl; + hStableProtoJetHist->Fill(eta,phi,Et); + } else { + delete protojet; + } + } + } + } + return 0; +} + +Int_t AliTkConeJetFinder::FindJets() { + //let's look for the highest Et-Jet + //AliTkProtoJet *pj; + + return 0; +} + + +Int_t AliTkConeJetFinder::CalculateConeCentroid(Float_t *eta, Float_t *phi, + Float_t *Et) { + + //==================================================================== + // WORKS STILL ON HISTOGRAM + // MUST WORK ON TOWERS + //==================================================================== + + + // let's copy some stuff + Float_t etaCenter = *eta; + Float_t phiCenter = *phi; + + /* + cout << "CalculateConeCentroid: Initial Cone Center eta=" + << etaCenter + << " phi=" + << phiCenter + << endl; + */ + + Float_t etaTower = 0; + Float_t phiTower = 0; + Float_t EtTower = 0; + + Float_t etaDiff = 0; + Float_t phiDiff = 0; + + Float_t etaJet = 0; + Float_t phiJet = 0; + Float_t EtJet = 0; + + // lets calculate boundaries from jet cone + Float_t etaMin = etaCenter - jetRadius; + Float_t etaMax = etaCenter + jetRadius; + Float_t phiMin = phiCenter - jetRadius; + + if (phiMin < 0) { + phiMin = 2*TMath::Pi() + phiMin; + } + Float_t phiMax = phiCenter + jetRadius; + if (phiMax > 2*TMath::Pi()) { + phiMax = phiMax - 2*TMath::Pi(); + } + + Int_t etaBinMin = hEtHist->GetXaxis()->FindFixBin(etaMin); + if (etaBinMin == 0) { + return -1; + } + Int_t etaBinMax = hEtHist->GetXaxis()->FindFixBin(etaMax); + if (etaBinMax == hEtHist->GetXaxis()->GetNbins()+1) { + return -1; + } + Int_t phiBinMin = hEtHist->GetYaxis()->FindFixBin(phiMin); + Int_t phiBinMax = hEtHist->GetYaxis()->FindFixBin(phiMax); + + // let's loop over all bins/towers... + for (Int_t etaBin = etaBinMin; etaBin != etaBinMax+1; etaBin++) { + for (Int_t phiBin = phiBinMin; phiBin != phiBinMax+1; phiBin++) { + // roll over in phi... + if (phiBin == hEtHist->GetYaxis()->GetNbins()+1) { + phiBin = 0; + continue; + } + // let's get the tower + etaTower = hEtHist->GetXaxis()->GetBinCenter(etaBin); + phiTower = hEtHist->GetYaxis()->GetBinCenter(phiBin); + EtTower = hEtHist->GetCellContent(etaBin,phiBin); + + // let's check if the bin is in the cone + etaDiff = (etaTower - etaCenter)*(etaTower - etaCenter); + phiDiff = calcPhiDiff(phiTower,phiCenter)* + calcPhiDiff(phiTower,phiCenter); + if (TMath::Sqrt(etaDiff+phiDiff) < jetRadius) { + // tower is in cone - add it to the cone + EtJet += EtTower; + if (EtTower != 0) { + etaJet += EtTower * etaTower; + phiJet += EtTower * phiTower; + } + } + } + } + + // normalize eta and phi + if (EtJet != 0) { + etaJet /= EtJet; + phiJet /= EtJet; + } + + /* + cout << "CalculateConeCentroid: Final Cone Center eta=" + << etaJet + << " phi=" + << phiJet + << " Et=" + << EtJet + << endl; + */ + + // return the jet cone parameters + *eta = etaJet; + *phi = phiJet; + *Et = EtJet; + + + return 1; +} + +Float_t AliTkConeJetFinder::calcPhiDiff(Float_t phi1, Float_t phi2) { + Float_t phidiff1 = TMath::Sqrt((phi1-phi2)*(phi1-phi2)); + Float_t phidiff2 = TMath::Sqrt((phi1-phi2-2*TMath::Pi())* + (phi1-phi2-2*TMath::Pi())); + Float_t phidiff3 = TMath::Sqrt((phi1-phi2+2*TMath::Pi())* + (phi1-phi2+2*TMath::Pi())); + // return the minmum; + Float_t phiret = phidiff1; + if (phiret > phidiff2) { + phiret = phidiff2; + } + if (phiret > phidiff3) { + phiret = phidiff3; + } + return phiret; +} + +Bool_t AliTkConeJetFinder::isProtoJetStable(Float_t etaDiff, Float_t phiDiff) { + const Float_t epsilon = 0.00001; + if (TMath::Sqrt(etaDiff*phiDiff) < epsilon) { + return kTRUE; + } + return kFALSE; +} + +Bool_t AliTkConeJetFinder::isProtoJetInTower(Int_t etaBin, Int_t phiBin, + Float_t eta, Float_t phi) { + Float_t etaBinMax = hEtHist->GetXaxis()->GetBinUpEdge(etaBin); + Float_t etaBinMin = hEtHist->GetXaxis()->GetBinLowEdge(etaBin); + Float_t phiBinMax = hEtHist->GetYaxis()->GetBinUpEdge(phiBin); + Float_t phiBinMin = hEtHist->GetYaxis()->GetBinLowEdge(phiBin); + if ((eta < etaBinMax) && + (eta > etaBinMin) && + (phi < phiBinMax) && + (phi > phiBinMin)) { + return kTRUE; + } + + return kFALSE; +} + +Bool_t AliTkConeJetFinder::isProtoJetInTower(Int_t tower, Float_t eta, + Float_t phi) { + if ((eta > towers[tower].etaMin) && + (eta < towers[tower].etaMax) && + (phi > towers[tower].phiMin) && + (phi < towers[tower].phiMax)) { + return kTRUE; + } + return kFALSE; +} + +Int_t AliTkConeJetFinder::findTower(Float_t eta, Float_t phi) { + Float_t etaBinSize = (nEtaMax - nEtaMin)/(Float_t)nEtaBins; + Float_t phiBinSize = (nPhiMax - nPhiMin)/(Float_t)nPhiBins; + + if ((eta < nEtaMin) || (eta > nEtaMax)) { + return -1; + } + if ((phi < nPhiMin) || (phi > nPhiMax)) { + return -1; + } + + Int_t etaBin = (Int_t) ((eta - nEtaMin)/etaBinSize); + Int_t phiBin = (Int_t) ((phi - nPhiMin)/phiBinSize); + + Int_t bin = etaBin * nPhiBins + phiBin; + + if (bin >= nTower) { + return -2; + } + + return bin; +} + +// lot of setters/getters... nothing special, no comments... +void AliTkConeJetFinder::setEtaNBins(Int_t nbins) { + nEtaBins = nbins; +} + +Int_t AliTkConeJetFinder::getEtaNBins() { + return nEtaBins; +} + +void AliTkConeJetFinder::setEtaRange(Float_t min, Float_t max) { + nEtaMin = min; + nEtaMax = max; +} + +Float_t AliTkConeJetFinder::getEtaRangeMin() { + return nEtaMin; +} + +Float_t AliTkConeJetFinder::getEtaRangeMax() { + return nEtaMax; +} + +void AliTkConeJetFinder::setEtaGrid(Int_t nbins, Float_t min, Float_t max) { + setEtaNBins(nbins); + setEtaRange(min,max); +} + +void AliTkConeJetFinder::setPhiNBins(Int_t nbins) { + nPhiBins = nbins; +} + +Int_t AliTkConeJetFinder::getPhiNBins() { + return nPhiBins; +} + +void AliTkConeJetFinder::setPhiRange(Float_t min, Float_t max) { + nPhiMin = min; + nPhiMax = max; +} + +Float_t AliTkConeJetFinder::getPhiRangeMin() { + return nPhiMin; +} + +Float_t AliTkConeJetFinder::getPhiRangeMax() { + return nPhiMax; +} + +void AliTkConeJetFinder::setPhiGrid(Int_t nbins, Float_t min, Float_t max) { + setPhiNBins(nbins); + setPhiRange(min,max); +} + +void AliTkConeJetFinder::setJetConeRadius(Float_t r) { + jetRadius = r; +} + +Float_t AliTkConeJetFinder::getJetConeRadius() { + return jetRadius; +} + +TObjArray *AliTkConeJetFinder::getProtoJetList() { + return protojets; +} + +//========================================================================== +ClassImp(AliTkTower) + +//========================================================================== +ClassImp(AliTkProtoJet) + +Bool_t AliTkProtoJet::IsEqual(AliTkProtoJet *other) { + const Float_t epsilon = 0.0000001; + + Float_t etaDiff = (other->eta - eta)*(other->eta - eta); + Float_t phiDiff = (other->phi - phi)*(other->phi - phi); + Float_t EtDiff = (other->Et - Et)*(other->Et - Et); + + Bool_t isEqual = kFALSE; + if ((etaDiff < epsilon) && + (phiDiff < epsilon) && + (EtDiff < epsilon)) { + isEqual = kTRUE; + } + return isEqual; +} + +bool SProtoJet::operator==(const SProtoJet &s1) { + Float_t epsilon = 0.0000001; + bool b; + if (eta > s1.eta) { + b = ((eta - s1.eta) < epsilon); + } else { + b = ((s1.eta - eta) < epsilon); + } + if (phi > s1.phi) { + b = b && ((phi - s1.phi) < epsilon); + } else { + b = b && ((s1.phi - phi) < epsilon); + } + if (Et > s1.Et) { + b = b && ((Et - s1.Et) < epsilon); + } else { + b = b && ((s1.Et - Et) < epsilon); + } + return b; +} diff --git a/JETAN/AliTkConeJetFinder.h b/JETAN/AliTkConeJetFinder.h new file mode 100644 index 00000000000..3403de885fa --- /dev/null +++ b/JETAN/AliTkConeJetFinder.h @@ -0,0 +1,178 @@ +// $Id$ + +/************************************************************************* + * AliTkConeJetFinder.h * + * Thorsten Kollegger * + * Jet finder based on a cone algorithm with seeds and addition of * + * midpoints, for a description of the algorithm see hep-ex/0005012 * + ************************************************************************/ + +/************************************************************************* + * Some remarks: * + * --- * + * This is a prototype finder - it's clearly not optimized for speed * + * e.g. one could win much by using TClonesArrays instead of TObjArrays * + * --- * + * for MC studies, it keeps track of the particle/proto-jet/jet origin * + ************************************************************************/ + +// NEXT STEPS: 09/03/02 12:30am +// Implement list of found stable protojets +// Implement function isProtoJetAlreadyFound() +// -> Finishes findProtoJets +// Implement merge/split process +// Implement seed + midpoint addition + +// includes +#include +#include "TROOT.h" +#include "TObject.h" +#include "TH2.h" +#include "TMath.h" +#include "TClonesArray.h" +#include "TParticle.h" + + +//forward declarations +class AliTkTower; +class AliTkProtoJet; + +class AliTkConeJetFinder : public TObject { + public: + AliTkConeJetFinder(); + ~AliTkConeJetFinder(); + + void setDefaultSettings(); + void Init(); + + void InitEvent(); + + void FillEtHistFromTParticles(TClonesArray *particles); + Bool_t isTParticleAccepted(TParticle * particle); + void AddEtHist(Float_t eta, Float_t phi, Double_t Et); + + + Int_t run(); + + /* + Int_t CreateSeedList(); + Int_t CreateMidPoints(); + */ + Int_t FindProtoJets(); + Int_t CalculateConeCentroid(Float_t *eta, Float_t *phi, Float_t *Et); + + Int_t FindJets(); + /* + Bool_t isProtoJetConeShared(); + Int_t FindNeighborCone(Int_t nProtoJet); + Int_t SplitProtoJetCone(Int_t nProtoJet1, Int_t nProtoJet2); + Int_t MergeProtoJetCone(Int_t nProtoJet1, Int_t nProtoJet2); + */ + + // eta binning + void setEtaNBins(Int_t nbins); + Int_t getEtaNBins(); + void setEtaRange(Float_t min, Float_t max); + Float_t getEtaRangeMin(); + Float_t getEtaRangeMax(); + void setEtaGrid(Int_t nbins, Float_t min, Float_t max); + + // phi binnig + void setPhiNBins(Int_t nbins); + Int_t getPhiNBins(); + void setPhiRange(Float_t min, Float_t max); + Float_t getPhiRangeMin(); + Float_t getPhiRangeMax(); + void setPhiGrid(Int_t nbins, Float_t min, Float_t max); + + // jet radius + void setJetConeRadius(Float_t r); + Float_t getJetConeRadius(); + /* + // seed tower threshold + void setTowerSeedEt(Float_t minEt); + Float_t getTowerSeedEt(); + */ + + // protojetlist + TObjArray *getProtoJetList(); + + protected: + + private: + //---------------------------------------------------------------------- + // member variables + TH2D *hEtHist; + TH2D *hTowerEt; + Int_t nEtaBins; + Float_t nEtaMin; + Float_t nEtaMax; + Int_t nPhiBins; + Float_t nPhiMin; + Float_t nPhiMax; + + Float_t jetRadius; + TH2D *hEtConeHist; + TH2D *hStableProtoJetHist; + + // number of "towers" - calcualted in Init() + Int_t nTower; + // array of towers + AliTkTower *towers; + // seed list - array of ints with tower id's + Int_t *SeedTower; + // will not work this way - this requires more towers than tower due to the additon of midpoint + + // protojet list + TObjArray *protojets; + + // private functions + Float_t calcPhiDiff(Float_t phi1, Float_t phi2); + Bool_t isProtoJetStable(Float_t etaDiff, Float_t phiDiff); + Bool_t isProtoJetInTower(Int_t etaBin,Int_t phiBin, + Float_t eta, Float_t phi); + Bool_t isProtoJetInTower(Int_t tower, Float_t eta, Float_t phi); + + Int_t findTower(Float_t eta, Float_t phi); + + ClassDef(AliTkConeJetFinder,1) +}; + +class AliTkTower : public TObject { + public: + AliTkTower() : TObject() { etaMin = 0; etaMax = 0; phiMin = 0; phiMax = 0;} + ~AliTkTower() { } + Int_t uid; + Float_t etaMin; + Float_t etaMax; + Float_t phiMin; + Float_t phiMax; + Float_t Et; + private: + + ClassDef(AliTkTower,1) +}; + +class AliTkProtoJet : public TObject { + public: + AliTkProtoJet() : TObject() { } + ~AliTkProtoJet() { } + Float_t eta; + Float_t phi; + Float_t Et; + + Bool_t IsEqual(AliTkProtoJet *other); + private: + + + ClassDef(AliTkProtoJet,1) +}; + +struct SProtoJet; +struct SProtoJet { + Float_t eta; + Float_t phi; + Float_t Et; + bool operator==(const SProtoJet &s1); +}; + diff --git a/JETAN/AliTkConeJetFinderV2.cxx b/JETAN/AliTkConeJetFinderV2.cxx new file mode 100644 index 00000000000..1a07e2bf65c --- /dev/null +++ b/JETAN/AliTkConeJetFinderV2.cxx @@ -0,0 +1,938 @@ +// $Id$ + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "AliTkConeJet.h" +#include "AliTkTowerV2.h" +#include "AliTkConeJetEvent.h" +#include "AliTkConeJetFinderV2.h" + +#ifdef ALICEINTERFACE +#include +#include +#include +#endif + +//numerical precision +#define __epsilon__ 1e-6 + +//==== Implementation of tower ===== +tower::tower() : fEta_min(-999),fEta_max(-999),fEta_center(-999), + fPhi_min(-999),fPhi_max(-999),fPhi_center(-999), + fEt(0), fParticles(0) +{ +} + +tower::tower(const tower& t) +{ + fEta_min = t.getEtaMin(); + fEta_max = t.getEtaMax(); + fEta_center = t.getEta(); + fPhi_min = t.getPhiMin(); + fPhi_max = t.getPhiMax(); + fPhi_center = t.getPhi(); + fEt = t.getEt(); +} + +tower::tower(Float_t phimin, Float_t phimax, Float_t etamin, Float_t etamax) +{ + fEta_min = etamin; + fEta_max = etamax; + fEta_center = (etamax+etamin)/2.; + fPhi_min = phimin; + fPhi_max = phimax; + fPhi_center = (phimax+phimin)/2.; + fEt = 0; +} + +tower::~tower() +{ + clearParticles(); +} + +inline tower& tower::operator+=(const Float_t E) +{ + fEt += E; + return *this; +} + +inline tower& tower::operator+=(const TParticle *part) +{ + fEt += part->Pt(); // Et for a massless particle... + addParticle(part); + return *this; +} + +ostream& operator<<(ostream& s,const tower& t) +{ + return s << "tower info: etamin=" << t.getEtaMin() + << " etamax=" << t.getEtaMax() + << " phimin=" << t.getPhiMin() + << " phimax=" << t.getPhiMax() + << " Et=" << t.getEt(); +} + +inline list *tower::getParticles() +{ + list *newList = new list; + list &myList = *newList; + copy(fParticles.begin(),fParticles.end(),back_inserter(myList)); + return newList; +} + +//==== Implementation of protojet ===== +protojet:: protojet() : fCentroid(-999,-999), + fEtWeightedCentroid(-999,-999), + fEt(-999),fUpdate(kFALSE),fTowers(0) +{ +} + +protojet::protojet(const protojet& p) : + fCentroid(-999,-999), + fEtWeightedCentroid(-999,-999), + fEt(-999),fUpdate(kFALSE),fTowers(0) +{ + setCentroidPosition(p.getCentroidPosition()); +} + +protojet::protojet(const protojet *p) : + fCentroid(-999,-999), + fEtWeightedCentroid(-999,-999), + fEt(-999),fUpdate(kFALSE),fTowers(0) +{ + setCentroidPosition(p->getCentroidPosition()); +} + +bool protojet::operator==(const protojet &p1) +{ + AliTkEtaPhiVector otherCenter = p1.getCentroidPosition(); + if (fCentroid.diffSq(otherCenter) > __epsilon__) + return false; + + if ((getEt() - p1.getEt())*(getEt() - p1.getEt()) > __epsilon__) + return false; + + return true; +} + +void protojet::update() +{ + Float_t Et = 0; + Float_t phi = 0; + Float_t eta = 0; + + for (list::const_iterator iter = fTowers.begin(); + iter != fTowers.end(); ++iter) { + Et += (*iter)->getEt(); + phi += (*iter)->getEt() * (*iter)->getPhi(); + eta += (*iter)->getEt() * (*iter)->getEta(); + } + if (Et != 0) { + phi /= Et; + eta /= Et; + } + fEtWeightedCentroid.setVector(eta,phi); + fEt=Et; + fUpdate=kFALSE; +} + +inline list protojet::getTowerList() const +{ + list newList; + copy(fTowers.begin(),fTowers.end(),back_inserter(newList)); + return newList; +} + +inline list protojet::getSharedTowerList(const protojet *other) const +{ + list newList; + for (list::const_iterator i = fTowers.begin(); + i != fTowers.end(); ++i) { + if (other->hasTower((*i))) { + newList.push_back((*i)); + } + } + return newList; +} + +inline bool protojet::hasTower(tower *pTower) const +{ + bool bHasTower = false; + for (list::const_iterator iter = fTowers.begin(); + iter != fTowers.end(); ++iter) { + if (pTower == (*iter)) { + bHasTower = true; + break; + } + } + return bHasTower; +} + +inline bool protojet::shareTowers(const protojet *other) const +{ + bool bShareTowers = false; + for (list::const_iterator iter = fTowers.begin(); + iter != fTowers.end(); ++iter) { + if (other->hasTower(*iter)) { + bShareTowers = true; + break; + } + } + return bShareTowers; +} + +inline Float_t protojet::diffToCenter(tower *pTower) const +{ + AliTkEtaPhiVector v(pTower->getEta(),pTower->getPhi()); + AliTkEtaPhiVector center = getCentroidPosition(); + + return v.diff(center); +} + +ostream& operator<<(ostream& s,const protojet& p) +{ + return s << "Protojet info: eta=" << p.Eta() + << " phi=" << p.Phi() << " Et=" << p.getEt(); +} + + +//================== implementation of AliTkConeJetFinderV2 ============== +ClassImp(AliTkConeJetFinderV2) + +AliTkConeJetFinderV2::AliTkConeJetFinderV2() + : TObject(), + fOutput(0),fNTowers(0),fEtaBins(0),fEtaMin(0), + fEtaMax(0),fEtaWidth(0),fPhiBins(0),fPhiMin(0),fPhiMax(0), + fPhiWidth(0),fEtCut(0),fEtMinJet(0),fPtCut(0),fRadius(0),fTowers(0), + fSeedPointsNew(),fProtojets(),fJets(0), + fEvoutfile(0),fEvout_name(0),fEvoutevent(0),fEvouttree(0) +#ifdef ALICEINTERFACE + ,fAliParticles(0) +#endif + +#ifdef DOHISTOS + ,fHistos(),fEventHistos(),fHistFile(0) +#endif +{ + defaultSettings(); +} + + +AliTkConeJetFinderV2::~AliTkConeJetFinderV2() +{ + if(fEvoutevent) delete fEvoutevent; + if(fEvoutfile) delete fEvoutfile; + if(fEvout_name) delete[] fEvout_name; +#ifdef ALICEINTERFACE + if(fAliParticles) delete fAliParticles; +#endif + +#ifdef DOHISTOS + if(fHistFile) delete fHistFile; +#endif +} + +void AliTkConeJetFinderV2::defaultSettings() +{ + fOutput = kFALSE; + fRadius = 0.7; + // some more or less usefull default settings + // only possibilty to control the jet finder without setters/getters + fPhiBins = (Int_t) (2 * TMath::Pi() / 0.1); + fPhiMin = 0; + fPhiMax = 2 * TMath::Pi(); + fEtaBins = 20; + fEtaMin = -1; + fEtaMax = 1; + fEtCut = 0; + fPtCut = 0; + fEtMinJet = 0; + fNTowers = fPhiBins*fEtaBins; +} + +void AliTkConeJetFinderV2::setSettings(Int_t phibins,Int_t etabins) +{ + fPhiBins = phibins; + fPhiMin = 0; + fPhiMax = 2 * TMath::Pi(); + fEtaBins = etabins; + fEtaMin = -1; + fEtaMax = 1; + fNTowers = fPhiBins*fEtaBins; +} + +void AliTkConeJetFinderV2::init() +{ + createTowers(); + + fEvoutevent = new AliTkConeJetEvent(); + fEvoutfile = 0; + fEvouttree = 0; + +#ifdef DOHISTOS + createHistos(); + createEventHistos(); +#endif + + if (getEvOutFilename()) { + if(fOutput)cout << "Writing finder output to " << getEvOutFilename() << endl; + fEvoutfile = new TFile(getEvOutFilename(),"RECREATE"); + fEvouttree = new TTree("jets","TKConeJetFinderV2 jets"); + fEvouttree->Branch("ConeFinder","AliTkConeJetEvent",&(this->fEvoutevent),32000,0); + } +} + +#ifdef ALICEINTERFACE +void AliTkConeJetFinderV2::initEvent(const AliJetEventParticles *p,TString desc) +{ + if(fEvoutevent){ + fEvoutevent->Clear(); + fEvoutevent->setDesc(desc); + //fEvoutevent->setJetParticles(p); + fEvoutevent->setJetParticles(0); + } + const TClonesArray *parts=p->GetParticles(); + initEvent_(parts,2); +} +#endif + +void AliTkConeJetFinderV2::initEvent(const TClonesArray *particles,Int_t type,TString desc) +{ + if(fEvoutevent){ + fEvoutevent->Clear(); + fEvoutevent->setDesc(desc); + } + initEvent_(particles,type); +} + +void AliTkConeJetFinderV2::initEvent(const TClonesArray *particles,Int_t type) +{ +#ifdef DOHISTOS + // clear event histograms for new event + clearEventHistos(); +#endif + + if(fEvoutevent){ + fEvoutevent->Clear(); + } + + initEvent_(particles,type); +} + + +void AliTkConeJetFinderV2::initEvent_(const TClonesArray *particles,Int_t type) +{ + fEvoutevent->setRadius(fRadius); + fEvoutevent->setEtCut(fEtCut); + fEvoutevent->setPtCut(fPtCut); + + // reset all towers + for (vector::iterator i = fTowers->begin(); i != fTowers->end();++i) { + (*i).clear(); + } + // reset seed points + fSeedPointsNew.erase(fSeedPointsNew.begin(),fSeedPointsNew.end()); + // reset protojet list + for (list::iterator i = fProtojets.begin();i != fProtojets.end(); ++i) { + protojet *p = (*i); + if (p) { + delete p; + } + } + fProtojets.erase(fProtojets.begin(),fProtojets.end()); + + // reset jet list + for (list::iterator i = fJets.begin(); + i != fJets.end(); ++i) { + protojet *p = (*i); + if (p) { + delete p; + } + } + fJets.erase(fJets.begin(),fJets.end()); + + // fill Et towers from particles + switch (type) { + case 1: + fillTowersFromTParticles(particles); + break; +#ifdef ALICEINTERFACE + case 2: + fillTowersFromAliParticles(particles); + break; +#endif + default: + cerr << "AliTkConeJetFinderV2: don't know how to fill Et hist from TClonesArray with type " << type << endl; + } + createSeedPoints(); + +#ifdef DOHISTOS + fillTowerHist(); +#endif +} + +Bool_t AliTkConeJetFinderV2::isJetEnergy(Float_t min, Float_t max) +{ // Checks if there was an jet with Et between min and max + Float_t men=maxJetEnergy(); + + if((men>min)&&(men::const_iterator iter = fJets.begin(); + iter != fJets.end(); ++iter) { + + Float_t et=(*iter)->getEt(); + if(men::const_iterator iter = fJets.begin(); + iter != fJets.end(); ++iter) { + + Float_t jetet=(*iter)->getEt(); + if(jetetClear(); + jet->setEta((*iter)->Eta()); + jet->setPhi((*iter)->Phi()); + jet->setEt(jetet); + + list jettowers = (*iter)->getTowerList(); + for (list::const_iterator twiter = jettowers.begin(); + twiter != jettowers.end(); ++twiter) { + myTower->Clear(); + myTower->setEta((*twiter)->getEta()); + myTower->setPhi((*twiter)->getPhi()); + myTower->setEt((*twiter)->getEt()); + list &twparts = *((*twiter)->getParticles()); + for (list::const_iterator partiter = twparts.begin(); + partiter != twparts.end(); ++partiter) { + myTower->addParticle(*partiter); + } + delete &twparts; + jet->addTower(myTower); + } + jet->calculateValues(); + fEvoutevent->addJet(jet); + } + fEvoutevent->sortJets(); + + if (fEvouttree) + fEvouttree->Fill(); + delete jet; + delete myTower; + } +#ifdef DOHISTOS + writeEventHistos(); +#endif +} + +void AliTkConeJetFinderV2::finish() +{ + if ((fEvoutfile) && (fEvoutfile->IsOpen())) { + fEvoutfile->cd(); + fEvouttree->Write(); + fEvoutfile->Close(); + } + +#ifdef DOHISTOS + writeHistos(); + fHistFile->Close(); +#endif +} + +void AliTkConeJetFinderV2::createTowers() +{ + if(fOutput) cout << "Creating " << fNTowers << " tower" << endl; + if (fPhiMax > fPhiMin) { + fPhiWidth = (fPhiMax-fPhiMin)/(Float_t)fPhiBins; + } else { + fPhiWidth = (fPhiMin-fPhiMax)/(Float_t)fPhiBins; + } + if (fEtaMax > fEtaMin) { + fEtaWidth = (fEtaMax-fEtaMin)/(Float_t)fEtaBins; + } else { + fEtaWidth = (fEtaMin-fEtaMax)/(Float_t)fEtaBins; + } + if(fOutput) cout << "Delta(eta)=" << fEtaWidth << " Delta(phi)=" << fPhiWidth << endl; + + // let's create the container + fTowers = new vector(fNTowers); + + // set tower boundaries... + Float_t eta = fEtaMin; + Float_t phi = fPhiMin; + for (Int_t e = 0; e < fEtaBins; e++) { + for (Int_t p = 0; p < fPhiBins; p++) { + Int_t tower = e*fPhiBins + p; + (*fTowers)[tower].setPhiMin(phi); + (*fTowers)[tower].setPhiMax(phi + fPhiWidth); + (*fTowers)[tower].setPhi(phi + fPhiWidth/2.); + (*fTowers)[tower].setEtaMin(eta); + (*fTowers)[tower].setEtaMax(eta + fEtaWidth); + (*fTowers)[tower].setEta(eta + fEtaWidth/2.); + + phi += fPhiWidth; + } + eta += fEtaWidth; + phi = fPhiMin; + } +} + +void AliTkConeJetFinderV2::fillTowersFromTParticles(const TClonesArray *particles) +{ + // input TClonesArray with TParticles, e.g. from PYTHIA + // fills the Et grid from these particles + if (!particles) { + return; + } + + // loop over all particles... + TParticle *particle = NULL; + TIterator *iter = particles->MakeIterator(); + while ((particle = (TParticle *) iter->Next()) != NULL) { + // check if particle is accepted + if (1) { //isTParticleAccepted(particle)) { + Float_t pt=particle->Pt(); + if(ptPhi(),particle->Eta()); + if (tower >= 0) { + (*fTowers)[tower] += particle; +#ifdef DOHISTOS + // calculate Et for a massless particle... + // idea for Et check: Et = E *sin(theta); + Float_t Et = TMath::Sqrt(pt*pt); + // just as check - fill particle Et in histogram + ((TH2F *)fEventHistos.At(1))->Fill(particle->Eta(),particle->Phi(),Et); +#endif + } + } + } + delete iter; +} + +#ifdef ALICEINTERFACE +void AliTkConeJetFinderV2::fillTowersFromAliParticles(const TClonesArray *particles) +{ + // input TClonesArray with AliParticles + // fills the Et grid from these particles + if (!particles) { + return; + } + + if(fAliParticles) fAliParticles->Clear(); + else fAliParticles=new TClonesArray("TParticle",0); + fAliParticles->Expand(particles->GetEntriesFast()); + + // loop over all particles... + AliJetParticle *aliparticle = NULL; + TIterator *iter = particles->MakeIterator(); + + Int_t i=0; + //Float_t meanet=0,totet=0; + while ((aliparticle = (AliJetParticle *) iter->Next()) != NULL) { + Float_t pt=aliparticle->Pt(); + if(ptPx(),aliparticle->Py(), + aliparticle->Pz(),aliparticle->Energy(),0,0,0,0); + //mark particle (-123 for Pythia) + particle->SetWeight(aliparticle->GetType()); + Int_t tower = findTower(particle->Phi(),particle->Eta()); + if (tower >= 0) { + (*fTowers)[tower] += particle; + //meanet+=pt;totet+=pt; +#ifdef DOHISTOS + // calculate Et for a massless particle... + // idea for Et check: Et = E *sin(theta); + Float_t Et = TMath::Sqrt(particle->Pt()*particle->Pt()); + // just as check - fill particle Et in histogram + ((TH2F *)fEventHistos.At(1))->Fill(particle->Eta(),particle->Phi(),Et); +#endif + } + i++; + } + delete iter; + //cout << "Mean particle " << meanet/i << " " << totet << endl; +} + +#endif + +inline Int_t AliTkConeJetFinderV2::findTower(Float_t phi,Float_t eta) +{ + if ((phi < fPhiMin) || (phi > fPhiMax) || + (eta < fEtaMin) || (eta > fEtaMax)) { + return -1; + } + Int_t phibins = (Int_t) ((phi - fPhiMin) / fPhiWidth); + Int_t etabins = (Int_t) ((eta - fEtaMin) / fEtaWidth); + return (etabins * fPhiBins + phibins); +} + +void AliTkConeJetFinderV2::createSeedPoints() +{ + // function should decide if it makes sense + // to use fEtCut for seed towers + // + midpoints or simply tower list + // uses only tower list so far... + +#if 0 + Float_t met=0.;Float_t set=0.; + Int_t counter=0; + for(vector::iterator iter = fTowers->begin(); + iter != fTowers->end(); ++iter) { + met+=iter->getEt(); + set+=iter->getEt()*iter->getEt(); + counter++; + } + if(counter>1){ + met/=counter; + set=set/counter-met*met; + if(set>0) set=TMath::Sqrt(set)/(counter-1); + else set=0; + if(fOutput) cout << "Tower Mean Et: " << met << "+-" << set << " " << counter << endl; + } + Float_t meanEt=met-set; //store mean tower et + + for(vector::iterator pos = fTowers->begin(); + pos != fTowers->end(); ++pos) { + if(pos->getEt()clear(); + } + } +#endif + + for(vector::iterator iter = fTowers->begin(); + iter != fTowers->end(); ++iter) { + if(iter->getEt()>fEtCut){ + AliTkEtaPhiVector seedPoint((*iter).getEta(),(*iter).getPhi()); + fSeedPointsNew.push_back(seedPoint); + } + } + if(fOutput) cout << "created " << fSeedPointsNew.size() << " seed points" << endl; +} + +void AliTkConeJetFinderV2::findProtojets() +{ + const Float_t radiusSq = fRadius*fRadius; + const Int_t maxIterations = 100; + const Bool_t geoCut = kTRUE; + const Float_t geoCutRadiusSq = 2*(fPhiWidth*fPhiWidth + fEtaWidth*fEtaWidth); + + // loop over all seedpoints + for(list::iterator iter = fSeedPointsNew.begin(); + iter != fSeedPointsNew.end(); ++iter) { + // create a new protojet at seedpoint position + protojet *pj = new protojet(); + pj->setCentroidPosition(*iter); + // loop over all towers and add all within "radius" to the protojet... + for (vector::iterator tower = fTowers->begin(); + tower != fTowers->end(); ++tower) { + if(tower->getEt()<=0) continue; + AliTkEtaPhiVector TwCenter((*tower).getEta(),(*tower).getPhi()); + AliTkEtaPhiVector protojetCenter(pj->getCentroidPosition()); + if (TwCenter.diffSq(protojetCenter) < radiusSq) { + pj->addTower(&(*tower)); + } + } + //update mean values + pj->update(); + // have added all towers within "radius" to protojet... + // iterate seedpoint until stable + // lets get the pT-weigthed center of the protojet... + AliTkEtaPhiVector centerGeo = pj->getCentroidPosition(); + AliTkEtaPhiVector centerEt = pj->getEtWeightedPosition(); + Int_t iteration = 0; + Bool_t wasGeoCut = kFALSE; + while ((centerGeo.diffSq(centerEt) > __epsilon__) && + (iteration < maxIterations)) { + iteration++; + pj->eraseTowers(); + pj->setCentroidPosition(centerEt); + centerGeo = pj->getCentroidPosition(); + + // if geoCut == kTRUE, break if it leaves original bin... + if ((geoCut == kTRUE) && + ((*iter).diffSq(centerGeo) > geoCutRadiusSq)) { + wasGeoCut = kTRUE; + break; + } + // loop over all towers and add all within "radius" to the protojet... + for (vector::iterator tower = fTowers->begin(); + tower != fTowers->end(); ++tower) { + if(tower->getEt()<=0) continue; + AliTkEtaPhiVector TwCenter((*tower).getEta(),(*tower).getPhi()); + if (TwCenter.diffSq(centerEt) < radiusSq) { + pj->addTower(&(*tower)); + } + } + // have added all towers within "radius" to protojet... + centerEt = pj->getEtWeightedPosition(); + } + + // we have a stable protojet (or run out of iterations...) +#if 0 + if((fOutput) &&(iteration==maxIterations)) + cout << " FindProtojets warning: max iterations of " + << maxIterations << " reached !!!" << endl; +#endif + // let's add it to the protojet list... + if (!wasGeoCut) { + addProtojet(pj); + } else { + delete pj; + } + } + //if(fOutput) cout << "found " << fProtojets.size() << "proto jets" << endl; +} + +void AliTkConeJetFinderV2::addProtojet(protojet *pj) +{ + if (!pj) { + return; + } + for(list::const_iterator iter = fProtojets.begin(); + iter != fProtojets.end(); ++iter) { + if ((*pj) == (*(*iter))) { + delete pj; + return; + } + } + fProtojets.push_back(pj); +} + +void AliTkConeJetFinderV2::dumpProtojets(Float_t etmin) +{ + for(list::const_iterator iter = fProtojets.begin(); + iter != fProtojets.end(); ++iter) { + if ((*iter)->getEt() > etmin) { + cout << (*(*iter)) << endl; + } + } +} + +void AliTkConeJetFinderV2::findJets() +{ + // loop over all protojets until list is empty + while(!fProtojets.empty()) { + // find the protojet with maximum Et + // should be easy to have a sorted list... + list::iterator maxEtProtojet = NULL; + maxEtProtojet = fProtojets.begin(); + Float_t maxEt = 0; + for (list::iterator iter = fProtojets.begin(); + iter != fProtojets.end(); ++iter) { + if ((*iter)->getEt() > maxEt) { + maxEt = (*iter)->getEt(); + maxEtProtojet = iter; + } + } + // we've found the protojet with the highest Et - remove it from the list + protojet *jet1 = *maxEtProtojet; + fProtojets.erase(maxEtProtojet); + // loop again over all protojets to find sharing jet with highest Et + list::iterator maxEtNeighbor = NULL; + maxEt = 0; + for (list::iterator iter = fProtojets.begin(); + iter != fProtojets.end(); ++iter) { + if (((*iter)->getEt() > maxEt) && + (jet1->shareTowers(*iter))) { + maxEt = (*iter)->getEt(); + maxEtNeighbor = iter; + } + } + if (maxEtNeighbor != NULL) { + // jet's share towers + // merging splitting step... + protojet *jet2 = (*maxEtNeighbor); + fProtojets.erase(maxEtNeighbor); + splitMergeJets(jet1,jet2); + } else { + // protojet 1 doesn't share towers with other protojets, make it a jet... + addJet(jet1); + } + } + if(fOutput){ + cout << "found " << fJets.size() << " jets" << endl; + dumpJets(); + } +} + +void AliTkConeJetFinderV2::splitMergeJets(protojet *jet1,protojet *jet2) +{ + const Float_t EtRatioCut = 0.5; + + // let's calcualte the shared energy... + Float_t fEtShared = 0.0; + list sharedTowers = jet1->getSharedTowerList(jet2); + for (list::const_iterator iter = sharedTowers.begin(); + iter != sharedTowers.end(); ++iter) { + fEtShared += (*iter)->getEt(); + } + Float_t fEtJet2 = jet2->getEt(); + // calculate the ratio of the shared energy and decided if split or merge + Float_t fEtRatio = EtRatioCut + 1.; + if(fEtJet2) fEtRatio = fEtShared / fEtJet2; + if (fEtRatio > EtRatioCut) { + mergeJets(jet1,jet2); + } else { + splitJets(jet1,jet2); + } +} + +void AliTkConeJetFinderV2::mergeJets(protojet *jet1,protojet *jet2) { + // merge protojets... + list jet2Towers = jet2->getTowerList(); + for (list::const_iterator iter = jet2Towers.begin(); + iter != jet2Towers.end(); ++iter) { + // add towers from protojet2 to protojet1... + // don't add shared towers... + if (!jet1->hasTower((*iter))) { + jet1->addTower((*iter)); + } + } + addProtojet(jet1); + delete jet2; +} + +void AliTkConeJetFinderV2::splitJets(protojet *jet1,protojet *jet2) +{ + // split protojets... + list sharedTowers = jet1->getSharedTowerList(jet2); + for (list::const_iterator iter = sharedTowers.begin(); + iter != sharedTowers.end(); ++iter) { + // search nearest jet + if (jet1->diffToCenter(*iter) < jet2->diffToCenter(*iter)) { + // tower closer to jet1 + jet2->eraseTower(*iter); + } else { + // tower closer to jet2 + jet1->eraseTower(*iter); + } + } + if (jet1->shareTowers(jet2)) { + cerr << "!!! SplitJets: Something is wrong !!!" << endl; + addProtojet(jet1); + delete jet2; + return; + } + addProtojet(jet1); + addProtojet(jet2); +} + +void AliTkConeJetFinderV2::dumpJets() +{ + cout << "----- found jets > " << fEtMinJet << " GeV -----" << endl; + for (list::const_iterator iter = fJets.begin(); + iter != fJets.end(); ++iter) { + if((*iter)->getEt()>fEtMinJet) cout << (*(*iter)) << endl; + } +} + +#ifdef DOHISTOS +void AliTkConeJetFinderV2::createHistos() +{ +} +#endif + +#ifdef DOHISTOS +void AliTkConeJetFinderV2::createEventHistos() +{ + fHistFile = new TFile("$JF_DATADIR/ConeFinderV2.root","RECREATE"); + TH2F *h = new TH2F("Etbins","Etbins", + fEtaBins,fEtaMin,fEtaMax, + fPhiBins,fPhiMin,fPhiMax); + h->GetXaxis()->SetTitle("#eta"); + h->GetYaxis()->SetTitle("#phi"); + h->GetZaxis()->SetTitle("E_{t} (GeV)"); + fEventHistos.Add(h); + + h = new TH2F("Etbin_check","Etbin_check", + fEtaBins,fEtaMin,fEtaMax, + fPhiBins,fPhiMin,fPhiMax); + h->GetXaxis()->SetTitle("#eta"); + h->GetYaxis()->SetTitle("#phi"); + h->GetZaxis()->SetTitle("E_{t} (GeV)"); + fEventHistos.Add(h); + + h = new TH2F("seedpoints","seedpoints", + fEtaBins,fEtaMin,fEtaMax, + fPhiBins,fPhiMin,fPhiMax); + h->GetXaxis()->SetTitle("#eta"); + h->GetYaxis()->SetTitle("#phi"); + fEventHistos.Add(h); +} +#endif +#ifdef DOHISTOS +void AliTkConeJetFinderV2::clearEventHistos() +{ + ((TH2F *)fEventHistos.At(0))->Reset(); + ((TH2F *)fEventHistos.At(1))->Reset(); + ((TH2F *)fEventHistos.At(2))->Reset(); +} +#endif + +#ifdef DOHISTOS +void AliTkConeJetFinderV2::writeEventHistos() +{ + fHistFile->cd(); + ((TH2F *)fEventHistos.At(0))->Write(); + ((TH2F *)fEventHistos.At(1))->Write(); + ((TH2F *)fEventHistos.At(2))->Write(); +} +#endif + +#ifdef DOHISTOS +void AliTkConeJetFinderV2::writeHistos() +{ +} +#endif + +#ifdef DOHISTOS +void AliTkConeJetFinderV2::fillTowerHist() +{ + for (vector::iterator i=(*fTowers).begin(); i!=(*fTowers).end(); ++i) { + tower t = *i; + Float_t eta = (t.getEtaMax() + t.getEtaMin()) / 2.; + Float_t phi = (t.getPhiMax() + t.getPhiMin()) / 2.; + ((TH2F *)fEventHistos.At(0))->Fill(eta,phi,t.getEt()); + } +} +#endif + +void AliTkConeJetFinderV2::setEvOutFilename(const Char_t *filename) +{ + if (!fEvout_name) { + fEvout_name = new Char_t[4096]; + } + + strcpy(fEvout_name,filename); +} + diff --git a/JETAN/AliTkConeJetFinderV2.h b/JETAN/AliTkConeJetFinderV2.h new file mode 100644 index 00000000000..fe3a9246102 --- /dev/null +++ b/JETAN/AliTkConeJetFinderV2.h @@ -0,0 +1,282 @@ +// $Id$ + +// Version 2 of my Cone Jet Finder +// improved storage (see also version 1) + +#ifndef ALITKCONJETFINDERV2_H +#define ALITKCONJETFINDERV2_H + +#include +#include +#include + +// helper classes +class tower { + + public: + tower(); + tower(const tower& t); + tower(Float_t phimin, Float_t phimax, Float_t etamin, Float_t etamax); + ~tower(); + + tower& operator+=(const Float_t E); + tower& operator+=(const TParticle *part); + + Float_t getEtaMin() const {return fEta_min;} + Float_t getEtaMax() const {return fEta_max;} + Float_t getEta() const {return fEta_center;} + Float_t getPhiMin() const {return fPhi_min;} + Float_t getPhiMax() const {return fPhi_max;} + Float_t getPhi() const {return fPhi_center;} + Float_t getEt() const {return fEt;} + Float_t getEtaWidth() const {return (fEta_max-fEta_min);} + Float_t getPhiWidth() const {return (fPhi_max-fPhi_min);} + + void setEtaMin(Float_t f) {fEta_min=f;} + void setEtaMax(Float_t f) {fEta_max=f;} + void setEta(Float_t f) {fEta_center=f;} + void setPhiMin(Float_t f) {fPhi_min=f;} + void setPhiMax(Float_t f) {fPhi_max=f;} + void setPhi(Float_t f) {fPhi_center=f;} + + void addParticle(const TParticle* part) {fParticles.push_back(part);} + void clearParticles() {fParticles.erase(fParticles.begin(),fParticles.end());} + void clear() {fEt = 0; clearParticles();} + + list *getParticles(); + + private: + Float_t fEta_min; + Float_t fEta_max; + Float_t fEta_center; + Float_t fPhi_min; + Float_t fPhi_max; + Float_t fPhi_center; + Float_t fEt; + + list fParticles; +}; + +ostream& operator<<(ostream& s,const tower& t); + +//----------------------------------------------------- + +#include "AliTkEtaPhiVector.h" + +class protojet { + + public: + protojet(); + protojet(const protojet& p); + protojet(const protojet *p); + ~protojet(){eraseTowers();} + + Float_t Eta() const {return fCentroid.Eta();} + Float_t Phi() const {return fCentroid.Phi();} + Float_t getEt() const { + if(fUpdate) cerr << "Eta update needed" << endl; + return fEt; + } + Float_t getEt() { + if(fUpdate) update(); + return fEt; + } + + Int_t getNTowers() const { return fTowers.size(); } + + void setCentroidPosition(AliTkEtaPhiVector center) {fCentroid = center;} + + AliTkEtaPhiVector getCentroidPosition() const { + return fCentroid; + } + AliTkEtaPhiVector getEtWeightedPosition() const { + if(fUpdate) cerr << "Weighted update needed" << endl; + return fEtWeightedCentroid; + } + AliTkEtaPhiVector getEtWeightedPosition() { + if(fUpdate) update(); + return fEtWeightedCentroid; + } + + void addTower(tower *tower) {fTowers.push_back(tower);fUpdate=kTRUE;} + void eraseTowers() {fTowers.erase(fTowers.begin(),fTowers.end()); } + void eraseTower(tower *pTower) {fTowers.remove(pTower);} + void clear(){eraseTowers();} + + list getTowerList() const; + list getSharedTowerList(const protojet *other) const; + + bool hasTower(tower *pTower) const; + bool shareTowers(const protojet *other) const; + Float_t diffToCenter(tower *pTower) const; + bool operator<(const protojet &p1) const {return (getEt() < p1.getEt());} + bool operator==(const protojet &p1); + void update(); + + private: + AliTkEtaPhiVector fCentroid; + AliTkEtaPhiVector fEtWeightedCentroid; + Float_t fEt; + Bool_t fUpdate; + list fTowers; +}; + +ostream& operator<<(ostream& s,const protojet& p); + +//----------------------------------------------------- +// Real ConeJetFinderClass +//----------------------------------------------------- + +#include +#include +#include +#include +#include "AliTkConeJet.h" +#include "AliTkConeJetEvent.h" +#ifdef ALICEINTERFACE +#include +#endif + +//if defined produce some debugging histos +//#define DOHISTOS + +class AliTkConeJetFinderV2 : public TObject { + public: + // constructor + AliTkConeJetFinderV2(); + virtual ~AliTkConeJetFinderV2(); + + // run control + void defaultSettings(); + void setSettings(Int_t phibins,Int_t etabins); + void setEtMinJet(Float_t et){fEtMinJet=et;} //minimum jet energy required + void setEtCut(Float_t et){fEtCut=et;} //min et for seedpoints + void setPtCut(Float_t pt){fPtCut=pt;} //set pt cut + void setOutput(Bool_t out){fOutput=out;} + void setRadius(Float_t r=0.7) {fRadius=r;} + + void init(); + void initEvent(const TClonesArray *particles,Int_t type); + void initEvent(const TClonesArray *particles,Int_t type,TString desc); + void run(); + void finishEvent(); + void finish(); + + // real physics functions... + void createTowers(); + void fillTowersFromTParticles(const TClonesArray *particles); +#ifdef ALICEINTERFACE + void fillTowersFromAliParticles(const TClonesArray *particles); + void initEvent(const AliJetEventParticles *p,TString desc); +#endif + + void createSeedPoints(); + void findProtojets(); + void findJets(); + +#ifdef DOHISTOS + // analysis functions... + void createHistos(); + void createEventHistos(); + void clearEventHistos(); + void writeEventHistos(); + void writeHistos(); +#endif + + // evout function + void setEvOutFilename(const Char_t *filename); + Char_t *getEvOutFilename() {return fEvout_name;} + + void addProtojet(protojet *pj); + void dumpProtojets(Float_t etmin = 5.0); + + void splitMergeJets(protojet *jet1, protojet *jet2); + void splitJets(protojet *jet1,protojet *jet2); + void mergeJets(protojet *jet1,protojet *jet2); + void addJet(protojet *pj) {fJets.push_back(pj);} + void dumpJets(); + + Bool_t isJetEnergy(Float_t min,Float_t max); + Float_t maxJetEnergy(); //of protojets (before calling finishEvent) + AliTkConeJetEvent* getEvent() const {return fEvoutevent;} + + //getters + Bool_t getOutput() const {return fOutput;} + Int_t getNTowers() const {return fNTowers;} + Int_t getNEtaBins() const {return fEtaBins;} + Float_t getEtaMin() const {return fEtaMin;} + Float_t getEtaMax() const {return fEtaMax;} + Float_t getEtaWidth() const {return fEtaWidth;} + Int_t getPhiBins() const {return fPhiBins;} + Float_t getPhiMin() const {return fPhiMin;} + Float_t getPhiMax() const {return fPhiMax;} + Float_t getPhiWidth() const {return fPhiWidth;} + Float_t getEtCut() const {return fEtCut;}; + Float_t getPtCut() const {return fPtCut;}; + Float_t getEtMinJet() const {return fEtMinJet;} + Float_t getRadius() const {return fRadius;} + + protected: + void initEvent_(const TClonesArray *particles,Int_t type); + void fillTowerHist(); + Int_t findTower(Float_t phi, Float_t eta); + Bool_t isTParticleAccepted(TParticle *particle); + + Bool_t fOutput; //outpug some information if true + Int_t fNTowers; //# of towers + Int_t fEtaBins; //eta-phi grid + Float_t fEtaMin; + Float_t fEtaMax; + Float_t fEtaWidth; + Int_t fPhiBins; + Float_t fPhiMin; + Float_t fPhiMax; + Float_t fPhiWidth; + Float_t fEtCut; // cut for seedpoints + Float_t fEtMinJet; // cut for jets + Float_t fPtCut; // cut for particles + Float_t fRadius; + + //towers, seeds, protojets and jets + vector *fTowers; //! + list fSeedPointsNew; //! + list fProtojets; //! + list fJets; //! + + //store results + TFile *fEvoutfile; //! + Char_t *fEvout_name; //! + AliTkConeJetEvent *fEvoutevent; //! + TTree *fEvouttree; //! + +#ifdef ALICEINTERFACE + TClonesArray *fAliParticles; //! +#endif + +#ifdef DOHISTOS + //histograms + TObjArray fHistos; + TObjArray fEventHistos; + TFile *fHistFile; //! +#endif + + ClassDef(AliTkConeJetFinderV2,1) +}; + +inline Bool_t AliTkConeJetFinderV2::AliTkConeJetFinderV2::isTParticleAccepted(TParticle *particle) +{ + // check if particle is accepted + // makes sense to write this into a own class, but now I'm lazy + + // check if particle is stable -> a detectable particle +#ifndef ALICEINTERFACE + if (particle->GetStatusCode()%100 != 1) { + return kFALSE; + } +#endif + + // default case: accept + return kTRUE; +} + +#endif diff --git a/JETAN/AliTkEtaPhiVector.cxx b/JETAN/AliTkEtaPhiVector.cxx new file mode 100644 index 00000000000..9e5c18440f2 --- /dev/null +++ b/JETAN/AliTkEtaPhiVector.cxx @@ -0,0 +1,15 @@ +// $Id$ +//-------------------------------------------------------------------------- +// implementation of the AliTkEtaPhiVector class +//-------------------------------------------------------------------------- + +#include +#include +#include +#include +#include "AliTkChargedJet.h" +#include "AliTkEtaPhiVector.h" + +ostream& operator<<(ostream& s, const AliTkEtaPhiVector& v) { + return s << "eta=" << v.Eta() << " phi=" << v.Phi(); +} diff --git a/JETAN/AliTkEtaPhiVector.h b/JETAN/AliTkEtaPhiVector.h new file mode 100644 index 00000000000..a55401caa1a --- /dev/null +++ b/JETAN/AliTkEtaPhiVector.h @@ -0,0 +1,59 @@ +// $Id$ + +#ifndef ALITKETAPHIVECTOR_H +#define ALITKETAPHIVECTOR_H + +#include + +class AliTkEtaPhiVector { + // simple class to store a vector in eta-phi space + // some subroutines to calculate distance to another vector + public: + AliTkEtaPhiVector() {fX = -9999; fY = -9999;} + AliTkEtaPhiVector(Double_t x0, Double_t y0) {fX = x0; fY = y0; } + AliTkEtaPhiVector(const AliTkEtaPhiVector& v) {fX=v.Eta(); fY=v.Phi();} + + Double_t Eta() const {return fX;} + Double_t Phi() const {return fY;} + + void setEta(Float_t eta) {fX = eta;} + void setPhi(Float_t phi) {fY = phi;} + void setVector(Float_t eta, Float_t phi) { + fX =eta; + fY = phi; + } + + // returns the square difference between the vectors in phi + Double_t phiDiffSq(AliTkEtaPhiVector& other) + { + Double_t phiDiff = TMath::Abs(fY-other.Phi()); + if(phiDiff>TMath::Pi()) phiDiff=2*TMath::Pi()-phiDiff; + return phiDiff*phiDiff; + } + // returns the difference between this vector and the other in phi + Double_t phiDiff(AliTkEtaPhiVector& other) + { + Double_t phiDiff = TMath::Abs(fY-other.Phi()); + if(phiDiff>TMath::Pi()) phiDiff=2*TMath::Pi()-phiDiff; + return phiDiff; + } + // returns the difference between the vectors in eta + Double_t etaDiff(AliTkEtaPhiVector& other) + {return (fX - other.Eta());} + // returns the square of the difference between the vectors in eta + Double_t etaDiffSq(AliTkEtaPhiVector& other) + {return (fX - other.Eta())*(fX - other.Eta());} + // returns the difference between the vectors in eta-phi + Double_t diff(AliTkEtaPhiVector& other) + {return sqrt(diffSq(other));} + // returns the square of the difference between the vectors in eta-phi + Double_t diffSq(AliTkEtaPhiVector& other) + {return (etaDiffSq(other) + phiDiffSq(other));} + + private: + Double_t fX; + Double_t fY; +}; + +ostream& operator<<(ostream& s, const AliTkEtaPhiVector& v); +#endif diff --git a/JETAN/AliTkHijingAna.cxx b/JETAN/AliTkHijingAna.cxx new file mode 100644 index 00000000000..008e1204253 --- /dev/null +++ b/JETAN/AliTkHijingAna.cxx @@ -0,0 +1,230 @@ +// $Id$ + +#include +#include +#include +#include + +#include "AliTkChargedJetFinder.h" +#include "AliTkHijingAna.h" + +void AliTkHijingAna::setCenter(Float_t eta, Float_t phi) { + center.setEta(eta); + center.setPhi(phi); + // new center makes particle list invalid + clearCone(); +} + +Float_t AliTkHijingAna::getCenterEta() const { + return center.Eta(); +} + +Float_t AliTkHijingAna::getCenterPhi() const { + return center.Phi(); +} + +Bool_t AliTkHijingAna::isParticleInRadius(TParticle *particle,Float_t radius) { + AliTkEtaPhiVector p(particle->Eta(),particle->Phi()); + if (center.diff(p) < radius) { + return kTRUE; + } else { + return kFALSE; + } +} + +Bool_t AliTkHijingAna::isParticleAccepted(TParticle *particle,Float_t pt,Bool_t neutral) { + + //check if particle was final + UInt_t status = 0; + status = (particle->GetStatusCode() % 100); + if (status != 1) { + return kFALSE; + } + + // if !neutral accept only charged particles, else accept everything + if(particle->Pt()GetPDG(); + if (partPDG->Charge() == 0) { + return kFALSE; + } + } + + return kTRUE; +} + +Bool_t AliTkHijingAna::isParticleAcceptedALICE(TParticle *particle,Float_t /*pt*/,Bool_t /*neutral*/) { + // fake ALICE acceptance, only particles in |eta|<0.9 + + if (/*(isParticleAccepted(particle,pt,neutral)) &&*/ (TMath::Abs(particle->Eta()) < 0.9)) { + return kTRUE; + } + + return kFALSE; +} + +void AliTkHijingAna::clear() { + // clear TClonesArrays + if (oParticles) { + oParticles->Delete(); + delete oParticles; + oParticles = NULL; + } + if (mParticles) { + mParticles->Delete(); + delete mParticles; + mParticles = NULL; + } + mRadius = -1; + updated = kFALSE; +} + +void AliTkHijingAna::clearCone() { + if (mParticles) { + mParticles->Delete(); + delete mParticles; + mParticles = NULL; + } + mRadius = -1; + updated = kFALSE; +} + +void AliTkHijingAna::setParticles(TClonesArray *particles) { + // take particles and dont apply any further cuts + if (!particles) { + return; + } + + clear(); + oParticles = new TClonesArray("TParticle",100000); + TIterator *iter = particles->MakeIterator(); + TParticle *particle; + UInt_t pos = 0; + while ((particle = (TParticle *) iter->Next()) != NULL) { + new ((*oParticles)[pos++]) TParticle(*particle); + } + delete iter; + +} + +void AliTkHijingAna::setParticles(TClonesArray *particles,Float_t pt,Bool_t neutral) { + // we are only interested in (charged) particles, to reduce computing time + // create a copy which contains only the charged particles + if (!particles) { + return; + } + // new particle list makes old one invalid... + clear(); + oParticles = new TClonesArray("TParticle",100000); + TIterator *iter = particles->MakeIterator(); + TParticle *particle; + UInt_t pos = 0; + while ((particle = (TParticle *) iter->Next()) != NULL) { + if (isParticleAccepted(particle,pt,neutral)) { + new ((*oParticles)[pos++]) TParticle(*particle); + } + } + delete iter; +} + +TClonesArray *AliTkHijingAna::getParticlesInRadius(Float_t radius) { + return getParticlesInRadius(NULL,radius); +} + +TClonesArray *AliTkHijingAna::getParticlesInRadius(TClonesArray *particles, + Float_t radius) { + // this creates a TClonesArray with all charged particles in radius + // and ALICE acceptance + + // uses the list of all charged particles (if created) + // OR + // used a previous list if radius < mRadius + + if (updated && (mParticles != NULL) && (radius < mRadius)) { + particles = mParticles; + } else { + if (oParticles) { + particles = oParticles; + } + } + if (!particles) { + return NULL; + } + + mRadius = radius; + TClonesArray *MyParticles = new TClonesArray("TParticle",100000); + TParticle *particle; + + TIterator *iter = particles->MakeIterator(); + UInt_t pos = 0; + while ((particle = (TParticle *) iter->Next()) != NULL) { + if (/*isParticleAcceptedALICE(particle) &&*/ + isParticleInRadius(particle,mRadius)) { + new ((*MyParticles)[pos++]) TParticle(*particle); + } + } + + // clean up + delete iter; + if (mParticles) { + mParticles->Delete(); + delete mParticles; + } + mParticles = MyParticles; + updated = kTRUE; + + return mParticles; +} + +Int_t AliTkHijingAna::getNParticlesInRadius(Float_t ptCut) { + if (!updated) { + // must call getParticlesInRadius before! + return -1; + } + // returns number of particles in cone with pt>ptCut + TIterator *iter = mParticles->MakeIterator(); + TParticle *particle; + Int_t nPart = 0; + while ((particle = (TParticle *) iter->Next()) != NULL) { + if (particle->Pt() > ptCut) { + nPart++; + } + } + delete iter; + return nPart; +} + +Float_t AliTkHijingAna::getEtInRadius(Float_t ptCut) { + if (!updated) { + // must call getParticlesInRadius before! + return -1; + } + // returns Et in cone using massless particles with pT>ptCut + TIterator *iter = mParticles->MakeIterator(); + TParticle *particle; + Float_t Et = 0; + while((particle = (TParticle*) iter->Next()) != NULL) { + if (particle->Pt() > ptCut) { + Et += particle->Pt(); // assume massless particle... + } + } + delete iter; + return Et; +} + +Float_t AliTkHijingAna::getEtInRadius(TClonesArray *particles,Float_t radius) { + TIterator *iter = particles->MakeIterator(); + TParticle *particle; + Float_t Et = 0; + while((particle = (TParticle*) iter->Next()) != NULL) { + if (/*isParticleAccepted(particle) &&*/ + isParticleInRadius(particle,radius)) { + Et += particle->Pt(); // assume massless particle... + } + } + delete iter; + return Et; +} + + +ClassImp(AliTkHijingAna) diff --git a/JETAN/AliTkHijingAna.h b/JETAN/AliTkHijingAna.h new file mode 100644 index 00000000000..8a4c373035e --- /dev/null +++ b/JETAN/AliTkHijingAna.h @@ -0,0 +1,57 @@ +// $Id$ + +#ifndef ALITKHIJINGANA_H +#define ALITKHIJINGANA_H + +#include +#include +#include "AliTkEtaPhiVector.h" + +class AliTkHijingAna : public TObject { + public: + // how to use it: - call setCenter + // - call setParticles at beginning (not mandatory) + // - call getParticlesInRadius with maximum radius + // - call analysis functions + // - repeat last 2 steps with decreasing radia + + // center of cone + void setCenter(Float_t eta, Float_t phi); + Float_t getCenterEta() const; + Float_t getCenterPhi() const; + + // helper functions + Bool_t isParticleInRadius(TParticle *particle,Float_t radius); + Bool_t isParticleAccepted(TParticle *particle, Float_t pt=0.1, Bool_t neutral=kFALSE); + Bool_t isParticleAcceptedALICE(TParticle *particle, Float_t pt=0.1, Bool_t neutral=kFALSE); + void clear(); + void clearCone(); + + // functions to create local copies of particles + void setParticles(TClonesArray *particles); + void setParticles(TClonesArray *particles,Float_t pt,Bool_t neutral); + TClonesArray *getParticlesInRadius(Float_t radius); + TClonesArray *getParticlesInRadius(TClonesArray *particles, Float_t radius); + + // analysis functions + Int_t getNParticlesInRadius(Float_t ptCut); + Int_t getNParticlesInRadius() { return getNParticlesInRadius(0); } + Float_t getEtInRadius(Float_t ptCut); + Float_t getEtInRadius() { return getEtInRadius(0); } + + + //--- old stuff, don't use anymore + Float_t getEtInRadius(TClonesArray *particles,Float_t radius); + //--- end of old stuff + + private: + AliTkEtaPhiVector center; + TClonesArray *oParticles; + TClonesArray *mParticles; + Float_t mRadius; + Bool_t updated; + + ClassDef(AliTkHijingAna,0) +}; + +#endif diff --git a/JETAN/AliTkJetTrigger.cxx b/JETAN/AliTkJetTrigger.cxx new file mode 100644 index 00000000000..8507fb85273 --- /dev/null +++ b/JETAN/AliTkJetTrigger.cxx @@ -0,0 +1,331 @@ +// $Id$ + +/**************************************************************************** + * AliTkJetTrigger.cxx * + * Test version of jet-trigger, includes many analysis functions to tune * + * paramters * + * Thorsten Kollegger * + ***************************************************************************/ + +#include +#include +#include +#include +#include +#include +#include "AliTkChargedJetFinder.h" +#include "AliTkJetTriggerDecision.h" +#include "AliTkJetTriggerEvent.h" +#include "AliTkJetTrigger.h" + +void AliTkJetTrigger::init() { + // open file and create tree... + if (getEvOutFilename() != NULL) { + cout << "Writing events to " << getEvOutFilename() << endl; + mEvOutFile = new TFile(getEvOutFilename(),"RECREATE"); + mEvOutEvent = new AliTkJetTriggerEvent(); + mEvOutTree = new TTree("jetTrigger",""); + mEvOutTree->Branch("event","AliTkJetTriggerEvent",&mEvOutEvent,32000,99); + } +} + +void AliTkJetTrigger::initEvent() { + // can not be implemented, we need the particles... +} + +void AliTkJetTrigger::initEvent(TClonesArray *particles, Int_t type) { + setParticleType(type); + initEvent(particles); +} + +void AliTkJetTrigger::initEvent(TClonesArray *particles) { + const UInt_t mParticlesDefaultSize = getExpectedParticleNumber(); + // make a copy of all accepted particles + // just to be sure that they are not modified... + + clearParticles(); + if (!particles) { + return; + } + mParticles = new TClonesArray("TParticle",mParticlesDefaultSize); + TIterator *iter = particles->MakeIterator(); + TParticle *particle; + UInt_t pos = 0; + while ((particle = (TParticle *) iter->Next()) != NULL) { + if (isParticleAccepted(particle)) { + if(particle->Pt()>fParticleMinPt) + new ((*mParticles)[pos++]) TParticle(*particle); + } + } + delete iter; + createSeedPoints(); +} + +void AliTkJetTrigger::make() { + // fill the matrix containing trigger decision for all different cone radia, + // nParticles and PtThresholds... + // loop over all seedpoints... + cout << "generated " << seedPoints.size() << " seedpoints" << endl; + for (list::const_iterator seedIter = seedPoints.begin(); + seedIter != seedPoints.end(); ++seedIter) { + AliTkEtaPhiVector coneCenter(*seedIter); + for (list::const_iterator radiusIter = mConeRadia.begin(); + radiusIter != mConeRadia.end(); ++radiusIter) { + // get particles in cone + list *myParticles = getParticlesInCone(coneCenter, + *radiusIter); + // loop over all PtThresholds... + for (list::const_iterator PtThreshold =mConePtThreshold.begin(); + PtThreshold != mConePtThreshold.end(); ++PtThreshold) { + // loop over all nParticles thresholds... + for (list::const_iterator nParticles = mConeNParticles.begin(); + nParticles != mConeNParticles.end(); ++nParticles) { + // what's the decision??? + if (decide(myParticles,*PtThreshold,*nParticles)) { + AliTkJetTriggerDecision *d = new AliTkJetTriggerDecision(); + d->setConeRadius(*radiusIter); + d->setPtThreshold(*PtThreshold); + d->setNParticles(*nParticles); + mEvOutEvent->addDecision(d); + // new change, requires testing + delete d; + } + } // end of nParticle threshold loop + } // end of PtThreshold loop + myParticles->erase(myParticles->begin(),myParticles->end()); + delete myParticles; + } // end of cone radia loop + } // end of seed point loop +} + +void AliTkJetTrigger::finishEvent() { + // let's write out all triggered settings... + // not finish yet... + clearParticles(); + if (mEvOutFile) { + mEvOutTree->Fill(); + } + mEvOutEvent->clear(); + seedPoints.erase(seedPoints.begin(),seedPoints.end()); +} + +void AliTkJetTrigger::finish() { + // write object containing settings + // close file + if (mEvOutFile) { + if (!mEvOutFile->IsOpen()) { cerr << "WHAT?" << endl; } + mEvOutFile->cd(); + mEvOutTree->Write(); + mEvOutFile->Close(); + } +} + +void AliTkJetTrigger::setDefaults() { + fParticleMinPt=0; + fParticleMinPtSeed=1; + setParticleType(3); + addConeRadius(0.7); + addConeRadius(0.5); + addConeRadius(0.3); + addConeRadius(0.2); + addConeRadius(0.1); + addConeNParticles(1); + addConeNParticles(2); + addConeNParticles(3); + addConeNParticles(4); + addConeNParticles(5); + addConePtThreshold(1.); + addConePtThreshold(2.); + addConePtThreshold(3.); + addConePtThreshold(4.); + addConePtThreshold(5.); + + setEvOutFilename("$JF_DATADIR/trigger.evout.root"); + setExpectedParticleNumber(30000); +} + +void AliTkJetTrigger::setParticleType(Int_t type) { + mParticleType = type; + // current used particles types: + // 1 == TParticle from TPythia6 + // 2 == TParticle from THijing + // 3 == TParticle from TPythia6 + ALICE acceptance approximation + // 4 == TParticle from THijing + ALICE acceptance approximation +} + +void AliTkJetTrigger::addConeRadius(Float_t radius) { + mConeRadia.push_back(radius); +} + +void AliTkJetTrigger::addConeNParticles(UInt_t nParticles) { + mConeNParticles.push_back(nParticles); +} + +void AliTkJetTrigger::addConePtThreshold(Float_t ptThreshold) { + mConePtThreshold.push_back(ptThreshold); +} + +void AliTkJetTrigger::mixParticles(TClonesArray *particles, Int_t type) { + // mixes particles to the existing event + if (!mParticles) { + return; + } + if (!particles) { + return; + } + TParticle *particle = NULL; + UInt_t pos = 0; + pos = mParticles->GetLast()+1; + TIterator *iter = particles->MakeIterator(); + while ((particle = (TParticle *) iter->Next()) != NULL) { + if (isParticleAccepted(particle,type)) { + new ((*mParticles)[pos++]) TParticle(*particle); + } + } + delete iter; + // we need to generate new seedPoints... + seedPoints.erase(seedPoints.begin(),seedPoints.end()); + createSeedPoints(); +} + +void AliTkJetTrigger::createSeedPoints() { + TParticle *particle; + TIterator *iter = mParticles->MakeIterator(); + while ((particle = (TParticle *)iter->Next()) != NULL) { + // particles are checked for acceptance during initEvent, mixParticles + // if (isParticleAccepted(particle)) { + if (particle->Pt() > fParticleMinPtSeed) { + AliTkEtaPhiVector v(particle->Eta(),particle->Phi()); + seedPoints.push_back(v); + } + // } + } + delete iter; +} + +Bool_t AliTkJetTrigger::isParticleAccepted(TParticle *particle) { + return isParticleAccepted(particle,getParticleType()); +} + +Bool_t AliTkJetTrigger::isParticleAccepted(TParticle *particle, Int_t type) { + switch (type) { + case 1: + return isParticleAcceptedPythia(particle); + break; + case 2: + return isParticleAcceptedHijing(particle); + break; + case 3: + return isParticleAcceptedPythiaAliceGeo(particle); + break; + case 4: + return isParticleAcceptedHijingAliceGeo(particle); + break; + }; + return kFALSE; +} + +Bool_t AliTkJetTrigger::isParticleAcceptedPythia(TParticle *particle) { + // check for stable particle + if (particle->GetStatusCode() != 1) { + return kFALSE; + } + return kTRUE; +} + +Bool_t AliTkJetTrigger::isParticleAcceptedPythiaAliceGeo(TParticle *particle) { + // check if valid PYTHIA particle + if (!isParticleAcceptedPythia(particle)) { + return kFALSE; + } + // check if particle is in |eta| < 1 + if (TMath::Abs(particle->Eta()) > 1) { + return kFALSE; + } + // check if charged particle + TParticlePDG *partPDG = particle->GetPDG(); + if (partPDG->Charge() == 0) { + return kFALSE; + } + return kTRUE; +} + +Bool_t AliTkJetTrigger::isParticleAcceptedHijing(TParticle */*particle*/) { + return kTRUE; +} + +Bool_t AliTkJetTrigger::isParticleAcceptedHijingAliceGeo(TParticle *particle) { + if (!isParticleAcceptedHijing(particle)) { + return kFALSE; + } + // check if particle is in |eta| < 1 + if (TMath::Abs(particle->Eta()) > 1) { + return kFALSE; + } + // check if charged particle + TParticlePDG *partPDG = particle->GetPDG(); + if (partPDG->Charge() == 0) { + return kFALSE; + } + return kTRUE; +} + +void AliTkJetTrigger::clearParticles() { + // delete my particle copy... + if (mParticles) { + mParticles->Delete(); + delete mParticles; + } + mParticles = NULL; +} + +list *AliTkJetTrigger::getParticlesInCone(AliTkEtaPhiVector center, + Float_t radius) { + return getParticlesInCone(center,radius,mParticles); +} + +list *AliTkJetTrigger::getParticlesInCone(AliTkEtaPhiVector center, + Float_t radius, + TClonesArray *particles) { + // returns a list with all particles which are in a cone with radius around + // center + // one can easily speed up this part by saving the last cone+parameters and + // calculate the new one from this one if there is some overlap + list *myParticles = new list; + Float_t radiusSq = radius*radius; + TIterator *iter = particles->MakeIterator(); + TParticle *particle; + while ((particle = (TParticle *)iter->Next()) != NULL) { + AliTkEtaPhiVector pos(particle->Eta(),particle->Phi()); + if (center.diffSq(pos) < radiusSq) { + myParticles->push_back(particle); + } + } + delete iter; + return myParticles; +} + +Bool_t AliTkJetTrigger::decide(list *particles, Float_t ptThreshold, + UInt_t nParticles) { + UInt_t n = 0; + for (list::const_iterator iter = particles->begin(); + iter != particles->end(); ++iter) { + if ((*iter)->Pt() > ptThreshold) { + n++; + } + } + if (n >= nParticles) { + return kTRUE; + } + return kFALSE; +} + +void AliTkJetTrigger::setEvOutFilename(Char_t *filename) { + if (!mEvOutName) { + mEvOutName = new Char_t[4096]; + } + strcpy(mEvOutName,filename); +} + + +ClassImp(AliTkJetTrigger) diff --git a/JETAN/AliTkJetTrigger.h b/JETAN/AliTkJetTrigger.h new file mode 100644 index 00000000000..d435bdee243 --- /dev/null +++ b/JETAN/AliTkJetTrigger.h @@ -0,0 +1,95 @@ +// $Id$ + +/**************************************************************************** + * AliTkJetTrigger.h * + * Test version of jet-trigger, includes many analysis functions to tune * + * paramters * + * Thorsten Kollegger * + ***************************************************************************/ + +#ifndef TKJETTRIGGER_H +#define TKJETTRIGGER_H + +#include +#include +#include +#include "AliTkJetTriggerEvent.h" + +class AliTkJetTrigger : public TObject { + public: + AliTkJetTrigger() : TObject() { + mEvOutName=0; + setDefaults(); + } + virtual ~AliTkJetTrigger(){if(mEvOutName) delete[] mEvOutName;} + + void init(); + void initEvent(); + void initEvent(TClonesArray *particles, Int_t type); + void initEvent(TClonesArray *particles); + void make(); + void run() { make(); } + void finishEvent(); + void finish(); + + void setDefaults(); + void setEvOutFilename(Char_t *filename); + Char_t *getEvOutFilename() { return mEvOutName; } + + void setParticleType(Int_t type); + Int_t getParticleType() { return mParticleType; } + void addConeRadius(Float_t radius); + void addConeNParticles(UInt_t nParticles); + void addConePtThreshold(Float_t ptThreshold); + + void mixParticles(TClonesArray *particles, Int_t type); + + void setParticleMinPt(Float_t f){fParticleMinPt=f;} + void setParticleMinPtSeed(Float_t f){fParticleMinPtSeed=f;} + + void setExpectedParticleNumber(UInt_t n) {mExpectedNParticles = n; } + UInt_t getExpectedParticleNumber() { return mExpectedNParticles; } + + private: + + void createSeedPoints(); + + Bool_t isParticleAccepted(TParticle *particle); + Bool_t isParticleAccepted(TParticle *particle, Int_t type); + Bool_t isParticleAcceptedPythia(TParticle *particle); + Bool_t isParticleAcceptedPythiaAliceGeo(TParticle *particle); + Bool_t isParticleAcceptedHijing(TParticle *particle); + Bool_t isParticleAcceptedHijingAliceGeo(TParticle *particle); + + void clearParticles(); + + list *getParticlesInCone(AliTkEtaPhiVector center, Float_t radius); + list *getParticlesInCone(AliTkEtaPhiVector center, + Float_t radius, + TClonesArray *particles); + Bool_t decide(list *particles, Float_t ptThreshold, + UInt_t nParticles); + + Int_t mParticleType; + TClonesArray *mParticles; + UInt_t mExpectedNParticles; + + list seedPoints; + list mConeRadia; + list mConeNParticles; + list mConePtThreshold; + + Char_t *mEvOutName; //! + TFile *mEvOutFile; //! + TTree *mEvOutTree; //! + AliTkJetTriggerEvent *mEvOutEvent; //! + TObjArray *mDecisions; + + Float_t fParticleMinPt; + Float_t fParticleMinPtSeed; + + ClassDef(AliTkJetTrigger,0) +}; + + +#endif diff --git a/JETAN/AliTkJetTriggerDecision.cxx b/JETAN/AliTkJetTriggerDecision.cxx new file mode 100644 index 00000000000..0d1976df5c1 --- /dev/null +++ b/JETAN/AliTkJetTriggerDecision.cxx @@ -0,0 +1,11 @@ +// $Id$ + +#include "AliTkJetTriggerDecision.h" + +AliTkJetTriggerDecision::AliTkJetTriggerDecision(AliTkJetTriggerDecision &d):TObject() { + setConeRadius(d.getConeRadius()); + setPtThreshold(d.getPtThreshold()); + setNParticles(d.getNParticles()); +} + +ClassImp(AliTkJetTriggerDecision) diff --git a/JETAN/AliTkJetTriggerDecision.h b/JETAN/AliTkJetTriggerDecision.h new file mode 100644 index 00000000000..62c43998755 --- /dev/null +++ b/JETAN/AliTkJetTriggerDecision.h @@ -0,0 +1,28 @@ +// $Id$ + +#ifndef ALITKJETTRIGGERDECISION_H +#define ALITKJETTRIGGERDECISION_H + +#include + +class AliTkJetTriggerDecision : public TObject { + public: + AliTkJetTriggerDecision() : TObject(), mConeRadius(-999), mPtThreshold(-999), + mNParticles(0) { } + AliTkJetTriggerDecision(AliTkJetTriggerDecision &d); + + void setConeRadius(Float_t r) { mConeRadius = r; } + Float_t getConeRadius() { return mConeRadius; } + void setPtThreshold(Float_t pt) { mPtThreshold = pt; } + Float_t getPtThreshold() { return mPtThreshold; } + void setNParticles(UInt_t n) { mNParticles = n; } + UInt_t getNParticles() { return mNParticles; } + + private: + Float_t mConeRadius; + Float_t mPtThreshold; + UInt_t mNParticles; + + ClassDef(AliTkJetTriggerDecision,1) +}; +#endif diff --git a/JETAN/AliTkJetTriggerEvent.cxx b/JETAN/AliTkJetTriggerEvent.cxx new file mode 100644 index 00000000000..2483b10b59d --- /dev/null +++ b/JETAN/AliTkJetTriggerEvent.cxx @@ -0,0 +1,59 @@ +// $Id$ + +#include "AliTkJetTriggerEvent.h" + +AliTkJetTriggerEvent::AliTkJetTriggerEvent() : TObject() { + decisions = new TClonesArray("AliTkJetTriggerDecision",10000); + counter = 0; +} + +AliTkJetTriggerEvent::AliTkJetTriggerEvent(AliTkJetTriggerEvent &t) : TObject() { + counter = t.counter; + decisions = new TClonesArray("AliTkJetTriggerDecision",counter); + TIterator *iter = t.decisions->MakeIterator(); + UInt_t pos = 0; + AliTkJetTriggerDecision *dec; + while ((dec = (AliTkJetTriggerDecision *) iter->Next()) != NULL) { + new ((*decisions)[pos++]) AliTkJetTriggerDecision(*dec); + } +} + +void AliTkJetTriggerEvent::addDecision(AliTkJetTriggerDecision *d) { + // let's check if we have already a decision for this trigger configuration + TIterator *iter = decisions->MakeIterator(); + AliTkJetTriggerDecision *myDec; + while ((myDec = (AliTkJetTriggerDecision *) iter->Next()) != NULL) { + if ((d->getNParticles() == myDec->getNParticles()) && + (d->getConeRadius() == myDec->getConeRadius()) && + (d->getPtThreshold() == myDec->getPtThreshold())) { + delete iter; + return; + } + } + // we dont have a decision, let's add it... + new ((*decisions)[counter++]) AliTkJetTriggerDecision(*d); +} + +void AliTkJetTriggerEvent::clear() { + decisions->Delete(); + counter = 0; +} + +Bool_t AliTkJetTriggerEvent::isEventTriggered(Float_t coneRadius, + UInt_t nParticles, + Float_t ptThreshold) { + AliTkJetTriggerDecision *dec; + TIterator *iter = decisions->MakeIterator(); + while ((dec = (AliTkJetTriggerDecision *) iter->Next()) != NULL) { + if ((dec->getConeRadius() == coneRadius) && + (dec->getNParticles() == nParticles) && + (dec->getPtThreshold() == ptThreshold)) { + delete iter; + return kTRUE; + } + } + delete iter; + return kFALSE; +} + +ClassImp(AliTkJetTriggerEvent) diff --git a/JETAN/AliTkJetTriggerEvent.h b/JETAN/AliTkJetTriggerEvent.h new file mode 100644 index 00000000000..0a786e9e300 --- /dev/null +++ b/JETAN/AliTkJetTriggerEvent.h @@ -0,0 +1,28 @@ +// $Id$ + +#ifndef ALITKJETTRIGGEREVENT_H +#define ALITKJETTRIGGEREVENT_H + +#include +#include +#include +#include "AliTkJetTriggerDecision.h" + +class AliTkJetTriggerEvent : public TObject { + public: + AliTkJetTriggerEvent(); + AliTkJetTriggerEvent(AliTkJetTriggerEvent &t); + + void addDecision(AliTkJetTriggerDecision *d); + void clear(); + Bool_t isEventTriggered(Float_t coneRadius, UInt_t nParticles, + Float_t ptThreshold); + + TClonesArray *decisions; //-> + UInt_t counter; + + private: + + ClassDef(AliTkJetTriggerEvent,1) +}; +#endif diff --git a/JETAN/AliTkJetTriggerSettings.cxx b/JETAN/AliTkJetTriggerSettings.cxx new file mode 100644 index 00000000000..a30e40205fc --- /dev/null +++ b/JETAN/AliTkJetTriggerSettings.cxx @@ -0,0 +1,23 @@ +// $Id$ + +#include "AliTkJetTriggerSettings.h" + +AliTkJetTriggerSettings::AliTkJetTriggerSettings() : TObject() { + mConeRadia = new TArrayF(10); + mNParticles = new TArrayI(10); + mPtThresholds = new TArrayF(10); +} + +AliTkJetTriggerSettings::AliTkJetTriggerSettings(AliTkJetTriggerSettings &s) :TObject(s) { + mConeRadia = new TArrayF(*(s.getConeRadia())); + mNParticles = new TArrayI(*(s.getNParticles())); + mPtThresholds = new TArrayF(*(s.getPtThresholds())); +} + +AliTkJetTriggerSettings::~AliTkJetTriggerSettings() { + delete mConeRadia; + delete mNParticles; + delete mPtThresholds; +} + +ClassImp(AliTkJetTriggerSettings) diff --git a/JETAN/AliTkJetTriggerSettings.h b/JETAN/AliTkJetTriggerSettings.h new file mode 100644 index 00000000000..c2db099e2a7 --- /dev/null +++ b/JETAN/AliTkJetTriggerSettings.h @@ -0,0 +1,28 @@ +// $Id$ + +#ifndef ALITKJETTRIGGERSETTINGS_H +#define ALITKJETTRIGGERSETTINGS_H + +#include +#include +#include + +class AliTkJetTriggerSettings : public TObject { + public: + AliTkJetTriggerSettings(); + AliTkJetTriggerSettings(AliTkJetTriggerSettings &s); + ~AliTkJetTriggerSettings(); + + TArrayF *getConeRadia() { return mConeRadia; } + TArrayI *getNParticles() { return mNParticles; } + TArrayF *getPtThresholds() { return mPtThresholds; } + + private: + TArrayF *mConeRadia; //-> + TArrayI *mNParticles; //-> + TArrayF *mPtThresholds; //-> + + + ClassDef(AliTkJetTriggerSettings,1) +}; +#endif diff --git a/JETAN/AliTkKtJetFinder.cxx b/JETAN/AliTkKtJetFinder.cxx new file mode 100644 index 00000000000..8c02b7aef8f --- /dev/null +++ b/JETAN/AliTkKtJetFinder.cxx @@ -0,0 +1,459 @@ +// $Id$ + +// includes +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include "AliTkKtJetFinder.h" + +void AliTkKtJetFinder::init() { + DebugOutput("TkJetFinder::init() called"); + + cout << "TkJetFinder::init() - finder initialized" << endl; + cout << "precluster parameter:" << endl; + cout << " - phi binning: " << phiBins << " bins from " + << phiMin << " to " << phiMax << ", bin width " + << (phiMax-phiMin)/(Float_t)phiBins << endl; + cout << " - theta binning: " << thetaBins << " bins from " + << thetaMin << " to " << thetaMax << ", bin width " + << (thetaMax-thetaMin)/(Float_t)thetaBins << endl; + cout << "jetfinder parameter:" << endl; + cout << " - D:" << finder_D << endl + << " - D_Cut:" << finder_DCut << endl; + + DebugOutput("TkJetFinder::init() finished"); +} + +void AliTkKtJetFinder::makeTParticles(TClonesArray *particles) { + DebugOutput("TkJetFinder::makeTParticle() called"); + initEvent(); + preclusterTParticles(particles); + DebugOutput("TkJetFinder::makeTParticle() preclustering done"); + findJets(); + DebugOutput("TkJetFinder::makeTParticle() jetfinding done"); + DebugOutput("TkJetFinder::makeTParticle() finished"); +} + +void AliTkKtJetFinder::clear() { + DebugOutput("TkJetFinder::clear() called"); + + DebugOutput("TkJetFinder::clear() finished"); +} + +void AliTkKtJetFinder::finish() { + DebugOutput("TkJetFinder::finish() called"); + + DebugOutput("TkJetFinder::finish() finished"); +} + +void AliTkKtJetFinder::initEvent() { + DebugOutput("TkJetFinder::initEvent() called"); + + // clean precluster list + if (firstPreCluster) { + TPreCluster *act = firstPreCluster; + TPreCluster *next; + while (act != NULL) { + next = act->next; + delete act; + act = next; + } + } + + // delete precluster array + delete[] preClusterArray; + + // reset list + firstPreCluster = NULL; + lastPreCluster = NULL; + preClusterUID = 0; + preClusterArray = NULL; + + // delete dlist; + for (list::iterator i = myDList.begin(); i != myDList.end(); ++i) { + Tdlist *dlist = *i; + delete dlist; + dlist = NULL; + } + myDList.clear(); + + + DebugOutput("TkJetFinder::initEvent() finished"); +} + +void AliTkKtJetFinder::preclusterTParticles(TClonesArray *particles) { + Char_t buffer[1024]; + Int_t acceptedParticles = 0; + Int_t acceptedPreCluster = 0; + + DetailedOutput("TkJetFinder::preclusterTParticle() called"); + + TStopwatch timer; + timer.Reset(); + + sprintf(buffer,"TkJetFinder::preclusterTParticle() - found %d particles", + particles->GetEntries()); + DetailedOutput(buffer); + + cout << "WARNING - TkJetFinder::preclusterTParticle()" << endl + << " no preclustering implemented - each particle accepted!" + << endl; + + timer.Start(); + // start the particle loop + TIterator *iter = particles->MakeIterator(); + TParticle *particle; + TPreCluster *precluster; + while((particle = (TParticle *) iter->Next()) != NULL) { + if (isTParticleAccepted(particle)) { + acceptedParticles++; + precluster = new TPreCluster; + // to be kind of realistic use maseless particles + // - TPC doesn't measure energy and there is no hadron calorimeter... + precluster->id = preClusterUID; + precluster->E = TMath::Sqrt(particle->P()*particle->P()); + precluster->px = particle->Px(); + precluster->py = particle->Py(); + precluster->pz = particle->Pz(); + precluster->next = NULL; + if (true) { + // add precluster to list of preclusters + addPreCluster(precluster); + acceptedPreCluster++; + preClusterUID++; + } else { + delete precluster; + } + } + } + + // build an array of pointers for direct access on the precluster... + preClusterArray = new TPreCluster*[preClusterUID]; + precluster = firstPreCluster; + while (precluster) { + preClusterArray[precluster->id] = precluster; + precluster = precluster->next; + } + + timer.Stop(); + + // if you want to be really sure what the precluster algorithm does... + //dumpPreClusters(); + //dumpPreClusterArray(); + + // status information at the end... + sprintf(buffer,"TkJetFinder::preclusterTParticle() - used %d particles", + acceptedParticles); + DebugOutput(buffer); + sprintf(buffer, + "TkJetFinder::preclusterTParticle() - created %d preclusters", + acceptedPreCluster); + DebugOutput(buffer); + + sprintf(buffer, + "TkJetFinder::preclusterTParticle() - timing CPU: %f, real %f", + timer.CpuTime(),timer.RealTime()); + TimingOutput(buffer); + + cout << "some stupid tests..." << endl; + Tdlist *p1 = new Tdlist; + Tdlist *p2 = new Tdlist; + Tdlist *p3 = new Tdlist; + p1->d = 3; + p2->d = 2; + p3->d = 1; + if (p1==p2) { + cout << "p1==p2 (" << p1->d << "==" << p2->d << ")" << endl; + } else { + cout << "p1!=p2 (" << p1->d << "!=" << p2->d << ")" << endl; + } + if (p1 < p2) { + cout << "p1 < p2 (" << p1->d << ">" << p2->d << ")" << endl; + } else { + cout << "p1 > p2 (" << p1->d << "<" << p2->d << ")" << endl; + } + priority_queue myHeap; + myHeap.push(p2); + myHeap.push(p1); + myHeap.push(p3); + + cout << myHeap.size() << endl; + while (!myHeap.empty()) { + Tdlist *myEntry = myHeap.top(); + myHeap.pop(); + cout << "d = " << myEntry->d << endl; + delete myEntry; + } + + DetailedOutput("TkJetFinder::preclusterTParticle() finished"); +} + +void AliTkKtJetFinder::findJets() { + Char_t buffer[1024]; + + TStopwatch timer; + timer.Reset(); + + DetailedOutput("TkJetFinder::findJets() called"); + + timer.Start(); + // let's start... + buildNewDList(); + // find the precluster/pair with lowest dmin... + //list::iterator i; + list::iterator min; + + myDList.sort(); + while(!myDList.empty()) { + min = myDList.begin(); + + // we have the entry with the lowest min... + //cout << (*min)->d << endl; + delete *min; + myDList.erase(min); + } + + + timer.Stop(); + + sprintf(buffer, + "TkJetFinder::findJets() - timing CPU: %f, real %f", + timer.CpuTime(),timer.RealTime()); + TimingOutput(buffer); + + DetailedOutput("TkJetFinder::findJets() finish"); +} + +void AliTkKtJetFinder::setPhiBins(Int_t nPhiBins, + Float_t fPhiMin, Float_t fPhiMax) { + setNPhiBins(nPhiBins); + setPhiMin(fPhiMin); + setPhiMax(fPhiMax); +} + +void AliTkKtJetFinder::setThetaBins(Int_t nThetaBins, + Float_t fThetaMin, Float_t fThetaMax) { + setNThetaBins(nThetaBins); + setThetaMin(fThetaMin); + setThetaMax(fThetaMax); +} + + +void AliTkKtJetFinder::setDefaultOptions() { + // precluster options + setPhiBins((Int_t)(TMath::Pi()*2./0.1), 0. ,2.*TMath::Pi()); + setThetaBins(10,(TMath::Pi()/2. - 0.5),(TMath::Pi()/2. + 0.5)); + + // finder options + setD(1.); + setDCut(-1.); + + // debug options + setDebugLevel(0); + setDebugFilename("KtJetFinderDebug.root"); + + cout << "TkJetFinder::setDefaultOptions() - DEFAULT options set" << endl; +} + +Bool_t AliTkKtJetFinder::isTParticleAccepted(TParticle *particle) { + // check if particle is accepted + // makes sense to write this into a own class, but now I'm lazy + + // check if particle is stable -> a detectable particle + if (particle->GetStatusCode() != 1) { + return kFALSE; + } + // and now just for fun + TParticlePDG *partPDG; + partPDG = particle->GetPDG(); +// if (partPDG->Charge() == 0) { +// cout << partPDG->GetName() << endl; +// return kFALSE; +// } + + // default case: accept + return kTRUE; +} + +void AliTkKtJetFinder::addPreCluster(TPreCluster *precluster) { + if (firstPreCluster == NULL) { + firstPreCluster = precluster; + lastPreCluster = precluster; + return; + } + + lastPreCluster->next = precluster; + precluster->next = NULL; + lastPreCluster = precluster; +} + +void AliTkKtJetFinder::deletePreCluster(Int_t UID) { + TPreCluster *p1 = NULL; + TPreCluster *p2 = firstPreCluster; + while (p2!=NULL) { + if (p2->id == UID) { + p1->next = p2->next; + delete p2; + break; + } + p1 = p2; + p2 = p2->next; + } +} + +void AliTkKtJetFinder::dumpPreClusters() { + TPreCluster *pre = firstPreCluster; + while (pre) { + cout << "UID: " << pre->id + << " E: " << pre->E + << " px: " << pre->px + << " py: " << pre->py + << " pz: " << pre->pz + << " next: " << pre->next + << endl; + pre = pre->next; + } +} + +void AliTkKtJetFinder::dumpPreClusterArray() { + for (Int_t i = 0; i < preClusterUID; i++) { + cout << "UID: " << preClusterArray[i]->id + << " E: " << preClusterArray[i]->E + << " px: " << preClusterArray[i]->px + << " py: " << preClusterArray[i]->py + << " pz: " << preClusterArray[i]->pz + << " next: " << preClusterArray[i]->next + << endl; + } +} + +void AliTkKtJetFinder::addD(Tdlist *newD) { + myDList.push_back(newD); +} + +void AliTkKtJetFinder::buildNewDList() { + Char_t buffer[1024]; + + // step 1 - add all preclusters to dlist + struct Tdlist *dlist; + for (Int_t i = 0; i < preClusterUID; i++) { + dlist = new Tdlist; + dlist->d = calcD((TPreCluster *)preClusterArray[i]); + dlist->id1 = preClusterArray[i]->id; + dlist->id2 = -1; + dlist->prev = NULL; + dlist->next = NULL; + addD(dlist); + } + + sprintf(buffer, + "AliTkKtJetFinder::buildNewDList - added %d preclusters to new list", + (Int_t)myDList.size()); + DetailedOutput(buffer); + + // and now for all combinations... + for (Int_t i = 0; i < preClusterUID; i++) { + for (Int_t j = i + 1; j < preClusterUID; j++) { + if (i == j) { + // makes no sense... + continue; + } + dlist = new Tdlist; + dlist->d = calcD((TPreCluster *)preClusterArray[i], + (TPreCluster *)preClusterArray[j]); + dlist->id1 = preClusterArray[i]->id; + dlist->id2 = preClusterArray[j]->id; + dlist->prev = NULL; + dlist->next = NULL; + addD(dlist); + } + } + + sprintf(buffer, + "AliTkKtJetFinder::buildNewDList - created list with %d entries", + (Int_t)myDList.size()); + DetailedOutput(buffer); +} + +Float_t AliTkKtJetFinder::calcD(TPreCluster *p1, TPreCluster *p2) { + if (!p1) { + // something is wrong - we need a precluster + return -9999; + } + if (!p2) { + // called with one particle only + // return pT^2 + return (p1->px*p1->px + p1->py*p1->py); + } + // we have two particles... + // calculate the minimum pt... + Float_t pt1Sq = p1->px*p1->px + p1->py*p1->py; + Float_t pt2Sq = p2->px*p2->px + p2->py*p2->py; + Float_t ptMinSq; + if (pt1Sq < pt2Sq) { + ptMinSq = pt1Sq; + } else { + ptMinSq = pt2Sq; + } + // calculate rapidities - !move this into precluster structure!!! + Float_t y1 = 0.5 * TMath::Log((p1->E+p1->pz)/(p1->E-p1->pz)); + Float_t y2 = 0.5 * TMath::Log((p2->E+p2->pz)/(p2->E-p2->pz)); + // calculate phi - !move this into precluster structure!!! + Float_t phi1 = 0; + Float_t phi2 = 0; + // calculate ((y1-y2)^2 + (phi1-phi2)^2)/(D^2) + // !save D^2 instead of D to save time!!! + Float_t R = ((y1-y2)*(y1-y2) + (phi1-phi2)*(phi1-phi2))/(finder_D*finder_D); + + return ptMinSq * R; +} + +void AliTkKtJetFinder::setDebugLevel(Int_t nDebugLevel) { + debugLevel = nDebugLevel; + + // description of debug levels + // levels are additive!!! + // 0 -> no debug output - only normal output (default) + // 1 -> normal debug output + // major function calls, summary of major results + // 2 -> timing output + // timing information for major steps + // 4 -> detailed results + // output of much more results + // 8 -> result histos + // histograms of event results for internal consitency checks + // 16 -> timing histos + // histograms with timing info - not cleared per event! + // 32 -> write debug histos to file +} + +void AliTkKtJetFinder::DebugOutput(Char_t *output) { + if ((debugLevel & 1) == 1) { + cout << output << endl; + } +} + +void AliTkKtJetFinder::TimingOutput(Char_t *output) { + if ((debugLevel & 2) == 2) { + cout << output << endl; + } +} + +void AliTkKtJetFinder::DetailedOutput(Char_t *output) { + if ((debugLevel & 4) == 4) { + cout << output << endl; + } +} + + +ClassImp(AliTkKtJetFinder) diff --git a/JETAN/AliTkKtJetFinder.h b/JETAN/AliTkKtJetFinder.h new file mode 100644 index 00000000000..87ebf07074b --- /dev/null +++ b/JETAN/AliTkKtJetFinder.h @@ -0,0 +1,140 @@ +// $Id$ + +#ifndef ALITKKTJETFINDER_H +#define ALITKKTJETFINDER_H + +#include +#include +#include + +struct TPreCluster; +struct TPreCluster { + Int_t id; + Float_t E; + Float_t px; + Float_t py; + Float_t pz; + TPreCluster *next; +}; + +struct Tdlist; +struct Tdlist { + Float_t d; + Int_t id1; + Int_t id2; + Tdlist *prev; + Tdlist *next; + bool operator==(const Tdlist &p1) const {return (d==p1.d);} + bool operator<(const Tdlist &p1) const {return (d > p1.d);} +}; + +struct TJetList; +struct TJetList { + Float_t E; + Float_t px; + Float_t py; + Float_t pz; + TJetList *next; +}; + +class AliTkKtJetFinder : public TObject { + public: + AliTkKtJetFinder() : TObject() {status = 0;} + ~AliTkKtJetFinder() {} + + // run functions - these ones should be called by the user... + void init(); + void makeTParticles(TClonesArray *particles); + void clear(); + void finish(); + + // main components of the jet finder - normally called by make() + // public to allow easier testing/timing analysis in macro + void initEvent(); + void preclusterTParticles(TClonesArray *particles); + void findJets(); + + // precluster options + void setPhiMin(Float_t fPhiMin) {phiMin = fPhiMin;} + void setPhiMax(Float_t fPhiMax) {phiMax = fPhiMax;} + void setNPhiBins(Int_t nPhiBins) {phiBins = nPhiBins;} + void setPhiBins(Int_t nPhiBins, Float_t fPhiMin, Float_t fPhiMax); + + void setThetaMin(Float_t fThetaMin) {thetaMin = fThetaMin;} + void setThetaMax(Float_t fThetaMax) {thetaMax = fThetaMax;} + void setNThetaBins(Int_t nThetaBins) {thetaBins = nThetaBins;} + void setThetaBins(Int_t nThetaBins, Float_t fThetaMin, Float_t fThetaMax); + + // jet finder options + void setD(Float_t fD) {finder_D = fD;} + void setDCut(Float_t fDCut) {finder_DCut = fDCut;} + + // some "standard" options + void setDefaultOptions(); + + // debug options + void setDebugLevel(Int_t nDebugLevel); + void setDebugFilename(Char_t *sFilename) {debugFilename = sFilename;} + + private: + Int_t status; + + // precluster parameters + Float_t phiMin; + Float_t phiMax; + Int_t phiBins; + + Float_t thetaMin; + Float_t thetaMax; + Int_t thetaBins; + + // jet finder parameters + Float_t finder_D; + Float_t finder_DCut; + + // debug parameters + Int_t debugLevel; + Char_t *debugFilename; + + // data variables + // list of preclusters with pointer to last precluster + Int_t preClusterUID; + TPreCluster *firstPreCluster; + TPreCluster *lastPreCluster; + + // array of pointers to preclusters + // makes access faster + TPreCluster **preClusterArray; + + // functions related to preclusters... + void addPreCluster(TPreCluster *precluster); + void deletePreCluster(Int_t UID); + void dumpPreClusters(); + void dumpPreClusterArray(); + + // double linked sorted list of (relativ) transverse momenta + list myDList; + //priority_queue myNewDList; + //priority_queue myHeap; + // priority queues are not known to CINT... :-( + + // functions related to (relativ) transverse momenta list... + void addD(Tdlist *newD); + void buildNewDList(); + Float_t calcD(TPreCluster *p1, TPreCluster *p2 = NULL); + + // list of final jets + TJetList *firstJet; + + // private member functions + Bool_t isTParticleAccepted(TParticle *particle); + + // debug/output functions + void DebugOutput(Char_t *output); + void TimingOutput(Char_t *output); + void DetailedOutput(Char_t *output); + + ClassDef(AliTkKtJetFinder,1) +}; +#endif + diff --git a/JETAN/AliTkTowerV2.cxx b/JETAN/AliTkTowerV2.cxx new file mode 100644 index 00000000000..64077f7156d --- /dev/null +++ b/JETAN/AliTkTowerV2.cxx @@ -0,0 +1,170 @@ +//$Id$ + +#include +#include +#include +#include +#include + +#include "AliTkTowerV2.h" + +#define Nparticles__ 100 + +ClassImp(AliTkTowerV2) + +AliTkTowerV2::AliTkTowerV2() : TObject(), + fEta(-999), fPhi(-999), fEt(-999), + fNParticles(0),fEtCharged(0), fEtEM(0), + fUpdate(kFALSE), fParticles(0) +{ + fParticles = new TClonesArray("TParticle",Nparticles__); +} + +AliTkTowerV2::AliTkTowerV2(const AliTkTowerV2 &t) : TObject(), + fEta(-999), fPhi(-999), fEt(-999), + fNParticles(0),fEtCharged(0), fEtEM(0), + fUpdate(kFALSE), fParticles(0) +{ + fEta = t.getEta(); + fPhi = t.getPhi(); + fEt = t.getEt(); + fEtCharged = 0; + fEtEM = 0; + fNParticles = t.getNParticles(); + if(fNParticles) fUpdate=kTRUE; + else fUpdate=kFALSE; + TClonesArray *otherParticles = t.getParticleList(); + TParticle *particle; + fParticles = new TClonesArray("TParticle",Nparticles__); + TIterator *iter = otherParticles->MakeIterator(); + Int_t i = 0; + while ((particle = (TParticle *) iter->Next()) != NULL) { + new ((*fParticles)[i]) TParticle(*particle); + i++; + if(i>fNParticles) + cerr << "TKTowerV2: should not happen " << i << " " << fNParticles << endl; + } + delete iter; +} + +AliTkTowerV2::~AliTkTowerV2() +{ + delete fParticles; +} + +TClonesArray *AliTkTowerV2::getChargedParticleList() const +{ + TClonesArray *chargedParticles = new TClonesArray("TParticle",Nparticles__); + Int_t nChargedParticles = 0; + TIterator *iter = getParticleList()->MakeIterator(); + TParticle *particle = NULL; + while ((particle = (TParticle *) iter->Next()) != NULL) { + if (isChargedParticle(particle)) { + new ((*chargedParticles)[nChargedParticles]) TParticle(*particle); + nChargedParticles++; + } + } + delete iter; + return chargedParticles; +} + +TClonesArray *AliTkTowerV2::getNeutralParticleList() const +{ + TClonesArray *neutralParticles = new TClonesArray("TParticle",Nparticles__); + Int_t nNeutralParticles = 0; + TIterator *iter = getParticleList()->MakeIterator(); + TParticle *particle = NULL; + while ((particle = (TParticle *) iter->Next()) != NULL) { + if (!isChargedParticle(particle)) { + new ((*neutralParticles)[nNeutralParticles]) TParticle(*particle); + nNeutralParticles++; + } + } + delete iter; + return neutralParticles; +} + +void AliTkTowerV2::addParticle(const TParticle *particle) +{ + new ((*fParticles)[fNParticles]) TParticle(*particle); + fNParticles++; + Float_t et_=TMath::Sqrt(particle->Pt()*particle->Pt()); + fEt+=et_; + fUpdate=kTRUE; +} + +void AliTkTowerV2::setParticleList(TClonesArray *ptr) +{ + delete fParticles; + fParticles=ptr; + fNParticles=ptr->GetEntries(); + fUpdate=kTRUE; +} + +void AliTkTowerV2::update() +{ + if(!fNParticles) return; + if(!fUpdate) return; + + fEtEM=0; + fEtCharged=0; + + TIterator *iter = fParticles->MakeIterator(); + TParticle *particle = NULL; + while ((particle = (TParticle *) iter->Next()) != NULL) { + Float_t et_=TMath::Sqrt(particle->Pt()*particle->Pt()); + if (isChargedParticle(particle)) + fEtCharged += et_; + + if (isEMParticle(particle)) + fEtEM += et_; + } + fUpdate=kFALSE; +} + +void AliTkTowerV2::Clear(Option_t *option) +{ + TObject::Clear(option); + fParticles->Clear("C"); + fEta=-999; + fPhi=-999; + fEt=-999; + fNParticles = 0; + fUpdate=kFALSE; + fEtCharged = 0; + fEtEM = 0; +} + +Bool_t AliTkTowerV2::isChargedParticle(const TParticle *particle) const +{ + Bool_t isCharged = kFALSE; + TParticle *part = new TParticle(*particle); + TParticlePDG *partPDG = part->GetPDG(0); + if (partPDG->Charge() != 0) { + isCharged = kTRUE; + } + delete part; + return isCharged; +} + +Bool_t AliTkTowerV2::isEMParticle(const TParticle *particle) const +{ + Bool_t isEM = kFALSE; + // define electrons and gammas as EM particles... + // not so sure if this is right... + if ((particle->GetPdgCode() == 11) || + (particle->GetPdgCode() == -11) || + (particle->GetPdgCode() == 22)) { + isEM = kTRUE; + } + return isEM; +} + +Int_t AliTkTowerV2::Compare(const TObject *obj) const +{ + Double_t val=((AliTkTowerV2*)obj)->getEt(); + + if(fEt>val) return -1; //qsort is ascending + else if (fEt +#include + +class AliTkTowerV2 : public TObject { + public: + AliTkTowerV2(); + AliTkTowerV2(const AliTkTowerV2 &t); + ~AliTkTowerV2(); + + Float_t getEta() const {return fEta;} + Float_t getPhi() const {return fPhi;} + Float_t getEt() const {return fEt;} + Int_t getNParticles() const {return fNParticles;} + Bool_t getUpdate() const {return fUpdate;} + Float_t getEtCharged() {if(fUpdate) update(); return fEtCharged;} + Float_t getEtEM() {if(fUpdate) update(); return fEtEM;}; + + TClonesArray *getParticleList() const {return fParticles;} + TClonesArray *getChargedParticleList() const; + TClonesArray *getNeutralParticleList() const; + + void setEta(Float_t Eta) {fEta = Eta;} + void setPhi(Float_t Phi) {fPhi = Phi;} + void setEt(Float_t Et) {fEt = Et;} + void addParticle(const TParticle *particle); + void setParticleList(TClonesArray *ptr); + + void Print(Option_t *) const { + cout << "AliTkTower " << fEt << " " << fEta << " " << fPhi << endl; + } + ULong_t Hash() const {return 0;} + Bool_t IsEqual(const TObject */*obj*/) const {return kFALSE;} + Bool_t IsSortable() const {return kTRUE;} + Int_t Compare(const TObject *obj) const; + void Clear(Option_t *option=""); + + private: + Bool_t isChargedParticle(const TParticle *particle) const; + Bool_t isEMParticle(const TParticle *particle) const; + void update(); + + // member variables + Float_t fEta; + Float_t fPhi; + Float_t fEt; + Int_t fNParticles; + Float_t fEtCharged; + Float_t fEtEM; + Bool_t fUpdate; + TClonesArray *fParticles; //-> + + ClassDef(AliTkTowerV2,2) //AliTkTower class +}; +#endif diff --git a/JETAN/JetFinderLinkDef.h b/JETAN/JetFinderLinkDef.h new file mode 100644 index 00000000000..bab92aea085 --- /dev/null +++ b/JETAN/JetFinderLinkDef.h @@ -0,0 +1,24 @@ +#ifdef __CINT__ +#include + +#pragma link off all globals; +#pragma link off all classes; +#pragma link off all functions; + +#pragma link C++ class AliJFTower+; +#pragma link C++ class AliJFPreCluster+; +#pragma link C++ class AliJFCluster+; +#pragma link C++ class AliJFClusterDifference+; +#pragma link C++ class AliJFParticlesCut+; +#pragma link C++ class AliJFMixEvent+; +#pragma link C++ class AliJFJet+; +#pragma link C++ class AliJFMCJet+; +#pragma link C++ class AliJFKtJet+; +#pragma link C++ class AliJFJetFinder+; +#pragma link C++ class AliJFKtJetFinder+; +#pragma link C++ class AliJFMCJetFinder+; +#pragma link C++ class AliJFJetTrigger+; +#pragma link C++ class AliJFJetCalorimeterTrigger+; +#pragma link C++ class AliJFJetTriggerResult+; +#pragma link C++ class AliJFJetCalorimeterTriggerResult+; +#endif diff --git a/JETAN/Makefile b/JETAN/Makefile deleted file mode 100644 index 9e850751405..00000000000 --- a/JETAN/Makefile +++ /dev/null @@ -1,446 +0,0 @@ -# $Id$ -# -# Makefile for the jetan package (standalone) - -ifdef ALIVERBOSE -MUTE:= -else -MUTE:=@ -endif - -#------------------------------------------------------------------------------- -# Include library definition - -include $(ALICE_ROOT)/build/Makefile.config - -#------------------------------------------------------------------------------- -# Location where to install libraries and binaries and common header files - -LIBPATH := ./lib/tgt_$(ALICE_TARGET) -BINPATH := ./bin/tgt_$(ALICE_TARGET) -EXPORTDIR := $(ALICE_ROOT)/include -BINLIBDIRS := -L$(ALICE_ROOT)/$(LIBPATH) - -#------------------------------------------------------------------------------- -# Include machine dependent macros - -include $(ALICE_ROOT)/build/Makefile.$(ALICE_TARGET) - -#------------------------------------------------------------------------------- -# Check if called with debug - -ifeq ($(ALIDEBUG),YES) -override ALICE_TARGET := $(ALICE_TARGET)DEBUG -FFLAGS := -g $(filter-out -O%,$(FFLAGS)) -CXXFLAGS := -g $(filter-out -O%,$(CXXLAGS)) -CFLAGS := -g $(filter-out -O%,$(CLAGS)) -SOFLAGS := -g $(filter-out -O%,$(SOFLAGS)) -LDFLAGS := -g $(filter-out -O%,$(LDFLAGS)) -endif - -#------------------------------------------------------------------------------- -# Check if called with profile - -ifeq ($(ALIPROFILE),YES) -override ALICE_TARGET := $(ALICE_TARGET)PROF -FFLAGS += -pg -CXXFLAGS += -pg -CFLAGS += -pg -SOFLAGS += -pg -LDFLAGS += -pg -endif - -#------------------------------------------------------------------------------- -# Check if DATE is installed - -ifdef DATE_ROOT -DATEFLAGS = -DALI_DATE -D${DATE_SYS} -DDATE_SYS=${DATE_SYS} -Dlong32=${DATE_LONG32} \ - -Dlong64=${DATE_LONG64} -DdatePointer=${DATE_POINTER} -CXXFLAGS += $(DATEFLAGS) -CFLAGS += $(DATEFLAGS) -CINTFLAGS += $(DATEFLAGS) -DEPINC += $(DATEFLAGS) -endif - -#------------------------------------------------------------------------------- -# Default include dirs for C++, Fortran, Cint, and dependencies -# The module directory will be added by each module - -GENINC := -I$(ALICE_ROOT)/include -I$(shell root-config --incdir) -CXXFLAGS += $(GENINC) -CXXFLAGSNO += $(GENINC) -CINTFLAGS += $(GENINC) -DEPINC += $(GENINC) - -LIBS := $(GLIBS) $(ROOTLIBS) $(SYSLIBS) - -#Determine if it's a library or a executable -TYPE=lib - -# Package head directory, source and include directories -CURDIR=$(shell pwd) -MODDIR:=. -MODDIRS:=$(MODDIR) -MODDIRI:=$(MODDIR) -MODDIRO:=./.objs - -# Reseting variables before importing pkg-file -SRCS:= -HDRS:= -FSRCS:= -DHDR:= -CSRCS:= -CHDRS:= -EINCLUDE:= -EDEFINE:= -ELIBS:= -ELIBSDIR:= -PACKFFLAGS:= -PACKCXXFLAGS:= -PACKCFLAGS:= -PACKDYFLAGS:= -PACKSOFLAGS:= -EXPORT:= -EHDRS:= -CINTHDRS:= -ARLIBS:= -SHLIBS:= -SUBDIR:= - -include libJETAN.pkg - -ifndef PACKFFLAGS -JETANFFLAGS:=$(FFLAGS) -else -JETANFFLAGS:=$(PACKFFLAGS) -endif - -ifndef PACKCFLAGS -JETANCFLAGS:=$(CFLAGS) -else -JETANCFLAGS:=$(PACKCFLAGS) -endif - -ifndef PACKCXXFLAGS -JETANCXXFLAGS:=$(CXXFLAGS) -else -JETANCXXFLAGS:=$(PACKCXXFLAGS) -endif - -ifndef PACKSOFLAGS -JETANSOFLAGS:=$(SOFLAGS) -else -JETANSOFLAGS:=$(PACKSOFLAGS) -endif - -ifdef DYEXT -ifndef PACKDYFLAGS -JETANDYFLAGS:=$(DYFLAGS) -else -JETANDYFLAGS:=$(PACKDYFLAGS) -endif -endif - -ifndef PACKDCXXFLAGS -JETANDCXXFLAGS:=$(CXXFLAGSNO) -else -JETANDCXXFLAGS:=$(PACKDCXXFLAGS) -endif - - -ifdef DHDR -WITHDICT=YES -else -WITHDICT= -endif - -# Headerfiles exported to common place: -JETANEXPORT:=$(EXPORT) -JETANEXPORTDEST:=$(patsubst %,$(EXPORTDIR)/%,$(EXPORT)) - - -#Extra include,libs, defines etc. - -JETANDEFINE:=$(EDEFINE) -DNOUQHEADERINFO - -JETANINC:=$(patsubst %,-I$(ALICE_ROOT)/%,$(EINCLUDE)) -I. - -JETANELIBS:=$(patsubst %,-l%,$(ELIBS)) -JETANELIBSDEP:=$(patsubst %,lib/tgt_$(ALICE_TARGET)/lib%.$(SOEXT),$(ELIBS)) -JETANELIBSDIR:=$(patsubst %,-L%,$(ELIBSDIR)) - -#c sources and headers - -JETANCS:=$(patsubst %,$(MODDIR)/%,$(CSRCS)) -JETANCH:=$(patsubst %,$(MODDIR)/%,$(CHDRS)) - -#Fortran sources -JETANFS:=$(patsubst %,$(MODDIR)/%,$(FSRCS)) - -#c++ sources and header -JETANS:=$(patsubst %,$(MODDIR)/%,$(SRCS)) -JETANH:=$(patsubst %,$(MODDIR)/%,$(HDRS)) $(EHDRS) - -#c++ source subdirectories -JETANSDIR:=$(SUBDIR) - -############################################################################# -# -# If special rootcint headerfiles is specified use them -# else use all headers - -ifndef CINTHDRS -JETANCINTHDRS:=$(JETANH) -else -JETANCINTHDRS:=$(CINTHDRS) -endif -############################################################################# - -# Package Dictionary - -JETANDH:=$(MODDIR)/$(DHDR) - - -#All objects -JETANCO:=$(patsubst %,$(MODDIRO)/%, $(CSRCS:.c=.o)) -TEMP:=$(FSRCS:.F=.o) -JETANFO:=$(patsubst %,$(MODDIRO)/%, $(TEMP:.f=.o)) -JETANO:= $(patsubst %,$(MODDIRO)/%, $(SRCS:.cxx=.o)) $(JETANFO) $(JETANCO) - - - -ifdef WITHDICT - JETANDS:=$(MODDIRO)/G__JETAN.cxx - JETANDO:=$(MODDIRO)/G__JETAN.o - JETANDDEP:=$(JETANDO:.o=.d) - JETANDEP:=$(JETANO:.o=.d) $(JETANDDEP) -else - JETANDS:= - JETANDO:= - JETANDDEP:= - JETANDEP:=$(JETANO:.o=.d) -endif - - -#The actual library file - -JETANLIB:=$(LIBPATH)/libJETAN.$(SOEXT) - -ifneq ($(DYEXT),) -JETANDLIB:=$(LIBPATH)/libJETAN.$(DYEXT) -endif - -JETANALIB:=$(LIBPATH)/libJETAN.$(AEXT) - -#Add this to the modules libs -JETANLIBS += $(JETANLIB) -JETANALIBS += $(JETANALIB) -ifneq ($(DYEXT),) -JETANDLIBS += $(JETANDLIB) -endif - -#The actual binary file - -JETANBIN:=$(BINPATH)/JETAN - -#Add to modules list of binaries -JETANBINS += $(JETANBIN) - -# Use in the main Makefile - -ifeq ($(TYPE),lib) -ALLLIBS += $(JETANLIB) -ALLALIBS += $(JETANALIB) -ifneq ($(DYEXT),) -ALLLIBS += $(JETANDLIB) -endif -BINLIBS += -lJETAN -else -ALLEXECS += $(JETANBIN) -endif - -ifeq ($(DYEXT),) -JETANLIB := $(JETANLIB) -else -JETANLIB := $(JETANLIB) -endif - -# include all dependence files -INCLUDEFILES +=$(JETANDEP) - -EXPORTFILES += $(JETANEXPORTDEST) - -#local rules - -#The exportfiles only include if any!! - -ifdef JETANEXPORT -#$(JETANEXPORTDEST): $(patsubst %,JETAN/%,$(JETANEXPORT)) - -$(JETANEXPORTDEST): $(EXPORTDIR)/%.h: JETAN/%.h -ifndef ALIQUIET - @echo "***** Copying file $^ to $@ *****" -endif - @[ -d $(dir $@) ] || mkdir -p $(dir $@) - @cp $^ $@ -endif - -#------------------------------------------------------------------------ - -$(JETANLIB):$(JETANO) $(JETANDO) -ifndef ALIQUIET - @echo "***** Linking library $@ *****" -endif - $(MUTE)mkdir -p $(LIBPATH) - $(MUTE)TMPDIR=/tmp/JETAN$$$$.`date +%M%S` ; \ - export TMPDIR; mkdir -p $$TMPDIR ; cd $$TMPDIR ; \ - find $(CURDIR)/.objs/ -name '*.o' -exec ln -s {} . \; ;\ - \rm -f $(CURDIR)/$@ ;\ - TMPLIB=$(notdir $(JETANLIB)); export TMPLIB;\ - $(SHLD) $(JETANSOFLAGS) -o $(CURDIR)/$@ $(notdir $(JETANO) $(JETANDO)) $(JETANELIBSDIR) $(JETANELIBS) $(SHLIB);\ - chmod a-w $(CURDIR)/$@ ;\ - cd $(ALICE_ROOT) ; \rm -rf $$TMPDIR - -ifneq ($(DYEXT),) -$(JETANDLIB):$(JETANO) $(JETANDO) -ifndef ALIQUIET - @echo "***** Linking library $@ *****" -endif - $(MUTE)mkdir -p $(LIBPATH) - $(MUTE)TMPDIR=/tmp/JETAN$$$$.`date +%M%S` ; \ - export TMPDIR; mkdir -p $$TMPDIR ; cd $$TMPDIR ; \ - find $(CURDIR)/.objs/ -name '*.o' -exec ln -s {} . \; ;\ - \rm -f $(CURDIR)/$@ ;\ - $(DYLD) $(JETANDYFLAGS) -o $(CURDIR)/$@ $(notdir $(JETANO) $(JETANDO)) $(JETANELIBSDIR) $(JETANELIBS) $(DYLIB);\ - chmod a-w $(CURDIR)/$@ ;\ - cd $(ALICE_ROOT) ; \rm -rf $$TMPDIR -endif - -#------------------------------------------------------------------------ - -$(JETANALIB):$(JETANO) $(JETANDO) -ifndef ALIQUIET - @echo "***** Linking static library $@ *****" -endif - $(MUTE)mkdir -p $(LIBPATH) - $(MUTE)TMPDIR=/tmp/JETAN$$$$.`date +%M%S` ; \ - export TMPDIR; mkdir -p $$TMPDIR ; cd $$TMPDIR ; \ - find $(CURDIR)/JETAN/tgt_$(ALICE_TARGET) -name '*.o' -exec ln -s {} . \; ;\ - \rm -f $(CURDIR)/$@ ;\ - TMPLIB=$(notdir $(JETANLIB)); export TMPLIB;\ - $(ALLD) $(ALFLAGS) $(CURDIR)/$@ $(notdir $(JETANO) $(JETANDO)) $(JETANELIBSDIR) $(JETANELIBS) $(ALLIB);\ - cd $(CURDIR) ; \rm -rf $$TMPDIR - $(MUTE)chmod a-w $@ - - -$(JETANBIN):$(JETANO) $(JETANDO) $(JETANELIBSDEP) -ifndef ALIQUIET - @echo "***** Making executable $@ *****" -endif -ifeq ($(ALIPROFILE),YES) - $(MUTE)$(LD) $(LDFLAGS) $(JETANO) $(ARLIBS) $(SHLIBS) $(LIBS) $(EXEFLAGS) -o $@ -else - $(MUTE)$(LD) $(LDFLAGS) $(JETANO) $(JETANDO) $(BINLIBDIRS) $(JETANELIBSDIR) $(JETANELIBS) $(LIBS) $(EXEFLAGS) -o $@ -endif - -$(JETANDS): $(JETANCINTHDRS) $(JETANDH) -ifndef ALIQUIET - @echo "***** Creating $@ *****"; -endif - @(if [ ! -d '$(dir $@)' ]; then echo "***** Making directory $(dir $@) *****"; mkdir -p $(dir $@); fi;) - @\rm -f $(patsubst %.cxx,%.d, $@) - $(MUTE)rootcint -f $@ -c $(JETANDEFINE) $(CINTFLAGS) $(JETANINC) $(JETANCINTHDRS) $(JETANDH) - -$(JETANDO): $(JETANDS) -ifndef ALIQUIET - @echo "***** Compiling $< *****"; -endif - $(MUTE)$(CXX) $(JETANDEFINE) -c $(JETANINC) -I$(ALICE_ROOT) $< -o $@ $(JETANDCXXFLAGS) - -#Different targets for the module - -ifeq ($(TYPE),lib) -all-JETAN: $(JETANLIB) -ifneq ($(DYEXT),) -all-JETAN: $(JETANDLIB) -endif -else -all-JETAN: $(JETANBIN) -endif - -depend-JETAN: $(JETANDEP) - -# determination of object files -$(MODDIRO)/%.o: $(MODDIR)/%.cxx $(MODDIRO)/%.d -ifndef ALIQUIET - @echo "***** Compiling $< *****"; -endif - @(if [ ! -d '$(dir $@)' ]; then echo "***** Making directory $(dir $@) *****"; mkdir -p $(dir $@); fi;) - $(MUTE)$(CXX) $(JETANDEFINE) -c $(JETANINC) $< -o $@ $(JETANCXXFLAGS) - -$(MODDIRO)/%.o: $(MODDIR)/%.F $(MODDIRO)/%.d -ifndef ALIQUIET - @echo "***** Compiling $< *****"; -endif - @(if [ ! -d '$(dir $@)' ]; then echo "***** Making directory $(dir $@) *****"; mkdir -p $(dir $@); fi;) - $(MUTE)$(F77) -c $(JETANINC) $< -o $@ $(JETANFFLAGS) - -$(MODDIRO)/%.o: $(MODDIR)/%.f $(MODDIRO)/%.d -ifndef ALIQUIET - @echo "***** Compiling $< *****"; -endif - @(if [ ! -d '$(dir $@)' ]; then echo "***** Making directory $(dir $@) *****"; mkdir -p $(dir $@); fi;) - $(MUTE)$(F77) -c $(JETANINC) $< -o $@ $(JETANFFLAGS) - -$(MODDIRO)/%.o: $(MODDIR)/%.c $(MODDIRO)/%.d -ifndef ALIQUIET - @echo "***** Compiling $< *****"; -endif - @(if [ ! -d '$(dir $@)' ]; then echo "***** Making directory $(dir $@) *****"; mkdir -p $(dir $@); fi;) - $(MUTE)$(CC) $(JETANDEFINE) -c $(JETANINC) $< -o $@ $(JETANCFLAGS) - -$(JETANDDEP): $(JETANDS) -ifndef ALIQUIET - @echo "***** Making dependences for $< *****"; -endif - @(if [ ! -d '$(dir $@)' ]; then echo "***** Making directory $(dir $@) *****"; mkdir -p $(dir $@); fi;) - @$(ALICE_ROOT)/share/alibtool depend "$(JETANELIBSDIR) $(JETANINC) $(DEPINC) $<" > $@ - -$(MODDIRO)/%.d: $(MODDIRS)/%.cxx -ifndef ALIQUIET - @echo "***** Making dependences for $< *****"; -endif - @(if [ ! -d '$(dir $@)' ]; then echo "***** Making directory $(dir $@) *****"; mkdir -p $(dir $@); fi;) - @$(ALICE_ROOT)/share/alibtool depend "$(JETANDEFINE) $(JETANELIBSDIR) $(JETANINC) $(DEPINC) $<" > $@ -$(MODDIRO)/%.d: $(MODDIRS)/%.f -ifndef ALIQUIET - @echo "***** Making dependences for $< *****"; -endif - @(if [ ! -d '$(dir $@)' ]; then echo "***** Making directory $(dir $@) *****"; mkdir -p $(dir $@); fi;) - @$(ALICE_ROOT)/share/alibtool dependF "$(JETANELIBSDIR) $(JETANINC) $(DEPINC) $<" > $@ -$(MODDIRO)/%.d: $(MODDIRS)/%.F -ifndef ALIQUIET - @echo "***** Making dependences for $< *****"; -endif - @(if [ ! -d '$(dir $@)' ]; then echo "***** Making directory $(dir $@) *****"; mkdir -p $(dir $@); fi;) - $(MUTE)share/alibtool dependF "$(JETANELIBSDIR) $(JETANINC) $(DEPINC) $<" > $@ -$(MODDIRO)/%.d: $(MODDIRS)/%.c -ifndef ALIQUIET - @echo "***** Making dependences for $< *****"; -endif - @(if [ ! -d '$(dir $@)' ]; then echo "***** Making directory $(dir $@) *****"; mkdir -p $(dir $@); fi;) - @$(ALICE_ROOT)/share/alibtool depend "$(JETANDEFINE) $(JETANELIBSDIR) $(JETANINC) $(DEPINC) $<" > $@ - -.PRECIOUS: $(patsubst %.cxx,$(MODDIRO)/%.d,$(SRCS)) -.PRECIOUS: $(patsubst %.c,$(MODDIRO)/%.d,$(CSRCS)) -.PRECIOUS: $(patsubst %.F,$(MODDIRO)/%.d,$(patsubst %.f,$(MODDIRO)/%.d,$(FSRCS))) - - -# Clean option for the whole module -clean: -ifndef ALIQUIET - @echo "***** Cleaning JETAN *****" -endif - $(MUTE)rm -rf $(MODDIRO) - $(MUTE)rm -rf lib - $(MUTE)rm -rf $(BINPATH) diff --git a/JETAN/TkJetFinderLinkDef.h b/JETAN/TkJetFinderLinkDef.h new file mode 100644 index 00000000000..42232b385a0 --- /dev/null +++ b/JETAN/TkJetFinderLinkDef.h @@ -0,0 +1,28 @@ +#ifdef __CINT__ +#include + +#pragma link off all globals; +#pragma link off all classes; +#pragma link off all functions; + +#pragma link C++ class AliTkTower+; +#pragma link C++ class AliTkProtoJet+; +#pragma link C++ class AliTkKtJetFinder+; +#pragma link C++ class AliTkConeJetFinder+; + +#pragma link C++ class AliTkConeJet+; +#pragma link C++ class AliTkTowerV2+; +#pragma link C++ class AliTkConeJetFinderV2+; +#pragma link C++ class AliTkConeJetEvent+; + +#pragma link C++ class AliTkChargedJet+; +#pragma link C++ class AliTkChargedJetFinder+; + +#pragma link C++ class AliTkHijingAna+; + +#pragma link C++ class AliTkJetTrigger+; +#pragma link C++ class AliTkJetTriggerSettings+; +#pragma link C++ class AliTkJetTriggerDecision+; +#pragma link C++ class AliTkJetTriggerEvent+; +#pragma link C++ class AliTkEtaPhiVector+; +#endif diff --git a/JETAN/anaAliJets.C b/JETAN/anaAliJets.C new file mode 100644 index 00000000000..7edd2b6e7c9 --- /dev/null +++ b/JETAN/anaAliJets.C @@ -0,0 +1,2418 @@ +// $Id$ + +#if !defined(__CINT__) || defined(__MAKECINT__) +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "AliTkConeJetEvent.h" +#include "AliTkConeJet.h" +#include "AliTkConeJetFinderV2.h" +#include +#include +#include +#include +#include +#include +#endif + +Float_t relphi(Float_t phi1, Float_t phi2); +Float_t addphi(Float_t phi1, Float_t phi2); +Float_t diffphi(Float_t phi1, Float_t phi2); +Int_t eventindex(Float_t phi1, Float_t phi2); +void convert(Float_t pjet[4], Float_t &pt, Float_t &theta, Float_t &eta, Float_t &phi); + +void anaAliJets(Char_t *filename,Char_t *savefilename, + Int_t mEnergy=100,Int_t mBackEn=-1,Int_t nMaxEvents=-1, + Char_t *evfilename=0,Char_t *sigevfilename=0, + Char_t *signalfilename=0,Char_t *monteconefilename=0) + /* + filename = cone finder event + evfilename = background event or jetevent only (if 0 take from jetevent) + sigevfilename = signal event if background event is used (otherwice == 0) + signalfilename = original signal event (eg. for real tracking to get trigger jets) + monteconefilename = reconstructed jets from signal event (esd=0,esd=10) + */ + +{ + const Float_t minEtRecoCut=mEnergy*0.95; + const Float_t maxEtRecoCut=mEnergy*1.05; + Float_t minJetEt; + if(mBackEn) minJetEt=mBackEn; + else minJetEt=mEnergy/4.; + const Float_t minPartPt=0.5; + //const Char_t *figprefix=0; + //const Char_t *figdirname="."; + + const Int_t nclasses=22; + const Float_t cletmin[nclasses] = {0,10,20,30,40,50,60,70,80,90,100, + 110,120,130,140,150,160,170,180,190,200,0}; + const Float_t cletmax[nclasses] = {10,20,30,40,50,60,70,80,90,100, + 110,120,130,140,150,160,170,180,190,200,350,350}; + + //differential shape + const Float_t deltaR=0.1/2; + + Float_t corrfac=0.; +#ifdef APPLYCORRECTION + if(!allparts) corrfac=2./3; + Float_t conefluc=1.; + if(Radius<=0.3) conefluc=0.8; + else if(Radius<=0.5) conefluc=0.9; + else if(Radius<=0.7) conefluc=0.9; + corrfac*=conefluc; +#endif + + Char_t dummy[1024]; + Char_t name[1024]; + Char_t title[1024]; + + TH1F *hJetEt = new TH1F("hJetEt","E_{T} (jet)",350,0,350); + hJetEt->GetXaxis()->SetTitle("E_{T} (jet) [GeV]"); + hJetEt->GetYaxis()->SetTitle("dN/dE_{T} [GeV^{-1}]"); + + TH1F *hBackJetEt = new TH1F("hBackJetEt","E_{T} (jet)",350,0,350); + hBackJetEt->GetXaxis()->SetTitle("E_{T} (jet) [GeV]"); + hBackJetEt->GetYaxis()->SetTitle("dN/dE_{T} [GeV^{-1}]"); + + TH1F *hJetEtall = new TH1F("hAllJetEt","E_{T} (jet)",350,0,350); + hJetEtall->GetXaxis()->SetTitle("E_{T} (jet) [GeV]"); + hJetEtall->GetYaxis()->SetTitle("dN/dE_{T} [GeV^{-1}]"); + + TProfile *hJetEttrue = new TProfile("hJetEttrue","E_{T} (jet)",350,0,350,0,1.5); + hJetEttrue->GetXaxis()->SetTitle("E_{T} (jet) [GeV]"); + hJetEttrue->GetYaxis()->SetTitle("E^{true}_{T}/E_{T}"); + + TProfile *hBackJetEttrue = new TProfile("hBackJetEttrue","E_{T} (jet)",350,0,350,0,1.5); + hBackJetEttrue->GetXaxis()->SetTitle("E_{T} (jet) [GeV]"); + hBackJetEttrue->GetYaxis()->SetTitle("E^{true}_{T}/E_{T}"); + + TProfile *hJetEtalltrue = new TProfile("hAllJetEttrue","E_{T} (jet)",350,0,350,0,1.5); + hJetEtalltrue->GetXaxis()->SetTitle("E_{T} (jet) [GeV]"); + hJetEtalltrue->GetYaxis()->SetTitle("E^{true}_{T}/E_{T}"); + + TH1F *hJetEtUQTrigger = new TH1F("hJetEtUQTrigger","E_{T} (trigger jet)",350,0,350); + hJetEtUQTrigger->GetXaxis()->SetTitle("E_{T} (jet) [GeV]"); + hJetEtUQTrigger->GetYaxis()->SetTitle("dN/dE_{T} [GeV^{-1}]"); + + TH1F *hJetEtTrigger = new TH1F("hJetEtTrigger","E_{T} (trigger jet)",350,0,350); + hJetEtTrigger->GetXaxis()->SetTitle("E_{T} (jet) [GeV]"); + hJetEtTrigger->GetYaxis()->SetTitle("dN/dE_{T} [GeV^{-1}]"); + + TH2F *hJetEtvsEll = new TH2F("hJetEtvsEll","E_{T} (jet) versus Length",350,0,350,100,0,10); + hJetEtvsEll->GetXaxis()->SetTitle("E_{T} (jet) [GeV]"); + hJetEtvsEll->GetYaxis()->SetTitle("L [fm]"); + + TH2F *hJetEtallvsEll = new TH2F("hAllJetEtallvsEll","E_{T} (jet) versus Length",350,0,350,100,0,10); + hJetEtallvsEll->GetXaxis()->SetTitle("E_{T} (jet) [GeV]"); + hJetEtallvsEll->GetYaxis()->SetTitle("L [fm]"); + + TH2F *hJetEtvsTrigger = new TH2F("hJetEtvsTrigger","",350,0,350,350,0,350); + hJetEtvsTrigger->GetXaxis()->SetTitle("E_{T} (jet) [GeV]"); + hJetEtvsTrigger->GetYaxis()->SetTitle("E_{T} (jettrigger) [GeV]"); + + TH2F *hJetEtvsUQTrigger = new TH2F("hJetEtvsUQTrigger","",350,0,350,350,0,350); + hJetEtvsUQTrigger->GetXaxis()->SetTitle("E_{T} (jet) [GeV]"); + hJetEtvsUQTrigger->GetYaxis()->SetTitle("E_{T} (jettrigger) [GeV]"); + + TH2F *hJetEtvsEt = new TH2F("hJetEtvsEt","",350,0,350,350,0,350); + hJetEtvsEt->GetXaxis()->SetTitle("E_{T} (jet) [GeV]"); + hJetEtvsEt->GetYaxis()->SetTitle("E_{T} (jet) [GeV]"); + + TH1F *hJetZ = new TH1F("hjetZ","Z distribution",100,0,1); + hJetZ->GetXaxis()->SetTitle("Z"); + hJetZ->GetYaxis()->SetTitle("dN/dZ"); + + TH1F *hJet1 = new TH1F("hjet1","E_{t} distribution",350,0,350); + hJet1->GetXaxis()->SetTitle("E_{T} (parton) [GeV]"); + hJet1->GetYaxis()->SetTitle("dN/dE_{T} [GeV^{-1}]"); + + TH1F *hJet2 = new TH1F("hjet2","E_{t} distribution",350,0,350); + hJet2->GetXaxis()->SetTitle("E_{T} (parton) [GeV]"); + hJet2->GetYaxis()->SetTitle("dN/dE_{T} [GeV^{-1}]"); + + TH1F **hJettype= new TH1F*[3]; + for(Int_t i=0;i<3;i++){ + Char_t t[100]; + sprintf(t,"hJettype%d",i); + Char_t tit[100]; + if(i==0) + sprintf(tit,"Unknown"); + else if(i==1) + sprintf(tit,"Quark"); + else + sprintf(tit,"Gluon"); + hJettype[i]=new TH1F(t,tit,350,0,350); + hJettype[i]->GetXaxis()->SetTitle("E_{T} (jet) [GeV]"); + hJettype[i]->GetYaxis()->SetTitle("dN/dE_{T} [GeV^{-1}]"); + } + + TH2F *hAxesDiff = new TH2F("hAxesDiff","",120,0,TMath::Pi(),40,0,2); + hAxesDiff->GetXaxis()->SetTitle("#Delta #phi"); + hAxesDiff->GetYaxis()->SetTitle("#Delta #eta"); + + //--- + TH1F *hJetEtres = new TH1F("hJetEtres","E_{T} (jet)",350,0,350); + hJetEtres->GetXaxis()->SetTitle("E_{T} (jet) [GeV]"); + hJetEtres->GetYaxis()->SetTitle("dN/dE_{T} [GeV^{-1}]"); + + TH1F *hJetEtratio = new TH1F("hJetEtratio","E_{T} (jet)",200,0,2); + hJetEtratio->GetXaxis()->SetTitle("E_{T} (jet)/E_{T} (trigger)"); + hJetEtratio->GetYaxis()->SetTitle("Number of jets"); + + TProfile *hJetEtrestrue = new TProfile("hJetEttestrue","E_{T} (jet)",35,0,350,-2,2); + hJetEtrestrue->GetXaxis()->SetTitle("E_{T} (jet) [GeV]"); + hJetEtrestrue->GetYaxis()->SetTitle("E^{true}_{T}/E_{T}"); + + TH1F *hJetEtresTrigger = new TH1F("hJetEtresTrigger","E_{T} (trigger jet)",350,0,350); + hJetEtresTrigger->GetXaxis()->SetTitle("E_{T} (jet) [GeV]"); + hJetEtresTrigger->GetYaxis()->SetTitle("dN/dE_{T} [GeV^{-1}]"); + + TProfile2D *hAxesDiffres = new TProfile2D("hAxesDiffres","",240,0,TMath::Pi(),100,0,2); + hAxesDiffres->GetXaxis()->SetTitle("#Delta #phi"); + hAxesDiffres->GetYaxis()->SetTitle("#Delta #eta"); + + TH1F *hPhires = new TH1F("hPhires","",250,-1,1); + hPhires->GetXaxis()->SetTitle("#Delta #phi [rad]"); + hPhires->GetYaxis()->SetTitle("Number of jets"); + + TH1F *hEtares = new TH1F("hEtares","",250,-1,1); + hEtares->GetXaxis()->SetTitle("#Delta #eta [rad]"); + hEtares->GetYaxis()->SetTitle("Number of jets"); + + TH1F *hmJetEtres = new TH1F("hmJetEtres","E_{T} (jet)",350,0,350); + hmJetEtres->GetXaxis()->SetTitle("E_{T} (jet) [GeV]"); + hmJetEtres->GetYaxis()->SetTitle("dN/dE_{T} [GeV^{-1}]"); + + TH1F *hmJetEtratio = new TH1F("hmJetEtratio","E_{T} (jet)",200,0,2); + hmJetEtratio->GetXaxis()->SetTitle("E_{T} (jet)/E_{T} (trigger)"); + hmJetEtratio->GetYaxis()->SetTitle("Number of jets"); + + TProfile *hmJetEtrestrue = new TProfile("hmJetEttestrue","E_{T} (jet)",35,0,350,-2,2); + hmJetEtrestrue->GetXaxis()->SetTitle("E_{T} (jet) [GeV]"); + hmJetEtrestrue->GetYaxis()->SetTitle("E^{true}_{T}/E_{T}"); + + TProfile2D *hmAxesDiffres = new TProfile2D("hmAxesDiffres","",240,0,TMath::Pi(),100,0,2); + hmAxesDiffres->GetXaxis()->SetTitle("#Delta #phi"); + hmAxesDiffres->GetYaxis()->SetTitle("#Delta #eta"); + + TH1F *hmPhires = new TH1F("hmPhires","",250,-1,1); + hmPhires->GetXaxis()->SetTitle("#Delta #phi [rad]"); + hmPhires->GetYaxis()->SetTitle("Number of jets"); + + TH1F *hmEtares = new TH1F("hmEtares","",250,-1,1); + hmEtares->GetXaxis()->SetTitle("#Delta #eta [rad]"); + hmEtares->GetYaxis()->SetTitle("Number of jets"); + + TH1F *hPhiMonteres = new TH1F("hPhiMonteres","",250,-1,1); + hPhiMonteres->GetXaxis()->SetTitle("#Delta #phi [rad]"); + hPhiMonteres->GetYaxis()->SetTitle("Number of jets"); + + TH1F *hEtaMonteres = new TH1F("hEtaMonteres","",250,-1,1); + hEtaMonteres->GetXaxis()->SetTitle("#Delta #eta [rad]"); + hEtaMonteres->GetYaxis()->SetTitle("Number of jets"); + + TH1F *hEtMonteres = new TH1F("hEtMonteres","",250,-125,125); + hEtMonteres->GetXaxis()->SetTitle("#Delta E_{T} [GeV]"); + hEtMonteres->GetYaxis()->SetTitle("Number of jets"); + + TH1F *hEtMonteratio = new TH1F("hEtMonteratio","E_{T} (jet)",200,0,2); + hEtMonteratio->GetXaxis()->SetTitle("E^{rec}_{T} / E^{monte}_{T}"); + hEtMonteratio->GetYaxis()->SetTitle("Number of jets"); + + //--- + + TH1F **hJetEttrigger=new TH1F*[9]; + TH1F **hJetEttrigger2=new TH1F*[9]; + for(Int_t i=0;i<9;i++){ + sprintf(dummy,"hJetEttrigger%d",i); + hJetEttrigger[i] = new TH1F(dummy,"E_{T} (jet)",350,0,350); + hJetEttrigger[i]->GetXaxis()->SetTitle("E_{T} (jet) [GeV]"); + hJetEttrigger[i]->GetYaxis()->SetTitle("dN/dE_{T} [GeV^{-1}]"); + sprintf(dummy,"hJetEttrigger2%d",i); + hJetEttrigger2[i] = new TH1F(dummy,"E_{T} (jet)",350,0,350); + hJetEttrigger2[i]->GetXaxis()->SetTitle("E_{T} (jet) [GeV]"); + hJetEttrigger2[i]->GetYaxis()->SetTitle("dN/dE_{T} [GeV^{-1}]"); + } + sprintf(dummy,"hJetEttriggernorm"); + TH1F *hJetEttriggernorm = new TH1F(dummy,"E_{T} (jet)",350,0,350); + hJetEttriggernorm->GetXaxis()->SetTitle("E_{T} (jet) [GeV]"); + hJetEttriggernorm->GetYaxis()->SetTitle("dN/dE_{T} [GeV^{-1}]"); + + //--- + + TH1F **hJetLeadingPt = new TH1F*[nclasses]; + for(Int_t i=0;iGetXaxis()->SetTitle("z=p_{T}^{lead.part.}/P_{T}^{jet}"); + hJetLeadingPt[i]->GetYaxis()->SetTitle("dN/dz"); + } + + TH1F **hJetFragLeadingPt = new TH1F*[nclasses]; + for(Int_t i=0;iGetXaxis()->SetTitle("z=p_{T}/p_{T}^{lead.part.}"); + hJetFragLeadingPt[i]->GetYaxis()->SetTitle("dN/dz"); + } + + TH1F **hJetLeadingPtDist = new TH1F*[nclasses]; + for(Int_t i=0;iGetXaxis()->SetTitle("p_{T}^{lead.part.} [GeV]"); + hJetLeadingPtDist[i]->GetYaxis()->SetTitle("dN/dp_{T}^{lead.part.} [GeV^{-1}]"); + } + + TH1F **hJetFragL = new TH1F*[nclasses]; + for(Int_t i=0;iGetXaxis()->SetTitle("z=p_{L}/P^{jet}"); + hJetFragL[i]->GetYaxis()->SetTitle("dN/dz"); + } + + TH1F **hJetFragPL = new TH1F*[nclasses]; + for(Int_t i=0;iGetXaxis()->SetTitle("p_{L}"); + hJetFragPL[i]->GetYaxis()->SetTitle("dN/dp_{L} [GeV^{-1}]"); + } + + TH1F **hJetFragT = new TH1F*[nclasses]; + for(Int_t i=0;iGetXaxis()->SetTitle("j_{T} [GeV]"); + hJetFragT[i]->GetYaxis()->SetTitle("dN/dj_{T}"); + } + + TH1F **hJetFragPt = new TH1F*[nclasses]; + for(Int_t i=0;iGetXaxis()->SetTitle("p_{T} [GeV]"); + hJetFragPt[i]->GetYaxis()->SetTitle("dN/dp_{T}"); + } + + TH1F **hJetN = new TH1F*[nclasses]; + for(Int_t i=0;iGetXaxis()->SetTitle("n = Number of Particles within Jet"); + hJetN[i]->GetYaxis()->SetTitle("dN/dn"); + } + + TH1F **hJetMeanPt = new TH1F*[nclasses]; + for(Int_t i=0;iGetXaxis()->SetTitle("#bar{p} = P_{T}^{jet}/n [GeV]"); + hJetMeanPt[i]->GetYaxis()->SetTitle("dN/d#bar{p}"); + } + + //intshape + Float_t retall[nclasses][10]; + Float_t retlow[nclasses][10]; + Float_t retlow1[nclasses][10]; + Float_t retlow2[nclasses][10]; + Float_t retlow3[nclasses][10]; + Float_t retlow4[nclasses][10]; + Float_t rxet[10]; + for(Int_t i=0;i<10;i++) { + for(Int_t j=0;jGetXaxis()->SetTitle("#phi"); + hPhiCorr[i]->GetYaxis()->SetTitle("dN/d#phi"); + } + + // + //global event properties (ue) + // [0]=toward, [1]=away, [2]=transverse, + // + AliTkEtaPhiVector **centers=new AliTkEtaPhiVector*[4]; + + TH1F ***hgJetFragLeadingPt = new TH1F**[3]; + TH1F ***hgJetFragL = new TH1F**[3]; + TH1F ***hgJetFragPL = new TH1F**[3]; + TH1F ***hgJetFragT = new TH1F**[3]; + TH1F ***hgJetFragPt = new TH1F**[3]; + TH1F ***hgDiJetFragLeadingPt = new TH1F**[3]; + TH1F ***hgDiJetFragL = new TH1F**[3]; + TH1F ***hgDiJetFragPL = new TH1F**[3]; + TH1F ***hgDiJetFragT = new TH1F**[3]; + TH1F ***hgDiJetFragPt = new TH1F**[3]; + for(Int_t k=0;k<3;k++){ + hgJetFragLeadingPt[k] = new TH1F*[nclasses]; + hgJetFragL[k] = new TH1F*[nclasses]; + hgJetFragPL[k] = new TH1F*[nclasses]; + hgJetFragT[k] = new TH1F*[nclasses]; + hgJetFragPt[k] = new TH1F*[nclasses]; + hgDiJetFragLeadingPt[k] = new TH1F*[nclasses]; + hgDiJetFragL[k] = new TH1F*[nclasses]; + hgDiJetFragPL[k] = new TH1F*[nclasses]; + hgDiJetFragT[k] = new TH1F*[nclasses]; + hgDiJetFragPt[k] = new TH1F*[nclasses]; + if(k==0){ + sprintf(name,"toward"); + } else if (k==1) { + sprintf(name,"away"); + } else { + sprintf(name,"transverse"); + } + for(Int_t i=0;iGetXaxis()->SetTitle("z=p_{T}/p_{T}^{lead.part.}"); + hgJetFragLeadingPt[k][i]->GetYaxis()->SetTitle("dN/dz"); + + sprintf(dummy,"h%s-JetFragL%d",name,i); + sprintf(title,"Longitudinal Fragmentation Function (%.0f GeVGetXaxis()->SetTitle("z=p_{L}/P^{jet}"); + hgJetFragL[k][i]->GetYaxis()->SetTitle("dN/dz"); + + sprintf(dummy,"h%s-JetFragPL%d",name,i); + sprintf(title,"Longitudinal Momentum (%.0f GeVGetXaxis()->SetTitle("p_{L}"); + hgJetFragPL[k][i]->GetYaxis()->SetTitle("dN/dp_{L} [GeV^{-1}]"); + + sprintf(dummy,"h%s-JetFragT%d",name,i); + sprintf(title,"Transversal Fragmentation Function (%.0f GeVGetXaxis()->SetTitle("j_{T} [GeV]"); + hgJetFragT[k][i]->GetYaxis()->SetTitle("dN/dj_{T}"); + + sprintf(dummy,"h%s-JetFragPt%d",name,i); + sprintf(title,"Particle Transversal Momentum Distribution (%.0f GeVGetXaxis()->SetTitle("p_{T} [GeV]"); + hgJetFragPt[k][i]->GetYaxis()->SetTitle("dN/dp_{T}"); + + sprintf(dummy,"h%s-DiJetFragLeadingPt%d",name,i); + sprintf(title,"Fragmentation Function (%.0f GeVGetXaxis()->SetTitle("z=p_{T}/p_{T}^{lead.part.}"); + hgDiJetFragLeadingPt[k][i]->GetYaxis()->SetTitle("dN/dz"); + + sprintf(dummy,"h%s-DiJetFragL%d",name,i); + sprintf(title,"Longitudinal Fragmentation Function (%.0f GeVGetXaxis()->SetTitle("z=p_{L}/P^{jet}"); + hgDiJetFragL[k][i]->GetYaxis()->SetTitle("dN/dz"); + + sprintf(dummy,"h%s-DiJetFragPL%d",name,i); + sprintf(title,"Longitudinal Momentum (%.0f GeVGetXaxis()->SetTitle("p_{L}"); + hgDiJetFragPL[k][i]->GetYaxis()->SetTitle("dN/dp_{L} [GeV^{-1}]"); + + sprintf(dummy,"h%s-DiJetFragT%d",name,i); + sprintf(title,"Transversal Fragmentation Function (%.0f GeVGetXaxis()->SetTitle("j_{T} [GeV]"); + hgDiJetFragT[k][i]->GetYaxis()->SetTitle("dN/dj_{T}"); + + sprintf(dummy,"h%s-DiJetFragPt%d",name,i); + sprintf(title,"Particle Transversal Momentum Distribution (%.0f GeVGetXaxis()->SetTitle("p_{T} [GeV]"); + hgDiJetFragPt[k][i]->GetYaxis()->SetTitle("dN/dp_{T}"); + } + } + + //intshape + Float_t gretall[3][nclasses][10]; + Float_t gretlow[3][nclasses][10]; + Float_t gretlow1[3][nclasses][10]; + Float_t gretlow2[3][nclasses][10]; + Float_t gretlow3[3][nclasses][10]; + Float_t gretlow4[3][nclasses][10]; + Float_t grxet[10]; + for(Int_t i=0;i<10;i++) { + for(Int_t j=0;jGetXaxis()->SetTitle("p_{T} [GeV]"); + hPartPtDist->GetYaxis()->SetTitle("dN/dp_{T} [GeV^{-1}]"); + + TH1F *hPartPhiDist = new TH1F("hPartPhiDist","Azimuthal Distribution",120,0,TMath::TwoPi()); + hPartPhiDist->GetXaxis()->SetTitle("#phi"); + hPartPhiDist->GetYaxis()->SetTitle("dN/d#phi"); + + TH1F *hPartEtaDist = new TH1F("hPartEtaDist","Pseudo-Rapidity Distribution",100,-1,1); + hPartEtaDist->GetXaxis()->SetTitle("#eta"); + hPartEtaDist->GetYaxis()->SetTitle("dN/d#eta"); + + TH1F *hPartPhiCorr = new TH1F("hPartPhiCorr","Azimuthal Correlation",120,0,TMath::TwoPi()); + hPartPhiCorr->GetXaxis()->SetTitle("#phi"); + hPartPhiCorr->GetYaxis()->SetTitle("dN/d#phi"); + + TH1F *hPartDiPhiCorr = new TH1F("hPartDiPhiCorr","Azimuthal Correlation",120,0,TMath::TwoPi()); + hPartDiPhiCorr->GetXaxis()->SetTitle("#phi"); + hPartDiPhiCorr->GetYaxis()->SetTitle("dN/d#phi"); + + TH1F *hPartACorr = new TH1F("hPartACorr","Alpha Correlation",100,-1.1,1.1); + hPartACorr->GetXaxis()->SetTitle("#alpha"); + hPartACorr->GetYaxis()->SetTitle("dN/d#alpha"); + + TH1F *hPartDiACorr = new TH1F("hPartDiACorr","Alpha Correlation",100,-1.1,1.1); + hPartDiACorr->GetXaxis()->SetTitle("#alpha"); + hPartDiACorr->GetYaxis()->SetTitle("dN/d#alpha"); + + Int_t nTotalEvents = 0; + Int_t nclGoodEvents[nclasses]; + for(Int_t i=0;iAdd(filename); + AliTkConeJetEvent *event = new AliTkConeJetEvent(); + theTree->SetBranchAddress("ConeFinder",&event); + + Int_t treeentries=(Int_t)theTree->GetEntries(); + if((nMaxEvents<0) || (nMaxEvents>treeentries)) + nMaxEvents=treeentries; + + cout << "Found " << nMaxEvents << " in " << filename << endl; + + TChain *theEvTree=0; + AliJetEventParticles *jetevent=0; + TChain *theEvTree_sig=0; + AliJetEventParticles *jetevent_sig=0; + Int_t backtreeentries=0; + Int_t nPerBackground=0; + if(nPerBackground==0) nPerBackground=1; + + if(evfilename){ + theEvTree = new TChain("AJEPtree"); + theEvTree->Add(evfilename); + jetevent=new AliJetEventParticles(); + theEvTree->SetBranchAddress("particles",&jetevent); + Int_t evtreeentries=(Int_t)theEvTree->GetEntries(); + + if(sigevfilename){ + theEvTree_sig = new TChain("AJEPtree"); + theEvTree_sig->Add(sigevfilename); + jetevent_sig=new AliJetEventParticles(); + theEvTree_sig->SetBranchAddress("particles",&jetevent_sig); + evtreeentries=(Int_t)theEvTree_sig->GetEntries(); + backtreeentries=(Int_t)theEvTree->GetEntries(); + nPerBackground=nMaxEvents/backtreeentries; + if(nPerBackground==0) nPerBackground=1; + } + + if(evtreeentries!=treeentries){ + cerr << "WARNING: "; + cerr << "Total jet event number not equals event number: " + << evtreeentries << " " << treeentries <Add(signalfilename); + jetsigevent=new AliJetEventParticles(); + theSignalTree->SetBranchAddress("particles",&jetsigevent); + + Int_t sigtreeentries=(Int_t)theSignalTree->GetEntries(); + if(sigtreeentries!=treeentries){ + cerr << "WARNING: "; + cerr << "Total jet signal event number not equals event number: " + << sigtreeentries << " " << treeentries <Add(monteconefilename); + monteevent= new AliTkConeJetEvent(); + theTreeMonte->SetBranchAddress("ConeFinder",&monteevent); + Int_t montetreeentries=(Int_t)theTreeMonte->GetEntries(); + if(montetreeentries!=treeentries){ + cerr << "WARNING: "; + cerr << "Total monte jet event number not equals jet event number: " + << montetreeentries << " " << treeentries <GetEntries(); + if(montetreeentries!=sigtreeentries){ + cerr << "WARNING: "; + cerr << "Total signal cone jet event number not equals signal event number: " + << sigtreeentries << " " << montetreeentries <Clear(); + theTree->GetEvent(nEvent); + event->sortJets(); + //event->Print(""); + Float_t ptcutused=event->getPtCut(); + if(ptcutusedgetJets(); + + if(theEvTree_sig){ // need to mix + if(nEventHijingCounter==nPerBackground){ + jetevent->Reset(); + nEventHijing++; + theEvTree->GetEvent(nEventHijing); + //jetevent->Print(); + if(nEventHijing==backtreeentries) nEventHijing=0; + nEventHijingCounter=0; + } + jetevent_sig->Reset(); + theEvTree_sig->GetEvent(nEvent); + //jetevent_sig->Print(); + jetevent->AddSignal(*jetevent_sig); + TString dummy="Counter: "; + dummy+=nEvent; + dummy+=" "; + dummy+="(Pythia ";dummy+=nEvent; + dummy+=" "; + dummy+=", Hijing ";dummy+=nEventHijing; + dummy+=")"; + jetevent->SetHeader(dummy); + nEventHijingCounter++; + } else if(theEvTree){ + theEvTree->GetEvent(nEvent); + } + else{ + jetevent=event->getJetParticles(); + } + + if(theSignalTree){ //get MC event containing signal + jetsigevent->Reset(); + theSignalTree->GetEvent(nEventSig); +#if 1 + if(jetsigevent->GetEventNr()!=jetevent->GetEventNr()){ + Int_t js=jetsigevent->GetEventNr(); + Int_t es=jetevent->GetEventNr(); + cerr << "Need to skip event: " << nEvent << ": " << es << " != " << js << endl; + if(es>js) nEventSig++; + else nEvent++; + continue; + } +#endif + } + else { + jetsigevent=jetevent; + } + + //connect the monte cone jets + TClonesArray *montejets=0; + if(theTreeMonte){ + monteevent->Clear(); + theTreeMonte->GetEvent(nEventSig); + monteevent->sortJets(); + //monteevent->Print(""); + montejets=monteevent->getJets(); + } + + // + //jetevent->Print(); + // + + Int_t njets=jets->GetEntries(); + if(!jets || !njets){ + cerr << "No Cone jet found in event " << nEvent << ", continuing..." <getHeader(); + //Int_t ntrials=jetsigevent->Trials(); + jetsigevent->Hard(0,phard,type); + if(type!=0){ + Float_t ptj,thj,etaj,phj; + convert(phard,ptj,thj,etaj,phj); + new ((*chard_jets)[nhard]) AliTkConeJet(ptj,etaj,phj,(Int_t)type); + nhard++; + } + jetsigevent->Hard(1,phard,type); + if(type!=0){ + Float_t ptj,thj,etaj,phj; + convert(phard,ptj,thj,etaj,phj); + new ((*chard_jets)[nhard]) AliTkConeJet(ptj,etaj,phj,(Int_t)type); + nhard++; + } + chard_jets->Sort(); + //chard_jets->Print(); + + Int_t ntr=jetsigevent->NTriggerJets(); + Float_t tr_jets[ntr][3]; // trigger jets + TClonesArray *ctr_jets=new TClonesArray("AliTkConeJet",ntr); + Float_t lead_tr_pt=-1.,lead_tr_phi=0,lead_tr_eta=0.; + for(Int_t j=0;jTriggerJet(j,pjet); + convert(pjet,ptj,thj,etaj,phj); + tr_jets[j][0]=ptj; + tr_jets[j][1]=phj; + tr_jets[j][2]=etaj; + new ((*ctr_jets)[j]) AliTkConeJet(ptj,etaj,phj); + if(lead_tr_ptAt(j); + diff=AliTkConeJet::Diff(jet,(AliTkConeJet*)chard_jets->At(i),etdiff,phidiff,etadiff); + //cout << diff << " " << etdiff << " " << phidiff << " " << etadiff << endl; + if(diff<0.25) { + jet->setType((Int_t)type); + break; + } + } + } + ctr_jets->Sort(); + //ctr_jets->Print(); + Int_t ntruq=jetsigevent->NUQTriggerJets(); + Float_t uq_jets[ntruq][3]; // unquenched jets + TClonesArray *cuq_jets=new TClonesArray("AliTkConeJet",ntruq); + Float_t lead_uq_pt=-1.,lead_uq_phi=0,lead_uq_eta=0.; + for(Int_t j=0;jUQJet(j,pjet); + convert(pjet,ptj,thj,etaj,phj); + uq_jets[j][0]=ptj; + uq_jets[j][1]=phj; + uq_jets[j][2]=etaj; + new ((*cuq_jets)[j]) AliTkConeJet(ptj,etaj,phj); + if(lead_uq_ptSort(); + //cuq_jets->Print(); + + Double_t x0=jetsigevent->GetXJet(); + Double_t y0=jetsigevent->GetYJet(); + Double_t prodlength=TMath::Sqrt(x0*x0+y0*y0); + Double_t zquench[4]; + jetsigevent->GetZQuench(zquench); + + //fill trigger histos (without cuts) + hJetEtUQTrigger->Fill(lead_uq_pt); + hJetEtTrigger->Fill(lead_tr_pt); + for(Int_t i=0;i<2;i++){ + hJetZ->Fill(zquench[i]); + } + //reconstruction efficiency plots + if(ntr) for(Int_t j=0;j<1/*ntr*/;j++){ //loop over MC jets + Float_t diff,etdiff,etadiff,phidiff; + Float_t mindiff=100; + Int_t index=-1; + AliTkConeJet *jt=(AliTkConeJet*)ctr_jets->At(j); + if(jt->getEt()getEt()>maxEtRecoCut) continue; + //if(TMath:Abs(jt->getEta())>0.1) continue, + //jets in event + Int_t njets=jets->GetEntries(); + AliTkConeJet *jet=0; + for(Int_t i=0;iAt(i); + if(!jet) continue; + jet->calculateValues(); + diff=AliTkConeJet::Diff(jt,jet,etdiff,phidiff,etadiff); + //_cut_ here if wanted (prob. for mixed events) + //if(phidiff>0.25||etadiff>0.25) continue; + //if(TMath::Abs(etdiff)/jt->getEt()>0.1) continue; + //cout << diff << " " << etdiff << " " << phidiff << " " << etadiff << endl; + if(mindiff>diff){ + mindiff=diff; + index=i; + } + } + if(index>-1) { + jet=(AliTkConeJet*)jets->At(index); + hJetEtres->Fill(jet->getEt()); + hJetEtresTrigger->Fill(jt->getEt()); + hJetEtratio->Fill(jet->getEt()/jt->getEt()); + Float_t phidiff=(jt->getPhi()-jet->getPhi()); + if(phidiff>TMath::Pi()) phidiff=TMath::TwoPi()-phidiff; + Float_t etadiff=(jt->getEta()-jet->getEta()); + Float_t etfract=jet->getEtMarkedFrac(); + hAxesDiffres->Fill(phidiff,etadiff,TMath::Abs(jet->getEt()-jt->getEt())); + hJetEtrestrue->Fill(jet->getEt(),etfract); + hPhires->Fill(phidiff); + hEtares->Fill(etadiff); + //cout << "test" << nEvent << " " << phidiff << " " << etadiff << endl; + } + } + if(theTreeMonte){ + //compare leading jets from Monte and Reconstruction + AliTkConeJet *jt=(AliTkConeJet*)jets->At(0); + AliTkConeJet *mjt=(AliTkConeJet*)montejets->At(0); + if(jt && mjt){ + Float_t phidiff=(jt->getPhi()-mjt->getPhi()); + if(phidiff>TMath::Pi()) phidiff=TMath::TwoPi()-phidiff; + Float_t etadiff=(jt->getEta()-mjt->getEta()); + Float_t etdiff=jt->getEt()-mjt->getEt(); + hPhiMonteres->Fill(phidiff); + hEtaMonteres->Fill(etadiff); + hEtMonteres->Fill(etdiff); + hEtMonteratio->Fill(jt->getEt()/mjt->getEt()); + } + for(Int_t j=0;j<1/*montejets->Entries()*/;j++){ + Float_t diff,etdiff,etadiff,phidiff; + Float_t mindiff=100; + Int_t index=-1; + AliTkConeJet *jt=(AliTkConeJet*)montejets->At(j); + if(!jt) continue; + //if(jt->getEt()getEt()>maxEtRecoCut) continue; + //jets in event + Int_t njets=jets->GetEntries(); + AliTkConeJet *jet=0; + for(Int_t i=0;iAt(i); + if(!jet) continue; + jet->calculateValues(); + diff=AliTkConeJet::Diff(jt,jet,etdiff,phidiff,etadiff); + //_cut_ here if wanted (prob. for mixed events) + //if(phidiff>0.25||etadiff>0.25) continue; + //if(TMath::Abs(etdiff)/jt->getEt()>0.1) continue; + //cout << diff << " " << etdiff << " " << phidiff << " " << etadiff << endl; + if(mindiff>diff){ + mindiff=diff; + index=i; + } + } + if(index>-1) { + jet=(AliTkConeJet*)jets->At(index); + hmJetEtres->Fill(jet->getEt()); + hmJetEtratio->Fill(jet->getEt()/jt->getEt()); + Float_t phidiff=(jt->getPhi()-jet->getPhi()); + if(phidiff>TMath::Pi()) phidiff=TMath::TwoPi()-phidiff; + Float_t etadiff=(jt->getEta()-jet->getEta()); + Float_t etfract=jet->getEtMarkedFrac(); + hmAxesDiffres->Fill(phidiff,etadiff,TMath::Abs(jet->getEt()-jt->getEt())); + hmJetEtrestrue->Fill(jet->getEt(),etfract); + hmPhires->Fill(phidiff); + hmEtares->Fill(etadiff); + } + } + } + + //could _cut_ on event +#if 0 + //cout << lead_tr_pt << " " << lead_tr_eta << " " << lead_tr_phi << endl; + if((lead_tr_eta>0.5) || (lead_tr_eta<-0.5)) continue; + if(zquench[0]<0.1||zquench[1]<0.1) continue; +#endif + + //particles in event + const TClonesArray *parts=jetevent->GetParticles(); + + //jets in event + AliTkConeJet *lead_jet=0; + AliTkConeJet *back_jet=0; + for(Int_t i=0;iAt(i); + if(!jet) continue; + jet->calculateValues(); + + hJetEtall->Fill(jet->getEt()); //without any cuts + Float_t etfract=jet->getEtMarkedFrac(); + hJetEtalltrue->Fill(jet->getEt(),etfract); //without any cuts + + //here could _cut_ on jet + //------- + Float_t et=jet->getEt(); + Float_t corret=et; + if(corrfac>0) corret/=corrfac; + if(corretnclasses-2) clindex=nclasses-2; + nclGoodEvents[clindex]++; + nclGoodEvents[nclasses-1]++; + //------- + + //set jet type + for(Int_t i=0;iAt(i); + diff=AliTkConeJet::Diff(jet,jh,etdiff,phidiff,etadiff); + //cout << diff << " " << etdiff << " " << phidiff << " " << etadiff << endl; + if(diff<0.25) { + jet->setType(jh->getType()); + break; + } + } + + //check leading jet + if(!lead_jet){ + lead_jet=jet; + whichjet=1; + hJetEt->Fill(lead_jet->getEt()); + hJetEttrue->Fill(lead_jet->getEt(),etfract); + Float_t mindiff=100; + Float_t minetdiff=0.,minphidiff=0.,minetadiff=0.; + Int_t index; + for(Int_t j=0;jAt(j); + diff=AliTkConeJet::Diff(lead_jet,jt,etdiff,phidiff,etadiff); + if(mindiff>diff){ + mindiff=diff; + index=j; + minphidiff=phidiff; + minetadiff=etadiff; + minetdiff=etdiff; + } + } + if(TMath::Abs(minetdiff)/lead_jet->getEt()<0.15) + hAxesDiff->Fill(minphidiff,minetadiff); + + //trigger + Float_t triget=lead_jet->getEt(); + Float_t leadet=((AliTkConeJet*)ctr_jets->At(0))->getEt(); + for(Int_t i=0;i<9;i++){ + Float_t minet=i*10+10; + if(triget>=minet) hJetEttrigger[i]->Fill(leadet,1); + else hJetEttrigger2[i]->Fill(leadet,1); + } + hJetEttriggernorm->Fill(leadet,1); + }// check the back-to-back jet + else if ((jet->getEt()/lead_jet->getEt()>0.75) && + (relphi(jet->getPhi(),lead_jet->getPhi())>5/6*TMath::Pi())){ + if(!back_jet) { + whichjet=2; + back_jet=jet; + hBackJetEt->Fill(back_jet->getEt()); + hBackJetEttrue->Fill(back_jet->getEt(),etfract); + hJetEtvsEt->Fill(lead_jet->getEt(),back_jet->getEt()); + + } else{ + cerr << "Already found one back jet, disregarding the new one." << endl; + } + } + + //fill properties + hJetEtvsTrigger->Fill(corret,lead_tr_pt); + hJetEtvsUQTrigger->Fill(corret,lead_uq_pt); + hJetEtallvsEll->Fill(corret,prodlength); + hJetEtvsEll->Fill(corret,prodlength); + hJettype[jet->getType()]->Fill(jet->getEt()); + + Int_t njetparts=jet->getNParts(); + hJetN[clindex]->Fill(njetparts); + hJetN[nclasses-1]->Fill(njetparts); + Float_t leadPartPt=jet->getPtLead(); + Float_t ptRatio=0; + if(corret>0) ptRatio=leadPartPt/corret; + Float_t meanpt=0.; + if(njetparts>0) meanpt=corret/njetparts; + hJetMeanPt[clindex]->Fill(meanpt); + hJetMeanPt[nclasses-1]->Fill(meanpt); + hJetLeadingPt[clindex]->Fill(ptRatio); + hJetLeadingPt[nclasses-1]->Fill(ptRatio); + hJetLeadingPtDist[clindex]->Fill(leadPartPt); + hJetLeadingPtDist[nclasses-1]->Fill(leadPartPt); + + Float_t jetAxisX=jet->getXAxis(); + Float_t jetAxisY=jet->getYAxis(); + Float_t jetAxisZ=jet->getZAxis(); + Float_t jetAxisLength=jet->getPLength(); + if(jetAxisLength) { + TClonesArray *particles = jet->getParts(); + TIterator *partit = particles->MakeIterator(); + TParticle *particle = NULL; + Int_t firstval=0; + while ((particle = (TParticle *) partit->Next()) != NULL) { + Float_t al=particle->Px()*jetAxisX+particle->Py()*jetAxisY+particle->Pz()*jetAxisZ; + if(al<0){ + //cout << "Should not happen!" << al << endl; + continue; + } + Float_t at=TMath::Sqrt(TMath::Abs(particle->P()*particle->P()-al*al)); + hJetFragL[clindex]->Fill(al/jetAxisLength); + hJetFragT[clindex]->Fill(at); + hJetFragPL[clindex]->Fill(al); + hJetFragPt[clindex]->Fill(particle->Pt()); + hJetFragL[nclasses-1]->Fill(al/jetAxisLength); + hJetFragT[nclasses-1]->Fill(at); + hJetFragPL[nclasses-1]->Fill(al); + hJetFragPt[nclasses-1]->Fill(particle->Pt()); + if(leadPartPt>0){ + Float_t z=particle->Pt()/leadPartPt; + if(firstval||z<1){ + hJetFragLeadingPt[clindex]->Fill(z); + hJetFragLeadingPt[nclasses-1]->Fill(z); + } else if(z==1) firstval=1; + } + } + delete partit; + } + + //calculate int/diff shapes + Float_t jeteta=jet->getCEta(); + Float_t jetphi=jet->getCPhi(); + AliTkEtaPhiVector center(jeteta,jetphi); + TIterator *partit = parts->MakeIterator(); + AliJetParticle *particle = NULL; + while ((particle = (AliJetParticle *) partit->Next()) != NULL) { + Float_t pt=particle->Pt(); + if(ptEta(),particle->Phi()); + Float_t diff=center.diff(centerp); + for(Int_t loop=Int_t(diff*10)+1;loop<=10;loop++){ + if(pt<1.) retlow1[clindex][loop-1]+=pt; + if(pt<2.) retlow[clindex][loop-1]+=pt; + if(pt<3.) retlow2[clindex][loop-1]+=pt; + if(pt<4.) retlow3[clindex][loop-1]+=pt; + if(pt<5.) retlow4[clindex][loop-1]+=pt; + retall[clindex][loop-1]+=pt; + if(pt<1.) retlow1[nclasses-1][loop-1]+=pt; + if(pt<2.) retlow[nclasses-1][loop-1]+=pt; + if(pt<3.) retlow2[nclasses-1][loop-1]+=pt; + if(pt<4.) retlow3[nclasses-1][loop-1]+=pt; + if(pt<5.) retlow4[nclasses-1][loop-1]+=pt; + retall[nclasses-1][loop-1]+=pt; + } + if(diff<=1){ + Int_t index=0; + if(diff<=deltaR) index=0; + else index=Int_t((diff-deltaR)*10)+1; + if(pt<1.) dretlow1[clindex][index]+=pt; + if(pt<2.) dretlow[clindex][index]+=pt; + if(pt<3.) dretlow2[clindex][index]+=pt; + if(pt<4.) dretlow3[clindex][index]+=pt; + if(pt<5.) dretlow4[clindex][index]+=pt; + dretall[clindex][index]+=pt; + if(pt<1.) dretlow1[nclasses-1][index]+=pt; + if(pt<2.) dretlow[nclasses-1][index]+=pt; + if(pt<3.) dretlow2[nclasses-1][index]+=pt; + if(pt<4.) dretlow3[nclasses-1][index]+=pt; + if(pt<5.) dretlow4[nclasses-1][index]+=pt; + dretall[nclasses-1][index]+=pt; + } + if(ptPhi(); + + Float_t dphi=diffphi(jet->getPhi(),phi); + hPhiCorr[clindex]->Fill(dphi); + hPhiCorr[nclasses-1]->Fill(dphi); + } + delete partit; + + } //loop over cone jets + + //global event studies + TIterator *partit = parts->MakeIterator(); + AliJetParticle *particle = NULL; + Float_t leta=0.; + Float_t lphi=0.; + Int_t clindex=-1; + Float_t jetAxisX=-1; + Float_t jetAxisY=-1; + Float_t jetAxisZ=-1; + Float_t jetAxisLength=-1; + Float_t leadPartPt=-1; + if(lead_jet){ + leta=lead_jet->getCEta(); + lphi=lead_jet->getCPhi(); + jetAxisX=lead_jet->getXAxis(); + jetAxisY=lead_jet->getYAxis(); + jetAxisZ=lead_jet->getZAxis(); + jetAxisLength=lead_jet->getPLength(); + leadPartPt=lead_jet->getPtLead(); + centers[0]=new AliTkEtaPhiVector(leta,lphi); + centers[1]=new AliTkEtaPhiVector(leta,addphi(lphi,TMath::Pi())); + centers[2]=new AliTkEtaPhiVector(leta,addphi(lphi,TMath::Pi()/2)); + centers[3]=new AliTkEtaPhiVector(leta,addphi(lphi,3*TMath::Pi()/2)); + Float_t et=lead_jet->getEt(); + Float_t corret=et; + if(corrfac>0) corret/=corrfac; + clindex=Int_t(corret/10); + if(clindex>nclasses-2) clindex=nclasses-2; + nclLeadEvents[clindex]++; + nclLeadEvents[nclasses-1]++; + if(back_jet){ + nclDiEvents[clindex]++; + nclDiEvents[nclasses-1]++; + } + } + + //loop over particles in event + Int_t firstval=0; + Int_t difirstval=0; + while ((particle = (AliJetParticle *) partit->Next()) != NULL) { + Float_t pt=particle->Pt(); + if(ptEta(); + Float_t phi=particle->Phi(); + hPartPtDist->Fill(pt); + hPartPhiDist->Fill(phi); + hPartEtaDist->Fill(eta); + if(lead_jet){ + Float_t dphi=diffphi(lphi,phi); + Float_t al=particle->Px()*jetAxisX+particle->Py()*jetAxisY+particle->Pz()*jetAxisZ; + al/=particle->P(); + hPartPhiCorr->Fill(dphi); + hPartACorr->Fill(al); + if(back_jet){ + hPartDiPhiCorr->Fill(dphi); + hPartDiACorr->Fill(al); + } + + //ue studies + for(Int_t ceindex=0;ceindex<4;ceindex++){ + Int_t heindex=ceindex; + if(heindex==3) heindex=2; //store both sides of trans plane in one histo + + AliTkEtaPhiVector centerp; + centerp.setVector(eta,phi); + Float_t diff=centers[ceindex]->diff(centerp); + for(Int_t loop=Int_t(diff*10)+1;loop<=10;loop++){ + if(pt<1.) gretlow1[heindex][clindex][loop-1]+=pt; + if(pt<2.) gretlow[heindex][clindex][loop-1]+=pt; + if(pt<3.) gretlow2[heindex][clindex][loop-1]+=pt; + if(pt<4.) gretlow3[heindex][clindex][loop-1]+=pt; + if(pt<5.) gretlow4[heindex][clindex][loop-1]+=pt; + gretall[heindex][clindex][loop-1]+=pt; + if(pt<1.) gretlow1[heindex][nclasses-1][loop-1]+=pt; + if(pt<2.) gretlow[heindex][nclasses-1][loop-1]+=pt; + if(pt<3.) gretlow2[heindex][nclasses-1][loop-1]+=pt; + if(pt<4.) gretlow3[heindex][nclasses-1][loop-1]+=pt; + if(pt<5.) gretlow4[heindex][nclasses-1][loop-1]+=pt; + gretall[heindex][nclasses-1][loop-1]+=pt; + } + if(diff<=1){ + Int_t index=0; + if(diff<=deltaR) index=0; + else index=Int_t((diff-deltaR)*10)+1; + if(pt<1.) gdretlow1[heindex][clindex][index]+=pt; + if(pt<2.) gdretlow[heindex][clindex][index]+=pt; + if(pt<3.) gdretlow2[heindex][clindex][index]+=pt; + if(pt<4.) gdretlow3[heindex][clindex][index]+=pt; + if(pt<5.) gdretlow4[heindex][clindex][index]+=pt; + gdretall[heindex][clindex][index]+=pt; + if(pt<1.) gdretlow1[heindex][nclasses-1][index]+=pt; + if(pt<2.) gdretlow[heindex][nclasses-1][index]+=pt; + if(pt<3.) gdretlow2[heindex][nclasses-1][index]+=pt; + if(pt<4.) gdretlow3[heindex][nclasses-1][index]+=pt; + if(pt<5.) gdretlow4[heindex][nclasses-1][index]+=pt; + gdretall[heindex][nclasses-1][index]+=pt; + } + if(back_jet){ + for(Int_t loop=Int_t(diff*10)+1;loop<=10;loop++){ + if(pt<1.) gdiretlow1[heindex][clindex][loop-1]+=pt; + if(pt<2.) gdiretlow[heindex][clindex][loop-1]+=pt; + if(pt<3.) gdiretlow2[heindex][clindex][loop-1]+=pt; + if(pt<4.) gdiretlow3[heindex][clindex][loop-1]+=pt; + if(pt<5.) gdiretlow4[heindex][clindex][loop-1]+=pt; + gdiretall[heindex][clindex][loop-1]+=pt; + if(pt<1.) gdiretlow1[heindex][nclasses-1][loop-1]+=pt; + if(pt<2.) gdiretlow[heindex][nclasses-1][loop-1]+=pt; + if(pt<3.) gdiretlow2[heindex][nclasses-1][loop-1]+=pt; + if(pt<4.) gdiretlow3[heindex][nclasses-1][loop-1]+=pt; + if(pt<5.) gdiretlow4[heindex][nclasses-1][loop-1]+=pt; + gdiretall[heindex][nclasses-1][loop-1]+=pt; + } + if(diff<=1){ + Int_t index=0; + if(diff<=deltaR) index=0; + else index=Int_t((diff-deltaR)*10)+1; + if(pt<1.) gdidretlow1[heindex][clindex][index]+=pt; + if(pt<2.) gdidretlow[heindex][clindex][index]+=pt; + if(pt<3.) gdidretlow2[heindex][clindex][index]+=pt; + if(pt<4.) gdidretlow3[heindex][clindex][index]+=pt; + if(pt<5.) gdidretlow4[heindex][clindex][index]+=pt; + gdidretall[heindex][clindex][index]+=pt; + if(pt<1.) gdretlow1[heindex][nclasses-1][index]+=pt; + if(pt<2.) gdretlow[heindex][nclasses-1][index]+=pt; + if(pt<3.) gdidretlow2[heindex][nclasses-1][index]+=pt; + if(pt<4.) gdidretlow3[heindex][nclasses-1][index]+=pt; + if(pt<5.) gdidretlow4[heindex][nclasses-1][index]+=pt; + gdidretall[heindex][nclasses-1][index]+=pt; + } + } + }//ceindex + + Int_t ceindex=eventindex(lphi,phi); + Int_t heindex=ceindex; + if(heindex==3) heindex=2; //store both sides of trans plane in one histo + + if(jetAxisLength) { + Float_t jetX=jetAxisX; + Float_t jetY=jetAxisY; + if(ceindex==1) { + jetX=-jetAxisX; + jetY=-jetAxisY; + } else if(ceindex==2) { + jetX=-jetAxisY; + jetY=jetAxisX; + } + else if(ceindex==3) { + jetX=jetAxisY; + jetY=-jetAxisX; + } + Float_t al=particle->Px()*jetX+particle->Py()*jetY+particle->Pz()*jetAxisZ; + Float_t at=TMath::Sqrt(TMath::Abs(particle->P()*particle->P()-al*al)); + hgJetFragL[heindex][clindex]->Fill(al/jetAxisLength); + hgJetFragT[heindex][clindex]->Fill(at); + hgJetFragPL[heindex][clindex]->Fill(al); + hgJetFragPt[heindex][clindex]->Fill(particle->Pt()); + hgJetFragL[heindex][nclasses-1]->Fill(al/jetAxisLength); + hgJetFragT[heindex][nclasses-1]->Fill(at); + hgJetFragPL[heindex][nclasses-1]->Fill(al); + hgJetFragPt[heindex][nclasses-1]->Fill(particle->Pt()); + if(leadPartPt>0){ + Float_t z=particle->Pt()/leadPartPt; + if(firstval||z<1){ + hgJetFragLeadingPt[heindex][clindex]->Fill(z); + hgJetFragLeadingPt[heindex][nclasses-1]->Fill(z); + } else if(z==1) firstval=1; + } + if(back_jet){ + hgDiJetFragL[heindex][clindex]->Fill(al/jetAxisLength); + hgDiJetFragT[heindex][clindex]->Fill(at); + hgDiJetFragPL[heindex][clindex]->Fill(al); + hgDiJetFragPt[heindex][clindex]->Fill(particle->Pt()); + hgDiJetFragL[heindex][nclasses-1]->Fill(al/jetAxisLength); + hgDiJetFragT[heindex][nclasses-1]->Fill(at); + hgDiJetFragPL[heindex][nclasses-1]->Fill(al); + hgDiJetFragPt[heindex][nclasses-1]->Fill(particle->Pt()); + if(leadPartPt>0){ + Float_t z=particle->Pt()/leadPartPt; + if(difirstval||z<1){ + hgDiJetFragLeadingPt[heindex][clindex]->Fill(z); + hgDiJetFragLeadingPt[heindex][nclasses-1]->Fill(z); + } else if(z==1) difirstval=1; + } + } + } + } //lead_jet + + } + delete partit; + if(lead_jet) + for(Int_t i=0;i<4;i++) delete centers[i]; + + nTotalEvents++; + } //end of nev loop + + cout << "Finished analysing events " << nTotalEvents << endl; + + delete centers; + delete event; + delete theTree; + if(theEvTree){ + delete jetevent; + delete theEvTree; + } + if(theSignalTree){ + delete jetsigevent; + delete theSignalTree; + } + if(theTreeMonte){ + delete monteevent; + delete theTreeMonte; + } + + //======================================================================== + // draw histograms + //======================================================================== + + TTimeStamp tstamp; + Char_t timestamp[255]; + sprintf(timestamp,"%d",tstamp.GetDate(0,0)); + + //store all objects in root file (you never know, when you need it) + Char_t rootfilename[1024]; + if(savefilename!=NULL) + sprintf(rootfilename,"%s",savefilename); + else + sprintf(rootfilename,"%s/anaAliJets-%s.root",gSystem->Getenv("JF_PLOTSDIR"),timestamp); + TFile *rootfile=new TFile(rootfilename,"RECREATE"); + + // let's start with the drawing... + Int_t nents=(Int_t)hJetEt->GetEntries(); + if(nents){ + cout << "hJetEt: " << nents << " entries in histogram" << endl; + hJetEt->SetLineWidth(3); + hJetEt->Write(); + } + + nents=(Int_t)hJetEttrue->GetEntries(); + if(nents){ + cout << "hJetEttrue: " << nents << " entries in histogram" << endl; + hJetEttrue->SetLineWidth(3); + hJetEttrue->Write(); + } + + nents=(Int_t)hBackJetEt->GetEntries(); + if(nents){ + cout << "hBackJetEt: " << nents << " entries in histogram" << endl; + hBackJetEt->SetLineWidth(3); + hBackJetEt->Write(); + } + + nents=(Int_t)hBackJetEttrue->GetEntries(); + if(nents){ + cout << "hBackJetEttrue: " << nents << " entries in histogram" << endl; + hBackJetEttrue->SetLineWidth(3); + hBackJetEttrue->Write(); + } + + nents=(Int_t)hJetEtall->GetEntries(); + if(nents){ + cout << "hJetEtall: " << nents << " entries in histogram" << endl; + hJetEtall->SetLineWidth(3); + hJetEtall->Write(); + } + + nents=(Int_t)hJetEtalltrue->GetEntries(); + if(nents){ + cout << "hJetEtalltrue: " << nents << " entries in histogram" << endl; + hJetEtalltrue->SetLineWidth(3); + hJetEtalltrue->Write(); + } + + nents=(Int_t)hJetEtUQTrigger->GetEntries(); + if(nents){ + cout << "hJetEtUQTrigger: " << nents << " entries in histogram" << endl; + hJetEtUQTrigger->SetLineWidth(3); + hJetEtUQTrigger->Write(); + } + nents=(Int_t)hJetEtTrigger->GetEntries(); + if(nents){ + cout << "hJetEtTrigger: " << nents << " entries in histogram" << endl; + hJetEtTrigger->SetLineWidth(3); + hJetEtTrigger->Write(); + } + + rootfile->cd(); + rootfile->mkdir("LeadingPt"); + rootfile->cd("LeadingPt"); + for(Int_t i=0;iGetEntries(); + if(nents){ + //cout << "hJetLeadingPt " << i << ": " << nents << " entries in histogram" << endl; + hJetLeadingPt[i]->SetLineWidth(3); + hJetLeadingPt[i]->Write(); + } + } + + rootfile->cd(); + rootfile->mkdir("FragLeadingPt"); + rootfile->cd("FragLeadingPt"); + for(Int_t i=0;iGetEntries(); + if(nents){ + //cout << "hJetFragLeadingPt " << i << ": " << nents << " entries in histogram" << endl; + hJetFragLeadingPt[i]->SetLineWidth(3); + hJetFragLeadingPt[i]->Write(); + } + } + + rootfile->cd(); + rootfile->mkdir("LeadingPtDist"); + rootfile->cd("LeadingPtDist"); + for(Int_t i=0;iGetEntries(); + if(nents){ + //cout << "hJetLeadingPtDist " << i << ": " << nents << " entries in histogram" << endl; + hJetLeadingPtDist[i]->SetLineWidth(3); + hJetLeadingPtDist[i]->Write(); + } + } + + rootfile->cd(); + rootfile->mkdir("FragLong"); + rootfile->cd("FragLong"); + for(Int_t i=0;iGetEntries(); + if(nents){ + //cout << "hJetFragL " << i << ": " << nents << " entries in histogram " << endl; + hJetFragL[i]->SetLineWidth(3); + hJetFragL[i]->Write(); + } + } + + rootfile->cd(); + rootfile->mkdir("FragPL"); + rootfile->cd("FragPL"); + for(Int_t i=0;iGetEntries(); + if(nents){ + //cout << "hJetFragPL " << i << ": " << nents << " entries in histogram " << endl; + hJetFragPL[i]->SetLineWidth(3); + hJetFragPL[i]->Write(); + } + } + + rootfile->cd(); + rootfile->mkdir("FragTrans"); + rootfile->cd("FragTrans"); + for(Int_t i=0;iGetEntries(); + if(nents){ + //cout << "hJetFragT " << i << ": " << nents << " entries in histogram" << endl; + hJetFragT[i]->SetLineWidth(3); + hJetFragT[i]->Write(); + } + } + + rootfile->cd(); + rootfile->mkdir("Multiplicity"); + rootfile->cd("Multiplicity"); + for(Int_t i=0;iGetEntries(); + //cout <<"hJetN " << i << ": " << nents << " entries in histogram " << endl; + if(nents){ + hJetN[i]->SetLineWidth(3); + hJetN[i]->Write(); + } + } + + rootfile->cd(); + rootfile->mkdir("PtDistribution"); + rootfile->cd("PtDistribution"); + for(Int_t i=0;iGetEntries(); + if(nents){ + //cout << "hJetFragPt " << i << ": " << nents << " entries in histogram " << endl; + hJetFragPt[i]->SetLineWidth(3); + hJetFragPt[i]->Write(); + } + } + + rootfile->cd(); + rootfile->mkdir("MeanPt"); + rootfile->cd("MeanPt"); + for(Int_t i=0;iGetEntries(); + if(nents){ + //cout << "hJetMeanPt " << i << ": " << nents << " entries in histogram " << endl; + hJetMeanPt[i]->SetLineWidth(3); + hJetMeanPt[i]->Write(); + } + } + + rootfile->cd(); + rootfile->mkdir("PhiCorr"); + rootfile->cd("PhiCorr"); + for(Int_t i=0;iGetEntries(); + if(nents){ + //cout << "hPhiCorr " << i << ": " << nents << " entries in histogram " << endl; + hPhiCorr[i]->SetLineWidth(3); + hPhiCorr[i]->Write(); + } + } + + rootfile->cd();//intshape + rootfile->mkdir("ConeFluc"); + rootfile->cd("ConeFluc"); + for(Int_t j=0;jSetPoint(i,rxet[i],retall[j][i]); + graphlow->SetPoint(i,rxet[i],retlow[j][i]); + graphlow1->SetPoint(i,rxet[i],retlow1[j][i]); + graphlow2->SetPoint(i,rxet[i],retlow2[j][i]); + graphlow3->SetPoint(i,rxet[i],retlow3[j][i]); + graphlow4->SetPoint(i,rxet[i],retlow4[j][i]); + } + sprintf(dummy,"gretall%d",j); + graphall->Write(dummy); + sprintf(dummy,"gretlow%d",j); + graphlow->Write(dummy); + sprintf(dummy,"gret2low%d",j); + graphlow->Write(dummy); + sprintf(dummy,"gret1low%d",j); + graphlow1->Write(dummy); + sprintf(dummy,"gret3low%d",j); + graphlow2->Write(dummy); + sprintf(dummy,"gret4low%d",j); + graphlow3->Write(dummy); + sprintf(dummy,"gret5low%d",j); + graphlow4->Write(dummy); + delete graphall; + delete graphlow; + delete graphlow1; + delete graphlow2; + delete graphlow3; + } + + rootfile->cd(); + rootfile->mkdir("Shape"); + rootfile->cd("Shape"); + for(Int_t j=0;jSetPoint(i,drxet[i],dretall[j][i]/deltaR); + graphlow->SetPoint(i,drxet[i],dretlow[j][i]/deltaR); + graphlow1->SetPoint(i,drxet[i],dretlow1[j][i]/deltaR); + graphlow2->SetPoint(i,drxet[i],dretlow2[j][i]/deltaR); + graphlow3->SetPoint(i,drxet[i],dretlow3[j][i]/deltaR); + graphlow4->SetPoint(i,drxet[i],dretlow4[j][i]/deltaR); + } + sprintf(dummy,"gretall%d",j); + graphall->Write(dummy); + sprintf(dummy,"gretlow%d",j); + graphlow->Write(dummy); + sprintf(dummy,"gret2low%d",j); + graphlow->Write(dummy); + sprintf(dummy,"gret1low%d",j); + graphlow1->Write(dummy); + sprintf(dummy,"gret3low%d",j); + graphlow2->Write(dummy); + sprintf(dummy,"gret4low%d",j); + graphlow3->Write(dummy); + sprintf(dummy,"gret5low%d",j); + graphlow4->Write(dummy); + delete graphall; + delete graphlow; + delete graphlow1; + delete graphlow2; + delete graphlow3; + } + + rootfile->cd(); + rootfile->mkdir("Extended"); + rootfile->cd("Extended"); + + nents=(Int_t)hJetEtvsTrigger->GetEntries(); + if(nents){ + cout << "hJetEtvsTrigger" << nents << " entries in histogram" << endl; + hJetEtvsTrigger->SetLineWidth(3); + hJetEtvsTrigger->Write(); + } + + nents=(Int_t)hJetEtvsEt->GetEntries(); + if(nents){ + cout << "hJetEtvsEt" << nents << " entries in histogram" << endl; + hJetEtvsEt->SetLineWidth(3); + hJetEtvsEt->Write(); + } + + nents=(Int_t)hAxesDiff->GetEntries(); + if(nents){ + cout << "hAxesDiff" << nents << " entries in histogram" << endl; + hAxesDiff->SetLineWidth(3); + hAxesDiff->Write(); + } + + nents=(Int_t)hJet1->GetEntries(); + if(nents){ + cout << "hJet1" << nents << " entries in histogram" << endl; + hJet1->SetLineWidth(3); + hJet1->Write(); + } + nents=(Int_t)hJet2->GetEntries(); + if(nents){ + cout << "hJet2" << nents << " entries in histogram" << endl; + hJet2->SetLineWidth(3); + hJet2->Write(); + } + + for(Int_t i=0;i<3;i++){ + nents=(Int_t)hJettype[i]->GetEntries(); + if(nents){ + hJettype[i]->SetLineWidth(3); + hJettype[i]->Write(); + } + } + + nents=(Int_t)hJetEtvsEll->GetEntries(); + if(nents){ + cout << "hJetEtvsEll" << nents << " entries in histogram " << endl; + hJetEtvsEll->SetLineWidth(3); + hJetEtvsEll->Write(); + } + + nents=(Int_t)hJetEtallvsEll->GetEntries(); + if(nents){ + cout << "hJetEtallvsEll" << nents << " entries in histogram " << endl; + hJetEtallvsEll->SetLineWidth(3); + hJetEtallvsEll->Write(); + } + + nents=(Int_t)hJetZ->GetEntries(); + if(nents){ + cout << "hJetZ: " << nents << " entries in histogram " << endl; + hJetZ->SetLineWidth(3); + hJetZ->Write(); + } + + rootfile->cd(); + rootfile->mkdir("Global"); + rootfile->cd("Global"); + + nents=(Int_t)hPartPtDist->GetEntries(); + if(nents){ + cout << "hPartPtDist: " << nents << " entries in histogram" << endl; + hPartPtDist->SetLineWidth(3); + hPartPtDist->Write(); + } + + nents=(Int_t)hPartEtaDist->GetEntries(); + if(nents){ + cout << "hPartEtaDist: " << nents << " entries in histogram" << endl; + hPartEtaDist->SetLineWidth(3); + hPartEtaDist->Write(); + } + + nents=(Int_t)hPartPhiDist->GetEntries(); + if(nents){ + cout << "hPartPhiDist: " << nents << " entries in histogram" << endl; + hPartPhiDist->SetLineWidth(3); + hPartPhiDist->Write(); + } + + nents=(Int_t)hPartPhiCorr->GetEntries(); + if(nents){ + cout << "hPartPhiCorr: " << nents << " entries in histogram" << endl; + hPartPhiCorr->SetLineWidth(3); + hPartPhiCorr->Write(); + } + + nents=(Int_t)hPartDiPhiCorr->GetEntries(); + if(nents){ + cout << "hPartDiPhiCorr: " << nents << " entries in histogram" << endl; + hPartDiPhiCorr->SetLineWidth(3); + hPartDiPhiCorr->Write(); + } + + nents=(Int_t)hPartACorr->GetEntries(); + if(nents){ + cout << "hPartACorr: " << nents << " entries in histogram" << endl; + hPartACorr->SetLineWidth(3); + hPartACorr->Write(); + } + + nents=(Int_t)hPartDiACorr->GetEntries(); + if(nents){ + cout << "hPartDiACorr: " << nents << " entries in histogram" << endl; + hPartDiACorr->SetLineWidth(3); + hPartDiACorr->Write(); + } + + rootfile->cd(); + rootfile->mkdir("gConeFluc"); + rootfile->cd("gConeFluc"); + for(Int_t k=0;k<3;k++){ + if(k==0){ + sprintf(name,"toward"); + } else if (k==1) { + sprintf(name,"away"); + } else { + sprintf(name,"transverse"); + } + + for(Int_t j=0;jSetPoint(i,grxet[i],gretall[k][j][i]); + graphlow->SetPoint(i,grxet[i],gretlow[k][j][i]); + graphlow1->SetPoint(i,grxet[i],gretlow1[k][j][i]); + graphlow2->SetPoint(i,grxet[i],gretlow2[k][j][i]); + graphlow3->SetPoint(i,grxet[i],gretlow3[k][j][i]); + graphlow4->SetPoint(i,grxet[i],gretlow4[k][j][i]); + } + sprintf(dummy,"%s-gretall%d",name,j); + graphall->Write(dummy); + sprintf(dummy,"%s-gretlow%d",name,j); + graphlow->Write(dummy); + sprintf(dummy,"%s-gret2low%d",name,j); + graphlow->Write(dummy); + sprintf(dummy,"%s-gret1low%d",name,j); + graphlow1->Write(dummy); + sprintf(dummy,"%s-gret3low%d",name,j); + graphlow2->Write(dummy); + sprintf(dummy,"%s-gret4low%d",name,j); + graphlow3->Write(dummy); + sprintf(dummy,"%s-gret5low%d",name,j); + graphlow4->Write(dummy); + delete graphall; + delete graphlow; + delete graphlow1; + delete graphlow2; + delete graphlow3; + } + } + + rootfile->cd(); + rootfile->mkdir("gShape"); + rootfile->cd("gShape"); + for(Int_t k=0;k<3;k++){ + if(k==0){ + sprintf(name,"toward"); + } else if (k==1) { + sprintf(name,"away"); + } else { + sprintf(name,"transverse"); + } + + for(Int_t j=0;jSetPoint(i,gdrxet[i],gdretall[k][j][i]/deltaR); + graphlow->SetPoint(i,gdrxet[i],gdretlow[k][j][i]/deltaR); + graphlow1->SetPoint(i,gdrxet[i],gdretlow1[k][j][i]/deltaR); + graphlow2->SetPoint(i,gdrxet[i],gdretlow2[k][j][i]/deltaR); + graphlow3->SetPoint(i,gdrxet[i],gdretlow3[k][j][i]/deltaR); + graphlow4->SetPoint(i,gdrxet[i],gdretlow4[k][j][i]/deltaR); + } + sprintf(dummy,"%s-gretall%d",name,j); + graphall->Write(dummy); + sprintf(dummy,"%s-gretlow%d",name,j); + graphlow->Write(dummy); + sprintf(dummy,"%s-gret2low%d",name,j); + graphlow->Write(dummy); + sprintf(dummy,"%s-gret1low%d",name,j); + graphlow1->Write(dummy); + sprintf(dummy,"%s-gret3low%d",name,j); + graphlow2->Write(dummy); + sprintf(dummy,"%s-gret4low%d",name,j); + graphlow3->Write(dummy); + sprintf(dummy,"%s-gret5low%d",name,j); + graphlow4->Write(dummy); + delete graphall; + delete graphlow; + delete graphlow1; + delete graphlow2; + delete graphlow3; + } + } + + rootfile->cd(); + rootfile->mkdir("gDiConeFluc"); + rootfile->cd("gDiConeFluc"); + for(Int_t k=0;k<3;k++){ + if(k==0){ + sprintf(name,"toward"); + } else if (k==1) { + sprintf(name,"away"); + } else { + sprintf(name,"transverse"); + } + + for(Int_t j=0;jSetPoint(i,grxet[i],gdiretall[k][j][i]); + graphlow->SetPoint(i,grxet[i],gdiretlow[k][j][i]); + graphlow1->SetPoint(i,grxet[i],gdiretlow1[k][j][i]); + graphlow2->SetPoint(i,grxet[i],gdiretlow2[k][j][i]); + graphlow3->SetPoint(i,grxet[i],gdiretlow3[k][j][i]); + graphlow4->SetPoint(i,grxet[i],gdiretlow4[k][j][i]); + } + sprintf(dummy,"%s-gretall%d",name,j); + graphall->Write(dummy); + sprintf(dummy,"%s-gretlow%d",name,j); + graphlow->Write(dummy); + sprintf(dummy,"%s-gret2low%d",name,j); + graphlow->Write(dummy); + sprintf(dummy,"%s-gret1low%d",name,j); + graphlow1->Write(dummy); + sprintf(dummy,"%s-gret3low%d",name,j); + graphlow2->Write(dummy); + sprintf(dummy,"%s-gret4low%d",name,j); + graphlow3->Write(dummy); + sprintf(dummy,"%s-gret5low%d",name,j); + graphlow4->Write(dummy); + delete graphall; + delete graphlow; + delete graphlow1; + delete graphlow2; + delete graphlow3; + } + } + + rootfile->cd(); + rootfile->mkdir("gDiShape"); + rootfile->cd("gDiShape"); + for(Int_t k=0;k<3;k++){ + if(k==0){ + sprintf(name,"toward"); + } else if (k==1) { + sprintf(name,"away"); + } else { + sprintf(name,"transverse"); + } + + for(Int_t j=0;jSetPoint(i,gdrxet[i],gdidretall[k][j][i]/deltaR); + graphlow->SetPoint(i,gdrxet[i],gdidretlow[k][j][i]/deltaR); + graphlow1->SetPoint(i,gdrxet[i],gdidretlow1[k][j][i]/deltaR); + graphlow2->SetPoint(i,gdrxet[i],gdidretlow2[k][j][i]/deltaR); + graphlow3->SetPoint(i,gdrxet[i],gdidretlow3[k][j][i]/deltaR); + graphlow4->SetPoint(i,gdrxet[i],gdidretlow4[k][j][i]/deltaR); + } + sprintf(dummy,"%s-gretall%d",name,j); + graphall->Write(dummy); + sprintf(dummy,"%s-gretlow%d",name,j); + graphlow->Write(dummy); + sprintf(dummy,"%s-gret2low%d",name,j); + graphlow->Write(dummy); + sprintf(dummy,"%s-gret1low%d",name,j); + graphlow1->Write(dummy); + sprintf(dummy,"%s-gret3low%d",name,j); + graphlow2->Write(dummy); + sprintf(dummy,"%s-gret4low%d",name,j); + graphlow3->Write(dummy); + sprintf(dummy,"%s-gret5low%d",name,j); + graphlow4->Write(dummy); + delete graphall; + delete graphlow; + delete graphlow1; + delete graphlow2; + delete graphlow3; + } + } + + rootfile->cd(); + rootfile->mkdir("gFragLeadingPt"); + rootfile->cd("gFragLeadingPt"); + for(Int_t k=0;k<3;k++){ + for(Int_t i=0;iGetEntries(); + if(nents){ + //cout << "hJetFragLeadingPt " << i << ": " << nents << " entries in histogram" << endl; + hgJetFragLeadingPt[k][i]->SetLineWidth(3); + hgJetFragLeadingPt[k][i]->Write(); + } + } + } + + rootfile->cd(); + rootfile->mkdir("gFragLong"); + rootfile->cd("gFragLong"); + for(Int_t k=0;k<3;k++){ + for(Int_t i=0;iGetEntries(); + if(nents){ + //cout << "hgJetFragL " << i << ": " << nents << " entries in histogram " << endl; + hgJetFragL[k][i]->SetLineWidth(3); + hgJetFragL[k][i]->Write(); + } + } + } + + rootfile->cd(); + rootfile->mkdir("gFragPL"); + rootfile->cd("gFragPL"); + for(Int_t k=0;k<3;k++){ + for(Int_t i=0;iGetEntries(); + if(nents){ + //cout << "hJetFragPL " << i << ": " << nents << " entries in histogram " << endl; + hgJetFragPL[k][i]->SetLineWidth(3); + hgJetFragPL[k][i]->Write(); + } + } + } + + rootfile->cd(); + rootfile->mkdir("gFragTrans"); + rootfile->cd("gFragTrans"); + for(Int_t k=0;k<3;k++){ + for(Int_t i=0;iGetEntries(); + if(nents){ + //cout << "hJetFragT " << i << ": " << nents << " entries in histogram" << endl; + hgJetFragT[k][i]->SetLineWidth(3); + hgJetFragT[k][i]->Write(); + } + } + } + + rootfile->cd(); + rootfile->mkdir("gDiFragLeadingPt"); + rootfile->cd("gDiFragLeadingPt"); + for(Int_t k=0;k<3;k++){ + for(Int_t i=0;iGetEntries(); + if(nents){ + //cout << "hJetFragLeadingPt " << i << ": " << nents << " entries in histogram" << endl; + hgDiJetFragLeadingPt[k][i]->SetLineWidth(3); + hgDiJetFragLeadingPt[k][i]->Write(); + } + } + } + + rootfile->cd(); + rootfile->mkdir("gDiFragLong"); + rootfile->cd("gDiFragLong"); + for(Int_t k=0;k<3;k++){ + for(Int_t i=0;iGetEntries(); + if(nents){ + //cout << "hgDiJetFragL " << i << ": " << nents << " entries in histogram " << endl; + hgDiJetFragL[k][i]->SetLineWidth(3); + hgDiJetFragL[k][i]->Write(); + } + } + } + + rootfile->cd(); + rootfile->mkdir("gDiFragPL"); + rootfile->cd("gDiFragPL"); + for(Int_t k=0;k<3;k++){ + for(Int_t i=0;iGetEntries(); + if(nents){ + //cout << "hgDJetFragPL " << i << ": " << nents << " entries in histogram " << endl; + hgDiJetFragPL[k][i]->SetLineWidth(3); + hgDiJetFragPL[k][i]->Write(); + } + } + } + + rootfile->cd(); + rootfile->mkdir("gDiFragTrans"); + rootfile->cd("gDiFragTrans"); + for(Int_t k=0;k<3;k++){ + for(Int_t i=0;iGetEntries(); + if(nents){ + //cout << "hJetFragT " << i << ": " << nents << " entries in histogram" << endl; + hgDiJetFragT[k][i]->SetLineWidth(3); + hgDiJetFragT[k][i]->Write(); + } + } + } + + //reconstruction + rootfile->cd(); + rootfile->mkdir("reconstruction"); + rootfile->cd("reconstruction"); + + nents=(Int_t)hJetEtres->GetEntries(); + if(nents){ + cout << "hJetEtres " << nents << " entries in histogram" << endl; + hJetEtres->SetLineWidth(3); + hJetEtres->Write(); + } + + nents=(Int_t)hJetEtratio->GetEntries(); + if(nents){ + cout << "hJetEtratio " << nents << " entries in histogram" << endl; + hJetEtratio->SetLineWidth(3); + hJetEtratio->Write(); + } + + nents=(Int_t)hJetEtrestrue->GetEntries(); + if(nents){ + cout << "hJetEtrestrue " << nents << " entries in histogram" << endl; + hJetEtrestrue->SetLineWidth(3); + hJetEtrestrue->Write(); + } + + nents=(Int_t)hJetEtresTrigger->GetEntries(); + if(nents){ + cout << "hJetEtresTrigger " << nents << " entries in histogram" << endl; + hJetEtresTrigger->SetLineWidth(3); + hJetEtresTrigger->Write(); + } + + nents=(Int_t)hAxesDiffres->GetEntries(); + if(nents){ + cout << "hAxesDiffres " << nents << " entries in histogram" << endl; + hAxesDiffres->SetLineWidth(3); + hAxesDiffres->Write(); + } + + nents=(Int_t)hPhires->GetEntries(); + if(nents){ + cout << "hPhires " << nents << " entries in histogram" << endl; + hPhires->SetLineWidth(3); + hPhires->Write(); + } + + nents=(Int_t)hEtares->GetEntries(); + if(nents){ + cout << "hEtares " << nents << " entries in histogram" << endl; + hEtares->SetLineWidth(3); + hEtares->Write(); + } + + nents=(Int_t)hEtMonteres->GetEntries(); + if(nents){ + cout << "hEtMonteres " << nents << " entries in histogram" << endl; + hEtMonteres->SetLineWidth(3); + hEtMonteres->Write(); + } + + nents=(Int_t)hEtaMonteres->GetEntries(); + if(nents){ + cout << "hEtaMonteres " << nents << " entries in histogram" << endl; + hEtaMonteres->SetLineWidth(3); + hEtaMonteres->Write(); + } + + nents=(Int_t)hPhiMonteres->GetEntries(); + if(nents){ + cout << "hPhiMonteres " << nents << " entries in histogram" << endl; + hPhiMonteres->SetLineWidth(3); + hPhiMonteres->Write(); + } + + nents=(Int_t)hEtMonteratio->GetEntries(); + if(nents){ + cout << "hEtMonteratio " << nents << " entries in histogram" << endl; + hEtMonteratio->SetLineWidth(3); + hEtMonteratio->Write(); + } + + nents=(Int_t)hmJetEtres->GetEntries(); + if(nents){ + cout << "hmJetEtres " << nents << " entries in histogram" << endl; + hmJetEtres->SetLineWidth(3); + hmJetEtres->Write(); + } + + nents=(Int_t)hmJetEtratio->GetEntries(); + if(nents){ + cout << "hmJetEtratio " << nents << " entries in histogram" << endl; + hmJetEtratio->SetLineWidth(3); + hmJetEtratio->Write(); + } + + nents=(Int_t)hmJetEtrestrue->GetEntries(); + if(nents){ + cout << "hmJetEtrestrue " << nents << " entries in histogram" << endl; + hmJetEtrestrue->SetLineWidth(3); + hmJetEtrestrue->Write(); + } + + nents=(Int_t)hmAxesDiffres->GetEntries(); + if(nents){ + cout << "hmAxesDiffres " << nents << " entries in histogram" << endl; + hmAxesDiffres->SetLineWidth(3); + hmAxesDiffres->Write(); + } + + nents=(Int_t)hmPhires->GetEntries(); + if(nents){ + cout << "hmPhires " << nents << " entries in histogram" << endl; + hmPhires->SetLineWidth(3); + hmPhires->Write(); + } + + nents=(Int_t)hmEtares->GetEntries(); + if(nents){ + cout << "hmEtares " << nents << " entries in histogram" << endl; + hmEtares->SetLineWidth(3); + hmEtares->Write(); + } + + rootfile->cd(); + rootfile->mkdir("trigger"); + rootfile->cd("trigger"); + for(Int_t i=0;i<9;i++){ + hJetEttrigger[i]->Write(); + hJetEttrigger2[i]->Write(); + } + hJetEttriggernorm->Write(); + + //store event info + rootfile->cd(); + TGraph *graph=new TGraph(nclasses+1); + cout << "Good jets counters" << endl; + for(Int_t i=0;iSetPoint(i,i,nclGoodEvents[i]); + } + graph->SetPoint(nclasses,nclasses,nTotalEvents); + cout << nclasses << " " << nTotalEvents << endl; + graph->Write("ggoodevents"); + delete graph; + graph=new TGraph(nclasses+1); + for(Int_t i=0;iSetPoint(i,i,nclLeadEvents[i]); + } + graph->SetPoint(nclasses,nclasses,nTotalEvents); + graph->Write("ggoodlead"); + delete graph; + graph=new TGraph(nclasses+1); + for(Int_t i=0;iSetPoint(i,i,nclDiEvents[i]); + } + graph->SetPoint(nclasses,nclasses,nTotalEvents); + graph->Write("ggooddilead"); + delete graph; + + //close the result file + rootfile->Close(); + // + + delete hJetEt; + delete hBackJetEt; + delete hJetEtall; + delete hJetEttrue; + delete hBackJetEttrue; + delete hJetEtalltrue; + delete hJetEtTrigger; + delete hJetEtUQTrigger; + delete hJetEtvsTrigger; + delete hJetEtvsUQTrigger; + delete hJetEtvsEt; + delete hAxesDiff; + delete hPartPtDist; + delete hPartEtaDist; + delete hPartPhiDist; + delete hPartPhiCorr; + delete hPartACorr; + delete hPartDiACorr; + delete hPartDiPhiCorr; + delete hJet1; + delete hJet2; + for(Int_t i=0;i<3;i++) delete hJettype[i]; + delete[] hJettype; + delete hJetEtvsEll; + delete hJetEtallvsEll; + delete hJetZ; + + delete hJetEtres; + delete hJetEtratio; + delete hJetEtrestrue; + delete hJetEtresTrigger; + delete hAxesDiffres; + delete hPhires; + delete hEtares; + delete hmJetEtres; + delete hmJetEtratio; + delete hmJetEtrestrue; + delete hmAxesDiffres; + delete hmPhires; + delete hmEtares; + delete hPhiMonteres; + delete hEtaMonteres; + delete hEtMonteres; + delete hEtMonteratio; + + for(Int_t i=0;iTMath::Pi()) ret=TMath::TwoPi()-ret; + return ret; +} + +Float_t addphi(Float_t phi1, Float_t phi2) +{ + Float_t addphi=phi1+phi2; + if(addphi>TMath::TwoPi()) addphi-=TMath::TwoPi(); + else if(addphi<0) addphi+=TMath::TwoPi(); + return addphi; +} + +Float_t diffphi(Float_t phi1, Float_t phi2) +{ //and move correlation to pi/2 + Float_t diffphi=TMath::Pi()/2+phi1-phi2; + if(diffphi>TMath::TwoPi()) diffphi-=TMath::TwoPi(); + else if(diffphi<0) diffphi+=TMath::TwoPi(); + return diffphi; +} + +Int_t eventindex(Float_t phi1, Float_t phi2) +{ //rel to phi1 + Int_t ret=0; //toward (300 - 60) + Float_t dphi=addphi(phi1,-phi2); + const Float_t slice=TMath::Pi()/3.; + if (dphi>1*slice && dphi < 2*slice) + ret=2; //transverse (60-120) + else if (dphi>4*slice && dphi < 5*slice) + ret=3; //transverse (240-300) + else if(dphi>=2*slice && dphi<=4*slice) + ret=1; //away side (120-200) + + return ret; +} + +void convert(Float_t pjet[4], Float_t &pt, Float_t &theta, Float_t &eta, Float_t &phi) +{ + pt=TMath::Sqrt(pjet[0]*pjet[0]+pjet[1]*pjet[1]); + theta=TMath::ATan2(pt,pjet[2]); + eta=-TMath::Log(TMath::Tan(theta/2)); + phi=TMath::Pi()+TMath::ATan2(-pjet[1],-pjet[0]); +} + diff --git a/JETAN/anaTracks.C b/JETAN/anaTracks.C new file mode 100644 index 00000000000..1c2308d3b17 --- /dev/null +++ b/JETAN/anaTracks.C @@ -0,0 +1,563 @@ +// $Id$ + +#ifndef __CINT__ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#endif + +#define LABEFF +#define MINHITS 0 + +void Sort(Int_t na,const Int_t *a,Int_t *index); +void anaTracks(Int_t esd1,Int_t esd2,Float_t qcut,Int_t nMaxEvents=-1); +void anaTracks(Char_t *filename1,Char_t *filename2,Float_t qcut,Int_t nMaxEvents=-1); +void anaTracks(TObjArray *fnames1,TObjArray *fnames2,Float_t qcut,Int_t nMaxEvents=-1); +void anaEtTracks(Int_t esd1,Int_t esd2,Float_t qcut, + Int_t etfrom=1, Int_t etto=16, Int_t nMaxEvents=-1); + +void anaTracks(Int_t esd1,Int_t esd2,Float_t qcut,Int_t nMaxEvents) +{ + const Int_t nes[5]={50,100,150,200,250}; + const Char_t *dir="/data/aliroot/jets"; + TObjArray *f1=new TObjArray(1); + TObjArray *f2=new TObjArray(1); + Char_t filename1[1024]; + Char_t filename2[1024]; + + for(Int_t i=0;i<5;i++){ + sprintf(filename1,"%s/%d/aliev-type%d.root",dir,nes[i],esd1); + f1->Add(new TObjString(filename1)); + sprintf(filename2,"%s/%d/aliev-type%d.root",dir,nes[i],esd2); + f2->Add(new TObjString(filename2)); + } + anaTracks(f1,f2,qcut,nMaxEvents); +} + +void anaEtTracks(Int_t esd1,Int_t esd2,Float_t qcut,Int_t etfrom, Int_t etto, Int_t nMaxEvents) +{ + const Char_t *dir="/data/aliroot/scan"; + TObjArray *f1=new TObjArray(1); + TObjArray *f2=new TObjArray(1); + Char_t filename1[1024]; + Char_t filename2[1024]; + for(Int_t i=etfrom;i<=etto;i++){ + sprintf(filename1,"%s/et%d/aliev-type%d.root",dir,i,esd1); + f1->Add(new TObjString(filename1)); + sprintf(filename2,"%s/et%d/aliev-type%d.root",dir,i,esd2); + f2->Add(new TObjString(filename2)); + } + anaTracks(f1,f2,qcut,nMaxEvents); +} + +void anaTracks(Char_t *filename1,Char_t *filename2,Float_t qcut,Int_t nMaxEvents) +/* + filename1 = monte events + filename2 = tracked events +*/ +{ + TObjArray *f1=new TObjArray(1); + f1->Add(new TObjString(filename1)); + TObjArray *f2=new TObjArray(1); + f2->Add(new TObjString(filename2)); + + anaTracks(f1,f2,qcut,nMaxEvents); +} + +void anaTracks(TObjArray *fnames1,TObjArray *fnames2,Float_t qcut,Int_t nMaxEvents) +/* + filename1 = monte events + filename2 = tracked events +*/ +{ + gRandom->SetSeed(0); + + //connect to events + TChain *theTree1 = new TChain("AJEPtree"); + for(Int_t i=0;iGetEntries();i++){ + theTree1->Add(((TObjString*)fnames1->At(i))->String()); + } + AliJetEventParticles *ev1=new AliJetEventParticles(); + theTree1->SetBranchAddress("particles",&ev1); + + //connect to events + TChain *theTree2 = new TChain("AJEPtree"); + for(Int_t i=0;iGetEntries();i++){ + theTree2->Add(((TObjString*)fnames2->At(i))->String()); + } + AliJetEventParticles *ev2=new AliJetEventParticles(); + theTree2->SetBranchAddress("particles",&ev2); + + Int_t treeentries1=(Int_t)theTree1->GetEntries(); + Int_t treeentries2=(Int_t)theTree2->GetEntries(); + + if((nMaxEvents<0) || (nMaxEvents>treeentries1)) + nMaxEvents=treeentries1; + + cout << "Found " << treeentries1 << ", but use " << nMaxEvents << " in chain1" << endl; + cout << "Found " << treeentries2 << ", but use " << nMaxEvents << " in chain2" << endl; + + const Int_t nmax=25000; + Int_t *ind2=new Int_t[nmax]; + const Float_t ptcut=0.5; + const Int_t nbinsx=20; + const Float_t binsx[nbinsx]={1,2,4,6,8,10,12.5,15,17.5,20,25,30,40,45,50,60,70,80,90,100}; + + //hinvp + TH1F *hInvQ2=new TH1F("hInvQ2","",1000,0,1.5); + TH1F *hInvQ2lab=new TH1F("hInvQ2lab","",1000,0,1.5); + TH1F *hEffPt1=new TH1F("hEffPt1","",nbinsx-1,binsx); + TH1F *hEffPt2=new TH1F("hEffPt2","",nbinsx-1,binsx); + TH1F *hEffEta1=new TH1F("hEffEta1","",40,-1,1); + TH1F *hEffEta2=new TH1F("hEffEta2","",40,-1,1); + TH1F *hEffPhi1=new TH1F("hEffPhi1","",62,0,6.2); + TH1F *hEffPhi2=new TH1F("hEffPhi2","",62,0,6.2); + TH1F *hFakePt=new TH1F("hFakePt","",nbinsx-1,binsx); + TH1F *hFakeEta=new TH1F("hFakeEta","",40,-1,1); + TH1F *hFakePhi=new TH1F("hFakePhi","",62,0,6.2); + TH1F *hResPt=new TH1F("hResPt","",60,-15,15); + TH1F *hResEta=new TH1F("hResEta","",200,-0.05,0.05); + TH1F *hResPhi=new TH1F("hResPhi","",200,-0.05,0.05); + TProfile *hpResPt=new TProfile("hpResPt","",nbinsx-1,binsx); + TProfile *hpResEta=new TProfile("hpResEta","",nbinsx-1,binsx); + TProfile *hpResPhi=new TProfile("hpResPhi","",nbinsx-1,binsx); + TH1F **hResPtAll=new TH1F*[nbinsx]; + TH1F **hResEtaAll=new TH1F*[nbinsx]; + TH1F **hResPhiAll=new TH1F*[nbinsx]; + for(Int_t i=0;iClear(); + ev2->Clear(); + theTree1->GetEvent(nEvent1); + theTree2->GetEvent(nEvent2); + + if(ev1->GetEventNr()!=ev2->GetEventNr()){ + cerr << "Need to skip event: " << nEvent1 << " != " << nEvent2 + << " (" << ev1->GetEventNr() << " " << ev2->GetEventNr() <<") " << endl; + if(ev1->GetEventNr()>ev2->GetEventNr()) nEvent2++; + else nEvent1++; + continue; + } + + //ev1->Print(); + //ev2->Print(); + const TClonesArray *p1=ev1->GetParticles(); + if(!p1){ + continue; + } + const TClonesArray *p2=ev2->GetParticles(); + if(!p2){ + continue; + } + const Int_t n1=p1->GetEntriesFast(); + const Int_t n2=p2->GetEntriesFast(); + if(n1==0 || n2==0){ + continue; + } + //clean found particle table + for(Int_t j=0;jAt(i); + if(p->Pt()Px(); + Float_t py=p->Py(); + Float_t pz=p->Pz(); + Int_t lab=p->GetLabel(); + if(lab==0) lab=p->GetUID(); //workaround for bug + for(Int_t j=0;jAt(j); + if(q->Pt()GetNhts()Px(); + Float_t qy=q->Py(); + Float_t qz=q->Pz(); + Float_t Q2=(px-qx)*(px-qx)+(py-qy)*(py-qy)+(pz-qz)*(pz-qz); + Q2=TMath::Sqrt(Q2)/p->P(); + hInvQ2->Fill(Q2); + if(q->GetLabel()!=lab) continue; + hInvQ2lab->Fill(Q2); + } + } + + for(Int_t i=0;iAt(i); + if(p->Pt()Px(); + Float_t py=p->Py(); + Float_t pz=p->Pz(); + Int_t lab=p->GetLabel(); + if(lab==0) lab=p->GetUID(); //workaround for bug + + Float_t minQ2=1e5; + Int_t j2=-1,lab2=-1; + for(Int_t j=0;jAt(j); + if(q->Pt()GetNhts()Px(); + Float_t qy=q->Py(); + Float_t qz=q->Pz(); + Float_t Q2=(px-qx)*(px-qx)+(py-qy)*(py-qy)+(pz-qz)*(pz-qz); + Q2=TMath::Sqrt(Q2)/p->P(); +#ifdef LABEFF + if(TMath::Abs(q->GetLabel())==lab){ + if(j2<0){ + lab2=q->GetLabel(); + j2=j; + minQ2=Q2; + } else { //take particle with smaller Q2 + if(Q2GetLabel(); + j2=j; + minQ2=Q2; + } else ind2[j]=2;//mark new found as fake + } + } +#else + if(Q2GetLabel(); + } +#endif + } + + hEffPt1->Fill(p->Pt()); + hEffEta1->Fill(p->Eta()); + hEffPhi1->Fill(p->Phi()); + + if(j2>=0){ //take found particle +#ifdef LABEFF + if(lab!=lab2){ + nlabs++; + continue; + } +#else + if(minQ2>qcut) continue; +#endif + ntracks2++; + ind2[j2]=0; //mark as found + AliJetParticle *q=(AliJetParticle*)p2->At(j2); + hEffPt2->Fill(q->Pt()); + hEffEta2->Fill(q->Eta()); + hEffPhi2->Fill(q->Phi()); + Float_t ptdiff=p->Pt()-q->Pt(); + Float_t phidiff=p->Phi()-q->Phi(); + Float_t etadiff=p->Eta()-q->Eta(); + hResPt->Fill(ptdiff); + hResEta->Fill(etadiff); + hResPhi->Fill(phidiff); + //cout << ptdiff << etadiff << phidiff << endl; + hpResPt->Fill(p->Pt(),TMath::Abs(ptdiff)/p->Pt()); + hpResEta->Fill(p->Pt(),TMath::Abs(etadiff)); + hpResPhi->Fill(p->Pt(),TMath::Abs(phidiff)); + Int_t index=hEffPt1->FindBin(p->Pt()); + hResPtAll[index]->Fill(ptdiff); + hResEtaAll[index]->Fill(etadiff); + hResPhiAll[index]->Fill(phidiff); + } + + } //event loop + nlokfakes2=0; + for(Int_t j=0;jAt(j); + if (q->Pt()GetLabel() << endl; + if(q->GetNhts()Fill(q->Pt()); + hFakeEta->Fill(q->Eta()); + hFakePhi->Fill(q->Phi()); + nlokfakes2++; + } + nfakes2+=nlokfakes2; + if(nlokfakes2/n2>0.1) cout << nEvent1 << " has more than 10% fakes: " << nlokfakes2 << endl; + } //end of nev loop + + Float_t ffakes=nfakes2*100./ntracks1; + cout << "Good tracks: " << ntracks1 << endl; + cout << "Found tracks: " << ntracks2 << endl; + cout << "Fake tracks: " << nfakes2 << endl; + cout << "Eff: " << ntracks2*100/ntracks1 << endl; + cout << "Fake: " << nfakes2*100/ntracks1 << endl; + TF1 *f1 = new TF1("f1","gaus"); + hResPt->Sumw2(); + Float_t m = hResPt->GetMean(); + Float_t s = hResPt->GetRMS(); + f1->SetParameter(1,m); + f1->SetParameter(2,s); + cout << "Res: " << m << " " << s << endl; + + hResPt->Fit(f1,"IN"); + m = f1->GetParameter(1); + s = f1->GetParameter(2); + cout << "Res: " << m << " " << s << endl; + + TCanvas *c1=new TCanvas("cInvQ2","",600,400); + hInvQ2->Sumw2(); + hInvQ2->Draw(); + c1->Update(); + Float_t qq=0,ival; + while(1){ + ival=hInvQ2->Integral(hInvQ2->FindBin(0),hInvQ2->FindBin(qq)); + if(ival>ntracks1) break; + qq+=0.001; + } + cout << "Qcut: " << qq << " " << ival << " " << ntracks1 << endl; + TCanvas *c1b=new TCanvas("cInvQ2lab","",600,400); + hInvQ2lab->Sumw2(); + hInvQ2lab->Draw(); + c1b->Update(); + + hEffPt2->Sumw2(); + hEffPt1->Sumw2(); + hEffPt2->Divide(hEffPt1); + + hEffEta2->Sumw2(); + hEffEta1->Sumw2(); + hEffEta2->Divide(hEffEta1); + + hEffPhi2->Sumw2(); + hEffPhi1->Sumw2(); + hEffPhi2->Divide(hEffPhi1); + + hFakePt->Sumw2(); + hFakePt->Divide(hEffPt1); + hFakeEta->Sumw2(); + hFakeEta->Divide(hEffEta1); + hFakePhi->Sumw2(); + hFakePhi->Divide(hEffPhi1); + + TGraphErrors *gpts=new TGraphErrors(); + TGraphErrors *getas=new TGraphErrors(); + TGraphErrors *gphis=new TGraphErrors(); + +//#define fit + for(Int_t i=0;iSumw2(); + m = hResPtAll[i]->GetMean(); + s = hResPtAll[i]->GetRMS(); +#ifdef fit + f1->SetParameter(1,m); + f1->SetParameter(2,s); + hResPtAll[i]->Fit(f1,"IN"); + m = f1->GetParameter(1); + s = f1->GetParameter(2); + //gpts->SetPointError(i,0,f1->GetParError(2)); +#endif + gpts->SetPoint(i,binsx[i],s/binsx[i]*100); + + hResEtaAll[i]->Sumw2(); + m = hResEtaAll[i]->GetMean(); + s = hResEtaAll[i]->GetRMS(); +#ifdef fit + f1->SetParameter(1,m); + f1->SetParameter(2,s); + hResEtaAll[i]->Fit(f1,"QIN"); + m = f1->GetParameter(1); + s = f1->GetParameter(2); +#endif + getas->SetPoint(i,binsx[i],s); + + hResPhiAll[i]->Sumw2(); +#ifdef fit + m = hResPhiAll[i]->GetMean(); + s = hResPhiAll[i]->GetRMS(); + f1->SetParameter(1,m); + f1->SetParameter(2,s); + hResPhiAll[i]->Fit(f1,"QIN"); + m = f1->GetParameter(1); + s = f1->GetParameter(2); +#endif + gphis->SetPoint(i,binsx[i],s); + } + +#if 0 + TCanvas *c2=new TCanvas("cEffPt","",600,400); + hEffPt2->Draw(); + c2->Update(); + TCanvas *c3=new TCanvas("cEffEta","",600,400); + hEffEta2->Draw(); + c3->Update(); + TCanvas *c4=new TCanvas("cEffPhi","",600,400); + hEffPhi2->Draw(); + c4->Update(); + + TCanvas *c5=new TCanvas("cResPt","",600,400); + hpResPt->Draw(); + gpts->SetMarkerSize(1); + gpts->SetMarkerStyle(20); + //gpts->Draw("p axis"); + c5->Update(); + TCanvas *c6=new TCanvas("cResPhi","",600,400); + hpResPhi->Draw(); + gphis->SetMarkerSize(1); + gphis->SetMarkerStyle(20); + //gphis->Draw("p axis"); + c6->Update(); + TCanvas *c7=new TCanvas("cResEta","",600,400); + hpResEta->Draw(); + getas->SetMarkerSize(1); + getas->SetMarkerStyle(20); + //getas->Draw("p axis"); + c7->Update(); +#else + TCanvas *c8=new TCanvas("call","",1200,800); + c8->Divide(3,2); + c8->cd(1); + hEffPt2->Draw(); + hFakePt->Draw("same"); + c8->cd(2); + hEffEta2->Draw(); + hFakeEta->Draw("same"); + c8->cd(3); + hEffPhi2->Draw(); + hFakePhi->Draw("same"); + c8->cd(4); + hpResPt->Draw(); + c8->cd(5); + hpResEta->Draw(); + c8->cd(6); + hpResPhi->Draw(); +#endif + + TFile *f=new TFile("tracks.root","recreate"); + hInvQ2->Write(); + hInvQ2lab->Write(); + hEffPt1->Write(); + hEffPt2->Write(); + hEffEta1->Write(); + hEffEta2->Write(); + hEffPhi1->Write(); + hEffPhi2->Write(); + hResPt->Write(); + hResEta->Write(); + hResPhi->Write(); + hFakePt->Write(); + hFakePhi->Write(); + hFakeEta->Write(); + gpts->Write("gtps"); + getas->Write("gtps"); + gphis->Write("gtps"); + f->mkdir("all"); + f->cd("all"); + for(Int_t i=0;iWrite(); + hResEtaAll[i]->Write(); + hResPhiAll[i]->Write(); + } + f->Close(); + delete f; + delete[] ind2; + delete ev1; + delete ev2; + delete theTree1; + delete theTree2; +} + +//_____________________________________________________________________________ + + +void Sort(Int_t na, const Int_t *a, Int_t *index) +{ + if (na <= 0) return; + Int_t *localArr1 = new Int_t[na]; + Int_t *localArr2 = new Int_t[na]; + Int_t iEl; + Int_t iEl2; + + for(iEl = 0; iEl < na; iEl++) { + localArr1[iEl] = a[iEl]; + localArr2[iEl] = iEl; + //cout << localArr1[iEl] << " " << localArr2[iEl] << endl; + } + + for (iEl = 0; iEl < na; iEl++) { + for (iEl2 = na-1; iEl2 > iEl; iEl2--) { + //cout << iEl << " " << iEl2 << " " << localArr1[iEl2-1] << " " << localArr1[iEl2] << endl; + + if (localArr1[iEl2-1] < localArr1[iEl2]) { + Int_t tmp = localArr1[iEl2-1]; + localArr1[iEl2-1] = localArr1[iEl2]; + localArr1[iEl2] = tmp; + + Int_t tmp2 = localArr2[iEl2-1]; + localArr2[iEl2-1] = localArr2[iEl2]; + localArr2[iEl2] = tmp2; + //cout << "Swapped: " << localArr1[iEl2-1] << " " << localArr2[iEl2-1] << endl; + //cout << "Swapped: " << localArr1[iEl2] << " " << localArr2[iEl2] << endl; + } + //cout << iEl << " " << iEl2 << " " << localArr1[iEl2-1] << " " << localArr1[iEl2] << endl; + } + } + + for (iEl = 0; iEl < na; iEl++) { + index[iEl] = localArr2[iEl]; + //cout << a[iEl] << " " << index[iEl] << endl; + } + delete [] localArr2; + delete [] localArr1; +} diff --git a/JETAN/createEvents.C b/JETAN/createEvents.C new file mode 100644 index 00000000000..6d1021f7f34 --- /dev/null +++ b/JETAN/createEvents.C @@ -0,0 +1,545 @@ +// $Id$ + +#ifndef __CINT__ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#endif + +#if 0 + kITSin=0x0001,kITSout=0x0002,kITSrefit=0x0004,kITSpid=0x0008, + kTPCin=0x0010,kTPCout=0x0020,kTPCrefit=0x0040,kTPCpid=0x0080, + kTRDin=0x0100,kTRDout=0x0200,kTRDrefit=0x0400,kTRDpid=0x0800, + kTOFin=0x1000,kTOFout=0x2000,kTOFrefit=0x4000,kTOFpid=0x8000, + kPHOSpid=0x10000, kRICHpid=0x20000, kEMCALpid=0x40000, + kTRDbackup=0x80000, + kTRDStop=0x20000000, + kESDpid=0x40000000, + kTIME=0x80000000 +#endif + +//#define constrained +#define useHoughITS + +void createEvents(Char_t *dir, Int_t files,Char_t *sdir="."); +void createEvents(Int_t esd, TObjArray *dirs, Float_t ptcut, Char_t *savefile); +void createEvents(Int_t esd,Char_t *dir="./input",Float_t ptcut=0.05,Char_t *savefile=0); +void createEvents(Int_t esd,Char_t *dirfile,Char_t *dir,Float_t ptcut=0.05,Char_t *savefile=0); +void createMixedEvents(Char_t *fname,Char_t *hname,Char_t *savefile=0,Int_t nMaxEvents=-1); +void createDirs(Char_t *dir,Int_t files,Char_t *savefile); +void testEvents(Char_t *sdir); +void readEvents(Char_t *filename,Int_t nMaxEvents=-1); +void displayMixedEvents(Char_t *fname,Char_t *hname,Float_t ptcut=2.0,Int_t nMaxEvents=-1); + +//----------------------- + +void createEvents(Char_t *dir, Int_t files, Char_t *sdir) +{ + createDirs(dir,files,"./dirlist.txt"); + Char_t filename[1000]; + sprintf(filename,"%s/aliev-type0.root",sdir); + createEvents(0,"./dirlist.txt",dir,0.4,filename); + sprintf(filename,"%s/aliev-type1.root",sdir); + createEvents(1,"./dirlist.txt",dir,0.4,filename); + sprintf(filename,"%s/aliev-type2.root",sdir); + createEvents(2,"./dirlist.txt",dir,0.4,filename); + sprintf(filename,"%s/aliev-type3.root",sdir); + createEvents(3,"./dirlist.txt",dir,0.4,filename); +#ifdef useHoughITS + sprintf(filename,"%s/aliev-type4.root",sdir); + createEvents(4,"./dirlist.txt",dir,0.4,filename); +#endif + sprintf(filename,"%s/aliev-type10.root",sdir); + createEvents(10,"./dirlist.txt",dir,0.4,filename); + sprintf(filename,"%s/aliev-type11.root",sdir); + createEvents(11,"./dirlist.txt",dir,0.4,filename); + sprintf(filename,"%s/aliev-type12.root",sdir); + createEvents(12,"./dirlist.txt",dir,0.4,filename); +} + +void createEvents(Int_t esd,Char_t *dirfile,Char_t *dir, + Float_t ptcut,Char_t *savefile) +{ + TObjArray *dirs=new TObjArray(10000); + + FILE *c=fopen(dirfile,"r"); + if(!c) return; + + Int_t saveErrIgLevel=gErrorIgnoreLevel; + gErrorIgnoreLevel=kFatal; + while(!feof(c)){ + Char_t adddir[1024]; + fscanf(c,"%s\n",adddir); + dirs->Add(new TObjString(adddir)); + //cout << adddir << endl; + } + gErrorIgnoreLevel=saveErrIgLevel; + + Char_t buffer[8096]; + if(savefile) + sprintf(buffer,"%s",savefile); + else + sprintf(buffer,"%s/aliev-type%d.root",dir,esd); + + createEvents(esd,dirs,ptcut,buffer); +} + +void createEvents(Int_t esd,Char_t *dir, + Float_t ptcut,Char_t *savefile) +{ + TObjArray *dirs=new TObjArray(1); + dirs->Add(new TObjString(dir)); + + Char_t buffer[8096]; + if(savefile) + sprintf(buffer,"%s",savefile); + else + sprintf(buffer,"%s/aliev-type%d.root",dir,esd); + + createEvents(esd,dirs,ptcut,buffer); +} + +void createEvents(Int_t esd, TObjArray *dirs, Float_t ptcut, Char_t *savefile) +{ + AliJetParticlesReader *reader=0; + TString desc=""; + if (esd==0) { + reader=new AliJetParticlesReaderKine(dirs); + //((AliJetParticlesReaderKine*)reader)->SetUseTracks(kTRUE); + ((AliJetParticlesReaderKine*)reader)->SetCharged(kTRUE); + ((AliJetParticlesReaderKine*)reader)->SetEM(kFALSE); + ((AliJetParticlesReaderKine*)reader)->SetNeutral(kFALSE); + desc+="Kine"; + } else if(esd==1){ +#ifdef constrained + reader=new AliJetParticlesReaderESD(1,dirs); + ((AliJetParticlesReaderESD*)reader)->SetCompareFlag( + AliESDtrack::kITSrefit+AliESDtrack::kTPCrefit+AliESDtrack::kTRDrefit); +#else + reader=new AliJetParticlesReaderESD(0,dirs); + ((AliJetParticlesReaderESD*)reader)->SetCompareFlag(AliESDtrack::kTPCin); +#endif + desc+="ESD"; + } else if (esd==2) { + reader=new AliJetParticlesReaderHLT(kTRUE,dirs); + //((AliJetParticlesReaderHLT*)reader)->SetMinHits(30); + desc+="HLTConf"; + } else if (esd==3) { + reader=new AliJetParticlesReaderHLT(kFALSE,dirs); + desc+="HLTHough"; + } else if (esd==4) { + reader=new AliJetParticlesReaderHLT(kFALSE,dirs,"AliESDits.root"); + //((AliJetParticlesReaderHLT*)reader)->SetMinHits(4); + desc+="HLTITSHough"; + } else if (esd==10) { + reader=new AliJetParticlesReaderKine(dirs); + //((AliJetParticlesReaderKine*)reader)->SetUseTracks(kTRUE); + ((AliJetParticlesReaderKine*)reader)->SetCharged(kTRUE); + ((AliJetParticlesReaderKine*)reader)->SetEM(kTRUE); + ((AliJetParticlesReaderKine*)reader)->SetNeutral(kTRUE); + desc+="Kine-All"; + } else if (esd==11) { + reader=new AliJetParticlesReaderKine(dirs); + //((AliJetParticlesReaderKine*)reader)->SetUseTracks(kTRUE); + ((AliJetParticlesReaderKine*)reader)->SetCharged(kTRUE); + ((AliJetParticlesReaderKine*)reader)->SetEM(kTRUE); + ((AliJetParticlesReaderKine*)reader)->SetNeutral(kFALSE); + desc+="Kine-EM"; + } else if (esd==12) { + reader=new AliJetParticlesReaderKineGoodTPC(dirs); + desc+="GoodTPC"; + } else { + cout << "Parameter settings: " << endl; + cout << "0 == Kine (ch)" << endl; + cout << "1 == TPC" << endl; + cout << "2 == Conformal" << endl; + cout << "3 == Hough" << endl; + cout << "4 == ITSHough" << endl; + cout << "10 == Kine (all)" << endl; + cout << "11 == Kine (ch+em)" << endl; + cout << "12 == Kine (good tpc)" << endl; + return; + } + //reader->ReadEventsFromTo(1,0); + reader->SetPtCut(ptcut,100); + reader->SetEtaCut(-0.9,0.9); + + desc+=" Ptcut: "; + desc+=ptcut; + + TFile* file = new TFile(savefile,"RECREATE"); + TTree* tree = new TTree("AJEPtree","AliJetEventParticles Tree"); + reader->SetTree(tree); + Int_t counter=0; + while(reader->Next()) + { + AliJetEventParticles *ev=new AliJetEventParticles(*reader->GetEventParticles()); + if(gErrorIgnoreLevel<=kWarning){ + cout << "Read event: " << ++counter << endl; + ev->Print(); + } + delete ev; + } + file->Write(); + file->Close(); + delete file; + delete reader; +} + +void createDirs(Char_t *dir,Int_t files,Char_t *savefile) +{ + Char_t buffer[8096]; + if(savefile) + sprintf(buffer,"%s",savefile); + else + sprintf(buffer,"%s/dirinput.txt",dir); + + FILE *c=fopen(buffer,"w"); + if(!c) return; + + Int_t saveErrIgLevel=gErrorIgnoreLevel; + gErrorIgnoreLevel=kFatal; + for(Int_t i=0;iGetNumberOfEvents() <= 0){ + delete r; + continue; + } + if(r->LoadKinematics()){ + delete r; + continue; + } + delete r; + sprintf(fname,"%s/AliESDs.root",adddir); + TFile g(fname); + if(!g.IsOpen()) continue; + + TTree *tree = dynamic_cast(g.Get("esdTree")); + if(!tree || tree->GetEntries()<=0){ + g.Close(); + continue; + } + g.Close(); +#ifdef useHoughITS + sprintf(fname,"%s/AliESDits.root",adddir); + TFile h(fname); + if(!h.IsOpen()) continue; + + tree = dynamic_cast(h.Get("esdTree")); + if(!tree || tree->GetEntries()<=0){ + h.Close(); + continue; + } + h.Close(); +#endif + + cout << "Added " << adddir << endl; + fprintf(c,"%s\n",adddir); + } + gErrorIgnoreLevel=saveErrIgLevel; + fclose(c); +} + +void createMixedEvents(Char_t *fname,Char_t *hname,Char_t *savefile,Int_t nMaxEvents) +{ + //connect to events + TChain *theTree = new TChain("AJEPtree"); + theTree->Add(fname); + AliJetEventParticles *ev=new AliJetEventParticles(); + theTree->SetBranchAddress("particles",&ev); + + Int_t treeentries=(Int_t)theTree->GetEntries(); + if((nMaxEvents<0) || (nMaxEvents>treeentries)) + nMaxEvents=treeentries; + //cout << "Found " << nMaxEvents << " in " << fname << endl; + + TChain *backtheTree = new TChain("AJEPtree"); + backtheTree->Add(hname); + AliJetEventParticles *backev=new AliJetEventParticles(); + backtheTree->SetBranchAddress("particles",&backev); + + Int_t backtreeentries=(Int_t)backtheTree->GetEntries(); + Int_t nPerBackground=nMaxEvents/backtreeentries; + if(nPerBackground==0) nPerBackground=1; + + Char_t buffer[8096]; + if(savefile) + sprintf(buffer,"%s",savefile); + else + sprintf(buffer,"./aliev-mixed.root"); + TFile* file = new TFile(buffer,"RECREATE"); + TTree* tree = new TTree("AJEPtree","AliJetEventParticles Tree"); + AliJetEventParticles *mixedev=new AliJetEventParticles(0); + tree->Branch("particles","AliJetEventParticles",&mixedev,32000,1); + + //========================================================================= + // start the event loop + //========================================================================= + Int_t nEvent = 0; + Int_t nEventHijing = -1; + Int_t nEventHijingCounter = nPerBackground; + while(nEventGetEvent(nEvent); + + //load background if needed + if(nEventHijingCounter==nPerBackground){ + backev->Reset(); + nEventHijing++; + backtheTree->GetEvent(nEventHijing); + if(nEventHijing==backtreeentries) nEventHijing=0; + nEventHijingCounter=0; + } + + backev->AddSignal(*ev); + TString dummy="Counter: "; + dummy+=nEvent; + dummy+=" "; + //dummy+=ev->GetHeader(); + dummy+="(Pythia ";dummy+=nEvent; + dummy+=" "; + //dummy+=backev->GetHeader(); + dummy+=", Hijing ";dummy+=nEventHijing; + dummy+=")"; + mixedev->Set(*backev); + mixedev->SetHeader(dummy); + if(gErrorIgnoreLevel<=kWarning){ + cout << "Read event: " << nEvent << " " << nEventHijing << endl; + mixedev->Print(); + } + + tree->Fill(); + + nEvent++; + nEventHijingCounter++; + ev->Reset(); + mixedev->Reset(); + } //end of nev loop + + file->Write(); + file->Close(); + delete file; + delete ev; + delete theTree; + delete backtheTree; + delete backev; +} + +void testEvents(Char_t *sdir) +{ + Char_t filename[1000]; + sprintf(filename,"%s/aliev-type0.root",sdir); + readEvents(filename,0); + sprintf(filename,"%s/aliev-type1.root",sdir); + readEvents(filename,0); + sprintf(filename,"%s/aliev-type2.root",sdir); + readEvents(filename,0); + sprintf(filename,"%s/aliev-type3.root",sdir); + readEvents(filename,0); + sprintf(filename,"%s/aliev-type10.root",sdir); + readEvents(filename,0); + sprintf(filename,"%s/aliev-type11.root",sdir); + readEvents(filename,0); + sprintf(filename,"%s/aliev-type12.root",sdir); +} + +void readEvents(Char_t *filename,Int_t nMaxEvents) +{ + //connect to events + TChain *theTree = new TChain("AJEPtree"); + theTree->Add(filename); + AliJetEventParticles *ev=new AliJetEventParticles(); + theTree->SetBranchAddress("particles",&ev); + + Int_t treeentries=(Int_t)theTree->GetEntries(); + if((nMaxEvents<0) || (nMaxEvents>treeentries)) + nMaxEvents=treeentries; + + cout << "Found " << treeentries << ", but use " << nMaxEvents << " in " << filename << endl; + + //========================================================================= + // start the event loop + //========================================================================= + Int_t nEvent = 0; + while(nEventGetEvent(nEvent); + + ev->Print(); +#if 0 + const TClonesArray *p=ev->GetParticles(); + for(Int_t i=0;iGetEntriesFast();i++) { + cout << i << endl; + ((AliJetParticle*)p->At(i))->Print(); + } +#endif + ev->Clear(); + nEvent++; + } //end of nev loop + + delete ev; + delete theTree; +} + +void displayMixedEvents(Char_t *fname,Char_t *hname,Float_t ptcut,Int_t nMaxEvents) +{ + //connect to events + TChain *theTree = new TChain("AJEPtree"); + theTree->Add(fname); + AliJetEventParticles *ev=new AliJetEventParticles(); + theTree->SetBranchAddress("particles",&ev); + + Int_t treeentries=(Int_t)theTree->GetEntries(); + if((nMaxEvents<0) || (nMaxEvents>treeentries)) + nMaxEvents=treeentries; + //cout << "Found " << nMaxEvents << " in " << fname << endl; + + TChain *backtheTree = new TChain("AJEPtree"); + backtheTree->Add(hname); + AliJetEventParticles *backev=new AliJetEventParticles(); + backtheTree->SetBranchAddress("particles",&backev); + + Int_t backtreeentries=(Int_t)backtheTree->GetEntries(); + Int_t nPerBackground=nMaxEvents/backtreeentries; + if(nPerBackground==0) nPerBackground=1; + + AliJetEventParticles *mixedev=new AliJetEventParticles(0); + + Int_t neta=20; + Int_t nphi=62; + + TCanvas *c1=new TCanvas("c1","",1000,500); + c1->Divide(2,1); + c1->Update(); + gStyle->SetLabelSize(0.03,"XYZ"); + gStyle->SetTitleOffset(1.0,"XYZ"); + gStyle->SetTitleOffset(1.3,"Y"); + gROOT->ForceStyle(); + + TH2F *h2pp=new TH2F("h2pp","E_{T}^{ch} in PP [GeV];#phi;#eta",nphi,0,TMath::TwoPi(),neta,-1,1); + h2pp->SetStats(0); + TH2F *h2pb=new TH2F("h2pb","E_{T}^{ch} in PbPb [GeV];#phi;#eta;",nphi,0,TMath::TwoPi(),neta,-1,1); + h2pb->SetStats(0); + + //========================================================================= + // start the event loop + //========================================================================= + Int_t nEvent = 0; + Int_t nEventHijing = -1; + Int_t nEventHijingCounter = nPerBackground; + while(nEventGetEvent(nEvent); + + //load background if needed + if(nEventHijingCounter==nPerBackground){ + backev->Reset(); + nEventHijing++; + backtheTree->GetEvent(nEventHijing); + if(nEventHijing==backtreeentries) nEventHijing=0; + nEventHijingCounter=0; + } + backev->AddSignal(*ev); + TString dummy="Counter: "; + dummy+=nEvent; + dummy+=" "; + //dummy+=ev->GetHeader(); + dummy+="(Pythia ";dummy+=nEvent; + dummy+=" "; + //dummy+=backev->GetHeader(); + dummy+=", Hijing ";dummy+=nEventHijing; + dummy+=")"; + mixedev->Set(*backev); + mixedev->SetHeader(dummy); + if(gErrorIgnoreLevel<=kWarning){ + cout << "Read event: " << nEvent << " " << nEventHijing << endl; + mixedev->Print(); + } + + // loop over all particles... + c1->cd(1); + h2pp->Reset(); + AliJetParticle *aliparticle = NULL; + TIterator *iter = ev->GetParticles()->MakeIterator(); + while ((aliparticle = (AliJetParticle *) iter->Next()) != NULL) { + Float_t pt=aliparticle->Pt(); + if(ptFill(aliparticle->Phi(),aliparticle->Eta(),pt); + } + delete iter; + h2pp->Draw("Lego"); + c1->cd(2); + h2pb->Reset(); + iter = mixedev->GetParticles()->MakeIterator(); + while ((aliparticle = (AliJetParticle *) iter->Next()) != NULL) { + Float_t pt=aliparticle->Pt(); + if(ptFill(aliparticle->Phi(),aliparticle->Eta(),pt); + } + delete iter; + + h2pb->Draw("Lego"); + c1->Update(); + Char_t c;cin >> c; + if(c=='s'){ + Char_t sfilenamehist[1024]; + sprintf(sfilenamehist,"./display-planehists-%d-%d.eps",nEvent,nEventHijingCounter); + c1->SaveAs(sfilenamehist); + } + else if(c=='q') break; + + nEvent++; + nEventHijingCounter++; + ev->Reset(); + mixedev->Reset(); + } //end of nev loop + + + delete ev; + delete theTree; + delete backtheTree; + delete backev; +} diff --git a/JETAN/findJets.C b/JETAN/findJets.C new file mode 100644 index 00000000000..7eae6d3ab98 --- /dev/null +++ b/JETAN/findJets.C @@ -0,0 +1,181 @@ +// $Id$ + +#ifndef __CINT__ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#endif + +void findJets(Char_t *filename,Float_t ptcut=1.0,Float_t radius=0.3, + Int_t seedpt=-1,Char_t *savename=0,Int_t nMaxEvents=-1) +{ + //connect to jets + TChain *theTree = new TChain("AJEPtree"); + theTree->Add(filename); + AliJetEventParticles *ev=new AliJetEventParticles(); + theTree->SetBranchAddress("particles",&ev); + + Int_t treeentries=(Int_t)theTree->GetEntries(); + if((nMaxEvents<0) || (nMaxEvents>treeentries)) + nMaxEvents=treeentries; + //cout << "Found " << nMaxEvents << " in " << filename << endl; + + // create the jet finder + Char_t buffer[8096]; + AliTkConeJetFinderV2 *ConeFinder = new AliTkConeJetFinderV2(); + ConeFinder->defaultSettings(); + //ConeFinder->setSettings(120,40); + if(gErrorIgnoreLevel<=kWarning) + ConeFinder->setOutput(kTRUE); + if(seedpt<5) + ConeFinder->setEtMinJet(5.); + else + ConeFinder->setEtMinJet(seedpt); + ConeFinder->setPtCut(ptcut); + ConeFinder->setEtCut(seedpt); + ConeFinder->setRadius(radius); + if(savename) sprintf(buffer,"%s",savename); + else { + Char_t buffer2[8096]; + strncpy(buffer2,filename,strlen(filename)-5); + buffer2[strlen(filename)-5]='\0'; + sprintf(buffer,"%s-thresh-%.1f-rad-%.1f.cone.evout.root",buffer2,ptcut,radius); + } + ConeFinder->setEvOutFilename(buffer); + ConeFinder->init(); + + //========================================================================= + // start the event loop + //========================================================================= + TStopwatch *stopwatch=new TStopwatch(); + Int_t nEvent = 0; + while(nEventGetEvent(nEvent); + + //const AliJetEventParticles *ev=reader->GetEventParticles(); + if(gErrorIgnoreLevel<=kWarning){ + cout << "Read event: " << nEvent << endl; + ev->Print(); + } + TString dummy="Counter: "; + dummy+=nEvent; + + stopwatch->Reset(); + stopwatch->Start(); + ConeFinder->initEvent(ev,dummy); + ConeFinder->run(); + ConeFinder->finishEvent(); + if(gErrorIgnoreLevel<=kWarning){ + cout << "JetFinding done: CPU time " << stopwatch->CpuTime() + << " Real Time " << stopwatch->RealTime() << endl; + } + nEvent++; + ev->Reset(); + } //end of nev loop + + ConeFinder->finish(); + + delete stopwatch; + delete ev; + delete theTree; + delete ConeFinder; +} + +void findChargedJets(Char_t *filename,Float_t ptcut=1.0,Float_t radius=0.3, + Int_t seedpt=10,Char_t *savename=0,Int_t nMaxEvents=-1) +{ + //connect to jets + TChain *theTree = new TChain("AJEPtree"); + theTree->Add(filename); + AliJetEventParticles *ev=new AliJetEventParticles(); + theTree->SetBranchAddress("particles",&ev); + + Int_t treeentries=(Int_t)theTree->GetEntries(); + if((nMaxEvents<0) || (nMaxEvents>treeentries)) + nMaxEvents=treeentries; + //cout << "Found " << nMaxEvents << " in " << filename << endl; + + // create the jet finder + Char_t buffer[8096]; + AliTkChargedJetFinder *ChFinder = new AliTkChargedJetFinder(); + ChFinder->defaultSettings(); + // if(gErrorIgnoreLevel<=kWarning) + ChFinder->setOutput(kTRUE); + ChFinder->setEtMinJet(seedpt); + ChFinder->setPtCut(ptcut); + ChFinder->setPtSeed(seedpt); + ChFinder->setRadius(radius); + if(savename) sprintf(buffer,"%s",savename); + else { + Char_t buffer2[8096]; + strncpy(buffer2,filename,strlen(filename)-5); + buffer2[strlen(filename)-5]='\0'; + sprintf(buffer,"%s-thresh-%.1f-rad-%.1f.charged.evout.root",buffer2,ptcut,radius); + } + ChFinder->setEvOutFilename(buffer); + ChFinder->init(); + + //========================================================================= + // start the event loop + //========================================================================= + TStopwatch *stopwatch=new TStopwatch(); + Int_t nEvent = 0; + while(nEventGetEvent(nEvent); + + // const AliJetEventParticles *ev=reader->GetEventParticles(); + if(gErrorIgnoreLevel<=kWarning){ + cout << "Read event: " << nEvent << endl; + ev->Print(); + } + TString dummy="Counter: "; + dummy+=nEvent; + + stopwatch->Reset(); + stopwatch->Start(); + ChFinder->initEvent(ev,dummy); + ChFinder->run(); + ChFinder->finishEvent(); + stopwatch->Stop(); + if(gErrorIgnoreLevel<=kWarning){ + cout << "JetFinding done: CPU time:" << stopwatch->CpuTime() + << " Real Time:" << stopwatch->RealTime() << endl; + } + nEvent++; + ev->Reset(); + } //end of nev loop + + ChFinder->finish(); + + delete stopwatch; + delete ev; + delete theTree; + delete ChFinder; +} diff --git a/JETAN/findJetsMixed.C b/JETAN/findJetsMixed.C new file mode 100644 index 00000000000..c2dbc513989 --- /dev/null +++ b/JETAN/findJetsMixed.C @@ -0,0 +1,136 @@ +// $Id$ + +#ifndef __CINT__ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#endif + +void findJetsMixed(Char_t *fname,Char_t *hname,Float_t ptcut=2.0,Float_t radius=0.3,Char_t *savename=0,Int_t nMaxEvents=-1) +{ + //connect to jets + TChain *theTree = new TChain("AJEPtree"); + theTree->Add(fname); + AliJetEventParticles *ev=new AliJetEventParticles(); + theTree->SetBranchAddress("particles",&ev); + + Int_t treeentries=(Int_t)theTree->GetEntries(); + if((nMaxEvents<0) || (nMaxEvents>treeentries)) + nMaxEvents=treeentries; + //cout << "Found " << nMaxEvents << " in " << fname << endl; + + + TChain *backtheTree = new TChain("AJEPtree"); + backtheTree->Add(hname); + AliJetEventParticles *backev=new AliJetEventParticles(); + backtheTree->SetBranchAddress("particles",&backev); + + Int_t backtreeentries=(Int_t)backtheTree->GetEntries(); + Int_t nPerBackground=nMaxEvents/backtreeentries; + if(nPerBackground==0) nPerBackground=1; + + // create the jet finder + Char_t buffer[8096]; + AliTkConeJetFinderV2 *ConeFinder = new AliTkConeJetFinderV2(); + ConeFinder->defaultSettings(); + //ConeFinder->setSettings(120,40); + if(gErrorIgnoreLevel<=kWarning) + ConeFinder->setOutput(kTRUE); + ConeFinder->setEtMinJet(10); + ConeFinder->setPtCut(ptcut); + ConeFinder->setEtCut(ptcut); + ConeFinder->setRadius(radius); + if(savename) sprintf(buffer,"%s",savename); + else { + Char_t buffer2[8096]; + strncpy(buffer2,fname,strlen(fname)-5); + buffer2[strlen(fname)-5]='\0'; + sprintf(buffer,"%s-mixed-thresh-%.1f-rad-%.1f.cone.evout.root",buffer2,ptcut,radius); + } + ConeFinder->setEvOutFilename(buffer); + ConeFinder->init(); + + //========================================================================= + // start the event loop + //========================================================================= + TStopwatch *stopwatch=new TStopwatch(); + Int_t nEvent = 0; + Int_t nEventHijing = -1; + Int_t nEventHijingCounter = nPerBackground; + while(nEventGetEvent(nEvent); + + //load background if needed + if(nEventHijingCounter==nPerBackground){ + backev->Reset(); + nEventHijing++; + backtheTree->GetEvent(nEventHijing); + if(nEventHijing==backtreeentries) nEventHijing=0; + nEventHijingCounter=0; + } + + backev->AddSignal(*ev); + TString dummy="Counter: "; + dummy+=nEvent; + dummy+=" "; + //dummy+=ev->GetHeader(); + dummy+="(Pythia ";dummy+=nEvent; + dummy+=" "; + //dummy+=backev->GetHeader(); + dummy+=", Hijing ";dummy+=nEventHijing; + dummy+=")"; + backev->SetHeader(dummy); + if(gErrorIgnoreLevel<=kWarning){ + cout << "Read event: " << nEvent << " " << nEventHijing << endl; + backev->Print(); + } + + stopwatch->Reset(); + stopwatch->Start(); + ConeFinder->initEvent(backev,dummy); + ConeFinder->run(); + ConeFinder->finishEvent(); + if(gErrorIgnoreLevel<=kWarning){ + cout << "JetFinding done: CPU time " << stopwatch->CpuTime() + << " Real Time " << stopwatch->RealTime() << endl; + } + + nEvent++; + nEventHijingCounter++; + ev->Reset(); + } //end of nev loop + + ConeFinder->finish(); + + delete ev; + delete theTree; + delete backev; + delete backtheTree; + delete ConeFinder; +} + diff --git a/JETAN/libJETAN.pkg b/JETAN/libJETAN.pkg index 77a429354c8..19621cc16e9 100644 --- a/JETAN/libJETAN.pkg +++ b/JETAN/libJETAN.pkg @@ -9,4 +9,6 @@ HDRS:= $(SRCS:.cxx=.h) DHDR= JetAnalysisLinkDef.h +EDEFINE := -DALICEINTERFACE + EINCLUDE:= STEER ANALYSIS PYTHIA6 HLT/src HLT/ITS diff --git a/JETAN/libJetFinder.pkg b/JETAN/libJetFinder.pkg new file mode 100644 index 00000000000..5d898938ac5 --- /dev/null +++ b/JETAN/libJetFinder.pkg @@ -0,0 +1,16 @@ +#-*-Mode: Makefile-*- + +SRCS = AliJFPreCluster.cxx AliJFCluster.cxx AliJFTower.cxx \ + AliJFClusterDifference.cxx AliJFMixEvent.cxx AliJFParticlesCut.cxx \ + AliJFJet.cxx AliJFMCJet.cxx AliJFKtJet.cxx \ + AliJFJetFinder.cxx AliJFKtJetFinder.cxx AliJFMCJetFinder.cxx \ + AliJFJetTrigger.cxx AliJFJetCalorimeterTrigger.cxx \ + AliJFJetTriggerResult.cxx AliJFJetCalorimeterTriggerResult.cxx + +HDRS:= $(SRCS:.cxx=.h) + +DHDR= JetFinderLinkDef.h + +EDEFINE := -DALICEINTERFACE + +EINCLUDE:= STEER ANALYSIS PYTHIA6 HLT/src HLT/ITS diff --git a/JETAN/libTkJetFinder.pkg b/JETAN/libTkJetFinder.pkg new file mode 100644 index 00000000000..fd4b6d9c129 --- /dev/null +++ b/JETAN/libTkJetFinder.pkg @@ -0,0 +1,15 @@ +#-*-Mode: Makefile-*- + +SRCS = AliTkConeJetFinder.cxx AliTkKtJetFinder.cxx AliTkConeJetFinderV2.cxx \ + AliTkChargedJetFinder.cxx AliTkConeJetEvent.cxx AliTkHijingAna.cxx \ + AliTkJetTrigger.cxx AliTkJetTriggerSettings.cxx AliTkJetTriggerDecision.cxx \ + AliTkJetTriggerEvent.cxx AliTkConeJet.cxx AliTkTowerV2.cxx \ + AliTkEtaPhiVector.cxx AliTkChargedJet.cxx + +HDRS:= $(SRCS:.cxx=.h) + +DHDR= TkJetFinderLinkDef.h + +EDEFINE := -DALICEINTERFACE + +EINCLUDE:= STEER ANALYSIS PYTHIA6 HLT/src HLT/ITS diff --git a/JETAN/rootlogon.C b/JETAN/rootlogon.C new file mode 100644 index 00000000000..ebf0b1c38eb --- /dev/null +++ b/JETAN/rootlogon.C @@ -0,0 +1,48 @@ +// $Id$ + +{ + printf("\nWELCOME to the magic world of jets\n\n"); + + gSystem->SetIncludePath("-Wno-deprecated -DALICEINTERFACE -I$ALICE_ROOT/include -I$ALICE_ROOT/JETAN -I$ALICE_ROOT/PYTHIA6 -I$ALICE_ROOT/HLT/ITS"); + + Int_t saveErrIgLevel=gErrorIgnoreLevel; + gErrorIgnoreLevel=kFatal; + + gSystem->Load("libAliL3ITS.so"); + + gSystem->Load("libTkJetFinder.so"); + gSystem->Load("libJetFinder.so"); + gSystem->Load("libJETAN.so"); + + gSystem->Load("testJets_C.so"); + gSystem->Load("anaAliJets_C.so"); + gSystem->Load("anaTracks_C.so"); + gSystem->Load("createEvents_C.so"); + gSystem->Load("findJets_C.so"); + gSystem->Load("findJetsMixed_C.so"); + + gErrorIgnoreLevel=saveErrIgLevel; + gErrorIgnoreLevel=kWarning; + gStyle->SetPadColor(0); + gStyle->SetPadBorderSize(0); + gStyle->SetPadBorderMode(0); + gStyle->SetCanvasColor(0); + gStyle->SetCanvasBorderMode(0); + gStyle->SetCanvasBorderSize(0); + gStyle->SetFrameBorderMode(0); + gStyle->SetTitleColor(0); + gStyle->SetTitleBorderSize(0); + gStyle->SetTitleSize(0.036,"XYZ"); + gStyle->SetTitleSize(0.05,"XYZ"); + gStyle->SetTitleOffset(1.3,"XYZ"); + gStyle->SetLabelSize(0.036,"XYZ"); + gStyle->SetTitleColor(1,"XYZ"); + gStyle->SetHistLineWidth(3); + //gStyle->SetLabelSize(0.06,"XYZ"); + //gStyle->SetLabelOffset(0.009,"XYZ"); + + gStyle->SetStatColor(0); + gStyle->SetStatBorderSize(1); + gStyle->SetOptStat("NEMR"); + gROOT->ForceStyle(); +} diff --git a/JETAN/testJets.C b/JETAN/testJets.C new file mode 100644 index 00000000000..8fd8db1e5f2 --- /dev/null +++ b/JETAN/testJets.C @@ -0,0 +1,184 @@ +// $Id$ + +#ifndef __CINT__ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#endif + +#if 0 + kITSin=0x0001,kITSout=0x0002,kITSrefit=0x0004,kITSpid=0x0008, + kTPCin=0x0010,kTPCout=0x0020,kTPCrefit=0x0040,kTPCpid=0x0080, + kTRDin=0x0100,kTRDout=0x0200,kTRDrefit=0x0400,kTRDpid=0x0800, + kTOFin=0x1000,kTOFout=0x2000,kTOFrefit=0x4000,kTOFpid=0x8000, + kPHOSpid=0x10000, kRICHpid=0x20000, + kTRDStop=0x20000000, + kESDpid=0x40000000, + kTIME=0x80000000 +#endif + +void testJets(Char_t *input,Int_t esd=0,Float_t ptcut=2.0,Float_t radius=0.3) +{ + + TObjArray *dirs=new TObjArray(10); + dirs->Add(new TObjString(input)); + + AliJetParticlesReader *reader=0; + TString desc=""; + if (esd==0) { + reader=new AliJetParticlesReaderKine(dirs); + //((AliJetParticlesReaderKine*)reader)->SetUseTracks(kTRUE); + ((AliJetParticlesReaderKine*)reader)->SetCharged(kTRUE); + ((AliJetParticlesReaderKine*)reader)->SetEM(kFALSE); + ((AliJetParticlesReaderKine*)reader)->SetNeutral(kFALSE); + desc+="Kine"; + } else if(esd==1){ + reader=new AliJetParticlesReaderESD(0,dirs); + ((AliJetParticlesReaderESD*)reader)->SetCompareFlag(0x0030); + desc+="ESD"; + } else if (esd==2) { + reader=new AliJetParticlesReaderHLT(kTRUE,dirs); + desc+="HLTConf"; + } else if (esd==3) { + reader=new AliJetParticlesReaderHLT(kFALSE,dirs); + desc+="HLTHough"; + } else if (esd==10) { + reader=new AliJetParticlesReaderKine(dirs); + //((AliJetParticlesReaderKine*)reader)->SetUseTracks(kTRUE); + ((AliJetParticlesReaderKine*)reader)->SetCharged(kTRUE); + ((AliJetParticlesReaderKine*)reader)->SetEM(kTRUE); + ((AliJetParticlesReaderKine*)reader)->SetNeutral(kTRUE); + desc+="Kine-All"; + } else if (esd==11) { + reader=new AliJetParticlesReaderKine(dirs); + //((AliJetParticlesReaderKine*)reader)->SetUseTracks(kTRUE); + ((AliJetParticlesReaderKine*)reader)->SetCharged(kTRUE); + ((AliJetParticlesReaderKine*)reader)->SetEM(kTRUE); + ((AliJetParticlesReaderKine*)reader)->SetNeutral(kFALSE); + desc+="Kine-EM"; + } else { + cout << "Parameter settings: " << endl; + cout << "0 == Kine (ch)" << endl; + cout << "1 == TPC" << endl; + cout << "2 == Conformal" << endl; + cout << "3 == Hough" << endl; + cout << "10 == Kine (all)" << endl; + cout << "11 == Kine (ch+em)" << endl; + return; + } + //reader->ReadEventsFromTo(0,10); + reader->SetPtCut(ptcut,100); + reader->SetEtaCut(-0.9,0.9); + + desc+=" Ptcut: "; + desc+=ptcut; + + // create the jet finder + Char_t buffer[8096]; + AliTkConeJetFinderV2 *ConeFinder = new AliTkConeJetFinderV2(); + ConeFinder->defaultSettings(); + //ConeFinder->setSettings(120,40); + if(gErrorIgnoreLevel<=kWarning) + ConeFinder->setOutput(kTRUE); + ConeFinder->setEtMinJet(1.); + ConeFinder->setEtCut(-1); + ConeFinder->setRadius(radius); + sprintf(buffer,"./conefinder-type%d.evout.root",esd); + //cout << "Cone Jet Finder init: " << endl; + ConeFinder->setEvOutFilename(buffer); + ConeFinder->init(); + + Int_t counter=0; + while(reader->Next()) + { + const AliJetEventParticles *ev=reader->GetEventParticles(); + if(gErrorIgnoreLevel<=kWarning){ + cout << "Read event: " << counter << endl; + ev->Print(); + } + TString dummy="Counter: "; + dummy+=counter; + dummy+=" "; + dummy+=desc; + ConeFinder->initEvent(ev,dummy); + ConeFinder->run(); + ConeFinder->finishEvent(); + } + ConeFinder->finish(); + + delete ConeFinder; + delete reader; +} + +void readJets(Int_t nMaxEvents,Char_t *filename) +{ + //connect to jets + TChain *theTree = new TChain("jets"); + theTree->Add(filename); + AliTkConeJetEvent *event = new AliTkConeJetEvent(); + theTree->SetBranchAddress("ConeFinder",&event); + + Int_t treeentries=(Int_t)theTree->GetEntries(); + if((nMaxEvents<0) || (nMaxEvents>treeentries)) + nMaxEvents=treeentries; + + cout << "Found " << nMaxEvents << " in " << filename << endl; + + //========================================================================= + // start the event loop + //========================================================================= + Int_t nEvent = 0; + while(nEventGetEvent(nEvent); + + AliJetEventParticles *jetparts=event->getJetParticles(); + jetparts->Print(); +#if 0 + const TClonesArray *p=jetparts->GetParticles(); + for(Int_t i=0;iGetEntriesFast();i++) { + cout << i << endl; + ((AliJetParticle*)p->At(i))->Print(); + } +#endif + + TClonesArray *tkjets=event->getJets(); + if(!tkjets){ + cerr << "No Cone jet found in event " << nEvent << ", exiting..." <Print(""); + nEvent++; + event->Clear(); + } //end of nev loop + + delete event; + delete theTree; +} -- 2.43.5