SFS: cms_exo_19_010.h

File cms_exo_19_010.h, 4.4 KB (added by Benjamin Fuks, 3 years ago)
Line 
1#ifndef analysis_cms_exo_19_010_h
2#define analysis_cms_exo_19_010_h
3
4#include "SampleAnalyzer/Process/Analyzer/AnalyzerBase.h"
5
6//#include "new_smearer_reco.h"
7//#include "new_tagger.h"
8#include <random>
9namespace MA5
10{
11class cms_exo_19_010 : public AnalyzerBase
12{
13 INIT_ANALYSIS(cms_exo_19_010,"cms_exo_19_010")
14
15 public:
16 virtual bool Initialize(const MA5::Configuration& cfg, const std::map<std::string,std::string>& parameters);
17 virtual void Finalize(const SampleFormat& summary, const std::vector<SampleFormat>& files);
18 virtual bool Execute(SampleFormat& sample, const EventFormat& event);
19
20 private:
21 std::random_device m_randomdevice;
22 std::mt19937 engine;
23
24 std::map<std::string, double> lumiratios;
25 const std::vector<std::string> alldataperiods = {"2015", "2016A", "2016B", "2017", "2018A", "2018B"};
26};
27}
28
29template<typename T1, typename T2> std::vector<T1*>
30 FullRemoval(std::vector<T1*> &v1, const std::vector<T2> &v2,
31 const double &drmin)
32{
33 // Determining with objects should be removed, and free memory
34
35 std::vector<bool> mask(v1.size(),false);
36
37 for (unsigned int j=0;j<v1.size();j++)
38 {
39 for (unsigned int i=0; !mask[j] && i<v2.size();i++)
40 {
41 if (v2[i].momentum().DeltaR(v1[j]->momentum()) < drmin)
42 {
43 mask[j]=true;
44 //break;
45 }
46 }
47 };
48 // Building the cleaned container
49 std::vector<T1*> cleaned_v1;
50 for (unsigned int i=0;i<v1.size();i++)
51 {
52 if (!mask[i]) {
53 cleaned_v1.push_back(v1[i]);
54 }
55 else
56 {
57 delete v1[i];
58 }
59
60 }
61
62 return cleaned_v1;
63};
64
65
66
67template<typename T1, typename T2> std::vector<T1*>
68 FullRemoval(std::vector<T1*> &v1, std::vector<T2*> &v2,
69 const double &drmin)
70{
71 // Determining with objects should be removed, and free memory
72
73 std::vector<bool> mask(v1.size(),false);
74
75 for (unsigned int j=0;j<v1.size();j++)
76 {
77 for (unsigned int i=0; !mask[j] && i<v2.size();i++)
78 {
79 if (v2[i]->momentum().DeltaR(v1[j]->momentum()) < drmin)
80 {
81 mask[j]=true;
82 //break;
83 }
84 }
85 };
86 // Building the cleaned container
87 std::vector<T1*> cleaned_v1;
88 for (unsigned int i=0;i<v1.size();i++)
89 {
90 if (!mask[i]) {
91 cleaned_v1.push_back(v1[i]);
92 }
93 else
94 {
95 delete v1[i];
96 }
97
98 }
99
100 return cleaned_v1;
101};
102
103
104
105
106template<typename T1, typename T2> std::vector<T1*>
107 Removal(std::vector<T1*> &v1, std::vector<T2*> &v2,
108 const double &drmin)
109{
110 // Determining with objects should be removed
111
112 std::vector<bool> mask(v1.size(),false);
113
114 for (unsigned int j=0;j<v1.size();j++)
115 {
116 for (unsigned int i=0; !mask[j] && i<v2.size();i++)
117 {
118 if (v2[i]->momentum().deltaR(v1[j]->momentum()) < drmin)
119 {
120 mask[j]=true;
121 //break;
122 }
123 }
124 };
125 // Building the cleaned container
126 std::vector<T1*> cleaned_v1;
127 for (unsigned int i=0;i<v1.size();i++)
128 if (!mask[i]) cleaned_v1.push_back(v1[i]);
129
130 return cleaned_v1;
131};
132
133
134template<typename T1> std::vector<T1*> SelfRemoval(std::vector<T1*> &v1, const double &drmin)
135{
136 // Determining with objects should be removed -- keep the higher pT version. This only applies for electrons anyway
137
138 std::vector<bool> mask(v1.size(),false);
139
140 double tdr;
141 for (unsigned int j=0;j<v1.size();j++){
142 for (unsigned int i=j+1;i<v1.size();i++) {
143
144 tdr=v1[i]->momentum().DeltaR(v1[j]->momentum());
145 if ((tdr < drmin))
146 {
147 if(v1[i]->momentum().Pt() < v1[j]->momentum().Pt())
148 {
149 mask[i]=true;
150 }
151 else
152 {
153 mask[j]=true;
154 }
155 }
156
157 }
158 };
159
160
161 // Building the cleaned container
162 std::vector<T1*> cleaned_v1;
163 for (unsigned int i=0;i<v1.size();i++)
164 if (!mask[i]) cleaned_v1.push_back(v1[i]);
165
166 return cleaned_v1;
167};
168
169template<typename T1> void filterPhaseSpace(std::vector<T1*> &vec_t1, const double &pTmin, const double &absEtaMax)
170{
171 // filters the particles/jets in a vector by pT and eta.
172
173
174 auto it = vec_t1.begin();
175 while(it != vec_t1.end())
176 {
177 //T1* t1 = vec_t1[it];
178 //if( (t1->pT() > pTmin) || (t1->abseta() > absEtaMax))
179 if( ((*it)->pt() < pTmin ) || (fabs((*it)->eta()) > absEtaMax))
180 {
181 it = vec_t1.erase(it);
182 }
183 else
184 {
185 it++;
186 }
187
188 }
189
190}
191
192
193
194#endif