Coding violations corrected.
[u/mrichter/AliRoot.git] / JETAN / AliJetHistos.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
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  **************************************************************************/
15
16 /* $Id$ */
17
18 #include <TList.h>
19 #include <TClonesArray.h>
20 #include <TH1I.h>
21 #include <TH1F.h>
22 #include <TMath.h>
23
24 #include "AliAODJet.h"
25 #include "AliJetHistos.h"
26
27 ClassImp(AliJetHistos)
28
29 AliJetHistos::AliJetHistos():
30   fNJetsH(0x0),
31   fPtH(0x0),
32   fEtaH(0x0),
33   fEneH(0x0),
34   fPhiH(0x0)
35 {
36   // Default constructor
37
38   fNJetsH = new TH1I("NJetsH","Number of Jets",12,0,11);
39   SetProperties(fNJetsH,"Number of jets","Entries");
40
41   fPtH = new TH1F("PtH","Pt of Jets",50,0.,200.);
42   SetProperties(fPtH,"P_{#perp} [GeV]","Entries");
43
44   fEtaH = new TH1F("EtaH","Pseudorapidity of Jets",30,-1.5,1.5);
45   SetProperties(fEtaH,"#eta","Entries");
46
47   fEneH = new TH1F("EneH","Energy of Jets",50,0.,200.);
48   SetProperties(fEneH,"Energy [GeV]","Entries");
49
50   fPhiH = new TH1F("PhiH","Azimuthal angle of Jets",
51                    60,0.,2.0*TMath::Pi());
52   SetProperties(fPhiH,"#phi","Entries");
53 }
54
55 AliJetHistos::~AliJetHistos()
56 {
57   delete fNJetsH;
58   delete fPtH;
59   delete fEtaH;
60   delete fEneH;
61   delete fPhiH;
62 }
63
64 void AliJetHistos::SetProperties(TH1* h,const char* x, const char* y) const
65 {
66 // Sets the histogram style properties
67   h->SetMarkerStyle(20);
68   h->SetMarkerSize(.5);
69   h->SetMarkerColor(2);
70   h->SetXTitle(x);
71   h->SetYTitle(y);
72   h->Sumw2();
73 }
74
75 void AliJetHistos::AddHistosToList(TList *list)
76 {
77   list->Add(fNJetsH);
78   list->Add(fPtH);
79   list->Add(fEtaH);
80   list->Add(fEneH);
81   list->Add(fPhiH);
82 }
83
84
85 void AliJetHistos::FillHistos(TClonesArray *jets)
86 {
87
88   if(!jets)return;
89   Int_t nj = jets->GetEntries();
90   fNJetsH->Fill(nj,1);
91
92   if (nj == 0 ) return;
93
94   AliAODJet *j;
95   for (Int_t i=0;i<nj;i++) {
96     j = (AliAODJet *) jets->At(i);
97     fPtH->Fill(j->Pt(),1);
98     fEtaH->Fill(j->Eta(),1);
99     fEneH->Fill(j->E(),1);
100     fPhiH->Fill(j->Phi(),1);
101   }
102   
103 }