BOSS 7.0.6
BESIII Offline Software System
Loading...
Searching...
No Matches
prepare_data.cxx File Reference
#include "TCanvas.h"
#include "TFile.h"
#include "TTree.h"
#include "TH1F.h"
#include <sstream>
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <cmath>
#include "TCut.h"

Go to the source code of this file.

Macros

#define mass_e   0.511e-3
 
#define mass_mu   105.658e-3
 
#define mass_pi   139.570e-3
 
#define mass_k   493.677e-3
 
#define mass_p   938.272e-3
 

Functions

void collect (TString filename, int type, TTree *tree)
 
void setregion ()
 
int main ()
 

Variables

float ptrk
 
float dEdx_meas
 
float costheta
 
float charge
 
float bg
 
float mass
 
int nhits
 
float dEdx_hit [100]
 

Macro Definition Documentation

◆ mass_e

#define mass_e   0.511e-3

Definition at line 22 of file prepare_data.cxx.

◆ mass_k

#define mass_k   493.677e-3

Definition at line 25 of file prepare_data.cxx.

◆ mass_mu

#define mass_mu   105.658e-3

Definition at line 23 of file prepare_data.cxx.

◆ mass_p

#define mass_p   938.272e-3

Definition at line 26 of file prepare_data.cxx.

◆ mass_pi

#define mass_pi   139.570e-3

Definition at line 24 of file prepare_data.cxx.

Function Documentation

◆ collect()

void collect ( TString  filename,
int  type,
TTree *  tree 
)

Definition at line 66 of file prepare_data.cxx.

66 {
67 TFile *ff = new TFile(filename);
68 TTree* trk = (TTree*)ff->Get("n103");
69 trk->SetBranchAddress("dEdx_meas", &dEdx_meas);
70 trk->SetBranchAddress("ptrk", &ptrk);
71 trk->SetBranchAddress("costheta", &costheta);
72 trk->SetBranchAddress("charge", &charge);
73 trk->SetBranchAddress("ndedxhit", &nhits);
74 trk->SetBranchAddress("dEdx_hit", dEdx_hit);
75
76 //initialize variables
77 switch (type) {
78 case 0:
79 mass = mass_p;
80 break;
81 case 1:
82 mass = mass_k;
83 break;
84 case 2:
85 mass = mass_pi;
86 break;
87 case 3:
88 mass = mass_mu;
89 break;
90 case 4:
91 mass = mass_e;
92 break;
93 default:
94 cout << "Error: no such sample type!" << endl;
95 }
96
97 int m_ntot = trk->GetEntries();
98 // if(m_ntot>500000) m_ntot = 500000;
99 for (int i = 0; i < m_ntot; i++){
100 trk->GetEntry(i);
101 if (type == 0 && dEdx_meas < 500) continue; // type 0 is proton!
102 if (type == 4 && dEdx_meas > 1200) continue; // type 4 is electron!
103 if(ptrk <= 0 || ptrk > 2.3) continue;
104 if(fabs(costheta) >= 0.93) continue;
105 bg = ptrk/mass;
106 t->Fill();
107 }
108 ff->Close();
109}// end of collect()
********INTEGER modcns REAL m_twom24 INTEGER m_ntot
Definition: PseuMar.h:14
TTree * t
Definition: binning.cxx:23
int nhits
float costheta
float charge
#define mass_mu
#define mass_e
float mass
#define mass_p
float dEdx_meas
#define mass_k
float bg
#define mass_pi
float ptrk
float dEdx_hit[100]

Referenced by main().

◆ main()

int main ( )

Definition at line 34 of file prepare_data.cxx.

34 {
35 TFile *f = new TFile("pre_data.root","recreate");
36 TTree *t = new TTree("n103","predata");
37 t->Branch("dEdx_meas", &dEdx_meas, "dEdx_meas/f");
38 t->Branch("costheta", &costheta, "costheta/f");
39 t->Branch("charge", &charge, "charge/f");
40 t->Branch("bg", &bg, "bg/f");
41 t->Branch("nhits", &nhits, "nhits/I");
42 t->Branch("dEdx_hit", dEdx_hit, "dEdx_hit[nhits]/f");
43
44 // collect all data here
45 cout << "begin to collect data" << endl;
46 collect("../hadron_track/proton/proton.root", 0, t);
47 cout << "proton collected" << endl;
48 collect("../hadron_track/kaon/kaon.root", 1, t);
49 cout << "kaon collected" << endl;
50 collect("../hadron_track/pion/pion.root", 2, t);
51 cout << "pion collected" << endl;
52 collect("../hadron_track/muon/muon.root", 3, t);
53 cout << "muon collected" << endl;
54 collect("../hadron_track/electron/electron.root", 4, t);
55 cout << "electron collected" << endl;
56
57 f->cd();
58 t->Write();
59 f->Close();
60
61 // setregion();
62
63 return 0;
64}
TFile f("ana_bhabha660a_dqa_mcPat_zy_old.root")
void collect(TString filename, int type, TTree *tree)

◆ setregion()

void setregion ( )

Definition at line 111 of file prepare_data.cxx.

111 { // use greedy algorithm, step by step to check
112 TFile *f = new TFile("pre_data.root");
113 TTree *t = (TTree*)f->Get("n103");
114 bool small_flag(true);
115 double step(0.1); // for beta-gamma
116 double current(0.0); // current position in beta-gamma
117 int accu(0); // accumulated events
118 double stop(4600);
119 int threshold(1000);
120 while(current<stop){
121 cout << "now: " << current << endl;
122 if(small_flag){
123 accu = t->GetEntries(Form("bg>=%f && bg<%f", current, current+step));
124 current += step;
125 if(accu > threshold){
126 cout << "point: " << current << " events: " << accu << endl;
127 small_flag = false;
128 }
129 }// end of if(small_flag)
130 else{
131 accu = t->GetEntries(Form("bg>=%f && bg<%f", current, current+step));
132 current += step;
133 if(accu < threshold){
134 cout << "point: " << current << " events: " << accu << endl;
135 small_flag = true;
136 }
137 }// end of else(small_flag)
138 }// end of while
139 f->Close();
140}

Variable Documentation

◆ bg

◆ charge

float charge

Definition at line 28 of file prepare_data.cxx.

Referenced by Pdt::addParticle(), FastVertexFit::addTrack(), BesTofDigitizerEcV4::StripStruct::avalanche(), HadronPrep::bgFits(), BesTofDigitizerBrV2::BirksLaw(), BesTofDigitizerEcV3::BirksLaw(), KalmanKinematicFit::BuildVirtualParticle(), KinematicFit::BuildVirtualParticle(), VertexFit::BuildVirtualParticle(), MdcUtilitySvc::cellTrackPassed(), collect(), BesEvent::ConstructMdcTrackFromRec(), BesEvent::ConstructMucTrackFromRec(), HoughHitList::continousHit(), EmcDigiCnv::DataObjectToTObject(), MdcDigiCnv::DataObjectToTObject(), MucDigiCnv::DataObjectToTObject(), TofDigiCnv::DataObjectToTObject(), HltRawCnv::DataObjectToTObject(), EvtBsquark::decay(), Dedx_Helix::Dedx_Helix(), CDChargedVisible< H >::defaultKinematicData(), VFHelix::del4MDelA(), Dedx_Helix::del4MDelA(), KalmanFit::Helix::del4MDelA(), Helix::del4MDelA(), Ext_Helix::del4MDelA(), VFHelix::del4MXDelA(), Dedx_Helix::del4MXDelA(), KalmanFit::Helix::del4MXDelA(), Helix::del4MXDelA(), Ext_Helix::del4MXDelA(), VFHelix::delMDelA(), Dedx_Helix::delMDelA(), KalmanFit::Helix::delMDelA(), Helix::delMDelA(), Ext_Helix::delMDelA(), BesTofDigitizerEcV4::Digitize(), TPerfectFinder::doit(), RawDataUtil::EmcChargeChannel(), RawDataUtil::EmcChargeMeasure(), DQADtag::execute(), BhabhaPreSelect::execute(), EventPreSelect::execute(), CosmicGenerator::execute(), EsTimeAlg::execute(), KalFitAlg::execute(), MdcDedxRecon::execute(), MucRecTrkExt::execute(), TrkExtAlg::execute(), FarmMonitorAlg::execute(), Ext_Helix::Ext_Helix(), TofCheckData::Fill(), DedxCalibCostheta::FillHists(), DedxCalibDocaEAng::FillHists(), DedxCalibEAng::FillHists(), DedxCalibMomentum::FillHists(), DedxCalibTzero::FillHists(), KalFitAlg::fillTds_ip(), SecondVertexFit::Fit(), Pdt::geantId(), DedxCalibEvent::genNtuple(), RecMucTrack::GetMdcExtTrack(), utility::getp4(), KalmanFit::Helix::Helix(), Helix::Helix(), histgen(), HoughMap::HoughMap(), HoughPeak::HoughPeak(), BesTofDigitizerEcV4::StripStruct::initial(), TRawData::initialize(), MdcDedxRecon::kaltrackrec(), Pdt::lookup(), Pdt::lundId(), main(), TTrackManager::makeTds(), RawDataUtil::MdcChargeChannel(), MdcDedxRecon::mdctrackrec(), DTagTool::p4(), DedxCorrecSvc::PathL(), Pdt::pdgId(), BesTofDigitizerEcV4::StripStruct::print(), BesMdcSD::ProcessHits(), BesTofSD::ProcessHits(), KinematicFit::pull(), RootRawEvtReader::readEmc(), Pdt::readMCppTable(), RootRawEvtReader::readMdc(), RootRawEvtReader::readMuc(), RootRawEvtReader::readTof(), McTestAlg::RetrieveTof(), ChargedDReconstruction::saveDpInfo(), DsReconstruction::saveDsInfo(), BesRawDataWriter::SaveEmcDigits(), LambdaCReconstruction::saveLcInfo(), BesRawDataWriter::SaveMdcDigits(), BesRawDataWriter::SaveTofDigits(), Emc2DCrystal::SetCharge(), Mdc2DWire::SetCharge(), Tof2DScin::SetCharge(), BesTofHit::SetCharge(), Event::McTrajectory::setCharge(), Hough2D::setCharge(), Hough3D::setCharge(), HoughTrack::setCharge(), TMcHitTof::SetCharge(), BesGeoTrack::SetCharge(), EmcROOTGeo::SetHits(), MdcROOTGeo::SetHits(), TofROOTGeo::SetHits(), Event::EmcMcHit::setPDGCharge(), BesEmcTruthHit::SetPDGCharge(), BesTruthTrack::SetPDGCharge(), EmcDigiCnv::TObjectToDataObject(), MdcDigiCnv::TObjectToDataObject(), MucDigiCnv::TObjectToDataObject(), TofDigiCnv::TObjectToDataObject(), MdcKalTrackCnv::TObjectToDataObject(), MdcTrackCnv::TObjectToDataObject(), HltRawCnv::TObjectToDataObject(), RecMdcKalTrackCnv::TObjectToDataObject(), RecMdcTrackCnv::TObjectToDataObject(), RawDataUtil::TofChargeChannel(), Track2Helix(), VFHelix::VFHelix(), and KalmanVertexFit::wTrack().

◆ costheta

float costheta

Definition at line 28 of file prepare_data.cxx.

Referenced by AngularSam::amps(), EvtPsi3Sdecay::AngSam(), EvtRexc::angularSampling(), EvtConExc::angularSampling(), EvtNT3::AR1(), EvtNT3::AR2(), EvtNT3::AR3(), EvtConExc::baryon_sampling(), DedxCorrecSvc::CellCorrec(), collect(), KalFitAlg::complete_track(), DedxCorrecSvc::CosthetaCorrec(), EvtAngSam::decay(), EvtAngSam3::decay(), EvtAngSamLab::decay(), EvtAngSamX::decay(), EvtHAngSam3::decay(), EvtJ2BB1::decay(), BesTofDigitizerBrV2::DirectPh(), McCor::execute(), DQA_EMC::execute(), DQA_MUC::execute(), MdcDedxRecon::execute(), SD0Tag::execute(), TofRec::execute(), f_real_work(), DedxCalibCostheta::FillHists(), DedxCalibDocaEAng::FillHists(), DedxCalibEAng::FillHists(), DedxCalibLayerGain::FillHists(), DedxCalibMomentum::FillHists(), DedxCalibRunByRun::FillHists(), DedxCalibTzero::FillHists(), DedxCalibWireGain::FillHists(), DedxSaveWireGain::FillHists(), EvtConExc::findMaxXS(), BesPrimaryGeneratorAction::GeneratePrimaries(), DedxCalibEvent::genNtuple(), DedxCorrecSvc::HadronCorrec(), ElectronCorrection::HadronCorrection(), histgen(), DTagTool::isGoodTrack(), DSemilepAlg::isGoodTrack(), DTagTool::isGoodTrack_loose(), EvtConExc::ISR_ang_integrate(), KalFitAlg::kalman_fitting_anal(), KalFitAlg::kalman_fitting_calib(), KalFitAlg::kalman_fitting_csmalign(), KalFitAlg::kalman_fitting_MdcxReco_Csmc_Sew(), MdcDedxRecon::kaltrackrec(), DedxCorrecSvc::LayerCorrec(), main(), MdcDedxRecon::mdctrackrec(), EvtConExc::meson_sampling(), EvtRexc::meson_sampling(), LocalKaonSelector::operator()(), LocalPionSelector::operator()(), LocalProtonSelector::operator()(), EvtConExc::photonSampling(), DedxCorrecSvc::SaturCorrec(), TofTrack::setExtTrack(), DedxCorrecSvc::StandardCorrec(), DedxCorrecSvc::StandardHitCorrec(), DedxCorrecSvc::StandardTrackCorrec(), t(), EvtConExc::VP_sampling(), and EvtRexc::VP_sampling().

◆ dEdx_hit

float dEdx_hit[100]

Definition at line 30 of file prepare_data.cxx.

Referenced by collect(), DedxCalibEvent::genNtuple(), and main().

◆ dEdx_meas

float dEdx_meas

◆ mass

float mass

Definition at line 28 of file prepare_data.cxx.

Referenced by collect().

◆ nhits

◆ ptrk

float ptrk

Definition at line 28 of file prepare_data.cxx.

Referenced by TrackPool::AddMissTrack(), TrackPool::AddTrack(), TrackPool::AddTrackVertex(), DedxPID::cal_par(), collect(), DedxPID::CorrDedx(), event_validate(), Gam4pikp::execute(), Ppjrhopi::execute(), PipiJpsi::execute(), Rhopi::execute(), DQADtag::execute(), inclks::execute(), inclkstar::execute(), incllambda::execute(), inclphi::execute(), DQAJpsi2PPbarAlg::execute(), DQAKsKpi::execute(), DQAKsKpiDEDX::execute(), DQAPi2p2::execute(), DQARhopi::execute(), DQASelBhabha::execute(), DQASelDimu::execute(), DQASelHadron::execute(), EmcSelBhaEvent::execute(), CalibEventSelect::execute(), EventPreSelect::execute(), MdcDedxRecon::execute(), DedxCalibCostheta::FillHists(), DedxCalibDocaEAng::FillHists(), DedxCalibEAng::FillHists(), DedxCalibLayerGain::FillHists(), DedxCalibMomentum::FillHists(), DedxCalibTzero::FillHists(), DedxCalibWireGain::FillHists(), DedxSaveWireGain::FillHists(), DedxCalibEvent::genNtuple(), EmcBhabhaEvent::getDepoMCShowerEnergy_lab(), getP4(), histgen(), MucPID::init(), DTagTool::isMuon(), DedxPID::iterate(), Tof1PID::offsetTof1(), Tof2PID::offsetTof2(), TofCPID::offsetTofC(), TofEPID::offsetTofE(), HTrackParameter::p(), DedxPID::particleIDCalculation(), EmcPID::particleIDCalculation(), MucPID::particleIDCalculation(), Tof1PID::particleIDCalculation(), Tof2PID::particleIDCalculation(), TofCorrPID::particleIDCalculation(), TofCPID::particleIDCalculation(), TofEPID::particleIDCalculation(), DedxCalib::set_dEdx(), TofCPID::sigmaTofC(), TofEPID::sigmaTofE(), and HTrackParameter::wTrack().