Ejemplo n.º 1
0
void SetupAnalysis(TString mode,
		   TString analysisMode="full",
		   Bool_t useMC = kFALSE,
		   Int_t nEvents=1.0*1e9, 
		   Int_t nEventsSkip=0,
		   TString format="esd")
{
  
  // ILC stuff
  IlcAnalysisManager *mgr = IlcAnalysisManager::GetAnalysisManager();
  if (!mgr) mgr = new IlcAnalysisManager("CAF train");
  
  // Create and configure the alien handler plugin 
  gROOT->LoadMacro("CreateAnalysisPlugin.C"); 
  IlcAnalysisGrid *alienHandler = CreateAnalysisPlugin(analysisMode);   
  if (!alienHandler) return;
  mgr->SetGridHandler(alienHandler);
  
  // input handler for esd or AOD, real or MC data
  InputHandlerSetup(format,useMC);

  // physics selection
  if(!format.CompareTo("esd")){
    gROOT->LoadMacro("$ILC_ROOT/ANALYSIS/macros/AddTaskPhysicsSelection.C");
    IlcPhysicsSelectionTask* physSelTask = AddTaskPhysicsSelection(kFALSE);
    if(useMC) physSelTask->GetPhysicsSelection()->SetAnalyzeMC();   
    IlcPhysicsSelection* physSel = physSelTask->GetPhysicsSelection();
    physSel->AddBackgroundIdentification(new IlcBackgroundSelection());
  }
  
  gROOT->ProcessLine(Form(".include %s/include",gSystem->ExpandPathName("$ILC_ROOT")));
  
  gROOT->LoadMacro("IlcAnalysisTaskEfficiency.cxx+g");
  
  // load and run AddTask macro
  gROOT->LoadMacro("AddTaskEfficiency.C");
  

  IlcAnalysisTaskSE* task1 = AddTaskEfficiency(-1);
  if(!task1){
    Printf("AddTask could not be run.");
  }

  // Run analysis
  mgr->InitAnalysis();
  
  if ((!mode.CompareTo("proof")) ||(!mode.CompareTo("local"))) {
    mgr->StartAnalysis(mode.Data(),nEvents,nEventsSkip);
  }
  else {
    mgr->StartAnalysis(mode.Data());
    
  }
  
}
Ejemplo n.º 2
0
//______________________________________________________________________________
void AODtrain(Int_t merge=0)
{
// Main analysis train macro.

  if (merge) {
    TGrid::Connect("alien://");
    if (!gGrid || !gGrid->IsConnected()) {
      ::Error("QAtrain", "No grid connection");
      return;
    }
  }
  // Set temporary merging directory to current one
  gSystem->Setenv("TMPDIR", gSystem->pwd());
  // Set temporary compilation directory to current one
  gSystem->SetBuildDir(gSystem->pwd(), kTRUE);
   printf("==================================================================\n");
   printf("===========    RUNNING FILTERING TRAIN   ==========\n");
   printf("==================================================================\n");
   printf("=  Configuring analysis train for:                               =\n");
   if (usePhysicsSelection)   printf("=  Physics selection                                                =\n");
   if (useTender)    printf("=  TENDER                                                        =\n");
   if (iESDfilter)   printf("=  ESD filter                                                    =\n");
   if (iMUONcopyAOD) printf("=  MUON copy AOD                                                 =\n");
   if (iJETAN)       printf("=  Jet analysis                                                  =\n");
   if (iJETANdelta)  printf("=     Jet delta AODs                                             =\n");
   if (iPWGHFvertexing) printf("=  PWGHF vertexing                                                =\n");
   if (iPWGDQJPSIfilter) printf("=  PWGDQ j/psi filter                                             =\n");
   if (iPWGHFd2h) printf("=  PWGHF D0->2 hadrons QA                                     =\n");

   // Load common libraries and set include path
   if (!LoadCommonLibraries()) {
      ::Error("AnalysisTrain", "Could not load common libraries");
      return;
   }
    
   // Make the analysis manager and connect event handlers
   IlcAnalysisManager *mgr  = new IlcAnalysisManager("Analysis Train", "Production train");
   if (useSysInfo) mgr->SetNSysInfo(100);
   // Load analysis specific libraries
   if (!LoadAnalysisLibraries()) {
      ::Error("AnalysisTrain", "Could not load analysis libraries");
      return;
   }   

   // Create input handler (input container created automatically)
   // ESD input handler
   IlcESDInputHandler *esdHandler = new IlcESDInputHandler();
   mgr->SetInputEventHandler(esdHandler);       
   // Monte Carlo handler
   if (useMC) {
      IlcMCEventHandler* mcHandler = new IlcMCEventHandler();
      mgr->SetMCtruthEventHandler(mcHandler);
      mcHandler->SetReadTR(useTR); 
   }   
   // AOD output container, created automatically when setting an AOD handler
   if (iAODhandler) {
      // AOD output handler
      IlcAODHandler* aodHandler   = new IlcAODHandler();
      aodHandler->SetOutputFileName("IlcAOD.root");
      mgr->SetOutputEventHandler(aodHandler);
   }
   // Debugging if needed
   if (useDBG) mgr->SetDebugLevel(3);

   AddAnalysisTasks();
   if (merge) {
      AODmerge();
      mgr->InitAnalysis();
      mgr->SetGridHandler(new IlcAnalysisAlien);
      mgr->StartAnalysis("gridterminate",0);
      return;
   }   
   // Run the analysis                                                                                                                     
   //
   TChain *chain = CreateChain();
   if (!chain) return;
                                                                                                                                                   
   TStopwatch timer;
   timer.Start();
   mgr->SetSkipTerminate(kTRUE);
   if (mgr->InitAnalysis()) {
      mgr->PrintStatus();
      mgr->StartAnalysis("local", chain);
   }
   timer.Print();
}