93 #include "TObjArray.h"
94 #include "TObjString.h"
95 #include "TIterator.h"
108 static const char*
const short_options =
"hvDs:S:d:c:n:f:t:e:r:o:b:T:X:Y:P:W:a:p:";
111 {
"help", 0, NULL,
'h' },
112 {
"verbose", 0, NULL,
'v' },
113 {
"debug", 0, NULL,
'D' },
114 {
"skip", 1, NULL,
's' },
115 {
"split", 1, NULL,
'S' },
116 {
"dets", 1, NULL,
'd' },
117 {
"config", 1, NULL,
'c' },
118 {
"nevents", 1, NULL,
'n' },
119 {
"from", 1, NULL,
'f' },
120 {
"to", 1, NULL,
't' },
121 {
"event", 1, NULL,
'e' },
122 {
"run", 1, NULL,
'r' },
123 {
"output", 1, NULL,
'o' },
124 {
"hbook", 1, NULL,
'b' },
125 {
"type", 1, NULL,
'T' },
126 {
"xdcc", 1, NULL,
'X' },
127 {
"ydcc", 1, NULL,
'Y' },
128 {
"pmm2", 1, NULL,
'P' },
133 {
"writer",1,NULL,
'W' },
134 {
"analyses", 1, NULL,
'a' },
135 {
"rawpedfile", 1, NULL,
'p' },
143 printf(
"Usage: %s -c cfgfile OPTIONS [x_rawfile] [y_rawfile] ...\n",
ProgramName->Data());
144 printf(
" Where options :\n\n"
145 " -h, --help\t print this text and exit\n"
146 " -v, --verbose\t increase verbosity level, can be repeated several times\n"
147 " -D, --debug\t increase debug level can repeat several times\n"
148 " -s NNN , --skip\t skip NNN events out of NNN+1\n"
149 " -S NNN , --split\t split output file every NNN events\n"
150 " -n NNN , --nevents\t number events to process\n"
151 " -f NNN , --from\t special processing for events starting from this number\n"
152 " -t NNN , --to\t special processing for events end at this event number\n"
153 " -r NNN , --run\t run number , do not guess from file name\n"
154 " -e NNN , --event\t number to show\n"
155 " -c FILE, --config\t config file name\n"
156 " -o FILE, --output\t output root file name\n\n"
157 " -b FILE, --hbook\t output root histograms file name\n\n"
158 " -d mask, --dets\t (default 0x3) active detectors mask\n"
159 " -d det, --dets\t detector id for reader type 'det'\n"
161 " -T type, --type\t (default) 1: read real data, 2: generate simulated data, 3: read ROOT file\n"
162 "or --det , --raw, --sim, --root for one detector, raw, sim and ROOT\n"
164 " -X type, --xdcc\t x dcc reader type 0: T3k , 1: MINOS\n"
165 " -Y type, --ydcc\t y dcc reader type 0: T3k , 1: MINOS\n"
166 " -P type, --pmm2\t pmm2 reader type 0:TEXT, 1:WIN, 2:Linux, 3:WIN(LLR)\n"
167 " -W 0|1 --writer\t Disble(0)/Enable(1) Out Tree writing (default:enabled).\n"
168 " -a LIST, --analyses\t list of HarpoAnalyses, separated by spaces\n"
169 " -p FILE, --rawpedfile root file with femion pedistals and sigmas\t \n"
261 DataDir =
new TString(gSystem->Getenv(
"HARPO_DATA_DIR"));
293 WorkDir =
new TString(dirname(argv[0]));
299 int option_index = 0;
310 printf(
" with arg %s", optarg);
330 fSplit = strtol(optarg,NULL,0);
339 RunNo = strtol(optarg,NULL,0);
343 nEvent = strtol(optarg,NULL,0);
355 ToEvent = strtol(optarg,NULL,0);
362 if(
Verbose) std::cout <<
"Config Ok" << std::endl;
364 std::cout <<
"Error in Config File Parsing " << std::endl;
368 std::cout <<
"Config File Read Error" << std::endl;
394 ndetmask = strtol(optarg,NULL,0);
398 type = strtol(optarg,NULL,0);
418 printf(
"UNKNOWN option\n");
423 printf(
"?? getopt returned character code 0%o ??\n", c);
428 if (ndetmask==0) Warning (__FUNCTION__,
"Zero Detector Set.\n");
435 Info(__FUNCTION__,
"+++RAW Reader selected.\n");
438 Info(__FUNCTION__,
"+++SIM Reader selected.\n");
441 Info(__FUNCTION__,
"+++ROOT Reader selected.\n");
444 Info(__FUNCTION__,
"+++DUMMY Reader selected.\n");
452 while (optind < argc) {
456 if( gSystem->AccessPathName(argv[optind])){
457 printf(
"Cannot access file %s\n",argv[optind]);
461 fInFile[i] =
new TString(argv[optind]);
475 if( gSystem->AccessPathName(argv[optind])){
476 printf(
"Cannot access file %s\n",argv[optind]);
479 fInFile[0] =
new TString(argv[optind]);
486 if( gSystem->AccessPathName(argv[optind])){
487 printf(
"Cannot access file %s\n",argv[optind]);
490 fInFile[0] =
new TString(argv[optind]);
496 printf(
"Wrong number of input files (%d)\n",argc-optind);
508 TPRegexp runre(
"run(\\d+)");
511 TObjArray *subStrL = runre.MatchS(file);
512 if(subStrL->GetEntries()<1){
513 Info(__FUNCTION__,
" Could not Guess Run Number");
515 const TString srun = ((TObjString *)subStrL->At(1))->GetString();
516 nmatched = subStrL->GetLast();
519 RunNo = std::atol(srun);
520 Info(__FUNCTION__,
" Guessed Run Num %lld",
RunNo);
528 fPedFile =
new TString(
"${HARPO_DATA_DIR}/harpopedsraw.root");
551 Long64_t verbose,verplus, dbgplus, runNo, Split;
552 Long64_t skip, maxevents, nevent,fromevent, toevent;
553 Bool_t WriterEnabled;
554 TString *histfile, *outfile, *pedfile, *dburl, *infile;
555 std::cout <<
"Reading Config --> " << *
fCfgFile << std::endl;
558 if (
Lookup(
"verbose",verplus)) {
562 std::cout <<
"cfg Verbose " << verbose << std::endl;
564 if (
Lookup(
"debug",dbgplus)) {
566 std::cout <<
"cfg Debug " <<
gHarpoDebug << std::endl;
569 if (
Lookup(
"config.run",runNo)) {
571 if (
Verbose > 1 ) std::cout <<
"cfg Run No " << runNo << std::endl;
574 if (
Lookup(
"config.split",Split)) {
576 if (
Verbose > 1 ) std::cout <<
"Split output file every " <<
fSplit <<
" events" << std::endl;
579 if (
Lookup(
"config.skip",skip)) {
582 std::cout <<
"Skip " << skip <<
" events between two analyses" << std::endl;
585 if (
Lookup(
"config.writer_enable",WriterEnabled)) {
587 if (
Verbose > 1 ) std::cout <<
"Tree Putput Writer Enabled "
588 << std::boolalpha << WriterEnabled
589 << std::noboolalpha << std::endl;
592 if (
Lookup(
"config.dets",ndetmask)) {
594 if (
Verbose > 1 ) std::cout <<
"cfg detmask " << std::endl;
597 if (
Lookup(
"config.maxevents",maxevents)) {
600 std::cout <<
"cfg Max Events " << maxevents << std::endl;
603 if (
Lookup(
"config.event",nevent)) {
605 if (
Verbose > 1 ) std::cout <<
"cfg Event No " << nevent << std::endl;
608 if (
Lookup(
"config.from",fromevent)) {
611 std::cout <<
"cfg From Event No " << fromevent << std::endl;
614 if (
Lookup(
"config.to",toevent)) {
617 std::cout <<
"cfg To Event No " << toevent << std::endl;
620 if (
Lookup(
"config.hfile",histfile)) {
623 std::cout <<
"cfg Hist File " << *histfile << std::endl;
626 TString* analysesTmp;
627 if (
Lookup(
"config.analyses",analysesTmp)){
630 if (
Verbose > 1 ) std::cout <<
"cfg Analyses list " <<
fAnalyses << std::endl;
633 if (
Lookup(
"config.ofile",outfile)) {
635 if (
Verbose > 1 ) std::cout <<
"cfg Out File " << *outfile << std::endl;
638 if (
Exist(
"config.infiles")) {
650 if (
LookupElem(
"config.infiles",j++,infile)) {
652 if (
Verbose > 1 ) { std::cout <<
"cfg inFile " << i << std::endl;
653 std::cout <<
"New fInFile["<< i <<
"] " << *infile << std::endl;
660 if (
Lookup(
"rundb.rawpedfile", pedfile)) {
661 gHConfig->
SetPedFile((
char *)pedfile->Data());
663 std::cout <<
"rundb raw peds File " << *pedfile << std::endl;
666 if (
Lookup(
"rundb.dburl",dburl)) {
667 gHConfig->
SetDbUrl((
char *)dburl->Data());
668 if (
Verbose > 1 ) std::cout <<
"rundb db url " << *dburl
669 <<
" " << dburl->IsNull() << std::endl;
675 std::cout <<
"config file failed" << std::endl;
719 if ((plane < 0) || (plane >= (Int_t )
gkNDetectors))
return;
721 fInFile[plane] =
new TString(fin);
752 fDbUrl =
new TString(url);
765 DataDir =
new TString(datadir);
770 std::cout <<
"--- HarpoConfig" << std::endl
772 <<
"WorkDir : " << *
WorkDir << std::endl
773 <<
"RunNo : " <<
RunNo << std::endl
774 <<
"MaxEvents : " <<
MaxEvents << std::endl
775 <<
"FromEvent : " <<
FromEvent << std::endl
776 <<
"ToEvent : " <<
ToEvent << std::endl
777 <<
"N Event : " <<
nEvent << std::endl;
780 std::cout <<
"+++ Harpo Reader Type " <<
gHReaderType << std::endl;
788 std::cout <<
"fInFile[" << ndet <<
"] : " << *
fInFile[ndet] << std::endl;
789 std::cout <<
"ReaderType[" << ndet <<
"] : " <<
tDetRdr[ndet] << std::endl;
794 std::cout <<
"fInFile[0] : " << *
fInFile[0] << std::endl;
static const char *const short_options
void SetNEvent(Long64_t nevt)
Set Event number with we looking for.
static HarpoDetSet * Instance()
Bool_t Exist(const char *path)
void SetToEvent(Long64_t nevt)
Set Last Event number to process.
void SetRunNo(Long64_t nrun)
Set Run Number.
TString * ProgramName
db serevr url
void SetDbUrl(char *url)
Set harpo database server URL.
void SetMaxEvents(Long64_t nevt)
Set Max Event for prosess.
void SetInFile(char *fin, Int_t plane=0)
Set Input file name for detector.
void SetAnalyses(char *fcfg)
Set List of HarpoAnalyses to run.
Bool_t isExist(ULong_t det)
Detecror date exist //! Number of Real Detectors.
void SetFromEvent(Long64_t nevt)
Set First Event to process.
void SetFile(TString *file)
Set Femimos Pedistal File Name.
TString * fDbUrl
root file with feminos pedstals
TString * fOutFile
Array of input row files.
void SetSplit(Long64_t split)
Bool_t LookupElem(const char *path, UInt_t index, Bool_t &val)
Long64_t fSplit
Events to skeep.
static const struct option long_options[]
Long_t countDets() const
Real Detectors number.
void SetPedFile(char *pfile)
Set Pedestal File.
HarpoConfig()
Constructor which does basically nothing.
Int_t getSettingLength(const char *path)
Function to deal with arrays or lists.
TString * fHistFile
Output file for root tries.
void SetDetRdrType(HarpoDetType nDet, Long64_t rtype)
Set type of reader impementation for given Harpo Detector.
A generic class for HARPO datectors The class is ....
Long64_t ToEvent
Fist event for analyse.
TString * fAnalyses
Output file for histograms.
void SetWriterEnable(Bool_t enable=true)
Set Writer Enabled Flag.
void SetSkipEvents(Long64_t skip)
TString * fPedFile
List of HarpoAnalyses to run.
Long64_t RunNo
Event number to show/print etc.
Long64_t MaxEvents
Verbose level.
Long64_t nEvent
Last event for analyse.
Long64_t DetNo
Detector mask (default 0x3)
void SetDataDir(char *datadir)
Get Top Data directory.
void SetMask(ULong_t detmask)
Redefine active detector set.
Long64_t fSkipEvents
Enabke/Disble Output Tree writer.
Bool_t infiles
Config file name.
void SetVerbose(Long64_t v=1)
Set program verbosity level.
Long64_t GetDetRdrType(HarpoDetType nDet)
Return type of reader impementation for given Harpo Detector.
virtual ~HarpoConfig()
Destructor:
void ParseArgs(int argc, char **argv, ULong64_t detmask=0x3)
Init Config data.
Bool_t Lookup(const char *path, Bool_t &val)
Lookup function for scalar values.
void print() const
Read config file in libconfig format.
void SetHistFile(char *fcfg)
Set Name of Histogram output file.
Long64_t tDetRdr[gkNDetectors]
Detector id (for dummy reader)
HarpoDetSet * GetDetSet()
Get set of active detectors.
dummy reader, for one detector test
Long64_t FromEvent
Max number events to process.
const ULong_t gkNDetectors
void SetOutFile(char *fout)
Set Output root file name.
static hReaderType gHReaderType
Reader Type.
enum hReaderType_ hReaderType
Harpo Reader Type.
A class which keeps track of the entire configuration of the analysis.
R__EXTERN HarpoDetSet * gHDetSet
Long64_t GetVerbose()
Get program verbosity level.
Bool_t SetCfgFile(const char *fcfg)
Set Name of libconfig configuration file.