Attachment 6: |
PlotRIBF.C
#include <bitset>
#include <fstream>
#include <iostream>
#include <stdio.h>
#include <sstream>
#include <string>
#include <TFile.h>
#include <TTree.h>
#include <TH1.h>
#include <TH2.h>
#include <TCanvas.h>
#include <TGraph.h>
#include <TRandom3.h>
//#include "Common.h"
//using namespace std;
//variables sorted in decreasing oredr of size: from TTree.html
/*
* struct struct_entry_midas{
unsigned long tm_stp_lsb;
unsigned long info_field;
// unsigned short sample_data[4];
unsigned short adc_data;
unsigned short sample_lenght;
unsigned char type;
unsigned char mod_id;
unsigned char ch_id;
unsigned char adc_range;
unsigned char info_code;
};
*/
//void Plot(string runNum, int Nskip=1, long long Nmax=-1, double ts_0= 0, double ts_1= 20e12, double t_ext_0= 0, double t_ext_1= 10e10, double offset_z=20e12, double t_ext_0_z=0, double t_ext_1_z=10e10){
void Plot(int run0, int Nrun, int Nskip=1, long long Nmax=-1, double kentry_max=1000, double ts_0=0, double ts_1= 500000, int Nskip2= 100){
/***********
struct dssd_hits{
Long64_t t;
Long64_t t_ext;
int x;
int y;
int z;
int ex;
int ey;
int flag;
};
struct calib_data_struct{
double time_aida;
double time_disc;
double time_external;
double adc_energy;
int adc_data;
int dssd;
int strip;
unsigned char adc_range;
unsigned char side;
unsigned char module;
unsigned char channel;
unsigned char data_type;
unsigned char info_code;
bool corr_flag; //if we have a good calculation of offset EXT->AIDA
bool disc_flag; //if we have good DISC value for ADC hit
};
struct unpack_data_struct{
unsigned long tm_stp;
unsigned long corr_scaler;
unsigned long tm_stp_lsb; //least significant bits timestamp
unsigned long info_field;
unsigned int adc_data;
unsigned int sample_length;
unsigned char data_type;
unsigned char fee64_id;
unsigned char ch_id;
unsigned char adc_range;
unsigned char info_code;
bool sync_flag;
};
******************/
TFile* input_file1;
TFile* input_file2;
TFile* input_file3;
TTree * tree1;
TTree * tree2;
TTree * tree3;
// unpack_data_struct unpack_data;
// calib_data_struct calib_data;
// dssd_hits event_data;
Long64_t delta_long64;
double delta_double;
Long64_t offset_long64;
//offset_long64= offset_z;
// TFile* input_file;
// TTree * input_tree;
//TH1I * hTs;
//TH2I * hFeeAdc;
//TH2I * hFeeCh;
//TH1I * hAdc[24];
//TH2I * hTsAdc[24];
// TH1I * Hdt_ext;
// TCanvas * c0;
// c0= new TCanvas("c0","c0"); c0->Divide(4,4); //deltaunp
// for(int i=0;i<16;i++){
//
// char my_title[256];
// char my_name[256];
// sprintf(my_name,"hDeltaUnp%d",i);
// sprintf(my_title,"#Delta time-stamp !FEE%d;t_{CORR. SCALER} - t_{AIDA}",i+1);
// hDeltaUnp[i]= new TH1I(my_name, my_title, 2048, t_ext_0, t_ext_1);
// }
ULong64_t my_tm_stp;
UInt_t my_bit;
Float_t my_Z;
ULong64_t a_tm_stp[1];
UInt_t a_bit[1];
Float_t a_Z[10];
string runName;
string path="/Disk/ds-sopa-personal/aestrade/rootfiles/AIDA/May2015/";
char pid_file[1024];
//number of data points in TTree
long long n_entries;
long long n_max;
long long n_entries_sum=0;
long long delta_ts;
double t3[10001];
double x3[10001];
double t2[10001];
double x2[10001];
int n3=0;
int n2=0;
// int Nskip2=100; //take 1/100 points for any trigger type
TH2I * hT3= new TH2I("hT3","time-stamp for trigger=2;entry num. [1/1e3];time-stamp [1/1e6]",1000,0,kentry_max,1000,ts_0,ts_1);
TH2I * hT2= new TH2I("hT2","time-stamp for any trigger;entry num. [1/1e3];time-stamp [1/1e6]",1000,0,kentry_max,1000,ts_0,ts_1);
/********/
const Int_t kMaxEventInfo = 1;
const Int_t kMaxBigRIPSRaw = 10;
Int_t EventInfo_;
Int_t BigRIPSRaw_;
ULong64_t EventInfo_timestamp[kMaxEventInfo]; //[EventInfo_]
UInt_t EventInfo_fBit[kMaxEventInfo]; //[EventInfo_]
Float_t BigRIPSRaw_Zed_F11[kMaxBigRIPSRaw]; //[BigRIPSRaw_]
TBranch *b_EventInfo_; //!
TBranch *b_BigRIPSRaw_; //!
TBranch *b_EventInfo_timestamp; //!
TBranch *b_EventInfo_fBit; //!
TBranch *b_BigRIPSRaw_Zed_F11; //!
cout << endl << endl;
for(int k=0;k<Nrun;k++){
sprintf(pid_file,"/Disk/ds-sopa-group/np/RIKEN/May2015/PID_data/go4_%d.root",run0+k);
input_file1 = new TFile(pid_file,"read");
tree1= (TTree*) input_file1->Get("tree");
if(!tree1){
cout <<"\n\nNOOOOOOOOOOOO TREEEEEEEEEEEEEEEEEEEEEEEEE"<<endl;
return;
}
// tree1->Print();
tree1->SetMakeClass(1); // important!
tree1->SetBranchAddress("EventInfo", &EventInfo_, &b_EventInfo_);
tree1->SetBranchAddress("BigRIPSRaw", &BigRIPSRaw_, &b_BigRIPSRaw_);
// tree1->SetBranchAddress("EventInfo.timestamp",&my_tm_stp,0);
// tree1->SetBranchAddress("BigRIPSRaw.Zed_F11",&my_Z,0);
// tree1->SetBranchAddress("EventInfo.fBit",&my_bit,0);
// tree1->SetBranchAddress("EventInfo.timestamp",a_tm_stp,0);
//tree1->SetBranchAddress("BigRIPSRaw.Zed_F11",a_Z,0);
// tree1->SetBranchAddress("EventInfo.fBit",a_bit,0);
tree1->SetBranchAddress("EventInfo.timestamp", EventInfo_timestamp, &b_EventInfo_timestamp);
tree1->SetBranchAddress("EventInfo.fBit", EventInfo_fBit, &b_EventInfo_fBit);
tree1->SetBranchAddress("BigRIPSRaw.Zed_F11", BigRIPSRaw_Zed_F11, &b_BigRIPSRaw_Zed_F11);
// tree1->SetBranchAddress("EventInfo.timestamp", EventInfo_timestamp, 0);
// tree1->SetBranchAddress("EventInfo.fBit", EventInfo_fBit, 0);
//tree1->SetBranchAddress("BigRIPSRaw.Zed_F11", BigRIPSRaw_Zed_F11, 0);
// tree1->SetBranchAddress("EventInfo.timestamp", EventInfo_timestamp, 0);
// tree1->SetBranchAddress("EventInfo.fBit", EventInfo_fBit, 0);
// tree1->SetBranchAddress("BigRIPSRaw.Zed_F11", BigRIPSRaw_Zed_F11, 0);
//tree1->SetBranchStatus("EventInfo.timestamp",1);
// tree1->SetBranchStatus("BigRIPSRaw.Zed_F11",1);
// tree1->SetBranchStatus("EventInfo.fBit",1);
n_entries = tree1->GetEntries();
// n_entries_sum+= n_entries;
cout << "Number of entries in PID tree= " << n_entries << " for file "<< pid_file<< " (accumulated= "<<n_entries_sum+n_entries<<")"<<endl;
// int module;
if(Nmax>0 && Nmax<n_entries) n_max= Nmax;
else n_max= n_entries;
int i2=0;
// cout << "\nBIT : TS : Z"<<endl;
for(long long i=0; i< n_max; i=i+Nskip){
//tree1->LoadTree(i);
// cout << "loaded..."<<endl;
tree1->GetEntry(i);
hT2->Fill((i+n_entries_sum)/1e3, EventInfo_timestamp[0]/1e6);
if(n2<10000 && (i2%Nskip2) ==0){
x2[n2]=(i+n_entries_sum)/1e3;
t2[n2]= EventInfo_timestamp[0]/1e6;
n2++;
}
i2++;
if(EventInfo_fBit[0]==3){
hT3->Fill((i+n_entries_sum)/1e3, EventInfo_timestamp[0]/1e6);
if(n3<10000){
x3[n3]=(i+n_entries_sum)/1e3;
t3[n3]= EventInfo_timestamp[0]/1e6;
n3++;
}
}
else if(EventInfo_fBit[0]!=2){
cout<< "i: "<<i<<" \t"<< EventInfo_timestamp[0]<<" \t"; //[EventInfo_]
cout<< EventInfo_fBit[0]<<" \t"; //[EventInfo_]
cout<< BigRIPSRaw_Zed_F11[0]<<endl; //[BigRIPSRaw_]
}
/***************
if(i < 33){
cout<< "i: "<<i<<" \t"<< EventInfo_timestamp[0]<<" \t"; //[EventInfo_]
cout<< EventInfo_fBit[0]<<" \t"; //[EventInfo_]
cout<< BigRIPSRaw_Zed_F11[0]<<endl; //[BigRIPSRaw_]
}
if(EventInfo_fBit[0] != 2){
cout<< "i: "<<i<<" \t"<< EventInfo_timestamp[0]<<" \t"; //[EventInfo_]
cout<< EventInfo_fBit[0]<<" \t"; //[EventInfo_]
cout<< BigRIPSRaw_Zed_F11[0]<<endl; //[BigRIPSRaw_]
}
... 32 more lines ...
|