////////////////////////////////////////////////////////// // 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 #include #include #include #include #include #include #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) { saveNewTree = false; pidCorrFileName = ""; fHistRootName = ""; plotHists = true; canvasTitle = "Run: "; lastRunID = -1; contFlag = false; } 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(); void SaveNewTree(bool YesOrNo){ saveNewTree = YesOrNo;} void SetPIDCorrectionFile(TString corr_PID){ pidCorrFileName = corr_PID;} void SetHistRootFileName(TString fileName){ fHistRootName = fileName;} void SetPlotHist(bool onOff) { plotHists = onOff; } ClassDef(peachCake,0); TString pidCorrFileName; std::vector> pidCorr; //=========== varibales in new tree bool saveNewTree; TFile * saveFile; TTree * newTree; TString saveFileName; unsigned long int totnumEntry; //of the original file //tree Int_t eventID; UInt_t crossEnergy; ULong64_t crossTime; Double_t TOF, dE; Double_t Z, AoQ; 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; TString fHistRootName; bool plotHists; TString canvasTitle; int lastRunID; bool contFlag; }; #endif #ifdef peachCake_cxx void peachCake::Init(TTree *tree){ // Set branch addresses and branch pointers if (!tree) return; totnumEntry = tree->GetEntries(); printf("============= num entry : %lu\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 printf(" is save tree? :%d \n", saveNewTree); if( saveNewTree ){ 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; } } 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("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"); } //==== clock clock.Reset(); clock.Start("timer"); shown = 0; nProcessed = 0; printf("==========================================\n"); } Bool_t peachCake::Notify(){ return kTRUE; } void peachCake::SlaveBegin(TTree * /*tree*/){ TString option = GetOption(); } void peachCake::SlaveTerminate(){ } 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; } #endif // #ifdef peachCake_cxx