ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitAna/PhysicsMod/src/ZXEvtSelMod.cc
Revision: 1.3
Committed: Fri Oct 10 10:54:13 2008 UTC (16 years, 7 months ago) by ceballos
Content type: text/plain
Branch: MAIN
Changes since 1.2: +6 -1 lines
Log Message:
fixing small memory leaks

File Contents

# User Rev Content
1 ceballos 1.3 // $Id: ZXEvtSelMod.cc,v 1.2 2008/10/09 18:10:23 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.3 for(UInt_t i=0; i<sortedJets.size(); i++) delete sortedJets[i];
353 ceballos 1.1 } // Z Charge == 0
354     } // WZ Selection
355    
356     // ZZ analysis
357     if(leptonsMu.size()+leptonsEl.size() >= 4){
358     int nZZType = -3;
359     vector<ChargedParticle*> leptonsZZ;
360     if (leptonsMu.size() >= 2 && leptonsEl.size() >= 2){
361     nZZType = 0;
362     leptonsZZ.push_back(leptonsMu[0]);
363     leptonsZZ.push_back(leptonsMu[1]);
364     leptonsZZ.push_back(leptonsEl[0]);
365     leptonsZZ.push_back(leptonsEl[1]);
366     }
367     else if(leptonsMu.size() >= 4){
368     CompositeParticle *dileptonA = new CompositeParticle();
369     CompositeParticle *dileptonB = new CompositeParticle();
370     if (leptonsMu[0]->Charge() != leptonsMu[1]->Charge() &&
371     leptonsMu[0]->Charge() != leptonsMu[2]->Charge()){
372     nZZType = 1;
373     dileptonA->AddDaughter(leptonsMu[0]);
374     dileptonA->AddDaughter(leptonsMu[1]);
375     dileptonB->AddDaughter(leptonsMu[0]);
376     dileptonB->AddDaughter(leptonsMu[2]);
377 ceballos 1.2 delete dileptonA;
378     delete dileptonB;
379 ceballos 1.1 }
380     else if(leptonsMu[0]->Charge() != leptonsMu[1]->Charge() &&
381     leptonsMu[0]->Charge() != leptonsMu[3]->Charge()){
382     nZZType = 2;
383     dileptonA->AddDaughter(leptonsMu[0]);
384     dileptonA->AddDaughter(leptonsMu[1]);
385     dileptonB->AddDaughter(leptonsMu[0]);
386     dileptonB->AddDaughter(leptonsMu[3]);
387     }
388     else if(leptonsMu[0]->Charge() != leptonsMu[2]->Charge() &&
389     leptonsMu[0]->Charge() != leptonsMu[3]->Charge()){
390     nZZType = 3;
391     dileptonA->AddDaughter(leptonsMu[0]);
392     dileptonA->AddDaughter(leptonsMu[2]);
393     dileptonB->AddDaughter(leptonsMu[0]);
394     dileptonB->AddDaughter(leptonsMu[3]);
395     }
396     else {
397     nZZType = -1;
398     }
399     if (nZZType == 1 &&
400     fabs(dileptonA->Mass()-91.1876) <
401     fabs(dileptonB->Mass()-91.1876) ) {
402     leptonsZZ.push_back(leptonsMu[0]);
403     leptonsZZ.push_back(leptonsMu[1]);
404     leptonsZZ.push_back(leptonsMu[2]);
405     leptonsZZ.push_back(leptonsMu[3]);
406     }
407     else if(nZZType == 1) {
408     leptonsZZ.push_back(leptonsMu[0]);
409     leptonsZZ.push_back(leptonsMu[2]);
410     leptonsZZ.push_back(leptonsMu[1]);
411     leptonsZZ.push_back(leptonsMu[3]);
412     nZZType = 4;
413     }
414     else if(nZZType == 2 &&
415     fabs(dileptonA->Mass()-91.1876) <
416     fabs(dileptonB->Mass()-91.1876) ) {
417     leptonsZZ.push_back(leptonsMu[0]);
418     leptonsZZ.push_back(leptonsMu[1]);
419     leptonsZZ.push_back(leptonsMu[2]);
420     leptonsZZ.push_back(leptonsMu[3]);
421     }
422     else if(nZZType == 2) {
423     leptonsZZ.push_back(leptonsMu[0]);
424     leptonsZZ.push_back(leptonsMu[3]);
425     leptonsZZ.push_back(leptonsMu[1]);
426     leptonsZZ.push_back(leptonsMu[2]);
427     nZZType = 5;
428     }
429     else if(nZZType == 3 &&
430     fabs(dileptonA->Mass()-91.1876) <
431     fabs(dileptonB->Mass()-91.1876) ) {
432     leptonsZZ.push_back(leptonsMu[0]);
433     leptonsZZ.push_back(leptonsMu[2]);
434     leptonsZZ.push_back(leptonsMu[1]);
435     leptonsZZ.push_back(leptonsMu[3]);
436     }
437     else if(nZZType == 3) {
438     leptonsZZ.push_back(leptonsMu[0]);
439     leptonsZZ.push_back(leptonsMu[3]);
440     leptonsZZ.push_back(leptonsMu[1]);
441     leptonsZZ.push_back(leptonsMu[2]);
442     nZZType = 6;
443     }
444     }
445     else if(leptonsEl.size() >= 4){
446     CompositeParticle *dileptonA = new CompositeParticle();
447     CompositeParticle *dileptonB = new CompositeParticle();
448     if (leptonsEl[0]->Charge() != leptonsEl[1]->Charge() &&
449     leptonsEl[0]->Charge() != leptonsEl[2]->Charge()){
450     nZZType = 7;
451     dileptonA->AddDaughter(leptonsEl[0]);
452     dileptonA->AddDaughter(leptonsEl[1]);
453     dileptonB->AddDaughter(leptonsEl[0]);
454     dileptonB->AddDaughter(leptonsEl[2]);
455     }
456     else if(leptonsEl[0]->Charge() != leptonsEl[1]->Charge() &&
457     leptonsEl[0]->Charge() != leptonsEl[3]->Charge()){
458     nZZType = 8;
459     dileptonA->AddDaughter(leptonsEl[0]);
460     dileptonA->AddDaughter(leptonsEl[1]);
461     dileptonB->AddDaughter(leptonsEl[0]);
462     dileptonB->AddDaughter(leptonsEl[3]);
463     }
464     else if(leptonsEl[0]->Charge() != leptonsEl[2]->Charge() &&
465     leptonsEl[0]->Charge() != leptonsEl[3]->Charge()){
466     nZZType = 9;
467     dileptonA->AddDaughter(leptonsEl[0]);
468     dileptonA->AddDaughter(leptonsEl[2]);
469     dileptonB->AddDaughter(leptonsEl[0]);
470     dileptonB->AddDaughter(leptonsEl[3]);
471     }
472     else {
473     nZZType = -2;
474     }
475     if (nZZType == 7 &&
476     fabs(dileptonA->Mass()-91.1876) <
477     fabs(dileptonB->Mass()-91.1876) ) {
478     leptonsZZ.push_back(leptonsEl[0]);
479     leptonsZZ.push_back(leptonsEl[1]);
480     leptonsZZ.push_back(leptonsEl[2]);
481     leptonsZZ.push_back(leptonsEl[3]);
482     }
483     else if(nZZType == 7) {
484     leptonsZZ.push_back(leptonsEl[0]);
485     leptonsZZ.push_back(leptonsEl[2]);
486     leptonsZZ.push_back(leptonsEl[1]);
487     leptonsZZ.push_back(leptonsEl[3]);
488     nZZType = 10;
489     }
490     else if(nZZType == 8 &&
491     fabs(dileptonA->Mass()-91.1876) <
492     fabs(dileptonB->Mass()-91.1876) ) {
493     leptonsZZ.push_back(leptonsEl[0]);
494     leptonsZZ.push_back(leptonsEl[1]);
495     leptonsZZ.push_back(leptonsEl[2]);
496     leptonsZZ.push_back(leptonsEl[3]);
497     }
498     else if(nZZType == 8) {
499     leptonsZZ.push_back(leptonsEl[0]);
500     leptonsZZ.push_back(leptonsEl[3]);
501     leptonsZZ.push_back(leptonsEl[1]);
502     leptonsZZ.push_back(leptonsEl[2]);
503     nZZType = 11;
504     }
505     else if(nZZType == 9 &&
506     fabs(dileptonA->Mass()-91.1876) <
507     fabs(dileptonB->Mass()-91.1876) ) {
508     leptonsZZ.push_back(leptonsEl[0]);
509     leptonsZZ.push_back(leptonsEl[2]);
510     leptonsZZ.push_back(leptonsEl[1]);
511     leptonsZZ.push_back(leptonsEl[3]);
512     }
513     else if(nZZType == 9) {
514     leptonsZZ.push_back(leptonsEl[0]);
515     leptonsZZ.push_back(leptonsEl[3]);
516     leptonsZZ.push_back(leptonsEl[1]);
517     leptonsZZ.push_back(leptonsEl[2]);
518     nZZType = 12;
519     }
520 ceballos 1.2 delete dileptonA;
521     delete dileptonB;
522 ceballos 1.1 }
523     hDZZSel[90]->Fill((double)nZZType);
524     if(nZZType >= 0){
525     CompositeParticle *dileptonZ1 = new CompositeParticle();
526     dileptonZ1->AddDaughter(leptonsZZ[0]);
527     dileptonZ1->AddDaughter(leptonsZZ[1]);
528     CompositeParticle *dileptonZ2 = new CompositeParticle();
529     dileptonZ2->AddDaughter(leptonsZZ[2]);
530     dileptonZ2->AddDaughter(leptonsZZ[3]);
531     hDZZSel[91]->Fill((double)(dileptonZ1->Charge()+dileptonZ2->Charge()));
532    
533     CompositeParticle *particleH = new CompositeParticle();
534     particleH->AddDaughter(leptonsZZ[0]);
535     particleH->AddDaughter(leptonsZZ[1]);
536     particleH->AddDaughter(leptonsZZ[2]);
537     particleH->AddDaughter(leptonsZZ[3]);
538    
539     int simpleZZType = 0;
540     if (nZZType >= 1 && nZZType <= 6) simpleZZType = 1;
541     else if(nZZType >= 7 && nZZType <= 12) simpleZZType = 2;
542    
543     hDZZSel[ 0+100*simpleZZType]->Fill(TMath::Min(leptonsAll[0]->Pt(),199.999));
544     hDZZSel[ 1+100*simpleZZType]->Fill(TMath::Min(leptonsAll[1]->Pt(),199.999));
545     hDZZSel[ 2+100*simpleZZType]->Fill(TMath::Min(leptonsAll[2]->Pt(),199.999));
546     hDZZSel[ 3+100*simpleZZType]->Fill(TMath::Min(leptonsAll[3]->Pt(),199.999));
547     if(fabs(dileptonZ1->Mass()-91.1876) < fabs(dileptonZ2->Mass()-91.1876)){
548     hDZZSel[ 4+100*simpleZZType]->Fill(TMath::Min(dileptonZ1->Mass(),199.99));
549     hDZZSel[ 5+100*simpleZZType]->Fill(TMath::Min(dileptonZ2->Mass(),199.99));
550     }
551     else {
552     hDZZSel[ 4+100*simpleZZType]->Fill(TMath::Min(dileptonZ2->Mass(),199.99));
553     hDZZSel[ 5+100*simpleZZType]->Fill(TMath::Min(dileptonZ1->Mass(),199.99));
554     }
555     hDZZSel[ 6+100*simpleZZType]->Fill(TMath::Min(particleH->Mass(),599.99));
556 ceballos 1.2 delete dileptonZ1;
557     delete dileptonZ2;
558     delete particleH;
559 ceballos 1.1 } // nZZType >= 0
560     } // ZZ analysis
561 ceballos 1.3
562     leptonsMu.clear();
563     leptonsEl.clear();
564     leptonsAll.clear();
565 ceballos 1.1 }
566     //--------------------------------------------------------------------------------------------------
567     void ZXEvtSelMod::SlaveBegin()
568     {
569     // Run startup code on the computer (slave) doing the actual analysis. Here,
570     // we typically initialize histograms and other analysis objects and request
571     // branches. For this module, we request a branch of the MitTree.
572    
573     ReqBranch(fMetName, fMet);
574    
575     char sb[200];
576     sprintf(sb,"hDZXSel_0"); hDZXSel[0] = new TH1D(sb,sb,10,-0.5,9.5);
577     AddOutput(hDZXSel[0]);
578    
579     // WZ histograms
580     for(int j=0; j<4; j++){
581     int ind = 100 * j;
582     sprintf(sb,"hDWZSel_%d",ind+0); hDWZSel[ind+0] = new TH1D(sb,sb,100,0.0,200.);
583     sprintf(sb,"hDWZSel_%d",ind+1); hDWZSel[ind+1] = new TH1D(sb,sb,100,0.0,200.);
584     sprintf(sb,"hDWZSel_%d",ind+2); hDWZSel[ind+2] = new TH1D(sb,sb,100,0.0,200.);
585     sprintf(sb,"hDWZSel_%d",ind+3); hDWZSel[ind+3] = new TH1D(sb,sb,100,0.0,200.);
586     sprintf(sb,"hDWZSel_%d",ind+4); hDWZSel[ind+4] = new TH1D(sb,sb,100,0.0,200.);
587     sprintf(sb,"hDWZSel_%d",ind+5); hDWZSel[ind+5] = new TH1D(sb,sb,10,-0.5,9.5);
588     sprintf(sb,"hDWZSel_%d",ind+6); hDWZSel[ind+6] = new TH1D(sb,sb,100,0.0,20.);
589     sprintf(sb,"hDWZSel_%d",ind+7); hDWZSel[ind+7] = new TH1D(sb,sb,200,0.0,800.);
590     sprintf(sb,"hDWZSel_%d",ind+8); hDWZSel[ind+8] = new TH1D(sb,sb,100,0.0,200.);
591     sprintf(sb,"hDWZSel_%d",ind+9); hDWZSel[ind+9] = new TH1D(sb,sb,90,0.0,180.);
592     sprintf(sb,"hDWZSel_%d",ind+10); hDWZSel[ind+10] = new TH1D(sb,sb,100,0.0,5.);
593     sprintf(sb,"hDWZSel_%d",ind+11); hDWZSel[ind+11] = new TH1D(sb,sb,100,0.0,5.);
594     sprintf(sb,"hDWZSel_%d",ind+12); hDWZSel[ind+12] = new TH1D(sb,sb,100,0.0,200.);
595     sprintf(sb,"hDWZSel_%d",ind+13); hDWZSel[ind+13] = new TH1D(sb,sb,100,0.0,200);
596     sprintf(sb,"hDWZSel_%d",ind+14); hDWZSel[ind+14] = new TH1D(sb,sb,100,0.0,5.);
597     sprintf(sb,"hDWZSel_%d",ind+15); hDWZSel[ind+15] = new TH1D(sb,sb,90,0.0,180.);
598     }
599    
600     for(int i=0; i<16; i++){
601     for(int j=0; j<4; j++){
602     AddOutput(hDWZSel[i+j*100]);
603     }
604     }
605    
606     sprintf(sb,"hDWZSel_90"); hDWZSel[90] = new TH1D(sb,sb,8,-0.5,7.5);
607     AddOutput(hDWZSel[90]);
608    
609     // ZZ histograms
610     for(int j=0; j<3; j++){
611     int ind = 100 * j;
612     sprintf(sb,"hDZZSel_%d",ind+0); hDZZSel[ind+0] = new TH1D(sb,sb,100,0.0,200.);
613     sprintf(sb,"hDZZSel_%d",ind+1); hDZZSel[ind+1] = new TH1D(sb,sb,100,0.0,200.);
614     sprintf(sb,"hDZZSel_%d",ind+2); hDZZSel[ind+2] = new TH1D(sb,sb,100,0.0,200.);
615     sprintf(sb,"hDZZSel_%d",ind+3); hDZZSel[ind+3] = new TH1D(sb,sb,100,0.0,200.);
616     sprintf(sb,"hDZZSel_%d",ind+4); hDZZSel[ind+4] = new TH1D(sb,sb,100,0.0,200.);
617     sprintf(sb,"hDZZSel_%d",ind+5); hDZZSel[ind+5] = new TH1D(sb,sb,100,0.0,200.);
618     sprintf(sb,"hDZZSel_%d",ind+6); hDZZSel[ind+6] = new TH1D(sb,sb,300,0.0,600.);
619     }
620    
621     for(int i=0; i<7; i++){
622     for(int j=0; j<3; j++){
623     AddOutput(hDZZSel[i+j*100]);
624     }
625     }
626    
627     sprintf(sb,"hDZZSel_90"); hDZZSel[90] = new TH1D(sb,sb,16,-3.5,12.5);
628     sprintf(sb,"hDZZSel_91"); hDZZSel[91] = new TH1D(sb,sb,9,-4.5,4.5);
629     AddOutput(hDZZSel[90]);
630     AddOutput(hDZZSel[91]);
631     }
632    
633     //--------------------------------------------------------------------------------------------------
634     void ZXEvtSelMod::SlaveTerminate()
635     {
636     // Run finishing code on the computer (slave) that did the analysis
637     }
638    
639     //--------------------------------------------------------------------------------------------------
640     void ZXEvtSelMod::Terminate()
641     {
642     // Run finishing code on the client computer
643     }