#define treeFairRunAna_C // The class definition in treeFairRunAna.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("treeFairRunAna.C") // Root > T->Process("treeFairRunAna.C","some options") // Root > T->Process("treeFairRunAna.C+") // #include "treeFairRunAna.h" #include #include #include #include #include #include "FairRunAna.h" #include "FairRuntimeDb.h" #include "FairParRootFileIo.h" #include "FairParAsciiFileIo.h" #include "PndGemFindHits.h" #include #include #include using std::cout; using std::cerr; using std::endl; using std::pair; using std::setw; using std::left; using std::right; using std::fixed; using std::setprecision; using std::map; void treeFairRunAna::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). cout << "treeFairRunAna::Begin" << endl; TString option = GetOption(); } void treeFairRunAna::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 vmcPath = gSystem->Getenv("VMCWORKDIR"); TChain* inputChain = dynamic_cast(fInput->FindObject("cbmsim")); //TTree* inputChain = dynamic_cast(fInput->FindObject("cbmsim")); fProofFile = new TProofOutputFile("SimpleTreeW.root", "M"); fProofFile->SetOutputFileName(Form("%s/macro/proof/Gem_3Stations_15GeV_n6000_hitsSELECTOR.root",vmcPath.Data())); TDirectory *savedir = gDirectory; fFile = fProofFile->OpenFile("RECREATE"); if (fFile && fFile->IsZombie()) SafeDelete(fFile); savedir->cd(); TString option = GetOption(); fRunAna = new FairRunAna(); fRunAna->SetProofAnalysis(); fRunAna->SetInChain(inputChain); fRunAna->SetOutputFile(fFile); // ----- Parameter database -------------------------------------------- TString allDigiFile = Form("%s/macro/params/gem_3Stations.digi.par",vmcPath.Data()); TString parFile = Form("%s/macro/proof/Gem_3Stations_15GeV_n1000_par.root",vmcPath.Data()); FairRuntimeDb* rtdb = fRunAna->GetRuntimeDb(); FairParRootFileIo* parInput1 = new FairParRootFileIo(); parInput1->open(parFile.Data()); FairParAsciiFileIo* parIo1 = new FairParAsciiFileIo(); parIo1->open(allDigiFile.Data(),"in"); rtdb->setFirstInput(parInput1); rtdb->setSecondInput(parIo1); // ------------------------------------------------------------------------ // ------------------------------------------------------------------------ PndGemFindHits* gemFindHits = new PndGemFindHits("GEM Hit Finder", 0); fRunAna->AddTask(gemFindHits); // ------------------------------------------------------------------------ Init(inputChain); //Init(tree); fRunAna->SlaveBegin(); } Bool_t treeFairRunAna::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 treeFairRunAna::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. cout << "--------------------------------------------" << endl; cout << "getting event " << entry << endl; // cout << "got array " << gemDigiArray << endl; // b_gemDigiArray->GetEntry(entry); // cout << "trying to fChain->GetEvent(" << entry << ")" << endl; fChain->GetEvent(entry); // cout << "got event" << endl; fRunAna->RunEntry(entry); return kTRUE; } void treeFairRunAna::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. TString vmcPath = gSystem->Getenv("VMCWORKDIR"); cout << "fRunAna->SlaveTerminate()" << endl; fRunAna->SlaveTerminate(); cout << "fOutput->Add(fProofFile);" << endl; fOutput->Add(fProofFile); cout << "fFile->Close()" << endl; fFile->Close(); cout << "fFile->GetName() = " << fFile->GetName() << endl; TString fileName = fFile->GetName(); if ( fileName.Contains("0.0") ) { TString command = Form("cp %s %s/macro/proof/worker0.0_FRA.root",fileName.Data(),vmcPath.Data()); gSystem->Exec(command.Data()); } if ( fileName.Contains("0.1") ) { TString command = Form("cp %s %s/macro/proof/worker0.1_FRA.root",fileName.Data(),vmcPath.Data()); gSystem->Exec(command.Data()); } if ( fileName.Contains("0.2") ) { TString command = Form("cp %s %s/macro/proof/worker0.2_FRA.root",fileName.Data(),vmcPath.Data()); gSystem->Exec(command.Data()); } if ( fileName.Contains("0.3") ) { TString command = Form("cp %s %s/macro/proof/worker0.3_FRA.root",fileName.Data(),vmcPath.Data()); gSystem->Exec(command.Data()); } cout << "finishing SlaveTerminate()" << endl; } void treeFairRunAna::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. cout << "TERMINATE" << endl; cout << "*********(((((((((((((((((**********" << endl; fOutput->ls(); cout << "*********)))))))))))))))))**********" << endl; /* // Get the ntuple form the file if ((fProofFile = dynamic_cast(fOutput->FindObject("SimpleTreeW.root")))) { TString outputFile = "/misc/karabowi/pandaroot_13510/trunk/macro/gem/treeFairRunAnaOutput.root"; // TString outputName(fProofFile->GetName()); cout << "outputFile \"" << outputFile.Data() << "\"" << endl; // cout << "outputName \"" << outputName.Data() << "\"" << endl; // outputName += ".root"; Printf("outputFile: %s", outputFile.Data()); // Read the ntuple from the file fFile = TFile::Open(outputFile); if (fFile) { Printf("Managed to open file: %s", outputFile.Data()); fOutTree = (TTree *) fFile->Get("demoTree"); } else { Error("Terminate", "could not open file: %s", outputFile.Data()); } if (!fFile) return; } else { cout << "no file in fOutput" << endl; Error("Terminate", "TProofOutputFile not found"); return; }*/ }