ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitPhysics/Mods/src/MVASystematicsMod.cc
(Generate patch)

Comparing UserCode/MitPhysics/Mods/src/MVASystematicsMod.cc (file contents):
Revision 1.1 by bendavid, Tue Dec 13 21:13:23 2011 UTC vs.
Revision 1.2 by bendavid, Thu Mar 22 15:54:07 2012 UTC

# Line 31 | Line 31 | MVASystematicsMod::MVASystematicsMod(con
31  
32    // define all the Branches to load
33    fMCParticleName    (Names::gkMCPartBrn),
34 +  fPVName            (Names::gkPVBeamSpotBrn),
35 +  fEBSCName            (Names::gkBarrelSuperClusterBrn),
36 +  fEESCName            (Names::gkEndcapSuperClusterBrn),  
37 +
38  
39    // ----------------------------------------
40    // collections....
41    fMCParticles       (0),
42 +  fPV       (0),
43 +  fEBSC       (0),
44 +  fEESC       (0),
45    // -------------------------------------------
46 +  
47 +  fMCR9ScaleEB(1.0),
48 +  fMCR9ScaleEE(1.0),
49 +  
50    fIsData            (false),
51  
52    fTupleName("hMVAtuple")
# Line 57 | Line 68 | void MVASystematicsMod::Process()
68    if( !fIsData )
69      LoadBranch(fMCParticleName);
70  
71 +  LoadBranch(fPVName);
72 +  LoadBranch(fEBSCName);
73 +  LoadBranch(fEESCName);
74 +  
75 +  const Vertex *vtx = 0;
76 +  if (fPV->GetEntries()>0) vtx = fPV->At(0);
77 +  
78 +  const MCParticle *h = 0;
79 +  const MCParticle *p1 = 0;
80 +  const MCParticle *p2 = 0;
81 +  
82 +  const SuperCluster *sc1 = 0;
83 +  const SuperCluster *sc2 = 0;
84 +  
85    Float_t _pth    = -100.;
86    Float_t _y      = -100.;
87    Float_t _genmass = -100.;
88 <  if( !fIsData ) FindHiggsPtAndY(_pth, _y, _genmass);  
88 >  if( !fIsData ) h = FindHiggsPtAndY(_pth, _y, _genmass);  
89 >
90 >  if (h && h->NDaughters()>=2) {
91 >    p1 = h->Daughter(0);
92 >    p2 = h->Daughter(1);
93 >  }
94 >  
95 >  Float_t pt1 = -100;
96 >  Float_t eta1 = -100;
97 >  Float_t phi1 = -100;
98 >
99 >  Float_t pt2 = -100;
100 >  Float_t eta2 = -100;
101 >  Float_t phi2 = -100;  
102 >  
103 >  Float_t scet1 = -100;
104 >  Float_t sceta1 = -100;
105 >  Float_t scphi1 = -100;
106 >  Float_t scr91 = -100;
107 >  bool iseb1 = kFALSE;
108 >
109 >  Float_t scet2 = -100;
110 >  Float_t sceta2 = -100;
111 >  Float_t scphi2 = -100;  
112 >  Float_t scr92 = -100;  
113 >  bool iseb2 = kFALSE;
114 >  
115 >  if (p1) {
116 >    pt1 = p1->Pt();
117 >    eta1 = p1->Eta();
118 >    phi1 = p1->Phi();
119 >    sc1 = MatchSC(p1,iseb1);
120 >  }
121 >
122 >  if (p2) {
123 >    pt2 = p2->Pt();
124 >    eta2 = p2->Eta();
125 >    phi2 = p2->Phi();
126 >    sc2 = MatchSC(p2,iseb2);
127 >  }
128 >  
129 >  if (sc1) {
130 >    double r9scale;
131 >    if   (iseb1) r9scale = fMCR9ScaleEB;
132 >    else r9scale = fMCR9ScaleEE;
133 >      
134 >    // compute the probe momentum wr to the chosen Vtx
135 >    FourVectorM scmom;  
136 >    ThreeVectorC scp;
137 >    if (vtx) scp = sc1->Point() - vtx->Position();
138 >    else scp = sc1->Point();
139 >    scp = scp/scp.R();
140 >    scmom.SetXYZT(sc1->Energy()*scp.X(), sc1->Energy()*scp.Y(), sc1->Energy()*scp.Z(), sc1->Energy());
141 >      
142 >    scet1 = scmom.Pt();
143 >    sceta1 = sc1->Eta();
144 >    scphi1 = sc1->Phi();
145 >    scr91 = r9scale*sc1->R9();
146 >    
147 >  }
148 >
149  
150 <  hMVAtuple->Fill(_pth, _y, _genmass);
150 >  if (sc2) {
151 >    double r9scale;
152 >    if   (iseb2) r9scale = fMCR9ScaleEB;
153 >    else r9scale = fMCR9ScaleEE;
154 >      
155 >    // compute the probe momentum wr to the chosen Vtx
156 >    FourVectorM scmom;  
157 >    ThreeVectorC scp;
158 >    if (vtx) scp = sc2->Point() - vtx->Position();
159 >    else scp = sc2->Point();
160 >    scp = scp/scp.R();
161 >    scmom.SetXYZT(sc2->Energy()*scp.X(), sc2->Energy()*scp.Y(), sc2->Energy()*scp.Z(), sc2->Energy());
162 >      
163 >    scet2 = scmom.Pt();
164 >    sceta2 = sc2->Eta();
165 >    scphi2 = sc2->Phi();
166 >    scr92 = r9scale*sc2->R9();
167 >    
168 >  }
169 >
170 >  Float_t fill[] = {_pth, _y, _genmass,pt1,eta1,phi1,pt2,eta2,phi2,scet1,sceta1,scphi1,scr91,scet2,sceta2,scphi2,scr92};
171 >
172 >  hMVAtuple->Fill(fill);
173  
174  
175    return;
# Line 78 | Line 185 | void MVASystematicsMod::SlaveBegin()
185    if (!fIsData) {
186      ReqBranch(fMCParticleName,        fMCParticles);
187    }
188 +  
189 +  ReqBranch(fPVName,        fPV);
190 +  ReqBranch(fEBSCName,      fEBSC);
191 +  ReqBranch(fEESCName,      fEESC);
192 +  
193  
194 <  hMVAtuple = new TNtuple(fTupleName.Data(),fTupleName.Data(),"hpt:hy:hm");
194 >  hMVAtuple = new TNtuple(fTupleName.Data(),fTupleName.Data(),"hpt:hy:hm:pt1:eta1:phi1:pt2:eta2:phi2:scet1:sceta1:scphi1:scr91:scet2:sceta2:scphi2:scr92");
195  
196    AddOutput(hMVAtuple);
197   }
# Line 100 | Line 212 | void MVASystematicsMod::Terminate()
212  
213   // ----------------------------------------------------------------------------------------
214   // some helpfer functions....
215 < void MVASystematicsMod::FindHiggsPtAndY(Float_t& pt, Float_t& Y, Float_t& mass) {
215 > const MCParticle *MVASystematicsMod::FindHiggsPtAndY(Float_t& pt, Float_t& Y, Float_t& mass) {
216  
217 +  const MCParticle *h = 0;
218 +  
219    pt = -999.;
220    Y  = -999;
221    mass = -999.;
# Line 113 | Line 227 | void MVASystematicsMod::FindHiggsPtAndY(
227        pt=p->Pt();
228        Y = p->Rapidity();
229        mass = p->Mass();
230 +      h = p;
231        break;
232      }
233    }
234    
235 <  return;
236 < }
235 >  return h;
236 > }
237 >
238 > // ----------------------------------------------------------------------------------------
239 > // some helpfer functions....
240 > const SuperCluster *MVASystematicsMod::MatchSC(const MCParticle *p, bool &iseb) {
241 >
242 >  iseb = kFALSE;
243 >  
244 >  for(UInt_t i=0; i<fEBSC->GetEntries(); ++i) {
245 >    iseb = kTRUE;
246 >    const SuperCluster *sc = fEBSC->At(i);
247 >    if (MathUtils::DeltaR(sc,p)<0.2) return sc;
248 >  }
249 >
250 >  for(UInt_t i=0; i<fEESC->GetEntries(); ++i) {
251 >    iseb = kFALSE;
252 >    const SuperCluster *sc = fEESC->At(i);
253 >    if (MathUtils::DeltaR(sc,p)<0.2) return sc;
254 >  }
255 >
256 >  return 0;
257 > }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines