18 #include <calobase/RawTower.h>
19 #include <calobase/RawTowerContainer.h>
20 #include <calobase/RawTowerGeom.h>
21 #include <calobase/RawTowerGeomContainer.h>
22 #include <calobase/TowerInfoContainer.h>
23 #include <calobase/TowerInfo.h>
25 #include <Pythia8/Pythia.h>
30 #include <fastjet/PseudoJet.hh>
35 #include "fastjet/ClusterSequence.hh"
36 #include "fastjet/contrib/SoftDrop.hh"
38 using namespace fastjet;
45 #include "TVirtualPad.h"
46 #include "TApplication.h"
57 :
SubsysReco(
"EMJetVal_" + recojetname +
"_" + truthjetname)
58 , m_recoJetName(recojetname)
60 , m_outputFileName(outputfilename)
94 std::cout <<
"EMJetVal::EMJetVal(const std::string &name) Calling ctor" << std::endl;
101 std::cout <<
"EMJetVal::~EMJetVal() Calling dtor" << std::endl;
109 std::cout <<
"EMJetVal::Init - Output to " <<
m_outputFileName << std::endl;
112 _h_R04_z_sj_10_20=
new TH1F(
"R04_z_sj_10_20",
"z_sj in subjets 1 & 2", 10, 0, 0.5);
115 _h_R04_z_g_10_20=
new TH1F(
"R04_z_g_10_20",
"z_g in subjets 1 & 2", 10, 0, 0.5);
118 _hmult_R04=
new TH1F(
"mult_R04",
"total number of constituents inside R=0.4 jets", 30, 0, 30);
119 _hmult_R04_pT_10_20GeV=
new TH1F(
"mult_R04_pT_10_20GeV",
"total number of constituents inside R=0.4 jets with 10 < p_{T} < 20", 30, 0, 30);
120 _hjetpT_R04 =
new TH1F(
"jetpT_R04",
"jet transverse momentum for R=0.4 jets", 100, 0, 100);
121 _hjeteta_R04 =
new TH1F(
"jeteta_R04",
"jet pseudorapidity for R=0.4 jets", 50, -0.6, 0.6);
123 correlation_theta_10_20 =
new TH2D(
"correlation_theta_10_20",
"Correlation Plot 10 < p_{T} < 20 [GeV/c]; R_{g}; #theta_{sj}", 20, 0, 0.5, 20, 0, 0.5);
124 correlation_z_10_20 =
new TH2D(
"correlation_z_10_20",
"Correlation Plot; z_{g}; z_{sj}", 20, 0, 0.5, 20, 0, 0.5);
129 m_T =
new TTree(
"T",
"MyJetAnalysis Tree");
169 std::cout <<
"finished declaring histos" << std::endl;
192 std::cout <<
"EMJetVal::process_event(PHCompositeNode *topNode) Processing Event " <<
m_event << std::endl;
200 <<
"MyJetAnalysis::process_event - Error can not find DST Reco JetContainer node "
210 <<
"MyJetAnalysis::process_event - Error can not find DST Truth JetMap node "
217 JetContainer* seedjetsraw = findNode::getClass<JetContainer>(topNode,
"AntiKt_TowerInfo_HIRecoSeedsRaw_r02");
221 <<
"MyJetAnalysis::process_event - Error can not find DST raw seed jets "
226 JetContainer* seedjetssub = findNode::getClass<JetContainer>(topNode,
"AntiKt_TowerInfo_HIRecoSeedsSub_r02");
230 <<
"MyJetAnalysis::process_event - Error can not find DST subtracted seed jets "
236 CentralityInfo* cent_node = findNode::getClass<CentralityInfo>(topNode,
"CentralityInfo");
240 <<
"MyJetAnalysis::process_event - Error can not find centrality node "
246 TowerInfoContainer *towersEM3 = findNode::getClass<TowerInfoContainer>(topNode,
"TOWERINFO_CALIB_CEMC_RETOWER");
247 TowerInfoContainer *towersIH3 = findNode::getClass<TowerInfoContainer>(topNode,
"TOWERINFO_CALIB_HCALIN");
248 TowerInfoContainer *towersOH3 = findNode::getClass<TowerInfoContainer>(topNode,
"TOWERINFO_CALIB_HCALOUT");
249 RawTowerGeomContainer *tower_geom = findNode::getClass<RawTowerGeomContainer>(topNode,
"TOWERGEOM_HCALIN");
250 RawTowerGeomContainer *tower_geomOH = findNode::getClass<RawTowerGeomContainer>(topNode,
"TOWERGEOM_HCALOUT");
251 if(!towersEM3 || !towersIH3 || !towersOH3){
253 <<
"MyJetAnalysis::process_event - Error can not find raw tower node "
258 if(!tower_geom || !tower_geomOH){
260 <<
"MyJetAnalysis::process_event - Error can not find raw tower geometry "
266 TowerBackground *background = findNode::getClass<TowerBackground>(topNode,
"TowerInfoBackground_Sub2");
268 std::cout<<
"Can't get background. Exiting"<<std::endl;
278 float background_v2 = 0;
279 float background_Psi2 = 0;
282 background_v2 = background->
get_v2();
283 background_Psi2 = background->
get_Psi2();
285 for (
auto jet : *jets)
288 std::cout <<
"working on original jet " << jet->get_id() <<
" out of " << jets->size() << std::endl;
290 if(jet->get_pt() < 1)
continue;
293 m_id.push_back(jet->get_id());
295 m_eta.push_back(jet->get_eta());
296 m_phi.push_back(jet->get_phi());
297 m_e.push_back(jet->get_e());
298 m_pt.push_back(jet->get_pt());
309 for (
auto comp : jet->get_comp_vec())
315 if (
comp.first == 15 ||
comp.first == 30)
317 tower = towersIH3->get_tower_at_channel(channel);
318 if(!tower || !tower_geom){
321 unsigned int calokey = towersIH3->encode_key(channel);
322 int ieta = towersIH3->getTowerEtaBin(calokey);
323 int iphi = towersIH3->getTowerPhiBin(calokey);
325 float UE = background->
get_UE(1).at(ieta);
326 float tower_phi = tower_geom->get_tower_geometry(key)->get_phi();
327 float tower_eta = tower_geom->get_tower_geometry(key)->get_eta();
329 UE = UE * (1 + 2 * background_v2 * cos(2 * (tower_phi - background_Psi2)));
331 double pt = (tower->
get_energy() + UE) / cosh(tower_eta);
332 totalPx += pt * cos(tower_phi);
333 totalPy += pt * sin(tower_phi);
334 totalPz += pt * sinh(tower_eta);
336 else if (
comp.first == 16 ||
comp.first == 31)
338 tower = towersOH3->get_tower_at_channel(channel);
339 if(!tower || !tower_geomOH)
344 unsigned int calokey = towersOH3->encode_key(channel);
345 int ieta = towersOH3->getTowerEtaBin(calokey);
346 int iphi = towersOH3->getTowerPhiBin(calokey);
348 float UE = background->
get_UE(2).at(ieta);
349 float tower_phi = tower_geomOH->get_tower_geometry(key)->get_phi();
350 float tower_eta = tower_geomOH->get_tower_geometry(key)->get_eta();
352 UE = UE * (1 + 2 * background_v2 * cos(2 * (tower_phi - background_Psi2)));
354 double pt = (tower->
get_energy() + UE) / cosh(tower_eta);
355 totalPx += pt * cos(tower_phi);
356 totalPy += pt * sin(tower_phi);
357 totalPz += pt * sinh(tower_eta);
359 else if (
comp.first == 14 ||
comp.first == 29)
362 if(!tower || !tower_geom)
367 unsigned int calokey = towersEM3->
encode_key(channel);
371 float UE = background->
get_UE(0).at(ieta);
372 float tower_phi = tower_geom->get_tower_geometry(key)->get_phi();
373 float tower_eta = tower_geom->get_tower_geometry(key)->get_eta();
376 UE = UE * (1 + 2 * background_v2 * cos(2 * (tower_phi - background_Psi2)));
381 pt = ETmp / cosh(tower_eta);
383 double pxTmp = pt * cos(tower_phi);
384 double pyTmp = pt * sin(tower_phi);
385 double pzTmp = pt * sinh(tower_eta);
393 particles.push_back( PseudoJet( pxTmp, pyTmp, pzTmp, ETmp) );
399 double radius[5] = {0.05, 0.1, 0.2, 0.4, 0.6};
400 double pseudorapidity = -999.;
401 double theta_sj = -1.;
413 ClusterSequence clustSeq_R04( particles, jetDefAKT_R04 );
414 std::vector<PseudoJet> sortedJets_R04 =
sorted_by_pt( clustSeq_R04.inclusive_jets() );
418 for (
int j = 0;
j < (int)sortedJets_R04.size();
j++) {
420 std::cout <<
"working on reclustered jet " <<
j <<
" of " << sortedJets_R04.size() << std::endl;
422 PseudoJet
jet_reco = sortedJets_R04.at(
j);
423 if(fabs(jet_reco.eta()) > 0.6)
426 std::cout <<
"jet within eta of 0.6" << std::endl;
428 ClusterSequence clustSeq_R01_con(jet_reco.constituents() , jetDefAKT_R01 );
429 std::cout <<
"made R=0.1 cluster sequence" << std::endl;
430 std:: vector<PseudoJet> sortedJets_R01_con =
sorted_by_pt( clustSeq_R01_con.inclusive_jets() );
431 std::cout <<
"ran R=0.1 and sorted by pT" << std::endl;
432 std::cout <<
"number of subjets: " << sortedJets_R01_con.size() << std::endl;
434 if (sortedJets_R01_con.size() < 2){
435 std::cout <<
"not enough subjets" << std::endl;
439 std:: cout <<
"at least 2 subjets" << std::endl;
441 PseudoJet sj1 = sortedJets_R01_con.at(0);
442 PseudoJet sj2 = sortedJets_R01_con.at(1);
446 if (sj1.pt() < 3 || sj2.pt() < 3 )
450 std::cout <<
"both are above 3" << std::endl;
452 theta_sj = sj1.delta_R(sj2);
453 z_sj = sj2.pt()/(sj2.pt()+sj1.pt());
455 std::cout <<
"theta_sj = " << theta_sj <<
" z_sj = " << z_sj << std::endl;
458 if (jet_reco.pt() > 10 && jet_reco.pt() < 20 ){
460 std::cout <<
"jet pt >10 & <20: " << jet_reco.pt() << std::endl;
462 pseudorapidity = jet_reco.eta();
464 _hmult_R04->Fill(jet_reco.constituents().size());
466 ClusterSequence clustSeqCA(jet_reco.constituents(), jetDefCA);
467 std::vector<PseudoJet> cambridgeJets =
sorted_by_pt(clustSeqCA.inclusive_jets());
469 std::cout <<
"have CA sort jets: " << cambridgeJets.size() << std::endl;
474 contrib::SoftDrop sd(beta, z_cut);
476 if (!isnan(theta_sj) && !isnan(z_sj) && !isinf(theta_sj) && !isinf(z_sj)){
481 std::cout <<
"filled some histos" << std::endl;
483 PseudoJet sd_jet = sd(jet_reco);
484 std::cout <<
"ran sd" << std::endl;
488 std::cout <<
"sd jet exists" << std::endl;
489 double delta_R_subjets = sd_jet.structure_of<contrib::SoftDrop>().delta_R();
490 double z_subjets = sd_jet.structure_of<contrib::SoftDrop>().symmetry();
511 std::cout <<
"finished jet " <<
j << std::endl;
516 std::cout <<
"finished loop over reclustered jets" << std::endl;
522 std::cout <<
"m_nJet: " <<
m_nJet << std::endl;
525 std::cout <<
"finised loop over original jets" << std::endl;
574 std::cout <<
"filled TTree" << std::endl;
618 std::cout <<
"EMJetVal::EndRun(const int runnumber) Ending Run for Run " << runnumber << std::endl;
654 std::cout <<
"EMJetVal::End(PHCompositeNode *topNode) This is the End..." << std::endl;
668 std::cout <<
"EMJetVal::Print(const std::string &what) const Printing info for " << what << std::endl;