ATLAS Offline Software
Functions
runZdcNtuple.cxx File Reference
#include "xAODRootAccess/Init.h"
#include "SampleHandler/SampleHandler.h"
#include "SampleHandler/ToolsDiscovery.h"
#include "EventLoop/Job.h"
#include "EventLoop/DirectDriver.h"
#include <EventLoop/OutputStream.h>
#include <EventLoopAlgs/NTupleSvc.h>
#include <EventLoopAlgs/AlgSelect.h>
#include "EventLoopGrid/PrunDriver.h"
#include "EventLoop/LSFDriver.h"
#include "SampleHandler/DiskListLocal.h"
#include "SampleHandler/DiskListEOS.h"
#include <TSystem.h>
#include "SampleHandler/ScanDir.h"
#include "ZdcNtuple/ZdcNtuple.h"

Go to the source code of this file.

Functions

int main (int argc, char *argv[])
 

Function Documentation

◆ main()

int main ( int  argc,
char *  argv[] 
)

Definition at line 19 of file runZdcNtuple.cxx.

19  {
20 
21  // Take the submit directory from the input if provided:
22  std::string submitDir = "submitDir";
23  if( argc > 1 ) submitDir = argv[ 1 ];
24 
25  std::string readDir = "file:/tmp/steinber";
26  if( argc > 2 ) readDir = argv[ 2 ];
27 
28  int nevt = -1;
29  if( argc > 3 ) nevt = std::atoi(argv[ 3 ]);
30 
31  std::string enableStr = "" ;
32  if ( argc > 4 ) enableStr = argv[4];
33 
34  std::string vers = "0";
35  if ( argc > 5 ) vers = argv[5];
36 
37  int localTrackLimit = 1e6;
38  if ( argc > 6 ) localTrackLimit = std::atoi(argv[ 6 ]);
39 
40  std::string grlOption = "";
41  if ( argc > 7 ) grlOption = argv[ 7 ];
42 
43  // Set up the job for xAOD access:
44  xAOD::Init().ignore();
45 
46  // Construct the samples to run on:
48  //sh.setMetaString( "nc_grid_filter", "*MinBias.merge.AOD.*");
49 
50  //const char* inputFilePath = gSystem->ExpandPathName(readDir.c_str());
51  //SH::DiskListLocal list (readDir);
52 
53  std::string fileDir;
54  bool file_mode = 0;
55  bool eos_mode = 0;
56  bool eoslsf_mode = 0;
57  bool grid_mode = 0;
58 
59  if (readDir.find("file:")==0)
60  {
61  fileDir = readDir.substr(5); // remove file:
62  file_mode = 1;
63  std::cout << "Setting up file mode:" << fileDir << std::endl;
64  SH::DiskListLocal list (fileDir);
66  }
67 
68  if (readDir.find("eos:")==0)
69  {
70  fileDir = readDir.substr(4);
71  eos_mode = 1;
72  std::cout << "Setting up EOS mode:" << fileDir << std::endl;
73  std::string eospath = "root://eosatlas.cern.ch/"+fileDir;
74  SH::DiskListEOS list(fileDir,eospath);
76  }
77 
78  if (readDir.find("eoslsf:")==0)
79  {
80  fileDir = readDir.substr(7);
81  eoslsf_mode = 1;
82  std::cout << "Setting up EOS LSF mode:" << fileDir << std::endl;
83  std::string eospath = "root://eosatlas.cern.ch/"+fileDir;
84  SH::DiskListEOS list(fileDir,eospath);
86  }
87 
88  if (readDir.find("grid:")==0)
89  {
90  fileDir = readDir.substr(5);
91  grid_mode = 1;
92  std::cout << "Setting up Grid mode:" << fileDir << std::endl;
93  SH::addGrid (sh, fileDir);
94  sh.setMetaString("nc_grid_filter","*");
95  }
96 
97  // Set the name of the input TTree. It's always "CollectionTree"
98  // for xAOD files.
99  sh.setMetaString( "nc_tree", "CollectionTree" );
100  // Print what we found:
101  sh.print();
102 
103  // Create an EventLoop job:
104  EL::Job job;
105  job.sampleHandler( sh );
106 
107  // Add our analysis to the job:
108  ZdcNtuple* zdcAna = new ZdcNtuple();
109 
110  std::cout << "runtime options:" << enableStr << std::endl;
111 
112  zdcAna->outputName = "output";
113  if (enableStr.find("debug")!=std::string::npos) { zdcAna->debug = true; }
114  if (enableStr.find("slimmed")!=std::string::npos) { zdcAna->slimmed = true; }
115  if (enableStr.find("tree")!=std::string::npos) { zdcAna->enableOutputTree = true; }
116  if (enableStr.find("samples")!=std::string::npos) { zdcAna->enableOutputSamples = true; }
117  if (enableStr.find("trigger")!=std::string::npos) { zdcAna->enableTrigger = true; }
118  if (enableStr.find("zdcCalib")!=std::string::npos) { zdcAna->zdcCalib = true; }
119  if (enableStr.find("zdcLaser")!=std::string::npos) { zdcAna->zdcLaser = true; }
120  if (enableStr.find("tracks")!=std::string::npos) { zdcAna->enableTracks = true; }
121  if (enableStr.find("clusters")!=std::string::npos) { zdcAna->enableClusters = true; }
122  if (enableStr.find("TT")!=std::string::npos) { zdcAna->enableTT = true; }
123  if (enableStr.find("jets")!=std::string::npos) { zdcAna->enableJets = true; }
124  if (enableStr.find("electrons")!=std::string::npos) { zdcAna->enableElectrons = true; }
125  if (enableStr.find("photons")!=std::string::npos) { zdcAna->enablePhotons = true; }
126  if (enableStr.find("trigjet")!=std::string::npos) { zdcAna->enableTriggerJets = true; }
127  if (enableStr.find("muons")!=std::string::npos) { zdcAna->enableMuons = true; }
128  if (enableStr.find("truth")!=std::string::npos) { zdcAna->enableTruth = true; }
129  if (enableStr.find("noflipdelay")!=std::string::npos) { zdcAna->flipDelay = false; }
130  if (enableStr.find("doflipdelay")!=std::string::npos) { zdcAna->flipDelay = true; }
131  if (enableStr.find("trackLimitReject")!=std::string::npos) { zdcAna->trackLimitReject = true; }
132  if (enableStr.find("reprocZdc")!=std::string::npos) { zdcAna->reprocZdc = true; }
133  if (enableStr.find("7samp")!=std::string::npos) { zdcAna->nsamplesZdc = 7; }
134  if (enableStr.find("15samp")!=std::string::npos) { zdcAna->nsamplesZdc = 15; }
135  if (enableStr.find("noGRL")!=std::string::npos) { zdcAna->useGRL = false;}
136  if (enableStr.find("express2016A")!=std::string::npos) { zdcAna->express2016A = true;}
137  if (enableStr.find("upc2015")!=std::string::npos) { zdcAna->upc2015 = true;}
138  if (enableStr.find("mb2015")!=std::string::npos) { zdcAna->mb2015 = true;}
139  if (enableStr.find("upcL2015")!=std::string::npos) { zdcAna->upcL2015 = true;}
140  if (enableStr.find("main2016A")!=std::string::npos) { zdcAna->main2016A = true;}
141  if (enableStr.find("upc2016A")!=std::string::npos) { zdcAna->upc2016A = true;}
142  if (enableStr.find("express2016B")!=std::string::npos) { zdcAna->express2016B = true;}
143  if (enableStr.find("main2016B")!=std::string::npos) { zdcAna->main2016B = true;}
144  if (enableStr.find("upc2016B")!=std::string::npos) { zdcAna->upc2016B = true;}
145  if (enableStr.find("upc2016C")!=std::string::npos) { zdcAna->upc2016C = true;}
146  if (enableStr.find("mboverlay2016")!=std::string::npos) { zdcAna->mboverlay2016 = true;}
147 
148  if (enableStr.find("writeOnlyTriggers")!=std::string::npos) { zdcAna->writeOnlyTriggers = true;}
149  if (grlOption != "") zdcAna->grlFilename = grlOption;
150 
151  zdcAna->trackLimit = localTrackLimit;
152 
153  // Add ntuple service
154 
155  EL::OutputStream output ("output");
156  job.outputAdd (output);
157  EL::NTupleSvc *ntuple = new EL::NTupleSvc ("output");
158  // configure ntuple object
159  job.algsAdd (ntuple);
160 
161  // Add my algorithms
162  job.algsAdd( zdcAna );
163 
164  if (nevt>-1) job.options()->setDouble (EL::Job::optMaxEvents, nevt);
165  std::cout << "Running " << nevt << " events" << std::endl;
166 
167  if (file_mode||eos_mode)
168  {
169  // Run the job using the local/direct driver:
171  driver.submit( job, submitDir );
172  //if (zdcAna->zdcCalib) job.options()->setString (EL::Job::optXaodAccessMode, EL::Job::optXaodAccessMode_branch);
173  if (zdcAna->zdcCalib) job.options()->setString(EL::Job::optXaodAccessMode, EL::Job::optXaodAccessMode_athena);
174  }
175 
176  if (grid_mode)
177  {
179  driver.options()->setString("nc_outputSampleName", "user.steinber.%in:name[0]%.%in:name[1]%.%in:name[2]%.%in:name[3]%.%in:name[4]%.%in:name[5]%.%in:name[6]%."+vers);
180  driver.options()->setDouble(EL::Job::optGridMergeOutput, 1); //run merging jobs for all samples before downloading (recommended)
181  driver.options()->setString(EL::Job::optGridNFilesPerJob, "3"); //By default, split in as few jobs as possible
182  //driver.options()->setString(EL::Job::optGridSite,"CERN-PROD");
183  driver.submitOnly( job, submitDir );
184  }
185 
186  if (eoslsf_mode)
187  {
189  TString shellCommand = "export export LSB_JOB_REPORT_MAIL=N; export ATLAS_LOCAL_ROOT_BASE=/cvmfs/atlas.cern.ch/repo/ATLASLocalRootBase &&";
190  shellCommand += "source ${ATLAS_LOCAL_ROOT_BASE}/user/atlasLocalSetup.sh" ;
191  driver.options()->setString (EL::Job::optSubmitFlags, "-L /bin/bash -q 1nd");
192  driver.options()->setString (EL::Job::optFilesPerWorker, "20");
193  driver.shellInit = shellCommand.Data();
194  driver.submitOnly( job, submitDir );
195  }
196 
197  return 0;
198 }
EL::Job::optFilesPerWorker
static const std::string optFilesPerWorker
description: the name of the option for selecting the number of files per batch job.
Definition: Job.h:256
EL::Job::optMaxEvents
static const std::string optMaxEvents
description: the name of the option used for setting the maximum number of events to process per samp...
Definition: Job.h:222
SH::ScanDir
the class used for scanning local directories and file servers for samples
Definition: ScanDir.h:38
ZdcNtuple::reprocZdc
bool reprocZdc
Definition: ZdcNtuple.h:75
ZdcNtuple::grlFilename
std::string grlFilename
Definition: ZdcNtuple.h:54
ZdcNtuple::enableTracks
bool enableTracks
Definition: ZdcNtuple.h:60
EL::Job::optXaodAccessMode
static const std::string optXaodAccessMode
description: the option to select the access mode for xAODs.
Definition: Job.h:397
beamspotman.eospath
eospath
Definition: beamspotman.py:874
EL::OutputStream
Definition: OutputStream.h:34
ZdcNtuple::nsamplesZdc
size_t nsamplesZdc
Definition: ZdcNtuple.h:77
ZdcNtuple::zdcLaser
bool zdcLaser
Definition: ZdcNtuple.h:69
runJobs.grid_mode
grid_mode
Definition: runJobs.py:227
ZdcNtuple::enableTT
bool enableTT
Definition: ZdcNtuple.h:64
ZdcNtuple::enableTrigger
bool enableTrigger
Definition: ZdcNtuple.h:57
LArCellConditions.argv
argv
Definition: LArCellConditions.py:112
FullCPAlgorithmsTest_eljob.driver
driver
Definition: FullCPAlgorithmsTest_eljob.py:157
ZdcNtuple::useGRL
bool useGRL
Definition: ZdcNtuple.h:53
ZdcNtuple::enableJets
bool enableJets
Definition: ZdcNtuple.h:66
EL::NTupleSvc
Definition: NTupleSvc.h:49
ZdcNtuple::enableOutputTree
bool enableOutputTree
Definition: ZdcNtuple.h:55
EL::PrunDriver
a Driver to submit jobs via prun
Definition: PrunDriver.h:23
ZdcNtuple::enablePhotons
bool enablePhotons
Definition: ZdcNtuple.h:63
ZdcNtuple::writeOnlyTriggers
bool writeOnlyTriggers
Definition: ZdcNtuple.h:58
FullCPAlgorithmsTest_eljob.sh
sh
Definition: FullCPAlgorithmsTest_eljob.py:98
FullCPAlgorithmsTest_eljob.submitDir
submitDir
Definition: FullCPAlgorithmsTest_eljob.py:146
RCU::Shell
Definition: ShellExec.cxx:28
EL::Job::optGridNFilesPerJob
static const std::string optGridNFilesPerJob
Definition: Job.h:467
ZdcNtuple::trackLimit
size_t trackLimit
Definition: ZdcNtuple.h:72
EL::LSFDriver
a Driver for running on LSF batch systems
Definition: LSFDriver.h:21
histSizes.list
def list(name, path='/')
Definition: histSizes.py:38
DQHistogramMergeRegExp.argc
argc
Definition: DQHistogramMergeRegExp.py:20
EL::Job::optSubmitFlags
static const std::string optSubmitFlags
description: the name of the option for supplying extra submit parameters to batch systems rationale:...
Definition: Job.h:293
SH::DiskListEOS
a DiskList implementation for EOS
Definition: DiskListEOS.h:26
ZdcNtuple::trackLimitReject
bool trackLimitReject
Definition: ZdcNtuple.h:73
SH::addGrid
void addGrid(SampleHandler &sh, const std::string &ds)
effects: add a grid dataset for dataset ds guarantee: strong failures: out of memory II requires: ds....
Definition: ToolsDiscovery.cxx:175
EL::Job::optGridMergeOutput
static const std::string optGridMergeOutput
Definition: Job.h:474
merge.output
output
Definition: merge.py:17
ZdcNtuple::outputName
std::string outputName
Definition: ZdcNtuple.h:88
ZdcNtuple::enableTriggerJets
bool enableTriggerJets
Definition: ZdcNtuple.h:67
EL::DirectDriver
a Driver that runs directly inside the submission job itself
Definition: DirectDriver.h:25
ZdcNtuple::enableTruth
bool enableTruth
Definition: ZdcNtuple.h:65
ZdcNtuple
Definition: ZdcNtuple.h:50
ZdcNtuple::slimmed
bool slimmed
Definition: ZdcNtuple.h:52
ZdcNtuple::zdcCalib
bool zdcCalib
Definition: ZdcNtuple.h:68
ZdcNtuple::enableClusters
bool enableClusters
Definition: ZdcNtuple.h:59
SH::DiskListLocal
a DiskList implementation for local directories
Definition: DiskListLocal.h:27
ZdcNtuple::enableMuons
bool enableMuons
Definition: ZdcNtuple.h:61
ZdcNtuple::flipDelay
bool flipDelay
Definition: ZdcNtuple.h:74
SH::ScanDir::scan
const ScanDir & scan(SampleHandler &sh, const std::string &dir) const
scan the given directory and put the created samples into the sample handler
Definition: ScanDir.cxx:168
EL::Job::optXaodAccessMode_athena
static const std::string optXaodAccessMode_athena
Definition: Job.h:400
ZdcNtuple::enableElectrons
bool enableElectrons
Definition: ZdcNtuple.h:62
CxxUtils::atoi
int atoi(std::string_view str)
Helper functions to unpack numbers decoded in string into integers and doubles The strings are requir...
Definition: Control/CxxUtils/Root/StringUtils.cxx:85
SH::ScanDir::filePattern
ScanDir & filePattern(const std::string &val_filePattern)
the pattern for files to be accepted
Definition: ScanDir.cxx:94
SH::SampleHandler
A class that manages a list of Sample objects.
Definition: SampleHandler.h:60
ZdcNtuple::enableOutputSamples
bool enableOutputSamples
Definition: ZdcNtuple.h:56
EL::Job
Definition: Job.h:51
test_interactive_athena.job
job
Definition: test_interactive_athena.py:6
Lb2Lll.NTupleSvc
NTupleSvc
Definition: Lb2Lll.py:200
xAOD::Init
StatusCode Init(const char *appname)
Function initialising ROOT/PyROOT for using the ATLAS EDM.
Definition: Init.cxx:31