Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

rundmc.cc File Reference

#include <algorithm>
#include <iostream>
#include <fstream>
#include <libgen.h>
#include <iosfwd>
#include <vector>
#include <map>
#include <unistd.h>
#include <getopt.h>
#include "TError.h"
#include "TFile.h"
#include "TIterator.h"
#include "TList.h"
#include "TObject.h"
#include "TObjectTable.h"
#include "TROOT.h"
#include "TString.h"
#include "TSystem.h"
#include "TTimeStamp.h"
#include "TTree.h"
#include "Conventions/Detector.h"
#include "JobControl/JobC.h"
#include "JobControl/JobCEnv.h"
#include "MessageService/MsgService.h"
#include "MessageService/Msg.h"
#include "OnlineUtil/mdRunTypeCodes.h"
#include "OnlineUtil/mdTriggerCodes.h"
#include "Util/UtilString.h"
#include "RSM.h"
#include "UtilRSM.h"

Go to the source code of this file.

Typedefs

typedef map< string, bool > MSB
typedef MSB::value_type MSBVT
typedef MSB::iterator MSBItr
typedef MSB::const_iterator MSBCItr
typedef multimap< string,
string > 
MMSS
typedef MMSS::value_type MMSSVT
typedef MMSS::iterator MMSSItr
typedef MMSS::const_iterator MMSSCItr

Functions

 CVSID ("$Id: rundmc.cc,v 2.4 2006/02/01 20:04:12 rhatcher Exp $")
void usage ()
int main (int argc, char **argv)

Variables

Int_t loud = 0
Bool_t DryRun = false
Bool_t BatchMode = false
string RootDataDir = "./"
vector< string > RootDataList
Bool_t PathCompare = true
Bool_t SuffCompare = true
Bool_t ReadRunFiles = true
Bool_t MakeListFiles = true


Typedef Documentation

typedef multimap<string,string> MMSS
 

Definition at line 60 of file rundmc.cc.

Referenced by main().

typedef MMSS::const_iterator MMSSCItr
 

Definition at line 63 of file rundmc.cc.

Referenced by main().

typedef MMSS::iterator MMSSItr
 

Definition at line 62 of file rundmc.cc.

typedef MMSS::value_type MMSSVT
 

Definition at line 61 of file rundmc.cc.

Referenced by main().

typedef map<string,bool> MSB
 

Definition at line 56 of file rundmc.cc.

Referenced by main().

typedef MSB::const_iterator MSBCItr
 

Definition at line 59 of file rundmc.cc.

Referenced by main().

typedef MSB::iterator MSBItr
 

Definition at line 58 of file rundmc.cc.

typedef MSB::value_type MSBVT
 

Definition at line 57 of file rundmc.cc.


Function Documentation

CVSID "$Id: rundmc.  cc,
v 2.4 2006/02/01 20:04:12 rhatcher Exp $" 
 

int main int  argc,
char **  argv
 

COMMAND LINE

CALIB CONSTANTS

BEAM RUN KEY

Cerenkov ADC cuts:

ATTENUATION PARAMS

FILE + TREE

Definition at line 80 of file rundmc.cc.

References BatchMode, UtilRSM::CheckFile(), UtilRSM::DirFileList(), DryRun, UtilRSM::FileFileList(), UtilRSM::FileListOut(), find(), MsgService::GetStream(), gSystem(), JobCEnv::Instance(), MsgService::Instance(), loud, MakeListFiles, MMSS, MMSSCItr, MMSSVT, MSB, MSBCItr, PathCompare, ReadRunFiles, RootDataDir, RootDataList, RSMErr, RSMInf, RSMSyn, RSMWar, UtilRSM::RunType(), UtilRSM::RunTypeName(), RunTypeName(), s(), MsgStream::SetLogLevel(), SuffCompare, UtilString::ToString(), usage(), and JobCEnv::Cleaner::~Cleaner().

00080                                 {
00081 
00082   MSB UseModes;
00083   UseModes["Physics"] = true;//just the physics runs by default
00084   const char short_opt[] = "hvqnFNAD:L:rRmM";
00085   int c;
00086   while ((c = getopt(argc,argv,short_opt)) != -1)
00087     switch (c) {
00088     case 'h':
00089       usage();
00090       exit(0);
00091       break;
00092     case 'v':
00093       loud++;
00094       break;
00095     case 'q':
00096       loud--;
00097       break;
00098     case 'n':
00099       if(loud>=0) cout << "DryRun (no running done)\n";
00100       DryRun = true;
00101       break;
00102     case 'F':
00103       if(loud>=0) cout << "Far Setup\n";
00104       BatchMode = true;
00105       UseModes["Physics"] = true;
00106       UseModes["CheckOut"] = true;
00107       UseModes["VACalibrate"] = true;
00108       UseModes["VAPedestal"] = true;
00109       ReadRunFiles = true;
00110       MakeListFiles = false;
00111       RootDataDir="/data/root_files";
00112       break;
00113     case 'N':
00114       if(loud>=0) cout << "Near Setup\n";
00115       BatchMode = true;
00116       UseModes["Physics"] = true;
00117       UseModes["CheckOut"] = true;
00118       UseModes["QieCalibrate"] = true;
00119       UseModes["QieMonitor"] = true;
00120       ReadRunFiles = true;
00121       MakeListFiles = false;
00122       break;
00123     case 'A':
00124       if(loud>=0) cout << "All Setup\n";
00125       //BatchMode = true;
00126       UseModes["Physics"] = true;
00127       UseModes["CheckOut"] = true;
00128       UseModes["VACalibrate"] = true;
00129       UseModes["VAPedestal"] = true;
00130       UseModes["QieCalibrate"] = true;
00131       UseModes["QieMonitor"] = true;
00132       ReadRunFiles = true;
00133       MakeListFiles = true;
00134       break;
00135     case 'D':
00136       if(loud>=0) cout << "Use root data directory " << optarg << endl;
00137       RootDataDir = optarg;
00138       break;
00139     case 'L':
00140       if(loud>=0) cout << "Add root data list " << optarg << endl;
00141       RootDataList.push_back(optarg);
00142       break;
00143     case 'r':
00144       ReadRunFiles = false;
00145       break;
00146     case 'R':
00147       ReadRunFiles = true;
00148       break;
00149     case 'm':
00150       MakeListFiles = false;
00151       break;
00152     case 'M':
00153       MakeListFiles = true;
00154       break;
00155     default:
00156       cerr << "unknown command line option:" << optopt << endl;
00157       usage();
00158       exit(1);
00159       break;
00160     }
00161   if(loud>=1) printf("Verbose output level %d\n",loud);
00162   if(loud<=0) gErrorIgnoreLevel = kFatal;
00163   MsgStream *s = MsgService::Instance()->GetStream("RSM");
00164 
00165   if(loud>= 4) s->SetLogLevel(Msg::kVerbose);
00166   if(loud== 3) s->SetLogLevel(Msg::kDebug);
00167   if(loud== 2) s->SetLogLevel(Msg::kSynopsis);
00168   if(loud== 1) s->SetLogLevel(Msg::kInfo);
00169   if(loud== 0) s->SetLogLevel(Msg::kWarning);
00170   if(loud==-1) s->SetLogLevel(Msg::kError);
00171   if(loud<=-2) s->SetLogLevel(Msg::kFatal);
00172 
00173   //Make sure nothing is building for batch mode
00174   if (BatchMode) {
00175     gROOT->SetBatch();
00176     if (UtilRSM::CheckFile("./.building_rundmc",false)) {
00177       cout << "Already building in this directory" << endl;
00178       cout << "Remove .building_rundmc to proceed" << endl;
00179       exit(0);
00180     }
00181 
00182     UtilRSM::FileListOut(".building_rundmc",
00183                          UtilString::ToString<int>(getpid()),
00184                          false);
00185     //ofstream bfile;
00186     //bfile.open(".building_rundmc", ios_base::out);
00187     //bfile << getpid() << endl;
00188     //bfile.close();
00189   }
00190 
00191   string fname;
00192   string mdaq_str = ".mdaq.root";
00193   vector<string> mdaq_ind;
00194 
00195   //Compile list if files are specified on command line
00196   for (int i=optind; i<argc; i++) {
00197     if(PathCompare) fname = argv[i];
00198     else fname = basename(argv[i]);
00199 
00200     if(fname.length()<=mdaq_str.length()) continue;
00201     if(fname.find(mdaq_str)!=fname.length()-mdaq_str.length()) continue;
00202 
00203     if(!SuffCompare) fname = fname.substr(0,fname.find(mdaq_str));
00204 
00205     mdaq_ind.push_back(fname);
00206     ReadRunFiles = false;
00207   }
00208 
00209   //If no mdaq files on command line, first look in RootDataList
00210   for (unsigned int i=0;i<RootDataList.size();i++) {
00211     mdaq_ind = UtilRSM::FileFileList(RootDataList[i],mdaq_str,
00212                                      PathCompare,SuffCompare);
00213   }
00214 
00215   //If no mdaq files yet, try RootDataDir
00216   if (mdaq_ind.size()==0) {
00217     PathCompare = false;
00218     mdaq_ind = UtilRSM::DirFileList(RootDataDir,mdaq_str,
00219                                     PathCompare,SuffCompare);
00220   }
00221 
00222   //Sort the mdaq lists
00223   sort(mdaq_ind.begin(),mdaq_ind.end());
00224 
00225   RSMSyn << mdaq_ind.size() << " " << mdaq_str << " files" << endl;
00226   //Build the list of the files that have been run into frun_ind
00227   vector<string> frun_ind;
00228   if (ReadRunFiles) {
00229     for (MSBCItr MItr=UseModes.begin();MItr!=UseModes.end();++MItr) {
00230       if (! (*MItr).second ) continue;
00231       string ThisMode = (*MItr).first;
00232       RSMInf << "Reading run file for " << ThisMode << " mode" << endl;
00233       frun_ind = UtilRSM::FileFileList(ThisMode+".run",mdaq_str,
00234                                        PathCompare,SuffCompare,
00235                                        frun_ind);
00236     }
00237 
00238     //Also check the Failure and Unknown run files
00239     frun_ind = UtilRSM::FileFileList("Failure.run",mdaq_str,
00240                                      PathCompare,SuffCompare,
00241                                      frun_ind);
00242     frun_ind = UtilRSM::FileFileList("Unknown.run",mdaq_str,
00243                                      PathCompare,SuffCompare,
00244                                      frun_ind);
00245 
00246     sort(frun_ind.begin(),frun_ind.end());
00247   }
00248   RSMSyn << frun_ind.size() << " run files" << endl;
00249 
00250   UInt_t NFailure = 0;
00251   UInt_t NUnknown = 0;
00252 
00253   MMSS ListModes;
00254   //Test files to determine runtype and build lists.
00255   for (unsigned int i=0;i<mdaq_ind.size();i++) {
00256     //Skip the run if it is in the frun_ind list
00257     if(find(frun_ind.begin(),frun_ind.end(),mdaq_ind[i])
00258        != frun_ind.end()) continue;
00259 
00260     string FullFName = mdaq_ind[i];
00261     if(!PathCompare) FullFName = RootDataDir + "/" + mdaq_ind[i];
00262     RSMSyn << "Looking at " << FullFName << endl;
00263     short RunType = UtilRSM::RunType(FullFName);
00264     short BaseRunType = RunType&UtilRSM::RTMask;
00265     string RunTypeName = UtilRSM::RunTypeName(BaseRunType);
00266     RSMSyn << "Get RunType " << RunType << endl;
00267     RSMSyn << "BaseRunType " << BaseRunType << endl;
00268     RSMSyn << "RunTypeName " << RunTypeName << endl;
00269 
00270     //Look for runs that failed UtilRSM::RunType
00271     if (RunType&UtilRSM::RTFail) {
00272       UtilRSM::FileListOut("Failure.run",FullFName,true);
00273       NFailure++;
00274       continue;
00275     }
00276 
00277     //Now check test and modified bit set
00278     if (BaseRunType==0) {
00279       UtilRSM::FileListOut("Unknown.run",FullFName,true);
00280       NUnknown++;
00281       continue;
00282     }
00283 
00284     ListModes.insert(MMSSVT(RunTypeName,FullFName));
00285     if(BatchMode) UtilRSM::FileListOut(".building_rundmc",FullFName,true);
00286   }
00287 
00288   if(NFailure>0) RSMErr << NFailure << " Failure runs\n";
00289   if(NUnknown>0) RSMWar << NUnknown << " Unknown runs\n";
00290 
00291   for (MSBCItr MItr=UseModes.begin();MItr!=UseModes.end();++MItr) {
00292     if(!(*MItr).second) continue;
00293     string ThisMode = (*MItr).first;
00294     RSMInf << ListModes.count(ThisMode) << " " << ThisMode << endl;
00295   }
00296 
00297   int NProcessed = 0;
00298 
00299   for (MSBCItr MItr=UseModes.begin();MItr!=UseModes.end();++MItr) {
00300     if(!(*MItr).second) continue;
00301     string ThisMode = (*MItr).first;
00302     RSMInf << "Building run list for " << ThisMode << " mode" << endl;
00303     MMSSCItr Lower = ListModes.lower_bound(ThisMode);
00304     MMSSCItr Upper = ListModes.upper_bound(ThisMode);
00305 
00306     vector<string> ThisList;
00307     for(MMSSCItr MMItr=Lower;MMItr!=Upper;++MMItr) {
00308       ThisList.push_back((*MMItr).second);
00309     }
00310     if(ThisList.size()==0) continue;
00311 
00312     if(MakeListFiles) UtilRSM::FileListOut(ThisMode+".lst",ThisList);
00313     if(DryRun) continue;
00314     if (!UtilRSM::CheckFile(ThisMode+".C")) {
00315       RSMWar << "No " << ThisMode+".C" << " found" << endl;
00316       continue;
00317     }
00318 
00319     JobCEnv::Cleaner jcecl;//Cleaner to purge JobCEnv
00320     //Start it up once and clean it, just to tempt fate, and have it
00321     //crash before running in case JobCEnv::Cleaner is privatized
00322     jcecl.~Cleaner();
00323 
00324     int Argc=2;
00325     char **Argv = new char*[Argc];
00326     Argv[0] = argv[0];
00327     Int_t ErrorStat;
00328     string MacroStr = ThisMode + ".C";
00329     MacroStr += "(" + UtilString::ToString(loud) + ")";
00330     for (unsigned int i=0;i<ThisList.size();i++) {
00331       Argv[1]=(char *)((ThisList[i]).c_str());
00332       //JobCEnv &jce = JobCEnv::Instance(Argc,Argv);
00333       JobCEnv::Instance(Argc,Argv);
00334 
00335       gROOT->Macro(MacroStr.c_str(),&ErrorStat);
00336 
00337       if(ErrorStat == 0) NProcessed++;
00338       else RSMWar << ThisMode << ".C returned " << ErrorStat << endl;
00339       jcecl.~Cleaner();
00340     }
00341   }
00342   RSMInf << NProcessed << " runs processed" << endl;
00343 
00344   if(BatchMode) gSystem->Unlink("./.building_rundmc");
00345   //gObjectTable->Print();
00346   return NProcessed;
00347 }

void usage  ) 
 

Definition at line 121 of file rate_plot.cc.

00122 {
00123   cout << "Usage: rate_plot -qvhntWMR -D,T,L [base] -C [Title] "
00124        << " -V [Crate-Varc-Vmm]"
00125        << " -x [X-Axis] -B [BinWidth]"
00126        << " -P [PlaneLimit] -s [OptRate]"
00127        << " [List of .rate.root files]" << endl;
00128   cout << " -v: Verbose output up one level\n";
00129   cout << " -q: Quiet output down one level\n";
00130   cout << " -h: Output this usage statement\n";
00131   cout << " -n: Dry Run (not for real, just for play)\n";
00132   cout << " -V [Crate-Varc-Vmm]: Make chip level plots\n";
00133   cout << " -W: Weekly binning convention, zero on Sunday, days on X-axis, 1 hour bins\n";
00134   cout << " -w [DATE]: Weekly binning convention zero day to DATE"
00135        << " (20071022 e.g.)" << endl;
00136   cout << " -M: Monthly binning convention, zero on end of month, days on X-axis, 4 hour bins\n";
00137   cout << " -m DATE: Monthly binning convention for month of DATE"
00138        << " (200710 e.g.)" << endl;
00139   cout << " -T \"title\": Title to go atop all plots\n";
00140   cout << " -X [S,M,H,D]: X-axis on seconds, minutes, hours, or days ("
00141        << time_str << ")" << endl;
00142   cout << " -B BinWidth[S,M,H,D]: Bin by BinWidth seconds, minutes, hours, or days ("
00143        << bin_width << bin_str << ")" << endl;
00144   cout << " -P PlaneLimit: Number of planes on SM activity cuts("
00145        << fPlaneLimit << ")" << endl;
00146   cout << " -s OptRate: Optimal Signal Snarl Rate ("
00147        << fOptSignal << ")" << endl;
00148   cout << " -A [P,S,p,s]: Allow (capital letter) or Disallow (small letter) pulsed (p or P) and shield (s or S)" << endl;
00149 }


Variable Documentation

Bool_t BatchMode = false
 

Definition at line 67 of file rundmc.cc.

Referenced by main().

Bool_t DryRun = false
 

Definition at line 65 of file rundmc.cc.

Int_t loud = 0
 

Definition at line 54 of file rundmc.cc.

Bool_t MakeListFiles = true
 

Definition at line 76 of file rundmc.cc.

Referenced by main().

Bool_t PathCompare = true
 

Definition at line 72 of file rundmc.cc.

Referenced by main().

Bool_t ReadRunFiles = true
 

Definition at line 75 of file rundmc.cc.

Referenced by main().

string RootDataDir = "./"
 

Definition at line 69 of file rundmc.cc.

Referenced by main().

vector<string> RootDataList
 

Definition at line 70 of file rundmc.cc.

Referenced by main().

Bool_t SuffCompare = true
 

Definition at line 73 of file rundmc.cc.

Referenced by main().


Generated on Mon Feb 15 11:08:11 2010 for loon by  doxygen 1.3.9.1