runsum.cc File Reference

#include <iostream>
#include <fstream>
#include <iosfwd>
#include <vector>
#include <unistd.h>
#include <getopt.h>
#include "TError.h"
#include "TFile.h"
#include "TIterator.h"
#include "TList.h"
#include "TObject.h"
#include "TString.h"
#include "TSystem.h"
#include "TTimeStamp.h"
#include "TTree.h"
#include "Algorithm/AlgFactory.h"
#include "Algorithm/AlgConfig.h"
#include "JobControl/JobC.h"
#include "OnlineUtil/mdRunTypeCodes.h"
#include "OnlineUtil/mdTriggerCodes.h"
#include "RawData/RawRecord.h"
#include "RawData/RawHeader.h"
#include "RawData/RawDaqSnarlHeader.h"
#include "RawData/RawRunConfigBlock.h"
#include "Record/RecMinos.h"
#include "Util/UtilString.h"
#include "RSM.h"

Go to the source code of this file.

Defines

#define RUNNUM_NEW_RUNTYPES   25190

Functions

int cfgtest (string fname)
int sepruns (string fname)
void ptrig_run (string fname)
void other_run (string fname)
void usage ()
void isetup ()
void question (string gravel, bool *drugs)
void question (string gravel, int *drugs)
void question (string gravel, string *drugs)
int main (int argc, char **argv)

Variables

Int_t loud = 0
Bool_t FarmListGen = false
Bool_t MonthlyGen = false
Bool_t WebGen = false
Bool_t PhysicsAnalysis = false
Bool_t UseOtherFile = false
string other_file = "other.run"
Bool_t UsePhysicsFile = false
string physics_file = "physics.run"
Bool_t UseRsmFile = false
string runsum_file = "RunSummary.run"
Bool_t MakeScript = false
Bool_t DryRun = false
Bool_t UseRunSummary = true
Bool_t UseRateSummary = true
Bool_t MakeHitMaps = false
Bool_t AppendFiles = true
Bool_t MonthlyDir = false
Bool_t MakeDBEntries = false
string sdir = "./"

Define Documentation

#define RUNNUM_NEW_RUNTYPES   25190

Definition at line 49 of file runsum.cc.

Referenced by FilterRunType::Ana(), cfgtest(), and sepruns().


Function Documentation

int cfgtest ( string  fname  ) 

Definition at line 764 of file runsum.cc.

References RawRecord::GetRawBlockIter(), RawRecord::GetRawHeader(), RawDaqHeader::GetRun(), RawRunConfigBlock::GetRunConfig(), RawDaqHeader::GetRunType(), RawDaqHeader::GetSubRun(), loud, run(), RUN_TYPE_CHECKOUT, RUN_TYPE_MASK_TYPECODE, RUN_TYPE_PHYSICS, RUN_TYPE_VA_CALIBRATE, RUN_TYPE_VA_PEDESTAL, and RUNNUM_NEW_RUNTYPES.

Referenced by main().

00764                           {
00765   TFile *fFile = 0;
00766 
00767   if(loud>=2) cout << "cfgtest checking file " << fname.c_str() << endl;
00768   fFile = new TFile(fname.c_str());
00769   if (!fFile) {
00770     if(loud>=1) cout << fname << " File not valid\n";
00771     return 0;
00772   }
00773 
00774   if (!(fFile->Get("DaqMonitor")) || !(fFile->Get("DaqSnarl"))) {
00775     if(loud>=1)
00776       cout << fname << " Contains no DaqMonitor or DaqSnarl object\n";
00777     fFile->Close();
00778     return -1;
00779   }
00780 
00781   TTree *dsnrl = dynamic_cast<TTree*>(fFile->Get("DaqSnarl"));
00782   TTree *dmntr = dynamic_cast<TTree*>(fFile->Get("DaqMonitor"));
00783   if (!dmntr || !dsnrl) {
00784     if(loud>=1)
00785       cout << fname << " Error retrieving DaqMonitor or DaqSnarl\n";
00786     fFile->Close(); return -1;
00787   }
00788   if (dmntr->GetEntries()<=5 || dsnrl->GetEntries()<=2) {
00789     if(loud>=1)
00790       cout << fname << " To Few (" << dmntr->GetEntries() << ") DaqMonitors\n"
00791            << "or " << " To Few (" << dsnrl->GetEntries() << ") DaqSnarls\n";
00792     fFile->Close(); return -1;
00793   }
00794 
00795   RawRecord* record = 0;
00796   const RawDaqHeader* rdh = 0;
00797   RawRunConfigBlock* rrcfgb = 0;
00798   TObject* obj = 0;
00799 
00800   dmntr->SetBranchAddress("RawRecord",&record);
00801 
00802   //If the RawRunConfigBlock isn't in the first entry, give up
00803   dmntr->GetEntry(0);
00804 
00805   rdh = dynamic_cast<const RawDaqHeader*>(record->GetRawHeader());
00806   if (!rdh) { fFile->Close(); return -1; }
00807 
00808   Int_t run = rdh->GetRun();
00809   Int_t srun = rdh->GetSubRun();
00810   Int_t rtype = rdh->GetRunType();
00811   if(loud>=2) cout << " Run:" << run << ";" << srun
00812                    << ", RunType:" << rtype << endl;
00813 
00814   //Hosed up RawDaqHeader
00815   if (run==0 || srun<0 || rtype<0) {
00816     if(loud>=1) cout << fname << " hosed header\n";
00817     fFile->Close();
00818     return -1;
00819   }
00820 
00821   fFile->Close();
00822 
00823   if (run > RUNNUM_NEW_RUNTYPES) {
00824     if(loud>=2) cout << " New RunType: " << rtype << endl;
00825     if((rtype&RUN_TYPE_MASK_TYPECODE) == RUN_TYPE_PHYSICS) return 0;
00826     if((rtype&RUN_TYPE_MASK_TYPECODE) == RUN_TYPE_CHECKOUT) return 2;
00827     if((rtype&RUN_TYPE_MASK_TYPECODE) == RUN_TYPE_VA_PEDESTAL) return 1;
00828     if((rtype&RUN_TYPE_MASK_TYPECODE) == RUN_TYPE_VA_CALIBRATE) return 3;
00829     return 4;
00830   }
00831 
00832   if(rtype==1) return 1;
00833   if(rtype==3) return 3;
00834   TIter rawitr = record->GetRawBlockIter();
00835 
00836   while ((obj=rawitr())) {
00837     if ((rrcfgb=dynamic_cast<RawRunConfigBlock*>(obj))) { //RawRunConfigBlock
00838       string cfg = rrcfgb->GetRunConfig();
00839       if(loud>=3) cout << "RawRunConfigBlock" << cfg << endl;
00840       if(cfg.find("runTypeName") == string::npos) {
00841         if(loud>=1) cout << "  No runTypeName in cfg\n";
00842         return -1;
00843       }
00844       string rtname;
00845       rtname = cfg.substr(cfg.find("runTypeName"),cfg.length()-1);
00846       rtname = rtname.substr(rtname.find("=")+1,rtname.length());
00847       rtname = rtname.substr(0,rtname.find(";"));
00848       if(loud>=2) cout << "  runTypeName: " << rtname << endl;
00849 
00850       if (rtname.find("Physics")==0) return 0; //Current runtype name for data runs
00851       if (rtname.find("PlaneTrigger")==0) return 0; //Old runtype name, keep for older files
00852 
00853       //Shift all *Special* and *Singles* to singles type
00854       if (rtname.find("Special")!=string::npos) return 2;
00855       if (rtname.find("Singles")!=string::npos) return 2;
00856 
00857       break;
00858     }
00859   }
00860   return -1;
00861 }

void isetup (  ) 

Definition at line 899 of file runsum.cc.

References AppendFiles, DryRun, FarmListGen, loud, MakeHitMaps, MakeScript, MonthlyDir, MonthlyGen, other_file, physics_file, question(), runsum_file, sdir, UseOtherFile, UsePhysicsFile, UseRateSummary, UseRsmFile, UseRunSummary, and WebGen.

Referenced by main().

00899               {
00900   bool temp_bool = false;
00901   if(loud>=1) cout << "Entering Interactive Setup\n";
00902 
00903   question("Verbosity level?",&loud);
00904   question("Do a dry run?",&DryRun);
00905 
00906   question("Monthly umn runs setup?",&temp_bool);
00907   if (temp_bool) {
00908     MonthlyGen = true;
00909     UseOtherFile = true;
00910     UseRsmFile = true;
00911     UsePhysicsFile = false;
00912     UseRunSummary = true;
00913     UseRateSummary = true;
00914     sdir = "./summaries";
00915     return;
00916   }
00917 
00918   question("Web minos-offline runs setup?",&temp_bool);
00919   if (temp_bool) {
00920     WebGen = true;
00921     MonthlyDir = true;
00922     UseOtherFile = true;
00923     UseRsmFile = true;
00924     UseRunSummary = false;
00925     UseRateSummary = true;
00926     sdir = "/data2/web_files/rsm/summaries";
00927     return;
00928   }
00929 
00930   question("Farms FNAL runs setup?",&temp_bool);
00931   if (temp_bool) {
00932     FarmListGen = true;
00933     MonthlyDir = false;
00934     UseOtherFile = false;
00935     UseRunSummary = true;
00936     UseRateSummary = false;
00937     sdir = "./";
00938     return;
00939   }
00940 
00941   question("Make other.sh script?",&MakeScript);
00942 
00943   question("Use other file?",&UseOtherFile);
00944   if(UseOtherFile) question("Other file name?",&other_file);
00945   question("Use physics file?",&UsePhysicsFile);
00946   if(UsePhysicsFile) question("Physics file name?",&physics_file);
00947   question("Use rsm file?",&UseRsmFile);
00948   if(UseRsmFile) question("Rsm file name?",&runsum_file);
00949 
00950   question("Use RunSummary Module?",&UseRunSummary);
00951   if (UseRunSummary) {
00952     question("Append summary files in RunSummary?",&AppendFiles);
00953   }
00954 
00955   question("Use RateSummary Module?",&UseRateSummary);
00956   if (UseRateSummary) {
00957     question("Make HitMaps in RateSummary",&MakeHitMaps);
00958   }
00959 
00960   if (UseRateSummary || UseRunSummary) {
00961     question("Put files in monthly subdir",&MonthlyDir);
00962   }
00963 }

int main ( int  argc,
char **  argv 
)

Definition at line 110 of file runsum.cc.

References JobCPathModule::Add(), JobCInput::AddFile(), AppendFiles, JobCPathModule::Attach(), cfgtest(), JobCPathModule::Create(), DryRun, exit(), FarmListGen, fname, AlgHandle::GetAlgConfig(), AlgFactory::GetAlgHandle(), AlgFactory::GetInstance(), gSystem(), JobC::Input, isetup(), Registry::LockKeys(), Registry::LockValues(), loud, MakeDBEntries, MakeHitMaps, MakeScript, JobCPath::Mod(), MonthlyDir, MonthlyGen, JobC::Msg, option, other_file, other_run(), JobC::Path, physics_file, PhysicsAnalysis, ptrig_run(), AlgFactory::Register(), JobCPath::Report(), JobCModule::Report(), JobCPath::Run(), runsum_file, sdir, sepruns(), Registry::Set(), JobCModule::Set(), JobCMsgModule::SetLevel(), Registry::UnLockValues(), usage(), UseOtherFile, UsePhysicsFile, UseRateSummary, UseRsmFile, UseRunSummary, and WebGen.

00110                                 {
00111   Int_t nfiles_run = 0;
00112 
00113   vector<string>::const_iterator citr;
00114   vector<string>::const_iterator citr2;
00115 
00116 #ifndef __GNU_LIBRARY__
00117 //#warning long opts are not necessarily supported except under GNU_LIBRARY
00118 #else
00119   static struct option long_opt[] = {
00120     {"help", 0, 0, 'h'},
00121     {"verbose", 0, 0, 'v'},
00122     {"loud", 0, 0, 'v'},
00123     {"dry-run", 0, 0, 'n'},
00124     {"scripts", 0, 0, 'm'},
00125     {"interactive", 0, 0, 'i'},
00126     {0, 0, 0, 0}
00127   };
00128   int opt_index = 0;
00129 #endif
00130   const char short_opt[] = "hvqinmsrHLWMAoO:fF:pP:DS:";
00131 
00132   int c;
00133 
00134 #ifndef __GNU_LIBRARY__
00135   while ((c = getopt(argc,argv,short_opt)) != -1)
00136 #else
00137   while ((c = getopt_long(argc,argv,short_opt,long_opt,&opt_index)) != -1)
00138 #endif
00139     switch (c) {
00140     case 'h':
00141       usage();
00142       exit(0);
00143       break;
00144     case 'v':
00145       loud++;
00146       break;
00147     case 'q':
00148       loud--;
00149       break;
00150     case 'i':
00151       isetup();
00152       exit(0);
00153       break;
00154     case 'n':
00155       if(loud>=0) cout << "DryRun (no summarizing done)\n";
00156       DryRun = true;
00157       break;
00158     case 'L':
00159       if(loud>=0) cout << "Generating farm lists\n";
00160       FarmListGen = true;
00161       MonthlyDir = false;
00162       UseOtherFile = true;
00163       UsePhysicsFile = false;
00164       UseRsmFile = true;
00165       UseRunSummary = true;
00166       UseRateSummary = false;
00167       sdir = "./";
00168       break;
00169     case 'M':
00170       if(loud>=0) cout << "Generating monthly summaries and trees\n";
00171       MonthlyGen = true;
00172       UseOtherFile = true;
00173       UseRsmFile = true;
00174       UsePhysicsFile = false;
00175       UseRunSummary = true;
00176       UseRateSummary = true;
00177       sdir = "./summaries";
00178       break;
00179     case 'W':
00180       if(loud>=0) cout << "Generating web summaries and trees\n";
00181       WebGen = true;
00182       MonthlyDir = true;
00183       UseOtherFile = true;
00184       UseRsmFile = true;
00185       UsePhysicsFile = false;
00186       UseRunSummary = true;
00187       UseRateSummary = true;
00188       sdir = "/home/rsm/summaries";
00189       break;
00190     case 'A':
00191       if(loud>=0) cout << "Generating Physics Analysis summaries and trees\n";
00192       PhysicsAnalysis = true;
00193       UseRunSummary = false;
00194       UseRateSummary = false;
00195       break;
00196     case 'm':
00197       if(loud>=0) cout << "Will make sh scripts\n";
00198       MakeScript = true;
00199       break;
00200     case 's':
00201       if(loud>=0) cout << "Use only RunSummary Module\n";
00202       UseRunSummary = true;
00203       UseRateSummary = false;
00204       break;
00205     case 'r':
00206       if(loud>=0) cout << "Use only RateSummary Module\n";
00207       UseRunSummary = false;
00208       UseRateSummary = true;
00209       break;
00210     case 'H':
00211       if(loud>=0) cout << "Make hit maps in RateSummary\n";
00212       MakeHitMaps = true;
00213       break;
00214     case 'o':
00215       if(loud>=0) cout << "Use other runs file " << other_file << endl;
00216       UseOtherFile = true;
00217       break;
00218     case 'O':
00219       if(loud>=0) cout << "Use other runs file " << optarg << endl;
00220       other_file = optarg;
00221       UseOtherFile = true;
00222       break;
00223     case 'f':
00224       if(loud>=0) cout << "Use runsum runs file " << runsum_file << endl;
00225       UseRsmFile = true;
00226       break;
00227     case 'F':
00228       if(loud>=0) cout << "Use runsum runs file " << optarg << endl;
00229       runsum_file = optarg;
00230       UseRsmFile = true;
00231       break;
00232     case 'p':
00233       if(loud>=0) cout << "Use physics runs file " << physics_file << endl;
00234       UsePhysicsFile = true;
00235       break;
00236     case 'P':
00237       if(loud>=0) cout << "Use physics runs file " << optarg << endl;
00238       physics_file = optarg;
00239       UsePhysicsFile = true;
00240       break;
00241     case 'D':
00242       if(loud>=0) cout << "Make Database Entries" << endl;
00243       MakeDBEntries = true;
00244       break;
00245     case 'S':
00246       if(loud>=0) cout << "Write to directory " << optarg << endl;
00247       sdir = optarg;
00248       break;
00249     default:
00250       cerr << "unknown command line option:" << optopt << endl;
00251       usage();
00252       exit(1);
00253       break;
00254     }
00255   if(loud>=1) printf("Verbose output level %d\n",loud);
00256   if(loud<=0) gErrorIgnoreLevel = kFatal;
00257 
00258   //Make sure nothing is building
00259   if ((gSystem->Exec("ls ./.building_* >& /dev/null")==0) && loud>=0) {
00260     if (!(FarmListGen||WebGen||MonthlyGen)) {
00261       cout << "Already building something, proceed anyway?(1=yes,0=no)";
00262       Bool_t proceed;
00263       cin >> proceed;
00264       if(!proceed) exit(0);
00265     }
00266     else {
00267       cout << "Already building something in this directory" << endl;
00268       cout << "Remove .building_* from here to proceed" << endl;
00269       exit(0);
00270     }
00271   }
00272   if(gSystem->Exec("touch ./.building_runsum >& /dev/null") != 0)
00273   if(loud>=1) printf("Can't touch .building_runsum\n");
00274 
00275   //Open the scripts if needed
00276   if (MakeScript) {
00277     if(loud>=1) cout << "Initializing scripts\n";
00278     ofstream script("other.sh",ios_base::out);
00279     script << "#!/bin/bash" << endl;
00280     script.close();
00281   }
00282 
00283   string fname;
00284   string mdaq_str = ".mdaq.root";
00285   vector<string> mdaq_ind;
00286   string noli_str = ".noli.root";
00287   vector<string> noli_ind;
00288 
00289   //Compile list if files are specified on command line
00290   for (int i=optind; i<argc; i++) {
00291     fname = argv[i];
00292     if (fname.length() > mdaq_str.length() &&
00293         fname.find(mdaq_str) == fname.length()-mdaq_str.length()) {
00294       if(loud>=3) cout << "Add to mdaq_ind list " << fname << endl;
00295       mdaq_ind.push_back(fname.substr(0,fname.find(mdaq_str)));
00296     }
00297     if (fname.length() > noli_str.length() &&
00298         fname.find(noli_str) == fname.length()-noli_str.length()) {
00299       if(loud>=3) cout << "Add to noli_ind list " << fname << endl;
00300       noli_ind.push_back(fname.substr(0,fname.find(noli_str)));
00301     }
00302     //If running on individual files, don't use run files or make scripts
00303     //UsePhysicsFile = false;
00304     //UseOtherFile = false;
00305     //UseRsmFile = false;
00306     //MakeScript = false;
00307     //AppendFiles = false;
00308   }
00309 
00310   //If no files on command line make list of all mdaq and noli files
00311   //in current directory
00312   if (mdaq_ind.size()==0 && noli_ind.size()==0) {
00313     void *dir = gSystem->OpenDirectory("./");
00314 
00315     if (!dir) {
00316       cout << "Error opening CWD\n";
00317       return 0;
00318     }
00319 
00320     const char* file;
00321 
00322     //Span root files in the directory and build lists
00323     while ((file = gSystem->GetDirEntry(dir))){
00324       fname = file;
00325       if (fname.length() > mdaq_str.length() &&
00326           fname.find(mdaq_str) == fname.length()-mdaq_str.length()) {
00327         if(loud>=3) cout << "Add to mdaq_ind list " << fname << endl;
00328         mdaq_ind.push_back(fname.substr(0,fname.find(mdaq_str)));
00329       }
00330       if (fname.length() > noli_str.length() &&
00331           fname.find(noli_str) == fname.length()-noli_str.length()) {
00332         if(loud>=3) cout << "Add to noli_ind list " << fname << endl;
00333         noli_ind.push_back(fname.substr(0,fname.find(noli_str)));
00334       }
00335     }
00336     gSystem->FreeDirectory(dir);
00337   }
00338 
00339   //Sort the mdaq and noli lists
00340   sort(mdaq_ind.begin(),mdaq_ind.end());
00341   if(loud>=4)
00342     for(citr=mdaq_ind.begin();citr!=mdaq_ind.end();citr++)
00343       cout << "mdaqlist: " << *citr << endl;
00344   sort(noli_ind.begin(),noli_ind.end());
00345   if(loud>=4)
00346     for(citr=noli_ind.begin();citr!=noli_ind.end();citr++)
00347       cout << "nolilist: " << *citr << endl;
00348 
00349   if(loud>=1) cout << "mdaqlist has " << mdaq_ind.size() << " elements\n";
00350   if(loud>=1) cout << "nolilist has " << noli_ind.size() << " elements\n";
00351 
00352   vector<string> frun_ind;
00353   char FName[30];
00354 
00355   //compile list from physics file if requested
00356   if (UseRsmFile) {
00357     if(loud>=2) printf("Reading runsum runs from %s\n",runsum_file.c_str());
00358     ifstream RFile(runsum_file.c_str());
00359     while (1) {
00360       if(!RFile.good()) break;
00361       RFile >> FName;
00362       fname = FName;
00363       if (fname.length()>mdaq_str.length() &&
00364           fname.find(mdaq_str)==fname.length()-mdaq_str.length()) {
00365         frun_ind.push_back(fname.substr(0,fname.find(mdaq_str)));
00366         if(loud>=3) cout << "Adding to runindex file " << fname << endl;
00367       }
00368       if (fname.length()>noli_str.length() &&
00369           fname.find(noli_str)==fname.length()-noli_str.length()) {
00370         frun_ind.push_back(fname.substr(0,fname.find(noli_str)));
00371         if(loud>=3) cout << "Adding to runindex file " << fname << endl;
00372       }
00373     }
00374     RFile.close();
00375   }
00376 
00377   //compile list from physics file if requested, and only for dry runs
00378   if (UsePhysicsFile && DryRun) {
00379     if(loud>=2) printf("Reading physics runs from %s\n",physics_file.c_str());
00380     ifstream RFile(physics_file.c_str());
00381     while (1) {
00382       if(!RFile.good()) break;
00383       RFile >> FName;
00384       fname = FName;
00385       if (fname.length()>mdaq_str.length() &&
00386           fname.find(mdaq_str)==fname.length()-mdaq_str.length()) {
00387         frun_ind.push_back(fname.substr(0,fname.find(mdaq_str)));
00388         if(loud>=3) cout << "Adding to runindex file " << fname << endl;
00389       }
00390       if (fname.length()>noli_str.length() &&
00391           fname.find(noli_str)==fname.length()-noli_str.length()) {
00392         frun_ind.push_back(fname.substr(0,fname.find(noli_str)));
00393         if(loud>=3) cout << "Adding to runindex file " << fname << endl;
00394       }
00395     }
00396     RFile.close();
00397   }
00398 
00399   //compile list from other file if requested
00400   if (UseOtherFile) {
00401     if(loud>=2) printf("Reading other runs from %s\n",other_file.c_str());
00402     ifstream OFile(other_file.c_str());
00403     while (1) {
00404       OFile >> FName;
00405       if(!OFile.good()) break;
00406       fname = FName;
00407       if (fname.length()>mdaq_str.length() &&
00408           fname.find(mdaq_str)==fname.length()-mdaq_str.length()) {
00409         frun_ind.push_back(fname.substr(0,fname.find(mdaq_str)));
00410         if(loud>=3) cout << "Adding to runindex file " << fname << endl;
00411       }
00412     }
00413     OFile.close();
00414   }
00415 
00416   sort(frun_ind.begin(),frun_ind.end());
00417   if(loud>=4)
00418     for(citr=frun_ind.begin();citr!=frun_ind.end();citr++)
00419       cout << "Runindex: " << *citr << endl;
00420 
00421   if(loud>=1) cout << "Runindex has " << frun_ind.size() << " elements\n";
00422 
00423   //span the noli files for files not run
00424   vector<string> file_ind;
00425   bool noli_has, frun_has;
00426   for (citr=noli_ind.begin();citr!=noli_ind.end();citr++) {
00427     fname = *citr;
00428     frun_has=false;
00429     for(citr2=frun_ind.begin();citr2!=frun_ind.end();citr2++)
00430       if (citr->rfind(*citr2)!=string::npos) {frun_has=true; break;}
00431     if (!frun_has) {
00432       file_ind.push_back(fname+noli_str);
00433       if(loud>=3) cout << "Adding noli file to runlist " << fname << endl;
00434     }
00435   }
00436 
00437   //span the mdaq files for files not run
00438   for (citr=mdaq_ind.begin();citr!=mdaq_ind.end();citr++) {
00439     fname = *citr;
00440     noli_has=false; frun_has=false;
00441     for(citr2=noli_ind.begin();citr2!=noli_ind.end();citr2++)
00442       if (citr->rfind(*citr2)!=string::npos) {noli_has=true; break;}
00443     for(citr2=frun_ind.begin();citr2!=frun_ind.end() && !noli_has;citr2++)
00444       if (citr->rfind(*citr2)!=string::npos) {frun_has=true; break;}
00445     if (!noli_has && !frun_has) {
00446       file_ind.push_back(fname+mdaq_str);
00447       if(loud>=3) cout << "Adding mdaq file runlist " << fname << endl;
00448     }
00449   }
00450 
00451   sort(file_ind.begin(),file_ind.end());
00452   if(loud>=4)
00453     for(citr=file_ind.begin();citr!=file_ind.end();citr++)
00454       cout << "Runlist: " << *citr << endl;
00455 
00456   if(loud>=1) cout << "Runlist has " << file_ind.size() << " elements\n";
00457 
00458   JobC RunSum;
00459   JobCPathModule& RSM_PTH = RunSum.Path;
00460   JobCInput& RSM_INP = RunSum.Input;
00461   JobCMsgModule& RSM_MSG = RunSum.Msg;
00462   RSM_PTH.Create("RSM");
00463   JobCPath& R_PTH = RunSum.Path("RSM");
00464 
00465   RSM_PTH.Create("RunSummary");
00466 
00467   //Start up the JobControl stuff
00468   if (!DryRun) {
00469     gSystem->Load("libRunSummary");
00470     if (PhysicsAnalysis) {
00471       gSystem->Load("libFilterDigitSR");
00472       gSystem->Load("libDeMux");
00473       gSystem->Load("libAltDeMux");
00474       gSystem->Load("libAtmosEvent");
00475       gSystem->Load("libShieldPlank");
00476       gSystem->Load("libCandDataQuality");
00477       gSystem->Load("libNoiseFilter");
00478       //gSystem->Load("libDigitDraw");
00479 
00480       RSM_PTH.Create("base");
00481       RSM_PTH.Add("base","FilterType::Ana");
00482       RSM_PTH.Add("base","NoiseFilterModule::Ana");
00483       RSM_PTH.Add("base","DigitListModule::Get");
00484       RSM_PTH.Add("base","DigitListModule::Reco");
00485       RSM_PTH.Add("base","FilterDigitListModule::Reco");
00486       RSM_PTH.Add("base","DeMuxDigitListModule::Reco");
00487       RSM_PTH.Add("base","ShieldPlankListModule::Reco");
00488       JobCPath& R1_PTH = RunSum.Path("base");
00489       R1_PTH.Mod("FilterDigitListModule").Set("FilterDigitListAlgorithm=AlgFilterDigitListSR");
00490       R1_PTH.Mod("FilterDigitListModule").Set("NameListOut=filterdigitlist");
00491       R1_PTH.Mod("FilterDigitListModule").Set("SwitchPersToTemp=0");
00492       R1_PTH.Mod("DeMuxDigitListModule").Set("NameListIn=filterdigitlist");
00493       R1_PTH.Mod("DeMuxDigitListModule").Set("NameListOut=altdemux");
00494       R1_PTH.Mod("DeMuxDigitListModule").Set("DeMuxDigitListAlgConfig=devel");
00495       R1_PTH.Mod("FilterType").Set("PassMonitor=0");
00496       R1_PTH.Mod("FilterType").Set("PassSnarl=1");
00497       R1_PTH.Mod("FilterType").Set("PassCand=0");
00498       R1_PTH.Mod("FilterType").Set("PassLI=0");
00499       if(loud>=3) R1_PTH.Mod("FilterType").Report();
00500 
00501       AlgFactory &af = AlgFactory::GetInstance();
00502       af.Register("AlgDeMuxDigitList", "devel");
00503       AlgHandle ah = af.GetAlgHandle("AlgDeMuxDigitList", "devel");
00504       AlgConfig &acd = ah.GetAlgConfig();
00505       acd.UnLockValues();
00506       acd.Set("DeMuxAlgorithm", "AlgAltDeMuxCosmics");
00507       acd.Set("DeMuxAlgConfig", "default");
00508       acd.LockValues();
00509       acd.LockKeys();
00510 
00511       RSM_PTH.Create("daqmon","FilterType::Ana");
00512       JobCPath& R2_PTH = RunSum.Path("daqmon");
00513       R2_PTH.Mod("FilterType").Set("PassMonitor=1");
00514       R2_PTH.Mod("FilterType").Set("PassSnarl=0");
00515       R2_PTH.Mod("FilterType").Set("PassCand=0");
00516       R2_PTH.Mod("FilterType").Set("PassLI=0");
00517       if(loud>=3) R2_PTH.Mod("FilterType").Report();
00518 
00519       RSM_PTH.Add("RunSummary","DataQualityModule::Reco");
00520       RSM_PTH.Attach("RSM", "base");
00521       RSM_PTH.Attach("RSM", "daqmon");
00522       RSM_PTH.Attach("base", "RunSummary");
00523       RSM_PTH.Attach("daqmon", "RunSummary");
00524     }
00525     else {
00526       RSM_PTH.Attach("RSM","RunSummary");
00527     }
00528 
00529     if (UseRunSummary) {
00530       RSM_PTH.Add("RunSummary","RunSummary::Ana");
00531       JobCPath& R1_PTH = RunSum.Path("RunSummary");
00532       if(UseRsmFile) R1_PTH.Mod("RunSummary").Set("MakeRunFile=1");
00533       else R1_PTH.Mod("RunSummary").Set("MakeRunFile=0");
00534       R1_PTH.Mod("RunSummary").Set(("AFileDir="+sdir).c_str());
00535       R1_PTH.Mod("RunSummary").Set(("MFileDir="+sdir).c_str());
00536       R1_PTH.Mod("RunSummary").Set(("SplitFileDir="+sdir).c_str());
00537       if(MakeDBEntries) R1_PTH.Mod("RunSummary").Set("MakeDBEntries=1");
00538       if (!AppendFiles) {
00539         R1_PTH.Mod("RunSummary").Set("AppendFiles=0");
00540         R1_PTH.Mod("RunSummary").Set("MakeAFile=0");
00541         R1_PTH.Mod("RunSummary").Set("MakeMFile=0");
00542       }
00543       if(MonthlyDir) R1_PTH.Mod("RunSummary").Set("MonthlySubDir=1");
00544       //Name summary mail file for current UTC date
00545       TTimeStamp tt;
00546       string mfname = "summary.";
00547       mfname += UtilString::ToString<int>(tt.GetDate());
00548       if (FarmListGen) {
00549         R1_PTH.Mod("RunSummary").Set("FarmList=1");
00550         R1_PTH.Mod("RunSummary").Set("MakeMFile=1");
00551         R1_PTH.Mod("RunSummary").Set(("MFileName="+mfname).c_str());
00552         R1_PTH.Mod("RunSummary").Set("AppendFiles=1");
00553         R1_PTH.Mod("RunSummary").Set("MakeAFile=0");
00554         R1_PTH.Mod("RunSummary").Set("MakeSplitFile=0");
00555       }
00556       if (WebGen) {
00557         R1_PTH.Mod("RunSummary").Set("AppendFiles=1");
00558         R1_PTH.Mod("RunSummary").Set("MakeSplitFile=1");
00559         R1_PTH.Mod("RunSummary").Set("MakeAFile=0");
00560         R1_PTH.Mod("RunSummary").Set("MakeMFile=1");
00561         R1_PTH.Mod("RunSummary").Set(("MFileDir="+sdir+"/farm_lists").c_str());
00562         R1_PTH.Mod("RunSummary").Set(("MFileName="+mfname).c_str());
00563       }
00564       if (MonthlyGen) {
00565         R1_PTH.Mod("RunSummary").Set("AppendFiles=1");
00566         R1_PTH.Mod("RunSummary").Set("MakeSplitFile=1");
00567         R1_PTH.Mod("RunSummary").Set("MakeAFile=0");
00568         R1_PTH.Mod("RunSummary").Set("MakeMFile=1");
00569         R1_PTH.Mod("RunSummary").Set(("MFileDir="+sdir).c_str());
00570         R1_PTH.Mod("RunSummary").Set(("MFileName=farm.lst"));
00571       }
00572       if(loud>=3) R1_PTH.Mod("RunSummary").Report();
00573     }
00574 
00575     if (UseRateSummary) {
00576       RSM_PTH.Add("RunSummary","RateSummary::Ana");
00577       JobCPath& R1_PTH = RunSum.Path("RunSummary");
00578       if(UseRsmFile) R1_PTH.Mod("RateSummary").Set("MakeRunFile=1");
00579       else R1_PTH.Mod("RateSummary").Set("MakeRunFile=0");
00580       R1_PTH.Mod("RateSummary").Set(("RateTreeDir="+sdir).c_str());
00581       if(MonthlyDir) R1_PTH.Mod("RateSummary").Set("MonthlySubDir=1");
00582       if(loud>=3) R1_PTH.Mod("RateSummary").Report();
00583     }
00584 
00585     //RSM_INP.Set("Streams=DaqSnarl,DaqMonitor,LightInjection,Cand");
00586     RSM_INP.Set("Streams=DaqSnarl,DaqMonitor");
00587     //RSM_INP.Set("Streams=DaqMonitor");
00588     if(FarmListGen) RSM_INP.Set("Streams=DaqSnarl");
00589 
00590     RSM_MSG.SetLevel("Raw","Fatal");
00591 
00592     RSM_MSG.SetLevel("DataQ","Debug");
00593     RSM_MSG.SetLevel("Plex","Error");
00594     if(loud>=2) RSM_MSG.SetLevel("Plex","Info");
00595 
00596     RSM_MSG.SetLevel("Dbi","Error");
00597     if(loud>=2) RSM_MSG.SetLevel("Dbi","Info");
00598 
00599     if(loud>= 4) RSM_MSG.SetLevel("RSM","Verbose");
00600     if(loud== 3) RSM_MSG.SetLevel("RSM","Debug");
00601     if(loud== 2) RSM_MSG.SetLevel("RSM","Synopsis");
00602     if(loud== 1) RSM_MSG.SetLevel("RSM","Info");
00603     if(loud== 0) RSM_MSG.SetLevel("RSM","Warning");
00604     if(loud==-1) RSM_MSG.SetLevel("RSM","Error");
00605     if(loud<=-2) RSM_MSG.SetLevel("RSM","Fatal");
00606   }
00607 
00608   //Other and Physics files here
00609   ofstream ofile, pfile;
00610   if(UseOtherFile) ofile.open(other_file.c_str(), ios_base::out | ios_base::app);
00611   if(UsePhysicsFile) pfile.open(physics_file.c_str(), ios_base::out | ios_base::app);
00612   ofstream bfile(".building_runsum",ios_base::out);
00613 
00614   //Test files now
00615   for (citr=file_ind.begin();citr!=file_ind.end();citr++) {
00616     if(loud>=2) cout << "Testing " << *citr << endl;
00617     int sep_val = sepruns(*citr);
00618     if(loud>=2) cout << " sepruns returns " << sep_val << endl;
00619     int cfg_val = cfgtest(*citr);
00620     if(loud>=2) cout << " cfgtest returns " << cfg_val << endl;
00621 
00622     if (cfg_val==0) {
00623       if(loud>=2) cout << " Passed cfgtest" << endl;
00624       if(MakeScript) ptrig_run(*citr);
00625       if(UsePhysicsFile) pfile << *citr << endl;
00626       RSM_INP.AddFile(citr->c_str());
00627       bfile << *citr << endl;
00628       nfiles_run++;
00629     }
00630     else if (cfg_val>=1 && cfg_val<=3) {
00631       if(loud>=2) cout << " Failed cfgtest" << endl;
00632       if(MakeScript) other_run(*citr);
00633       if(UseOtherFile) ofile << *citr << endl;
00634     }
00635     else {
00636       if(loud>=2) cout << " Undetermined cfgtest" << endl;
00637       if (sep_val==0) {
00638         if(loud>=2) cout << " Passed sepruns" << endl;
00639         if(MakeScript) ptrig_run(*citr);
00640         if(UsePhysicsFile) pfile << *citr << endl;
00641         RSM_INP.AddFile(citr->c_str());
00642         bfile << *citr << endl;
00643         nfiles_run++;
00644       }
00645       else {
00646         if(loud>=2) cout << " Failed sepruns" << endl;
00647         if(MakeScript) other_run(*citr);
00648         if(UseOtherFile) ofile << *citr << endl;;
00649       }
00650     }
00651   }
00652 
00653   if(UseOtherFile) ofile.close();
00654   if(UsePhysicsFile) pfile.close();
00655   bfile.close();
00656 
00657   if(nfiles_run>0 && loud>=0)
00658     cout << "Running " << nfiles_run << " of "
00659          << mdaq_ind.size() << " mdaq files and "
00660          << noli_ind.size() << " noli files\n";
00661 
00662   if (!DryRun) {
00663     RSM_MSG.SetLevel("Io","Warning");
00664     if(loud>=2) R_PTH.Report();
00665     R_PTH.Run();
00666     if(loud>=1) R_PTH.Report();
00667   }
00668 
00669   if(MakeScript)
00670     gSystem->Exec("chmod 755 other.sh");
00671 
00672   gSystem->Exec("rm -f ./.building_runsum");
00673 }

void other_run ( string  fname  ) 

Definition at line 868 of file runsum.cc.

References loud.

Referenced by main().

00868                              {
00869   if(loud>=3) cout << "other run for " << fname << endl;
00870   ofstream script("other.sh",ios_base::out | ios_base::app);
00871   script << "rm -f " << fname << endl;
00872   script.close();
00873 }

void ptrig_run ( string  fname  ) 

Definition at line 863 of file runsum.cc.

References loud.

Referenced by main().

00863                              {
00864   if(loud>=3) cout << "ptrig run for " << fname << endl;
00865   //Add nothing to scripts
00866 }

void question ( string  gravel,
string *  drugs 
)

Definition at line 78 of file runsum.cc.

00078                                             {
00079   char linein[50];
00080   cout << gravel;
00081   cout << "(" << *drugs << "):";
00082   cin.getline(linein,sizeof(linein));
00083   if(strlen(linein)) *drugs=linein;
00084 }

void question ( string  gravel,
int *  drugs 
)

Definition at line 70 of file runsum.cc.

00070                                          {
00071   char linein[50];
00072   cout << gravel;
00073   cout << "(" << *drugs << "):";
00074   cin.getline(linein,sizeof(linein));
00075   if(strlen(linein)) *drugs=atoi(linein);
00076 }

void question ( string  gravel,
bool *  drugs 
)

Definition at line 58 of file runsum.cc.

Referenced by isetup().

00058                                           {
00059   char linein[50];
00060   cout << gravel;
00061   if(*drugs) cout << "(Y/n):";
00062   else cout << "(y/N):";
00063   cin.getline(linein,sizeof(linein));
00064   if(strncmp(linein,"y",1)==0) *drugs=true;
00065   if(strncmp(linein,"Y",1)==0) *drugs=true;
00066   if(strncmp(linein,"n",1)==0) *drugs=false;
00067   if(strncmp(linein,"N",1)==0) *drugs=false;
00068 }

int sepruns ( string  fname  ) 

Definition at line 685 of file runsum.cc.

References RawRecord::GetRawHeader(), RawDaqHeader::GetRun(), RawDaqHeader::GetRunType(), RawDaqHeader::GetSubRun(), RawDaqSnarlHeader::GetTrigSrc(), loud, run(), RUN_TYPE_CHECKOUT, RUN_TYPE_MASK_TYPECODE, RUN_TYPE_PHYSICS, RUN_TYPE_VA_CALIBRATE, RUN_TYPE_VA_PEDESTAL, RUNNUM_NEW_RUNTYPES, TRIGGER_BIT_NULL, and TRIGGER_BIT_PLANE.

Referenced by main().

00685                           {
00686   TFile *fFile = 0;
00687 
00688   if(loud>=2) cout << "sepruns checking file " << fname.c_str() << endl;
00689   fFile = new TFile(fname.c_str());
00690   if (!fFile) {
00691     if(loud>=1) cout << fname << " File not valid\n";
00692     return -1;
00693   }
00694   if (!(fFile->Get("DaqSnarl"))) {
00695     if(loud>=1) cout << fname << " Contains no DaqSnarl object\n";
00696     fFile->Close();
00697     return -1;
00698   }
00699 
00700   TTree *dsnrl = dynamic_cast<TTree*>(fFile->Get("DaqSnarl"));
00701   if (!dsnrl) {
00702     if(loud>=1) cout << fname << " Error retrieving DaqSnarl\n";
00703     fFile->Close();
00704     return -1;
00705   }
00706 
00707   if (dsnrl->GetEntries() <= 1) {
00708     if(loud>=1) cout << fname << " To Few (" << dsnrl->GetEntries() << ") DaqSnarls\n";
00709     fFile->Close();
00710     return -1;
00711   }
00712 
00713   RawRecord* record = 0;
00714   const RawDaqSnarlHeader* head = 0;
00715 
00716   dsnrl->SetBranchAddress("RawRecord",&record);
00717   dsnrl->GetEntry(0);//Look at just first DaqSnarl
00718 
00719   head=dynamic_cast<const RawDaqSnarlHeader*>(record->GetRawHeader());
00720   if(!head) {fFile->Close(); return -1;}
00721 
00722   Int_t run = head->GetRun();
00723   Int_t srun = head->GetSubRun();
00724   Int_t rtype = head->GetRunType();
00725   Int_t trigsrc = head->GetTrigSrc();
00726   if(loud>=2) cout << " Run:" << run << ";" << srun
00727                    << ", RunType:" << rtype
00728                    << ", TrigSrc:" << trigsrc << endl;
00729 
00730   //Hosed up RawDaqSnarlHeader
00731   if (run==0 || srun<0 || rtype<0) {
00732     if(loud>=1) cout << fname << " hosed header\n";
00733     fFile->Close();
00734     return -1;
00735   }
00736 
00737   fFile->Close();
00738 
00739   //Check for new RunType definitions
00740   if (run > RUNNUM_NEW_RUNTYPES) {
00741     if(loud>=2) cout << " New RunType: " << rtype << endl;
00742     if((rtype&RUN_TYPE_MASK_TYPECODE) == RUN_TYPE_PHYSICS) return 0;
00743     if((rtype&RUN_TYPE_MASK_TYPECODE) == RUN_TYPE_CHECKOUT) return 2;
00744     if((rtype&RUN_TYPE_MASK_TYPECODE) == RUN_TYPE_VA_PEDESTAL) return 1;
00745     if((rtype&RUN_TYPE_MASK_TYPECODE) == RUN_TYPE_VA_CALIBRATE) return 3;
00746     return 4;
00747   }
00748 
00749   //Plane Trigger Runs
00750   if(rtype==2 && (trigsrc&TRIGGER_BIT_PLANE)) return 0;
00751 
00752   //Singles and Special Runs
00753   if(rtype==2 && (trigsrc&TRIGGER_BIT_NULL)) return 2;
00754 
00755   //Pedestals
00756   if(rtype==1) return 1;
00757 
00758   //Calibrate
00759   if(rtype==3) return 3;
00760 
00761   return 4;
00762 }

void usage (  ) 

Definition at line 875 of file runsum.cc.

00875              {
00876   cout << "Usage: runsum -hvdmsrHPMw -o -O <otherfile> -f -F <runfile>\n";
00877 
00878   cout << " -h: Usage Message\n";
00879   cout << " -v: Verbose output\n";
00880   cout << " -n: Dry Run (no summarizing)\n";
00881 
00882   cout << " -M: Run monthly umn generation\n";
00883   cout << " -W: Run standard web generation\n";
00884   cout << " -L: Run farm list generation\n";
00885 
00886   cout << " -m: Produce sh scripts\n";
00887   cout << " -o: Use other run file (other.run)\n";
00888   cout << " -O <otherfile>: Set other run file name=<otherfile>\n";
00889   cout << " -f: Use runsum run file (RunSummary.run)\n";
00890   cout << " -F <runfile>: Set runsum run file name=<runfile>\n";
00891   cout << " -p: Use physics run file (RunSummary.run)\n";
00892   cout << " -P <runfile>: Set physicsrun file name=<runfile>\n";
00893 
00894   cout << " -s: use only RunSummary Module\n";
00895   cout << " -r: use only RateSummary Module\n";
00896   cout << " -H: Make hit maps in RateSummary module\n";
00897 }


Variable Documentation

Bool_t AppendFiles = true

Definition at line 103 of file runsum.cc.

Referenced by isetup(), and main().

Bool_t DryRun = false

Definition at line 99 of file runsum.cc.

Bool_t FarmListGen = false

Definition at line 89 of file runsum.cc.

Referenced by isetup(), and main().

Int_t loud = 0

Definition at line 86 of file runsum.cc.

Bool_t MakeDBEntries = false

Definition at line 106 of file runsum.cc.

Referenced by main().

Bool_t MakeHitMaps = false

Definition at line 102 of file runsum.cc.

Referenced by isetup(), and main().

Bool_t MakeScript = false

Definition at line 98 of file runsum.cc.

Referenced by isetup(), and main().

Bool_t MonthlyDir = false

Definition at line 104 of file runsum.cc.

Referenced by isetup(), and main().

Bool_t MonthlyGen = false

Definition at line 90 of file runsum.cc.

Referenced by isetup(), and main().

string other_file = "other.run"

Definition at line 94 of file runsum.cc.

Referenced by isetup(), and main().

string physics_file = "physics.run"

Definition at line 95 of file runsum.cc.

Referenced by isetup(), and main().

Bool_t PhysicsAnalysis = false

Definition at line 92 of file runsum.cc.

Referenced by main().

string runsum_file = "RunSummary.run"

Definition at line 96 of file runsum.cc.

Referenced by isetup(), and main().

string sdir = "./"

Definition at line 108 of file runsum.cc.

Referenced by isetup(), main(), MiniPlotMaker::SaveHistos(), and RunSummary::SFileOUT().

Bool_t UseOtherFile = false

Definition at line 94 of file runsum.cc.

Referenced by isetup(), and main().

Bool_t UsePhysicsFile = false

Definition at line 95 of file runsum.cc.

Referenced by isetup(), and main().

Bool_t UseRateSummary = true

Definition at line 101 of file runsum.cc.

Referenced by isetup(), and main().

Bool_t UseRsmFile = false

Definition at line 96 of file runsum.cc.

Referenced by isetup(), and main().

Bool_t UseRunSummary = true

Definition at line 100 of file runsum.cc.

Referenced by isetup(), and main().

Bool_t WebGen = false

Definition at line 91 of file runsum.cc.

Referenced by isetup(), and main().


Generated on 8 Jul 2019 for loon by  doxygen 1.6.1