From ff00f341830ebbd722ae2740a69a595b7a345256 Mon Sep 17 00:00:00 2001 From: Vratislav Chudoba Date: Wed, 5 Oct 2016 11:59:21 +0300 Subject: [PATCH] Function AculCalibration::CalibrateRawSpectra() added. --- macros/myMacros/AnalysisxTree.C | 43 +++++ macros/myMacros/AnalysisxTree.h | 240 ++++++++++++++++++++++++++ macros/myMacros/makeClassFromTree.cxx | 14 ++ macros/myMacros/myMacro.cxx | 15 ++ 4 files changed, 312 insertions(+) create mode 100644 macros/myMacros/AnalysisxTree.C create mode 100644 macros/myMacros/AnalysisxTree.h create mode 100644 macros/myMacros/makeClassFromTree.cxx create mode 100644 macros/myMacros/myMacro.cxx diff --git a/macros/myMacros/AnalysisxTree.C b/macros/myMacros/AnalysisxTree.C new file mode 100644 index 0000000..b77d55e --- /dev/null +++ b/macros/myMacros/AnalysisxTree.C @@ -0,0 +1,43 @@ +#define AnalysisxTree_cxx +#include "AnalysisxTree.h" +#include +#include +#include + +void AnalysisxTree::Loop() +{ +// In a ROOT session, you can do: +// Root > .L AnalysisxTree.C +// Root > AnalysisxTree t +// Root > t.GetEntry(12); // Fill t data members with entry number 12 +// Root > t.Show(); // Show values of entry 12 +// Root > t.Show(16); // Read and show values of entry 16 +// Root > t.Loop(); // Loop on all entries +// + +// This is the loop skeleton where: +// jentry is the global entry number in the chain +// ientry is the entry number in the current Tree +// Note that the argument to GetEntry must be: +// jentry for TChain::GetEntry +// ientry for TTree::GetEntry and TBranch::GetEntry +// +// To read only selected branches, Insert statements like: +// METHOD1: +// fChain->SetBranchStatus("*",0); // disable all branches +// fChain->SetBranchStatus("branchname",1); // activate branchname +// METHOD2: replace line +// fChain->GetEntry(jentry); //read all branches +//by b_branchname->GetEntry(ientry); //read only this branch + if (fChain == 0) return; + + Long64_t nentries = fChain->GetEntriesFast(); + + Long64_t nbytes = 0, nb = 0; + for (Long64_t jentry=0; jentryGetEntry(jentry); nbytes += nb; + // if (Cut(ientry) < 0) continue; + } +} diff --git a/macros/myMacros/AnalysisxTree.h b/macros/myMacros/AnalysisxTree.h new file mode 100644 index 0000000..051fcde --- /dev/null +++ b/macros/myMacros/AnalysisxTree.h @@ -0,0 +1,240 @@ +////////////////////////////////////////////////////////// +// This class has been automatically generated on +// Mon Oct 3 10:53:30 2016 by ROOT version 5.34/30 +// from TTree AnalysisxTree/Go4FileStore +// found on file: clb01_0001.root +////////////////////////////////////////////////////////// + +#ifndef AnalysisxTree_h +#define AnalysisxTree_h + +#include +#include +#include + +// Header file for the classes stored in the TTree if any. + +// Fixed size dimensions of array or collections stored in the TTree if any. + const Int_t kMaxLiEvent = 1; + +class AnalysisxTree { +public : + TTree *fChain; //!pointer to the analyzed TTree or TChain + Int_t fCurrent; //!current Tree number in a TChain + + // Declaration of leaf types + //TLiEvent *LiEvent_; + //TLiEvent *LiEvent_TGo4EventElement; + UShort_t LiEvent_SQ11[16]; + UShort_t LiEvent_SQ12[32]; + UShort_t LiEvent_SQ13[16]; + UShort_t LiEvent_SQ21[16]; + UShort_t LiEvent_SQ22[32]; + UShort_t LiEvent_SQ23[16]; + UShort_t LiEvent_ANR[16]; + UShort_t LiEvent_ANS[16]; + UShort_t LiEvent_ANC[32]; + UShort_t LiEvent_TSQ11[16]; + UShort_t LiEvent_TSQ12[32]; + UShort_t LiEvent_TSQ21[16]; + UShort_t LiEvent_TSQ22[32]; + UShort_t LiEvent_TANR[16]; + UShort_t LiEvent_TANS[16]; + UShort_t LiEvent_QDC[16]; + UShort_t LiEvent_TDC[16]; + UShort_t LiEvent_SCR[16]; + UShort_t LiEvent_nx1; + UShort_t LiEvent_ny1; + UShort_t LiEvent_nx2; + UShort_t LiEvent_ny2; + UShort_t LiEvent_x1[32]; + UShort_t LiEvent_y1[32]; + UShort_t LiEvent_x2[32]; + UShort_t LiEvent_y2[32]; + UShort_t LiEvent_adc1[16]; + UShort_t LiEvent_adc2[16]; + UShort_t LiEvent_adc3[16]; + UShort_t LiEvent_adc4[16]; + UShort_t LiEvent_tdc1[32]; + UShort_t LiEvent_tdc2[32]; + UInt_t LiEvent_time; + Int_t LiEvent_nevent; + Int_t LiEvent_trigger; + Int_t LiEvent_subevents; + Int_t LiEvent_evsize; + + // List of branches + TBranch *b_LiEvent_SQ11; //! + TBranch *b_LiEvent_SQ12; //! + TBranch *b_LiEvent_SQ13; //! + TBranch *b_LiEvent_SQ21; //! + TBranch *b_LiEvent_SQ22; //! + TBranch *b_LiEvent_SQ23; //! + TBranch *b_LiEvent_ANR; //! + TBranch *b_LiEvent_ANS; //! + TBranch *b_LiEvent_ANC; //! + TBranch *b_LiEvent_TSQ11; //! + TBranch *b_LiEvent_TSQ12; //! + TBranch *b_LiEvent_TSQ21; //! + TBranch *b_LiEvent_TSQ22; //! + TBranch *b_LiEvent_TANR; //! + TBranch *b_LiEvent_TANS; //! + TBranch *b_LiEvent_QDC; //! + TBranch *b_LiEvent_TDC; //! + TBranch *b_LiEvent_SCR; //! + TBranch *b_LiEvent_nx1; //! + TBranch *b_LiEvent_ny1; //! + TBranch *b_LiEvent_nx2; //! + TBranch *b_LiEvent_ny2; //! + TBranch *b_LiEvent_x1; //! + TBranch *b_LiEvent_y1; //! + TBranch *b_LiEvent_x2; //! + TBranch *b_LiEvent_y2; //! + TBranch *b_LiEvent_adc1; //! + TBranch *b_LiEvent_adc2; //! + TBranch *b_LiEvent_adc3; //! + TBranch *b_LiEvent_adc4; //! + TBranch *b_LiEvent_tdc1; //! + TBranch *b_LiEvent_tdc2; //! + TBranch *b_LiEvent_time; //! + TBranch *b_LiEvent_nevent; //! + TBranch *b_LiEvent_trigger; //! + TBranch *b_LiEvent_subevents; //! + TBranch *b_LiEvent_evsize; //! + + AnalysisxTree(TTree *tree=0); + virtual ~AnalysisxTree(); + virtual Int_t Cut(Long64_t entry); + virtual Int_t GetEntry(Long64_t entry); + virtual Long64_t LoadTree(Long64_t entry); + virtual void Init(TTree *tree); + virtual void Loop(); + virtual Bool_t Notify(); + virtual void Show(Long64_t entry = -1); +}; + +#endif + +#ifdef AnalysisxTree_cxx +AnalysisxTree::AnalysisxTree(TTree *tree) : fChain(0) +{ +// if parameter tree is not specified (or zero), connect the file +// used to generate this class and read the Tree. + if (tree == 0) { + TFile *f = (TFile*)gROOT->GetListOfFiles()->FindObject("clb01_0001.root"); + if (!f || !f->IsOpen()) { + f = new TFile("clb01_0001.root"); + } + f->GetObject("AnalysisxTree",tree); + + } + Init(tree); +} + +AnalysisxTree::~AnalysisxTree() +{ + if (!fChain) return; + delete fChain->GetCurrentFile(); +} + +Int_t AnalysisxTree::GetEntry(Long64_t entry) +{ +// Read contents of entry. + if (!fChain) return 0; + return fChain->GetEntry(entry); +} +Long64_t AnalysisxTree::LoadTree(Long64_t entry) +{ +// Set the environment to read one entry + if (!fChain) return -5; + Long64_t centry = fChain->LoadTree(entry); + if (centry < 0) return centry; + if (fChain->GetTreeNumber() != fCurrent) { + fCurrent = fChain->GetTreeNumber(); + Notify(); + } + return centry; +} + +void AnalysisxTree::Init(TTree *tree) +{ + // The Init() function is called when the selector needs to initialize + // a new tree or chain. Typically here the branch addresses and branch + // pointers of the tree will be set. + // It is normally not necessary to make changes to the generated + // code, but the routine can be extended by the user if needed. + // Init() will be called many times when running on PROOF + // (once per file to be processed). + + // Set branch addresses and branch pointers + if (!tree) return; + fChain = tree; + fCurrent = -1; + fChain->SetMakeClass(1); + + fChain->SetBranchAddress("LiEvent.SQ11[16]", LiEvent_SQ11, &b_LiEvent_SQ11); + fChain->SetBranchAddress("LiEvent.SQ12[32]", LiEvent_SQ12, &b_LiEvent_SQ12); + fChain->SetBranchAddress("LiEvent.SQ13[16]", LiEvent_SQ13, &b_LiEvent_SQ13); + fChain->SetBranchAddress("LiEvent.SQ21[16]", LiEvent_SQ21, &b_LiEvent_SQ21); + fChain->SetBranchAddress("LiEvent.SQ22[32]", LiEvent_SQ22, &b_LiEvent_SQ22); + fChain->SetBranchAddress("LiEvent.SQ23[16]", LiEvent_SQ23, &b_LiEvent_SQ23); + fChain->SetBranchAddress("LiEvent.ANR[16]", LiEvent_ANR, &b_LiEvent_ANR); + fChain->SetBranchAddress("LiEvent.ANS[16]", LiEvent_ANS, &b_LiEvent_ANS); + fChain->SetBranchAddress("LiEvent.ANC[32]", LiEvent_ANC, &b_LiEvent_ANC); + fChain->SetBranchAddress("LiEvent.TSQ11[16]", LiEvent_TSQ11, &b_LiEvent_TSQ11); + fChain->SetBranchAddress("LiEvent.TSQ12[32]", LiEvent_TSQ12, &b_LiEvent_TSQ12); + fChain->SetBranchAddress("LiEvent.TSQ21[16]", LiEvent_TSQ21, &b_LiEvent_TSQ21); + fChain->SetBranchAddress("LiEvent.TSQ22[32]", LiEvent_TSQ22, &b_LiEvent_TSQ22); + fChain->SetBranchAddress("LiEvent.TANR[16]", LiEvent_TANR, &b_LiEvent_TANR); + fChain->SetBranchAddress("LiEvent.TANS[16]", LiEvent_TANS, &b_LiEvent_TANS); + fChain->SetBranchAddress("LiEvent.QDC[16]", LiEvent_QDC, &b_LiEvent_QDC); + fChain->SetBranchAddress("LiEvent.TDC[16]", LiEvent_TDC, &b_LiEvent_TDC); + fChain->SetBranchAddress("LiEvent.SCR[16]", LiEvent_SCR, &b_LiEvent_SCR); + fChain->SetBranchAddress("LiEvent.nx1", &LiEvent_nx1, &b_LiEvent_nx1); + fChain->SetBranchAddress("LiEvent.ny1", &LiEvent_ny1, &b_LiEvent_ny1); + fChain->SetBranchAddress("LiEvent.nx2", &LiEvent_nx2, &b_LiEvent_nx2); + fChain->SetBranchAddress("LiEvent.ny2", &LiEvent_ny2, &b_LiEvent_ny2); + fChain->SetBranchAddress("LiEvent.x1[32]", LiEvent_x1, &b_LiEvent_x1); + fChain->SetBranchAddress("LiEvent.y1[32]", LiEvent_y1, &b_LiEvent_y1); + fChain->SetBranchAddress("LiEvent.x2[32]", LiEvent_x2, &b_LiEvent_x2); + fChain->SetBranchAddress("LiEvent.y2[32]", LiEvent_y2, &b_LiEvent_y2); + fChain->SetBranchAddress("LiEvent.adc1[16]", LiEvent_adc1, &b_LiEvent_adc1); + fChain->SetBranchAddress("LiEvent.adc2[16]", LiEvent_adc2, &b_LiEvent_adc2); + fChain->SetBranchAddress("LiEvent.adc3[16]", LiEvent_adc3, &b_LiEvent_adc3); + fChain->SetBranchAddress("LiEvent.adc4[16]", LiEvent_adc4, &b_LiEvent_adc4); + fChain->SetBranchAddress("LiEvent.tdc1[32]", LiEvent_tdc1, &b_LiEvent_tdc1); + fChain->SetBranchAddress("LiEvent.tdc2[32]", LiEvent_tdc2, &b_LiEvent_tdc2); + fChain->SetBranchAddress("LiEvent.time", &LiEvent_time, &b_LiEvent_time); + fChain->SetBranchAddress("LiEvent.nevent", &LiEvent_nevent, &b_LiEvent_nevent); + fChain->SetBranchAddress("LiEvent.trigger", &LiEvent_trigger, &b_LiEvent_trigger); + fChain->SetBranchAddress("LiEvent.subevents", &LiEvent_subevents, &b_LiEvent_subevents); + fChain->SetBranchAddress("LiEvent.evsize", &LiEvent_evsize, &b_LiEvent_evsize); + Notify(); +} + +Bool_t AnalysisxTree::Notify() +{ + // The Notify() function is called when a new file is opened. This + // can be either for a new TTree in a TChain or when when a new TTree + // is started when using PROOF. It is normally not necessary to make changes + // to the generated code, but the routine can be extended by the + // user if needed. The return value is currently not used. + + return kTRUE; +} + +void AnalysisxTree::Show(Long64_t entry) +{ +// Print contents of entry. +// If entry is not specified, print current entry + if (!fChain) return; + fChain->Show(entry); +} +Int_t AnalysisxTree::Cut(Long64_t entry) +{ +// This function may be called from Loop. +// returns 1 if entry is accepted. +// returns -1 otherwise. + return 1; +} +#endif // #ifdef AnalysisxTree_cxx diff --git a/macros/myMacros/makeClassFromTree.cxx b/macros/myMacros/makeClassFromTree.cxx new file mode 100644 index 0000000..357b89e --- /dev/null +++ b/macros/myMacros/makeClassFromTree.cxx @@ -0,0 +1,14 @@ +#include "TROOT.h" + +void makeClassFromTree() +{ + gSystem->Load("../libAculData.so"); + + TFile fr("clb01_0001.root"); + TTree *tr = (TTree*)fr.Get("AnalysisxTree"); + + tr->MakeClass(); + +// tr->MakeCode(); + +} diff --git a/macros/myMacros/myMacro.cxx b/macros/myMacros/myMacro.cxx new file mode 100644 index 0000000..9855cfb --- /dev/null +++ b/macros/myMacros/myMacro.cxx @@ -0,0 +1,15 @@ +{ + + gSystem->Load("../../libAculData.so"); + + cout << "kasjbdjka" << endl; + + AculCalibration cal; + + UShort_t SQ22 = 14; + + cal.SomeFunction(SQ22, 3); + + + +} -- 2.18.1