1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
17 //*-- Author: Andreas Morsch (CERN)
18 #include <TClonesArray.h>
23 #include <TParticle.h>
24 #include <TParticlePDG.h>
25 #include "AliEMCALJetFinder.h"
26 #include "AliEMCALGeometry.h"
27 #include "AliEMCALHit.h"
31 #include "AliHeader.h"
33 ClassImp(AliEMCALJetFinder)
35 //____________________________________________________________________________
36 AliEMCALJetFinder::AliEMCALJetFinder()
38 // Default constructor
44 AliEMCALJetFinder::AliEMCALJetFinder(const char* name, const char *title)
48 fJets = new TClonesArray("AliEMCALJet",10000);
50 for (Int_t i=0; i<30000; i++)
62 //____________________________________________________________________________
63 AliEMCALJetFinder::~AliEMCALJetFinder()
76 # define jet_finder_ua1 jet_finder_ua1_
81 # define jet_finder_ua1 J
83 # define type_of_call _stdcall
86 extern "C" void type_of_call
87 jet_finder_ua1(Int_t& ncell, Int_t& ncell_tot,
88 Float_t etc[30000], Float_t etac[30000],
90 Float_t& min_move, Float_t& max_move, Int_t& mode,
91 Float_t& prec_bg, Int_t& ierror);
93 extern "C" void type_of_call hf1(Int_t& id, Float_t& x, Float_t& wgt);
99 void AliEMCALJetFinder::Find(Int_t ncell, Int_t ncell_tot, Float_t etc[30000],
100 Float_t etac[30000], Float_t phic[30000],
101 Float_t min_move, Float_t max_move, Int_t mode,
102 Float_t prec_bg, Int_t ierror)
104 // Wrapper for fortran coded jet finder
105 // Full argument list
106 jet_finder_ua1(ncell, ncell_tot, etc, etac, phic,
107 min_move, max_move, mode, prec_bg, ierror);
108 // Write result to output
112 void AliEMCALJetFinder::Find()
114 // Wrapper for fortran coded jet finder using member data for
117 Float_t min_move = 0;
118 Float_t max_move = 0;
120 Float_t prec_bg = 0.;
123 jet_finder_ua1(fNcell, fNtot, fEtCell, fEtaCell, fPhiCell,
124 min_move, max_move, mode, prec_bg, ierror);
125 // Write result to output
130 Int_t AliEMCALJetFinder::Njets()
132 // Get number of reconstructed jets
133 return EMCALJETS.njet;
136 Float_t AliEMCALJetFinder::JetEnergy(Int_t i)
138 // Get reconstructed jet energy
139 return EMCALJETS.etj[i];
142 Float_t AliEMCALJetFinder::JetPhiL(Int_t i)
144 // Get reconstructed jet phi from leading particle
145 return EMCALJETS.phij[0][i];
148 Float_t AliEMCALJetFinder::JetPhiW(Int_t i)
150 // Get reconstructed jet phi from weighting
151 return EMCALJETS.phij[1][i];
154 Float_t AliEMCALJetFinder::JetEtaL(Int_t i)
156 // Get reconstructed jet eta from leading particles
157 return EMCALJETS.etaj[0][i];
161 Float_t AliEMCALJetFinder::JetEtaW(Int_t i)
163 // Get reconstructed jet eta from weighting
164 return EMCALJETS.etaj[1][i];
167 void AliEMCALJetFinder::SetCellSize(Float_t eta, Float_t phi)
169 // Set grid cell size
170 EMCALCELLGEO.etaCellSize = eta;
171 EMCALCELLGEO.phiCellSize = phi;
174 void AliEMCALJetFinder::SetConeRadius(Float_t par)
176 // Set jet cone radius
177 EMCALJETPARAM.coneRad = par;
180 void AliEMCALJetFinder::SetEtSeed(Float_t par)
182 // Set et cut for seeds
183 EMCALJETPARAM.etSeed = par;
186 void AliEMCALJetFinder::SetMinJetEt(Float_t par)
188 // Set minimum jet et
189 EMCALJETPARAM.ejMin = par;
192 void AliEMCALJetFinder::SetMinCellEt(Float_t par)
194 // Set et cut per cell
195 EMCALJETPARAM.etMin = par;
199 void AliEMCALJetFinder::Test()
202 // Test the finder call
204 const Int_t nmax = 30000;
206 Int_t ncell_tot = 100;
211 Float_t min_move = 0;
212 Float_t max_move = 0;
218 Find(ncell, ncell_tot, etc, etac, phic,
219 min_move, max_move, mode, prec_bg, ierror);
227 void AliEMCALJetFinder::AddJet(const AliEMCALJet& jet)
232 TClonesArray &lrawcl = *fJets;
233 new(lrawcl[fNjets++]) AliEMCALJet(jet);
236 void AliEMCALJetFinder::ResetJets()
245 void AliEMCALJetFinder::WriteJets()
248 // Add all jets to the list
250 const Int_t kBufferSize = 4000;
251 TTree *pK = gAlice->TreeK();
252 const char* file = (pK->GetCurrentFile())->GetName();
254 AliEMCAL* pEMCAL = (AliEMCAL* )gAlice->GetModule("EMCAL");
255 printf("Make Branch - TreeR address %p %p\n",gAlice->TreeR(), pEMCAL);
256 if (fJets && gAlice->TreeR()) {
257 pEMCAL->MakeBranchInTree(gAlice->TreeR(),
263 Int_t njet = Njets();
264 for (Int_t nj=0; nj<njet; nj++)
266 AliEMCALJet* jet = new AliEMCALJet(JetEnergy(nj),
272 Int_t nev = gAlice->GetHeader()->GetEvent();
273 gAlice->TreeR()->Fill();
275 sprintf(hname,"TreeR%d", nev);
276 gAlice->TreeR()->Write(hname);
277 gAlice->TreeR()->Reset();
281 void AliEMCALJetFinder::BookLego()
284 // Book histo for discretisation
287 // Get geometry parameters from
288 AliEMCAL* pEMCAL = (AliEMCAL*) gAlice->GetModule("EMCAL");
289 AliEMCALGeometry* geom =
290 AliEMCALGeometry::GetInstance(pEMCAL->GetTitle(), "");
291 fNbinEta = geom->GetNZ();
292 fNbinPhi = geom->GetNPhi();
293 const Float_t phiMin = geom->GetArm1PhiMin()*TMath::Pi()/180.;
294 const Float_t phiMax = geom->GetArm1PhiMax()*TMath::Pi()/180.;
295 fDphi = (phiMax-phiMin)/fNbinEta;
296 fDeta = 1.4/fNbinEta;
297 fNtot = fNbinPhi*fNbinEta;
300 fLego = new TH2F("legoH","eta-phi",
302 fNbinPhi, phiMin, phiMax);
305 void AliEMCALJetFinder::DumpLego()
308 // Dump lego histo into array
311 for (Int_t i = 1; i < fNbinEta; i++) {
312 for (Int_t j = 1; j < fNbinPhi; j++) {
313 Float_t e = fLego->GetBinContent(i,j);
314 TAxis* Xaxis = fLego->GetXaxis();
315 TAxis* Yaxis = fLego->GetYaxis();
316 Float_t eta = Xaxis->GetBinCenter(i);
317 Float_t phi = Yaxis->GetBinCenter(j);
319 fEtaCell[fNcell] = eta;
320 fPhiCell[fNcell] = phi;
327 void AliEMCALJetFinder::ResetMap()
330 // Reset eta-phi array
332 for (Int_t i=0; i<30000; i++)
341 void AliEMCALJetFinder::FillFromTracks(Int_t flag, Int_t ich)
344 // Fill Cells with hit information
349 if (!fLego) BookLego();
351 if (flag == 0) fLego->Reset();
353 // Access particle information
354 Int_t npart = (gAlice->GetHeader())->GetNprimary();
355 for (Int_t part=2; part<npart; part++) {
356 TParticle *MPart = gAlice->Particle(part);
357 Int_t mpart = MPart->GetPdgCode();
358 Int_t child1 = MPart->GetFirstDaughter();
359 Float_t pT = MPart->Pt();
360 Float_t phi = MPart->Phi();
361 Float_t theta = MPart->Theta();
362 Float_t eta = -TMath::Log(TMath::Tan(theta/2.));
363 // if (part == 6 || part == 7)
365 // printf("\n Simulated Jet (pt, eta, phi): %d %f %f %f",
366 // part-5, pT, eta, phi);
369 if (pT == 0.) continue;
370 // charged or neutral
372 TParticlePDG* pdgP = MPart->GetPDG();
373 if (pdgP->Charge() == 0) continue;
376 if (TMath::Abs(mpart) <= 6 ||
378 mpart == 92) continue;
380 if (TMath::Abs(eta) > 0.7) continue;
381 if (phi*180./TMath::Pi() > 120.) continue;
383 if (child1 >= 0 && child1 < npart) continue;
384 // printf("\n sel:%5d %5d %5d %8.2f %8.2f %8.2f",
385 // part, mpart, child1, eta, phi, pT);
386 fLego->Fill(eta, phi, pT);
391 void AliEMCALJetFinder::FillFromHits(Int_t flag)
394 // Fill Cells with track information
399 if (!fLego) BookLego();
400 if (flag == 0) fLego->Reset();
403 // Access hit information
404 AliEMCAL* pEMCAL = (AliEMCAL*) gAlice->GetModule("EMCAL");
405 // AliEMCALGeometry* geom =
406 // AliEMCALGeometry::GetInstance(pEMCAL->GetTitle(), "");
408 TTree *treeH = gAlice->TreeH();
409 Int_t ntracks = (Int_t) treeH->GetEntries();
416 for (Int_t track=0; track<ntracks;track++) {
418 nbytes += treeH->GetEvent(track);
422 for(AliEMCALHit* mHit=(AliEMCALHit*) pEMCAL->FirstHit(-1);
424 mHit=(AliEMCALHit*) pEMCAL->NextHit())
426 Float_t x = mHit->X(); // x-pos of hit
427 Float_t y = mHit->Y(); // y-pos
428 Float_t z = mHit->Z(); // z-pos
429 Float_t eloss = mHit->GetEnergy(); // deposited energy
430 // Int_t index = mHit->GetId(); // cell index
432 // geom->EtaPhiFromIndex(index, eta, phi);
433 Float_t r = TMath::Sqrt(x*x+y*y);
434 Float_t theta = TMath::ATan2(r,z);
435 Float_t eta = -TMath::Log(TMath::Tan(theta/2.));
436 Float_t phi = TMath::ATan2(y,x);
437 fLego->Fill(eta, phi, eloss);
438 // if (eloss > 1.) printf("\nx,y,z %f %f %f %f %f",
439 // r, z, eta, phi, eloss);
440 // printf("\n Max %f", fLego->GetMaximum());
447 void hf1(Int_t& id, Float_t& x, Float_t& wgt)
449 // dummy for hbook calls