FRIB_e21062/peachCake.h
2022-05-24 18:21:12 -04:00

202 lines
6.2 KiB
C++

//////////////////////////////////////////////////////////
// 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>
#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; //!
peachCake(TTree * /*tree*/ =0) : fChain(0) { }
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();
ClassDef(peachCake,0);
//=========== varibales in new tree
TFile * saveFile;
TTree * newTree;
TString saveFileName;
int totnumEntry; //of the original file
//tree
Int_t eventID;
UInt_t crossEnergy;
ULong64_t crossTime;
Double_t TOF;
Double_t energy;
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;
};
#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
saveFileName = "test";
int oldSeg = -100;
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
if( i == 0 ) {
saveFileName = name;
pos = saveFileName.Last('-');
saveFileName = saveFileName.Remove(pos); //run-XXXX
}
pos = name.Last('-');
int segNum = atoi(name.Remove(0, pos+1).Remove(2));
if( oldSeg == -100 ) oldSeg = segNum;
saveFileName = saveFileName + Form("_%02d",segNum);
if( segNum == oldSeg + 1 && i != numFile -1 ){
int len = saveFileName.Length();
saveFileName = saveFileName.Remove(len - 3);
oldSeg = segNum;
}
}
saveFileName = saveFileName + ".root";
printf("=========== saveFile : %s \n", saveFileName.Data());
saveFile = new TFile(saveFileName, "recreate");
newTree = new TTree("tree", "tree");
newTree->Branch("eventID", &eventID, "eventID/l");
//newTree->Branch("runID", &runID, "runID/I");
newTree->Branch("TOF", &TOF, "TOF/D");
newTree->Branch("energy", &energy, "energy/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");
//==== clock
clock.Reset();
clock.Start("timer");
shown = 0;
nProcessed = 0;
}
Bool_t peachCake::Notify(){
return kTRUE;
}
void peachCake::SlaveBegin(TTree * /*tree*/){
TString option = GetOption();
}
void peachCake::SlaveTerminate(){
}
#endif // #ifdef peachCake_cxx