3 /* Kt Jet finder class ala hep-ex/0005012
10 #include <TClonesArray.h>
11 #include <TIterator.h>
12 #include <TParticle.h>
13 #include <TParticlePDG.h>
14 #include <TObjArray.h>
16 #include "AliJFPreCluster.h"
17 #include "AliJFCluster.h"
18 #include "AliJFClusterDifference.h"
19 #include "AliJFKtJet.h"
20 #include "AliJFKtJetFinder.h"
22 ClassImp(AliJFKtJetFinder)
24 AliJFKtJetFinder::AliJFKtJetFinder(Int_t n) : AliJFJetFinder(n)
28 AliJFKtJetFinder::~AliJFKtJetFinder()
33 Bool_t AliJFKtJetFinder::IsAcceptedParticle(TParticle *p)
35 if(p->GetStatusCode()%100!=1) return kFALSE;
37 Int_t pcode=p->GetPdgCode();
39 if((!fEM) && ((pcode==11)||(pcode==-11)||(pcode==22))) return kFALSE;
41 TParticlePDG *pdg=p->GetPDG();
42 Float_t ch=pdg->Charge();
43 if((!fCharged)&&(ch)) return kFALSE;
44 if((!fNeutral)&&(!ch)) return kFALSE;
47 if((eta<fEtaMin)||(eta>fEtaMax)) return kFALSE;
50 if((phi<fPhiMin)||(phi>fPhiMax)) return kFALSE;
53 if((pt<fPtMin)||(pt>fPtMax)) return kFALSE;
58 Int_t AliJFKtJetFinder::Init(TClonesArray *particles)
59 { //create precluster according to particles
60 //each precluster corresponds to a particle
61 //in the accepted range
62 if(particles==NULL) return -1;
64 TIterator *iter=particles->MakeIterator();
68 while((p=(TParticle*)iter->Next()) != NULL){
69 if(IsAcceptedParticle(p)){
72 //fPreClusterList.push_back(new AliJFPreCluster(p));
73 fPreClusterList.push_back(new AliJFPreCluster(p->Px(),p->Py(),p->Pz(),-1,p));
78 for(vector<AliJFPreCluster*>::iterator c=fPreClusterList.begin();c!=fPreClusterList.end();c++){
79 cout << *(*c) << endl;
84 for(vector<AliJFPreCluster*>::iterator i=fPreClusterList.begin();i!=fPreClusterList.end();i++){
85 fClusterList.push_back(new AliJFCluster(*(*i)));
89 for(vector<AliJFCluster*>::iterator c=fClusterList.begin();c!=fClusterList.end();c++){
90 cout << *(*c) << endl;
95 AliJFClusterDifference diff;
96 for(vector<AliJFCluster*>::iterator i=fClusterList.begin();i!=fClusterList.end();i++){
97 for(vector<AliJFCluster*>::iterator j=i;j!=fClusterList.end();j++){
98 diff.SetValues(*i,*j);
99 fClusterDiffSet.insert(diff);
104 for(multiset<AliJFClusterDifference>::iterator pos=fClusterDiffSet.begin();pos!=fClusterDiffSet.end();pos++){
105 cout << *pos << endl;
113 Int_t AliJFKtJetFinder::Run()
115 //loop over stored diffence objects until set is empty
116 while(!fClusterDiffSet.empty()){
117 //get first element of sorted set
118 multiset<AliJFClusterDifference>::iterator pos=fClusterDiffSet.begin();
120 //cout << pos->GetDij() << endl;
121 if((!pos->IsValidPointer())||(!pos->IsValidEntry())){ //delete old value left in set
122 fClusterDiffSet.erase(pos);
127 //get information on stored difference
128 AliJFCluster *i=pos->GetI();
129 AliJFCluster *j=pos->GetJ();
130 bool isjetfound=pos->IsDiagonal();
131 fClusterDiffSet.erase(pos); //take it out
133 if(isjetfound){ //found jet
136 if(fNJets==fNJetsMax){
138 fJets.Expand(fNJetsMax);
141 fJets.AddAt(new AliJFKtJet(),fNJets);
142 fJet=(AliJFKtJet*)fJets.At(fNJets);
143 fJet->SetNJet(++fNJets);
147 } else { //combine cluster and make new difference objects
148 i->CombineCluster(*j);
150 AliJFClusterDifference diff; //create and insert new difference objects
151 for(vector<AliJFCluster*>::iterator c=fClusterList.begin();c!=fClusterList.end();c++){
152 if((*c)->IsValid()) {
153 diff.SetValues(i,*c);
154 fClusterDiffSet.insert(diff);
157 } //end if combine cluster
166 void AliJFKtJetFinder::Debug()
168 for(vector<AliJFPreCluster*>::iterator c=fPreClusterList.begin();c!=fPreClusterList.end();c++){
169 cout << *(*c) << endl;
172 for(vector<AliJFCluster*>::iterator c=fClusterList.begin();c!=fClusterList.end();c++){
178 void AliJFKtJetFinder::Clean()
180 if(!fPreClusterList.empty()){
181 for(vector<AliJFPreCluster*>::iterator i=fPreClusterList.begin();i!=fPreClusterList.end();i++){
184 fPreClusterList.erase(fPreClusterList.begin(),fPreClusterList.end());
186 if(!fClusterList.empty()){
187 for(vector<AliJFCluster*>::iterator i=fClusterList.begin();i!=fClusterList.end();i++){
190 fClusterList.erase(fClusterList.begin(),fClusterList.end());
193 if(!fClusterDiffSet.empty()) fClusterDiffSet.clear();
195 AliJFJetFinder::Clean();