ATLAS Offline Software
zbeam.h
Go to the documentation of this file.
1 /* emacs: this is -*- c++ -*- */
12 #ifndef ZBEAM_H
13 #define ZBEAM_H
14 
15 #include <iostream>
16 
17 #include "TProfile.h"
18 #include "TH1D.h"
19 #include "TH2D.h"
20 #include "TPad.h"
21 #include "TStyle.h"
22 
23 
24 class zbeam {
25 
26 public:
27 
28  zbeam( const std::vector<std::pair<int,double> >& refz,
29  const std::vector<std::pair<int,double> >& testz ) {
30 
31  if ( refz.size()!=testz.size() || refz.size()==0 ) return;
32 
33  double _min = refz.back().first;
34  double _max = refz[0].first;
35 
36  for ( unsigned i=refz.size() ; i-- ; ) if ( refz[i].first>_max ) _max = refz[i].first;
37  for ( unsigned i=0 ; i<refz.size() ; i++ ) if ( refz[i].first<_min ) _min = refz[i].first;
38 
39  double minz = refz.back().second;
40  double maxz = minz;
41 
42  for ( unsigned i=refz.size() ; i-- ; ) {
43  if ( refz[i].second<minz ) minz = refz[i].second;
44  if ( testz[i].second<minz ) minz = testz[i].second;
45  if ( refz[i].second>maxz ) maxz = refz[i].second;
46  if ( testz[i].second>maxz ) maxz = testz[i].second;
47  }
48 
49  double dz = maxz-minz;
50 
51  gStyle->SetOptStat(0);
52 
53  TProfile* hr = new TProfile( "refz", ";lumi block;z reference [mm]", _max-_min+1, _min-0.5, _max+0.5 );
54  TProfile* ht = new TProfile( "testz", ";lumi block;z reference [mm]", _max-_min+1, _min-0.5, _max+0.5 );
55 
56  TH1D* h = new TH1D("zres", ";#Delta z [mm]", 100, -10, 10 );
57 
58  TH2D* h2 = new TH2D( "zcor", ";z ref [mm]; ztest [mm]", 20, minz, maxz, 20, minz, maxz );
59 
60  for ( unsigned i=refz.size() ; i-- ; ) {
61  hr->Fill( refz[i].first, refz[i].second );
62  ht->Fill( testz[i].first, testz[i].second );
63 
64  h->Fill( testz[i].second-refz[i].second );
65 
66  h2->Fill( refz[i].second, testz[i].second );
67  }
68 
69  hr->SetMarkerColor(kRed);
70  hr->SetLineColor(kRed);
71 
72  hr->SetMarkerStyle(24);
73  ht->SetMarkerStyle(20);
74 
75  hr->SetMarkerSize(0.5);
76  ht->SetMarkerSize(0.5);
77 
78  hr->SetMaximum( maxz+dz/10 );
79  hr->SetMinimum( minz-dz/10 );
80 
81  hr->DrawCopy();
82  ht->DrawCopy("same");
83 
84  gPad->Print( "zbeam.pdf");
85 
86  h->DrawCopy();
87 
88  gPad->Print( "zbeam-res.pdf" );
89 
90 
91  h2->DrawCopy( "colz" );
92  gPad->Print( "zbeam-cor.pdf" );
93 
94  TFile f( "zbeam.root", "recreate" );
95  h->Write();
96  hr->Write();
97  ht->Write();
98  h2->Write();
99  f.Close();
100 
101  delete hr;
102  delete ht;
103 
104  delete h;
105 
106  }
107 
108  virtual ~zbeam() { }
109 
110 private:
111 
112 };
113 
114 inline std::ostream& operator<<( std::ostream& s, const zbeam& ) {
115  return s;
116 }
117 
118 
119 #endif // ZBEAM_H
120 
121 
122 
123 
124 
125 
126 
127 
128 
129 
python.SystemOfUnits.second
int second
Definition: SystemOfUnits.py:120
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
BindingsTest.hr
hr
Definition: BindingsTest.py:23
operator<<
std::ostream & operator<<(std::ostream &s, const zbeam &)
Definition: zbeam.h:114
zbeam::~zbeam
virtual ~zbeam()
Definition: zbeam.h:108
lumiFormat.i
int i
Definition: lumiFormat.py:85
python.TrigEgammaMonitorHelper.TProfile
def TProfile(*args, **kwargs)
Definition: TrigEgammaMonitorHelper.py:81
extractSporadic.h
list h
Definition: extractSporadic.py:97
hist_file_dump.f
f
Definition: hist_file_dump.py:135
zbeam::zbeam
zbeam(const std::vector< std::pair< int, double > > &refz, const std::vector< std::pair< int, double > > &testz)
Definition: zbeam.h:28
h
DeMoScan.first
bool first
Definition: DeMoScan.py:536
zbeam
Definition: zbeam.h:24