CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
AnalyzerWithCentrality.cc
Go to the documentation of this file.
1 
2 // system include files
3 #include <memory>
4 #include <iostream>
5 
6 // user include files
9 
12 
14 
18 
19 #include "TNtuple.h"
20 #include "TH1D.h"
21 using namespace std;
22 
23 //
24 // class declaration
25 //
26 
28  public:
31 
32 
33  private:
34  virtual void beginJob() ;
35  virtual void analyze(const edm::Event&, const edm::EventSetup&);
36  virtual void endJob() ;
37 
38  // ----------member data ---------------------------
39 
42  TH1D* h1;
43  TNtuple* nt;
44 };
45 
46 //
47 // constants, enums and typedefs
48 //
49 
50 //
51 // static data member definitions
52 //
53 
54 //
55 // constructors and destructor
56 //
58 centrality_(0)
59 {
60  //now do what ever initialization is needed
61  h1 = fs->make<TH1D>("h1","histogram",100,0,100);
62  nt = fs->make<TNtuple>("hi","hi","hf:hft:hftp:hftm:eb:ee:eep:eem:npix:et:zdc:zdcp:zdcm:bin:trig");
63 }
64 
66 {
67 
68  // do anything here that needs to be done at desctruction time
69  // (e.g. close files, deallocate resources etc.)
70 
71 }
72 
73 
74 //
75 // member functions
76 //
77 
78 // ------------ method called to for each event ------------
79 void
81 {
82  using namespace edm;
83  if(!centrality_) centrality_ = new CentralityProvider(iSetup);
84  centrality_->newEvent(iEvent,iSetup);
85 
86  double hf = centrality_->raw()->EtHFhitSum();
87  double hft = centrality_->raw()->EtHFtowerSum();
88  double hftp = centrality_->raw()->EtHFtowerSumPlus();
89  double hftm = centrality_->raw()->EtHFtowerSumMinus();
90  double eb = centrality_->raw()->EtEBSum();
91  double ee = centrality_->raw()->EtEESum();
92  double eep = centrality_->raw()->EtEESumPlus();
93  double eem = centrality_->raw()->EtEESumMinus();
94  double zdc = centrality_->raw()->zdcSum();
95  double zdcm = centrality_->raw()->zdcSumMinus();
96  double zdcp = centrality_->raw()->zdcSumPlus();
97  double npix = centrality_->raw()->multiplicityPixel();
98  double et = centrality_->raw()->EtMidRapiditySum();
99 
100  cout<<"Centrality variables in the event:"<<endl;
101  cout<<"Total energy in HF hits : "<<hf<<endl;
102  cout<<"Asymmetry of HF towers : "<<fabs(hftp-hftm)/(hftp+hftm)<<endl;
103  cout<<"Total energy in EE basic clusters : "<<eep+eem<<endl;
104  cout<<"Total energy in EB basic clusters : "<<eb<<endl;
105 
106  centrality_->print();
107 
108  cout<<"Centrality of the event : "<<centrality_->centralityValue()<<endl;
109 
110  int bin = centrality_->getBin();
111  cout<<"a"<<endl;
112  nt->Fill(hf,hft,hftp,hftm,eb,ee,eep,eem,npix,et,zdc,zdcp,zdcm,bin,1);
113  cout<<"b"<<endl;
114 
115  h1->Fill(bin);
116  cout<<"c"<<endl;
117 
118  int nbins = centrality_->getNbins();
119  cout<<"d"<<endl;
120  int binsize = 100./nbins;
121  cout<<"e"<<endl;
122  char* binName = Form("%d to % d",bin*binsize,(bin+1)*binsize);
123  cout<<"The event falls into centrality bin : "<<binName<<" id : "<<bin<<endl;
124 
125  double npartMean = centrality_->NpartMean();
126  double npartSigma = centrality_->NpartSigma();
127  cout<<"Npart Mean : "<<npartMean<<" Variance : "<<npartSigma<<endl;
128 
129  // or, alternatively,
130  npartMean = centrality_->NpartMeanOfBin(bin);
131  npartSigma = centrality_->NpartSigmaOfBin(bin);
132 
133  double ncollMean = centrality_->NcollMean();
134  double ncollSigma = centrality_->NcollSigma();
135  cout<<"Ncoll Mean : "<<ncollMean<<" Variance : "<<ncollSigma<<endl;
136 
137  // or, alternatively,
138  ncollMean = centrality_->NcollMeanOfBin(bin);
139  ncollSigma = centrality_->NcollSigmaOfBin(bin);
140 
141 
142  double nhardMean = centrality_->NhardMean();
143  double nhardSigma = centrality_->NhardSigma();
144  cout<<"Nhard Mean : "<<nhardMean<<" Variance : "<<nhardSigma<<endl;
145 
146  double bMean = centrality_->bMean();
147  double bSigma = centrality_->bSigma();
148  cout<<"b Mean : "<<bMean<<" Variance : "<<bSigma<<endl;
149 
150  bMean = centrality_->bMeanOfBin(bin);
151  bSigma = centrality_->bSigmaOfBin(bin);
152 
153 
154 }
155 
156 
157 // ------------ method called once each job just before starting event loop ------------
158 void
160 {
161 }
162 
163 // ------------ method called once each job just after ending the event loop ------------
164 void
166 }
167 
168 //define this as a plug-in
double zdcSum() const
Definition: Centrality.h:43
double EtEESum() const
Definition: Centrality.h:26
float bMean() const
float NpartSigmaOfBin(int bin) const
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
double EtHFtowerSumMinus() const
Definition: Centrality.h:22
double EtEESumMinus() const
Definition: Centrality.h:28
float NcollSigma() const
float NhardMean() const
const reco::Centrality * raw() const
float NpartMean() const
void beginJob()
Definition: Breakpoints.cc:15
virtual void analyze(const edm::Event &, const edm::EventSetup &)
double zdcSumMinus() const
Definition: Centrality.h:45
int iEvent
Definition: GenABIO.cc:243
float NcollMeanOfBin(int bin) const
AnalyzerWithCentrality(const edm::ParameterSet &)
void newEvent(const edm::Event &ev, const edm::EventSetup &iSetup)
float NpartSigma() const
double EtHFtowerSumPlus() const
Definition: Centrality.h:21
float bSigmaOfBin(int bin) const
double EtEESumPlus() const
Definition: Centrality.h:27
float NhardSigma() const
double multiplicityPixel() const
Definition: Centrality.h:36
double EtHFtowerSum() const
Definition: Centrality.h:20
float NpartMeanOfBin(int bin) const
double EtEBSum() const
Definition: Centrality.h:32
double EtMidRapiditySum() const
Definition: Centrality.h:46
double EtHFhitSum() const
Definition: Centrality.h:17
float bSigma() const
CentralityProvider * centrality_
float bMeanOfBin(int bin) const
T * make() const
make new ROOT object
float NcollMean() const
tuple cout
Definition: gather_cfg.py:121
double centralityValue() const
edm::Service< TFileService > fs
float NcollSigmaOfBin(int bin) const
double zdcSumPlus() const
Definition: Centrality.h:44