![]() |
|
|||
File indexing completed on 2025-08-06 08:12:32
0001 // #include <TFile.h> 0002 // #include <TTree.h> 0003 // #include <TDirectory.h> 0004 0005 // // #include "InttEvent.cc" 0006 // #include "ReadINTTDSTv1.C" 0007 // #include "MBDReaderV2.C" 0008 0009 // #include <iostream> 0010 0011 // //R__LOAD_LIBRARY(libInttEvent.so) 0012 0013 // void sync_mbd_intt_DST() 0014 // { 0015 // Int_t evt; 0016 // Short_t bns, bnn; 0017 // UShort_t clk, femclk; 0018 // Float_t bqs, bqn, bts, btn, bz, bt0; 0019 0020 0021 // TDirectory* gDir = gDirectory; 0022 // /////////// 0023 // // 0024 0025 // TFile *f_mbd = TFile::Open("/gpfs/mnt/gpfs02/sphenix/user/cdean/software/analysis/dNdEta_Run2023/macros/centrality_run20869.root"); 0026 // gDirectory=gDir; 0027 0028 // TTree *t_mbd = (TTree*)f_mbd->Get("EventTree"); 0029 // cout<<" "<<t_mbd<<endl; 0030 // if(!t_mbd) return ; 0031 0032 // MBDReaderV2 mbdt(t_mbd); 0033 // cout<<"test1"<<endl; 0034 // //t_mbd->SetBranchAddress("evt", &evt); 0035 // //t_mbd->SetBranchAddress("bns", &bns); 0036 // //t_mbd->SetBranchAddress("bnn", &bnn); 0037 // //t_mbd->SetBranchAddress("clk", &clk); 0038 // //t_mbd->SetBranchAddress("femclk", &femclk); 0039 // //t_mbd->SetBranchAddress("bqs", &bqs); 0040 // //t_mbd->SetBranchAddress("bqn", &bqn); 0041 // //t_mbd->SetBranchAddress("bts", &bts); 0042 // //t_mbd->SetBranchAddress("btn", &btn); 0043 // //t_mbd->SetBranchAddress("bz", &bz); 0044 // //t_mbd->SetBranchAddress("bt0", &bt0); 0045 0046 // /////////////////// 0047 // TFile *f_intt = TFile::Open("/gpfs/mnt/gpfs02/sphenix/user/cdean/software/analysis/dNdEta_Run2023/macros/intt_run20869.root"); 0048 // gDirectory=gDir; 0049 // TTree *t_intt = (TTree*)f_intt->Get("EventTree"); 0050 // cout<<" "<<t_intt<<endl; 0051 // if(!t_intt) return ; 0052 0053 // // InttEvent* inttEvt; 0054 // // t_intt->SetBranchAddress("event", &inttEvt); 0055 0056 // ReadINTTDSTv1 * inttEvt = new ReadINTTDSTv1(t_intt); 0057 0058 0059 // cout<<t_mbd->GetEntries()<<" "<<t_intt->GetEntries()<<endl; 0060 // //cout<<t_mbd->GetEntries()<<endl; 0061 0062 // gDirectory = gDir; 0063 0064 // TH2F *h_qmbd_nintt = new TH2F("h_qmbd_nintt", "BbcQ vs Intt N", 200, 0, 20000, 200, 0, 4000); 0065 // TH2F *intt_mbd_bco = new TH2F("intt_mbd_bco", "INTT - MBD", 100, 0, 600000, 100, -10, 100000); 0066 // // TH2F *intt_mbd_bco = new TH2F("intt_mbd_bco", "INTT - MBD", 100, 0, 10000, 100, -10, 100000); 0067 // intt_mbd_bco->GetXaxis()->SetTitle("evt"); 0068 // intt_mbd_bco->GetYaxis()->SetTitle("clock_diff"); 0069 0070 // TH1F *intt_mbd_bco_1D = new TH1F("intt_mbd_bco_1D", "INTT - MBD", 100, -10, 100000); 0071 // intt_mbd_bco_1D->GetXaxis()->SetTitle("clock_diff"); 0072 // intt_mbd_bco_1D->GetYaxis()->SetTitle("entry"); 0073 0074 // int prev_mbdclk = 0; 0075 // ULong64_t prev_bco = 0; 0076 0077 // bool found_firstevt=false; 0078 // int mbd_evt_offset = 0; 0079 // int intt_evt_offset = 0; 0080 // for(int i=0; i< t_mbd -> GetEntries(); i++){ 0081 // mbdt.LoadTree(i+mbd_evt_offset); 0082 // mbdt.GetEntry(i+mbd_evt_offset); 0083 0084 // int INTT_evtseq = inttEvt->event_counter; 0085 // int MBD_evtseq = mbdt.event; 0086 // // cout<<evtseq<<endl; 0087 // // if(evtseq==0) found_firstevt=true; 0088 // // if(!found_firstevt){ 0089 // // continue; 0090 // // } 0091 // // 0092 0093 // // int mbdevt = evtseq = mbd_evt_offset; 0094 // // cout<<"mbd: "<<mbdevt<<endl; 0095 // // mbdt.LoadTree(mbdevt); 0096 // // mbdt.GetEntry(mbdevt); 0097 0098 0099 0100 // t_intt->GetEntry(i+intt_evt_offset); 0101 0102 // // if((i%100)==0){ 0103 // // cout<<i<<" mbd: " <<mbdt.evt<<" "<<hex<<mbdt.clk<<" "<<mbdt.femclk<<dec<<" "<<mbdt.bns<<" "<<mbdt.bnn 0104 // // <<" "<<mbdt.bqs<<" "<<mbdt.bqn<<" "<<mbdt.bz<<endl; 0105 // // cout<<"intt: "<<inttEvt->evtSeq<<" "<<hex<<inttEvt->bco<<dec<<" "<<inttEvt->fNhits<<endl; 0106 // // cout<<endl; 0107 // // } 0108 0109 // float bbcq = mbdt.MBD_charge_sum; 0110 // float nintt = inttEvt->NClus; 0111 0112 // unsigned short mbdclk = mbdt.femclk; 0113 // ULong64_t bco = inttEvt->INTT_BCO; 0114 // ULong64_t bco16 = bco&0xFFFF; 0115 0116 // int mbd_prvdif = (mbdclk-prev_mbdclk)&0xFFFF; 0117 // ULong64_t intt_prvdif = bco-prev_bco; 0118 0119 // if((i%1000)==0){cout<<i<<" "<<hex<<setw(6)<<mbdclk<<" "<<setw(6)<<bco16<<" (mbd-intt)"<<setw(6)<<((mbdclk-bco16)&0xFFFF) 0120 // <<" (femclk-prev)"<<setw(6)<<mbd_prvdif<<" (bco-prev)"<<setw(6)<<intt_prvdif<<dec<<" INTT Evt: "<<INTT_evtseq<<" MBD Evt: "<<MBD_evtseq<<endl;} 0121 0122 0123 // if (mbdt.MBD_south_charge_sum > 200 && mbdt.MBD_north_charge_sum > 200) 0124 // h_qmbd_nintt->Fill(nintt, bbcq); 0125 0126 // intt_mbd_bco -> Fill(i,(mbdclk-bco16)&0xFFFF); 0127 // intt_mbd_bco_1D -> Fill((mbdclk-bco16)&0xFFFF); 0128 0129 // prev_mbdclk = mbdclk; 0130 // prev_bco = bco; 0131 0132 // t_intt->GetEntry(i+1+intt_evt_offset); 0133 // ULong64_t next_bco16 = (inttEvt->INTT_BCO)&0xFFFF; 0134 // mbdt.LoadTree(i+1); 0135 // mbdt.GetEntry(i+1); 0136 // unsigned short next_mbdclk = mbdt.femclk; 0137 // if ( ((next_mbdclk-next_bco16)&0xFFFF) != ((mbdclk-bco16)&0xFFFF)) intt_evt_offset += 1; 0138 0139 // // if (i == 7012) intt_evt_offset += 1; 0140 0141 // // if(i>200000) break; 0142 // } 0143 0144 0145 // TFile* froot = new TFile("/sphenix/user/ChengWei/DST_test_sync.root", "recreate"); 0146 // h_qmbd_nintt->Write(); 0147 // intt_mbd_bco->Write(); 0148 // intt_mbd_bco_1D->Write(); 0149 // froot->Close(); 0150 0151 0152 0153 0154 0155 // /* 0156 0157 // t->Draw("bz") 0158 // t->Draw("bz","abs(bz)<500") 0159 // t->Draw("bz>>h(500,-500,500)","abs(bz)<500") 0160 // t->Draw("bz>>h(2000,-500,500)","abs(bz)<500") 0161 // t->Scan("evt:femclk") 0162 // t->Scan("evt:femclk:clk") 0163 // tree->Scan("evtSeq:bco&0xFFFF") 0164 // .q 0165 // TFile *_file0 = TFile::Open("/sphenix/user/chiu/sphenix_bbc/run2023/beam_mbd-00020708-0000_mbd.root") 0166 // t->Print() 0167 // t->Draw("qs") 0168 // t->Draw("bqs:bqn") 0169 // t->Draw("bqs:bqn","","colz") 0170 // t->Draw("bqs:bqn>>h(200,0,2000,200,0,2000)","","colz") 0171 // t->Draw("bqs+bqn:evt>>h(200,0,200,100,0,2000)","evt<200") 0172 // tree->Scan("fNhits:evtSeq","evtSeq<100") 0173 // tree->Draw("fNhits:evtSeq","evtSeq<100") 0174 // .q 0175 // TFile *_file0 = TFile::Open("../../../../INTT/INTT/general_codes/hachiya/InttEventSync/beam_inttall-00020708-0000_event_base_ana.root") 0176 // tree->Draw("fNhits:evtSeq","evtSeq<100") 0177 // tree->SetMarkerStyle(20) 0178 // tree->Draw("fNhits:evtSeq","evtSeq<100") 0179 // t->Draw("bns+bnn:evt>>h(200,0,200,128,0,128)","evt<200") 0180 // t->Draw("bqs+bqn:evt>>h(200,0,200,100,0,2000)","evt<200") 0181 // t->Draw("bns+bnn:evt>>h(200,0,200,128,0,128)","evt<200") 0182 // t->Draw("bqs+bqn:evt>>h(200,0,200,100,0,2000)","evt<200") 0183 // .q 0184 // TFile *_file0 = TFile::Open("AnaTutorial.root") 0185 // ntp_cluspair->Draw("ang1-ang2:ang1>>h(300,-3,3,400, -0.5, 0.5)","nclus2<200","colz") 0186 // .q 0187 // TFile *_file0 = TFile::Open("AnaTutorial_run20869_newgeo.root") 0188 // ntp_cluspair->Draw("vy:vx>>h(200,-1,1,200, -1, 1","nclus2<200","colz") 0189 // ntp_cluspair->Draw("vy:vx>>h(200,-1,1,200, -1, 1","nclus2<200&&abs(ang1)<1.5","colz") 0190 // ntp_cluspair->Draw("vy:vx>>h1(200,-1,1,200, -1, 1","nclus2<200&&abs(ang1)>1.5","colz") 0191 // ntp_cluspair->Draw("vy:vx>>h(200,-1,1,200, -1, 1","nclus2<200&&abs(ang1)<1.5","colz") 0192 // ntp_cluspair->Draw("vy:vx>>h1(200,-1,1,200, -1, 1","nclus2<200&&abs(ang1)>1.5","colz") 0193 // ntp_clus->Draw("z") 0194 // c1->cd() 0195 // ntp_cluspair->Draw("vy:vx>>h(200,-1,1,200, -1, 1","nclus2<200&&abs(ang1)<1.5&&abs(ang1-ang2)<0.1","colz") 0196 // c1_n2->cd() 0197 // ntp_cluspair->Draw("vy:vx>>h(200,-1,1,200, -1, 1","nclus2<200&&abs(ang1)>1.5&&abs(ang1-ang2)<0.1","colz") 0198 // ntp_cluspair->Draw("vy:vx>>h1(200,-1,1,200, -1, 1","nclus2<200&&abs(ang1)>1.5&&abs(ang1-ang2)<0.1","colz") 0199 // c1->Cd() 0200 // c1->cd() 0201 // ntp_cluspair->Draw("vy:vx>>h(200,-1,1,200, -1, 1","nclus2<200&&abs(ang1)<1.5&&abs(ang1-ang2)<0.1","colz") 0202 // */ 0203 // } 0204 0205 0206 #include <TFile.h> 0207 #include <TTree.h> 0208 #include <TDirectory.h> 0209 #include <iostream> 0210 0211 0212 void sync_mbd_intt_DST() 0213 { 0214 0215 0216 0217 TDirectory* gDir = gDirectory; 0218 0219 TFile *f_mbd = TFile::Open("/gpfs/mnt/gpfs02/sphenix/user/cdean/software/analysis/dNdEta_Run2023/macros/centrality_run20869.root"); 0220 gDirectory=gDir; 0221 0222 TTree *t_mbd = (TTree*)f_mbd->Get("EventTree"); 0223 cout<<" "<<t_mbd<<" Entry: "<<t_mbd -> GetEntries()<<endl; 0224 if(!t_mbd) return ; 0225 0226 0227 Int_t MBD_event; 0228 UShort_t femclk; 0229 Float_t MBD_south_charge_sum; 0230 Float_t MBD_north_charge_sum; 0231 0232 t_mbd->SetBranchAddress("femclk", &femclk); 0233 t_mbd->SetBranchAddress("event", &MBD_event); 0234 t_mbd->SetBranchAddress("MBD_north_charge_sum", &MBD_north_charge_sum); 0235 t_mbd->SetBranchAddress("MBD_south_charge_sum", &MBD_south_charge_sum); 0236 0237 TFile *f_intt = TFile::Open("/gpfs/mnt/gpfs02/sphenix/user/cdean/software/analysis/dNdEta_Run2023/macros/intt_run20869.root"); 0238 gDirectory=gDir; 0239 TTree *t_intt = (TTree*)f_intt->Get("EventTree"); 0240 cout<<" "<<t_intt<<" Entry: "<<t_intt->GetEntries()<<endl; 0241 if(!t_intt) return; 0242 0243 Int_t INTT_event_counter; 0244 ULong_t INTT_BCO; 0245 Int_t NClus; 0246 t_intt->SetBranchAddress("NClus", &NClus); 0247 t_intt->SetBranchAddress("INTT_BCO", &INTT_BCO); 0248 t_intt->SetBranchAddress("event_counter", &INTT_event_counter); 0249 0250 gDirectory = gDir; 0251 0252 TH2F *h_qmbd_nintt = new TH2F("h_qmbd_nintt", "BbcQ vs Intt N", 200, 0, 20000, 200, 0, 4000); 0253 TH2F *intt_mbd_bco = new TH2F("intt_mbd_bco", "INTT - MBD", 100, 0, 600000, 100, -10, 100000); 0254 intt_mbd_bco->GetXaxis()->SetTitle("evt"); 0255 intt_mbd_bco->GetYaxis()->SetTitle("clock_diff"); 0256 0257 TH1F *intt_mbd_bco_1D = new TH1F("intt_mbd_bco_1D", "INTT - MBD", 100, -10, 100000); 0258 intt_mbd_bco_1D->GetXaxis()->SetTitle("clock_diff"); 0259 intt_mbd_bco_1D->GetYaxis()->SetTitle("entry"); 0260 0261 int prev_mbdclk = 0; 0262 ULong64_t prev_bco = 0; 0263 0264 bool found_firstevt=false; 0265 int mbd_evt_offset = 0; 0266 int intt_evt_offset = 0; 0267 for(int i=0; i< 10000; i++){ 0268 t_mbd->GetEntry(i+mbd_evt_offset); 0269 0270 int INTT_evtseq = INTT_event_counter; 0271 int MBD_evtseq = MBD_event; 0272 0273 0274 0275 t_intt->GetEntry(i+intt_evt_offset); 0276 0277 0278 float bbcq = MBD_north_charge_sum + MBD_south_charge_sum; 0279 float nintt = NClus; 0280 0281 unsigned short mbdclk = femclk; 0282 ULong64_t bco = INTT_BCO; 0283 ULong64_t bco16 = bco&0xFFFF; 0284 0285 int mbd_prvdif = (mbdclk-prev_mbdclk)&0xFFFF; 0286 ULong64_t intt_prvdif = bco-prev_bco; 0287 0288 if((i%1000)==0){cout<<i<<" "<<hex<<setw(6)<<mbdclk<<" "<<setw(6)<<bco16<<" (mbd-intt)"<<setw(6)<<((mbdclk-bco16)&0xFFFF) 0289 <<" (femclk-prev)"<<setw(6)<<mbd_prvdif<<" (bco-prev)"<<setw(6)<<intt_prvdif<<dec<<" INTT Evt: "<<INTT_evtseq<<" MBD Evt: "<<MBD_evtseq<<endl;} 0290 0291 0292 if (MBD_south_charge_sum > 200 && MBD_north_charge_sum > 200) 0293 h_qmbd_nintt->Fill(nintt, bbcq); 0294 0295 intt_mbd_bco -> Fill(i,(mbdclk-bco16)&0xFFFF); 0296 intt_mbd_bco_1D -> Fill((mbdclk-bco16)&0xFFFF); 0297 0298 prev_mbdclk = mbdclk; 0299 prev_bco = bco; 0300 0301 t_intt->GetEntry(i+1+intt_evt_offset); 0302 ULong64_t next_bco16 = (INTT_BCO)&0xFFFF; 0303 t_mbd -> GetEntry(i+1); 0304 unsigned short next_mbdclk = femclk; 0305 if ( ((next_mbdclk-next_bco16)&0xFFFF) != ((mbdclk-bco16)&0xFFFF)) intt_evt_offset += 1; 0306 0307 } 0308 0309 0310 TFile* froot = new TFile("/sphenix/user/ChengWei/DST_test_sync_test.root", "recreate"); 0311 h_qmbd_nintt->Write(); 0312 intt_mbd_bco->Write(); 0313 intt_mbd_bco_1D->Write(); 0314 froot->Close(); 0315 }
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |