BOSS 7.1.0
BESIII Offline Software System
Loading...
Searching...
No Matches
DedxSaveWireGain.cxx
Go to the documentation of this file.
1#include "GaudiKernel/MsgStream.h"
2
3#include <sstream>
4#include <string>
5#include "TTree.h"
6#include "TH1F.h"
7#include "TF1.h"
8#include "TFile.h"
9#include "TStyle.h"
10#include "TCanvas.h"
11
13DECLARE_COMPONENT(DedxSaveWireGain)
14using namespace std;
15
16DedxSaveWireGain::DedxSaveWireGain(const std::string& name, ISvcLocator* pSvcLocator): DedxCalib(name, pSvcLocator){
17 declareProperty("PMin", pMin=0.2);
18 declareProperty("PMax", pMax=2.3);
19 f_save = new TFile("wiregain.root", "recreate");
20 m_wiregain = new TTree("wiregain", "wiregain");
21}
22
23
25{
26 MsgStream log(msgSvc(), name());
27 log<<MSG::INFO<<"DedxSaveWireGain::BookHists()"<<endreq;
28
30}
31
33{
34 MsgStream log(msgSvc(), name());
35 log<<MSG::INFO<<"DedxSaveWireGain::FillHists()"<<endreq;
36 int run, evt;
37 double gain;
38 m_wiregain->Branch("run", &run, "run/I");
39 m_wiregain->Branch("evt", &evt, "evt/I");
40 m_wiregain->Branch("gain", &gain, "gain/D");
41
42 TFile* f;
43 TTree* n102;
44 string runlist;
45
46 double dedx=0;
47 float runNO=0,evtNO=0,runFlag=0,pathlength=0,wid=0,layid=0,dd_in=0,driftdist=0,eangle=0,zhit=0,costheta=0,tes=0,ptrk=0;
48 cout<<"m_recFileVector.size()= "<<m_recFileVector.size()<<endl;
49 for(int i=0; i<m_recFileVector.size(); i++)
50 {
51 runlist = m_recFileVector[i];
52 cout<<"runlist: "<<runlist.c_str()<<endl;
53 f = new TFile(runlist.c_str());
54 n102 = (TTree*)f->Get("n102");
55 n102-> SetBranchAddress("adc_raw",&dedx);
56 n102-> SetBranchAddress("path_rphi",&pathlength);
57 n102-> SetBranchAddress("wire",&wid);
58 n102-> SetBranchAddress("layer",&layid);
59 n102-> SetBranchAddress("doca_in",&dd_in);
60 n102-> SetBranchAddress("driftdist",&driftdist);
61 n102-> SetBranchAddress("eangle",&eangle);
62 n102-> SetBranchAddress("zhit",&zhit);
63 n102-> SetBranchAddress("runNO",&runNO);
64 n102-> SetBranchAddress("evtNO",&evtNO);
65 n102-> SetBranchAddress("runFlag",&runFlag);
66 n102-> SetBranchAddress("costheta1",&costheta);
67 n102-> SetBranchAddress("t01",&tes);
68 n102->SetBranchAddress("ptrk1",&ptrk);
69
70 cout <<"entries in this file" << n102->GetEntries() << endl;
71 for(int j=0;j<n102->GetEntries();j++)
72 {
73 n102->GetEntry(j);
74 if(tes>1400) continue;
75 if(ptrk>pMax || ptrk<pMin) continue;
76 if(layid <8)
77 {if(dedx<MinADCValuecut || dedx>MaxADCValuecut || pathlength>RPhi_PathMaxCut || pathlength<Iner_RPhi_PathMinCut || driftdist>Iner_DriftDistCut) continue;}
78 else
79 {if(dedx<MinADCValuecut || dedx>MaxADCValuecut || pathlength>RPhi_PathMaxCut || pathlength<Out_RPhi_PathMinCut || driftdist>Out_DriftDistCut) continue;}
80 dedx = exsvc->StandardHitCorrec(0,runFlag,2,runNO,evtNO,pathlength,wid,layid,dedx,dd_in,eangle,costheta);
81 dedx = exsvc->StandardTrackCorrec(0, runFlag, 2, runNO, evtNO, dedx, costheta, tes);
82 run = (int)runNO;
83 evt = (int)evtNO;
84 gain = dedx;
85 // cout << "run " << run << " evt " << evt << " gain " << gain << endl;
86 m_wiregain->Fill();
87 }// end of loop in n102 entries
88 }// end of loop in rec files
89}// end of this function
90
91
93{
94 f_save->cd();
95 m_wiregain->Write();
96 f_save->Save();
97 f_save->Close();
98}
TFile f("ana_bhabha660a_dqa_mcPat_zy_old.root")
data SetBranchAddress("time",&time)
#define MaxADCValuecut
#define Iner_DriftDistCut
#define RPhi_PathMaxCut
#define Out_DriftDistCut
IMessageSvc * msgSvc()
void ReadRecFileList()
Definition: DedxCalib.cxx:89
IDedxCorrecSvc * exsvc
Definition: DedxCalib.h:30
vector< string > m_recFileVector
Definition: DedxCalib.h:48
DedxSaveWireGain(const std::string &name, ISvcLocator *pSvcLocator)
virtual double StandardHitCorrec(int calib_rec_Flag, int runFlag, int ntpFlag, int runNO, int evtNO, double pathl, int wid, int layid, double adc, double dd, double eangle, double costheta) const =0
virtual double StandardTrackCorrec(int calib_rec_Flag, int typFlag, int ntpFlag, int runNO, int evtNO, double ex, double costheta, double t0) const =0
float costheta
float ptrk