예제 #1
0
void Run_Simple_Test(char *host, const char *data_dir = "/var/tmp", Int_t dbg = 0)
{

   if (gSystem->AccessPathName("../libEvent.so")) {
      gSystem->Exec("cd $ROOTSYS/test; make libEvent.so");
      gSystem->Exec("./make_event_par.sh");
      gSystem->Exec("ln -s ../Event.h");
      gSystem->Load("../libEvent.so");
   }

   TProof *p = 0;
   if (dbg > 0) {
      p = TProof::Open(host, "", "", dbg);
   } else {
      p = TProof::Open(host);
   }
   if (!p || !p->IsValid()) {
      cout << "Could not start the PROOF session - exit "<<endl;
      return;
   }
   if (dbg > 0) p->SetLogLevel(dbg);

   p->UploadPackage("event");
   p->EnablePackage("event");

   make_event_trees(data_dir, 100000, files_per_node);

   TDSet *d = make_tdset(data_dir, files_per_node);

   d->Print("a");

   if (show_stats) gEnv->SetValue("Proof.StatsHist", 1);

   TDrawFeedback *fb(0);
   if (show_feedback) {
      if (show_stats) {
         p->AddFeedback("PROOF_ProcTimeHist");
         p->AddFeedback("PROOF_LatencyHist");
         p->AddFeedback("PROOF_EventsHist");
      }

      p->AddFeedback("pt_dist");

      fb = new TDrawFeedback(p);
   }

   // We load the selector before execution to avoid a problem affecting some versions
   // (in particular 5.22/00 and 5.22/00a); with problem-free versions this is equivalent
   // to direct processing via d->Process("EventTree_Proc.C+","")
   p->Load("EventTree_Proc.C+");
   d->Process("EventTree_Proc");

   if (fb) delete fb;
}
예제 #2
0
void TestPeacVerifier() {

//   gSystem->Load("libPeacUtils.so");

//   TProof *p = TProof::Open("skaf.saske.sk:1099","workers=1x");
//   TProof *p = TProof::Open("skaf.saske.sk","workers=1x");
    TProof *p = TProof::Open("alice-caf.cern.ch", "workers=1x");
    p->UploadPackage("../pars/PeacUtils");
    if (p->EnablePackage("PeacUtils")) return;

//   TProofNodes pn(p);
//   TMap *filesmap = new TMap;
//   TMap *nodesmap = pn.GetMapOfNodes();
//
//   TIter nxnd(nodesmap);
//   TList *wli = 0;
//   TObject *obj = 0;
//   Int_t kf = 1;
//   while ((obj = nxnd()) != 0) {
//      if ((wli = dynamic_cast<TList *>(nodesmap->GetValue(obj)))) {
//         THashList *fli = new THashList;
//         Int_t nf = wli->GetSize();
//         TSlaveInfo *wi = (TSlaveInfo *) wli->First();
//         Printf("WK: %s",wi->GetName());
//         fli->Add(new TObjString(wi->GetName()));
//         filesmap->Add(new TObjString(obj->GetName()), fli);
//      }
//   }
//
//   filesmap->SetName("PROOF_FilesToProcess");
//   p->AddInput(filesmap);

//   TFileCollection *coll = p->GetDataSet("myDS");
//   TFileCollection *coll = p->GetDataSet("myBigDS");
    TFileCollection *coll = p->GetDataSet("/PWG2/mvala/LHC11a_000146805_p4_with_SDD");
    TFileCollection *coll = p->GetDataSet("/PWG2/mvala/myDSNew");

    if (!coll) return;
    coll->SetName("PROOF_PEAC_FileCollectionIn");
    p->AddInput(coll);

//   p->SetParameter("PROOF_Packetizer", "TPacketizerFile");
//   p->SetParameter("PROOF_ProcessNotAssigned", (Int_t)1);
    p->SetParameter("PROOF_Packetizer", "TPacketizerUnit");
//   p->SetParameter("PROOF_ProcessNotAssigned", (Int_t)1);
    p->SetParameter("PROOF_UseMergers", "-1");
    TStopwatch timer;
    timer.Start();
    p->Process("TPeacVerifierSel", (Long64_t) 57);
    timer.Stop();
    timer.Print();
}
int main(int argc, char* argv[]){
  
  //This line could be commented if you don't want display while running, by example using screen.
  //TApplication theApp("App",&argc,argv);
  
  //---------------------------------------//
  // Global variables: could be give as argument later
  //---------------------------------------//
  
  int nwnodes = 10; //8 to 10 is the optimal
  string macroName = "ProofSelectorTTBarTagAndProbe.C+"; //"+" should be put at the end to use ACLIC complication - This macro should inherit from TSelector 
  string xmlFileName = string("/opt/sbg/data/data1/cms/jandrea/TopIPHC_2012_01_16/CMSSW_4_2_8_patch7/src/MiniTreeAnalysis/NTupleAnalysis/config/TTBarTagAndProbe.xml");  
  string outputFileName = "proof.root";
  
  //---------------------------------------//
  //	Decleration of TProof
  //---------------------------------------//
  
  //to be done before colling TProof
  system("../GeneralExamples/./clean_proof.sh ; echo 'Wait few seconds ... ' ; sleep 6");
  system("rm -r $HOME/.proof");
  
  TProof *proof = TProof::Open("");
  proof->SetParallel(nwnodes);
  //you should not have any package yet
  proof->ShowPackages();
  //proof->ClearPackages();
  //Loading package related to NTupleAnalysis
  cout<<" ## Upload package NTAna.par: ";
  proof->UploadPackage("../NTAna.par");
  cout<<" DONE [don't worry with symlink error - do rm NTAna if you change NTAna.par in the meanwhile !] "<<endl;
  proof->EnablePackage("NTAna");
  //Adding histograms for feedback: must exist in the TSelector !
  //proof->AddFeedback("fHist"); //give the "name" of the histogram and not the name of the variable TH1F* (could be the same !)
  
  //This line is required to display histograms durint the process
  TDrawFeedback fb(proof);
  
  
  //---------------------------------------//
  // Xml Loading  & Dataset registration
  //---------------------------------------//
  
  vector < Dataset > datasets;
  AnalysisEnvironmentLoader anaEL (xmlFileName);
  anaEL.LoadSamples (datasets); // now the list of datasets written in the xml file is known
  
  cout<<" #------------------------------------# "<<endl;
  cout<<" PROOF DATASETS SUMMARY [normaly 0]"<<endl;
  proof->ShowDataSets();
  cout<<" #------------------------------------# "<<endl;
  cout<<" # Registring dataset ... "<<endl;
  cout<<" Don't be worry with the checksum error message [at least I'm not ;-) ]"<<endl;
  cout<<" #------------------------------------# "<<endl;
  //Create datasets in proof format
  TFileCollection** fileCollec = new TFileCollection*[datasets.size()];
  for(unsigned int i=0;i<datasets.size();i++){
    fileCollec[i]  = new TFileCollection(datasets[i].Name().c_str(),"");
    for(unsigned int j=0;j<datasets[i].Filenames().size();j++){
      fileCollec[i]->Add(datasets[i].Filenames()[j].c_str());
    }
    //register dataset in proof
    proof->RegisterDataSet(datasets[i].Name().c_str(),fileCollec[i]);
    proof->VerifyDataSet(datasets[i].Name().c_str());
  }
  
  //summarize the list of datasets
  cout<<" #------------------------------------# "<<endl;
  cout<<" PROOF DATASETS SUMMARY"<<endl;
  proof->ShowDataSets();
  cout<<" #------------------------------------# "<<endl;
  
  //---------------------------------------//
  // 	Loading of the xml file
  //---------------------------------------//
  //Possibility to give float ... ex:
  //Double_t f = 3.14;
  //proof->SetParameter("IN_FLOAT",f);
  
  //---------------------------------------//
  // 	Processing of the datasets
  //---------------------------------------//
  
  string outputFileNameModif = outputFileName.substr(0,outputFileName.size()-5);
  //string MergingCommand = "hadd "+outputFileNameModif+"_merged.root "+outputFileNameModif+"_*.root  ";
  
  
  for(unsigned int i=0;i<datasets.size();i++){
    proof->AddInput(new TNamed("PROOF_DATASETNAME", datasets[i].Name()));
    //---------------------------------------//
    // 	Loading of the xml file
    //---------------------------------------//
    //Possibility to give float ... ex:
    //Double_t f = 3.14;
    //proof->SetParameter("IN_FLOAT",f);
    
    proof->AddInput(new TNamed("PROOF_XMLFILENAME", xmlFileName));
    proof->AddInput(new TNamed("PROOF_OUTPUTFILE", outputFileName));
    
    cout<<"#------------------------------------# "<<endl;
    cout<<"PROOF PARAMETERS SUMMARY"<<endl;
    proof->ShowParameters();
    cout<<"#------------------------------------# "<<endl;
    
    
    cout<<"################################################################"<<endl;
    cout<<"########### Processing the dataset "<<datasets[i].Name()<<endl;
    cout<<"################################################################"<<endl;
    //proof->Process(datasets[i].Name().c_str(),macroName.c_str());
    //system("ps -ef |grep jandrea");
    //gSystem->Load("../.lib/libNTupleAna_22-09-11_12-08-49.so");
    //gSystem->Load("../../../MiniTreeFormat/NTFormat/src/libNTuple.so");
    proof->Process(datasets[i].Name().c_str(),macroName.c_str());
    string newFileName = outputFileNameModif+"_"+datasets[i].Name()+".root";
    //system("sleep 30");
    cout<<"Copying the output file with the name "<<endl;
    //string command = "cp "+outputFileName+" "+newFileName;
    //MergingCommand+=newFileName+" ";
    //system(command.c_str());
    proof->ClearInput();
    
  }
  
  //cout<<"## Merging of all the dataset into one single file with hadd: "<<outputFileName<<endl;
  //system(MergingCommand.c_str());
  cout << "start backuping proof root files " << endl;
  system("mkdir backup_outputProof`date +\"%d-%m-%y_%H-%M-%S\"`; mv proof*.root  backup_outputProof`date +\"%d-%m-%y_%H-%M-%S\"`/.");
  
  cout<<"###############################################################"<<endl;
  cout<<"################ 	   May your job 	##############"<<endl;
  cout<<"################      Live long and prosper	##############"<<endl;
  cout<<"###############################################################"<<endl;
  cout<< "  							      "<< endl;
  cout<< "  			     _  			      "<< endl;
  cout<< "  			  .-T |   _			      "<< endl;
  cout<< "  			  | | |  / |			      "<< endl;
  cout<< "  			  | | | / /`|			      "<< endl;
  cout<< "  		       _  | | |/ / /			      "<< endl;
  cout<< "  		       \\`\\| \'.\' / / 		      "<< endl;
  cout<< "  			\\ \\`-. \'--|  		      "<< endl;
  cout<< "  			 \\    \'   |			      "<< endl;
  cout<< "  			  \\ \\  .` /			      "<< endl;
  cout<< "  			    |	 |			      "<< endl;
  cout<< "  							      "<< endl;
  cout<< "  							      "<< endl;
  cout<<"###############################################################"<<endl;
  cout<<"###############################################################"<<endl;
  
  
  
  
  
  
  
  return (0);
  
}