/*********/
//#include <bitset>
#include <fstream>
#include <iostream>
#include <stdio.h>
#include <sstream>
#include <string>
#include <ctime>
#include <TFile.h>
#include <TTree.h>
#include <TH1I.h>
#include <TH2I.h>
#include <TGraph.h>
#include <TCanvas.h>
//#include "Common.h"
//using namespace std;
/*********/
//ts_0 in usec
void LoopTree(string inFile, int downscale=1, long long n_last= -1, int ts_0=-1, bool b_print=false, bool b_quit_ts=false){
struct struct_entry_sort{
long long tm_stp; //reconstructed timestamp (MSB+LSB)
long long info; //MBS info data (external timestamp), anything else(?)
int mod_id;
int ch_id;
int type; // QQQ: 0= 20 MeV or 1 GeV (decays), 1= 20 GeV (checked pulser data only in type 0)
// type>=10: type = info_code+10 (i.e., PAUSE, RESUME, SYNC100, etc...)
int adc_data;
bool sync_flag; // check SYNC100 pulses received for this module
bool pause_flag; // check Pause signals followed by proper Resume signal: true= SYNC100 paused...
};
//***** histograms! many...
//
//delta ts: any->any [100]
// adc->adc [100]
// adc(feei)->adc(feej) [1]
// adc(sidei)->adc(sidej) [1]
// !adc->!adc [1]
//1,2,3,5,10,15,20,50,100
TH1D *Hdts_any[10];
Hdts_any[0]= new TH1D("Hdts_any0","#Delta ts_{(i+1,i)} !ANY DATA;ts_{i+1} - ts_{i} [usec]",4400,-20,200); //200 us full scale
Hdts_any[1]= new TH1D("Hdts_any1","#Delta ts_{(i+2,i)} !ANY DATA;ts_{i+2} - ts_{i} [usec]",4400,-20,200); //200 us full scale
Hdts_any[2]= new TH1D("Hdts_any2","#Delta ts_{(i+3,i)} !ANY DATA;ts_{i+3} - ts_{i} [usec]",4400,-20,200); //200 us full scale
Hdts_any[3]= new TH1D("Hdts_any3","#Delta ts_{(i+5,i)} !ANY DATA;ts_{i+5} - ts_{i} [usec]",4400,-20,200); //200 us full scale
Hdts_any[4]= new TH1D("Hdts_any4","#Delta ts_{(i+10,i)} !ANY DATA;ts_{i+10} - ts_{i} [usec]",4400,-20,200); //200 us full scale
Hdts_any[5]= new TH1D("Hdts_any5","#Delta ts_{(i+15,i)} !ANY DATA;ts_{i+15} - ts_{i} [usec]",4400,-20,200); //200 us full scale
Hdts_any[6]= new TH1D("Hdts_any6","#Delta ts_{(i+20,i)} !ANY DATA;ts_{i+20} - ts_{i} [usec]",4400,-20,200); //200 us full scale
Hdts_any[7]= new TH1D("Hdts_any7","#Delta ts_{(i+50,i)} !ANY DATA;ts_{i+50} - ts_{i} [usec]",4400,-20,200); //200 us full scale
Hdts_any[8]= new TH1D("Hdts_any8","#Delta ts_{(i+100,i)} !ANY DATA;ts_{i+100} - ts_{i} [usec]",4400,-20,200); //200 us full scale
TH1D *Hdts_adc[10];
Hdts_adc[0]= new TH1D("Hdts_adc0","#Delta ts_{(i+1,i)} !ADC(low) DATA;ts_{i+1} - ts_{i} [usec]",4400,-20,200); //200 us full scale
Hdts_adc[1]= new TH1D("Hdts_adc1","#Delta ts_{(i+2,i)} !ADC(low) DATA;ts_{i+2} - ts_{i} [usec]",4400,-20,200); //200 us full scale
Hdts_adc[2]= new TH1D("Hdts_adc2","#Delta ts_{(i+3,i)} !ADC(low) DATA;ts_{i+3} - ts_{i} [usec]",4400,-20,200); //200 us full scale
Hdts_adc[3]= new TH1D("Hdts_adc3","#Delta ts_{(i+5,i)} !ADC(low) DATA;ts_{i+5} - ts_{i} [usec]",4400,-20,200); //200 us full scale
Hdts_adc[4]= new TH1D("Hdts_adc4","#Delta ts_{(i+10,i)} !ADC(low) DATA;ts_{i+10} - ts_{i} [usec]",4400,-20,200); //200 us full scale
Hdts_adc[5]= new TH1D("Hdts_adc5","#Delta ts_{(i+15,i)} !ADC(low) DATA;ts_{i+15} - ts_{i} [usec]",4400,-20,200); //200 us full scale
Hdts_adc[6]= new TH1D("Hdts_adc6","#Delta ts_{(i+20,i)} !ADC(low) DATA;ts_{i+20} - ts_{i} [usec]",4400,-20,200); //200 us full scale
Hdts_adc[7]= new TH1D("Hdts_adc7","#Delta ts_{(i+50,i)} !ADC(low) DATA;ts_{i+50} - ts_{i} [usec]",4400,-20,200); //200 us full scale
Hdts_adc[8]= new TH1D("Hdts_adc8","#Delta ts_{(i+100,i)} !ADC(low) DATA;ts_{i+100} - ts_{i} [usec]",4400,-20,200); //200 us full scale
TH1D *Hdts_fee[1];
Hdts_fee[0]= new TH1D("Hdts_fee0","#Delta ts_{(i+1,i)} !ADC(low), diff. FEE;ts_{i+1} - ts_{i} [usec]",4400,-20,200); //200 us full scale
TH1D *Hdts_side[2];
Hdts_side[0]= new TH1D("Hdts_side0","#Delta ts_{(i+1,i)} !ADC(low), side0->1;ts_{i+1} - ts_{i} [usec]",4400,-20,200); //200 us full scale
Hdts_side[1]= new TH1D("Hdts_side1","#Delta ts_{(i+1,i)} !ADC(low), side1->0;ts_{i+1} - ts_{i} [usec]",4400,-20,200); //200 us full scale
TH1D *Hdts_info[1];
Hdts_info[0]= new TH1D("Hdts_info0","#Delta ts_{(i+1,i)} !info DATA;ts_{i+1} - ts_{i} [usec]",4400,-20,200); //200 us full scale
TH1D *Hdts_ooo[1];
Hdts_ooo[0]= new TH1D("Hdts_ooo0","#Delta ts_{(i+1,i)} !out-of-order!;ts_{i+1} - ts_{i} [usec]",15000,-3e6,0); //500 us full scale
TH1D * Hts[2];
Hts[0]= new TH1D("Hts0","Time-stamp;ts [usec]",2000,0,27e5);
Hts[1]= new TH1D("Hts1","Time-stamp;ts [usec]",2000,91e9,97e9);
//Rate hitograms
TH1D * HrateFEE_ts[4];
TH1D * HrateFEE_ch[4];
TH1D * HrateADChigh_ts[1];
TH1D * HrateInfo_ts[1];
TH1I * HhitsADC[5];
TH1I * HhitsInfo[4];
TH2I * HtsFEE[3];
TH2I * HtsInfo[1];
TH2D * HtsCh[4];
TH2I * HInfoFEE[4];
double max_bin;
if(n_last>0) max_bin= n_last;
else max_bin= 1.e7;
TH2I * HtsEvent[2];
//HtsEvent[0]= new TH2I("HtsEvent0","Time-stamp vs entry;entry #;ts [usec]",200,0,max_bin,1000,0,27e5);
HtsEvent[1]= new TH2I("HtsEvent1","Time-stamp vs entry;entry #;ts [usec]",500,0,max_bin,500,92e9,97e9);
//sEvent[1]= new TH2I("HtsEvent1","Time-stamp vs entry;entry #;ts [usec]",500,0,max_bin,500,92.4e9,92.44e9);
// variables for distribution of time-stamp differences
double dts;
double ts100_any[101];
double ts100_adc[101];
// long long tsinide01;
// long long ts_side10;
// long long ts_fee;
double ts_info= -1;
int index_adc=0;
int index_any=0;
int index_prev;
int last_side, this_side;
int last_fee, this_fee;
int step_back[9]={1,2,3,5,10,15,20,50,100};
int steps;
double ts;
for(int i=0;i<101;i++){
ts100_any[i]= -1;
ts100_adc[i]= -1;
}
int Nooo=0;
int info_code_prev, mod_id_prev, type_prev;
//logfile
ofstream logfile("outputLoop_R61_5.txt");
time_t t_start; //, t_stop;
TFile* input_file;
input_file = new TFile(inFile.data(),"read");
if (input_file != 0){
input_file->ls();
TTree * input_tree;
input_tree= (TTree*) input_file->Get("AIDA_sort");
if(input_tree !=0) input_tree->Print();
else {
cout << "\n WARNING@ could not assign AIDA_sort Tree...." << endl;
exit(0);
}
//tree from Converter step will data in a struct_entry_midas structure
struct_entry_sort entry_1;
input_tree->SetMakeClass(1);
input_tree->SetBranchAddress("entry_sort",&entry_1,0);
input_tree->SetBranchStatus("entry_sort",1);
//number of data points in TTree
long long n_entries;
n_entries = input_tree->GetEntries();
cout << "\nNumber of entries in input tree= " << n_entries << ", in file " << inFile << endl;
logfile << "\nNumber of entries in input tree= " << n_entries << ", in file " << inFile << endl;
//get run time... properly...
long long time_first, time_last;
time_first= 0;
for(long long i=0; i<=100000; i++){
input_tree->GetEntry(i);
if(entry_1.sync_flag){
time_first= entry_1.tm_stp;
i=100000+1;
}
}
if(time_first<=0){
cout << "\n\n**** WARNING: Couldn't find Synchronized data in first 100K entries of file! ****\n" << endl;
time_first=0;
}
input_tree->GetEntry(n_entries-1);
time_last= entry_1.tm_stp;
cout << "\n----------------------------------------------------------------------------"
<< "\n Inititial time stamp= " <<time_first;
cout << "\n Lenght of run= "<<time_last-time_first <<" tm-stp= "<<(time_last-time_first)/1.e8 <<" sec"<<endl;
//Define histograms that need to know run lenght....
double ts_low, ts_up; //in usc
double ts_sec;
// int ts_0;
//in msec units!
if(ts_0<0) ts_0 = time_first/100000; // 10x ns -> ms
cout << " .... using ts_0= " << ts_0;
//and this in usec units!
ts_low= ts_0*1000.;
ts_up= ts_low+20.e6;
cout << "msec, ts_low= " << ts_low << " usec, ts_up= " << ts_up << " usec" << endl<<endl;
int fee_index;
bool b_ts_window;
//Rate histograms
int ts_0_sec= int(1.*time_first/1e8);
//2 hrs, 10sec/bin
HrateFEE_ts[0]= new TH1D("HrateFEE_ts0","Rate - ADClow(nnaida11);time-stamp [s];rate [1/s]",360,ts_0_sec,ts_0_sec+3600);
HrateFEE_ts[1]= new TH1D("HrateFEE_ts1","Rate - ADClow(nnaida12);time-stamp [s];rate [1/s]",360,ts_0_sec,ts_0_sec+3600);
HrateFEE_ts[2]= new TH1D("HrateFEE_ts2","Rate - ADClow(nnaida13);time-stamp [s];rate [1/s]",360,ts_0_sec,ts_0_sec+3600);
HrateFEE_ts[3]= new TH1D("HrateFEE_ts3","Rate - ADClow(nnaida14);time-stamp [s];rate [1/s]",360,ts_0_sec,ts_0_sec+3600);
HrateFEE_ch[0]= new TH1D("HrateFEE_ch0","Rate - ADClow(nnaida11);ch; rate [1/s];time-stamp [s]",64,0,64);
HrateFEE_ch[1]= new TH1D("HrateFEE_ch1","Rate - ADClow(nnaida12);ch; rate [1/s];time-stamp [s]",64,0,64);
HrateFEE_ch[2]= new TH1D("HrateFEE_ch2","Rate - ADClow(nnaida13);ch; rate [1/s];time-stamp [s]",64,0,64);
HrateFEE_ch[3]= new TH1D("HrateFEE_ch3","Rate - ADClow(nnaida14);ch; rate [1/s];time-stamp [s]",64,0,64);
HrateADChigh_ts[0]= new TH1D("HrateADChigh_ts0","Rate - ADChigh(any FEE);time-stamp [s];rate [1/s]",360,ts_0_sec,ts_0_sec+3600);
HrateInfo_ts[0]= new TH1D("HrateInfo_ts0","Rate - Info Types;time-stamp [s];rate [1/s]",360,ts_0_sec,ts_0_sec+3600);
//Info types for different FEEs (sum and vs time)
HInfoFEE[0]= new TH2I("HInfoFEE0","Info Code vs FEE;Info Type;nnaida",16,0,16,4,11,15);
HInfoFEE[1]= new TH2I("HInfoFEE1","Time-stamp vs FEE(Pause/Resume);time-stamp [s];nnaida",240,ts_0_sec,ts_0_sec+3600,4,11,15);
HInfoFEE[2]= new TH2I("HInfoFEE2","Time-stamp vs FEE(SYNC100);time-stamp [s];nnaida",240,ts_0_sec,ts_0_sec+3600,4,11,15);
HInfoFEE[3]= new TH2I("HInfoFEE3","Time-stamp vs FEE(Disc.);time-stamp [s];nnaida",240,ts_0_sec,ts_0_sec+3600,4,11,15);
//hist vs time
HhitsADC[0]= new TH1I("HhitsADC0","Rate [1/ms] - ADClow(nnaida11);time-stamp [ms]",20000,ts_0,ts_0+20000);
HhitsADC[1]= new TH1I("HhitsADC1","Rate [1/ms] - ADClow(nnaida12);time-stamp [ms]",20000,ts_0,ts_0+20000);
HhitsADC[2]= new TH1I("HhitsADC2","Rate [1/ms] - ADClow(nnaida13);time-stamp [ms]",20000,ts_0,ts_0+20000);
HhitsADC[3]= new TH1I("HhitsADC3","Rate [1/ms] - ADClow(nnaida14);time-stamp [ms]",20000,ts_0,ts_0+20000);
HhitsADC[4]= new TH1I("HhitsADC4","Rate [1/ms] - ADChigh;time-stamp [ms]",20000,ts_0,ts_0+20000);
HhitsInfo[0]= new TH1I("HhitsInfo0","Rate [1/ms] - PAUSE/RESUME;time-stamp [ms]",20000,ts_0,ts_0+20000);
HhitsInfo[1]= new TH1I("HhitsInfo1","Rate [1/ms] - RESUME TS;time-stamp [ms]",20000,ts_0,ts_0+20000);
HhitsInfo[2]= new TH1I("HhitsInfo2","Rate [1/ms] - SYNC100;time-stamp [ms]",20000,ts_0,ts_0+20000);
HhitsInfo[3]= new TH1I("HhitsInfo3","Rate [1/ms] - Discr. Data;time-stamp [ms]",20000,ts_0,ts_0+20000);
HtsFEE[0]= new TH2I("HtsFEE0","Time-stamp vs FEE(ADClow);ts [ms];nnaida",1000,ts_0,ts_0+20000,4,11,15);
HtsFEE[1]= new TH2I("HtsFEE1","Time-stamp vs FEE(SYNC100);ts [ms];nnaida",1000,ts_0,ts_0+20000,4,11,15);
HtsFEE[2]= new TH2I("HtsFEE2","Time-stamp vs FEE(Pause/Res.);ts [ms];nnaida",1000,ts_0,ts_0+20000,8,11,15);
// HtsFEE[0]= new TH2I("HtsFEE0","Time-stamp vs FEE\# (ADClow);ts [msec];nnaida\# ",2000,ts_0,ts_0+20000,4,10.5,14.5);
HtsInfo[0]= new TH2I("HtsInfo0","Time-stamp vs InfoCode;ts [ms];Info Type",1000,ts_0,ts_0+20000,16,0,16);
HtsCh[0]= new TH2D("HtsCh0","Time-stamp vs Ch. (nnaida11);ts [ms];ch",5000,ts_0,ts_0+5000,64,0,64);
HtsCh[1]= new TH2D("HtsCh1","Time-stamp vs Ch. (nnaida12);ts [ms];ch",5000,ts_0,ts_0+5000,64,0,64);
HtsCh[2]= new TH2D("HtsCh2","Time-stamp vs Ch. (nnaida13);ts [ms];ch",5000,ts_0,ts_0+5000,64,0,64);
HtsCh[3]= new TH2D("HtsCh3","Time-stamp vs Ch. (nnaida14);ts [ms];ch",5000,ts_0,ts_0+5000,64,0,64);
t_start= time(0); //lets count how long it takes to loop through tree
//now looping only over first 99 events, or up to n_entries, whatever is less
if(n_last<1 || n_last>n_entries) n_last= n_entries;
// input_tree->GetEntry(0);
for(long long i=0; i<n_last; i=i+downscale){
//
// do stuff...
//
// entry_0.tm_stp= entry_1.tm_stp;
// entry_0.type= entry_1.type;
// entry_0.info= entry_1.info;
... 343 more lines ...
|
19/02/15
1000: Check system gives same resolution as yesterday, removing only the Cu braiding connecting and grounding all adapter PCBs (also moved bias braid back to nnaida3).
Pulser FWHM in each FEE... nnaida1 ~800ch, nnaida3 ~110ch, nnaida6 ~2300ch, nnaida8 ~950ch. Rate in 6 and 8 ~5kHz per strip.
Re-added Cu braids, clipping on to LEMO connectors of adapter PCBs.
FWHM and rate/strip in nnaida1,3,6,8 now (respectively): ~600ch and 100Hz, ~120ch and 25Hz, ~2100ch and 6kHz, 1000ch and 6kHz. => small reduction in nnaida1+6
nnaida8 also has non-Gaussian pulser peaks.
No clear effect, but minor improvement and no negative effects mean we will keep Cu braids attached.
1045: Grounded nose to adapter PCB attached to nnaida7+8. No clear effect.
1055: Changed pre-amp reference settings in nnaida1+8.
nnaida1 0x30 -> 0x60. nnaida8 0xb2 -> 0x82.
No clear change. Reverted back to original settings.
1130: Changed to detector BB18 2977-20 and added 241Am (1uCi) and 207Bi (few uCi) sources 2cm from front of detector (see attached photos for arrangement).
Bias set at -100V with leakage current -10.9uA.
Pulser peak FWHMs for each nnaida are: #1 ~600ch, #3 ~150ch, #6 ~1300ch, #8 ~ 700ch. Minor improvement over previous detector.
1345: nnaida3 still much more well behaved than other nnaida. To test if kapton cables are source of issue, swapped kaptons for nnaida3+8 at FEE end.
Peak FWHMs and rates for nnaida3+8 having swapped cables are: #3 ~700ch and 300Hz, #8 ~200ch and 30Hz.
=> noise moved with kapton! Kaptons could be the issue. (For completeness, FWHM in nnaida1 ~800ch and nnaida6 ~1100ch.)
1435: Disconnected kaptons at detector end (still connected to FEE adapters).
Pulser FWHMs and rates/strip per strip now: nnaida1 - ~250ch and 25Hz, nnaida3 - ~120ch and 25Hz, nnaida6 - ~160ch and 25Hz, nnaida8 - ~120ch and 25Hz.
Waveforms for all nnaida looked similar and with little noise => no way of telling a 'bad' cable from a 'good' one, just from FEE + cable (without detector).
Current cable configuration/pairings: nnaida1-kapton A, 3-B, 6-C, 8-D.
Kapton B shows no alpha/beta spectrum from sources in 1.1.L, a problem which tracked across to nnaida8 when cables were swapped => suggesting break in cable for this channel.
Waveforms in all nnaida look relatively noise free (nnaida1 slightly noisier) and as expected.
1520: Changed some of the kaptons to check all were functioning properly. Kept nnaida3-kapton B combo as this was working as expected from DL tests.
Changed nnaida1 A->E (neither isolated), nnaida6 C->F, nnaida8 D->G.
After removal. noticed outgoing kaptons C+D did not have "Isolated" label on them (B does).
Without connecting new cables to detector, FWHMs and rates/strip in all nnaida ~130-150ch and ~25Hz, respectively.
1545: Connected kaptons to detector 2977-20 and with alpha+beta sources 2cm in front of detector.
Bias connected via nnaida6 (-ve core) and nnaida3 (low V ref braid). nnaida3+8 grounded.
nnaida-kapton pairings now as follows: nnaida1-kapton E, 3-B, 6-F, 8-G.
Pulser FWHMs and rates/strip now: nnaida 1 - ~190ch and ~60Hz, nnaida3 - ~250ch and ~60Hz, nnaida6 - ~180ch and ~40Hz, nnaida8 - ~350ch and ~100Hz.
Above rates seem sensible considering we have 25Hz pulser going into FEEs, plus alpha and beta sources.
MUCH better than previous! (apart from nnaida3 which remains about the same)
Further more, rate spectrum for each nnaida shows slow decline in rate with increasing bin number. Expected as 241Am placed centrally and outer strips will see lower rate as more alphas are stopped due to path travelled.
1645: Saving data to file with system configuration: Am+Bi sources, EBFG kaptons, Cu braid grounding between adapters and nose grounded to nnaida7+8 adapter.
File - /TapeData/Feb2015/Run1_*.gz.
Run stopped at 1715.
17:40: Providing one pulser signal to BRIKEN VME crate, which is in the same main bias supply as AIDA. Start a new run to check things are not changed
File - /TapeData/Feb2015/Run3_*.gz.
19.42 File /TapeDate/R3_1.gz closed (985+303Mb)
|