#define CShiftSort_cxx // The class definition in CShiftSort.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("CShiftSort.C") // root> T->Process("CShiftSort.C","some options") // root> T->Process("CShiftSort.C+") // #include "CShiftSort.h" #include #include #include #include "TChain.h" #include "TTree.h" #include "TFile.h" #include "TH1.h" #include "TH3F.h" #include "THnSparse.h" #include "TAxis.h" #include "TMath.h" #include "TSpectrum2.h" #include "TProof.h" #include "TSelector.h" //TFile *f; THnSparse *sparse3D; TH2F *his2D; Long64_t MaxNbins = 268435456; // number of THnSparse cells limit UInt_t CubDim = 1000; //Int_t _MAX_No_Clover_ = 16; void CShiftSort::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 CShiftSort::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(); Int_t bins[3] = {(Int_t)CubDim, (Int_t)CubDim, (Int_t)CubDim}; Double_t xmin[3] = {0., 0., 0.}; Double_t xmax[3] = {(Double_t)CubDim, (Double_t)CubDim, (Double_t)CubDim}; sparse3D = new THnSparseF("sparse3D", "sparse3D;EarlyX;DelayedY;TimeDiffZ;N", 3, bins, xmin, xmax); his2D = new TH2F("his2D","his2D",4096,0,4096,4096,0,4096); fOutput->Add(sparse3D); fOutput->Add(his2D); } Bool_t CShiftSort::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); //double delta_T1 = 0.0, delta_T2 = 0.0; Int_t delta_T1 = 0.0, delta_T2 = 0.0; UInt_t E_Early, E_Delayed, x, y, z; Int_t CMult, NClover; CMult = Int_t(*clov_mult); NClover = Int_t(*No_Clover); if(CMult > 1) { for(Int_t j = 0; j < NClover; j++) { for(Int_t k = 0; k < NClover; k++) { //if((k != j) && ((CLT[j] > 0) && (CLT[j] < 8192 )) && ((CLT[k] > 0) && ( CLT[k] < 8192)) && (Eclab[j] != Eclab[k])){ if((k != j) && (Eclab[j] != Eclab[k])){ E_Early = 0; E_Delayed = 0; //E_Early = Eclab[k]/2; //E_Delayed = Eclab[j]/2; //delta_T1 = abs(Int_t(CLT[j] - CLT[k])); //delta_T2 = Int_t(CLT[k] - CLT[j]); if(CLT[j]>CLT[k]){ E_Early = Eclab[k]/2; E_Delayed = Eclab[j]/2; delta_T1 = CLT[j] - CLT[k]; } else if (CLT[j] 10) && (E_Early < CubDim) && (E_Delayed > 10) && (E_Delayed < CubDim)) { x = E_Early; y = E_Delayed; z = 500 + (delta_T1/10); //Energy Calibration == 1keV/ch; Time Calibration == 1ns/ch double e1[3] = {(x + 1.e-6), (y + 1.e-6), (z + 1.e-6)}; //if (sparse3D->GetNbins() <= MaxNbins) sparse3D->Fill(e1); his2D->Fill(x,y); /*x = E_Delayed; y = E_Early; z = 500 + (delta_T2/10); //Energy Calibration == 1keV/ch; Time Calibration == 1ns/ch double e2[3] = {(x + 1.e-6), (y + 1.e-6), (z + 1.e-6)}; if (sparse3D->GetNbins() <= MaxNbins) sparse3D->Fill(e2);*/ } } } } } // ... return kTRUE; } void CShiftSort::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 CShiftSort::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 *f = TFile::Open("CShiftSort.root", "RECREATE", "", 101); f->cd(); //sparse3D->Write(); his2D->Write(); f->Write(); delete f; delete fChain; }