1 |
fgolf |
1.1 |
#include <algorithm>
|
2 |
|
|
#include <set>
|
3 |
|
|
#include "Math/VectorUtil.h"
|
4 |
|
|
#include "Math/PtEtaPhiE4D.h"
|
5 |
|
|
#include "Math/PtEtaPhiM4D.h"
|
6 |
|
|
#include "Math/LorentzVector.h"
|
7 |
|
|
#include "TH1F.h"
|
8 |
|
|
#include "TH2F.h"
|
9 |
|
|
#include "TFile.h"
|
10 |
|
|
#include "TMath.h"
|
11 |
|
|
#include "TList.h"
|
12 |
|
|
#include "TRegexp.h"
|
13 |
|
|
#include "TDirectory.h"
|
14 |
|
|
#include "tools.h"
|
15 |
|
|
#include "../CORE/CMS2.h"
|
16 |
|
|
|
17 |
|
|
// use this directory to store our histograms (so they can be written to file in one fell swoop)
|
18 |
|
|
TDirectory *histo_directory = new TDirectory("histo_directory", "directory for all our histograms");
|
19 |
|
|
|
20 |
|
|
void progressBar(int& i_permille_old, int nEventsTotal, int nEventsChain) {
|
21 |
|
|
//
|
22 |
|
|
// progress bar
|
23 |
|
|
//
|
24 |
|
|
int i_permille = (int)floor(1000 * nEventsTotal / float(nEventsChain));
|
25 |
|
|
if (i_permille != i_permille_old) {
|
26 |
|
|
// xterm magic from L. Vacavant and A. Cerri
|
27 |
|
|
printf("\015\033[32m ---> \033[1m\033[31m%4.1f%%"
|
28 |
|
|
"\033[0m\033[32m <---\033[0m\015", i_permille/10.);
|
29 |
|
|
fflush(stdout);
|
30 |
|
|
i_permille_old = i_permille;
|
31 |
|
|
}
|
32 |
|
|
}
|
33 |
|
|
|
34 |
|
|
DorkyEventIdentifier::DorkyEventIdentifier (CMS2 &cms2)
|
35 |
|
|
: run(cms2.evt_run()),
|
36 |
|
|
event(cms2.evt_event()),
|
37 |
|
|
lumi_section(cms2.evt_lumiBlock()),
|
38 |
|
|
trks_d0(cms2.trks_d0().at(0)), // use at() because that way we
|
39 |
|
|
// get an exception if we are
|
40 |
|
|
// out of bounds
|
41 |
|
|
trks_pt (cms2.trks_trk_p4().at(0).pt()),
|
42 |
|
|
trks_eta(cms2.trks_trk_p4().at(0).eta()),
|
43 |
|
|
trks_phi(cms2.trks_trk_p4().at(0).phi()) { }
|
44 |
|
|
|
45 |
|
|
DorkyEventIdentifier::DorkyEventIdentifier (unsigned long int r, unsigned long int e, unsigned long int l)
|
46 |
|
|
: run(r),
|
47 |
|
|
event(e),
|
48 |
|
|
lumi_section(l),
|
49 |
|
|
trks_d0(0),
|
50 |
|
|
trks_pt (0),
|
51 |
|
|
trks_eta(0),
|
52 |
|
|
trks_phi(0) { }
|
53 |
|
|
|
54 |
|
|
bool DorkyEventIdentifier::operator < (const DorkyEventIdentifier &other) const
|
55 |
|
|
{
|
56 |
|
|
if (run != other.run)
|
57 |
|
|
return run < other.run;
|
58 |
|
|
if (event != other.event)
|
59 |
|
|
return event < other.event;
|
60 |
|
|
if (lumi_section != other.lumi_section)
|
61 |
|
|
return lumi_section < other.lumi_section;
|
62 |
|
|
if (TMath::Abs(trks_d0 - other.trks_d0) > 1e-6 * fabs(trks_d0))
|
63 |
|
|
return trks_d0 < other.trks_d0;
|
64 |
|
|
if (TMath::Abs(trks_pt - other.trks_pt) > 1e-6 * fabs(trks_pt))
|
65 |
|
|
return trks_pt < other.trks_pt;
|
66 |
|
|
if (TMath::Abs(trks_eta - other.trks_eta) > 1e-6 * fabs(trks_eta))
|
67 |
|
|
return trks_eta < other.trks_eta;
|
68 |
|
|
if (TMath::Abs(trks_phi - other.trks_phi) > 1e-6 * fabs(trks_phi))
|
69 |
|
|
return trks_phi < other.trks_phi;
|
70 |
|
|
return false;
|
71 |
|
|
}
|
72 |
|
|
|
73 |
|
|
bool DorkyEventIdentifier::operator == (const DorkyEventIdentifier &other) const
|
74 |
|
|
{
|
75 |
|
|
if (run != other.run)
|
76 |
|
|
return false;
|
77 |
|
|
if (event != other.event)
|
78 |
|
|
return false;
|
79 |
|
|
if (lumi_section != other.lumi_section)
|
80 |
|
|
return false;
|
81 |
|
|
if (TMath::Abs(trks_d0 - other.trks_d0) > 1e-6 * fabs(trks_d0))
|
82 |
|
|
return false;
|
83 |
|
|
if (TMath::Abs(trks_pt - other.trks_pt) > 1e-6 * fabs(trks_pt))
|
84 |
|
|
return false;
|
85 |
|
|
if (TMath::Abs(trks_eta - other.trks_eta) > 1e-6 * fabs(trks_eta))
|
86 |
|
|
return false;
|
87 |
|
|
if (TMath::Abs(trks_phi - other.trks_phi) > 1e-6 * fabs(trks_phi))
|
88 |
|
|
return false;
|
89 |
|
|
return true;
|
90 |
|
|
}
|
91 |
|
|
|
92 |
|
|
std::set<DorkyEventIdentifier> already_seen;
|
93 |
|
|
|
94 |
|
|
bool is_duplicate (const DorkyEventIdentifier &id)
|
95 |
|
|
{
|
96 |
|
|
std::pair<std::set<DorkyEventIdentifier>::const_iterator, bool> ret =
|
97 |
|
|
already_seen.insert(id);
|
98 |
|
|
return !ret.second;
|
99 |
|
|
}
|
100 |
|
|
|
101 |
|
|
// save histograms to outfile
|
102 |
|
|
void saveHist(const char* filename, const char* pat)
|
103 |
|
|
{
|
104 |
|
|
TList* list = histo_directory->GetList() ;
|
105 |
|
|
TIterator* iter = list->MakeIterator();
|
106 |
|
|
|
107 |
|
|
//TRegexp re(pat,kTRUE) ;
|
108 |
|
|
|
109 |
|
|
TRegexp re(pat, 1) ;
|
110 |
|
|
|
111 |
|
|
TFile outf(filename,"RECREATE") ;
|
112 |
|
|
while(TObject *obj=iter->Next()) {
|
113 |
|
|
if (TString(obj->GetName()).Index(re)>=0) {
|
114 |
|
|
obj->Write() ;
|
115 |
|
|
cout << "." ;
|
116 |
|
|
cout.flush() ;
|
117 |
|
|
}
|
118 |
|
|
}
|
119 |
|
|
cout << endl ;
|
120 |
|
|
outf.Close() ;
|
121 |
|
|
|
122 |
|
|
delete iter ;
|
123 |
|
|
}
|
124 |
|
|
|