First commit.
[u/mrichter/AliRoot.git] / EMCAL / AnaJets.C
CommitLineData
048813fc 1void AnaJets(Int_t evNumber1=0, Int_t evNumber2=0)
2{
3//*-- Author: Andreas Morsch (CERN)
4
5 if (gClassTable->GetID("AliRun") < 0) {
6 gROOT->LoadMacro("../macros/loadlibs.C");
7 loadlibs();
8 }
9// Connect the Root Galice file containing Geometry, Kine and Hits
10
11 TFile *file = (TFile*)gROOT->GetListOfFiles()->FindObject("galice.root");
12
13 if (!file) {
14 printf("\n Creating galice.root \n");
15 file = new TFile("galice.root");
16 } else {
17 printf("\n galice.root found in file list");
18 }
19// Get AliRun object from file or create it if not on file
20 if (!gAlice) {
21 gAlice = (AliRun*)(file->Get("gAlice"));
22 if (gAlice) printf("AliRun object found on file\n");
23 if (!gAlice) {
24 printf("\n create new gAlice object");
25 gAlice = new AliRun("gAlice","Alice test program");
26 }
27 }
28// Book histos
29 TH1F *eH = new TH1F("eH","Energy", 150, 0.0, 150.);
30 TH1F *etaH = new TH1F("eEta","Eta", 180, -0.9, 0.9);
31 TH1F *phiH = new TH1F("ePhi","Phi", 62, -3.1, 3.1);
32
33
34 TClonesArray* jets = new TClonesArray("AliEMCALJet",10000);
35
36 for (int nev=0; nev<= evNumber2; nev++) {
37 printf("\n Event .............%d", nev);
38 Int_t nparticles = gAlice->GetEvent(nev);
39 Int_t nbytes = 0;
40 AliEMCAL *pEMCAL = (AliEMCAL*) gAlice->GetModule("EMCAL");
41 if (pEMCAL) {
42 TTree *TR = gAlice->TreeR();
43 Int_t nent=TR->GetEntries();
44 TR->SetBranchAddress("Jets", &jets);
45 nbytes += TR->GetEntry(0);
46 Int_t nJet = jets->GetEntries();
47 printf("\n Number of Jets %d", nJet);
48 AliEMCALJet *mJet;
49 for (Int_t ij=0; ij < nJet; ij++) {
50 mJet = (AliEMCALJet*)jets->UncheckedAt(ij);
51 printf("\n Jet:%d E %f phi %f eta %f\n", ij,
52 mJet->Energy(), mJet->Phi(), mJet->Eta());
53 etaH->Fill(mJet->Eta());
54 phiH->Fill(mJet->Phi());
55 eH ->Fill(mJet->Energy());
56 } // jet
57 } // ?EMCAL
58 } // event
59 TCanvas *c1 = new TCanvas("c1","Canvas 1",400,10,600,700);
60 c1->Divide(2,2);
61 c1->cd(1); eH->Draw();
62 c1->cd(2); etaH->Draw();
63 c1->cd(3); phiH->Draw();
64}