ATLAS Offline Software
Loading...
Searching...
No Matches
runZdcNtuple.cxx
Go to the documentation of this file.
4#include "EventLoop/Job.h"
10#include "EventLoop/LSFDriver.h"
11
14#include <TSystem.h>
16
17#include "ZdcNtuple/ZdcNtuple.h"
18
19int main( int argc, char* argv[] ) {
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.starts_with("file:"))
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);
65 SH::ScanDir().filePattern("*").scan(sh,list);
66 }
67
68 if (readDir.starts_with("eos:"))
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);
75 SH::ScanDir().filePattern("*").scan(sh,list);
76 }
77
78 if (readDir.starts_with("eoslsf:"))
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);
85 SH::ScanDir().filePattern("*").scan(sh,list);
86 }
87
88 if (readDir.starts_with("grid:"))
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:
170 EL::DirectDriver 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 {
178 EL::PrunDriver driver;
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 {
188 EL::LSFDriver driver;
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}
a Driver that runs directly inside the submission job itself
Definition Job.h:51
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:225
static const std::string optGridMergeOutput
Definition Job.h:483
static const std::string optXaodAccessMode_athena
Definition Job.h:403
static const std::string optXaodAccessMode
description: the option to select the access mode for xAODs.
Definition Job.h:400
static const std::string optSubmitFlags
description: the name of the option for supplying extra submit parameters to batch systems rationale:...
Definition Job.h:296
static const std::string optFilesPerWorker
description: the name of the option for selecting the number of files per batch job.
Definition Job.h:259
static const std::string optGridNFilesPerJob
Definition Job.h:476
a Driver for running on LSF batch systems
Definition LSFDriver.h:21
a Driver to submit jobs via prun
Definition PrunDriver.h:23
a DiskList implementation for EOS
Definition DiskListEOS.h:26
a DiskList implementation for local directories
A class that manages a list of Sample objects.
bool reprocZdc
Definition ZdcNtuple.h:82
std::string outputName
Definition ZdcNtuple.h:97
bool enableTriggerJets
Definition ZdcNtuple.h:73
bool enableOutputTree
Definition ZdcNtuple.h:59
bool flipDelay
Definition ZdcNtuple.h:81
bool zdcLaser
Definition ZdcNtuple.h:75
bool trackLimitReject
Definition ZdcNtuple.h:80
bool enableTruth
Definition ZdcNtuple.h:71
bool slimmed
Definition ZdcNtuple.h:56
std::string grlFilename
Definition ZdcNtuple.h:58
bool enablePhotons
Definition ZdcNtuple.h:69
bool enableElectrons
Definition ZdcNtuple.h:68
bool enableMuons
Definition ZdcNtuple.h:67
bool enableTrigger
Definition ZdcNtuple.h:61
bool enableTracks
Definition ZdcNtuple.h:66
size_t nsamplesZdc
Definition ZdcNtuple.h:84
bool enableOutputSamples
Definition ZdcNtuple.h:60
size_t trackLimit
Definition ZdcNtuple.h:79
bool useGRL
Definition ZdcNtuple.h:57
bool writeOnlyTriggers
Definition ZdcNtuple.h:62
bool enableClusters
Definition ZdcNtuple.h:65
bool enableTT
Definition ZdcNtuple.h:70
bool zdcCalib
Definition ZdcNtuple.h:74
bool enableJets
Definition ZdcNtuple.h:72
int main()
Definition hello.cxx:18
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....
StatusCode Init(const char *appname)
Function initialising ROOT/PyROOT for using the ATLAS EDM.
Definition Init.cxx:31
the class used for scanning local directories and file servers for samples
Definition ScanDir.h:38
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
ScanDir & filePattern(const std::string &val_filePattern)
the pattern for files to be accepted
Definition ScanDir.cxx:94