]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - JETAN/AliUA1JetFinder.cxx
Updated geometry including v11Hybrid ITS geometry
[u/mrichter/AliRoot.git] / JETAN / AliUA1JetFinder.cxx
index c9c1e953a009d9d3877d055a62c2ce78a6c2aef3..3dd4cefbf8cb481507e3862f422747bcb6af322f 100755 (executable)
@@ -36,12 +36,11 @@ ClassImp(AliUA1JetFinder)
 
 ////////////////////////////////////////////////////////////////////////
 
-AliUA1JetFinder::AliUA1JetFinder()
-
+AliUA1JetFinder::AliUA1JetFinder():
+  fHeader(0x0),
+  fLego(0x0)
 {
-  // Constructor
-  fHeader = 0x0;
-  fLego   = 0x0;
+  // Default constructor
 }
 
 ////////////////////////////////////////////////////////////////////////
@@ -76,7 +75,7 @@ extern "C" void type_of_call hf1(Int_t& id, Float_t& x, Float_t& wgt);
 
 ////////////////////////////////////////////////////////////////////////
 
-void AliUA1JetFinder::FindJets()
+void AliUA1JetFinder::FindJetsTPC()
 
 {
   // initialize event, look for jets, download jet info
@@ -216,6 +215,253 @@ void AliUA1JetFinder::FindJets()
   delete percentage;
 }
 
+void AliUA1JetFinder::FindJets()
+{ // Find jets with TPC or EMCAL or TPC + EMCAL information
+  // initialize event, look for jets, download jet info
+
+  // 1) transform input to pt,eta,phi plus lego
+    AliJetUnitArray *fUnit = fReader->GetUnitArray();
+    Int_t nIn = fUnit->GetUnitEntries();
+    Int_t fOption = fReader->GetReaderHeader()->GetDetector();
+    Int_t fDebug = fReader->GetReaderHeader()->GetDebug();
+    
+    if(fDebug>1){ 
+       printf("Inside FindJets function ! \n");
+       printf("fOption : %d \n",fOption);
+    }
+    
+    if(fDebug>10){ 
+       cout << "fUnit : " << fUnit << endl;
+       printf("nIn = fUnit->GetUnitEntries() : %d \n",nIn);
+    }
+    
+    if(fDebug>10){
+       printf("     -----------------------------------------------------------------\n");
+       printf("     --- All inputs in fUnitArray ---\n");
+       for(Int_t i=0; i<nIn ; i++){
+           if(fUnit[i].GetUnitEnergy()!=0){
+               printf("     -----------------------------------------------------------------\n");
+               cout << "     |  ID : " << fUnit[i].GetUnitID() << "  |  Eta : " << fUnit[i].GetUnitEta() << "  |  Phi : " << fUnit[i].GetUnitPhi() << "  |  Energy : " << fUnit[i].GetUnitEnergy() << " |" <<endl;
+           }
+       }
+    }
+    
+    if (nIn == 0) return;
+    
+    Int_t nCandidateCut = 0;
+    Int_t nCandidateCut2 = 0;
+    Int_t nCandidate = 0;
+    for (Int_t i = 0; i < nIn; i++){
+       if(fUnit[i].GetUnitEnergy()>0. && fUnit[i].GetUnitCutFlag()==1) {
+           // Number of good tracks/digits which have passed the pt cut
+           nCandidateCut += 1;
+       }
+    if(fUnit[i].GetUnitEnergy()>0.) {
+       // Number of good tracks/digits without pt cut
+       nCandidate += 1;
+    }
+    }
+    
+    if(fDebug>=3){
+    cout << "nCandidate : " << nCandidate << endl;
+    cout << "nCandidateCut : " << nCandidateCut << endl;
+    cout << "nCandidateCut2 : " << nCandidateCut2 << endl;
+    }
+    
+  // local arrays for input No Cuts
+  // Both pt < ptMin and pt > ptMin
+    Float_t* enT       = new Float_t[nCandidate];
+    Float_t* ptT       = new Float_t[nCandidate];
+    Float_t* etaT      = new Float_t[nCandidate];
+    Float_t* phiT      = new Float_t[nCandidate];
+    Float_t* detaT     = new Float_t[nCandidate];
+    Float_t* dphiT     = new Float_t[nCandidate];
+    Float_t* cFlagT    = new Float_t[nCandidate];
+    Float_t* cClusterT = new Float_t[nCandidate];
+    Float_t* idT       = new Float_t[nCandidate];
+    Int_t loop1 = 0;
+    
+    fJets->SetNinput(nCandidate);
+    
+    if(fDebug>3){
+       cout << "nCandidate : " << nCandidate << endl;
+       //    cout << "nMultCandidate : " << nMultCandidate << endl;
+    }
+    
+    Float_t *etCell = new Float_t[nIn];   //! Cell Energy - Extracted from UnitArray
+    Float_t *etaCell = new Float_t[nIn];  //! Cell eta - Extracted from UnitArray
+    Float_t *phiCell = new Float_t[nIn];  //! Cell phi - Extracted from UnitArray
+    
+    // Information extracted from fUnitArray
+    for(Int_t i=0; i<nIn; i++) 
+    {
+       if(fUnit[i].GetUnitCutFlag()==1){ 
+           etCell[i] = fUnit[i].GetUnitEnergy();
+           if (etCell[i] > 0.0) etCell[i] -= fHeader->GetMinCellEt();
+           if (etCell[i] < 0.0) etCell[i] = 0.;
+           etaCell[i] = fUnit[i].GetUnitEta();
+           phiCell[i] = fUnit[i].GetUnitPhi();
+       }
+       else {
+           etCell[i]  = 0.;
+           etaCell[i] = fUnit[i].GetUnitEta();
+           phiCell[i] = fUnit[i].GetUnitPhi();
+       }
+       
+       if(fUnit[i].GetUnitEnergy()>0.){
+           ptT[loop1]   = fUnit[i].GetUnitEnergy();
+           enT[loop1]   = fUnit[i].GetUnitEnergy();
+           etaT[loop1]  = fUnit[i].GetUnitEta();
+           phiT[loop1]  = fUnit[i].GetUnitPhi();
+           detaT[loop1] = fUnit[i].GetUnitDeta();
+           dphiT[loop1] = fUnit[i].GetUnitDphi();
+           cFlagT[loop1]= fUnit[i].GetUnitCutFlag();
+           idT[loop1]   = fUnit[i].GetUnitID();
+           loop1++;
+       }
+    }
+    
+    
+    if(fDebug > 40) // For comparison
+    {
+       for(Int_t j=0; j<nIn; j++) {
+           if(etCell[j]>0){
+               cout << "etCell[" << j << "] : " << etCell[j] << endl;
+               cout << "etaCell[" << j << "] : " << etaCell[j] << endl;
+               cout << "phiCell[" << j << "] : " << phiCell[j] << endl;
+           }
+       }
+    }
+    
+    // Run the algo. Parameters from header
+    //  Int_t nTot      = (fHeader->GetLegoNbinEta())*(fHeader->GetLegoNbinPhi());
+    Int_t nTot      = nIn;
+    Float_t minmove = fHeader->GetMinMove();
+    Float_t maxmove = fHeader->GetMaxMove();
+    Int_t mode      = fHeader->GetMode();
+    Float_t precbg  = fHeader->GetPrecBg();
+    Int_t ierror;
+    
+    ua1_jet_finder(nIn, nTot, etCell, etaCell, phiCell, 
+                  minmove, maxmove, mode, precbg, ierror);
+    
+    // sort jets
+    Int_t * idx  = new Int_t[UA1JETS.njet];
+    TMath::Sort(UA1JETS.njet, UA1JETS.etj, idx);
+    
+    if(fDebug > 20)
+    {
+       for(Int_t i = 0; i < UA1JETS.njet; i++) 
+       {
+           cout << "Number of jets found, UA1JETS.njet : " << UA1JETS.njet << endl;
+           cout << "UA1JETS.etj : " << UA1JETS.etj << endl;
+           cout << "idx[" << i << "] : " << idx[i] << endl;
+           cout << "UA1JETS.etaj[1][" << idx[i] << "] : " << UA1JETS.etaj[1][idx[i]] << endl;
+           cout << "UA1JETS.phij[1][" << idx[i] << "] : " << UA1JETS.phij[1][idx[i]] << endl;
+           cout << "UA1JETS.etj[" << idx[i] << "] : " << UA1JETS.etj[idx[i]] << endl;
+       }
+    }
+    
+    // download jet info.   
+    for(Int_t i = 0; i < UA1JETS.njet; i++) {
+       // reject events outside acceptable eta range
+       if (((UA1JETS.etaj[1][idx[i]])> (fHeader->GetJetEtaMax()))
+           || ((UA1JETS.etaj[1][idx[i]]) < (fHeader->GetJetEtaMin())))
+       {
+           continue;
+       }
+       
+       Float_t px, py,pz,en,pT; // convert to 4-vector
+       px = UA1JETS.etj[idx[i]] * TMath::Cos(UA1JETS.phij[1][idx[i]]);
+       py = UA1JETS.etj[idx[i]] * TMath::Sin(UA1JETS.phij[1][idx[i]]);
+       pz = UA1JETS.etj[idx[i]] /
+           TMath::Tan(2.0 * TMath::ATan(TMath::Exp(-UA1JETS.etaj[1][idx[i]])));
+       en = TMath::Sqrt(px * px + py * py + pz * pz);
+       pT = TMath::Sqrt(px * px + py * py);
+       
+       fJets->AddJet(px, py, pz, en);
+       
+    }
+
+    // find multiplicities and relationship jet-particle
+    // find also percentage of pt from pythia
+    
+    Int_t* injet = new Int_t[nCandidate];
+    Int_t* sflag = new Int_t[nCandidate];
+    for (Int_t i = 0; i < nCandidate; i++) {injet[i]= 0;sflag[i]=0;}
+    Int_t* mult  = new Int_t[fJets->GetNJets()];
+    Int_t* ncell  = new Int_t[fJets->GetNJets()];
+    Float_t* percentage  = new Float_t[fJets->GetNJets()];
+    
+    // Instead of using etaT below, it would be interesting to use the previous fUnitArray object
+    // With the particle ID, it is possible to to have access to its physical properties and one can,
+    // for example, set if the corresponding particle is inside or outside the jet with the flag 
+    // kOutJet/kInJet, other possibilities...
+    
+    for(Int_t i = 0; i < (fJets->GetNJets()); i++) {
+       Float_t pt_sig = 0.0;
+       mult[i] = 0;
+       ncell[i] = UA1JETS.ncellj[i];
+       for (Int_t j = 0; j < nCandidate; j++) {
+           Float_t deta = etaT[j] - fJets->GetEta(i);
+           Float_t dphi = phiT[j] - fJets->GetPhi(i);
+           if (dphi < -TMath::Pi()) dphi= -dphi - 2.0 * TMath::Pi();
+           if (dphi > TMath::Pi()) dphi = 2.0 * TMath::Pi() - dphi;
+           Float_t dr = TMath::Sqrt(deta * deta + dphi * dphi);
+           if (dr < fHeader->GetRadius() && injet[j] == 0) {
+               injet[j] = -(i+1);
+               if(cFlagT[j] == 1 &&
+                  (etaT[j] < fHeader->GetLegoEtaMax()) &&
+                  (etaT[j] > fHeader->GetLegoEtaMin())) {
+                   injet[j] = i+1;
+                   mult[i]++;
+                   pt_sig+=enT[j];
+                   sflag[j]=1;
+               }
+           }
+           if(fDebug>10){
+               cout << "mult[" << i << "] : " << mult[i] << endl;
+               cout << "ncell[" << i << "] : " << ncell[i] << endl;
+           }
+       }
+       percentage[i] = (pt_sig-ncell[i]*UA1JETS.etavg)/
+           ((Double_t) fJets->GetPt(i));    
+    }
+    
+    fJets->SetNCells(ncell);
+    fJets->SetPtFromSignal(percentage);
+    fJets->SetMultiplicities(mult);
+    fJets->SetInJet(injet);
+    fJets->SetEtaIn(etaT);
+    if(fDebug>10){
+       for(Int_t i=0; i<nCandidate ; i++){
+           cout << "phiT[" << i << "] : " << phiT[i] << endl;
+           cout << "etaT[" << i << "] : " << etaT[i] << endl;
+       }
+    }
+    fJets->SetPhiIn(phiT);
+    fJets->SetPtIn(enT);
+    fJets->SetEtAvg(UA1JETS.etavg);
+    delete etCell;
+    delete etaCell;
+    delete phiCell;
+    delete ncell;
+    delete cFlagT;
+    delete cClusterT;
+    delete enT;
+    delete ptT;
+    delete etaT;
+    delete phiT;
+    delete detaT;
+    delete dphiT;
+    delete injet;
+    delete idx;
+    delete mult;
+    delete percentage;
+    
+}
+
+
 ////////////////////////////////////////////////////////////////////////
 
 void AliUA1JetFinder::Reset()