Changeset 19848 for trunk


Ignore:
Timestamp:
11/01/19 14:18:10 (5 years ago)
Author:
tbretz
Message:
Make a public access to MCorsikaRead::CalcNumEvents possible. This allows to use it to check whether all files are valid. Added the new option '--check' to ceres for that. Copy '-tel' to the file names. This is more conevenient in reading them.
Location:
trunk/Mars
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Mars/ceres.cc

    r19728 r19848  
    148148    gLog.Setup(arg);
    149149
    150     StartUpMessage();
     150    const Bool_t kCheckOnly = arg.HasOnlyAndRemove("--check");
     151
     152    if (!kCheckOnly)
     153        StartUpMessage();
    151154
    152155    if (arg.HasOnly("-V") || arg.HasOnly("--version"))
     
    159162    }
    160163
    161     const Bool_t  kBatch      = arg.HasOnlyAndRemove("-b");
     164    const Bool_t  kBatch      = arg.HasOnlyAndRemove("-b") || kCheckOnly;
    162165    //const Int_t   kCompLvl   = arg.GetIntAndRemove("--comp=", 1);
    163     const Bool_t  kForce      = arg.HasOnlyAndRemove("-ff");
     166    const Bool_t  kForce      = arg.HasOnlyAndRemove("-ff") && !kCheckOnly;
    164167    const Bool_t  kDebugMem   = arg.HasOnlyAndRemove("--debug-mem");
    165168    const Bool_t  kNullOut    = arg.HasOnlyAndRemove("--dev-null");
     
    340343    MArray::Class()->IgnoreTObjectStreamer();
    341344    MParContainer::Class()->IgnoreTObjectStreamer();
     345
     346    if (kCheckOnly)
     347        gROOT->SetBatch();
    342348
    343349    TApplication app("ceres", &argc, argv);
     
    381387        // job.SetPathIn(kInpath); // not yet needed
    382388
    383         if (!job.Process(arg, seq))
    384         {
    385             gLog << err << "Calculation of ceres failed." << endl << endl;
     389        if (!job.Process(arg, seq, kCheckOnly))
     390        {
     391            if (job.GetDisplay())
     392                delete d;
     393
     394            if (!kCheckOnly)
     395                gLog << err << "Calculation of ceres failed." << endl << endl;
    386396            return 2;
    387397        }
  • trunk/Mars/mcorsika/MCorsikaRead.cc

    r19696 r19848  
    167167// This opens the next file in the list and deletes its name from the list.
    168168//
    169 Int_t MCorsikaRead::OpenNextFile(Bool_t print)
     169Int_t MCorsikaRead::OpenNextFile(Bool_t print, Bool_t telrequired)
    170170{
    171171
     
    196196        return kERROR;
    197197
    198     *fLog << inf << "Open file: '" << name << "'" << endl;
    199 
    200     // Check if thsi is a single telescope from a CORSIKA telescope array
    201     // This is indicated by the -telXXX attached to the filename
    202     TObjArray *res = TPRegexp("(.*/)?cer([0-9]+)-tel([0-9]+)").MatchS(name, "i");
    203     if (res->GetLast()==3)
     198    *fLog << (telrequired?inf:all) << "Open file: '" << name << "'" << endl;
     199
     200    if (telrequired)
    204201    {
    205         const TString match = res->At(0)->GetName();
    206         const TString path  = res->At(1)->GetName();
    207         const UInt_t  runid = atoi(res->At(2)->GetName());
    208         const UInt_t  telid = atoi(res->At(3)->GetName());
    209 
    210         *fLog << inf2 << "Run " << runid << " detected to be for telescope #" << telid << endl;
    211 
    212         if (telid>=fNumTelescopes)
     202        // Check if thsi is a single telescope from a CORSIKA telescope array
     203        // This is indicated by the -telXXX attached to the filename
     204        TObjArray *res = TPRegexp("(.*/)?cer([0-9]+)-tel([0-9]+)").MatchS(name, "i");
     205        if (res->GetLast()==3)
    213206        {
    214             *fLog << err << "Position of telescope " << telid << " not defined." << endl;
    215             return kERROR;
     207            const TString match = res->At(0)->GetName();
     208            const TString path  = res->At(1)->GetName();
     209            const UInt_t  runid = atoi(res->At(2)->GetName());
     210            const UInt_t  telid = atoi(res->At(3)->GetName());
     211
     212            *fLog << inf2 << "Run " << runid << " detected to be for telescope #" << telid << endl;
     213
     214            if (telid>=fNumTelescopes)
     215            {
     216                *fLog << err << "Position of telescope " << telid << " not defined." << endl;
     217                return kERROR;
     218            }
     219
     220            *fLog << inf << "Telescope #" << telid << " [X/Y/Z (R)]: ";
     221            *fLog << fTelescopeX[telid] << "/";
     222            *fLog << fTelescopeY[telid] << "/";
     223            *fLog << fTelescopeZ[telid] << " (R=" << fTelescopeR[telid] << ")" << endl;
     224
     225            fNumTelescope = telid+1;
    216226        }
    217 
    218         *fLog << inf << "Telescope #" << telid << " [X/Y/Z (R)]: ";
    219         *fLog << fTelescopeX[telid] << "/";
    220         *fLog << fTelescopeY[telid] << "/";
    221         *fLog << fTelescopeZ[telid] << " (R=" << fTelescopeR[telid] << ")" << endl;
    222 
    223         fNumTelescope = telid+1;
     227        delete res;
    224228    }
    225     delete res;
    226 
    227229
    228230    if (fDisplay)
     
    288290    fNumTotalEvents = 0;
    289291
     292    MCorsikaRunHeader runheader;
     293
    290294    Bool_t rc = kTRUE;
    291295
    292296    while (1)
    293297    {
    294         switch (OpenNextFile(kFALSE))
     298        switch (OpenNextFile(kFALSE, kFALSE))
    295299        {
    296300        case kFALSE:
     
    310314               {
    311315               if (blockType == 1200)
    312                   status = fRunHeader->ReadEvt(fInFormat, blockLength / sizeof(Float_t));
     316                  status = runheader.ReadEvt(fInFormat, blockLength / sizeof(Float_t));
    313317
    314318               else if(blockType == 1201)
     
    319323                  vector<Float_t> buffer(blockLength / sizeof(Float_t));
    320324                  status = fInFormat->Read(buffer.data(), blockLength);
    321                   status = fRunHeader->ReadEventHeader(buffer.data());
     325                  status = runheader.ReadEventHeader(buffer.data());
    322326                  break;
    323327                  }
     
    325329                  fInFormat->Seek(blockLength);
    326330               }
    327                  
     331
    328332            if (status != kTRUE)
    329333               return status;
     
    331335            if (!fInFormat->SeekEvtEnd())
    332336            {
    333                *fLog << (fForceMode?warn:err) << "Error: RUNE section not found in file." << endl;
     337               *fLog << (fForceMode?warn:err) << "ERROR - RUNE section not found in file." << endl;
    334338               if (!fForceMode)
    335339                  return fForceMode ? kTRUE : kFALSE;
    336340            }
    337341
    338             if (!fRunHeader->ReadEvtEnd(fInFormat, kTRUE))
     342            if (!runheader.ReadEvtEnd(fInFormat, kTRUE))
    339343            {
    340                *fLog << (fForceMode?warn:err) << "Error: Reading RUNE section failed." << endl;
     344               *fLog << (fForceMode?warn:err) << "ERROR - Reading RUNE section failed." << endl;
    341345               if (!fForceMode)
    342346                  return kFALSE;
    343347            }
    344348
    345             fNumTotalEvents += fRunHeader->GetNumEvents()*fRunHeader->GetNumReuse()*
     349            fNumTotalEvents += runheader.GetNumEvents()*runheader.GetNumReuse()*
    346350                (fTelescopeIdx<0 && fNumTelescope==0 ? fNumTelescopes : 1);
    347351            continue;
     
    806810        *fLog << inf2 << "Reading Telecope positions from " << fname << ":" << endl;
    807811
    808         TPRegexp regexp("\\s*TELESCOPE"
    809                         "\\s+([-+]?[0-9]*\\.?[0-9]+([eE][-+]?[0-9]+)?)"
    810                         "\\s+([-+]?[0-9]*\\.?[0-9]+([eE][-+]?[0-9]+)?)"
    811                         "\\s+([-+]?[0-9]*\\.?[0-9]+([eE][-+]?[0-9]+)?)"
    812                         "\\s+([-+]?[0-9]*\\.?[0-9]+([eE][-+]?[0-9]+)?)"
    813                         "\\s+([0-9]+)\\s*");
    814 
    815812        ifstream fin(fname);
    816813
     
    823820                break;
    824821
    825             const TObjArray *res = regexp.MatchS(buf);
    826             if (res->GetLast()==9)
     822            buf = buf.Strip(TString::kBoth);
     823            if (buf(0, 9)!="TELESCOPE")
     824                continue;
     825
     826            float x, y, z, r;
     827            int idx;
     828            if (sscanf(buf.Data()+9, "%f %f %f %f %d", &x, &y, &z, &r, &idx)!=5)
     829                continue;
     830
     831            if (idx>=fNumTelescopes)
    827832            {
    828                 const UInt_t idx = atoi(res->At(9)->GetName());
    829                 if (idx>=fNumTelescopes)
    830                 {
    831                     fNumTelescopes = idx+1;
    832                     fTelescopeX.Set(fNumTelescopes);
    833                     fTelescopeY.Set(fNumTelescopes);
    834                     fTelescopeZ.Set(fNumTelescopes);
    835                     fTelescopeR.Set(fNumTelescopes);
    836                 }
    837 
    838                 fTelescopeX[idx] = atof(res->At(1)->GetName());
    839                 fTelescopeY[idx] = atof(res->At(3)->GetName());
    840                 fTelescopeZ[idx] = atof(res->At(5)->GetName());
    841                 fTelescopeR[idx] = atof(res->At(7)->GetName());
     833                fNumTelescopes = idx+1;
     834                fTelescopeX.Set(fNumTelescopes);
     835                fTelescopeY.Set(fNumTelescopes);
     836                fTelescopeZ.Set(fNumTelescopes);
     837                fTelescopeR.Set(fNumTelescopes);
    842838            }
    843             delete res;
     839
     840            fTelescopeX[idx] = x;
     841            fTelescopeY[idx] = y;
     842            fTelescopeZ[idx] = z;
     843            fTelescopeR[idx] = r;
    844844        }
    845845
  • trunk/Mars/mcorsika/MCorsikaRead.h

    r19669 r19848  
    6767    //Bool_t    fForce;
    6868
    69 
    70     Int_t  OpenNextFile(Bool_t print=kTRUE);
    71     Bool_t CalcNumTotalEvents();
     69    Int_t  OpenNextFile(Bool_t print=kTRUE, Bool_t telrequired=kTRUE);
    7270    Int_t  ReadTelescopePosition();
    7371    Int_t  ReadNextBlockHeader();
     
    8280    MCorsikaRead(const char *filename=NULL, const char *name=NULL, const char *title=NULL);
    8381    ~MCorsikaRead();
     82
     83    Bool_t CalcNumTotalEvents();
    8484
    8585    void SetForceMode(Bool_t b=kTRUE) { fForceMode=b; }
  • trunk/Mars/mjobs/MJSimulation.cc

    r19723 r19848  
    396396}
    397397
    398 Bool_t MJSimulation::Process(const MArgs &args, const MSequence &seq)
     398Bool_t MJSimulation::Process(const MArgs &args, const MSequence &seq, Bool_t checkonly)
    399399{
    400400    // --------------------------------------------------------------------------------
     
    409409    // - description of the job itself
    410410    // - list of the to processed sequence
     411    if (!checkonly)
     412        fLog->Separator(GetDescriptor());
     413
    411414    *fLog << inf;
    412     fLog->Separator(GetDescriptor());
    413 
    414415    if (!CheckEnv())
    415416        return kFALSE;
     
    418419        *fLog << fSequence.GetFileName() << endl;
    419420    else
    420         *fLog << "Input: " << args.GetNumArguments() << "-files" << endl;
     421        *fLog << "Input: " << args.GetNumArguments() << " file(s)" << endl;
    421422    *fLog << endl;
    422423
     
    550551        return kFALSE;
    551552    }
     553
     554    if (checkonly)
     555        return read.CalcNumTotalEvents();
    552556
    553557    // --------------------------------------------------------------------------------
     
    823827
    824828    const char *regex = fRunNumber<0 ?
    825         "s/[cC][eE][rR]([0-9]+)(-[tT][eE][lL]([0-9]+))?/%s\\/00$1.%03d%%s_MonteCarlo$3.root/" :
    826         "s/[cC][eE][rR][0-9]+([0-9][0-9][0-9])(-[tT][eE][lL]([0-9]+))?/%s\\/%08d.$1%%s_MonteCarlo$3.root/";
     829        "s/[cC][eE][rR]([0-9]+)(-[tT][eE][lL]([0-9]+))?/%s\\/00$1.%03d%%s_MonteCarlo$2.root/" :
     830        "s/[cC][eE][rR][0-9]+([0-9][0-9][0-9])(-[tT][eE][lL]([0-9]+))?/%s\\/%08d.$1%%s_MonteCarlo$2.root/";
    827831
    828832    const char *fmt = fFileOut.IsNull() ?
  • trunk/Mars/mjobs/MJSimulation.h

    r18450 r19848  
    5454
    5555    // Process
    56     Bool_t Process(const MArgs &args, const MSequence &seq);
     56    Bool_t Process(const MArgs &args, const MSequence &seq, Bool_t checkonly);
    5757
    5858    ClassDef(MJSimulation, 0) // Job to run the simulation (ceres)
Note: See TracChangeset for help on using the changeset viewer.