- Timestamp:
- 07/20/08 15:47:10 (16 years ago)
- Location:
- trunk/MagicSoft/Mars
- Files:
-
- 2 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/Changelog
r9017 r9018 43 43 * mbase/MTime.cc: 44 44 - made SetSqlDateTime more flexible 45 46 * mjobs/MJMerpp.[h,cc]: 47 - added (basically the code from merpp.cc) 48 - enhanced with the possibility to merpp a whole sequence 49 50 * merpp.cc: 51 - use new MJMerpp 52 53 * mjobs/Makefile, mjobs/JobsLinkDef.h: 54 - added MJMerpp 45 55 46 56 -
trunk/MagicSoft/Mars/datacenter/macros/checkfileavail.C
r8851 r9018 18 18 ! Author(s): Daniela Dorner, 01/2005 <mailto:dorner@astro.uni-wuerzburg.de> 19 19 ! 20 ! Copyright: MAGIC Software Development, 2000-200 620 ! Copyright: MAGIC Software Development, 2000-2008 21 21 ! 22 22 ! … … 34 34 // 35 35 // executing the macro: 36 // .x checkfileavail.C+( "sequencefile")36 // .x checkfileavail.C+(100002) 37 37 // the sequencefile (including path) has to be given, as the macro retrieves 38 38 // from there the runnumbers 39 39 // 40 // the macro returns 0, if there's no connection to the database, 2 ,if a41 // file is missing, and 1 if all files are there 40 // the macro returns 0, if there's no connection to the database, 2 if a 41 // file is missing, and 1 if all files are there, 3 in case of error. 42 42 // the return value is checked by the script, that executes the macro 43 43 // … … 45 45 // 46 46 ///////////////////////////////////////////////////////////////////////////// 47 48 47 #include <iostream> 49 48 #include <iomanip> 50 #include <fstream>51 49 52 #include <TEnv.h>53 54 #include <MSQLServer.h>55 50 #include <TSQLRow.h> 56 51 #include <TSQLResult.h> 57 52 53 #include "MSQLServer.h" 54 58 55 using namespace std; 59 56 60 61 //check the value of a column for a run 62 //if a file is not available, the column contains nothing (NULL) - this value is returned 63 TString GetStatus(MSQLServer &serv, TEnv &rc, TString primary, TString table, TString column) 57 int checkfileavail(Int_t num, Int_t tel) 64 58 { 65 TString query(Form("SELECT %s FROM %s WHERE %s=%s", 66 column.Data(), table.Data(), 67 rc.GetValue(table+".Primary", ""), 68 primary.Data())); 69 70 cout << "Query: " << query << endl; 71 72 TSQLResult *res = serv.Query(query); 73 if (!res) 74 { 75 cout << "Error - no run to check" << endl; 76 return ""; 77 } 78 79 TSQLRow *row = res->Next(); 80 81 TString ret = row ? (*row)[0] : ""; 82 83 delete res; 84 85 return ret; 86 } 87 88 int checkfileavail(TString sequencefile) 89 { 90 TEnv env("sql.rc"); 91 92 MSQLServer serv(env); 59 MSQLServer serv("sql.rc"); 93 60 if (!serv.IsConnected()) 94 61 { … … 96 63 return 0; 97 64 } 65 98 66 cout << "checkfileavail" << endl; 99 67 cout << "--------------" << endl; … … 101 69 cout << "Connected to " << serv.GetName() << endl; 102 70 cout << endl; 71 cout << "Sequence: " << num << endl; 72 cout << "Telecope: " << tel << endl; 73 cout << endl; 103 74 104 TEnv rc("steps.rc");75 // ------------------------------------------- 105 76 106 //reading runnumbers from Sequencefile 107 TEnv sequ(sequencefile); 108 cout << "sequ file: " << sequencefile.Data() << endl; 109 TString runs; 110 runs = sequ.GetValue("Runs", ""); 111 runs.ReplaceAll(" ", ","); 112 if (runs.IsNull()) 113 { 114 cout << "ERROR - No runs in file " << sequencefile << " found." << endl; 115 return 0; 116 } 117 118 //getting runnumbers from database 119 //(not neccessary anymore -> can be changed) 120 TString query="SELECT fRunNumber FROM RunData WHERE fRunNumber in ("; 121 query +=runs.Data(); 122 query +=")"; 77 TString query = "MIN( NOT (" 78 "ISNULL(fRawFileAvail) OR " 79 "ISNULL(fCCFileAvail) OR " 80 "ISNULL(fCaCoFileAvail) OR " 81 "ISNULL(fCaCoFileFound) OR " 82 "ISNULL(fTimingCorrection) OR " 83 "ISNULL(fCompmux) " 84 ")) " 85 "FROM RunProcessStatus " 86 "LEFT JOIN RunData USING (fTelescopeNumber,fRunNumber,fFileNumber) " 87 query += Form("WHERE fSequenceFirst=%d AND fTelescopeNumber=%d", num, tel); 123 88 124 89 TSQLResult *res = serv.Query(query); 125 90 if (!res) 126 cout << "Error - no run to check" << endl;91 return 3; 127 92 128 //check for each run the availability of files from the table RunProcessStatus 129 //the following columns have to be checked: 130 //fCCFileAvail, fCaCoFileAvail, fCaCoFileFound, fRawFileAvail, fTimingCorrection, fCompmux 131 //fTimingCorrection has to be checked, as only rawfiles with correct timing should be calibrated 132 TSQLRow *row=0; 133 while ((row = res->Next())) 93 if (res->GetRowCount()!=1) 134 94 { 135 TString runno=(*row)[0]; 136 cout << "run#: " << runno << endl; 137 //if one value returns "" (i.e. column is NULL), 0 is returned 138 if (GetStatus(serv, rc, runno, "RunProcessStatus", "fCCFileAvail").IsNull() 139 || GetStatus(serv, rc, runno, "RunProcessStatus", "fCaCoFileAvail").IsNull() 140 || GetStatus(serv, rc, runno, "RunProcessStatus", "fCaCoFileFound").IsNull() 141 || GetStatus(serv, rc, runno, "RunProcessStatus", "fTimingCorrection").IsNull() 142 || GetStatus(serv, rc, runno, "RunProcessStatus", "fCompmux").IsNull() 143 // || GetStatus(serv, rc, runno, "RunProcessStatus", "fTimingCorrection")=="1970-01-01 00:00:00" 144 || GetStatus(serv, rc, runno, "RunProcessStatus", "fRawFileAvail").IsNull()) 145 return 2; 95 cout << "ERROR - Unexpected number of returned rows (" << res->GetRowCount() << ")" << endl; 96 delete res; 97 return 3; 146 98 } 147 //if all values are okay (i.e. files are availabel), 1 is returned148 return 1;149 99 100 TSQlRow *row = res->Next(); 101 102 if (!row || !(*row)[0]) 103 { 104 cout << "ERROR - Unexpected result." << endl; 105 delete res; 106 return 3; 107 } 108 109 const Int_t rc = atoi((*row)[0]); 110 111 delete res; 112 113 return rc==1 ? 1 : 2; 150 114 } 151 -
trunk/MagicSoft/Mars/datacenter/macros/checkstardone.C
r7859 r9018 18 18 ! Author(s): Daniela Dorner, 05/2005 <mailto:dorner@astro.uni-wuerzburg.de> 19 19 ! 20 ! Copyright: MAGIC Software Development, 2000-200 620 ! Copyright: MAGIC Software Development, 2000-2008 21 21 ! 22 22 ! … … 28 28 // =============== 29 29 // 30 // check the availability of the star files for one sequence:30 // check the availability of all star files for one dataset: 31 31 // if star has been executed successfully, this information has been inserted 32 32 // into the database (SequenceProcessStatus) with this macro this information … … 34 34 // 35 35 // executing the macro: 36 // .x checkstardone.C+( "sequencenumber")36 // .x checkstardone.C+(1) 37 37 // 38 // the macro returns 0, if there's no connection to the database, 2, if a39 // file is missing, and 1 if all files are there38 // The macro returns 0, if there's no connection to the database, 2 if 39 // star is not done, and 1 if star done, 3 in case of error. 40 40 // the return value is checked by the script, that executes the macro 41 41 // 42 // this macro is very similar to the macro checkfileavail.C42 // This macro is very similar to the macro checkfileavail.C 43 43 // 44 44 ///////////////////////////////////////////////////////////////////////////// 45 46 45 #include <iostream> 47 46 #include <iomanip> 48 #include <fstream>49 47 50 #include <TEnv.h>51 52 #include <MSQLServer.h>53 48 #include <TSQLRow.h> 54 49 #include <TSQLResult.h> 55 50 51 #include "MSQLServer.h" 52 56 53 using namespace std; 57 54 58 59 //check the value of a column for a sequence 60 TString GetStatus(MSQLServer &serv, TEnv &env, TString primary, TString table, TString column) 55 int checkstardone(Int_t num) 61 56 { 62 TString query(Form("SELECT %s FROM %s WHERE %s=%s", 63 column.Data(), table.Data(), 64 env.GetValue(table+".Primary", ""), 65 primary.Data())); 66 67 cout << "Query: " << query << endl; 68 69 TSQLResult *res = serv.Query(query); 70 if (!res) 71 { 72 cout << "Error - no sequence to check" << endl; 73 return ""; 74 } 75 76 TSQLRow *row = res->Next(); 77 78 TString rc = row ? (*row)[0] : ""; 79 80 delete res; 81 82 return rc; 83 } 84 85 int checkstardone(TString datasetno) 86 { 87 TEnv env("sql.rc"); 88 89 MSQLServer serv(env); 57 MSQLServer serv("sql.rc"); 90 58 if (!serv.IsConnected()) 91 59 { … … 93 61 return 0; 94 62 } 63 95 64 cout << "checkstardone" << endl; 96 65 cout << "-------------" << endl; … … 98 67 cout << "Connected to " << serv.GetName() << endl; 99 68 cout << endl; 69 cout << "Dataset: " << num << endl; 70 cout << endl; 100 71 101 TEnv rc("steps.rc");72 // ------------------------------------------- 102 73 103 //check if fStar not NULL for sequence104 if (GetStatus(serv, rc, datasetno, "SequenceProcessStatus", "fStar").IsNull())105 return 2;74 TString query = "NOT ISNULL(fStar) FROM SequenceProcessStatus " 75 "LEFT JOIN DataSetSequenceMapping USING (fTelescopeNumber,fSequenceFirst) "; 76 query += Form("WHERE fDataSetNumber=%d", num); 106 77 107 return 1; 78 TSQLResult *res = serv.Query(query); 79 if (!res) 80 return 3; 81 82 if (res->GetRowCount()!=1) 83 { 84 cout << "ERROR - Unexpected number of returned rows (" << res->GetRowCount() << ")" << endl; 85 delete res; 86 return 3; 87 } 88 89 TSQlRow *row = res->Next(); 90 91 if (!row || !(*row)[0]) 92 { 93 cout << "ERROR - Unexpected result." << endl; 94 delete res; 95 return 3; 96 } 97 98 const Int_t rc = atoi((*row)[0]); 99 100 delete res; 101 102 return rc==1 ? 1 : 2; 108 103 } 109 -
trunk/MagicSoft/Mars/datacenter/scripts/checkstardone
r8482 r9018 20 20 # Author(s): Daniela Dorner 08/2004 <mailto:dorner@astro.uni-wuerzburg.de> 21 21 # 22 # Copyright: MAGIC Software Development, 2000-200 722 # Copyright: MAGIC Software Development, 2000-2008 23 23 # 24 24 # … … 35 35 # the function setstatus. 36 36 # 37 38 37 source `dirname $0`/sourcefile 39 38 printprocesslog "INFO starting $0" … … 64 63 for dataset in ${datasets[@]} 65 64 do 66 echo "checking files for dataset $dataset..." >> $scriptlog 2>&1 67 printprocesslog "INFO checking files for dataset $dataset" 65 echo "checking star done for sequences of dataset $dataset..." >> $scriptlog 2>&1 66 printprocesslog "INFO checking star done for sequences of dataset $dataset" 67 68 68 no=`printf %08d $dataset | cut -c 0-5` 69 69 no2=`printf %08d $dataset` 70 datasetfile=$datasetpath/$no/dataset`printf %08d $dataset`.txt 71 72 sequences=(`cat $datasetfile | grep Sequences | sed -e 's/SequencesOn://g' | sed -e 's/SequencesOff://g'`) 73 if [ "$sequences" = "" ] 74 then 75 echo "no sequences found" >> $scriptlog 2>&1 76 echo "continue with next dataset" >> $scriptlog 2>&1 77 continue 78 fi 79 echo "sequences: "${sequences[@]} >> $scriptlog 2>&1 80 70 dsnum=`printf %08d $dataset` 71 72 echo "run $program for sequence $sequence..." >> $scriptlog 2>&1 73 81 74 outpath=$logpath/$program/$no/$no2 82 75 makedir $outpath >> $scriptlog 2>&1 83 76 84 77 primvar=$dataset 85 78 setstatus "start" >> $scriptlog 2>&1 86 79 87 for sequence in ${sequences[@]} 88 do 89 echo "run $program for sequence $sequence..." >> $scriptlog 2>&1 90 printprocesslog "INFO check availability for sequence $sequence" 80 check1=`root -q -b $macrospath/checkstardone.C+\(\""$dsnum\""\) | tee $outpath/checkstardone-$dsnum.log | intgrep` 91 81 92 check1=`root -q -b $macrospath/checkstardone.C+\(\""$sequence\""\) | tee $outpath/checkstardone-$sequence.log | intgrep` 82 case $check1 in 83 1) echo " check1=$check1 -> everything ok -> continue with next dataset..." >> $scriptlog 2>&1 ;; 84 2) echo " check1=$check1 -> star files for dataset $dsnum not yet available -> continue..." >> $scriptlog 2>&1 85 printprocesslog "INFO files not yet available for dataset $dsnum" 86 check="no" 87 break 88 ;; 89 0) echo " check1=$check1 -> no connection to db -> continue..." >> $scriptlog 2>&1 90 printprocesslog "WARN connection to DB failed" 91 check="no" 92 break 93 ;; 94 *) echo " check1=$check1 -> ERROR " >> $scriptlog 2>&1 95 printprocesslog "ERROR checkstardone.C failed" 96 com=$Fstardone 97 comadd=$sequence 98 check=$check1 99 break 100 ;; 101 esac 93 102 94 case $check1 in95 1) echo " check1=$check1 -> everything ok -> continue with next sequence..." >> $scriptlog 2>&1 ;;96 2) echo " check1=$check1 -> files for sequence $sequence not yet available -> continue..." >> $scriptlog 2>&197 printprocesslog "INFO files not yet available for sequence $sequence"98 check="no"99 break100 ;;101 0) echo " check1=$check1 -> no connection to db -> continue..." >> $scriptlog 2>&1102 printprocesslog "WARN connection to DB failed"103 check="no"104 break105 ;;106 *) echo " check1=$check1 -> ERROR " >> $scriptlog 2>&1107 printprocesslog "ERROR $program.C failed"108 com=$Fstardone109 comadd=$sequence110 check=$check1111 break112 ;;113 esac114 done115 116 103 setstatus "stop" >> $scriptlog 2>&1 117 104 done 118 105 119 106 finish >> $scriptlog 2>&1 120 -
trunk/MagicSoft/Mars/merpp.cc
r9005 r9018 1 #include <TFile.h> 2 #include <TTree.h> 3 4 #include "MParList.h" 5 #include "MTaskList.h" 6 #include "MEvtLoop.h" 7 8 #include "MRawFileRead.h" 9 #include "MReportFileReadCC.h" 10 #include "MWriteRootFile.h" 1 #include <TObjectTable.h> 2 3 #include "MArgs.h" 4 #include "MArray.h" 11 5 12 6 #include "MLog.h" 13 7 #include "MLogManip.h" 14 8 15 #include "MArgs.h" 16 #include "MTime.h" 17 #include "MArray.h" 18 #include "MRawRunHeader.h" 19 20 #include "MFDataPhrase.h" 9 #include "MJMerpp.h" 21 10 22 11 using namespace std; … … 57 46 gLog << all << endl; 58 47 gLog << "Sorry the usage is:" << endl; 59 gLog << " merpp [options] inputfile[.rep,[.raw.gz],[.txt]] [outputfile[.root]]" << endl << endl; 48 gLog << " merpp [options] [tel:]seqnumber [outpath [inpath]]" << endl; 49 gLog << " merpp [options] [tel:]seqnumber outpath sumfile.txt" << endl; 50 gLog << " merpp [options] seqfile.txt [outpath [inpath]]" << endl; 51 gLog << " merpp [options] seqfile.txt outpath sumfile.txt" << endl; 52 // gLog << " merpp [options] mysql [outpath [inpath]]" << endl; 53 // gLog << " merpp [options] mysql outpath sumfile.txt" << endl; 54 gLog << " merpp [options] infile.raw.[gz] [outfile.root]" << endl; 55 gLog << " merpp [options] infile.rep [outfile.root]" << endl; 56 gLog << " merpp [options] infile.txt outfile.root" << endl; 57 gLog << endl; 60 58 gLog << " Arguments:" << endl; 61 gLog << " inputfile.raw[.gz] Magic DAQ binary file." << endl; 62 gLog << " inputfile.rep Magic Central Control report file." << endl; 63 gLog << " inputfile.txt Magic DC currents file." << endl; 64 gLog << " ouputfile.root Merpped root file." << endl << endl; 59 gLog << " [tel:]seqnumber Telescope and sequence number to mbe merpped." << endl; 60 gLog << " inpath The input files whether the CC files are." << endl; 61 gLog << " outpath The output path where the outputfile are or stored." << endl; 62 gLog << " sumfile.txt A central control report summary file (--summary can be omitted)." << endl; 63 gLog << " infile.raw[.gz] Magic DAQ binary file." << endl; 64 gLog << " infile.rep Magic Central Control report file." << endl; 65 gLog << " infile.txt Magic DC currents file." << endl; 66 gLog << " outfile.root Merpped root file." << endl; 67 // gLog << " mysql mysql://user:password@host/database/tel:sequence" << endl; 68 gLog << endl; 65 69 gLog << " Options:" << endl; 66 70 gLog.Usage(); 67 gLog << " --version, -V Show startup message with version number" << endl; 68 gLog << " -?, -h, --help This help" << endl << endl; 71 // gLog << " --debug-env=0 Disable debugging setting resources <default>" << endl; 72 // gLog << " --debug-env[=1] Display untouched resources after program execution" << endl; 73 // gLog << " --debug-env=2 Display untouched resources after eventloop setup" << endl; 74 // gLog << " --debug-env=3 Debug setting resources from resource file and command line" << endl; 75 gLog << " --debug-mem Debug memory usage" << endl << endl; 76 gLog << endl; 69 77 gLog << " File Options:" << endl; 70 78 gLog << " -c# Compression level #=1..9 [default=2]" << endl; 71 79 gLog << " -f Force overwrite of an existing file" << endl; 72 80 gLog << " -u, --update Update an existing file." << endl; 73 gLog << " --only=Name Read only reports described by MReportName. See the" << endl; 74 gLog << " mreport-directory for available classes." << endl << endl; 81 gLog << endl; 75 82 gLog << " Raw Data Options:" << endl; 76 83 gLog << " -ff Force merpp to ignore broken events and don't stop" << endl; 77 gLog << " --interleave=# Process only each i-th event [default=1]" << endl << endl;78 // gLog << " --sql=mysql://user:password@url Insert run into database" << endl<< endl;79 gLog << " Report File Options:" << endl;84 gLog << " --interleave=# Process only each i-th event [default=1]" << endl; 85 gLog << endl; 86 gLog << " Report/Currents File Options:" << endl; 80 87 gLog << " --auto-time-start Take time automatically from MRawRunHeader" << endl; 81 gLog << " (overwrites --start= )" << endl;88 gLog << " (overwrites --start=, update only)" << endl; 82 89 gLog << " --auto-time-stop Take time automatically from MRawRunHeader" << endl; 83 gLog << " (overwrites --stop= )" << endl;90 gLog << " (overwrites --stop=, update only)" << endl; 84 91 gLog << " --auto-time Abbrev. for --auto-time-start and auto-time-stop" << endl; 85 gLog << " --start=date/time Start event time" << endl; 86 gLog << " --stop=date/time Stop event time" << endl; 92 gLog << " --start=\"time\" Start event time (format see MTime::SetSqlDateTime, update only)" << endl; 93 gLog << " --stop=\"time\" Stop event time (format see MTime::SetSqlDateTime, update only)" << endl; 94 gLog << endl; 95 gLog << " Report Options:" << endl; 87 96 gLog << " --rep-run=# Only data corresponding to this run number as" << endl; 88 97 gLog << " taken from the RUN-REPORT is extracted" << endl; … … 98 107 gLog << " (from .rep header)" << endl; 99 108 gLog << " --allfiles Don't check file type <default>" << endl << endl; 109 gLog << " --only=Name Read only reports described by MReportName. See the" << endl; 110 gLog << " mreport-directory for available classes." << endl; 111 gLog << endl; 112 gLog << " --version, -V Show startup message with version number" << endl; 113 gLog << " -?, -h, --help This help" << endl; 114 gLog << endl; 100 115 gLog << " Compatibility (deprecated):" << endl; 101 116 gLog << " --run=# See --rep-run (overwritten by --rep-run)" << endl; … … 105 120 } 106 121 107 // FIXME: Move to MTime (maybe 'InterpreteCmdline') 108 MTime AnalyseTime(TString str) 109 { 110 Int_t y=0, ms=0, mon=0, d=0, h=0, m=0, s=0; 111 112 const Int_t n = sscanf(str.Data(), "%d-%d-%d/%d:%d:%d.%d", &y, &mon, &d, &h, &m, &s, &ms); 113 114 if (n<6 || n>7) 115 { 116 gLog << warn << "'" << str << "' no valid Time... ignored." << endl; 117 return MTime(); 118 } 119 120 MTime t; 121 t.Set(y, mon, d, h, m, s, ms); 122 return t; 123 } 124 125 void GetTimeFromFile(const char *fname, MTime *start, MTime *stop) 126 { 127 TFile f(fname, "READ"); 128 129 TTree *t = (TTree*)f.Get("RunHeaders"); 130 if (t->GetEntries()!=1) 131 { 132 gLog << warn << "WARNING - File " << fname << " contains no or more than one entry in RunHeaders... Times unchanged." << endl; 133 return; 134 } 135 136 MRawRunHeader *h = 0; 137 t->SetBranchAddress("MRawRunHeader.", &h); 138 t->GetEntry(0); 139 if (!h) 140 { 141 gLog << warn << "WARNING - File " << fname << " did not contain RunHeaders.MRawRunHeader... Times unchanged." << endl; 142 return; 143 } 144 145 if (start && !*start) 146 *start = h->GetRunStart(); 147 if (stop && !*stop) 148 *stop = h->GetRunEnd(); 149 } 150 151 void Add(MReportFileReadCC *r, const TString &rep, const TString &only) 152 { 153 if (!only.IsNull() && rep!=only) 154 return; 155 156 r->AddToList(Form("MReport%s", rep.Data())); 122 static bool HasExtension(const TString &name) 123 { 124 return 125 name.EndsWith(".rep") || name.EndsWith(".txt") || 126 name.EndsWith(".raw") || name.EndsWith(".raw.gz"); 157 127 } 158 128 … … 181 151 } 182 152 153 const Bool_t kDebugMem = arg.HasOnlyAndRemove("--debug-mem"); 183 154 const Int_t kComprlvl = arg.GetIntAndRemove("-c", 2); 184 155 const Bool_t kInterleave = arg.GetIntAndRemove("--interleave=", 1); 185 const Bool_t k Force= arg.HasOnlyAndRemove("-f");156 const Bool_t kOverwrite = arg.HasOnlyAndRemove("-f"); 186 157 const Bool_t kForceProc = arg.HasOnlyAndRemove("-ff"); 187 158 const Int_t run = arg.GetIntAndRemove("--run=", -1); … … 196 167 const Int_t kTelescope = arg.GetIntAndRemove("--telescope=", -1); 197 168 Bool_t kUpdate = arg.HasOnlyAndRemove("--update") || arg.HasOnlyAndRemove("-u"); 198 const TString kOnly = arg.GetStringAndRemove("--only=", ""); 199 200 MTime kTimeStart; 201 MTime kTimeStop; 202 if (arg.HasOption("--star=")) 203 kTimeStart = AnalyseTime(arg.GetStringAndRemove("--start=")); 204 if (arg.HasOption("--stop=")) 205 kTimeStop = AnalyseTime(arg.GetStringAndRemove("--stop=")); 206 207 // const TString kSqlDataBase(arg.GetStringAndRemove("--sql=")); 169 const TString kOnly = arg.GetStringAndRemove("--only", ""); 170 const Bool_t kNullOut = arg.HasOnlyAndRemove("--dev-null"); 171 172 // Int_t kDebugEnv = arg.HasOnlyAndRemove("--debug-env") ? 1 : 0; 173 // kDebugEnv = arg.GetIntAndRemove("--debug-env=", kDebugEnv); 174 175 MTime kTimeStart(arg.GetStringAndRemove("--start=")); 176 MTime kTimeStop(arg.GetStringAndRemove("--stop=")); 208 177 209 178 if (arg.HasOnlyAndRemove("--sumfile")) … … 221 190 // check for the right usage of the program 222 191 // 223 if (arg.GetNumArguments()<1 || arg.GetNumArguments()> 2)192 if (arg.GetNumArguments()<1 || arg.GetNumArguments()>3) 224 193 { 225 194 Usage(); … … 230 199 // This is to make argv[i] more readable insidethe code 231 200 // 232 TString kNamein = arg.GetArgumentStr(0); 233 TString kNameout = arg.GetArgumentStr(1); 234 235 const Bool_t isreport = kNamein.EndsWith(".rep"); 236 const Bool_t isdc = kNamein.EndsWith(".txt"); 237 const Bool_t israw = !isreport && !isdc; 238 239 if (!kNamein.EndsWith(".raw") && !kNamein.EndsWith(".raw.gz") && israw) 240 kNamein += ".raw.gz"; 241 242 if (kNameout.IsNull()) 243 kNameout = kNamein(0, kNamein.Last('.')); 244 245 if (!kNameout.EndsWith(".root")) 246 kNameout += ".root"; 247 248 // if (!kSqlDataBase.IsNull() && !israw) 249 // gLog << warn << "WARNING - Option '--sql=' only valid for raw-files... ignored." << endl; 201 const Int_t narg = arg.GetNumArguments(); 202 203 const TString arg0 = arg.GetArgumentStr(0); 204 const TString arg1 = arg.GetArgumentStr(1); 205 const TString arg2 = arg.GetArgumentStr(2); 206 207 const Bool_t isseq = 208 (narg==1 && !(HasExtension(arg0) && !arg0.EndsWith(".txt"))) || 209 (narg==2 && !HasExtension(arg1)) || 210 (narg==3); 211 212 TString sequence, kNamein, kNameout; 213 if (isseq) 214 { 215 sequence = arg0; 216 kNameout = arg1; 217 kNamein = arg2; 218 219 if (HasExtension(arg2)) // set --summary 220 kHeaderRun = 0; 221 222 kUpdate = kTRUE; 223 } 224 else 225 { 226 kNamein = arg0; 227 kNameout = arg1(0, kNamein.Last('.')); 228 if (!kNameout.EndsWith(".root")) 229 kNameout += ".root"; 230 } 250 231 251 232 // … … 253 234 // 254 235 gROOT->SetBatch(); 255 256 //257 // check whether the given files are OK.258 //259 if (gSystem->AccessPathName(kNamein, kFileExists))260 {261 gLog << err << "Sorry, the input file '" << kNamein << "' doesn't exist." << endl;262 return 2;263 }264 265 const Bool_t fileexist = !gSystem->AccessPathName(kNameout, kFileExists);266 const Bool_t writeperm = !gSystem->AccessPathName(kNameout, kWritePermission);267 268 if (fileexist && !writeperm)269 {270 gLog << err << "Sorry, you don't have write permission for '" << kNameout << "'." << endl;271 return 2;272 }273 274 if (fileexist && !kUpdate && !kForce)275 {276 gLog << err << "Sorry, file '" << kNameout << "' already existing." << endl;277 return 2;278 }279 280 if (!fileexist && kUpdate)281 {282 gLog << warn << "File '" << kNameout << "' doesn't yet exist." << endl;283 kUpdate=kFALSE;284 }285 286 //287 // Evaluate possible start-/stop-time288 //289 if ((kAutoTimeStart || kAutoTimeStop) && kUpdate && (isreport || isdc))290 GetTimeFromFile(kNameout, kAutoTimeStart?&kTimeStart:0, kAutoTimeStop?&kTimeStop:0);291 292 if (kTimeStart)293 gLog << inf << "Start Time: " << kTimeStart << endl;294 if (kTimeStop)295 gLog << inf << "Stop Time: " << kTimeStop << endl;296 236 297 237 // … … 301 241 MParContainer::Class()->IgnoreTObjectStreamer(); 302 242 303 // 304 // create a (empty) list of parameters which can be used by the tasks 305 // and an (empty) list of tasks which should be executed 306 // 307 MParList plist; 308 309 MTaskList tasks; 310 tasks.SetOwner(); 311 plist.AddToList(&tasks); 312 313 // 314 // ---- The following is only necessary to supress some output ---- 315 /* 316 MRawRunHeader runheader; 317 plist.AddToList(&runheader); 318 319 MRawEvtHeader evtheader; 320 plist.AddToList(&evtheader); 321 322 MRawEvtData evtdata; 323 plist.AddToList(&evtdata); 324 325 MRawCrateArray cratearray; 326 plist.AddToList(&cratearray); 327 328 MTime evttime; 329 plist.AddToList(&evttime); 330 */ 331 332 // 333 // create the tasks which should be executed and add them to the list 334 // in the case you don't need parameter containers, all of them can 335 // be created by MRawFileRead::PreProcess 336 // 337 const TString option(kUpdate ? "UPDATE" : "RECREATE"); 338 339 MTask *read = 0; 340 MFilter *filter = 0; 341 MWriteRootFile *write = new MWriteRootFile(kNameout, option, "Magic root-file", kComprlvl); 342 343 if (isreport || isdc) 344 { 345 if (isdc) 243 if (kDebugMem) 244 TObject::SetObjectStat(kTRUE); 245 246 { 247 MJMerpp merpp(Form("MJMerpp %s", arg0.Data())); 248 merpp.SetOverwrite(kOverwrite); 249 merpp.SetCompression(kComprlvl); 250 merpp.SetUpdate(kUpdate); 251 merpp.SetInterleave(kInterleave); 252 merpp.SetForceProcessing(kForceProc); 253 merpp.SetConstrainHeader(kTelescope, kHeaderRun, kHeaderFile); 254 merpp.SetConstrainRunRep(kRunNumber, kFileNumber); 255 merpp.SetOnly(kOnly); 256 merpp.SetTime(kTimeStart, kTimeStop); 257 merpp.SetAutoTime(kAutoTimeStart, kAutoTimeStop); 258 merpp.SetNullOut(kNullOut); 259 //merpp.SetEnvDebug(kDebugEnv); 260 //merpp.SetEnv(&env); 261 //merpp.SetDisplay(d);; 262 263 merpp.SetPathIn(kNamein); 264 merpp.SetPathOut(kNameout); 265 266 const Int_t rc = sequence.IsNull() ? merpp.Process() : merpp.ProcessSeq(sequence); 267 if (rc>0) 346 268 { 347 write->AddContainer("MTimeCurrents", "Currents"); 348 write->AddContainer("MCameraDC", "Currents"); 349 write->AddContainer("MReportCurrents", "Currents"); 269 gLog << err << "Merpp failed." << endl << endl; 270 return rc; 350 271 } 351 else 352 { 353 const Bool_t required = kOnly.IsNull(); 354 write->AddContainer("MReportCamera", "Camera", required); 355 write->AddContainer("MTimeCamera", "Camera", required); 356 write->AddContainer("MCameraAUX", "Camera", required); 357 write->AddContainer("MCameraCalibration", "Camera", required); 358 write->AddContainer("MCameraCooling", "Camera", required); 359 write->AddContainer("MCameraActiveLoad", "Camera", required); 360 write->AddContainer("MCameraHV", "Camera", required); 361 write->AddContainer("MCameraDC", "Camera", required); 362 write->AddContainer("MCameraLV", "Camera", required); 363 write->AddContainer("MCameraLids", "Camera", required); 364 write->AddContainer("MReportTrigger", "Trigger", required); 365 write->AddContainer("MTimeTrigger", "Trigger", required); 366 write->AddContainer("MTriggerBit", "Trigger", required); 367 write->AddContainer("MTriggerIPR", "Trigger", required); 368 write->AddContainer("MTriggerCell", "Trigger", required); 369 write->AddContainer("MTriggerPrescFact", "Trigger", required); 370 write->AddContainer("MTriggerLiveTime", "Trigger", required); 371 write->AddContainer("MReportDrive", "Drive", required); 372 write->AddContainer("MTimeDrive", "Drive", required); 373 write->AddContainer("MCameraTH", "Rec", required); 374 write->AddContainer("MCameraTD", "Rec", required); 375 write->AddContainer("MCameraRecTemp", "Rec", required); 376 write->AddContainer("MReportRec", "Rec", required); 377 write->AddContainer("MTimeRec", "Rec", required); 378 write->AddContainer("MReportCC", "CC", required); 379 write->AddContainer("MTimeCC", "CC", required); 380 write->AddContainer("MReportStarguider", "Starguider", required); 381 write->AddContainer("MTimeStarguider", "Starguider", required); 382 write->AddContainer("MReportPyrometer", "Pyrometer", required); 383 write->AddContainer("MTimePyrometer", "Pyrometer", required); 384 // write->AddContainer("MReportDAQ", "DAQ"); 385 // write->AddContainer("MTimeDAQ", "DAQ"); 386 } 387 388 MReportFileReadCC *r = new MReportFileReadCC(kNamein); 389 r->SetTimeStart(kTimeStart); 390 r->SetTimeStop(kTimeStop); 391 if (isdc) 392 { 393 r->SetHasNoHeader(); 394 r->AddToList("MReportCurrents"); 395 } 396 else 397 { 398 r->SetTelescope(kTelescope); 399 r->SetRunNumber(kHeaderRun); 400 r->SetFileNumber(kHeaderFile); 401 Add(r, "CC", kOnly); 402 Add(r, "Rec", kOnly); 403 Add(r, "Drive", kOnly); 404 Add(r, "Camera", kOnly); 405 Add(r, "Trigger", kOnly); 406 Add(r, "Starguider", kOnly); 407 Add(r, "Pyrometer", kOnly); 408 // Add(r, "DAQ", kUpdateOnly); 409 if (kRunNumber>0) 410 { 411 const TString f1 = kRunNumber>0 ? Form("MReportRun.fRunNumber==%d", kRunNumber) : ""; 412 const TString f2 = kFileNumber>0 ? Form("MReportRun.fFileNumber==%d", kFileNumber) : ""; 413 414 const TString f = Form(kRunNumber>0 && kFileNumber>0 ? "%s && %s" : "%s%s", 415 f1.Data(), f2.Data()); 416 417 r->AddToList("MReportRun"); 418 filter = new MFDataPhrase(f.Data()); 419 write->SetFilter(filter); 420 } 421 } 422 read = r; 423 } 424 else 425 { 426 read = new MRawFileRead(kNamein); 427 static_cast<MRawFileRead*>(read)->SetInterleave(kInterleave); 428 static_cast<MRawFileRead*>(read)->SetForceMode(kForceProc); 429 430 write->AddContainer("MRawRunHeader", "RunHeader"); 431 write->AddContainer("MTime", "Events"); 432 write->AddContainer("MRawEvtHeader", "Events"); 433 write->AddContainer("MRawEvtData", "Events"); 434 write->AddContainer("MRawEvtData2", "Events"); 435 write->AddContainer("MRawCrateArray", "Events"); 436 } 437 438 tasks.AddToList(read); 439 if (filter) 440 tasks.AddToList(filter); 441 /* 442 if (israw && !kSqlDataBase.IsNull()) 443 { 444 MSqlInsertRun *ins = new MSqlInsertRun(kSqlDataBase); 445 ins->SetUpdate(); 446 tasks.AddToList(ins); 447 }*/ 448 tasks.AddToList(write); 449 450 // 451 // create the looping object and tell it about the parameters to use 452 // and the tasks to execute 453 // 454 MEvtLoop magic; 455 magic.SetParList(&plist); 456 457 // 458 // Start the eventloop which reads the raw file (MRawFileRead) and 459 // write all the information into a root file (MRawFileWrite) 460 // 461 // between reading and writing we can do, transformations, checks, etc. 462 // (I'm think of a task like MRawDataCheck) 463 // 464 if (!magic.Eventloop()) 465 { 466 gLog << err << "ERROR: Merging and preprocessing failed!" << endl; 467 return 2; 468 } 469 470 tasks.PrintStatistics(); 471 472 gLog << all << "Merpp finished successfull!" << endl; 272 273 //if (kDebugEnv>0) 274 // env.PrintUntouched(); 275 } 276 277 if (TObject::GetObjectStat()) 278 { 279 TObject::SetObjectStat(kFALSE); 280 gObjectTable->Print(); 281 } 282 473 283 return 0; 474 284 } -
trunk/MagicSoft/Mars/mjobs/JobsLinkDef.h
r8996 r9018 19 19 #pragma link C++ class MJCut+; 20 20 #pragma link C++ class MJSpectrum+; 21 #pragma link C++ class MJMerpp+; 21 22 22 23 #endif -
trunk/MagicSoft/Mars/mjobs/Makefile
r8996 r9018 24 24 -I../mtools -I../mimage -I../mpointing -I../mastro -I../mfbase \ 25 25 -I../mhvstime -I../mtrigger -I../mmuon -I../mmc -I../mmovie \ 26 -I../mextralgo -I../mhflux -I../msql 26 -I../mextralgo -I../mhflux -I../msql -I../mreport 27 27 28 28 SRCFILES = MSequence.cc \ … … 36 36 MJStar.cc \ 37 37 MJCut.cc \ 38 MJSpectrum.cc 38 MJSpectrum.cc \ 39 MJMerpp.cc 39 40 40 41 ############################################################
Note:
See TracChangeset
for help on using the changeset viewer.