////////////////////////////////////////////////////////// // // Tracer.h - "makeclass" for root "tree1" trees generated // by the uconn.cc utility. // // author: richard.t.jones at uconn.edu // version: june 1, 2014 // // This class has been automatically generated on // Tue Feb 11 14:01:19 2014 by ROOT version 5.34/09 // from TTree tree1/Sipm test // found on file: data/simple_91.root ////////////////////////////////////////////////////////// #ifndef Tracer_h #define Tracer_h #include #include #include #include #include #include #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. class Tracer { public : TTree *fChain; //!pointer to the analyzed TTree or TChain Int_t fCurrent; //!current Tree number in a TChain static const int fWindowWidth = 256; // Declaration of leaf types Int_t fadc_raw[2][16][fWindowWidth]; Int_t fadc_pulse[2][16][fWindowWidth]; Int_t nhit_tdc; Int_t tdc_ch[3]; //[nhit_tdc] Int_t tdc_time[3]; //[nhit_tdc] // List of branches TBranch *b_fadc_raw; //! TBranch *b_fadc_pulse; //! TBranch *b_nhit_tdc; //! TBranch *b_tdc_ch; //! TBranch *b_tdc_time; //! Tracer(TTree *tree=0); virtual ~Tracer(); 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 Bool_t Notify(); virtual TH1D* Loop(int channel, int pulse = 0, int fadc = 0); virtual TH1D* Spec(int channel, int pulse = 0, int fadc = 0); virtual TH1D* Show(int channel, int pulse = 0, int fadc = 0, Long64_t entry = -1); virtual TProfile* Prof(int channel, int pulse = 0, int fadc = 0); virtual TTree* Tree(char *tname, int pulse = 0, int fadc = 0); private: int overflow_fill(Int_t *fadc_array, int fadc_size); }; #endif #ifdef Tracer_cxx Tracer::Tracer(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("data/simple_174.root"); if (!f || !f->IsOpen()) { f = new TFile("data/simple_174.root"); } f->GetObject("tree1",tree); } Init(tree); } Tracer::~Tracer() { if (!fChain) return; delete fChain->GetCurrentFile(); } Int_t Tracer::GetEntry(Long64_t entry) { // Read contents of entry. if (!fChain) return 0; return fChain->GetEntry(entry); } Long64_t Tracer::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 Tracer::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("fadc_raw", fadc_raw, &b_fadc_raw); fChain->SetBranchAddress("fadc_pulse", fadc_pulse, &b_fadc_pulse); fChain->SetBranchAddress("nhit_tdc", &nhit_tdc, &b_nhit_tdc); fChain->SetBranchAddress("tdc_ch", tdc_ch, &b_tdc_ch); fChain->SetBranchAddress("tdc_time", tdc_time, &b_tdc_time); Notify(); } Bool_t Tracer::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; } TH1D* Tracer::Show(int channel, int pulse, int fadc, Long64_t entry) { // Creates a 1d histogram containing the raw pulse train, // displays the histogram, and returns a pointer to it. char title[80]; TH1D *h1d; if (pulse) { sprintf(title, "fadc_pulse %lld", entry); h1d = new TH1D("pulse", title, fWindowWidth, -2., fWindowWidth*4-2.); } else { sprintf(title, "fadc_raw %lld", entry); h1d = new TH1D("raw", title, fWindowWidth, -2., fWindowWidth*4-2.); } Long64_t ent[2] = {entry, entry}; if (entry < 2) { Long64_t nentries = fChain->GetEntriesFast(); ent[0] = 2; ent[1] = nentries; } for (Long64_t e=ent[0]; e <= ent[1]; ++e) { GetEntry(e); for (int n=0; n < fWindowWidth; ++n) { if (pulse) { overflow_fill(fadc_pulse[fadc][channel],fWindowWidth); h1d->Fill(n*4.0,float(fadc_pulse[fadc][channel][n])); } else { overflow_fill(fadc_raw[fadc][channel],fWindowWidth); h1d->Fill(n*4.0,float(fadc_raw[fadc][channel][n])); } } } TCanvas *c1 = (TCanvas*)gROOT->FindObject("c1"); if (c1 == 0) { c1 = new TCanvas("c1","c1",0,20,600,500); } h1d->Draw(); pulse_analyzer pana(fadc_raw[0][0], 16, fWindowWidth); #if PHEIGHT_TRIG_SCANNING double pheight = pana.pheight_trig_scanning(channel); #elif PHEIGHT_TRIG_SUMMER double pheight = pana.pheight_trig_summer(channel); #else double pheight = pana.pheight_trig_pulser(channel); #endif double pnorm = pana.pulse_normalization(); std::cout << "Pulse integral is " << pheight << " (ADC count units)." << std::endl << "Normalized pulse integral is " << pheight/pnorm << std::endl; return h1d; } Int_t Tracer::Cut(Long64_t entry) { // This function may be called from Loop. // returns 1 if entry is accepted. // returns -1 otherwise. return (entry > 0)? 1 : 0; } #endif // #ifdef Tracer_cxx