5 #include <StMuDSTMaker/COMMON/StMuDstMaker.h>
6 #include <StMuDSTMaker/COMMON/StMuDst.h>
7 #include <StMuDSTMaker/COMMON/StMuEvent.h>
8 #include <StMuDSTMaker/COMMON/StMuPrimaryVertex.h>
11 #include "tables/St_g2t_tpc_hit_Table.h"
12 #include "StMcEventMaker/StMcEventMaker.h"
13 #include "StMcEvent/StMcEvent.hh"
14 #include "StMcEvent/StMcVertex.hh"
15 #include "StMcEvent/StMcTrack.hh"
18 #include "St2009WMaker.h"
19 #include "St2009WjjMaker.h"
20 #include "StMcJetCalibMaker.h"
21 #include <StSpinPool/StJets/StJet.h>
28 wMK=0; wjjMK=0;HList=0;
34 par_jetEtaLow=-1.5; par_jetEtaHigh=2;
42 StMcJetCalibMaker::Init(){
44 if( par_corLevel) assert(wjjMK);
48 return StMaker::Init();
55 StMcJetCalibMaker::FinishRun (
int runNo){
62 StMcJetCalibMaker::InitRun (
int runNo){
65 LOG_INFO<<
GetName()<<Form(
"::InitRun(%d),calib params: |geant vertZ|<%.0f cm |zG-zR|<%.1f cm, jet: eta=[%.1f,%1f], delR(reco-gen)<%.2f \n JES corr level=%d",
66 runNo,par_vertexZ ,par_verZerr,par_jetEtaLow,par_jetEtaHigh,
86 StMcJetCalibMaker::calibrate(){
88 mMcEvent = (
StMcEvent*) StMaker::GetChain()->GetDataSet(
"StMcEvent");
89 if(mMcEvent==0)
return;
96 TVector3 mcV=TVector3(V->position().x(),V->position().y(),V->position().z());
99 hA[0]->Fill(
"inp",1.);
100 hA[1]->Fill(mcV.z());
101 if(fabs(mcV.z()) > par_vertexZ)
return;
102 hA[0]->Fill(
"verG",1.);
105 for(
unsigned int i=0;i<mMcEvent->tracks().size();i++){
106 StMcTrack* mcTrack = mMcEvent->tracks()[i];
107 int pdgId=mcTrack->pdgId();
109 printf(
"i=%d pdgId=%d p=%f %f %f m=%f\n",i,pdgId,p4.x(),p4.y(),p4.z(),p4.m());
116 int pdgId=mMcEvent->tracks()[6]->pdgId();
117 if(pdgId==23) type=1;
118 if( pdgId==-24 || pdgId==24 ) type=2;
122 if(mMcEvent->tracks().size()<10)
return;
129 mctW=mMcEvent->tracks()[6];
130 mctC= mMcEvent->tracks()[7];
131 mctD= mMcEvent->tracks()[8];
132 hA[0]->Fill(
"W,Z",1.);
134 mctC= mMcEvent->tracks()[6];
135 mctD= mMcEvent->tracks()[7];
139 const int mxGJ=2, mxRJ=4;
140 int nGJ=0,nRJ=0 , mrJI[mxGJ];;
141 TLorentzVector gJA[mxGJ], rJA[mxRJ];
143 float delRA[mxGJ][mxRJ],delRAc[mxGJ][mxRJ];
144 memset(mrJI,-1,
sizeof(mrJI));
146 for(
int k=0;k<2;k++) {
150 if(k==0) gJ=TLorentzVector(ttC.px(),ttC.py(),ttC.pz(),ttC.e());
151 if(k==1) gJ=TLorentzVector(ttD.px(),ttD.py(),ttD.pz(),ttD.e());
152 hA[11]->Fill(gJ.Eta(),gJ.Phi());
153 if(gJ.Eta()<par_jetEtaLow )
continue;
154 if(gJ.Eta()>par_jetEtaHigh )
continue;
157 hA[4]->Fill(gJ.Pt(),gJ.Eta());
161 hA[0]->Fill(
"etaG",1.);
165 hA[10]->Fill(pW.m());
171 int nInpPrimV=wMK->mMuDstMaker->
muDst()->numberOfPrimaryVertices();
173 for(
int iv=0;iv<nInpPrimV;iv++) {
178 float rank=V->ranking();
179 if (rank<=0)
continue;
181 hA[2]->Fill(r.z()-mcV.z());
182 if(fabs(r.z()-mcV.z()) > par_verZerr)
continue;
188 hA[0]->Fill(
"verR",1.);
193 TClonesArray* jets = wMK->getJets(
"ConeJets12_100");
194 int nJets= wMK->nJets;
198 hA[0]->Fill(
"anyJ",1.);
199 if(nJets>=2) hA[0]->Fill(
"mulJ",1.);
202 float par_recJetPtMin=5.;
204 for (
int ir=0; ir< nJets; ir++){
206 TLorentzVector rJ = *jet;
207 if(par_corLevel) rJ=wjjMK->trueJet(rJ);
209 if(rJ.Pt()<par_recJetPtMin)
continue;
210 if(nRJ>=mxRJ)
continue;
211 for(
int ig=0;ig<nGJ;ig++)
212 delRA[ig][nRJ]=gJA[ig].DrEtaPhi(rJ);
218 memcpy(delRAc,delRA,
sizeof(delRA));
225 for (
int ir=0; ir< nRJ; ir++)
226 for(
int ig=0;ig<nGJ;ig++) {
227 if(delRA[ig][ir]>minR)
continue;
234 for (
int ir=0; ir< nRJ; ir++) delRA[igm][ir]=99999;
235 for(
int ig=0;ig<nGJ;ig++) delRA[ig][irm]=99999;
240 for(
int ig=0;ig<nGJ;ig++) {
241 if(mrJI[ig]<0)
continue;
243 float delR=delRAc[ig][ir];
244 TLorentzVector gJ=gJA[ig], rJ=rJA[ ir];
247 if(delR>par_delRmax)
continue;
248 hA[0]->Fill(
"delR",1.);
252 hA[15]->Fill(gJ.Pt());
253 hA[12]->Fill(gJ.Pt(),gJ.Eta());
254 hA[21]->Fill(gJ.E(),rJ.E());
255 hA[22]->Fill(gJ.Pt(),rJ.Pt());
258 int iEta=(rJ.Eta()+1.2)/0.4;
260 if(iEta>=mxEta) iEta=mxEta-1;
261 hA[40+iEta]->Fill(gJ.Pt(),rJ.Pt());
263 float ratioPT=rJ.Pt()/gJ.Pt();
266 hA[16]->Fill(ratioPT);
276 #if 0 // pppppppppp test printing
278 printf(
"gen type=%d pdgId=%d eveID=%d\n",type,pdgId,wMK->mMuDstMaker->
muDst()->
event()->eventId());
279 if(type && par_corLevel==0) {
281 pG=TLorentzVector(ttW.px(),ttW.py(),ttW.pz(),ttW.e());
282 printf(
"gen W, P=%.1f %.1f %.1f E=%.1f M=%.1f PT=%.1f eta=%.2f phi/deg=%.0f\n",pG.X(),pG.Y(),pG.Z(),pG.E(), pG.M(),pG.Pt(),pG.Eta(), pG.Phi()/3.14*180);
284 for(
int k=0;k<2;k++) {
287 if(k==0) pG=TLorentzVector(ttC.px(),ttC.py(),ttC.pz(),ttC.e());
288 if(k==1) pG=TLorentzVector(ttD.px(),ttD.py(),ttD.pz(),ttD.e());
289 printf(
"gen q=%c, P=%.1f %.1f %.1f E=%.1f M=%.1f PT=%.1f eta=%.2f phi/deg=%.0f\n",
'C'+k,pG.X(),pG.Y(),pG.Z(),pG.E(), pG.M(),pG.Pt(),pG.Eta(), pG.Phi()/3.14*180);
293 printf(
"reco inp nJ=%d eveID=%d: selected nGJ=%d nRJ=%d\n",nJets,wMK->mMuDstMaker->
muDst()->
event()->eventId(),nGJ,nRJ);
294 for (
int i_jet=0; i_jet< nJets; i_jet++){
296 TLorentzVector J = *jet;
297 float neutPt=jet->neutralFraction()*J.Pt();
298 if(J.Pt()<5)
continue;
299 printf(
"recJ=%d, P=%.1f %.1f %.1f E=%.1f M=%.1f PT=%.1f neutPt=%.1f eta=%.2f phi/deg=%.0f\n",i_jet,J.X(),J.Y(),J.Z(),J.E(), J.M(),J.Pt(),neutPt,J.Eta(), J.Phi()/3.14*180);
302 printf(
"matching gen-->reco :\n");
303 for(
int ig=0;ig<nGJ;ig++) {
304 printf(
"gen J PT=%.1f : delR(ir)= ",gJA[ig].Pt());
305 for (
int ir=0; ir< nRJ; ir++){
306 if( mrJI[ig]==ir) printf(
"*");
308 printf(
"%.2f, ", delRAc[ig][ir]);
310 if(mrJI[ig]<0) printf(
"no match");
311 else printf(
" rec PT=%.1f", rJA[mrJI[ig]].Pt());
314 printf(
"\n---------\n");
326 TLorentzVector pJ=pJreco;
327 float cor1=1./St2009WjjMaker::jetEcorr(pJreco.E());
330 if(par_corLevel) pJ=cor1*pJ;
332 float neutFrac=jet->neutralFraction();
333 float chargFrac=jet->chargedFraction();
335 float frac=pJ.E()/pG.E();
336 if(fabs(frac-1.)> par_ptMargin)
continue;
338 if(delR>par_delRmargin)
continue;
340 if(delR>par_delRmax)
continue;
341 hA[0]->Fill(
"delR",1.);
342 hA[12]->Fill(pG.Pt(),pG.Eta());
349 hA[17]->Fill(frac,pG.Eta());
350 hA[18]->Fill(pG.Eta()-pJ.Eta(),pG.Eta());
351 hA[19]->Fill(pG.DeltaPhi(pJ)/3.1416*180 ,pG.Eta());
352 hA[21]->Fill(pG.E(),pJ.E());
353 hA[22]->Fill(pG.Pt(),pJ.Pt());
355 int iEta=(pJ.Eta()+1.)/0.5;
357 if(iEta>=mxEta) iEta=mxEta-1;
358 hA[40+iEta]->Fill(pG.Pt(),pJ.Pt());
361 hA[26]->Fill(frac*neutFrac);
362 hA[27]->Fill(pJ.Eta(),pJ.E()*neutFrac);
365 hA[36]->Fill(frac*chargFrac);
366 hA[37]->Fill(pJ.Eta(),pJ.E()*chargFrac);
static StMuPrimaryVertex * primaryVertex()
return pointer to current primary vertex
Monte Carlo Track class All information on a simulated track is stored in this class: kinematics...
static StMuEvent * event()
returns pointer to current StMuEvent (class holding the event wise information, e.g. event number, run number)
virtual const char * GetName() const
special overload
static void setVertexIndex(Int_t vtx_id)
Set the index number of the current primary vertex (used by both primaryTracks() functions and for St...
Event data structure to hold all information from a Monte Carlo simulation. This class is the interfa...