#define MySelector_cxx // The class definition in MySelector.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("MySelector.C") // root> T->Process("MySelector.C","some options") // root> T->Process("MySelector.C+") // #include "MySelector.h" #include #include #include #include using namespace std; void MySelector::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(); fOutputFile = new TFile("Results.root","recreate"); hCosThetaTheo = new TH1D("CosThetaTheo","CosThetaTheo",200,-1,1); h_trackE = new TH1F("trackE","trackE",2000,0,2000); } void MySelector::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(); } Bool_t MySelector::Process(Long64_t entry) { fReader.SetLocalEntry(entry); if(*nbTrack==0) return true; for(int i=0 ; i<*nbTrack ; i++) { // we skip the events for wich no Compton diffusion occur if(trackType.At(i) !=2 ) continue; // Real value of Theta using the real position of the gamma-ray emission: TVector3 Source(0.,0.,0.); TVector3 Int1(trackX1.At(i),trackY1.At(i),trackZ1.At(i)); TVector3 Int2(trackX2.At(i),trackY2.At(i),trackZ2.At(i)); if(!(abs(trackE.At(i)-600)<5)) continue; // to keep only gammas with two interation points Float_t CosThetaTheo = CalcCosTheta(0,0,0,Int1,Int2); h_trackE->Fill(trackE.At(i)); hCosThetaTheo->Fill(CosThetaTheo); } return kTRUE; } Double_t MySelector::CalcCosTheta(Double_t X, Double_t Y, Double_t Z, TVector3 &Int1, TVector3 &Int2) { TVector3 Source(X,Y,Z); TVector3 Vec_Source_Int1 = Int1-Source; TVector3 Vec_Int1_Int2 = Int2-Int1; Float_t CosThetaTheo = (Vec_Source_Int1 * Vec_Int1_Int2)/(Vec_Source_Int1.Mag() * Vec_Int1_Int2.Mag()); return CosThetaTheo; } void MySelector::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 MySelector::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. fOutputFile->Write(); fOutputFile->Close(); }