#define select_cxx // The class definition in select.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 everytime 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("select.C") // Root > T->Process("select.C","some options") // Root > T->Process("select.C+") // #include "select.h" #include #include #include #include #include #include #include #include #include #include #include TFile *thefile; TTree *t_data; //members for tree UInt_t nEvt2; //count the number of events UInt_t inst2; //the ith hit of one event UInt_t detid2; //detid from root file Double_t energy2; Double_t time2; UInt_t trackid2; Int_t det2, subdet2, plane2, iz2, ix2, iy2, strip2; //information from detid //members for "es.table" UInt_t f_detid; //detid from "es.table" Double_t x, y, z, r; //position from "es.table" int i=0; //index for array int *a_detid = new int[140000]; //container of data from input file double *a_x = new double[140000]; double *a_y = new double[140000]; double *a_z = new double[140000]; void select::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(); thefile = new TFile("data_id.root", "RECREATE"); thefile->cd(); t_data = new TTree("data","data from PCaloHits_g4SimHitsES"); t_data->Branch("nEvt",&nEvt2,"nEvt2/i"); t_data->Branch("inst",&inst2,"inst2/i"); t_data->Branch("detid",&detid2,"detid2/i"); t_data->Branch("x",&x,"x/D"); t_data->Branch("y",&y,"y/D"); t_data->Branch("z",&z,"z/D"); t_data->Branch("r",&r,"r/D"); t_data->Branch("energy",&energy2,"energy2/D"); t_data->Branch("time",&time2,"time2/D"); t_data->Branch("trackid",&trackid2,"trackid2/i"); t_data->Branch("det",&det2,"det2/I"); t_data->Branch("subdet",&subdet2,"subdet2/I"); t_data->Branch("plane",&plane2,"plane2/I"); t_data->Branch("iz",&iz2,"iz2/I"); t_data->Branch("ix",&ix2,"ix2/I"); t_data->Branch("iy",&iy2,"iy2/I"); t_data->Branch("strip",&strip2,"strip2/I"); ifstream input("es.table"); while (!input.eof()) { input >> f_detid >> x >> y >> z; a_detid[i] = f_detid; a_x[i] = x; a_y[i] = y; a_z[i] = z; i++; } } void select::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 select::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. // It can be passed to either select::GetEntry() or TBranch::GetEntry() // to read either all or the required parts of the data. 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. fChain->GetTree()->GetEntry(entry); nEvt2 = nEvt; inst2 = inst; detid2 = detid; energy2 = energy; time2 = time; trackid2 = trackid; det2 = det; subdet2 = subdet; plane2 = plane; iz2 = iz; ix2 = ix; iy2 = iy; strip2 = strip; int idx = 0; //index for input file while (idxFill(); return kTRUE; } void select::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 select::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. thefile->cd(); thefile->Write(); thefile->Close(); }