ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitAna/PhysicsMod/src/ZXEvtSelMod.cc
Revision: 1.1
Committed: Mon Oct 6 16:59:48 2008 UTC (16 years, 7 months ago) by ceballos
Content type: text/plain
Branch: MAIN
Log Message:
3 new analysis modules

File Contents

# User Rev Content
1 ceballos 1.1 // $Id: ZXEvtSelMod.cc,v 1.1 2008/09/30 19:24:22 ceballos Exp $
2    
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     }
154     else if(leptonsMu[1]->Charge() != leptonsMu[0]->Charge() &&
155     leptonsMu[1]->Charge() != leptonsMu[2]->Charge()){
156     CompositeParticle *dileptonA = new CompositeParticle();
157     dileptonA->AddDaughter(leptonsMu[1]);
158     dileptonA->AddDaughter(leptonsMu[0]);
159     CompositeParticle *dileptonB = new CompositeParticle();
160     dileptonB->AddDaughter(leptonsMu[1]);
161     dileptonB->AddDaughter(leptonsMu[2]);
162     if(fabs(dileptonA->Mass()-91.1876) < fabs(dileptonB->Mass()-91.1876)){
163     leptonsWZ.push_back(leptonsMu[0]);
164     leptonsWZ.push_back(leptonsMu[1]);
165     leptonsWZ.push_back(leptonsMu[2]);
166     }
167     else {
168     leptonsWZ.push_back(leptonsMu[1]);
169     leptonsWZ.push_back(leptonsMu[2]);
170     leptonsWZ.push_back(leptonsMu[0]);
171     }
172     }
173     else if(leptonsMu[2]->Charge() != leptonsMu[0]->Charge() &&
174     leptonsMu[2]->Charge() != leptonsMu[1]->Charge()){
175     CompositeParticle *dileptonA = new CompositeParticle();
176     dileptonA->AddDaughter(leptonsMu[2]);
177     dileptonA->AddDaughter(leptonsMu[0]);
178     CompositeParticle *dileptonB = new CompositeParticle();
179     dileptonB->AddDaughter(leptonsMu[2]);
180     dileptonB->AddDaughter(leptonsMu[1]);
181     if(fabs(dileptonA->Mass()-91.1876) < fabs(dileptonB->Mass()-91.1876)){
182     leptonsWZ.push_back(leptonsMu[0]);
183     leptonsWZ.push_back(leptonsMu[2]);
184     leptonsWZ.push_back(leptonsMu[1]);
185     }
186     else {
187     leptonsWZ.push_back(leptonsMu[1]);
188     leptonsWZ.push_back(leptonsMu[2]);
189     leptonsWZ.push_back(leptonsMu[0]);
190     }
191     }
192     else {
193     printf("Impossible in nWZType = 2\n");
194     }
195     }
196     else {
197     nWZType = 6;
198     }
199     }
200     else if(leptonsEl.size() == 3){
201     if(fabs(leptonsEl[0]->Charge()+leptonsEl[1]->Charge()+
202     leptonsEl[2]->Charge())==1){
203     nWZType = 3;
204     if (leptonsEl[0]->Charge() != leptonsEl[1]->Charge() &&
205     leptonsEl[0]->Charge() != leptonsEl[2]->Charge()){
206     CompositeParticle *dileptonA = new CompositeParticle();
207     dileptonA->AddDaughter(leptonsEl[0]);
208     dileptonA->AddDaughter(leptonsEl[1]);
209     CompositeParticle *dileptonB = new CompositeParticle();
210     dileptonB->AddDaughter(leptonsEl[0]);
211     dileptonB->AddDaughter(leptonsEl[2]);
212     if(fabs(dileptonA->Mass()-91.1876) < fabs(dileptonB->Mass()-91.1876)){
213     leptonsWZ.push_back(leptonsEl[0]);
214     leptonsWZ.push_back(leptonsEl[1]);
215     leptonsWZ.push_back(leptonsEl[2]);
216     }
217     else {
218     leptonsWZ.push_back(leptonsEl[0]);
219     leptonsWZ.push_back(leptonsEl[2]);
220     leptonsWZ.push_back(leptonsEl[1]);
221     }
222     }
223     else if(leptonsEl[1]->Charge() != leptonsEl[0]->Charge() &&
224     leptonsEl[1]->Charge() != leptonsEl[2]->Charge()){
225     CompositeParticle *dileptonA = new CompositeParticle();
226     dileptonA->AddDaughter(leptonsEl[1]);
227     dileptonA->AddDaughter(leptonsEl[0]);
228     CompositeParticle *dileptonB = new CompositeParticle();
229     dileptonB->AddDaughter(leptonsEl[1]);
230     dileptonB->AddDaughter(leptonsEl[2]);
231     if(fabs(dileptonA->Mass()-91.1876) < fabs(dileptonB->Mass()-91.1876)){
232     leptonsWZ.push_back(leptonsEl[0]);
233     leptonsWZ.push_back(leptonsEl[1]);
234     leptonsWZ.push_back(leptonsEl[2]);
235     }
236     else {
237     leptonsWZ.push_back(leptonsEl[1]);
238     leptonsWZ.push_back(leptonsEl[2]);
239     leptonsWZ.push_back(leptonsEl[0]);
240     }
241     }
242     else if(leptonsEl[2]->Charge() != leptonsEl[0]->Charge() &&
243     leptonsEl[2]->Charge() != leptonsEl[1]->Charge()){
244     CompositeParticle *dileptonA = new CompositeParticle();
245     dileptonA->AddDaughter(leptonsEl[2]);
246     dileptonA->AddDaughter(leptonsEl[0]);
247     CompositeParticle *dileptonB = new CompositeParticle();
248     dileptonB->AddDaughter(leptonsEl[2]);
249     dileptonB->AddDaughter(leptonsEl[1]);
250     if(fabs(dileptonA->Mass()-91.1876) < fabs(dileptonB->Mass()-91.1876)){
251     leptonsWZ.push_back(leptonsEl[0]);
252     leptonsWZ.push_back(leptonsEl[2]);
253     leptonsWZ.push_back(leptonsEl[1]);
254     }
255     else {
256     leptonsWZ.push_back(leptonsEl[1]);
257     leptonsWZ.push_back(leptonsEl[2]);
258     leptonsWZ.push_back(leptonsEl[0]);
259     }
260     }
261     else {
262     printf("Impossible in nWZType = 3\n");
263     }
264     }
265     else {
266     nWZType = 7;
267     }
268     }
269    
270     // Start analysis after selecting WZ -> l0 l1 l2
271     hDWZSel[90]->Fill((double) nWZType);
272    
273     // Charge of the leptons should be opposite
274     if (nWZType < 4){
275     CompositeParticle *dilepton = new CompositeParticle();
276     dilepton->AddDaughter(leptonsWZ[0]);
277     dilepton->AddDaughter(leptonsWZ[1]);
278    
279     if(dilepton->Charge() != 0)
280     printf("Impossible, nchaZ != 0, nWZType ===> %d\n",nWZType);
281    
282     // Sort and count the number of central Jets for vetoing
283     vector<Jet*> sortedJets;
284     for(UInt_t i=0; i<CleanJets->GetEntries(); i++){
285     if(fabs(CleanJets->At(i)->Eta()) < 2.5){
286     Jet* jet_f = new Jet(CleanJets->At(i)->Px()*CleanJets->At(i)->L2RelativeCorrectionScale()*CleanJets->At(i)->L3AbsoluteCorrectionScale(),
287     CleanJets->At(i)->Py()*CleanJets->At(i)->L2RelativeCorrectionScale()*CleanJets->At(i)->L3AbsoluteCorrectionScale(),
288     CleanJets->At(i)->Pz()*CleanJets->At(i)->L2RelativeCorrectionScale()*CleanJets->At(i)->L3AbsoluteCorrectionScale(),
289     CleanJets->At(i)->E() *CleanJets->At(i)->L2RelativeCorrectionScale()*CleanJets->At(i)->L3AbsoluteCorrectionScale());
290     sortedJets.push_back(jet_f);
291     }
292     }
293     for(UInt_t i=0; i<sortedJets.size(); i++){
294     for(UInt_t j=i+1; j<sortedJets.size(); j++){
295     if(sortedJets[i]->Pt() < sortedJets[j]->Pt()) {
296     //swap i and j
297     Jet* tempjet = sortedJets[i];
298     sortedJets[i] = sortedJets[j];
299     sortedJets[j] = tempjet;
300     }
301     }
302     }
303     double deltaRJetl = 999.;
304     double deltaRJetMet = 999.;
305     if(sortedJets.size() > 0){
306     for(int i=0; i<3; i++){
307     if(MathUtils::DeltaR(leptonsWZ[i]->Phi(), leptonsWZ[i]->Eta(),
308     sortedJets[0]->Phi(), sortedJets[0]->Eta()) < deltaRJetl)
309     deltaRJetl = MathUtils::DeltaR(leptonsWZ[i]->Phi(), leptonsWZ[i]->Eta(),
310     sortedJets[0]->Phi(), sortedJets[0]->Eta());
311     }
312     deltaRJetMet = MathUtils::DeltaPhi(caloMet->Phi(), sortedJets[0]->Phi());
313     }
314     double deltaPhiln = MathUtils::DeltaPhi(leptonsWZ[2]->Phi(), caloMet->Phi());
315     double mTW = TMath::Sqrt(2.0*leptonsWZ[2]->Pt()*caloMet->Pt()*
316     (1.0 - cos(deltaPhiln)));
317     double deltaRWl[2] = {MathUtils::DeltaR(leptonsWZ[0]->Phi(), leptonsWZ[0]->Eta(),
318     leptonsWZ[2]->Phi(), leptonsWZ[2]->Eta()),
319     MathUtils::DeltaR(leptonsWZ[1]->Phi(), leptonsWZ[1]->Eta(),
320     leptonsWZ[2]->Phi(), leptonsWZ[2]->Eta())}; ;
321     hDWZSel[ 0+100*nWZType]->Fill(TMath::Min(caloMet->Pt(),199.999));
322     hDWZSel[ 1+100*nWZType]->Fill(TMath::Min(leptonsWZ[0]->Pt(),199.999));
323     hDWZSel[ 2+100*nWZType]->Fill(TMath::Min(leptonsWZ[1]->Pt(),199.999));
324     hDWZSel[ 3+100*nWZType]->Fill(TMath::Min(leptonsWZ[2]->Pt(),199.999));
325     hDWZSel[ 4+100*nWZType]->Fill(TMath::Min(dilepton->Mass(),199.999));
326     hDWZSel[ 5+100*nWZType]->Fill((double)sortedJets.size());
327     hDWZSel[ 6+100*nWZType]->Fill(caloMet->MetSig());
328     hDWZSel[ 7+100*nWZType]->Fill(caloMet->SumEt());
329     hDWZSel[ 8+100*nWZType]->Fill(TMath::Min(mTW,199.999));
330     hDWZSel[ 9+100*nWZType]->Fill(deltaPhiln * 180./TMath::Pi());
331     hDWZSel[10+100*nWZType]->Fill(TMath::Min(deltaRWl[0],deltaRWl[1]));
332     hDWZSel[11+100*nWZType]->Fill(TMath::Max(deltaRWl[0],deltaRWl[1]));
333     hDWZSel[12+100*nWZType]->Fill(TMath::Min(caloMet->Pt()*deltaPhiln/4.,199.999));
334     if(sortedJets.size() > 0){
335     hDWZSel[13+100*nWZType]->Fill(TMath::Min(sortedJets[0]->Pt(),199.99));
336     hDWZSel[14+100*nWZType]->Fill(deltaRJetl);
337     hDWZSel[15+100*nWZType]->Fill(deltaRJetMet * 180./TMath::Pi());
338     }
339     } // Z Charge == 0
340     } // WZ Selection
341    
342     // ZZ analysis
343     if(leptonsMu.size()+leptonsEl.size() >= 4){
344     int nZZType = -3;
345     vector<ChargedParticle*> leptonsZZ;
346     if (leptonsMu.size() >= 2 && leptonsEl.size() >= 2){
347     nZZType = 0;
348     leptonsZZ.push_back(leptonsMu[0]);
349     leptonsZZ.push_back(leptonsMu[1]);
350     leptonsZZ.push_back(leptonsEl[0]);
351     leptonsZZ.push_back(leptonsEl[1]);
352     }
353     else if(leptonsMu.size() >= 4){
354     CompositeParticle *dileptonA = new CompositeParticle();
355     CompositeParticle *dileptonB = new CompositeParticle();
356     if (leptonsMu[0]->Charge() != leptonsMu[1]->Charge() &&
357     leptonsMu[0]->Charge() != leptonsMu[2]->Charge()){
358     nZZType = 1;
359     dileptonA->AddDaughter(leptonsMu[0]);
360     dileptonA->AddDaughter(leptonsMu[1]);
361     dileptonB->AddDaughter(leptonsMu[0]);
362     dileptonB->AddDaughter(leptonsMu[2]);
363     }
364     else if(leptonsMu[0]->Charge() != leptonsMu[1]->Charge() &&
365     leptonsMu[0]->Charge() != leptonsMu[3]->Charge()){
366     nZZType = 2;
367     dileptonA->AddDaughter(leptonsMu[0]);
368     dileptonA->AddDaughter(leptonsMu[1]);
369     dileptonB->AddDaughter(leptonsMu[0]);
370     dileptonB->AddDaughter(leptonsMu[3]);
371     }
372     else if(leptonsMu[0]->Charge() != leptonsMu[2]->Charge() &&
373     leptonsMu[0]->Charge() != leptonsMu[3]->Charge()){
374     nZZType = 3;
375     dileptonA->AddDaughter(leptonsMu[0]);
376     dileptonA->AddDaughter(leptonsMu[2]);
377     dileptonB->AddDaughter(leptonsMu[0]);
378     dileptonB->AddDaughter(leptonsMu[3]);
379     }
380     else {
381     nZZType = -1;
382     }
383     if (nZZType == 1 &&
384     fabs(dileptonA->Mass()-91.1876) <
385     fabs(dileptonB->Mass()-91.1876) ) {
386     leptonsZZ.push_back(leptonsMu[0]);
387     leptonsZZ.push_back(leptonsMu[1]);
388     leptonsZZ.push_back(leptonsMu[2]);
389     leptonsZZ.push_back(leptonsMu[3]);
390     }
391     else if(nZZType == 1) {
392     leptonsZZ.push_back(leptonsMu[0]);
393     leptonsZZ.push_back(leptonsMu[2]);
394     leptonsZZ.push_back(leptonsMu[1]);
395     leptonsZZ.push_back(leptonsMu[3]);
396     nZZType = 4;
397     }
398     else if(nZZType == 2 &&
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 == 2) {
407     leptonsZZ.push_back(leptonsMu[0]);
408     leptonsZZ.push_back(leptonsMu[3]);
409     leptonsZZ.push_back(leptonsMu[1]);
410     leptonsZZ.push_back(leptonsMu[2]);
411     nZZType = 5;
412     }
413     else if(nZZType == 3 &&
414     fabs(dileptonA->Mass()-91.1876) <
415     fabs(dileptonB->Mass()-91.1876) ) {
416     leptonsZZ.push_back(leptonsMu[0]);
417     leptonsZZ.push_back(leptonsMu[2]);
418     leptonsZZ.push_back(leptonsMu[1]);
419     leptonsZZ.push_back(leptonsMu[3]);
420     }
421     else if(nZZType == 3) {
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 = 6;
427     }
428     }
429     else if(leptonsEl.size() >= 4){
430     CompositeParticle *dileptonA = new CompositeParticle();
431     CompositeParticle *dileptonB = new CompositeParticle();
432     if (leptonsEl[0]->Charge() != leptonsEl[1]->Charge() &&
433     leptonsEl[0]->Charge() != leptonsEl[2]->Charge()){
434     nZZType = 7;
435     dileptonA->AddDaughter(leptonsEl[0]);
436     dileptonA->AddDaughter(leptonsEl[1]);
437     dileptonB->AddDaughter(leptonsEl[0]);
438     dileptonB->AddDaughter(leptonsEl[2]);
439     }
440     else if(leptonsEl[0]->Charge() != leptonsEl[1]->Charge() &&
441     leptonsEl[0]->Charge() != leptonsEl[3]->Charge()){
442     nZZType = 8;
443     dileptonA->AddDaughter(leptonsEl[0]);
444     dileptonA->AddDaughter(leptonsEl[1]);
445     dileptonB->AddDaughter(leptonsEl[0]);
446     dileptonB->AddDaughter(leptonsEl[3]);
447     }
448     else if(leptonsEl[0]->Charge() != leptonsEl[2]->Charge() &&
449     leptonsEl[0]->Charge() != leptonsEl[3]->Charge()){
450     nZZType = 9;
451     dileptonA->AddDaughter(leptonsEl[0]);
452     dileptonA->AddDaughter(leptonsEl[2]);
453     dileptonB->AddDaughter(leptonsEl[0]);
454     dileptonB->AddDaughter(leptonsEl[3]);
455     }
456     else {
457     nZZType = -2;
458     }
459     if (nZZType == 7 &&
460     fabs(dileptonA->Mass()-91.1876) <
461     fabs(dileptonB->Mass()-91.1876) ) {
462     leptonsZZ.push_back(leptonsEl[0]);
463     leptonsZZ.push_back(leptonsEl[1]);
464     leptonsZZ.push_back(leptonsEl[2]);
465     leptonsZZ.push_back(leptonsEl[3]);
466     }
467     else if(nZZType == 7) {
468     leptonsZZ.push_back(leptonsEl[0]);
469     leptonsZZ.push_back(leptonsEl[2]);
470     leptonsZZ.push_back(leptonsEl[1]);
471     leptonsZZ.push_back(leptonsEl[3]);
472     nZZType = 10;
473     }
474     else if(nZZType == 8 &&
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 == 8) {
483     leptonsZZ.push_back(leptonsEl[0]);
484     leptonsZZ.push_back(leptonsEl[3]);
485     leptonsZZ.push_back(leptonsEl[1]);
486     leptonsZZ.push_back(leptonsEl[2]);
487     nZZType = 11;
488     }
489     else if(nZZType == 9 &&
490     fabs(dileptonA->Mass()-91.1876) <
491     fabs(dileptonB->Mass()-91.1876) ) {
492     leptonsZZ.push_back(leptonsEl[0]);
493     leptonsZZ.push_back(leptonsEl[2]);
494     leptonsZZ.push_back(leptonsEl[1]);
495     leptonsZZ.push_back(leptonsEl[3]);
496     }
497     else if(nZZType == 9) {
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 = 12;
503     }
504     }
505     hDZZSel[90]->Fill((double)nZZType);
506     if(nZZType >= 0){
507     CompositeParticle *dileptonZ1 = new CompositeParticle();
508     dileptonZ1->AddDaughter(leptonsZZ[0]);
509     dileptonZ1->AddDaughter(leptonsZZ[1]);
510     CompositeParticle *dileptonZ2 = new CompositeParticle();
511     dileptonZ2->AddDaughter(leptonsZZ[2]);
512     dileptonZ2->AddDaughter(leptonsZZ[3]);
513     hDZZSel[91]->Fill((double)(dileptonZ1->Charge()+dileptonZ2->Charge()));
514    
515     CompositeParticle *particleH = new CompositeParticle();
516     particleH->AddDaughter(leptonsZZ[0]);
517     particleH->AddDaughter(leptonsZZ[1]);
518     particleH->AddDaughter(leptonsZZ[2]);
519     particleH->AddDaughter(leptonsZZ[3]);
520    
521     int simpleZZType = 0;
522     if (nZZType >= 1 && nZZType <= 6) simpleZZType = 1;
523     else if(nZZType >= 7 && nZZType <= 12) simpleZZType = 2;
524    
525     hDZZSel[ 0+100*simpleZZType]->Fill(TMath::Min(leptonsAll[0]->Pt(),199.999));
526     hDZZSel[ 1+100*simpleZZType]->Fill(TMath::Min(leptonsAll[1]->Pt(),199.999));
527     hDZZSel[ 2+100*simpleZZType]->Fill(TMath::Min(leptonsAll[2]->Pt(),199.999));
528     hDZZSel[ 3+100*simpleZZType]->Fill(TMath::Min(leptonsAll[3]->Pt(),199.999));
529     if(fabs(dileptonZ1->Mass()-91.1876) < fabs(dileptonZ2->Mass()-91.1876)){
530     hDZZSel[ 4+100*simpleZZType]->Fill(TMath::Min(dileptonZ1->Mass(),199.99));
531     hDZZSel[ 5+100*simpleZZType]->Fill(TMath::Min(dileptonZ2->Mass(),199.99));
532     }
533     else {
534     hDZZSel[ 4+100*simpleZZType]->Fill(TMath::Min(dileptonZ2->Mass(),199.99));
535     hDZZSel[ 5+100*simpleZZType]->Fill(TMath::Min(dileptonZ1->Mass(),199.99));
536     }
537     hDZZSel[ 6+100*simpleZZType]->Fill(TMath::Min(particleH->Mass(),599.99));
538     } // nZZType >= 0
539     } // ZZ analysis
540     }
541     //--------------------------------------------------------------------------------------------------
542     void ZXEvtSelMod::SlaveBegin()
543     {
544     // Run startup code on the computer (slave) doing the actual analysis. Here,
545     // we typically initialize histograms and other analysis objects and request
546     // branches. For this module, we request a branch of the MitTree.
547    
548     ReqBranch(fMetName, fMet);
549    
550     char sb[200];
551     sprintf(sb,"hDZXSel_0"); hDZXSel[0] = new TH1D(sb,sb,10,-0.5,9.5);
552     AddOutput(hDZXSel[0]);
553    
554     // WZ histograms
555     for(int j=0; j<4; j++){
556     int ind = 100 * j;
557     sprintf(sb,"hDWZSel_%d",ind+0); hDWZSel[ind+0] = new TH1D(sb,sb,100,0.0,200.);
558     sprintf(sb,"hDWZSel_%d",ind+1); hDWZSel[ind+1] = new TH1D(sb,sb,100,0.0,200.);
559     sprintf(sb,"hDWZSel_%d",ind+2); hDWZSel[ind+2] = new TH1D(sb,sb,100,0.0,200.);
560     sprintf(sb,"hDWZSel_%d",ind+3); hDWZSel[ind+3] = new TH1D(sb,sb,100,0.0,200.);
561     sprintf(sb,"hDWZSel_%d",ind+4); hDWZSel[ind+4] = new TH1D(sb,sb,100,0.0,200.);
562     sprintf(sb,"hDWZSel_%d",ind+5); hDWZSel[ind+5] = new TH1D(sb,sb,10,-0.5,9.5);
563     sprintf(sb,"hDWZSel_%d",ind+6); hDWZSel[ind+6] = new TH1D(sb,sb,100,0.0,20.);
564     sprintf(sb,"hDWZSel_%d",ind+7); hDWZSel[ind+7] = new TH1D(sb,sb,200,0.0,800.);
565     sprintf(sb,"hDWZSel_%d",ind+8); hDWZSel[ind+8] = new TH1D(sb,sb,100,0.0,200.);
566     sprintf(sb,"hDWZSel_%d",ind+9); hDWZSel[ind+9] = new TH1D(sb,sb,90,0.0,180.);
567     sprintf(sb,"hDWZSel_%d",ind+10); hDWZSel[ind+10] = new TH1D(sb,sb,100,0.0,5.);
568     sprintf(sb,"hDWZSel_%d",ind+11); hDWZSel[ind+11] = new TH1D(sb,sb,100,0.0,5.);
569     sprintf(sb,"hDWZSel_%d",ind+12); hDWZSel[ind+12] = new TH1D(sb,sb,100,0.0,200.);
570     sprintf(sb,"hDWZSel_%d",ind+13); hDWZSel[ind+13] = new TH1D(sb,sb,100,0.0,200);
571     sprintf(sb,"hDWZSel_%d",ind+14); hDWZSel[ind+14] = new TH1D(sb,sb,100,0.0,5.);
572     sprintf(sb,"hDWZSel_%d",ind+15); hDWZSel[ind+15] = new TH1D(sb,sb,90,0.0,180.);
573     }
574    
575     for(int i=0; i<16; i++){
576     for(int j=0; j<4; j++){
577     AddOutput(hDWZSel[i+j*100]);
578     }
579     }
580    
581     sprintf(sb,"hDWZSel_90"); hDWZSel[90] = new TH1D(sb,sb,8,-0.5,7.5);
582     AddOutput(hDWZSel[90]);
583    
584     // ZZ histograms
585     for(int j=0; j<3; j++){
586     int ind = 100 * j;
587     sprintf(sb,"hDZZSel_%d",ind+0); hDZZSel[ind+0] = new TH1D(sb,sb,100,0.0,200.);
588     sprintf(sb,"hDZZSel_%d",ind+1); hDZZSel[ind+1] = new TH1D(sb,sb,100,0.0,200.);
589     sprintf(sb,"hDZZSel_%d",ind+2); hDZZSel[ind+2] = new TH1D(sb,sb,100,0.0,200.);
590     sprintf(sb,"hDZZSel_%d",ind+3); hDZZSel[ind+3] = new TH1D(sb,sb,100,0.0,200.);
591     sprintf(sb,"hDZZSel_%d",ind+4); hDZZSel[ind+4] = new TH1D(sb,sb,100,0.0,200.);
592     sprintf(sb,"hDZZSel_%d",ind+5); hDZZSel[ind+5] = new TH1D(sb,sb,100,0.0,200.);
593     sprintf(sb,"hDZZSel_%d",ind+6); hDZZSel[ind+6] = new TH1D(sb,sb,300,0.0,600.);
594     }
595    
596     for(int i=0; i<7; i++){
597     for(int j=0; j<3; j++){
598     AddOutput(hDZZSel[i+j*100]);
599     }
600     }
601    
602     sprintf(sb,"hDZZSel_90"); hDZZSel[90] = new TH1D(sb,sb,16,-3.5,12.5);
603     sprintf(sb,"hDZZSel_91"); hDZZSel[91] = new TH1D(sb,sb,9,-4.5,4.5);
604     AddOutput(hDZZSel[90]);
605     AddOutput(hDZZSel[91]);
606     }
607    
608     //--------------------------------------------------------------------------------------------------
609     void ZXEvtSelMod::SlaveTerminate()
610     {
611     // Run finishing code on the computer (slave) that did the analysis
612     }
613    
614     //--------------------------------------------------------------------------------------------------
615     void ZXEvtSelMod::Terminate()
616     {
617     // Run finishing code on the client computer
618     }