Changeset 4740
- Timestamp:
- 08/26/04 13:58:11 (20 years ago)
- Location:
- trunk/MagicSoft/Mars
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/Changelog
r4738 r4740 41 41 - added GetMinPixId 42 42 - added GetMaxPixId 43 44 * merpp.cc: 45 - added a new option --auto-time to get the time range for 46 cc and/or caco data from the run header of the raw data 43 47 44 48 -
trunk/MagicSoft/Mars/NEWS
r4738 r4740 40 40 - implemented support for pixels with negative IDs (Raw file format 41 41 version 4) 42 43 - implemented an new option in merpp (--auto-time) to get the time 44 range for cc and/or caco data from the run header of the raw data 42 45 43 46 -
trunk/MagicSoft/Mars/merpp.cc
r4723 r4740 1 1 #include <TSystem.h> 2 3 #include <TFile.h> 4 #include <TTree.h> 2 5 3 6 #include "MParList.h" … … 79 82 // gLog << " --sql=mysql://user:password@url Insert run into database" << endl << endl; 80 83 gLog << " Report File Options:" << endl; 84 gLog << " --auto-time Take time automatically from MRawRunHeader" << endl; 85 gLog << " (overwrites --start= and/or --stop=)" << endl; 81 86 gLog << " --start=date/time Start event time" << endl; 82 87 gLog << " --stop=date/time Stop event time" << endl; … … 110 115 } 111 116 117 void GetTimeFromFile(const char *fname, MTime &start, MTime &stop) 118 { 119 TFile f(fname, "READ"); 120 121 TTree *t = (TTree*)f.Get("RunHeaders"); 122 if (t->GetEntries()!=1) 123 { 124 gLog << warn << "WARNING - File " << fname << " contains no or more than one entry in RunHeaders... Times unchanged." << endl; 125 return; 126 } 127 128 MRawRunHeader *h = 0; 129 t->SetBranchAddress("MRawRunHeader.", &h); 130 t->GetEntry(0); 131 if (!h) 132 { 133 gLog << warn << "WARNING - File " << fname << " did not contain RunHeaders.MRawRunHeader... Times unchanged." << endl; 134 return; 135 } 136 137 if (!start) 138 start = h->GetRunStart(); 139 if (!stop) 140 stop = h->GetRunEnd(); 141 } 142 112 143 int main(const int argc, char **argv) 113 144 { … … 132 163 const Bool_t kForceProc = arg.HasOnlyAndRemove("-ff"); 133 164 const Int_t kRunNumber = arg.GetIntAndRemove("--run=", -1); 165 const Bool_t kAutoTime = arg.HasOnlyAndRemove("--auto-time"); 134 166 Int_t kRunFile = arg.GetIntAndRemove("--runfile=", -1); 135 167 Bool_t kUpdate = arg.HasOnlyAndRemove("--update") || arg.HasOnlyAndRemove("-u"); … … 147 179 kRunFile = 0; 148 180 181 if (arg.GetNumOptions()>0) 182 { 183 gLog << warn << "WARNING - Unknown commandline options..." << endl; 184 arg.Print("options"); 185 gLog << endl; 186 } 187 188 // 189 // check for the right usage of the program 190 // 191 if (arg.GetNumArguments()<1 || arg.GetNumArguments()>2) 192 { 193 Usage(); 194 return -1; 195 } 196 197 // 198 // This is to make argv[i] more readable insidethe code 199 // 200 TString kNamein = arg.GetArgumentStr(0); 201 TString kNameout = arg.GetArgumentStr(1); 202 203 const Bool_t isreport = kNamein.EndsWith(".rep"); 204 const Bool_t isdc = kNamein.EndsWith(".txt"); 205 const Bool_t israw = !isreport && !isdc; 206 207 if (!kNamein.EndsWith(".raw") && israw) 208 kNamein += ".raw"; 209 210 if (kNameout.IsNull()) 211 kNameout = kNamein(0, kNamein.Last('.')); 212 213 if (!kNameout.EndsWith(".root")) 214 kNameout += ".root"; 215 216 // if (!kSqlDataBase.IsNull() && !israw) 217 // gLog << warn << "WARNING - Option '--sql=' only valid for raw-files... ignored." << endl; 218 219 // 220 // Initialize Non-GUI (batch) mode 221 // 222 gROOT->SetBatch(); 223 224 // 225 // check whether the given files are OK. 226 // 227 if (gSystem->AccessPathName(kNamein, kFileExists)) 228 { 229 gLog << err << "Sorry, the input file '" << kNamein << "' doesn't exist." << endl; 230 return -1; 231 } 232 233 const Bool_t fileexist = !gSystem->AccessPathName(kNameout, kFileExists); 234 const Bool_t writeperm = !gSystem->AccessPathName(kNameout, kWritePermission); 235 236 if (fileexist && !writeperm) 237 { 238 gLog << err << "Sorry, you don't have write permission for '" << kNameout << "'." << endl; 239 return -1; 240 } 241 242 if (fileexist && !kUpdate && !kForce) 243 { 244 gLog << err << "Sorry, file '" << kNameout << "' already existing." << endl; 245 return -1; 246 } 247 248 if (!fileexist && kUpdate) 249 { 250 gLog << warn << "File '" << kNameout << "' doesn't yet exist." << endl; 251 kUpdate=kFALSE; 252 } 253 254 // 255 // Evaluate possible start-/stop-time 256 // 257 if (kAutoTime && kUpdate && (isreport || isdc)) 258 GetTimeFromFile(kNameout, kTimeStart, kTimeStop); 259 149 260 if (kTimeStart) 150 261 gLog << inf << "Start Time: " << kTimeStart << endl; … … 152 263 gLog << inf << "Stop Time: " << kTimeStop << endl; 153 264 154 if (arg.GetNumOptions()>0) 155 { 156 gLog << warn << "WARNING - Unknown commandline options..." << endl; 157 arg.Print("options"); 158 gLog << endl; 159 } 160 161 // 162 // check for the right usage of the program 163 // 164 if (arg.GetNumArguments()<1 || arg.GetNumArguments()>2) 165 { 166 Usage(); 167 return -1; 168 } 169 170 // 171 // This is to make argv[i] more readable insidethe code 172 // 173 TString kNamein = arg.GetArgumentStr(0); 174 TString kNameout = arg.GetArgumentStr(1); 175 176 const Bool_t isreport = kNamein.EndsWith(".rep"); 177 const Bool_t isdc = kNamein.EndsWith(".txt"); 178 const Bool_t israw = !isreport && !isdc; 179 180 if (!kNamein.EndsWith(".raw") && israw) 181 kNamein += ".raw"; 182 183 if (kNameout.IsNull()) 184 kNameout = kNamein(0, kNamein.Last('.')); 185 186 if (!kNameout.EndsWith(".root")) 187 kNameout += ".root"; 188 189 // if (!kSqlDataBase.IsNull() && !israw) 190 // gLog << warn << "WARNING - Option '--sql=' only valid for raw-files... ignored." << endl; 191 192 // 193 // Initialize Non-GUI (batch) mode 194 // 195 gROOT->SetBatch(); 196 197 // 198 // check whether the given files are OK. 199 // 200 if (gSystem->AccessPathName(kNamein, kFileExists)) 201 { 202 gLog << err << "Sorry, the input file '" << kNamein << "' doesn't exist." << endl; 203 return -1; 204 } 205 206 const Bool_t fileexist = !gSystem->AccessPathName(kNameout, kFileExists); 207 const Bool_t writeperm = !gSystem->AccessPathName(kNameout, kWritePermission); 208 209 if (fileexist && !writeperm) 210 { 211 gLog << err << "Sorry, you don't have write permission for '" << kNameout << "'." << endl; 212 return -1; 213 } 214 215 if (fileexist && !kUpdate && !kForce) 216 { 217 gLog << err << "Sorry, file '" << kNameout << "' already existing." << endl; 218 return -1; 219 } 220 221 if (!fileexist && kUpdate) 222 { 223 gLog << warn << "File '" << kNameout << "' doesn't yet exist." << endl; 224 kUpdate=kFALSE; 225 } 226 265 // 266 // Ignore TObject Streamer (bits, uniqueid) for MArray and MParContainer 267 // 227 268 MArray::Class()->IgnoreTObjectStreamer(); 228 269 MParContainer::Class()->IgnoreTObjectStreamer();
Note:
See TracChangeset
for help on using the changeset viewer.