15 #include "StThreeVector.hh"
18 #include "StAnaPars.h"
19 #include "StjTPCMuDst.h"
21 #include "StjBEMCMuDst.h"
22 #include "StjEEMCMuDst.h"
23 #include "StjFMSMuDst.h"
24 #include "StjFCSMuDst.h"
25 #include "StjMCMuDst.h"
26 #include "StjTPCNull.h"
27 #include "StjBEMCNull.h"
28 #include "StjEEMCNull.h"
29 #include "StjFMSNull.h"
30 #include "StjAbstractTowerEnergyCorrectionForTracks.h"
31 #include "StjeTrackListToStMuTrackFourVecList.h"
32 #include "StjeTowerEnergyListToStMuTrackFourVecList.h"
33 #include "StjMCParticleToStMuTrackFourVec.h"
34 #include "StJetFinder/StJetFinder.h"
35 #include "StSpinPool/StJetEvent/StJetEventTypes.h"
36 #include "StMuTrackFourVec.h"
37 #include "StMuTrackEmu.h"
38 #include "StMuTowerEmu.h"
39 #include "StMcTrackEmu.h"
41 #include "StarGenerator/StarGenEventReader/StarGenEventReader.h"
43 #include "StSpinPool/StUeEvent/StUeOffAxisConesEvent.h"
44 #include "StSpinPool/StUeEvent/StUeVertex.h"
45 #include "StSpinPool/StUeEvent/StUeOffAxisConesJet.h"
46 #include "StSpinPool/StUeEvent/StUeOffAxisCones.h"
48 #include "StJetMaker2012.h"
55 for(
size_t ueBranch = 0; ueBranch < mJetUeBranches.size(); ++ueBranch){
57 for (
size_t iBranch = 0; iBranch < mJetBranches.size(); ++iBranch) {
58 (jetuebranch->eventUe).at(iBranch)->Clear(option);
65 int StJetMaker2012::Init()
67 assert(!mFileNameUe.IsNull());
68 mFileUe = TFile::Open(mFileNameUe,
"recreate");
71 mTreeUe =
new TTree(
"ue",
"ueTree");
73 for(
size_t ueBranch = 0; ueBranch < mJetUeBranches.size(); ++ueBranch){
74 StJetUeBranch* jetuebranch = mJetUeBranches[ueBranch];
75 for (
size_t iBranch = 0; iBranch < mJetBranches.size(); ++iBranch) {
76 StJetBranch* jetbranch = mJetBranches[iBranch];
77 TString branchname(jetbranch->name);
78 branchname.Append(jetuebranch->name);
79 mTreeUe->Branch(branchname,
"StUeOffAxisConesEvent",&((jetuebranch->eventUe)[iBranch]));
80 LOG_INFO<<jetbranch->name<<
" and "<<jetuebranch->name<<
" initialized!"<<endm;
86 return StJetMaker2009::Init();
93 for (
size_t iBranch = 0; iBranch < mJetBranches.size(); ++iBranch) {
98 jetbranch->event->mEventId = GetEventNumber();
99 jetbranch->event->mDatime = GetDateTime();
101 if (jetbranch->anapars->useTpc) {
109 int savedVertexIndex = tpc.currentVertexIndex();
114 int totNumVertices = tpc.numberOfVertices();
116 if(jetbranch->anapars->storeOnlyDefaultVertex && totNumVertices > 1) {
121 for (
int iVertex = 0; iVertex < totNumVertices; ++iVertex) {
122 tpc.setVertexIndex(iVertex);
128 if (vertex.ranking() <= 0)
continue;
132 StjTrackList trackList = tpc.getTrackList();
133 if (jetbranch->anapars->changeTracks) trackList = (*jetbranch->anapars->changeTracks)(trackList);
134 trackList = jetbranch->anapars->tpcCuts()(trackList);
137 StjTowerEnergyList bemcEnergyList;
139 if (jetbranch->anapars->useBemc) {
141 bemcEnergyList = bemc.getEnergyList();
142 if (jetbranch->anapars->changeTowers) (*jetbranch->anapars->changeTowers)(bemcEnergyList);
143 bemcEnergyList = jetbranch->anapars->bemcCuts()(bemcEnergyList);
147 StjTowerEnergyList eemcEnergyList;
149 if (jetbranch->anapars->useEemc) {
151 eemcEnergyList = eemc.getEnergyList();
152 if (jetbranch->anapars->changeTowers) (*jetbranch->anapars->changeTowers)(eemcEnergyList);
153 eemcEnergyList = jetbranch->anapars->eemcCuts()(eemcEnergyList);
157 StjTowerEnergyList fmsEnergyList;
158 if (jetbranch->anapars->useFms) {
160 fmsEnergyList = fms.getEnergyList();
165 StjTowerEnergyList fcsECalEnergyList;
166 if(jetbranch->anapars->useFcsECal){
169 fcsECalEnergyList = fcsECal.getEnergyList();
170 fcsECalEnergyList = jetbranch->anapars->FCSEcalemcCuts()(fcsECalEnergyList);
173 StjTowerEnergyList fcsHCalEnergyList;
174 if(jetbranch->anapars->useFcsHCal){
177 fcsHCalEnergyList = fcsHCal.getEnergyList();
178 fcsHCalEnergyList = jetbranch->anapars->FCSHcalhcCuts()(fcsHCalEnergyList);
183 StjTowerEnergyList energyList;
185 copy(bemcEnergyList.begin(),bemcEnergyList.end(),back_inserter(energyList));
186 copy(eemcEnergyList.begin(),eemcEnergyList.end(),back_inserter(energyList));
187 copy(fmsEnergyList.begin(),fmsEnergyList.end(),back_inserter(energyList));
190 energyList = jetbranch->anapars->correctTowerEnergyForTracks()(energyList,trackList);
193 copy(fcsECalEnergyList.begin(),fcsECalEnergyList.end(),back_inserter(energyList));
194 copy(fcsHCalEnergyList.begin(),fcsHCalEnergyList.end(),back_inserter(energyList));
203 StProtoJet::FourVecList particles;
205 copy(tpc4pList.begin(),tpc4pList.end(),back_inserter(particles));
206 copy(energy4pList.begin(),energy4pList.end(), back_inserter(particles));
209 StJetFinder::JetList protojets;
210 jetbranch->jetfinder->findJets(protojets,particles);
213 protojets = jetbranch->anapars->jetCuts()(protojets);
216 StJetVertex* jetvertex = jetbranch->event->newVertex();
217 copyVertex(vertex,jetvertex);
219 for(
size_t ueBranch = 0; ueBranch < mJetUeBranches.size(); ueBranch++){
220 ((mJetUeBranches[ueBranch]->eventUe).at(iBranch))->setEventId(GetEventNumber());
221 StUeVertex *uevertex = (mJetUeBranches[ueBranch]->eventUe).at(iBranch)->newVertex();
222 uevertex->setPosition(vertex.position());
223 uevertex->setRanking(vertex.ranking());
227 for (StJetFinder::JetList::const_iterator iProtoJet = protojets.begin(); iProtoJet != protojets.end(); ++iProtoJet){
228 addJet(*iProtoJet,jetbranch->event,jetvertex);
230 StJetCandidate* currentjet = jetbranch->event->jet(jetbranch->event->numberOfJets()-1);
231 for(
size_t ueBranch = 0; ueBranch < mJetUeBranches.size(); ueBranch++){
233 double radius = jetuebranch->uePars->coneRadius();
234 double uedensity = addJetUe(particles, (jetuebranch->eventUe).at(iBranch), *iProtoJet, radius);
235 currentjet->setUeDensity(jetuebranch->name, uedensity);
239 for (StProtoJet::FourVecList::const_iterator i = particles.begin(); i != particles.end(); ++i)
247 StjTowerEnergyList bemcEnergyList;
249 if (jetbranch->anapars->useBemc) {
251 bemc.setVertex(0,0,0);
252 bemcEnergyList = bemc.getEnergyList();
253 if (jetbranch->anapars->changeTowers) (*jetbranch->anapars->changeTowers)(bemcEnergyList);
254 bemcEnergyList = jetbranch->anapars->bemcCuts()(bemcEnergyList);
258 StjTowerEnergyList eemcEnergyList_temp, eemcEnergyList;
260 if (jetbranch->anapars->useEemc) {
262 eemcEnergyList = eemc.getEnergyList();
263 if (jetbranch->anapars->changeTowers) (*jetbranch->anapars->changeTowers)(eemcEnergyList);
264 eemcEnergyList = jetbranch->anapars->eemcCuts()(eemcEnergyList);
268 StjTowerEnergyList fmsEnergyList;
269 if (jetbranch->anapars->useFms) {
271 fmsEnergyList = fms.getEnergyList();
276 StjTowerEnergyList fcsECalEnergyList;
277 if(jetbranch->anapars->useFcsECal){
280 fcsECalEnergyList = fcsECal.getEnergyList();
281 fcsECalEnergyList = jetbranch->anapars->FCSEcalemcCuts()(fcsECalEnergyList);
284 StjTowerEnergyList fcsHCalEnergyList;
285 if(jetbranch->anapars->useFcsHCal){
288 fcsHCalEnergyList = fcsHCal.getEnergyList();
289 fcsHCalEnergyList = jetbranch->anapars->FCSHcalhcCuts()(fcsHCalEnergyList);
294 StjTowerEnergyList energyList;
296 copy(bemcEnergyList.begin(),bemcEnergyList.end(),back_inserter(energyList));
297 copy(eemcEnergyList.begin(),eemcEnergyList.end(),back_inserter(energyList));
298 copy(fmsEnergyList.begin(),fmsEnergyList.end(),back_inserter(energyList));
299 copy(fcsECalEnergyList.begin(),fcsECalEnergyList.end(),back_inserter(energyList));
300 copy(fcsHCalEnergyList.begin(),fcsHCalEnergyList.end(),back_inserter(energyList));
306 StProtoJet::FourVecList particles;
308 copy(energy4pList.begin(),energy4pList.end(),back_inserter(particles));
311 StJetFinder::JetList protojets;
312 jetbranch->jetfinder->findJets(protojets,particles);
315 protojets = jetbranch->anapars->jetCuts()(protojets);
318 StJetVertex* jetvertex = jetbranch->event->newVertex();
319 jetvertex->mPosition.SetXYZ(0,0,0);
322 for (StJetFinder::JetList::const_iterator iProtoJet = protojets.begin(); iProtoJet != protojets.end(); ++iProtoJet)
323 addJet(*iProtoJet,jetbranch->event,jetvertex);
326 for (StProtoJet::FourVecList::const_iterator i = particles.begin(); i != particles.end(); ++i)
331 tpc.setVertexIndex(savedVertexIndex);
336 if (jetbranch->anapars->useMonteCarlo) {
340 if(GetMaker(
"genEvent")){
342 sEvent = eventreader->
Event();
343 mc.setGenEvent(sEvent);
347 StjMCParticleList mcparticles = jetbranch->anapars->mcCuts()(mc.getMCParticleList());
348 StProtoJet::FourVecList particles;
352 StJetFinder::JetList protojets;
353 jetbranch->jetfinder->findJets(protojets,particles);
356 protojets = jetbranch->anapars->jetCuts()(protojets);
359 StJetVertex* jetvertex = jetbranch->event->newVertex();
360 copyVertex(mcvertex,jetvertex);
362 for(
size_t ueBranch = 0; ueBranch < mJetUeBranches.size(); ueBranch++){
363 ((mJetUeBranches[ueBranch]->eventUe).at(iBranch))->setEventId(GetEventNumber());
364 StUeVertex *uevertex = (mJetUeBranches[ueBranch]->eventUe).at(iBranch)->newVertex();
365 uevertex->setPosition(mcvertex.position());
366 uevertex->setRanking(mcvertex.ranking());
370 for (StJetFinder::JetList::const_iterator iProtoJet = protojets.begin(); iProtoJet != protojets.end(); ++iProtoJet){
371 addJet(*iProtoJet,jetbranch->event,jetvertex);
374 StJetCandidate* currentjet = jetbranch->event->jet(jetbranch->event->numberOfJets()-1);
375 for(
size_t ueBranch = 0; ueBranch < mJetUeBranches.size(); ueBranch++){
377 double radius = jetuebranch->uePars->coneRadius();
378 double uedensity = addJetUe(particles, (jetuebranch->eventUe).at(iBranch), *iProtoJet, radius);
379 currentjet->setUeDensity(jetuebranch->name, uedensity);
384 for (StProtoJet::FourVecList::const_iterator i = particles.begin(); i != particles.end(); ++i)
408 StJetUeBranch *ue =
new StJetUeBranch(name, pars);
409 for(
size_t iBranch = 0; iBranch < mJetBranches.size(); iBranch++)
411 mJetUeBranches.push_back(ue);
415 void StJetMaker2012::setJetFileUe(
const char* filename)
417 mFileNameUe = filename;
419 TTree* StJetMaker2012::treeUe()
426 TBranch* branch = mTreeUe->GetBranch(branchname);
434 double jpt = jet.pt();
435 double jeta = jet.eta();
436 double jphi = jet.phi();
438 double jarea = jet.area();
442 const double PI = 3.14159;
446 double cone_eta[Ncone];
447 double cone_phi[Ncone];
448 for(
int ii = 0; ii < Ncone; ii++){
450 cone_phi[ii] = jphi + (PI/2.)*(2*ii-1);
451 cones[ii] = ueEvent->newUeOffAxisCones();
456 for(
size_t ii = 0; ii < particles.size(); ii++){
459 double p_pt = mom.perp();
460 double p_eta = vect->eta();
461 double p_phi = vect->
phi();
464 double dR = DeltaR(p_eta, p_phi, cone_eta[0], cone_phi[0]);
470 dR = DeltaR(p_eta, p_phi, cone_eta[1], cone_phi[1]);
477 if(index == 0 || index == 1){
482 cones[index]->addTrack(track);
489 cones[index]->addTower(tower);
494 copyParticle(t,part);
495 cones[index]->addParticle(part);
501 for(
int ii = 0; ii < Ncone; ii++){
502 cones[ii]->setPt(pt[ii]);
503 cones[ii]->setEtaPhi(cone_eta[ii], cone_phi[ii]);
504 cones[ii]->setRadius(radius);
505 cones[ii]->setMult(number[ii]);
506 density += pt[ii]/(PI*radius*radius);
508 density = density/(Ncone+0.);
512 jcones->setEta(jeta);
513 jcones->setPhi(jphi);
515 jcones->setArea(jarea);
516 jcones->setDensity(density);
517 jcones->addCone(cones[0]);
518 jcones->addCone(cones[1]);
520 ueVertex->addUeJet(jcones);
524 double StJetMaker2012::DeltaR(
double etaA,
double phiA,
double etaB,
double phiB)
526 const double PI = 3.14159;
528 double deta = etaA - etaB;
529 double dphi = phiA - phiB;
531 if(dphi > PI) dphi -= 2.*PI;
532 if(dphi < -1.*PI) dphi += 2.*PI;
534 double dR = TMath::Sqrt(deta*deta+dphi*dphi);
StarGenEvent * Event()
Retrieves the event record.
double phi() const
angles
void Clear(Option_t *option="")
User defined functions.
virtual Int_t GetRunNumber() const
Returns the current RunNumber.
void Clear(Option_t *option="")
User defined functions.