#define pstag_cxx // The class definition in pstag.h has been generated automatically // by the ROOT utility TTree::MakeSelector(). This class is derived // from the ROOT class TSelector. For more information on the TSelector // framework see $ROOTSYS/README/README.SELECTOR or the ROOT User Manual. // The following methods are defined in this file: // Begin(): called every time a loop on the tree starts, // a convenient place to create your histograms. // SlaveBegin(): called after Begin(), when on PROOF called only on the // slave servers. // Process(): called for each event, in this function you decide what // to read and fill your histograms. // SlaveTerminate: called at the end of the loop on the tree, when on PROOF // called only on the slave servers. // Terminate(): called at the end of the loop on the tree, // a convenient place to draw/fit your histograms. // // To use this file, try the following session on your Tree T: // // root> T->Process("pstag.C") // root> T->Process("pstag.C","some options") // root> T->Process("pstag.C+") // #include #include #include "pstag.h" #include #include #include #include void pstag::Begin(TTree * /*tree*/) { // The Begin() function is called at the start of the query. // When running with PROOF Begin() is only called on the client. // The tree argument is deprecated (on PROOF 0 is passed). TString option = GetOption(); } void pstag::SlaveBegin(TTree * /*tree*/) { // The SlaveBegin() function is called after the Begin() function. // When running with PROOF SlaveBegin() is called on each slave server. // The tree argument is deprecated (on PROOF 0 is passed). TString option = GetOption(); for (int col=1; col <= 102; ++col) { std::stringstream hname; std::stringstream htitle; hname << "htagm" << col << "ps"; htitle << "TAGM column " << col << " ps tags"; TH2D *h = new TH2D(hname.str().c_str(), htitle.str().c_str(), 200, 6, 12, 1024, -106, 150); std::stringstream xtitle; std::stringstream ytitle; xtitle << "ps pair energy (GeV)"; ytitle << "#Delta{t} (tag - ps) [ns]"; h->GetXaxis()->SetTitle(xtitle.str().c_str()); h->GetYaxis()->SetTitle(ytitle.str().c_str()); GetOutputList()->Add(h); hTAGMps.push_back(h); std::stringstream hname2; std::stringstream htitle2; hname2 << "Etagm" << col; htitle2 << "energy of TAGM column " << col; TH1D *h2 = new TH1D(hname2.str().c_str(), htitle2.str().c_str(), 2000, 7.5, 9.5); std::stringstream xtitle2; std::stringstream ytitle2; xtitle2 << "tagger energy (GeV)"; ytitle2 << "counts"; h2->GetXaxis()->SetTitle(xtitle2.str().c_str()); h2->GetYaxis()->SetTitle(ytitle2.str().c_str()); GetOutputList()->Add(h2); hTAGM.push_back(h2); } for (int chan=1; chan <= 272; ++chan) { std::stringstream hname; std::stringstream htitle; hname << "htagh" << chan << "ps"; htitle << "TAGH channel " << chan << " ps tags"; TH2D *h = new TH2D(hname.str().c_str(), htitle.str().c_str(), 200, 6, 12, 1024, -86, 170); std::stringstream xtitle; std::stringstream ytitle; xtitle << "ps pair energy (GeV)"; ytitle << "#Delta{t} (tag - ps) [ns]"; h->GetXaxis()->SetTitle(xtitle.str().c_str()); h->GetYaxis()->SetTitle(ytitle.str().c_str()); GetOutputList()->Add(h); hTAGHps.push_back(h); std::stringstream hname2; std::stringstream htitle2; hname2 << "Etagh" << chan; htitle2 << "energy of TAGH counter " << chan; TH1D *h2 = new TH1D(hname2.str().c_str(), htitle2.str().c_str(), 2000, 6.5, 11.5); std::stringstream xtitle2; std::stringstream ytitle2; xtitle2 << "tagger energy (GeV)"; ytitle2 << "counts"; h2->GetXaxis()->SetTitle(xtitle2.str().c_str()); h2->GetYaxis()->SetTitle(ytitle2.str().c_str()); GetOutputList()->Add(h2); hTAGH.push_back(h2); } } Bool_t pstag::Process(Long64_t entry) { // The Process() function is called for each entry in the tree (or possibly // keyed object in the case of PROOF) to be processed. The entry argument // specifies which entry in the currently loaded tree is to be processed. // When processing keyed objects with PROOF, the object is already loaded // and is available via the fObject pointer. // // This function should contain the \"body\" of the analysis. It can contain // simple or elaborate selection criteria, run algorithms on the data // of the event and typically fill histograms. // // The processing can be stopped by calling Abort(). // // Use fStatus to set the return value of TTree::Process(). // // The return value is currently not used. fReader.SetLocalEntry(entry); if (*npairps != 1) return kFALSE; double pstime = (pscleft_t[0] + pscright_t[0])/2; for (int ipairps=0; ipairps < *npairps; ++ipairps) { for (int itagm=0; itagm < *ntagm; ++itagm) { int icol = tagm_channel[itagm]; if (icol <= 102 && tagm_ttdc[itagm] != 0) { hTAGMps[icol-1]->Fill(Epair[ipairps], tagm_time[itagm] - pstime); hTAGM[icol-1]->Fill(tagm_Etag[itagm]); } } for (int itagh=0; itagh < *ntagh; ++itagh) { int ichan = tagh_counter[itagh]; if (ichan <= 272 && tagh_ttdc[itagh] != 0) { hTAGHps[ichan-1]->Fill(Epair[ipairps], tagh_time[itagh] - pstime); hTAGH[ichan-1]->Fill(tagh_Etag[itagh]); } } } return kTRUE; } void pstag::SlaveTerminate() { // The SlaveTerminate() function is called after all entries or objects // have been processed. When running with PROOF SlaveTerminate() is called // on each slave server. } void pstag::Terminate() { // The Terminate() function is the last function to be called during // a query. It always runs on the client, it can be used to present // the results graphically or save the results to file. TFile fout("pstag.root", "update"); TIter next(GetOutputList()); while (TObject *myobj = next()) { TH1 *h = dynamic_cast(myobj); if (h && h->GetEntries() > 0) h->Write(); } }