ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitAna/PhysicsMod/src/ZXEvtSelMod.cc
Revision: 1.2
Committed: Thu Oct 9 18:10:23 2008 UTC (16 years, 7 months ago) by ceballos
Content type: text/plain
Branch: MAIN
Changes since 1.1: +21 -1 lines
Log Message:
Fixing memory leaks here and there

File Contents

# User Rev Content
1 ceballos 1.2 // $Id: ZXEvtSelMod.cc,v 1.1 2008/10/06 16:59:48 ceballos Exp $
2 ceballos 1.1
3     #include "MitAna/PhysicsMod/interface/ZXEvtSelMod.h"
4     #include <TH1D.h>
5     #include <TH2D.h>
6     #include "MitAna/DataTree/interface/Names.h"
7     #include "MitAna/DataCont/interface/ObjArray.h"
8     #include "MitCommon/MathTools/interface/MathUtils.h"
9    
10     using namespace mithep;
11     ClassImp(mithep::ZXEvtSelMod)
12    
13     //-----------------------------------------------------------------------------
14     ZXEvtSelMod::ZXEvtSelMod(const char *name, const char *title) :
15     BaseMod(name,title),
16     fPrintDebug(false),
17     fMetName(Names::gkCaloMetBrn),
18     fCleanJetsName(Names::gkCleanJetsName),
19     fMCLeptonsName(Names::gkMCLeptonsName),
20     fMet(0),
21     fNEventsProcessed(0)
22     {
23     // Constructor.
24     }
25    
26     //-----------------------------------------------------------------------------
27     void ZXEvtSelMod::Begin()
28     {
29     // Run startup code on the client machine. For this module, we dont do
30     // anything here.
31     }
32    
33     //-----------------------------------------------------------------------------
34     void ZXEvtSelMod::Process()
35     {
36     // Process entries of the tree. For this module, we just load the branches and
37     fNEventsProcessed++;
38    
39     if (fNEventsProcessed % 1000 == 0 || fPrintDebug) {
40     time_t systime;
41     systime = time(NULL);
42     cerr << endl << "ZXEvtSelMod : Process Event " << fNEventsProcessed
43     << " Time: " << ctime(&systime) << endl;
44     }
45    
46     //Get Generator Level information for matching
47     //ObjArray<MCParticle> *GenLeptons = dynamic_cast<ObjArray<MCParticle>* > (FindObjThisEvt(fMCLeptonsName.Data()));
48    
49     //Obtain all the good objects from the event cleaning module
50     ObjArray<Electron> *CleanElectrons = dynamic_cast<ObjArray<Electron>* >
51     (FindObjThisEvt(Names::gkCleanElectronsName));
52     ObjArray<Muon> *CleanMuons = dynamic_cast<ObjArray<Muon>* >
53     (FindObjThisEvt(Names::gkCleanMuonsName));
54     ObjArray<Jet> *CleanJets = dynamic_cast<ObjArray<Jet>* >
55     (FindObjThisEvt(fCleanJetsName.Data()));
56    
57     LoadBranch(fMetName);
58     Met *caloMet = fMet->At(0);
59    
60     vector<ChargedParticle*> leptonsMu;
61     vector<ChargedParticle*> leptonsEl;
62     vector<ChargedParticle*> leptonsAll;
63    
64     // Make lepton vector from muons and electrons
65     for (UInt_t j=0; j<CleanMuons->GetEntries(); j++) {
66     leptonsMu.push_back(CleanMuons->At(j));
67     leptonsAll.push_back(CleanMuons->At(j));
68     }
69     for (UInt_t j=0; j<CleanElectrons->GetEntries(); j++) {
70     leptonsEl.push_back(CleanElectrons->At(j));
71     leptonsAll.push_back(CleanElectrons->At(j));
72     }
73    
74     // Sort the Muons by Pt
75     for(UInt_t i=0; i<leptonsMu.size(); i++){
76     for(UInt_t j=i+1; j<leptonsMu.size(); j++){
77     if(leptonsMu[i]->Pt() < leptonsMu[j]->Pt()) {
78     //swap i and j
79     ChargedParticle* templepton = leptonsMu[i];
80     leptonsMu[i] = leptonsMu[j];
81     leptonsMu[j] = templepton;
82     }
83     }
84     }
85     // Sort the Electrons by Pt
86     for(UInt_t i=0; i<leptonsEl.size(); i++){
87     for(UInt_t j=i+1; j<leptonsEl.size(); j++){
88     if(leptonsEl[i]->Pt() < leptonsEl[j]->Pt()) {
89     //swap i and j
90     ChargedParticle* templepton = leptonsEl[i];
91     leptonsEl[i] = leptonsEl[j];
92     leptonsEl[j] = templepton;
93     }
94     }
95     }
96     // Sort the Leptons by Pt
97     for(UInt_t i=0; i<leptonsAll.size(); i++){
98     for(UInt_t j=i+1; j<leptonsAll.size(); j++){
99     if(leptonsAll[i]->Pt() < leptonsAll[j]->Pt()) {
100     //swap i and j
101     ChargedParticle* templepton = leptonsAll[i];
102     leptonsAll[i] = leptonsAll[j];
103     leptonsAll[j] = templepton;
104     }
105     }
106     }
107     hDZXSel[0]->Fill((double)leptonsAll.size());
108    
109     if(CleanMuons->GetEntries()+CleanElectrons->GetEntries() < 3) return;
110    
111     // The selection of the correct pair is ugly, but you know, life is tough
112    
113     // WZ analysis
114     if(leptonsMu.size()+leptonsEl.size() == 3){
115     int nWZType = -1;
116     vector<ChargedParticle*> leptonsWZ;
117     if (leptonsMu.size() == 2){
118     leptonsWZ.push_back(leptonsMu[0]);
119     leptonsWZ.push_back(leptonsMu[1]);
120     leptonsWZ.push_back(leptonsEl[0]);
121     nWZType = 0;
122     if(leptonsWZ[0]->Charge() == leptonsWZ[1]->Charge()) nWZType = 4;
123     }
124     else if(leptonsEl.size() == 2){
125     leptonsWZ.push_back(leptonsEl[0]);
126     leptonsWZ.push_back(leptonsEl[1]);
127     leptonsWZ.push_back(leptonsMu[0]);
128     nWZType = 1;
129     if(leptonsWZ[0]->Charge() == leptonsWZ[1]->Charge()) nWZType = 5;
130     }
131     else if(leptonsMu.size() == 3){
132     if(fabs(leptonsMu[0]->Charge()+leptonsMu[1]->Charge()+
133     leptonsMu[2]->Charge())==1){
134     nWZType = 2;
135     if (leptonsMu[0]->Charge() != leptonsMu[1]->Charge() &&
136     leptonsMu[0]->Charge() != leptonsMu[2]->Charge()){
137     CompositeParticle *dileptonA = new CompositeParticle();
138     dileptonA->AddDaughter(leptonsMu[0]);
139     dileptonA->AddDaughter(leptonsMu[1]);
140     CompositeParticle *dileptonB = new CompositeParticle();
141     dileptonB->AddDaughter(leptonsMu[0]);
142     dileptonB->AddDaughter(leptonsMu[2]);
143     if(fabs(dileptonA->Mass()-91.1876) < fabs(dileptonB->Mass()-91.1876)){
144     leptonsWZ.push_back(leptonsMu[0]);
145     leptonsWZ.push_back(leptonsMu[1]);
146     leptonsWZ.push_back(leptonsMu[2]);
147     }
148     else {
149     leptonsWZ.push_back(leptonsMu[0]);
150     leptonsWZ.push_back(leptonsMu[2]);
151     leptonsWZ.push_back(leptonsMu[1]);
152     }
153 ceballos 1.2 delete dileptonA;
154     delete dileptonB;
155 ceballos 1.1 }
156     else if(leptonsMu[1]->Charge() != leptonsMu[0]->Charge() &&
157     leptonsMu[1]->Charge() != leptonsMu[2]->Charge()){
158     CompositeParticle *dileptonA = new CompositeParticle();
159     dileptonA->AddDaughter(leptonsMu[1]);
160     dileptonA->AddDaughter(leptonsMu[0]);
161     CompositeParticle *dileptonB = new CompositeParticle();
162     dileptonB->AddDaughter(leptonsMu[1]);
163     dileptonB->AddDaughter(leptonsMu[2]);
164     if(fabs(dileptonA->Mass()-91.1876) < fabs(dileptonB->Mass()-91.1876)){
165     leptonsWZ.push_back(leptonsMu[0]);
166     leptonsWZ.push_back(leptonsMu[1]);
167     leptonsWZ.push_back(leptonsMu[2]);
168     }
169     else {
170     leptonsWZ.push_back(leptonsMu[1]);
171     leptonsWZ.push_back(leptonsMu[2]);
172     leptonsWZ.push_back(leptonsMu[0]);
173     }
174 ceballos 1.2 delete dileptonA;
175     delete dileptonB;
176 ceballos 1.1 }
177     else if(leptonsMu[2]->Charge() != leptonsMu[0]->Charge() &&
178     leptonsMu[2]->Charge() != leptonsMu[1]->Charge()){
179     CompositeParticle *dileptonA = new CompositeParticle();
180     dileptonA->AddDaughter(leptonsMu[2]);
181     dileptonA->AddDaughter(leptonsMu[0]);
182     CompositeParticle *dileptonB = new CompositeParticle();
183     dileptonB->AddDaughter(leptonsMu[2]);
184     dileptonB->AddDaughter(leptonsMu[1]);
185     if(fabs(dileptonA->Mass()-91.1876) < fabs(dileptonB->Mass()-91.1876)){
186     leptonsWZ.push_back(leptonsMu[0]);
187     leptonsWZ.push_back(leptonsMu[2]);
188     leptonsWZ.push_back(leptonsMu[1]);
189     }
190     else {
191     leptonsWZ.push_back(leptonsMu[1]);
192     leptonsWZ.push_back(leptonsMu[2]);
193     leptonsWZ.push_back(leptonsMu[0]);
194     }
195 ceballos 1.2 delete dileptonA;
196     delete dileptonB;
197 ceballos 1.1 }
198     else {
199     printf("Impossible in nWZType = 2\n");
200     }
201     }
202     else {
203     nWZType = 6;
204     }
205     }
206     else if(leptonsEl.size() == 3){
207     if(fabs(leptonsEl[0]->Charge()+leptonsEl[1]->Charge()+
208     leptonsEl[2]->Charge())==1){
209     nWZType = 3;
210     if (leptonsEl[0]->Charge() != leptonsEl[1]->Charge() &&
211     leptonsEl[0]->Charge() != leptonsEl[2]->Charge()){
212     CompositeParticle *dileptonA = new CompositeParticle();
213     dileptonA->AddDaughter(leptonsEl[0]);
214     dileptonA->AddDaughter(leptonsEl[1]);
215     CompositeParticle *dileptonB = new CompositeParticle();
216     dileptonB->AddDaughter(leptonsEl[0]);
217     dileptonB->AddDaughter(leptonsEl[2]);
218     if(fabs(dileptonA->Mass()-91.1876) < fabs(dileptonB->Mass()-91.1876)){
219     leptonsWZ.push_back(leptonsEl[0]);
220     leptonsWZ.push_back(leptonsEl[1]);
221     leptonsWZ.push_back(leptonsEl[2]);
222     }
223     else {
224     leptonsWZ.push_back(leptonsEl[0]);
225     leptonsWZ.push_back(leptonsEl[2]);
226     leptonsWZ.push_back(leptonsEl[1]);
227     }
228 ceballos 1.2 delete dileptonA;
229     delete dileptonB;
230 ceballos 1.1 }
231     else if(leptonsEl[1]->Charge() != leptonsEl[0]->Charge() &&
232     leptonsEl[1]->Charge() != leptonsEl[2]->Charge()){
233     CompositeParticle *dileptonA = new CompositeParticle();
234     dileptonA->AddDaughter(leptonsEl[1]);
235     dileptonA->AddDaughter(leptonsEl[0]);
236     CompositeParticle *dileptonB = new CompositeParticle();
237     dileptonB->AddDaughter(leptonsEl[1]);
238     dileptonB->AddDaughter(leptonsEl[2]);
239     if(fabs(dileptonA->Mass()-91.1876) < fabs(dileptonB->Mass()-91.1876)){
240     leptonsWZ.push_back(leptonsEl[0]);
241     leptonsWZ.push_back(leptonsEl[1]);
242     leptonsWZ.push_back(leptonsEl[2]);
243     }
244     else {
245     leptonsWZ.push_back(leptonsEl[1]);
246     leptonsWZ.push_back(leptonsEl[2]);
247     leptonsWZ.push_back(leptonsEl[0]);
248     }
249 ceballos 1.2 delete dileptonA;
250     delete dileptonB;
251 ceballos 1.1 }
252     else if(leptonsEl[2]->Charge() != leptonsEl[0]->Charge() &&
253     leptonsEl[2]->Charge() != leptonsEl[1]->Charge()){
254     CompositeParticle *dileptonA = new CompositeParticle();
255     dileptonA->AddDaughter(leptonsEl[2]);
256     dileptonA->AddDaughter(leptonsEl[0]);
257     CompositeParticle *dileptonB = new CompositeParticle();
258     dileptonB->AddDaughter(leptonsEl[2]);
259     dileptonB->AddDaughter(leptonsEl[1]);
260     if(fabs(dileptonA->Mass()-91.1876) < fabs(dileptonB->Mass()-91.1876)){
261     leptonsWZ.push_back(leptonsEl[0]);
262     leptonsWZ.push_back(leptonsEl[2]);
263     leptonsWZ.push_back(leptonsEl[1]);
264     }
265     else {
266     leptonsWZ.push_back(leptonsEl[1]);
267     leptonsWZ.push_back(leptonsEl[2]);
268     leptonsWZ.push_back(leptonsEl[0]);
269     }
270 ceballos 1.2 delete dileptonA;
271     delete dileptonB;
272 ceballos 1.1 }
273     else {
274     printf("Impossible in nWZType = 3\n");
275     }
276     }
277     else {
278     nWZType = 7;
279     }
280     }
281    
282     // Start analysis after selecting WZ -> l0 l1 l2
283     hDWZSel[90]->Fill((double) nWZType);
284    
285     // Charge of the leptons should be opposite
286     if (nWZType < 4){
287     CompositeParticle *dilepton = new CompositeParticle();
288     dilepton->AddDaughter(leptonsWZ[0]);
289     dilepton->AddDaughter(leptonsWZ[1]);
290    
291     if(dilepton->Charge() != 0)
292     printf("Impossible, nchaZ != 0, nWZType ===> %d\n",nWZType);
293    
294     // Sort and count the number of central Jets for vetoing
295     vector<Jet*> sortedJets;
296     for(UInt_t i=0; i<CleanJets->GetEntries(); i++){
297     if(fabs(CleanJets->At(i)->Eta()) < 2.5){
298     Jet* jet_f = new Jet(CleanJets->At(i)->Px()*CleanJets->At(i)->L2RelativeCorrectionScale()*CleanJets->At(i)->L3AbsoluteCorrectionScale(),
299     CleanJets->At(i)->Py()*CleanJets->At(i)->L2RelativeCorrectionScale()*CleanJets->At(i)->L3AbsoluteCorrectionScale(),
300     CleanJets->At(i)->Pz()*CleanJets->At(i)->L2RelativeCorrectionScale()*CleanJets->At(i)->L3AbsoluteCorrectionScale(),
301     CleanJets->At(i)->E() *CleanJets->At(i)->L2RelativeCorrectionScale()*CleanJets->At(i)->L3AbsoluteCorrectionScale());
302     sortedJets.push_back(jet_f);
303     }
304     }
305     for(UInt_t i=0; i<sortedJets.size(); i++){
306     for(UInt_t j=i+1; j<sortedJets.size(); j++){
307     if(sortedJets[i]->Pt() < sortedJets[j]->Pt()) {
308     //swap i and j
309     Jet* tempjet = sortedJets[i];
310     sortedJets[i] = sortedJets[j];
311     sortedJets[j] = tempjet;
312     }
313     }
314     }
315     double deltaRJetl = 999.;
316     double deltaRJetMet = 999.;
317     if(sortedJets.size() > 0){
318     for(int i=0; i<3; i++){
319     if(MathUtils::DeltaR(leptonsWZ[i]->Phi(), leptonsWZ[i]->Eta(),
320     sortedJets[0]->Phi(), sortedJets[0]->Eta()) < deltaRJetl)
321     deltaRJetl = MathUtils::DeltaR(leptonsWZ[i]->Phi(), leptonsWZ[i]->Eta(),
322     sortedJets[0]->Phi(), sortedJets[0]->Eta());
323     }
324     deltaRJetMet = MathUtils::DeltaPhi(caloMet->Phi(), sortedJets[0]->Phi());
325     }
326     double deltaPhiln = MathUtils::DeltaPhi(leptonsWZ[2]->Phi(), caloMet->Phi());
327     double mTW = TMath::Sqrt(2.0*leptonsWZ[2]->Pt()*caloMet->Pt()*
328     (1.0 - cos(deltaPhiln)));
329     double deltaRWl[2] = {MathUtils::DeltaR(leptonsWZ[0]->Phi(), leptonsWZ[0]->Eta(),
330     leptonsWZ[2]->Phi(), leptonsWZ[2]->Eta()),
331     MathUtils::DeltaR(leptonsWZ[1]->Phi(), leptonsWZ[1]->Eta(),
332     leptonsWZ[2]->Phi(), leptonsWZ[2]->Eta())}; ;
333     hDWZSel[ 0+100*nWZType]->Fill(TMath::Min(caloMet->Pt(),199.999));
334     hDWZSel[ 1+100*nWZType]->Fill(TMath::Min(leptonsWZ[0]->Pt(),199.999));
335     hDWZSel[ 2+100*nWZType]->Fill(TMath::Min(leptonsWZ[1]->Pt(),199.999));
336     hDWZSel[ 3+100*nWZType]->Fill(TMath::Min(leptonsWZ[2]->Pt(),199.999));
337     hDWZSel[ 4+100*nWZType]->Fill(TMath::Min(dilepton->Mass(),199.999));
338     hDWZSel[ 5+100*nWZType]->Fill((double)sortedJets.size());
339     hDWZSel[ 6+100*nWZType]->Fill(caloMet->MetSig());
340     hDWZSel[ 7+100*nWZType]->Fill(caloMet->SumEt());
341     hDWZSel[ 8+100*nWZType]->Fill(TMath::Min(mTW,199.999));
342     hDWZSel[ 9+100*nWZType]->Fill(deltaPhiln * 180./TMath::Pi());
343     hDWZSel[10+100*nWZType]->Fill(TMath::Min(deltaRWl[0],deltaRWl[1]));
344     hDWZSel[11+100*nWZType]->Fill(TMath::Max(deltaRWl[0],deltaRWl[1]));
345     hDWZSel[12+100*nWZType]->Fill(TMath::Min(caloMet->Pt()*deltaPhiln/4.,199.999));
346     if(sortedJets.size() > 0){
347     hDWZSel[13+100*nWZType]->Fill(TMath::Min(sortedJets[0]->Pt(),199.99));
348     hDWZSel[14+100*nWZType]->Fill(deltaRJetl);
349     hDWZSel[15+100*nWZType]->Fill(deltaRJetMet * 180./TMath::Pi());
350     }
351 ceballos 1.2 delete dilepton;
352 ceballos 1.1 } // Z Charge == 0
353     } // WZ Selection
354    
355     // ZZ analysis
356     if(leptonsMu.size()+leptonsEl.size() >= 4){
357     int nZZType = -3;
358     vector<ChargedParticle*> leptonsZZ;
359     if (leptonsMu.size() >= 2 && leptonsEl.size() >= 2){
360     nZZType = 0;
361     leptonsZZ.push_back(leptonsMu[0]);
362     leptonsZZ.push_back(leptonsMu[1]);
363     leptonsZZ.push_back(leptonsEl[0]);
364     leptonsZZ.push_back(leptonsEl[1]);
365     }
366     else if(leptonsMu.size() >= 4){
367     CompositeParticle *dileptonA = new CompositeParticle();
368     CompositeParticle *dileptonB = new CompositeParticle();
369     if (leptonsMu[0]->Charge() != leptonsMu[1]->Charge() &&
370     leptonsMu[0]->Charge() != leptonsMu[2]->Charge()){
371     nZZType = 1;
372     dileptonA->AddDaughter(leptonsMu[0]);
373     dileptonA->AddDaughter(leptonsMu[1]);
374     dileptonB->AddDaughter(leptonsMu[0]);
375     dileptonB->AddDaughter(leptonsMu[2]);
376 ceballos 1.2 delete dileptonA;
377     delete dileptonB;
378 ceballos 1.1 }
379     else if(leptonsMu[0]->Charge() != leptonsMu[1]->Charge() &&
380     leptonsMu[0]->Charge() != leptonsMu[3]->Charge()){
381     nZZType = 2;
382     dileptonA->AddDaughter(leptonsMu[0]);
383     dileptonA->AddDaughter(leptonsMu[1]);
384     dileptonB->AddDaughter(leptonsMu[0]);
385     dileptonB->AddDaughter(leptonsMu[3]);
386     }
387     else if(leptonsMu[0]->Charge() != leptonsMu[2]->Charge() &&
388     leptonsMu[0]->Charge() != leptonsMu[3]->Charge()){
389     nZZType = 3;
390     dileptonA->AddDaughter(leptonsMu[0]);
391     dileptonA->AddDaughter(leptonsMu[2]);
392     dileptonB->AddDaughter(leptonsMu[0]);
393     dileptonB->AddDaughter(leptonsMu[3]);
394     }
395     else {
396     nZZType = -1;
397     }
398     if (nZZType == 1 &&
399     fabs(dileptonA->Mass()-91.1876) <
400     fabs(dileptonB->Mass()-91.1876) ) {
401     leptonsZZ.push_back(leptonsMu[0]);
402     leptonsZZ.push_back(leptonsMu[1]);
403     leptonsZZ.push_back(leptonsMu[2]);
404     leptonsZZ.push_back(leptonsMu[3]);
405     }
406     else if(nZZType == 1) {
407     leptonsZZ.push_back(leptonsMu[0]);
408     leptonsZZ.push_back(leptonsMu[2]);
409     leptonsZZ.push_back(leptonsMu[1]);
410     leptonsZZ.push_back(leptonsMu[3]);
411     nZZType = 4;
412     }
413     else if(nZZType == 2 &&
414     fabs(dileptonA->Mass()-91.1876) <
415     fabs(dileptonB->Mass()-91.1876) ) {
416     leptonsZZ.push_back(leptonsMu[0]);
417     leptonsZZ.push_back(leptonsMu[1]);
418     leptonsZZ.push_back(leptonsMu[2]);
419     leptonsZZ.push_back(leptonsMu[3]);
420     }
421     else if(nZZType == 2) {
422     leptonsZZ.push_back(leptonsMu[0]);
423     leptonsZZ.push_back(leptonsMu[3]);
424     leptonsZZ.push_back(leptonsMu[1]);
425     leptonsZZ.push_back(leptonsMu[2]);
426     nZZType = 5;
427     }
428     else if(nZZType == 3 &&
429     fabs(dileptonA->Mass()-91.1876) <
430     fabs(dileptonB->Mass()-91.1876) ) {
431     leptonsZZ.push_back(leptonsMu[0]);
432     leptonsZZ.push_back(leptonsMu[2]);
433     leptonsZZ.push_back(leptonsMu[1]);
434     leptonsZZ.push_back(leptonsMu[3]);
435     }
436     else if(nZZType == 3) {
437     leptonsZZ.push_back(leptonsMu[0]);
438     leptonsZZ.push_back(leptonsMu[3]);
439     leptonsZZ.push_back(leptonsMu[1]);
440     leptonsZZ.push_back(leptonsMu[2]);
441     nZZType = 6;
442     }
443     }
444     else if(leptonsEl.size() >= 4){
445     CompositeParticle *dileptonA = new CompositeParticle();
446     CompositeParticle *dileptonB = new CompositeParticle();
447     if (leptonsEl[0]->Charge() != leptonsEl[1]->Charge() &&
448     leptonsEl[0]->Charge() != leptonsEl[2]->Charge()){
449     nZZType = 7;
450     dileptonA->AddDaughter(leptonsEl[0]);
451     dileptonA->AddDaughter(leptonsEl[1]);
452     dileptonB->AddDaughter(leptonsEl[0]);
453     dileptonB->AddDaughter(leptonsEl[2]);
454     }
455     else if(leptonsEl[0]->Charge() != leptonsEl[1]->Charge() &&
456     leptonsEl[0]->Charge() != leptonsEl[3]->Charge()){
457     nZZType = 8;
458     dileptonA->AddDaughter(leptonsEl[0]);
459     dileptonA->AddDaughter(leptonsEl[1]);
460     dileptonB->AddDaughter(leptonsEl[0]);
461     dileptonB->AddDaughter(leptonsEl[3]);
462     }
463     else if(leptonsEl[0]->Charge() != leptonsEl[2]->Charge() &&
464     leptonsEl[0]->Charge() != leptonsEl[3]->Charge()){
465     nZZType = 9;
466     dileptonA->AddDaughter(leptonsEl[0]);
467     dileptonA->AddDaughter(leptonsEl[2]);
468     dileptonB->AddDaughter(leptonsEl[0]);
469     dileptonB->AddDaughter(leptonsEl[3]);
470     }
471     else {
472     nZZType = -2;
473     }
474     if (nZZType == 7 &&
475     fabs(dileptonA->Mass()-91.1876) <
476     fabs(dileptonB->Mass()-91.1876) ) {
477     leptonsZZ.push_back(leptonsEl[0]);
478     leptonsZZ.push_back(leptonsEl[1]);
479     leptonsZZ.push_back(leptonsEl[2]);
480     leptonsZZ.push_back(leptonsEl[3]);
481     }
482     else if(nZZType == 7) {
483     leptonsZZ.push_back(leptonsEl[0]);
484     leptonsZZ.push_back(leptonsEl[2]);
485     leptonsZZ.push_back(leptonsEl[1]);
486     leptonsZZ.push_back(leptonsEl[3]);
487     nZZType = 10;
488     }
489     else if(nZZType == 8 &&
490     fabs(dileptonA->Mass()-91.1876) <
491     fabs(dileptonB->Mass()-91.1876) ) {
492     leptonsZZ.push_back(leptonsEl[0]);
493     leptonsZZ.push_back(leptonsEl[1]);
494     leptonsZZ.push_back(leptonsEl[2]);
495     leptonsZZ.push_back(leptonsEl[3]);
496     }
497     else if(nZZType == 8) {
498     leptonsZZ.push_back(leptonsEl[0]);
499     leptonsZZ.push_back(leptonsEl[3]);
500     leptonsZZ.push_back(leptonsEl[1]);
501     leptonsZZ.push_back(leptonsEl[2]);
502     nZZType = 11;
503     }
504     else if(nZZType == 9 &&
505     fabs(dileptonA->Mass()-91.1876) <
506     fabs(dileptonB->Mass()-91.1876) ) {
507     leptonsZZ.push_back(leptonsEl[0]);
508     leptonsZZ.push_back(leptonsEl[2]);
509     leptonsZZ.push_back(leptonsEl[1]);
510     leptonsZZ.push_back(leptonsEl[3]);
511     }
512     else if(nZZType == 9) {
513     leptonsZZ.push_back(leptonsEl[0]);
514     leptonsZZ.push_back(leptonsEl[3]);
515     leptonsZZ.push_back(leptonsEl[1]);
516     leptonsZZ.push_back(leptonsEl[2]);
517     nZZType = 12;
518     }
519 ceballos 1.2 delete dileptonA;
520     delete dileptonB;
521 ceballos 1.1 }
522     hDZZSel[90]->Fill((double)nZZType);
523     if(nZZType >= 0){
524     CompositeParticle *dileptonZ1 = new CompositeParticle();
525     dileptonZ1->AddDaughter(leptonsZZ[0]);
526     dileptonZ1->AddDaughter(leptonsZZ[1]);
527     CompositeParticle *dileptonZ2 = new CompositeParticle();
528     dileptonZ2->AddDaughter(leptonsZZ[2]);
529     dileptonZ2->AddDaughter(leptonsZZ[3]);
530     hDZZSel[91]->Fill((double)(dileptonZ1->Charge()+dileptonZ2->Charge()));
531    
532     CompositeParticle *particleH = new CompositeParticle();
533     particleH->AddDaughter(leptonsZZ[0]);
534     particleH->AddDaughter(leptonsZZ[1]);
535     particleH->AddDaughter(leptonsZZ[2]);
536     particleH->AddDaughter(leptonsZZ[3]);
537    
538     int simpleZZType = 0;
539     if (nZZType >= 1 && nZZType <= 6) simpleZZType = 1;
540     else if(nZZType >= 7 && nZZType <= 12) simpleZZType = 2;
541    
542     hDZZSel[ 0+100*simpleZZType]->Fill(TMath::Min(leptonsAll[0]->Pt(),199.999));
543     hDZZSel[ 1+100*simpleZZType]->Fill(TMath::Min(leptonsAll[1]->Pt(),199.999));
544     hDZZSel[ 2+100*simpleZZType]->Fill(TMath::Min(leptonsAll[2]->Pt(),199.999));
545     hDZZSel[ 3+100*simpleZZType]->Fill(TMath::Min(leptonsAll[3]->Pt(),199.999));
546     if(fabs(dileptonZ1->Mass()-91.1876) < fabs(dileptonZ2->Mass()-91.1876)){
547     hDZZSel[ 4+100*simpleZZType]->Fill(TMath::Min(dileptonZ1->Mass(),199.99));
548     hDZZSel[ 5+100*simpleZZType]->Fill(TMath::Min(dileptonZ2->Mass(),199.99));
549     }
550     else {
551     hDZZSel[ 4+100*simpleZZType]->Fill(TMath::Min(dileptonZ2->Mass(),199.99));
552     hDZZSel[ 5+100*simpleZZType]->Fill(TMath::Min(dileptonZ1->Mass(),199.99));
553     }
554     hDZZSel[ 6+100*simpleZZType]->Fill(TMath::Min(particleH->Mass(),599.99));
555 ceballos 1.2 delete dileptonZ1;
556     delete dileptonZ2;
557     delete particleH;
558 ceballos 1.1 } // nZZType >= 0
559     } // ZZ analysis
560     }
561     //--------------------------------------------------------------------------------------------------
562     void ZXEvtSelMod::SlaveBegin()
563     {
564     // Run startup code on the computer (slave) doing the actual analysis. Here,
565     // we typically initialize histograms and other analysis objects and request
566     // branches. For this module, we request a branch of the MitTree.
567    
568     ReqBranch(fMetName, fMet);
569    
570     char sb[200];
571     sprintf(sb,"hDZXSel_0"); hDZXSel[0] = new TH1D(sb,sb,10,-0.5,9.5);
572     AddOutput(hDZXSel[0]);
573    
574     // WZ histograms
575     for(int j=0; j<4; j++){
576     int ind = 100 * j;
577     sprintf(sb,"hDWZSel_%d",ind+0); hDWZSel[ind+0] = new TH1D(sb,sb,100,0.0,200.);
578     sprintf(sb,"hDWZSel_%d",ind+1); hDWZSel[ind+1] = new TH1D(sb,sb,100,0.0,200.);
579     sprintf(sb,"hDWZSel_%d",ind+2); hDWZSel[ind+2] = new TH1D(sb,sb,100,0.0,200.);
580     sprintf(sb,"hDWZSel_%d",ind+3); hDWZSel[ind+3] = new TH1D(sb,sb,100,0.0,200.);
581     sprintf(sb,"hDWZSel_%d",ind+4); hDWZSel[ind+4] = new TH1D(sb,sb,100,0.0,200.);
582     sprintf(sb,"hDWZSel_%d",ind+5); hDWZSel[ind+5] = new TH1D(sb,sb,10,-0.5,9.5);
583     sprintf(sb,"hDWZSel_%d",ind+6); hDWZSel[ind+6] = new TH1D(sb,sb,100,0.0,20.);
584     sprintf(sb,"hDWZSel_%d",ind+7); hDWZSel[ind+7] = new TH1D(sb,sb,200,0.0,800.);
585     sprintf(sb,"hDWZSel_%d",ind+8); hDWZSel[ind+8] = new TH1D(sb,sb,100,0.0,200.);
586     sprintf(sb,"hDWZSel_%d",ind+9); hDWZSel[ind+9] = new TH1D(sb,sb,90,0.0,180.);
587     sprintf(sb,"hDWZSel_%d",ind+10); hDWZSel[ind+10] = new TH1D(sb,sb,100,0.0,5.);
588     sprintf(sb,"hDWZSel_%d",ind+11); hDWZSel[ind+11] = new TH1D(sb,sb,100,0.0,5.);
589     sprintf(sb,"hDWZSel_%d",ind+12); hDWZSel[ind+12] = new TH1D(sb,sb,100,0.0,200.);
590     sprintf(sb,"hDWZSel_%d",ind+13); hDWZSel[ind+13] = new TH1D(sb,sb,100,0.0,200);
591     sprintf(sb,"hDWZSel_%d",ind+14); hDWZSel[ind+14] = new TH1D(sb,sb,100,0.0,5.);
592     sprintf(sb,"hDWZSel_%d",ind+15); hDWZSel[ind+15] = new TH1D(sb,sb,90,0.0,180.);
593     }
594    
595     for(int i=0; i<16; i++){
596     for(int j=0; j<4; j++){
597     AddOutput(hDWZSel[i+j*100]);
598     }
599     }
600    
601     sprintf(sb,"hDWZSel_90"); hDWZSel[90] = new TH1D(sb,sb,8,-0.5,7.5);
602     AddOutput(hDWZSel[90]);
603    
604     // ZZ histograms
605     for(int j=0; j<3; j++){
606     int ind = 100 * j;
607     sprintf(sb,"hDZZSel_%d",ind+0); hDZZSel[ind+0] = new TH1D(sb,sb,100,0.0,200.);
608     sprintf(sb,"hDZZSel_%d",ind+1); hDZZSel[ind+1] = new TH1D(sb,sb,100,0.0,200.);
609     sprintf(sb,"hDZZSel_%d",ind+2); hDZZSel[ind+2] = new TH1D(sb,sb,100,0.0,200.);
610     sprintf(sb,"hDZZSel_%d",ind+3); hDZZSel[ind+3] = new TH1D(sb,sb,100,0.0,200.);
611     sprintf(sb,"hDZZSel_%d",ind+4); hDZZSel[ind+4] = new TH1D(sb,sb,100,0.0,200.);
612     sprintf(sb,"hDZZSel_%d",ind+5); hDZZSel[ind+5] = new TH1D(sb,sb,100,0.0,200.);
613     sprintf(sb,"hDZZSel_%d",ind+6); hDZZSel[ind+6] = new TH1D(sb,sb,300,0.0,600.);
614     }
615    
616     for(int i=0; i<7; i++){
617     for(int j=0; j<3; j++){
618     AddOutput(hDZZSel[i+j*100]);
619     }
620     }
621    
622     sprintf(sb,"hDZZSel_90"); hDZZSel[90] = new TH1D(sb,sb,16,-3.5,12.5);
623     sprintf(sb,"hDZZSel_91"); hDZZSel[91] = new TH1D(sb,sb,9,-4.5,4.5);
624     AddOutput(hDZZSel[90]);
625     AddOutput(hDZZSel[91]);
626     }
627    
628     //--------------------------------------------------------------------------------------------------
629     void ZXEvtSelMod::SlaveTerminate()
630     {
631     // Run finishing code on the computer (slave) that did the analysis
632     }
633    
634     //--------------------------------------------------------------------------------------------------
635     void ZXEvtSelMod::Terminate()
636     {
637     // Run finishing code on the client computer
638     }