2022-05-24 18:21:12 -04:00
|
|
|
//////////////////////////////////////////////////////////
|
|
|
|
// This class has been automatically generated on
|
|
|
|
// Fri May 13 17:59:58 2022 by ROOT version 6.24/06
|
|
|
|
// from TTree tree/root_data/run-0143-00.root
|
|
|
|
// found on file: root_data/run-0143-00.root
|
|
|
|
//////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#ifndef peachCake_h
|
|
|
|
#define peachCake_h
|
|
|
|
|
|
|
|
#include <TROOT.h>
|
|
|
|
#include <TChain.h>
|
|
|
|
#include <TFile.h>
|
2022-06-28 16:04:20 -04:00
|
|
|
#include <TH2.h>
|
|
|
|
#include <TH1.h>
|
2022-05-24 18:21:12 -04:00
|
|
|
#include <TSelector.h>
|
|
|
|
#include <TBenchmark.h>
|
|
|
|
#include "cmath"
|
|
|
|
|
|
|
|
// Header file for the classes stored in the TTree if any.
|
|
|
|
|
|
|
|
class peachCake : public TSelector {
|
|
|
|
public :
|
|
|
|
TChain *fChain; //!pointer to the analyzed TTree or TChain
|
|
|
|
|
|
|
|
// Fixed size dimensions of array or collections stored in the TTree if any.
|
|
|
|
|
|
|
|
// Declaration of leaf types
|
|
|
|
ULong64_t evID;
|
|
|
|
Int_t multi;
|
|
|
|
Int_t detID[416]; //[multi]
|
|
|
|
Double_t e[416]; //[multi]
|
|
|
|
ULong64_t e_t[416]; //[multi]
|
|
|
|
Int_t cfd[416]; //[multi]
|
|
|
|
Int_t qdc[416][8]; //[multi]
|
|
|
|
Int_t multiClover;
|
|
|
|
Int_t multiBeam;
|
|
|
|
Int_t runID;
|
|
|
|
|
|
|
|
// List of branches
|
|
|
|
TBranch *b_event_ID; //!
|
|
|
|
TBranch *b_multi; //!
|
|
|
|
TBranch *b_detID; //!
|
|
|
|
TBranch *b_e; //!
|
|
|
|
TBranch *b_e_t; //!
|
|
|
|
TBranch *b_cfd; //!
|
|
|
|
TBranch *b_qdc; //!
|
|
|
|
TBranch *b_multiplicity_Clover; //!
|
|
|
|
TBranch *b_multiplicity_Beam; //!
|
|
|
|
TBranch *b_runID; //!
|
|
|
|
|
2022-06-08 14:43:03 -04:00
|
|
|
peachCake(TTree * /*tree*/ =0) : fChain(0) {
|
|
|
|
saveNewTree = false;
|
2022-06-22 19:33:20 -04:00
|
|
|
pidCorrFileName = "";
|
|
|
|
fHistRootName = "";
|
|
|
|
plotHists = true;
|
2022-06-28 16:04:20 -04:00
|
|
|
canvasTitle = "Run: ";
|
|
|
|
lastRunID = -1;
|
|
|
|
contFlag = false;
|
2022-06-08 14:43:03 -04:00
|
|
|
}
|
2022-05-24 18:21:12 -04:00
|
|
|
virtual ~peachCake() { }
|
|
|
|
virtual Int_t Version() const { return 2; }
|
|
|
|
virtual void Begin(TTree *tree);
|
|
|
|
virtual void SlaveBegin(TTree *tree);
|
|
|
|
virtual void Init(TTree *tree);
|
|
|
|
virtual Bool_t Notify();
|
|
|
|
virtual Bool_t Process(Long64_t entry);
|
|
|
|
virtual Int_t GetEntry(Long64_t entry, Int_t getall = 0) { return fChain ? fChain->GetTree()->GetEntry(entry, getall) : 0; }
|
|
|
|
virtual void SetOption(const char *option) { fOption = option; }
|
|
|
|
virtual void SetObject(TObject *obj) { fObject = obj; }
|
|
|
|
virtual void SetInputList(TList *input) { fInput = input; }
|
|
|
|
virtual TList *GetOutputList() const { return fOutput; }
|
|
|
|
virtual void SlaveTerminate();
|
|
|
|
virtual void Terminate();
|
2022-06-08 14:43:03 -04:00
|
|
|
|
|
|
|
void SaveNewTree(bool YesOrNo){ saveNewTree = YesOrNo;}
|
2022-06-22 19:33:20 -04:00
|
|
|
void SetPIDCorrectionFile(TString corr_PID){ pidCorrFileName = corr_PID;}
|
|
|
|
|
|
|
|
void SetHistRootFileName(TString fileName){ fHistRootName = fileName;}
|
|
|
|
|
|
|
|
void SetPlotHist(bool onOff) { plotHists = onOff; }
|
2022-05-24 18:21:12 -04:00
|
|
|
|
|
|
|
ClassDef(peachCake,0);
|
|
|
|
|
2022-06-22 19:33:20 -04:00
|
|
|
TString pidCorrFileName;
|
2024-05-30 16:06:10 -04:00
|
|
|
std::vector<std::vector<double>> pidCorr;
|
2022-06-22 19:33:20 -04:00
|
|
|
|
2022-05-24 18:21:12 -04:00
|
|
|
//=========== varibales in new tree
|
2022-06-08 14:43:03 -04:00
|
|
|
bool saveNewTree;
|
|
|
|
|
2022-05-24 18:21:12 -04:00
|
|
|
TFile * saveFile;
|
|
|
|
TTree * newTree;
|
|
|
|
TString saveFileName;
|
|
|
|
int totnumEntry; //of the original file
|
|
|
|
|
|
|
|
//tree
|
|
|
|
Int_t eventID;
|
|
|
|
UInt_t crossEnergy;
|
|
|
|
ULong64_t crossTime;
|
2023-05-18 16:33:51 -04:00
|
|
|
Double_t TOF, dE;
|
|
|
|
Double_t Z, AoQ;
|
2022-05-24 18:21:12 -04:00
|
|
|
|
|
|
|
Short_t flag; /// 1 = has beam, 2 = has Ions, 4 = hasBeta, default 0;
|
|
|
|
|
|
|
|
Double_t xIons;
|
|
|
|
Double_t yIons;
|
|
|
|
Double_t xBeta;
|
|
|
|
Double_t yBeta;
|
|
|
|
UInt_t dyIonsEnergy[4];
|
|
|
|
ULong64_t dyIonsTime[4];
|
|
|
|
UInt_t dyBetaEnergy[4];
|
|
|
|
ULong64_t dyBetaTime[4];
|
|
|
|
Double_t veto_f;
|
|
|
|
ULong64_t veto_f_time;
|
|
|
|
Double_t veto_r;
|
|
|
|
ULong64_t veto_r_time;
|
|
|
|
|
|
|
|
Short_t vetoFlag; /// default = 0, 1 = front, 2 = rear, 4 = cross
|
|
|
|
|
|
|
|
//clock
|
|
|
|
TBenchmark clock;
|
|
|
|
Bool_t shown;
|
|
|
|
|
|
|
|
Long64_t nProcessed;
|
|
|
|
|
2022-06-22 19:33:20 -04:00
|
|
|
TString fHistRootName;
|
|
|
|
|
|
|
|
bool plotHists;
|
|
|
|
|
2022-06-27 20:21:44 -04:00
|
|
|
TString canvasTitle;
|
2022-06-28 16:04:20 -04:00
|
|
|
int lastRunID;
|
|
|
|
bool contFlag;
|
2022-05-24 18:21:12 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef peachCake_cxx
|
|
|
|
void peachCake::Init(TTree *tree){
|
|
|
|
|
|
|
|
// Set branch addresses and branch pointers
|
|
|
|
if (!tree) return;
|
|
|
|
|
|
|
|
totnumEntry = tree->GetEntries();
|
|
|
|
printf("============= num entry : %d\n", totnumEntry);
|
|
|
|
|
|
|
|
fChain = (TChain *)tree;
|
|
|
|
fChain->SetMakeClass(1);
|
|
|
|
|
|
|
|
fChain->SetBranchAddress("evID", &evID, &b_event_ID);
|
|
|
|
fChain->SetBranchAddress("multi", &multi, &b_multi);
|
|
|
|
fChain->SetBranchAddress("detID", detID, &b_detID);
|
|
|
|
fChain->SetBranchAddress("e", e, &b_e);
|
|
|
|
fChain->SetBranchAddress("e_t", e_t, &b_e_t);
|
|
|
|
fChain->SetBranchAddress("cfd", cfd, &b_cfd);
|
|
|
|
fChain->SetBranchAddress("qdc", qdc, &b_qdc);
|
|
|
|
fChain->SetBranchAddress("multiClover", &multiClover, &b_multiplicity_Clover);
|
|
|
|
fChain->SetBranchAddress("multiBeam", &multiBeam, &b_multiplicity_Beam);
|
|
|
|
fChain->SetBranchAddress("runID", &runID, &b_runID);
|
|
|
|
|
|
|
|
//============ new tree
|
2022-06-08 14:43:03 -04:00
|
|
|
printf(" is save tree? :%d \n", saveNewTree);
|
2022-05-24 18:21:12 -04:00
|
|
|
|
2022-06-08 14:43:03 -04:00
|
|
|
if( saveNewTree ){
|
2023-05-18 16:33:51 -04:00
|
|
|
saveFileName = "zzz_";
|
|
|
|
int oldRun = -1;
|
|
|
|
bool flag1 = false;
|
|
|
|
int numFile = fChain->GetListOfFiles()->GetLast()+1;
|
|
|
|
for( int i = 0; i < numFile; i++){
|
|
|
|
TString name = fChain->GetListOfFiles()->At(i)->GetTitle();
|
|
|
|
int pos = name.Last('/');
|
|
|
|
name = name.Remove(0,pos+1); ///this should be run-XXXX-XX.root
|
|
|
|
pos = name.Last('-');
|
|
|
|
name = name.Remove(pos);
|
|
|
|
pos = name.Last('-');
|
|
|
|
name = name.Remove(0, pos+2);
|
|
|
|
int runNum = atoi(name);
|
|
|
|
if( runNum == oldRun + 1 ) {
|
|
|
|
int len = saveFileName.Sizeof();
|
|
|
|
if( flag1 == false) {
|
|
|
|
saveFileName += "-";
|
|
|
|
}
|
|
|
|
if( flag1 == true) saveFileName.Remove(len-4);
|
|
|
|
flag1 = true;
|
|
|
|
}
|
|
|
|
if( runNum > oldRun + 1 ) {
|
|
|
|
flag1 = false;
|
|
|
|
saveFileName += "_";
|
|
|
|
}
|
|
|
|
if( runNum > oldRun ){
|
|
|
|
saveFileName += Form("%03d", runNum );
|
|
|
|
oldRun = runNum;
|
|
|
|
}
|
2022-06-08 14:43:03 -04:00
|
|
|
}
|
2023-05-18 16:33:51 -04:00
|
|
|
saveFileName = saveFileName + ".root";
|
2022-06-08 14:43:03 -04:00
|
|
|
|
2023-05-18 16:33:51 -04:00
|
|
|
printf("=========== saveFile : %s \n", saveFileName.Data());
|
2022-06-08 14:43:03 -04:00
|
|
|
|
2023-05-18 16:33:51 -04:00
|
|
|
saveFile = new TFile(saveFileName, "recreate");
|
|
|
|
newTree = new TTree("tree", "tree");
|
2022-06-08 14:43:03 -04:00
|
|
|
|
2023-05-18 16:33:51 -04:00
|
|
|
newTree->Branch("eventID", &eventID, "eventID/l");
|
|
|
|
newTree->Branch("runID", &runID, "runID/I");
|
|
|
|
///newTree->Branch("TOF", &TOF, "TOF/D");
|
|
|
|
///newTree->Branch("dE", &dE, "dE/D");
|
|
|
|
newTree->Branch("AoQ", &AoQ, "AoQ/D");
|
|
|
|
newTree->Branch("Z", &Z, "Z/D");
|
|
|
|
newTree->Branch("crossTime", &crossTime, "crossTime/l");
|
|
|
|
newTree->Branch("crossEnergy", &crossEnergy, "crossEnergy/i");
|
|
|
|
newTree->Branch("flag", &flag, "flag/S");
|
|
|
|
newTree->Branch("vetoFlag", &vetoFlag, "vetoFlag/S");
|
|
|
|
newTree->Branch("xIons", &xIons, "xIons/D");
|
|
|
|
newTree->Branch("yIons", &yIons, "yIons/D");
|
|
|
|
newTree->Branch("xBeta", &xBeta, "xBeta/D");
|
|
|
|
newTree->Branch("yBeta", &yBeta, "yBeta/D");
|
|
|
|
newTree->Branch("dyIonsTime", dyIonsTime, "dyIonsTime[4]/l");
|
|
|
|
newTree->Branch("dyBetaTime", dyBetaTime, "dyBetaTime[4]/l");
|
|
|
|
newTree->Branch("veto_f", &veto_f, "veto_f/D");
|
|
|
|
newTree->Branch("veto_r", &veto_r, "veto_r/D");
|
2022-06-08 14:43:03 -04:00
|
|
|
}
|
2022-05-24 18:21:12 -04:00
|
|
|
|
|
|
|
//==== clock
|
|
|
|
clock.Reset();
|
|
|
|
clock.Start("timer");
|
|
|
|
shown = 0;
|
|
|
|
|
|
|
|
nProcessed = 0;
|
|
|
|
|
2022-06-22 19:33:20 -04:00
|
|
|
printf("==========================================\n");
|
2022-05-24 18:21:12 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
Bool_t peachCake::Notify(){
|
|
|
|
|
|
|
|
return kTRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
void peachCake::SlaveBegin(TTree * /*tree*/){
|
|
|
|
TString option = GetOption();
|
|
|
|
}
|
|
|
|
|
|
|
|
void peachCake::SlaveTerminate(){
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-06-28 16:04:20 -04:00
|
|
|
TH2F * createTH2F(const char* name, const char* title, Int_t nbinsx, Double_t xlow, Double_t xup, Int_t nbinsy, Double_t ylow, Double_t yup){
|
|
|
|
|
|
|
|
TH2F * hist2 = (TH2F *) gROOT->FindObjectAny( name );
|
|
|
|
if ( hist2 == NULL ) hist2 = new TH2F( name , title , nbinsx, xlow, xup, nbinsy, ylow, yup);
|
|
|
|
hist2->Reset();
|
|
|
|
|
|
|
|
return hist2;
|
|
|
|
}
|
|
|
|
|
|
|
|
TH1F * createTH1F(const char* name, const char* title, Int_t nbinsx, Double_t xlow, Double_t xup){
|
|
|
|
|
|
|
|
TH1F * hist1 = (TH1F *) gROOT->FindObjectAny( name );
|
|
|
|
if ( hist1 == NULL ) hist1 = new TH1F( name , title , nbinsx, xlow, xup);
|
|
|
|
hist1->Reset();
|
|
|
|
|
|
|
|
return hist1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-05-24 18:21:12 -04:00
|
|
|
#endif // #ifdef peachCake_cxx
|