2023-04-06 20:03:08 -04:00
# define Monitor_cxx
2023-04-06 19:05:20 -04:00
# include <TH2.h>
# include <TH1.h>
# include <TF1.h>
# include <TStyle.h>
# include <TCutG.h>
# include <TGraph.h>
# include <TMath.h>
# include <TMultiGraph.h>
# include <TString.h>
# include <TLatex.h>
# include <TSystem.h>
# include <TMacro.h>
# include <TLine.h>
# include <TStopwatch.h>
# include <TCanvas.h>
# include <TBox.h>
# include <TDatime.h>
# include <TMD5.h>
# include <TObjArray.h>
# include <fstream>
# include <vector>
2024-02-13 19:25:33 -05:00
# include "../Cleopatra/ClassIsotope.h"
2023-04-06 19:05:20 -04:00
# include "Mapping.h"
2023-04-07 16:22:37 -04:00
# define tick2ns 8. // 1clock tick = 8 ns
2024-07-06 17:48:31 -04:00
# define tick2min tick2ns / 1e9 / 60.
2023-04-07 16:22:37 -04:00
2023-04-06 19:05:20 -04:00
using namespace std ;
//############################################ User setting
//---histogram setting
int rawEnergyRange [ 2 ] = { 100 , 4000 } ; /// share with e, xf, xn
int energyRange [ 2 ] = { 0 , 10 } ; /// in the E-Z plot
int rdtDERange [ 2 ] = { 0 , 80 } ;
int rdtERange [ 2 ] = { 0 , 80 } ;
int thetaCMRange [ 2 ] = { 0 , 80 } ;
double exRange [ 3 ] = { 100 , - 2 , 10 } ; /// bin [keV], low[MeV], high[MeV]
int coinTimeRange [ 2 ] = { - 200 , 200 } ;
int timeRangeUser [ 2 ] = { 0 , 99999999 } ; /// min, use when cannot find time, this set the min and max
bool isUseArrayTrace = false ;
bool isUseRDTTrace = false ;
//---Gate
bool isTimeGateOn = true ;
int timeGate [ 2 ] = { - 20 , 12 } ; /// min, max, 1 ch = 10 ns
double eCalCut [ 2 ] = { 0.5 , 50 } ; /// lower & higher limit for eCal
int dEgate [ 2 ] = { 500 , 1500 } ;
int Eresgate [ 2 ] = { 1000 , 4000 } ;
double thetaCMGate = 10 ; /// deg
double xGate = 0.9 ; ///cut out the edge
vector < int > skipDetID = { 11 , 16 , 23 } ; //{2, 11, 17}
TString rdtCutFile1 = " " ;
TString rdtCutFile2 = " " ;
TString ezCutFile = " " ; //"ezCut.root";
//############################################ end of user setting
2024-07-06 17:48:31 -04:00
2023-04-06 19:05:20 -04:00
//======== raw data
2023-04-06 20:03:08 -04:00
TH1F * * he , * * hxf , * * hxn , * hMultiHit ; //basic data
TH2F * * hxfVxn , * * heVxs , * * heVx ; // correlation
TH2F * heVID , * hxfVID , * hxnVID ; // vs ID
2023-04-06 19:05:20 -04:00
//====== cal data
2023-04-06 20:03:08 -04:00
TH1F * * heCal ;
TH2F * * hxfCalVxnCal ;
TH2F * * heVxsCal ; // raw e vs xf
TH2F * * heCalVxCal ; // eCal vs xCal
TH2F * * heCalVxCalG ; // eCal vs xCal
2023-04-06 19:05:20 -04:00
2024-07-06 17:48:31 -04:00
TH2F * heCalID ; // e vs id
2023-04-06 19:05:20 -04:00
//======= Recoil
2023-04-06 20:03:08 -04:00
TH2F * hrdtID ;
TH1F * * hrdt ; // single recoil
TH1F * * hrdtg ;
2023-04-06 19:05:20 -04:00
2023-04-06 20:03:08 -04:00
TH2F * * hrdt2D ;
TH2F * * hrdt2Dg ;
2023-04-06 19:05:20 -04:00
2023-04-06 20:03:08 -04:00
TH1F * hrdtRate1 ;
TH1F * hrdtRate2 ;
2023-04-06 19:05:20 -04:00
//======= multi-Hit
2023-04-06 20:03:08 -04:00
TH2I * hmult ;
TH1I * hmultEZ ;
TH2I * hArrayRDTMatrix ;
TH2I * hArrayRDTMatrixG ;
2023-04-06 19:05:20 -04:00
//======= ARRAY-RDT time diff
2023-04-06 20:03:08 -04:00
TH1I * htdiff ;
TH1I * htdiffg ;
2023-04-06 19:05:20 -04:00
/***************************
* * * * * * * * * * * * * * * * * * * * * * * * * * */
TLatex text ;
ULong64_t NumEntries = 0 ;
ULong64_t ProcessedEntries = 0 ;
Float_t Frac = 0.1 ; ///Progress bar
TStopwatch StpWatch ;
//======= Recoil Cut
TCutG * cutG ; //! //general temeprary pointer to cut
TObjArray * cutList1 ;
TObjArray * cutList2 ;
//======= Other Cuts
2023-04-06 20:03:08 -04:00
TCutG * EZCut ;
2023-04-06 19:05:20 -04:00
2023-04-06 20:03:08 -04:00
# include "Monitor.h"
2023-04-06 19:05:20 -04:00
//^###########################################################
//^ * Begin
//^###########################################################
2023-04-06 20:03:08 -04:00
void Monitor : : Begin ( TTree * tree ) {
2023-04-06 19:05:20 -04:00
TString option = GetOption ( ) ;
NumEntries = tree - > GetEntries ( ) ;
canvasTitle = GetCanvasTitle ( ) ;
printf ( " ########################################################### \n " ) ;
printf ( " ########## SOLARIS Monitors.C ######### \n " ) ;
printf ( " ########################################################### \n " ) ;
2024-07-06 17:48:31 -04:00
for ( int i = 0 ; i < detGeo - > numGeo ; + + ) plotter [ i ] - > SetUpHistograms ( energyRange , exRange , thetaCMRange ) ;
2023-04-06 19:05:20 -04:00
//===================================================== loading parameter
2024-07-04 13:06:26 -04:00
// corr->LoadDetGeoAndReactionConfigFile();
2024-02-13 19:25:33 -05:00
corr - > LoadXNCorr ( ) ;
corr - > LoadXFXN2ECorr ( ) ;
corr - > LoadXScaleCorr ( ) ;
corr - > LoadECorr ( ) ;
corr - > LoadRDTCorr ( ) ;
if ( ( int ) corr - > xnCorr . size ( ) < mapping : : NARRAY ) { printf ( " !!!!!!!! size of xnCorr < NARRAY . \n " ) ; }
if ( ( int ) corr - > xfxneCorr . size ( ) < mapping : : NARRAY ) { printf ( " !!!!!!!! size of xfxneCorr < NARRAY . \n " ) ; }
if ( ( int ) corr - > eCorr . size ( ) < mapping : : NARRAY ) { printf ( " !!!!!!!! size of eCorr < NARRAY . \n " ) ; }
if ( ( int ) corr - > xScale . size ( ) < mapping : : NARRAY ) { printf ( " !!!!!!!! size of xScale < NARRAY . \n " ) ; }
if ( ( int ) corr - > rdtCorr . size ( ) < mapping : : NRDT ) { printf ( " !!!!!!!! size of rdtCorr < NRDT . \n " ) ; }
2023-04-07 16:22:37 -04:00
printf ( " ===================================================== \n " ) ;
printf ( " time Range : %5.0f - %5.0f min \n " , timeRangeInMin [ 0 ] , timeRangeInMin [ 1 ] ) ;
printf ( " ===================================================== \n " ) ;
2023-04-06 19:05:20 -04:00
//================ Get Recoil cuts;
cutG = new TCutG ( ) ;
cutList1 = AnalysisLib : : LoadListOfTCut ( rdtCutFile1 , " cutList " ) ;
cutList2 = AnalysisLib : : LoadListOfTCut ( rdtCutFile2 , " cutList " ) ;
//================ Get EZ cuts;
EZCut = AnalysisLib : : LoadSingleTCut ( ezCutFile ) ;
//========================= Generate all of the histograms needed for drawing later on
2023-04-07 16:22:37 -04:00
printf ( " ============================================ Histograms declaration \n " ) ;
2023-04-06 19:05:20 -04:00
gROOT - > cd ( ) ;
2024-07-06 17:48:31 -04:00
CreateListOfHist1D ( he , 0 , mapping : : NARRAY , " he " , " Raw e (ch=%d); e (channel); count " , 200 , rawEnergyRange [ 0 ] , rawEnergyRange [ 1 ] ) ;
CreateListOfHist1D ( hxf , 0 , mapping : : NARRAY , " hxf " , " Raw xf (ch=%d); e (channel); count " , 200 , rawEnergyRange [ 0 ] , rawEnergyRange [ 1 ] ) ;
CreateListOfHist1D ( hxn , 0 , mapping : : NARRAY , " hxn " , " Raw xn (ch=%d); e (channel); count " , 200 , rawEnergyRange [ 0 ] , rawEnergyRange [ 1 ] ) ;
2023-04-06 19:05:20 -04:00
2024-07-06 17:48:31 -04:00
CreateListOfHist2D ( hxfVxn , 0 , mapping : : NARRAY , " hxfVxn " , " Raw xf vs. xn (ch=%d);xf (channel);xn (channel) " , 500 , rawEnergyRange [ 0 ] , rawEnergyRange [ 1 ] , 500 , rawEnergyRange [ 0 ] , rawEnergyRange [ 1 ] ) ;
CreateListOfHist2D ( heVxs , 0 , mapping : : NARRAY , " heVxs " , " Raw e vs xf+xn (ch=%d); xf+xn (channel); e (channel) " , 500 , rawEnergyRange [ 0 ] , rawEnergyRange [ 1 ] , 500 , rawEnergyRange [ 0 ] , rawEnergyRange [ 1 ] ) ;
2023-04-06 19:05:20 -04:00
2024-07-06 17:48:31 -04:00
CreateListOfHist1D ( heCal , 0 , mapping : : NARRAY , " heCal " , " Corrected e (ch=%d); e (MeV); count " , 2000 , energyRange [ 0 ] , energyRange [ 1 ] ) ;
2023-04-06 20:03:08 -04:00
2024-07-06 17:48:31 -04:00
CreateListOfHist2D ( hxfCalVxnCal , 0 , mapping : : NARRAY , " hxfCalVxnCal " , " Corrected XF vs. XN (ch=%d);XF (channel);XN (channel) " , 500 , 0 , rawEnergyRange [ 1 ] , 500 , 0 , rawEnergyRange [ 1 ] ) ;
CreateListOfHist2D ( heVxsCal , 0 , mapping : : NARRAY , " heVxsCal " , " Raw e vs Corrected xf+xn (ch=%d); corrected xf+xn (channel); Raw e (channel) " , 500 , rawEnergyRange [ 0 ] , rawEnergyRange [ 1 ] , 500 , rawEnergyRange [ 0 ] , rawEnergyRange [ 1 ] ) ;
int startIndex = 0 ;
for ( int i = 0 ; i < detGeo - > numGeo ; i + + ) {
CreateListOfHist2D ( heVx , startIndex , detGeo - > array [ i ] . numDet , " heVx " , " Raw PSD E vs. X (ch=%d);X (channel);E (channel) " , 500 , - 2.5 , detGeo - > array [ i ] . detLength + 2.5 , 500 , rawEnergyRange [ 0 ] , rawEnergyRange [ 1 ] ) ;
CreateListOfHist2D ( heCalVxCal , startIndex , detGeo - > array [ i ] . numDet , " heCalVxCal " , " Cal PSD E vs. X (ch=%d);X (cm);E (MeV) " , 500 , - 2.5 , detGeo - > array [ i ] . detLength + 2.5 , 500 , energyRange [ 0 ] , energyRange [ 1 ] ) ;
CreateListOfHist2D ( heCalVxCalG , startIndex , detGeo - > array [ i ] . numDet , " heCalVxCalG " , " Cal PSD E vs. X (ch=%d);X (cm);E (MeV) " , 500 , - 2.5 , detGeo - > array [ i ] . detLength + 2.5 , 500 , energyRange [ 0 ] , energyRange [ 1 ] ) ;
startIndex + = detGeo - > array [ i ] . numDet ;
}
2023-04-06 19:05:20 -04:00
2023-04-06 20:03:08 -04:00
heVID = new TH2F ( " heVID " , " Raw e vs channel " , mapping : : NARRAY , 0 , mapping : : NARRAY , 500 , rawEnergyRange [ 0 ] , rawEnergyRange [ 1 ] ) ;
2023-04-06 19:05:20 -04:00
hxfVID = new TH2F ( " hxfVID " , " Raw xf vs channel " , mapping : : NARRAY , 0 , mapping : : NARRAY , 500 , rawEnergyRange [ 0 ] , rawEnergyRange [ 1 ] ) ;
hxnVID = new TH2F ( " hxnVID " , " Raw xn vs channel " , mapping : : NARRAY , 0 , mapping : : NARRAY , 500 , rawEnergyRange [ 0 ] , rawEnergyRange [ 1 ] ) ;
2024-07-06 17:48:31 -04:00
heCalID = new TH2F ( " heCalID " , " Corrected E vs id; id; E / 10 keV " , mapping : : NARRAY , 0 , mapping : : NARRAY , 2000 , energyRange [ 0 ] , energyRange [ 1 ] ) ;
2023-04-06 19:05:20 -04:00
hMultiHit = new TH1F ( " hMultiHit " , " Multi-Hit of Energy " , 10 , 0 , 1 ) ;
//===================== Recoils
hrdtID = new TH2F ( " hrdtID " , " RDT vs ID; ID; energy [ch] " , 8 , 0 , 8 , 500 , TMath : : Min ( rdtERange [ 0 ] , rdtDERange [ 0 ] ) , TMath : : Max ( rdtERange [ 1 ] , rdtDERange [ 1 ] ) ) ;
hrdt = new TH1F * [ mapping : : NRDT ] ;
hrdtg = new TH1F * [ mapping : : NRDT ] ;
hrdt2D = new TH2F * [ mapping : : NRDT / 2 ] ;
2024-07-06 17:48:31 -04:00
// hrdt2Dg = new TH2F * [mapping::NRDT/2];
2023-04-06 19:05:20 -04:00
for ( Int_t i = 0 ; i < mapping : : NRDT ; i + + ) {
if ( i % 2 = = 0 ) hrdt [ i ] = new TH1F ( Form ( " hrdt%d " , i ) , Form ( " Raw Recoil E(ch=%d); E (channel) " , i ) , 500 , rdtERange [ 0 ] , rdtERange [ 1 ] ) ;
if ( i % 2 = = 0 ) hrdtg [ i ] = new TH1F ( Form ( " hrdt%dg " , i ) , Form ( " Raw Recoil E(ch=%d) gated; E (channel) " , i ) , 500 , rdtERange [ 0 ] , rdtERange [ 1 ] ) ;
if ( i % 2 = = 1 ) hrdt [ i ] = new TH1F ( Form ( " hrdt%d " , i ) , Form ( " Raw Recoil DE(ch=%d); DE (channel) " , i ) , 500 , rdtDERange [ 0 ] , rdtDERange [ 1 ] ) ;
if ( i % 2 = = 1 ) hrdtg [ i ] = new TH1F ( Form ( " hrdt%dg " , i ) , Form ( " Raw Recoil DE(ch=%d) gated; DE (channel) " , i ) , 500 , rdtDERange [ 0 ] , rdtDERange [ 1 ] ) ;
///dE vs E
if ( i % 2 = = 0 ) {
int tempID = i / 2 ;
2024-07-06 17:48:31 -04:00
hrdt2D [ tempID ] = new TH2F ( Form ( " hrdt2D%d " , tempID ) , Form ( " Raw Recoil DE vs Eres (dE=%d, E=%d); Eres (channel); DE (channel) " , i + 1 , i ) , 500 , rdtERange [ 0 ] , rdtERange [ 1 ] , 500 , rdtDERange [ 0 ] , rdtDERange [ 1 ] ) ;
2023-04-06 19:05:20 -04:00
hrdt2Dg [ tempID ] = new TH2F ( Form ( " hrdt2Dg%d " , tempID ) , Form ( " Gated Raw Recoil DE vs Eres (dE=%d, E=%d); Eres (channel); DE (channel) " , i + 1 , i ) , 500 , rdtERange [ 0 ] , rdtERange [ 1 ] , 500 , rdtDERange [ 0 ] , rdtDERange [ 1 ] ) ;
}
}
2023-04-07 16:22:37 -04:00
hrdtRate1 = new TH1F ( " hrdtRate1 " , " recoil rate 1 / min; min; count / 1 min " , timeRangeInMin [ 1 ] - timeRangeInMin [ 0 ] , timeRangeInMin [ 0 ] , timeRangeInMin [ 1 ] ) ;
hrdtRate2 = new TH1F ( " hrdtRate2 " , " recoil rate 2 / min; min; count / 1 min " , timeRangeInMin [ 1 ] - timeRangeInMin [ 0 ] , timeRangeInMin [ 0 ] , timeRangeInMin [ 1 ] ) ;
2023-04-06 19:05:20 -04:00
hrdtRate1 - > SetLineColor ( 2 ) ;
hrdtRate2 - > SetLineColor ( 4 ) ;
//===================== multiplicity
hmultEZ = new TH1I ( " hmultEZ " , " Filled EZ with coinTime and recoil " , 10 , 0 , 10 ) ;
hmult = new TH2I ( " hmult " , " Array Multiplicity vs Recoil Multiplicity; Array ; Recoil " , 10 , 0 , 10 , 10 , 0 , 10 ) ;
hArrayRDTMatrix = new TH2I ( " hArrayRDTMatrix " , " Array ID vs Recoil ID; Array ID; Recoil ID " , 30 , 0 , 30 , 8 , 0 , 8 ) ;
hArrayRDTMatrixG = new TH2I ( " hArrayRDTMatrixG " , " Array ID vs Recoil ID / g; Array ID; Recoil ID " , 30 , 0 , 30 , 8 , 0 , 8 ) ;
//===================== coincident time
htdiff = new TH1I ( " htdiff " , " Coincident time (recoil-dE - array); time [ch = 10ns]; count " , coinTimeRange [ 1 ] - coinTimeRange [ 0 ] , coinTimeRange [ 0 ] , coinTimeRange [ 1 ] ) ;
htdiffg = new TH1I ( " htdiffg " , " Coincident time (recoil-dE - array) w/ recoil gated; time [ch = 10ns]; count " , coinTimeRange [ 1 ] - coinTimeRange [ 0 ] , coinTimeRange [ 0 ] , coinTimeRange [ 1 ] ) ;
2024-07-06 17:48:31 -04:00
2023-04-07 16:22:37 -04:00
printf ( " ============================================ End of histograms Declaration \n " ) ;
2023-04-06 19:05:20 -04:00
StpWatch . Start ( ) ;
}
//^###########################################################
//^ * Process
//^###########################################################
2023-04-06 20:03:08 -04:00
Bool_t Monitor : : Process ( Long64_t entry ) {
2023-04-06 19:05:20 -04:00
2023-04-07 16:22:37 -04:00
if ( entry = = 0 ) {
treeID + + ;
baseTimeStamp = ( treeID = = 0 ? 0 : endTime [ treeID - 1 ] ) ;
printf ( " ============================================ %s , treeID : %d \n " , __func__ , treeID ) ;
}
2023-04-06 19:05:20 -04:00
ProcessedEntries + + ;
//@*********** Progress Bar ******************************************/
2023-04-07 16:22:37 -04:00
if ( ProcessedEntries > = NumEntries * Frac - 1 ) {
2023-04-06 19:05:20 -04:00
TString msg ; msg . Form ( " %llu " , NumEntries / 1000 ) ;
int len = msg . Sizeof ( ) ;
printf ( " %3.0f%% (%*llu/%llu k) processed in %6.1f sec | expect %6.1f sec \n " ,
Frac * 100 , len , ProcessedEntries / 1000 , NumEntries / 1000 , StpWatch . RealTime ( ) , StpWatch . RealTime ( ) / Frac ) ;
StpWatch . Start ( kFALSE ) ;
2023-04-07 16:22:37 -04:00
Frac + = 0.1 ;
2023-04-06 19:05:20 -04:00
}
//@********** Get Branch *********************************************/
b_Energy - > GetEntry ( entry ) ;
b_XF - > GetEntry ( entry ) ;
b_XN - > GetEntry ( entry ) ;
b_EnergyTimestamp - > GetEntry ( entry ) ;
if ( isRDTExist ) {
b_RDT - > GetEntry ( entry ) ;
b_RDTTimestamp - > GetEntry ( entry ) ;
}
// if( isArrayTraceExist ) {
// ///b_Trace_Energy->GetEntry(entry);
// b_Trace_Energy_RiseTime->GetEntry(entry);
// b_Trace_Energy_Time->GetEntry(entry);
// }
// if( isRDTTraceExist ){
// ///b_Trace_RDT->GetEntry(entry);
// b_Trace_RDT_Time->GetEntry(entry);
// b_Trace_RDT_RiseTime->GetEntry(entry);
// }
//@*********** initization ******************************************/
for ( int i = 0 ; i < mapping : : NARRAY ; i + + ) {
z [ i ] = TMath : : QuietNaN ( ) ;
x [ i ] = TMath : : QuietNaN ( ) ;
xCal [ i ] = TMath : : QuietNaN ( ) ;
eCal [ i ] = TMath : : QuietNaN ( ) ;
}
//@*********** Apply Recoil correction here *************************/
2024-07-06 17:48:31 -04:00
if ( corr - > rdtCorr . size ( ) > = mapping : : NRDT ) {
2023-04-06 19:05:20 -04:00
for ( int i = 0 ; i < mapping : : NRDT ; i + + ) {
2024-07-06 17:48:31 -04:00
rdt [ i ] = corr - > rdtCorr [ i ] [ 0 ] + rdt [ i ] * corr - > rdtCorr [ i ] [ 1 ] ;
2023-04-06 19:05:20 -04:00
}
}
//@*********** Array ************************************************/
//Do calculations and fill histograms
Int_t recoilMulti = 0 ;
Int_t arrayMulti = 0 ;
Int_t multiEZ = 0 ;
bool rdtgate1 = false ;
bool rdtgate2 = false ;
bool coinFlag = false ;
bool ezGate = false ;
bool isGoodEventFlag = false ;
2024-07-06 17:48:31 -04:00
for ( Int_t id = 0 ; id < mapping : : NARRAY ; id + + ) {
2023-04-06 19:05:20 -04:00
//@================== Filling raw data
2024-07-06 17:48:31 -04:00
he [ id ] - > Fill ( e [ id ] ) ;
hxf [ id ] - > Fill ( xf [ id ] ) ;
hxn [ id ] - > Fill ( xn [ id ] ) ;
hxfVxn [ id ] - > Fill ( xf [ id ] , xn [ id ] ) ;
heVxs [ id ] - > Fill ( xf [ id ] + xn [ id ] , e [ id ] ) ;
2023-04-06 19:05:20 -04:00
2024-07-06 17:48:31 -04:00
heVID - > Fill ( id , e [ id ] ) ;
hxfVID - > Fill ( id , xf [ id ] ) ;
hxnVID - > Fill ( id , xn [ id ] ) ;
2023-04-06 19:05:20 -04:00
2024-07-06 17:48:31 -04:00
//if( !TMath::IsNaN(e[id]) ) printf("%llu | %d | %f %f %f \n", entry, id, e[id], xf[id], xn[id]);
2023-04-06 19:05:20 -04:00
//@==================== Basic gate
2024-07-06 17:48:31 -04:00
if ( TMath : : IsNaN ( e [ id ] ) ) continue ;
///if( ring[id] < -100 || ring[id] > 100 ) continue;
///if( ring[id] > 300 ) continue;
if ( TMath : : IsNaN ( xn [ id ] ) & & TMath : : IsNaN ( xf [ id ] ) ) continue ;
2023-04-06 19:05:20 -04:00
//@==================== Skip detector
bool skipFlag = false ;
for ( unsigned int kk = 0 ; kk < skipDetID . size ( ) ; kk + + ) {
2024-07-06 17:48:31 -04:00
if ( id = = skipDetID [ kk ] ) {
2023-04-06 19:05:20 -04:00
skipFlag = true ;
break ;
}
}
if ( skipFlag ) continue ;
//@==================== Basic gate
2024-07-06 17:48:31 -04:00
if ( TMath : : IsNaN ( e [ id ] ) ) continue ;
///if( ring[id] < -100 || ring[id] > 100 ) continue;
///if( ring[id] > 300 ) continue;
if ( TMath : : IsNaN ( xn [ id ] ) & & TMath : : IsNaN ( xf [ id ] ) ) continue ;
2023-04-06 19:05:20 -04:00
//@==================== Calibrations go here
2024-07-06 17:48:31 -04:00
if ( corr - > xnCorr . size ( ) corr - > xfxneCorr . size ( ) ) xnCal [ id ] = xn [ id ] * corr - > xnCorr [ id ] * corr - > xfxneCorr [ id ] [ 1 ] + corr - > xfxneCorr [ id ] [ 0 ] ;
if ( corr - > xfxneCorr . size ( ) ) xfCal [ id ] = xf [ id ] * corr - > xfxneCorr [ id ] [ 1 ] + corr - > xfxneCorr [ id ] [ 0 ] ;
if ( corr - > eCorr . size ( ) ) eCal [ id ] = e [ id ] / corr - > eCorr [ id ] [ 0 ] + corr - > eCorr [ id ] [ 1 ] ;
2023-04-06 19:05:20 -04:00
2024-07-06 17:48:31 -04:00
if ( eCal [ id ] < eCalCut [ 0 ] | | eCalCut [ 1 ] < eCal [ id ] ) continue ;
2023-04-06 19:05:20 -04:00
//@===================== fill Calibrated data
2024-07-06 17:48:31 -04:00
heCal [ id ] - > Fill ( eCal [ id ] ) ;
heCalID - > Fill ( id , eCal [ id ] ) ;
hxfCalVxnCal [ id ] - > Fill ( xfCal [ id ] , xnCal [ id ] ) ;
heVxsCal [ id ] - > Fill ( xnCal [ id ] + xfCal [ id ] , e [ id ] ) ;
2023-04-06 19:05:20 -04:00
//@===================== calculate X
2024-07-06 17:48:31 -04:00
if ( ( xf [ id ] > 0 | | ! TMath : : IsNaN ( xf [ id ] ) ) & & ( xn [ id ] > 0 | | ! TMath : : IsNaN ( xn [ id ] ) ) ) {
///x[id] = 0.5*((xf[id]-xn[id]) / (xf[id]+xn[id]))+0.5;
x [ id ] = 0.5 * ( ( xf [ id ] - xn [ id ] ) / e [ id ] ) + 0.5 ;
2023-04-06 19:05:20 -04:00
}
/// range of x is (0, 1)
2024-07-06 17:48:31 -04:00
if ( ! TMath : : IsNaN ( xf [ id ] ) & & ! TMath : : IsNaN ( xn [ id ] ) ) xCal [ id ] = 0.5 + 0.5 * ( xfCal [ id ] - xnCal [ id ] ) / e [ id ] ;
if ( ! TMath : : IsNaN ( xf [ id ] ) & & TMath : : IsNaN ( xn [ id ] ) ) xCal [ id ] = xfCal [ id ] / e [ id ] ;
if ( TMath : : IsNaN ( xf [ id ] ) & & ! TMath : : IsNaN ( xn [ id ] ) ) xCal [ id ] = 1.0 - xnCal [ id ] / e [ id ] ;
2023-04-06 19:05:20 -04:00
//@======= Scale xcal from (0,1)
2024-07-06 17:48:31 -04:00
if ( corr - > xScale . size ( ) ) xCal [ id ] = ( xCal [ id ] - 0.5 ) / corr - > xScale [ id ] + 0.5 ; /// if include this scale, need to also inclused in Cali_littleTree
2023-04-06 19:05:20 -04:00
2024-07-06 17:48:31 -04:00
if ( abs ( xCal [ id ] - 0.5 ) > xGate / 2. ) continue ;
2024-02-13 19:25:33 -05:00
2023-04-06 19:05:20 -04:00
//@==================== calculate Z
2024-07-06 17:48:31 -04:00
short arrayID = detGeo - > GetArrayID ( id ) ;
if ( arrayID > = 0 ) {
int colIndex = id % detGeo - > array [ arrayID ] . colDet ;
if ( detGeo - > array [ arrayID ] . firstPos > 0 ) {
z [ id ] = detGeo - > array [ arrayID ] . detLength * ( 1.0 - xCal [ id ] ) + detGeo - > array [ arrayID ] . detPos [ colIndex ] ;
} else {
z [ id ] = detGeo - > array [ arrayID ] . detLength * ( xCal [ id ] - 1.0 ) + detGeo - > array [ arrayID ] . detPos [ colIndex ] ;
}
2023-04-06 19:05:20 -04:00
}
//@===================== multiplicity
arrayMulti + + ; /// multi-hit when both e, xf, xn are not NaN
//@=================== Array fill
2024-07-06 17:48:31 -04:00
heVx [ id ] - > Fill ( x [ id ] , e [ id ] ) ;
2023-04-06 19:05:20 -04:00
2024-07-06 17:48:31 -04:00
heCalVxCal [ id ] - > Fill ( xCal [ id ] * detGeo - > array [ arrayID ] . detLength , eCal [ id ] ) ;
heCalVz - > Fill ( z [ id ] , eCal [ id ] ) ;
2023-04-06 19:05:20 -04:00
//@=================== Recoil Gate
if ( isRDTExist & & ( cutList1 | | cutList2 ) ) {
for ( int i = 0 ; i < cutList1 - > GetEntries ( ) ; i + + ) {
cutG = ( TCutG * ) cutList1 - > At ( i ) ;
if ( cutG - > IsInside ( rdt [ 2 * i ] , rdt [ 2 * i + 1 ] ) ) {
// if(cutG->IsInside(rdt[2*i] + rdt[2*i+1],rdt[2*i+1])) {
rdtgate1 = true ;
break ; /// only one is enough
}
}
for ( int i = 0 ; i < cutList2 - > GetEntries ( ) ; i + + ) {
cutG = ( TCutG * ) cutList2 - > At ( i ) ;
if ( cutG - > IsInside ( rdt [ 2 * i ] , rdt [ 2 * i + 1 ] ) ) {
//if(cutG->IsInside(rdt[2*i]+ rdt[2*i+1],rdt[2*i+1])) {
rdtgate2 = true ;
break ; /// only one is enough
}
}
} else {
rdtgate1 = true ;
rdtgate2 = true ;
}
//================ coincident with Recoil when z is calculated.
2024-07-06 17:48:31 -04:00
if ( ! TMath : : IsNaN ( z [ id ] ) ) {
2023-04-06 19:05:20 -04:00
for ( int j = 0 ; j < mapping : : NRDT ; j + + ) {
if ( TMath : : IsNaN ( rdt [ j ] ) ) continue ;
2024-07-06 17:48:31 -04:00
int tdiff = rdt_t [ j ] - e_t [ id ] ;
2023-04-06 19:05:20 -04:00
if ( j % 2 = = 1 ) {
htdiff - > Fill ( tdiff ) ;
2024-07-06 17:48:31 -04:00
if ( ( rdtgate1 | | rdtgate2 ) & & ( eCalCut [ 1 ] > eCal [ id ] & & eCal [ id ] > eCalCut [ 0 ] ) ) {
2023-04-06 19:05:20 -04:00
htdiffg - > Fill ( tdiff ) ;
}
}
2024-07-06 17:48:31 -04:00
hArrayRDTMatrix - > Fill ( id , j ) ;
2023-04-06 19:05:20 -04:00
if ( isTimeGateOn & & timeGate [ 0 ] < tdiff & & tdiff < timeGate [ 1 ] ) {
if ( j % 2 = = 0 ) hrdt2Dg [ j / 2 ] - > Fill ( rdt [ j ] , rdt [ j + 1 ] ) ; /// x=E, y=dE
///if(j % 2 == 0 ) hrdt2Dg[j/2]->Fill(rdt[j+1],rdt[j]); /// x=dE, y=E
2024-07-06 17:48:31 -04:00
hArrayRDTMatrixG - > Fill ( id , j ) ;
///if( rdtgate1) hArrayRDTMatrixG->Fill(id, j);
2023-04-06 19:05:20 -04:00
hrdtg [ j ] - > Fill ( rdt [ j ] ) ;
coinFlag = true ;
}
}
}
if ( ! isTimeGateOn ) coinFlag = true ;
//================ E-Z gate
2023-04-06 20:03:08 -04:00
if ( EZCut ) {
2024-07-06 17:48:31 -04:00
if ( EZCut - > IsInside ( z [ id ] , eCal [ id ] ) ) ezGate = true ;
2023-04-06 19:05:20 -04:00
} else {
ezGate = true ;
}
if ( coinFlag & & ( rdtgate1 | | rdtgate2 ) & & ezGate ) {
2024-07-06 17:48:31 -04:00
heCalVzGC - > Fill ( z [ id ] , eCal [ id ] ) ;
2023-04-06 19:05:20 -04:00
2024-07-06 17:48:31 -04:00
heCalVxCalG [ id ] - > Fill ( xCal [ id ] * detGeo - > array [ arrayID ] . detLength , eCal [ id ] ) ;
2023-04-06 19:05:20 -04:00
multiEZ + + ;
isGoodEventFlag = true ;
}
2023-04-06 20:03:08 -04:00
} //end of array loop
if ( EZCut = = nullptr ) ezGate = true ;
2023-04-06 19:05:20 -04:00
//@*********** RECOILS ***********************************************/
for ( int i = 0 ; i < mapping : : NRDT ; i + + ) {
hrdtID - > Fill ( i , rdt [ i ] ) ;
hrdt [ i ] - > Fill ( rdt [ i ] ) ;
2023-04-07 16:22:37 -04:00
if ( i % 2 = = 0 ) {
recoilMulti + + ; // when both dE and E are hit
hrdt2D [ i / 2 ] - > Fill ( rdt [ i ] , rdt [ i + 1 ] ) ; //E-dE
2023-04-06 19:05:20 -04:00
}
}
2023-04-07 16:22:37 -04:00
2024-07-06 17:48:31 -04:00
hrdtRate1 - > Fill ( ( e_t [ 1 ] + baseTimeStamp ) * tick2min ) ; //incorrect
2023-04-06 19:05:20 -04:00
//@******************* Multi-hit *************************************/
hmultEZ - > Fill ( multiEZ ) ;
hmult - > Fill ( recoilMulti , arrayMulti ) ;
hMultiHit - > Fill ( arrayMulti ) ;
//@*********** Good event Gate ***************************************/
if ( ! isGoodEventFlag ) return kTRUE ;
//@*********** Ex and thetaCM ****************************************/
2024-07-06 17:48:31 -04:00
for ( Int_t id = 0 ; id < mapping : : NARRAY ; id + + ) {
2023-04-06 19:05:20 -04:00
2024-07-06 17:48:31 -04:00
if ( TMath : : IsNaN ( e [ id ] ) ) continue ;
if ( TMath : : IsNaN ( z [ id ] ) ) continue ;
if ( eCal [ id ] < eCalCut [ 0 ] ) continue ;
if ( eCal [ id ] > eCalCut [ 1 ] ) continue ;
2023-04-06 19:05:20 -04:00
2024-07-06 17:48:31 -04:00
short arrayID = detGeo - > GetArrayID ( id ) ;
if ( arrayID < 0 ) continue ;
std : : pair < double , double > ExThetaCM = transfer - > CalExThetaCM ( eCal [ id ] , z [ id ] , detGeo - > Bfield , detGeo - > array [ arrayID ] . detPerpDist ) ;
2024-02-13 19:25:33 -05:00
double Ex = ExThetaCM . first ;
double thetaCM = ExThetaCM . second ;
2023-04-06 19:05:20 -04:00
if ( thetaCM > thetaCMGate ) {
hEx - > Fill ( Ex ) ;
hExThetaCM - > Fill ( thetaCM , Ex ) ;
if ( rdtgate1 ) {
hExCut1 - > Fill ( Ex ) ;
hExThetaCM - > Fill ( thetaCM , Ex ) ;
}
if ( rdtgate2 ) {
hExCut2 - > Fill ( Ex ) ;
hExThetaCM - > Fill ( thetaCM , Ex ) ;
}
2024-07-06 17:48:31 -04:00
hExi [ id ] - > Fill ( Ex ) ;
hExVxCal [ id ] - > Fill ( xCal [ id ] , Ex ) ;
2023-04-06 19:05:20 -04:00
}
}
return kTRUE ;
}
//^###########################################################
//^ * Terminate
//^###########################################################
2023-04-06 20:03:08 -04:00
void Monitor : : Terminate ( ) {
2023-04-07 16:22:37 -04:00
printf ( " ============================================ Drawing Canvas. \n " ) ;
2023-04-06 19:05:20 -04:00
gROOT - > cd ( ) ;
//############################################ User is free to edit this section
//--- Canvas Size
int canvasXY [ 2 ] = { 1200 , 800 } ; // x, y
int canvasDiv [ 2 ] = { 3 , 2 } ;
gStyle - > SetOptStat ( " neiou " ) ;
text . SetNDC ( ) ;
text . SetTextFont ( 82 ) ;
text . SetTextSize ( 0.04 ) ;
text . SetTextColor ( 2 ) ;
double yMax = 0 ;
Isotope hRecoil ( AnalysisLib : : reactionConfig . recoilHeavyA , AnalysisLib : : reactionConfig . recoilHeavyZ ) ;
double Sn = hRecoil . CalSp ( 0 , 1 ) ;
double Sp = hRecoil . CalSp ( 1 , 0 ) ;
double Sa = hRecoil . CalSp2 ( 4 , 2 ) ;
2024-07-06 17:48:31 -04:00
for ( int i = 0 ; i < detGeo - > numGeo ; i + + ) {
plotter [ i ] - > SetUpCanvas ( canvasTitle + " | " + rdtCutFile1 , canvasXY [ 0 ] , canvasXY [ 1 ] , canvasDiv [ 0 ] , canvasDiv [ 1 ] ) ;
// cCanvas[i] = new TCanvas("cCanvas",canvasTitle + " | " + rdtCutFile1,canvasXY[0],canvasXY[1]);
// cCanvas[i]->Modified(); cCanvas->Update();
// cCanvas[i]->cd(); cCanvas->Divide(canvasDiv[0],canvasDiv[1]);
plotter [ i ] - > canvas - > cd ( ) ;
2023-04-06 19:05:20 -04:00
2024-07-06 17:48:31 -04:00
///----------------------------------- Canvas - 1
PlotEZ ( 1 ) ; /// raw EZ
///----------------------------------- Canvas - 2
PlotEZ ( 0 ) ; ///gated EZ
2023-04-06 19:05:20 -04:00
2024-07-06 17:48:31 -04:00
///----------------------------------- Canvas - 3
PlotTDiff ( 1 , 1 ) ; ///with Gated Tdiff, isLog
///----------------------------------- Canvas - 4
padID + + ; cCanvas - > cd ( padID ) ;
//hEx->Draw();
hExCut1 - > Draw ( " " ) ;
hExCut2 - > Draw ( " same " ) ;
DrawLine ( hEx , Sn ) ;
DrawLine ( hEx , Sa ) ;
if ( isTimeGateOn ) text . DrawLatex ( 0.15 , 0.8 , Form ( " %d < coinTime < %d " , timeGate [ 0 ] , timeGate [ 1 ] ) ) ;
if ( xGate < 1 ) text . DrawLatex ( 0.15 , 0.75 , Form ( " with |x-0.5|<%.4f " , xGate / 2. ) ) ;
if ( cutList1 ) text . DrawLatex ( 0.15 , 0.7 , " with recoil gated " ) ;
2023-04-06 19:05:20 -04:00
2024-07-06 17:48:31 -04:00
///----------------------------------- Canvas - 5
padID + + ; cCanvas - > cd ( padID ) ;
//Draw2DHist(hExThetaCM);
//heVIDG->Draw();
//text.DrawLatex(0.15, 0.75, Form("#theta_{cm} > %.1f deg", thetaCMGate));
2023-04-06 19:05:20 -04:00
2024-07-06 17:48:31 -04:00
Draw2DHist ( hrdt2D [ 0 ] ) ;
// Draw2DHist(hrdt2Dsum[0]);
2023-04-06 19:05:20 -04:00
2024-07-06 17:48:31 -04:00
if ( cutList1 & & cutList1 - > GetEntries ( ) > 0 ) { cutG = ( TCutG * ) cutList1 - > At ( 0 ) ; cutG - > Draw ( " same " ) ; }
if ( cutList2 & & cutList2 - > GetEntries ( ) > 0 ) { cutG = ( TCutG * ) cutList2 - > At ( 0 ) ; cutG - > Draw ( " same " ) ; }
2023-04-06 19:05:20 -04:00
2024-07-06 17:48:31 -04:00
//helum4D->Draw();
//text.DrawLatex(0.25, 0.3, Form("gated from 800 to 1200 ch\n"));
///----------------------------------- Canvas - 6
PlotRDT ( 0 , 0 ) ;
// padID++; cCanvas->cd(padID);
// Draw2DHist(hrdtExGated);
//padID++; cCanvas->cd(padID);
//Draw2DHist(htacEx);
///------------------------------------- Canvas - 7
//PlotRDT(0, 0);
///----------------------------------- Canvas - 8
//PlotRDT(1, 0);
///yMax = hic2->GetMaximum()*1.2;
///hic2->GetYaxis()->SetRangeUser(0, yMax);
///hic2->Draw();
///TBox * box14N = new TBox (-10, 0, -2, yMax);
///box14N->SetFillColorAlpha(2, 0.1);
///box14N->Draw();
///
///TBox * box14C = new TBox (8, 0, 16, yMax);
///box14C->SetFillColorAlpha(4, 0.1);
///box14C->Draw();
///
///text.SetTextColor(2); text.DrawLatex(0.38, 0.50, "14N");
///text.SetTextColor(4); text.DrawLatex(0.6, 0.45, "14C");
///text.SetTextColor(2);
///----------------------------------- Canvas - 9
//padID++; cCanvas->cd(padID);
//Draw2DHist(hic01);
2023-04-06 19:05:20 -04:00
2024-07-06 17:48:31 -04:00
///----------------------------------- Canvas - 10
//PlotRDT(3,0);
//TH1F * helumDBIC = new TH1F("helumDBIC", "elum(d)/BIC; time [min]; count/min", timeRangeInMin[1]-timeRangeInMin[0], timeRangeInMin[0], timeRangeInMin[1]);
//helumDBIC = (TH1F*) helum4D->Clone();
//helumDBIC->SetTitle("elum(d)/BIC; time [min]; count/min");
//helumDBIC->SetName("helumDBIC");
//helumDBIC->SetLineColor(2);
//helumDBIC->Divide(hBIC);
//yMax = helumDBIC->GetMaximum();
//if( yMax < hBIC->GetMaximum() ) yMax = hBIC->GetMaximum();
//helumDBIC->SetMaximum(yMax * 1.2);
//hBIC->SetMaximum(yMax * 1.2);
//hBIC->Draw();
//helumDBIC->Draw("same");
//text.DrawLatex(0.15, 0.5, Form("Elum(D) / BIC \n"));
///----------------------------------- Canvas - 11
//PlotRDT(2,0);
///----------------------------------- Canvas - 12
//padID++; cCanvas->cd(padID);
//htac->Draw();
2023-04-06 19:05:20 -04:00
2024-07-06 17:48:31 -04:00
///----------------------------------- Canvas - 13
//padID++; cCanvas->cd(padID);
///hicT14N->Draw("");
///hicT14C->Draw("same");
///
///text.SetTextColor(2); text.DrawLatex(0.15, 0.60, "14N");
///text.SetTextColor(4); text.DrawLatex(0.15, 0.25, "14C");
///text.SetTextColor(2);
2023-04-06 19:05:20 -04:00
2024-07-06 17:48:31 -04:00
///----------------------------------- Canvas - 14
padID + + ; cCanvas - > cd ( padID ) ;
hrdtRate1 - > Draw ( " " ) ;
hrdtRate2 - > Draw ( " same " ) ;
///----------------------------------- Canvas - 15
//padID++; cCanvas->cd(padID);
///----------------------------------- Canvas - 16
//padID++; cCanvas->cd(padID);
2023-04-06 19:05:20 -04:00
2024-07-06 17:48:31 -04:00
///----------------------------------- Canvas - 17
//padID++; cCanvas->cd(padID);
2023-04-06 19:05:20 -04:00
2024-07-06 17:48:31 -04:00
///----------------------------------- Canvas - 18
//padID++; cCanvas->cd(padID);
2023-04-06 19:05:20 -04:00
2024-07-06 17:48:31 -04:00
///----------------------------------- Canvas - 19
//padID++; cCanvas->cd(padID);
///----------------------------------- Canvas - 20
//padID++; cCanvas->cd(padID);
2023-04-06 19:05:20 -04:00
2024-07-06 17:48:31 -04:00
}
2023-04-06 19:05:20 -04:00
/************************************/
gStyle - > GetAttDate ( ) - > SetTextSize ( 0.02 ) ;
gStyle - > SetOptDate ( 1 ) ;
gStyle - > SetDateX ( 0 ) ;
gStyle - > SetDateY ( 0 ) ;
/************************************/
StpWatch . Start ( kFALSE ) ;
2024-07-06 17:48:31 -04:00
// gROOT->ProcessLine(".L ../armory/Monitor_Util.C"); //TODO some pointer is empty
// printf("============================================ loaded Monitor_Utils.C\n");
2023-04-07 16:22:37 -04:00
//gROOT->ProcessLine(".L ../armory/AutoFit.C");
//printf("============================================ loaded armory/AutoFit.C\n");
2023-04-07 00:48:05 -04:00
// gROOT->ProcessLine(".L ../armory/RDTCutCreator.C");
2023-04-07 16:22:37 -04:00
// printf("============================================ loaded armory/RDTCutCreator.C\n");
2023-04-07 00:48:05 -04:00
// gROOT->ProcessLine(".L ../armory/Check_rdtGate.C");
2023-04-07 16:22:37 -04:00
// printf("============================================ loaded armory/Check_rdtGate.C\n");
2023-04-07 00:48:05 -04:00
// gROOT->ProcessLine(".L ../armory/readTrace.C");
2023-04-07 16:22:37 -04:00
// printf("============================================ loaded Armory/readTrace.C\n");
2023-04-07 00:48:05 -04:00
// gROOT->ProcessLine(".L ../armory/readRawTrace.C");
2023-04-07 16:22:37 -04:00
// printf("============================================ loaded Armory/readRawTrace.C\n");
2024-07-06 17:48:31 -04:00
// gROOT->ProcessLine("listDraws()");
2023-04-06 19:05:20 -04:00
/************************* Save histograms to root file*/
gROOT - > cd ( ) ;
/************************************/
//gROOT->ProcessLine("recoils()");
}