Changeset 4729
- Timestamp:
- 08/25/04 13:20:16 (20 years ago)
- Location:
- trunk/MagicSoft/Mars
- Files:
-
- 2 added
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/callisto.cc
r4724 r4729 53 53 gLog << endl; 54 54 gLog << " -f Force overwrite of existing files" << endl; 55 gLog << " --in =pathPath where to search for the data files" << endl;55 gLog << " --ind=path Path where to search for the data files" << endl; 56 56 gLog << " [default=standard path in datacenter]" << endl; 57 57 gLog << " --iny=path Path where to search for the calibration files" << endl; 58 58 gLog << " [default=local path or output path of Mode-C]" << endl; 59 gLog << " --out=path Path to write the all results to [def=local path]" << endl;60 59 gLog << " --outc=path Path to write Mode-C result to [def=local path]" << endl; 61 60 gLog << " --outy=path Path to write Mode-Y result to [def=local path]" << endl; 61 gLog << " --out=path Path to write the all results to [def=local path]" << endl; 62 gLog << " (overwrites --outc and --outy)" << endl; 63 gLog << " --path=path Path to write the all results to [def=local path]" << endl; 64 gLog << " (overwrites --iny, --outc and --outy)" << endl; 62 65 gLog << " --printseq Print Sequence information" << endl; 63 66 gLog << " --printfiles Print Files taken from Sequence" << endl; … … 70 73 gLog << " especially CheckEnv() for more details. Command line options might" << endl; 71 74 gLog << " be overwritten by the resource file." << endl << endl; 75 gLog << " If running in Mode-C and Mode-Y --iny= is obsolete, instead --outc=" << endl; 76 gLog << " is used." << endl << endl; 72 77 gLog << "Description:" << endl; 73 78 gLog << " callisto will calculate pedestals from pedestal-files defined in a" << endl; … … 97 102 98 103 const TString kConfig = arg.GetStringAndRemove("--config=", "callisto.rc"); 104 99 105 const Bool_t kPrintSeq = arg.HasOnlyAndRemove("--printseq"); 100 106 const Bool_t kPrintFiles = arg.HasOnlyAndRemove("--printfiles"); 101 107 const Bool_t kPrintOnly = arg.HasOnlyAndRemove("--printonly"); 108 102 109 const Bool_t kOverwrite = arg.HasOnlyAndRemove("-f"); 103 const TString kInpathY = arg.GetStringAndRemove("--iny=", ""); 104 TString kInpath = arg.GetStringAndRemove("--in=", ""); 105 const TString kOutpath = arg.GetStringAndRemove("--out=", ""); 106 TString kOutpathC = arg.GetStringAndRemove("--outc=", ""); 107 TString kOutpathY = arg.GetStringAndRemove("--outy=", ""); 110 111 const TString kInpathD = arg.GetStringAndRemove("--ind=", ""); 112 TString kInpathY = arg.GetStringAndRemove("--iny=", "."); 113 TString kOutpathY = arg.GetStringAndRemove("--outy=", "."); 114 TString kOutpathC = arg.GetStringAndRemove("--outc=", "."); 115 const TString kOutpath = arg.GetStringAndRemove("--out=", ""); 116 const TString kPath = arg.GetStringAndRemove("--path=", ""); 108 117 109 118 const Bool_t kModeC = arg.HasOnlyAndRemove("-c"); … … 115 124 return 0; 116 125 } 117 118 126 if (!kOutpath.IsNull()) 119 127 { 120 if (!kOutpathC.IsNull() || !kOutpathY.IsNull()) 121 { 122 gLog << err << "You cannot use --out= and --outc= or --outy= together!" << endl; 123 return 0; 124 } 125 if (kOutpathC.IsNull()) 126 kOutpathC = kOutpath; 127 if (kOutpathY.IsNull()) 128 kOutpathY = kOutpath; 129 } 128 kOutpathC = kOutpath; 129 kOutpathY = kOutpath; 130 } 131 if (!kPath.IsNull()) 132 { 133 kOutpathC = kOutpath; 134 kOutpathY = kOutpath; 135 kInpathY = kOutpath; 136 } 137 138 if (kModeC && kModeY) 139 kInpathY = kOutpathC; 140 130 141 if (arg.GetNumOptions()>0) 131 142 { … … 169 180 if (kPrintFiles) 170 181 { 171 MDirIter Next1, Next2; 172 seq.SetupPedRuns(Next1, kInpath); 173 seq.SetupDatRuns(Next2, kInpath); 182 MDirIter Next1, Next2, Next3; 183 seq.SetupPedRuns(Next1, kInpathD); 184 seq.SetupCalRuns(Next2, kInpathD); 185 seq.SetupDatRuns(Next3, kInpathD); 174 186 175 187 gLog << all; … … 177 189 Next1.Print("all"); 178 190 gLog << endl; 191 gLog.Separator("Calibration Files"); 192 Next2.Print("all"); 193 gLog << endl; 179 194 gLog.Separator("Data Files"); 180 Next 2.Print("all");195 Next3.Print("all"); 181 196 gLog << endl; 182 197 } … … 199 214 if (kModeC) 200 215 { 201 MJPedestal job1(Form("MJPedestal #%d", seq.GetSequence()));202 job1.SetSequence( &seq);216 MJPedestal job1(Form("MJPedestalC #%d", seq.GetSequence())); 217 job1.SetSequence(seq); 203 218 job1.SetEnv(kConfig); 204 219 job1.SetDisplay(d);; 205 job1.SetInputPath(kInpath);206 job1.SetOutputPath(kOutpathC);207 220 job1.SetOverwrite(kOverwrite); 221 job1.SetPathData(kInpathD); 222 // job1.SetPathOut(kOutpathC); // not yet needed 223 // job1.SetPathIn(kInpathC); // not yet needed 208 224 209 225 if (!job1.ProcessFile()) … … 220 236 221 237 MJCalibration job2(Form("MJCalibration #%d", seq.GetSequence())); 222 job2.SetSequence( &seq);238 job2.SetSequence(seq); 223 239 job2.SetEnv(kConfig); 224 240 job2.SetDisplay(d);; 225 241 job2.SetBadPixels(job1.GetBadPixels()); 226 job2.SetInputPath(kInpath);227 job2.SetOutputPath(kOutpathC);228 242 job2.SetOverwrite(kOverwrite); 243 job2.SetPathOut(kOutpathC); 244 job2.SetPathData(kInpathD); 245 // job2.SetPathIn(kInpathC); // not yet needed 229 246 230 247 if (!job2.ProcessFile(job1.GetPedestalCam())) … … 245 262 d->Reset(); 246 263 247 MJCalibrateSignal job(Form("MJCalibrateSignal #%d", seq.GetSequence())); 248 job.SetDisplay(d);; 249 job.SetInputPath(kInpath); // Where to search for data files 250 job.SetOutputPath(kOutpathY); 251 job.SetOverwrite(kOverwrite); 264 MJPedestal job1(Form("MJPedestalY #%d", seq.GetSequence())); 265 job1.SetSequence(seq); 266 job1.SetEnv(kConfig); 267 job1.SetDisplay(d);; 268 //job1.SetPathIn(kInpathY); // not yet needed 269 //job1.SetPathOut(kOutpathY); // not yet needed 270 job1.SetPathData(kInpathD); 271 job1.SetOverwrite(kOverwrite); 272 273 if (!job1.ProcessFile()) 274 { 275 gLog << err << "Calculation of pedestal failed." << endl << endl; 276 return -1; 277 } 278 279 if (!job1.GetDisplay()) 280 { 281 gLog << warn << "Display closed by user... execution aborted." << endl << endl; 282 return 1; 283 } 284 285 MJCalibrateSignal job2(Form("MJCalibrateSignal #%d", seq.GetSequence())); 286 job2.SetSequence(seq); 287 job2.SetDisplay(d);; 288 job2.SetEnv(kConfig); 289 job2.SetOverwrite(kOverwrite); 290 job2.SetPathIn(kInpathY); 291 job2.SetPathOut(kOutpathY); 292 job2.SetPathData(kInpathD); 293 252 294 // Where to search for calibration files 253 if (!job .ProcessFile(seq, kConfig, kModeC ? kOutpathC : kInpathY))295 if (!job2.ProcessFile(job1.GetPedestalCam())) 254 296 return -1; 255 297 256 if (!job .GetDisplay())298 if (!job2.GetDisplay()) 257 299 { 258 300 gLog << warn << "Display closed by user... execution aborted." << endl << endl; -
trunk/MagicSoft/Mars/mjobs/JobsLinkDef.h
r4723 r4729 5 5 #pragma link off all functions; 6 6 7 #pragma link C++ class MJob+; 7 8 #pragma link C++ class MSequence+; 8 9 -
trunk/MagicSoft/Mars/mjobs/MJCalibrateSignal.cc
r4723 r4729 43 43 #include "MLogManip.h" 44 44 45 #include "MSequence.h"46 45 #include "MDirIter.h" 47 46 #include "MParList.h" … … 83 82 // 84 83 MJCalibrateSignal::MJCalibrateSignal(const char *name, const char *title) 85 : fOverwrite(kFALSE), fMaxEvents(0)86 84 { 87 85 fName = name ? name : "MJCalibrateSignal"; … … 89 87 } 90 88 91 MJCalibrateSignal::~MJCalibrateSignal()89 Bool_t MJCalibrateSignal::WriteResult() 92 90 { 93 } 94 95 Bool_t MJCalibrateSignal::WriteResult(const MSequence &seq) 96 { 97 if (fOutputPath.IsNull()) 91 if (fPathOut.IsNull()) 92 { 93 *fLog << inf << "No output path specified via SetPathOut - no output written." << endl; 98 94 return kTRUE; 99 100 const TString oname = Form("%s/calped%06d.root", (const char*)fOutputPath, seq.GetSequence()); 95 } 96 97 const TString oname = Form("%s/calped%06d.root", (const char*)fPathOut, fSequence.GetSequence()); 101 98 102 99 *fLog << inf << "Writing to file: " << oname << endl; … … 115 112 } 116 113 117 void MJCalibrateSignal::SetOutputPath(const char *path) 118 { 119 fOutputPath = path; 120 if (fOutputPath.EndsWith("/")) 121 fOutputPath = fOutputPath(0, fOutputPath.Length()-1); 122 } 123 void MJCalibrateSignal::SetInputPath(const char *path) 124 { 125 fInputPath = path; 126 if (fInputPath.EndsWith("/")) 127 fInputPath = fInputPath(0, fInputPath.Length()-1); 128 } 129 130 void MJCalibrateSignal::CheckEnv(const char *env) 131 { 132 TEnv e(env); 133 134 TString e1 = e.GetValue("MJCalibrateSignal.OutputPath", ""); 135 if (!e1.IsNull()) 136 { 137 e1.ReplaceAll("\015", ""); 138 SetOutputPath(e1); 139 } 140 141 fMaxEvents = e.GetValue("MJCalibrateSignal.MaxEvents", fMaxEvents); 142 } 143 144 Bool_t MJCalibrateSignal::ReadCalibration(const MSequence &seq, const char *path, 145 MCalibrationCam &calcam, 114 Bool_t MJCalibrateSignal::ReadCalibration(MCalibrationCam &calcam, 146 115 MCalibrationCam &qecam, 147 116 MCalibrationCam &tmcam, 148 117 MBadPixelsCam &badpix, MTask* &ext1, MTask* &ext2) const 149 118 { 150 TString inpath(path); 151 if (inpath.EndsWith("/")) 152 inpath = inpath(0, inpath.Length()-1); 153 154 const TString fname = Form("%s/calib%06d.root", inpath.Data(), seq.GetSequence()); 119 const TString fname = Form("%s/calib%06d.root", fPathIn.Data(), fSequence.GetSequence()); 155 120 156 121 TFile file(fname, "READ"); … … 211 176 } 212 177 213 Bool_t MJCalibrateSignal::ProcessFile( const MSequence &seq, const char *env, const char *path)178 Bool_t MJCalibrateSignal::ProcessFile(MPedestalCam &pedcam) 214 179 { 180 if (!fSequence.IsValid()) 181 { 182 *fLog << err << "ERROR - Sequence invalid!" << endl; 183 return kFALSE; 184 } 185 186 //if (!CheckEnv()) 187 // return kFALSE; 188 189 CheckEnv(); 190 191 // -------------------------------------------------------------------------------- 192 215 193 *fLog << inf; 216 194 fLog->Separator(GetDescriptor()); 217 195 *fLog << "Calculate calibrated data from runs "; 218 *fLog << seq.GetName() << endl;196 *fLog << fSequence.GetName() << endl; 219 197 *fLog << endl; 220 198 221 CheckEnv(env);222 223 // -------------------------------------------------------------------------------224 225 MJPedestal job1;226 job1.SetSequence(&seq);227 job1.SetDisplay(fDisplay);;228 job1.SetEnv(env);229 230 if (!job1.ProcessFile())231 return kFALSE;232 233 199 // -------------------------------------------------------------------------------- 234 200 235 201 MDirIter iter; 236 if (seq.SetupDatRuns(iter, fInputPath)==0) 237 { 238 *fLog << err << "ERROR - No input files of sequence found!" << endl; 239 return kFALSE; 202 const Int_t n0 = fSequence.SetupDatRuns(iter, fPathData); 203 const Int_t n1 = fSequence.GetNumDatRuns(); 204 if (n0==0) 205 { 206 *fLog << err << "ERROR - No input files of sequence found!" << endl; 207 return kFALSE; 208 } 209 if (n0!=n1) 210 { 211 *fLog << err << "ERROR - Number of files found (" << n0 << ") doesn't match number of files in sequence (" << n1 << ")" << endl; 212 return kFALSE; 240 213 } 241 214 … … 249 222 MTask *extractor2=0; 250 223 251 if (!ReadCalibration( seq, path,calcam, qecam, tmcam, badpix, extractor1, extractor2))224 if (!ReadCalibration(calcam, qecam, tmcam, badpix, extractor1, extractor2)) 252 225 return kFALSE; 253 226 … … 270 243 plist.AddToList(&tmcam); 271 244 plist.AddToList(&badcam); 272 plist.AddToList(& job1.GetPedestalCam());245 plist.AddToList(&pedcam); 273 246 274 247 // Setup Tasklist … … 314 287 MFillH fill5(&evt5, "MArrivalTime", "FillTimes"); 315 288 316 MWriteRootFile write(2, Form("%s{s/_D_/_Y_}", f OutputPath.Data()), fOverwrite);289 MWriteRootFile write(2, Form("%s{s/_D_/_Y_}", fPathOut.Data()), fOverwrite); 317 290 write.AddContainer("MCerPhotEvt", "Events"); 318 291 write.AddContainer("MPedPhotCam", "Events"); … … 347 320 evtloop.SetDisplay(fDisplay); 348 321 evtloop.SetLogStream(fLog); 349 evtloop.ReadEnv(env); 322 if (GetEnv()) 323 evtloop.ReadEnv(*GetEnv()); 350 324 351 325 // Execute first analysis … … 358 332 tlist.PrintStatistics(); 359 333 360 if (!WriteResult( seq))334 if (!WriteResult()) 361 335 return kFALSE; 362 336 -
trunk/MagicSoft/Mars/mjobs/MJCalibrateSignal.h
r4723 r4729 2 2 #define MARS_MJCalibrateSignal 3 3 4 #ifndef MARS_M ParContainer5 #include "M ParContainer.h"4 #ifndef MARS_MJob 5 #include "MJob.h" 6 6 #endif 7 7 … … 11 11 class MParList; 12 12 class MSequence; 13 class MPedestalCam; 13 14 class MBadPixelsCam; 14 15 class MCalibrationCam; … … 17 18 class MCalibrationChargeCam; 18 19 19 class MJCalibrateSignal : public M ParContainer20 class MJCalibrateSignal : public MJob 20 21 { 21 22 private: 22 TString fOutputPath; // Directory to write signal*.root file to 23 TString fInputPath; // Directory to read calib*.root file from 24 25 Bool_t fOverwrite; // Allow overwriting files 26 Int_t fMaxEvents; // Maximum number of events 27 28 void CheckEnv(const char *env); 29 Bool_t WriteResult(const MSequence &seq); 30 Bool_t ReadCalibration(const MSequence &seq, const char *path, MCalibrationCam &calcam, 23 Bool_t WriteResult(); 24 Bool_t ReadCalibration(MCalibrationCam &calcam, 31 25 MCalibrationCam &qecam, MCalibrationCam &tmcam, 32 26 MBadPixelsCam &badpix, MTask* &ext1, MTask* &ext2) const; … … 34 28 public: 35 29 MJCalibrateSignal(const char *name=NULL, const char *title=NULL); 36 ~MJCalibrateSignal();37 30 38 Bool_t ProcessFile(const MSequence &seq, const char *env, const char *path=0); 39 40 void SetOutputPath(const char *path="."); 41 void SetInputPath(const char *path="."); 42 void SetMaxEvents(Int_t max) { fMaxEvents = max; } 43 44 void SetOverwrite(Bool_t b=kTRUE) { fOverwrite=b; } 45 46 MStatusDisplay *GetDisplay() { return fDisplay; } 31 Bool_t ProcessFile(MPedestalCam &cam); 47 32 48 33 ClassDef(MJCalibrateSignal, 0) // Tool to create a pedestal file (MPedestalCam) -
trunk/MagicSoft/Mars/mjobs/MJCalibration.cc
r4723 r4729 87 87 #include "MJCalibration.h" 88 88 89 #include <TEnv.h>90 89 #include <TFile.h> 91 90 #include <TStyle.h> … … 174 173 const Float_t MJCalibration::fgRefQEInner = 0.18; 175 174 const Float_t MJCalibration::fgRefQEOuter = 0.12; 175 176 176 177 // -------------------------------------------------------------------------- 177 178 // … … 184 185 // 185 186 MJCalibration::MJCalibration(const char *name, const char *title) 186 : f Env(0), fRuns(0), fSequence(0), fExtractor(NULL), fTimeExtractor(NULL),187 : fRuns(0), fExtractor(NULL), fTimeExtractor(NULL), 187 188 fColor(MCalibrationCam::kNONE), fDisplayType(kNormalDisplay), 188 fRelTimes(kFALSE), fDataCheck(kFALSE), fDebug(kFALSE), fOverwrite(kFALSE) 189 { 190 191 fName = name ? name : "MJCalibration"; 192 fTitle = title ? title : "Tool to create the calibration constants for one calibration run"; 193 194 SetUseBlindPixel(); 195 SetUsePINDiode(); 196 197 } 198 199 MJCalibration::~MJCalibration() 200 { 201 if (fEnv) 202 delete fEnv; 189 fRelTimes(kFALSE), fDataCheck(kFALSE), fDebug(kFALSE) 190 { 191 fName = name ? name : "MJCalibration"; 192 fTitle = title ? title : "Tool to create the calibration constants for one calibration run"; 193 194 SetUseBlindPixel(); 195 SetUsePINDiode(); 203 196 } 204 197 … … 255 248 TString title = fDisplay->GetTitle(); 256 249 title += "-- Calibration "; 257 title += fSequence ? Form("calib%06d", fSequence->GetSequence()) : fRuns->GetRunsAsString();250 title += fSequence.IsValid() ? Form("calib%06d", fSequence.GetSequence()) : fRuns->GetRunsAsString(); 258 251 title += " --"; 259 252 fDisplay->SetTitle(title); … … 1126 1119 Bool_t MJCalibration::FindColor() 1127 1120 { 1128 if (fSequence )1121 if (fSequence.IsValid()) 1129 1122 { 1130 1123 fColor = MCalibrationCam::kCT1; … … 1222 1215 const char* MJCalibration::GetOutputFile() const 1223 1216 { 1224 if (fSequence )1225 return Form("%s/calib%06d.root", (const char*)f OutputPath, fSequence->GetSequence());1217 if (fSequence.IsValid()) 1218 return Form("%s/calib%06d.root", (const char*)fPathOut, fSequence.GetSequence()); 1226 1219 if (!fRuns) 1227 1220 return ""; 1228 1221 1229 return Form("%s/%s-F1.root", (const char*)f OutputPath, (const char*)fRuns->GetRunsAsFileName());1222 return Form("%s/%s-F1.root", (const char*)fPathOut, (const char*)fRuns->GetRunsAsFileName()); 1230 1223 } 1231 1224 … … 1240 1233 } 1241 1234 1242 void MJCalibration::SetEnv(const char *env)1243 {1244 if (fEnv)1245 delete fEnv;1246 fEnv = new TEnv(env);1247 }1248 1249 1235 // -------------------------------------------------------------------------- 1250 1236 // 1251 1237 // MJCalibration allows to setup several option by a resource file: 1252 // MJCalibration.OutputPath: path1253 // MJCalibration.InputPath: path1254 1238 // MJCalibration.Display: full, datacheck, normal 1255 1239 // MJCalibration.RelTimeCalibration: yes,no … … 1261 1245 // For more details see the class description and the corresponding Getters 1262 1246 // 1263 void MJCalibration::CheckEnv() 1264 { 1265 if (!fEnv) 1266 return; 1267 1268 TString e1 = fEnv->GetValue(Form("%s.OutputPath", fName.Data()), ""); 1269 if (!e1.IsNull()) 1270 { 1271 e1.ReplaceAll("\015", ""); 1272 SetOutputPath(e1); 1273 } 1274 1275 TString col = fEnv->GetValue(Form("%s.Color", fName.Data()), ""); 1247 Bool_t MJCalibration::CheckEnv() 1248 { 1249 if (!MJob::CheckEnv()) 1250 return kFALSE; 1251 1252 TString col = GetEnv("Color", ""); 1276 1253 if (!col.IsNull()) 1277 1254 { 1278 1255 } 1279 1256 1280 TString dis = fEnv->GetValue(Form("%s.Display", fName.Data()), "");1257 TString dis = GetEnv("Display", ""); 1281 1258 if (dis.BeginsWith("Full", TString::kIgnoreCase)) 1282 1259 SetFullDisplay(); … … 1286 1263 SetNormalDisplay(); 1287 1264 1288 SetRelTimeCalibration(fEnv->GetValue(Form("%s.RelTimeCalibration", fName.Data()), fRelTimes)); 1289 SetDataCheck(fEnv->GetValue(Form("%s.Datacheck", fName.Data()), fDataCheck)); 1290 SetDebug(fEnv->GetValue(Form("%s.Debug", fName.Data()), fDebug)); 1291 SetUseBlindPixel(fEnv->GetValue(Form("%s.UseBlindPixel", fName.Data()), IsUseBlindPixel())); 1292 SetUsePINDiode(fEnv->GetValue(Form("%s.UsePINDiode", fName.Data()), IsUsePINDiode())); 1293 1294 SetOverwrite(fEnv->GetValue(Form("%s.AllowOverwrite", fName.Data()), fOverwrite)); 1295 SetInputPath(fEnv->GetValue(Form("%s.InputPath", fName.Data()), fInputPath)); 1265 SetRelTimeCalibration(GetEnv("RelTimeCalibration", fRelTimes)); 1266 SetDataCheck(GetEnv("Datacheck", fDataCheck)); 1267 SetDebug(GetEnv("Debug", fDebug)); 1268 SetUseBlindPixel(GetEnv("UseBlindPixel", IsUseBlindPixel())); 1269 SetUsePINDiode(GetEnv("UsePINDiode", IsUsePINDiode())); 1270 1271 return kTRUE; 1296 1272 } 1297 1273 … … 1312 1288 { 1313 1289 1314 Int_t run = fSequence ? fSequence->GetLastRun() : fRuns->GetRuns()[fRuns->GetNumRuns()-1];1290 Int_t run = fSequence.IsValid() ? fSequence.GetLastRun() : fRuns->GetRuns()[fRuns->GetNumRuns()-1]; 1315 1291 1316 1292 // … … 1394 1370 Bool_t MJCalibration::ProcessFile(MPedestalCam &pedcam) 1395 1371 { 1396 if (!fRuns && !fSequence) 1397 { 1398 *fLog << err << "No Runs choosen... abort." << endl; 1399 return kFALSE; 1400 } 1401 1402 if (!fSequence && fRuns->GetNumRuns() != fRuns->GetNumEntries()) 1403 { 1404 *fLog << err << "Number of files found doesn't match number of runs... abort." 1405 << fRuns->GetNumRuns() << " vs. " << fRuns->GetNumEntries() << endl; 1406 return kFALSE; 1407 } 1372 if (!fSequence.IsValid()) 1373 { 1374 if (!fRuns) 1375 { 1376 *fLog << err << "No Runs choosen... abort." << endl; 1377 return kFALSE; 1378 } 1379 1380 if (fRuns->GetNumRuns() != fRuns->GetNumEntries()) 1381 { 1382 *fLog << err << "Number of files found doesn't match number of runs... abort." 1383 << fRuns->GetNumRuns() << " vs. " << fRuns->GetNumEntries() << endl; 1384 return kFALSE; 1385 } 1386 } 1387 1388 //if (!CheckEnv()) 1389 // return kFALSE; 1390 1391 CheckEnv(); 1392 1393 // -------------------------------------------------------------------------------- 1408 1394 1409 1395 *fLog << inf; … … 1414 1400 1415 1401 *fLog << "Calculate MCalibrationCam from "; 1416 if (fSequence )1417 *fLog << "Sequence #" << fSequence ->GetSequence() << endl;1402 if (fSequence.IsValid()) 1403 *fLog << "Sequence #" << fSequence.GetSequence() << endl; 1418 1404 else 1419 1405 *fLog << "Runs " << fRuns->GetRunsAsString() << endl; 1420 1406 *fLog << endl; 1421 1407 1422 CheckEnv();1408 // -------------------------------------------------------------------------------- 1423 1409 1424 1410 // Setup Tasklist … … 1432 1418 1433 1419 MDirIter iter; 1434 if (fSequence) 1435 { 1436 if (fSequence->SetupCalRuns(iter, fInputPath)==0) 1420 if (fSequence.IsValid()) 1421 { 1422 const Int_t n0 = fSequence.SetupCalRuns(iter, fPathData); 1423 const Int_t n1 = fSequence.GetNumCalRuns(); 1424 if (n0==0) 1437 1425 { 1438 1426 *fLog << err << "ERROR - No input files of sequence found!" << endl; 1439 1427 return kFALSE; 1440 1428 } 1429 if (n0!=n1) 1430 { 1431 *fLog << err << "ERROR - Number of files found (" << n0 << ") doesn't match number of files in sequence (" << n1 << ")" << endl; 1432 return kFALSE; 1433 } 1441 1434 } 1442 1435 1443 1436 if (fDataCheck) 1444 1437 { 1445 rawread.AddFiles(fSequence ? iter : *fRuns);1438 rawread.AddFiles(fSequence.IsValid() ? iter : *fRuns); 1446 1439 tlist.AddToList(&rawread); 1447 1440 } … … 1449 1442 { 1450 1443 read.DisableAutoScheme(); 1451 read.AddFiles(fSequence ? iter : *fRuns);1444 read.AddFiles(fSequence.IsValid() ? iter : *fRuns); 1452 1445 tlist.AddToList(&read); 1453 1446 } … … 1478 1471 MCalibrationRelTimeCalc timecalc; 1479 1472 1480 if (!fSequence )1481 { 1482 calcalc.SetOutputPath(f OutputPath);1473 if (!fSequence.IsValid()) 1474 { 1475 calcalc.SetOutputPath(fPathOut); 1483 1476 calcalc.SetOutputFile(Form("%s-ChargeCalibStat.txt",(const char*)fRuns->GetRunsAsFileName())); 1484 1477 } … … 1564 1557 evtloop.SetDisplay(fDisplay); 1565 1558 evtloop.SetLogStream(fLog); 1566 if ( fEnv)1567 evtloop.ReadEnv(* fEnv);1559 if (GetEnv()) 1560 evtloop.ReadEnv(*GetEnv()); 1568 1561 1569 1562 //if (!WriteEventloop(evtloop)) … … 1688 1681 // -------------------------------------------------------------------------- 1689 1682 // 1690 // Set the path for output files, written by WriteResult()1691 //1692 void MJCalibration::SetOutputPath(const char *path)1693 {1694 fOutputPath = path;1695 if (fOutputPath.EndsWith("/"))1696 fOutputPath = fOutputPath(0, fOutputPath.Length()-1);1697 }1698 1699 // --------------------------------------------------------------------------1700 //1701 // Set the path from which the sequence files are read1702 //1703 void MJCalibration::SetInputPath(const char *path)1704 {1705 fInputPath = path;1706 if (fInputPath.EndsWith("/"))1707 fInputPath = fInputPath(0, fInputPath.Length()-1);1708 }1709 1710 // --------------------------------------------------------------------------1711 //1712 1683 // Set the useage of the Blind Pixel device 1713 1684 // … … 1728 1699 Bool_t MJCalibration::WriteEventloop(MEvtLoop &evtloop) const 1729 1700 { 1730 if (f OutputPath.IsNull())1701 if (fPathOut.IsNull()) 1731 1702 return kTRUE; 1732 1703 … … 1753 1724 Bool_t MJCalibration::WriteTasks(MTask *t1, MTask *t2) const 1754 1725 { 1755 if (f OutputPath.IsNull())1726 if (fPathOut.IsNull()) 1756 1727 return kTRUE; 1757 1728 … … 1794 1765 Bool_t MJCalibration::WriteResult() 1795 1766 { 1796 if (f OutputPath.IsNull())1767 if (fPathOut.IsNull()) 1797 1768 return kTRUE; 1798 1769 -
trunk/MagicSoft/Mars/mjobs/MJCalibration.h
r4723 r4729 2 2 #define MARS_MJCalibration 3 3 4 #ifndef MARS_MJob 5 #include "MJob.h" 6 #endif 4 7 #ifndef MARS_MCalibrationChargeCam 5 8 #include "MCalibrationChargeCam.h" … … 21 24 #endif 22 25 23 class TEnv; 26 class TH1D; 27 24 28 class MTask; 25 29 class MRunIter; 26 class MSequence;27 30 class MParList; 28 31 class MPedestalCam; … … 30 33 class MExtractTime; 31 34 class MEvtLoop; 32 33 35 class MExtractBlindPixel; 34 36 class MHCalibrationChargeBlindCam; 35 37 class MHCamera; 36 class TH1D; 37 class MJCalibration : public M ParContainer38 39 class MJCalibration : public MJob 38 40 { 39 41 private: … … 57 59 static const Float_t fgRefQEOuter; //! Reference value for the quantum eff. cascades - outer 58 60 59 TString fOutputPath; // Path to the output files60 TString fInputPath; // Path to get the data files from61 62 TEnv *fEnv; // Input setup-file63 61 MRunIter *fRuns; // Calibration files 64 MSequence *fSequence; // Sequence65 62 66 63 MExtractor *fExtractor; // Signal extractor … … 97 94 Bool_t fDataCheck; // Flag if the data check is run on raw data 98 95 Bool_t fDebug; // Flag if debug option is passed onto cal. classes 99 Bool_t fOverwrite; // Allow to overwite existing files100 96 101 97 void DisplayResult ( MParList &plist ); … … 109 105 Bool_t WriteEventloop(MEvtLoop &evtloop) const; 110 106 Bool_t WriteTasks(MTask *t1, MTask *t2) const; 111 voidCheckEnv();107 Bool_t CheckEnv(); 112 108 113 109 // WORKAROUNDS!!! … … 117 113 118 114 public: 119 120 115 MJCalibration(const char *name=NULL, const char *title=NULL); 121 ~MJCalibration();122 116 123 117 const char* GetOutputFile() const; 124 void SetEnv(const char *env);125 118 126 119 MCalibrationChargeCam &GetCalibrationCam() { return fCalibrationCam; } … … 137 130 void SetQECam(const MCalibrationQECam &qe) { qe.Copy(fQECam); } 138 131 void SetColor(const MCalibrationCam::PulserColor_t color) { fColor = color; } 139 140 void SetInput(MRunIter *iter) { fRuns=iter; }141 void SetSequence(MSequence *seq) { fSequence=seq; }142 void SetOutputPath(const char *path=".");143 void SetInputPath(const char *path=".");144 void SetOverwrite(Bool_t b=kTRUE) { fOverwrite=b; }145 132 146 133 // Displays … … 161 148 void SetUseBlindPixel(const Bool_t b=kTRUE); 162 149 void SetUsePINDiode(const Bool_t b=kTRUE); 163 150 151 // Precessing 164 152 Bool_t ReadCalibrationCam(); 165 153 Bool_t ProcessFile(MPedestalCam &pedcam); 166 154 Bool_t Process(MPedestalCam &pedcam); 167 155 168 MStatusDisplay *GetDisplay() { return fDisplay; }169 170 156 ClassDef(MJCalibration, 0) // Tool to run a calibration per pulser colour and intensity 171 157 }; -
trunk/MagicSoft/Mars/mjobs/MJPedestal.cc
r4723 r4729 90 90 // 91 91 MJPedestal::MJPedestal(const char *name, const char *title) 92 : f Env(0), fRuns(0), fSequence(0), fExtractor(NULL), fDisplayType(kNormalDisplay),93 fDataCheck(kFALSE), fUseData(kFALSE) , fOverwrite(kFALSE), fMaxEvents(0)92 : fRuns(0), fExtractor(NULL), fDisplayType(kNormalDisplay), 93 fDataCheck(kFALSE), fUseData(kFALSE) 94 94 { 95 95 fName = name ? name : "MJPedestal"; … … 97 97 } 98 98 99 MJPedestal::~MJPedestal()100 {101 if (fEnv)102 delete fEnv;103 }104 105 99 const char* MJPedestal::GetOutputFile() const 106 100 { 107 if (fSequence )108 return Form("%s/calped%06d.root", (const char*)f OutputPath, fSequence->GetSequence());101 if (fSequence.IsValid()) 102 return Form("%s/calped%06d.root", (const char*)fPathOut, fSequence.GetSequence()); 109 103 110 104 if (!fRuns) 111 105 return ""; 112 106 113 return Form("%s/%s-F0.root", (const char*)f OutputPath, (const char*)fRuns->GetRunsAsFileName());107 return Form("%s/%s-F0.root", (const char*)fPathOut, (const char*)fRuns->GetRunsAsFileName()); 114 108 } 115 109 … … 160 154 TString title = fDisplay->GetTitle(); 161 155 title += "-- Pedestal "; 162 if (fSequence )163 title += fSequence ->GetName();156 if (fSequence.IsValid()) 157 title += fSequence.GetName(); 164 158 else 165 159 if (fRuns) // FIXME: What to do if an environmentfile was used? … … 468 462 Bool_t MJPedestal::WriteResult() 469 463 { 470 if (f OutputPath.IsNull())464 if (fPathOut.IsNull()) 471 465 return kTRUE; 472 466 … … 503 497 } 504 498 505 void MJPedestal::SetOutputPath(const char *path)506 {507 fOutputPath = path;508 if (fOutputPath.EndsWith("/"))509 fOutputPath = fOutputPath(0, fOutputPath.Length()-1);510 }511 512 // --------------------------------------------------------------------------513 //514 // Set the path from which the sequence files are read515 //516 void MJPedestal::SetInputPath(const char *path)517 {518 fInputPath = path;519 if (fInputPath.EndsWith("/"))520 fInputPath = fInputPath(0, fInputPath.Length()-1);521 }522 523 void MJPedestal::SetEnv(const char *env)524 {525 if (fEnv)526 delete fEnv;527 fEnv = new TEnv(env);528 }529 530 499 Bool_t MJPedestal::Process() 531 500 { … … 536 505 } 537 506 538 // --------------------------------------------------------------------------539 //540 // MJPedestsl allows to setup several option by a resource file:541 // MJPedestal.OutputPath: path542 // MJPedestal.MaxEvents: 1000543 // MJPedestal.AllowOverwrite: yes, no544 // MJPedestal.UseData: yes, no (use DatRuns from sequence instead of PedRuns)545 //546 // For more details see the class description and the corresponding Getters547 //548 void MJPedestal::CheckEnv()549 {550 if (!fEnv)551 return;552 553 TString e1 = fEnv->GetValue(Form("%s.OutputPath", fName.Data()), "");554 if (!e1.IsNull())555 {556 e1.ReplaceAll("\015", "");557 SetOutputPath(e1);558 }559 560 SetMaxEvents(fEnv->GetValue(Form("%s.MaxEvents", fName.Data()), fMaxEvents));561 SetOverwrite(fEnv->GetValue(Form("%s.AllowOverwrite", fName.Data()), fOverwrite));562 563 fUseData = fEnv->GetValue(Form("%s.UseData", fName.Data()), fUseData);564 }565 566 507 Bool_t MJPedestal::ProcessFile() 567 508 { 568 if (!fRuns && !fEnv && !fSequence) 569 { 570 *fLog << err << "Neither AddRuns nor SetSequence nor SetEnv was called... abort." << endl; 571 return kFALSE; 572 } 573 if (!fSequence && fRuns && fRuns->GetNumRuns() != fRuns->GetNumEntries()) 574 { 575 *fLog << err << "Number of files found doesn't match number of runs... abort." << endl; 576 return kFALSE; 577 } 509 if (!fSequence.IsValid()) 510 { 511 if (!fRuns) 512 { 513 *fLog << err << "Neither AddRuns nor SetSequence nor SetEnv was called... abort." << endl; 514 return kFALSE; 515 } 516 if (fRuns && fRuns->GetNumRuns() != fRuns->GetNumEntries()) 517 { 518 *fLog << err << "Number of files found doesn't match number of runs... abort." << endl; 519 return kFALSE; 520 } 521 } 522 523 //if (!CheckEnv()) 524 // return kFALSE; 525 526 CheckEnv(); 527 528 // -------------------------------------------------------------------------------- 578 529 579 530 *fLog << inf; 580 531 fLog->Separator(GetDescriptor()); 581 532 *fLog << "Calculate MPedestalCam from Runs "; 582 if (fSequence )583 *fLog << fSequence ->GetName() << endl;533 if (fSequence.IsValid()) 534 *fLog << fSequence.GetName() << endl; 584 535 else 585 536 if (fRuns) 586 537 *fLog << fRuns->GetRunsAsString() << endl; 587 538 else 588 *fLog << "in " << fEnv->GetName()<< endl;539 *fLog << "in Resource File." << endl; 589 540 *fLog << endl; 590 541 591 CheckEnv();542 // -------------------------------------------------------------------------------- 592 543 593 544 MParList plist; … … 600 551 601 552 MDirIter iter; 602 if (fSequence) 603 { 604 const Int_t n = fUseData ? fSequence->SetupDatRuns(iter, fInputPath) : fSequence->SetupPedRuns(iter, fInputPath); 605 if (n==0) 553 if (fSequence.IsValid()) 554 { 555 const Int_t n0 = fUseData ? fSequence.SetupDatRuns(iter, fPathData) : fSequence.SetupPedRuns(iter, fPathData); 556 const Int_t n1 = fUseData ? fSequence.GetNumDatRuns() : fSequence.GetNumPedRuns(); 557 if (n0==0) 606 558 { 607 559 *fLog << err << "ERROR - No input files of sequence found!" << endl; 608 560 return kFALSE; 609 561 } 562 if (n0!=n1) 563 { 564 *fLog << err << "ERROR - Number of files found (" << n0 << ") doesn't match number of files in sequence (" << n1 << ")" << endl; 565 return kFALSE; 566 } 610 567 } 611 568 612 569 if (fDataCheck) 613 570 { 614 if (fRuns || fSequence )615 rawread.AddFiles(fSequence ? iter : *fRuns);571 if (fRuns || fSequence.IsValid()) 572 rawread.AddFiles(fSequence.IsValid() ? iter : *fRuns); 616 573 tlist.AddToList(&rawread); 617 574 } … … 619 576 { 620 577 read.DisableAutoScheme(); 621 if (fRuns || fSequence )622 read.AddFiles(fSequence ? iter : *fRuns);578 if (fRuns || fSequence.IsValid()) 579 read.AddFiles(fSequence.IsValid() ? iter : *fRuns); 623 580 tlist.AddToList(&read); 624 581 } 625 // Enable logging to file626 //*fLog.SetOutputFile(lname, kTRUE);627 582 628 583 // Setup Tasklist … … 662 617 evtloop.SetDisplay(fDisplay); 663 618 evtloop.SetLogStream(fLog); 664 if ( fEnv)665 evtloop.ReadEnv(* fEnv);619 if (GetEnv()) 620 evtloop.ReadEnv(*GetEnv()); 666 621 667 622 // if (!WriteEventloop(evtloop)) -
trunk/MagicSoft/Mars/mjobs/MJPedestal.h
r4723 r4729 2 2 #define MARS_MJPedestal 3 3 4 #ifndef MARS_MJob 5 #include "MJob.h" 6 #endif 4 7 #ifndef MARS_MPedestalCam 5 8 #include "MPedestalCam.h" … … 9 12 #endif 10 13 11 class TEnv;12 14 class TCanvas; 13 15 class MParList; 14 class MSequence;15 16 class MRunIter; 16 17 class MHCamera; … … 19 20 class MEvtLoop; 20 21 21 class MJPedestal : public M ParContainer22 class MJPedestal : public MJob 22 23 { 23 24 private: … … 39 40 static const Float_t fgRefPedRmsGalacticOuter; 40 41 41 TString fOutputPath; // Directory where the F0-files get stored42 TString fInputPath; // Directory from which to read the data files43 44 TEnv *fEnv; // Input setup-file45 42 MRunIter *fRuns; // Used pedestal runs 46 const MSequence *fSequence; // Sequence47 48 43 MExtractor *fExtractor; // Signal extractor, used to find the nr. of used FADC slices 49 44 … … 57 52 Bool_t fDataCheck; // Flag if the data check is run on raw data 58 53 Bool_t fUseData; // Use data-runs from sequence instead of pedestal runs 59 Bool_t fOverwrite; // Allow to overwite existing files60 61 Int_t fMaxEvents; // Maximum number of events62 54 63 55 Bool_t ReadPedestalCam(); … … 70 62 void FixDataCheckHist(TH1D *hist) const; 71 63 72 void CheckEnv();73 74 64 public: 75 65 MJPedestal(const char *name=NULL, const char *title=NULL); 76 ~MJPedestal();77 66 78 67 MPedestalCam &GetPedestalCam() { return fPedestalCam; } … … 88 77 void SetExtractor(MExtractor* ext) { fExtractor = ext; } 89 78 void SetInput(MRunIter *iter) { fRuns = iter; } 90 void SetSequence(const MSequence *seq, Bool_t usedata=kFALSE) { fSequence = seq; }91 void SetOutputPath(const char *path=".");92 void SetInputPath(const char *path=".");93 void SetEnv(const char *env);94 void SetOverwrite(Bool_t b=kTRUE) { fOverwrite=b; }95 void SetMaxEvents(Int_t max) { fMaxEvents = max; }96 79 97 80 void SetDataCheck(const Bool_t b=kTRUE) { fDataCheck = b; SetDataCheckDisplay(); } … … 100 83 void SetNormalDisplay() { fDisplayType = kNormalDisplay; } 101 84 102 MStatusDisplay *GetDisplay() { return fDisplay; }103 104 85 ClassDef(MJPedestal, 0) // Tool to create a pedestal file (MPedestalCam) 105 86 }; -
trunk/MagicSoft/Mars/mjobs/MSequence.cc
r4722 r4729 84 84 } 85 85 86 Int_t num = 0;87 88 86 for (int i=0; i<arr.GetSize(); i++) 89 87 { … … 95 93 96 94 // Add Path/File to TIter 97 num +=iter.AddDirectory(d, n, 0);98 } 99 return num;95 iter.AddDirectory(d, n, 0); 96 } 97 return iter.GetNumEntries(); 100 98 } 101 99 -
trunk/MagicSoft/Mars/mjobs/MSequence.h
r4722 r4729 39 39 40 40 public: 41 MSequence() : fSequence((UInt_t)-1), fLastRun((UInt_t)-1), 42 fNumEvents((UInt_t)-1), fPeriod((UInt_t)-1) { } 41 43 MSequence(const char *fname); 44 MSequence(const MSequence &s) : fSequence(s.fSequence), fStart(s.fStart), 45 fLastRun(s.fLastRun), fNumEvents(s.fNumEvents), fPeriod(s.fPeriod), 46 fNight(s.fNight), fProject(s.fProject), fSource(s.fSource), 47 fTriggerTable(s.fTriggerTable), fHvSettings(s.fHvSettings), 48 fRuns(s.fRuns), fCalRuns(s.fCalRuns), fPedRuns(s.fPedRuns), 49 fDatRuns(s.fDatRuns) { } 42 50 43 51 void Print(Option_t *o="") const; … … 50 58 Int_t SetupCalRuns(MDirIter &iter, const char *path=0) const; 51 59 60 Int_t GetNumAllRuns() const { return fRuns.GetSize(); } 61 Int_t GetNumDatRuns() const { return fDatRuns.GetSize(); } 62 Int_t GetNumPedRuns() const { return fPedRuns.GetSize(); } 63 Int_t GetNumCalRuns() const { return fCalRuns.GetSize(); } 64 52 65 // Getter 53 66 UInt_t GetSequence() const { return fSequence; } -
trunk/MagicSoft/Mars/mjobs/Makefile
r4723 r4729 25 25 #manalysis: MChisqEval (MParameters) 26 26 27 SRCFILES = MSequence.cc \ 27 SRCFILES = MJob.cc \ 28 MSequence.cc \ 28 29 MJPedestal.cc \ 29 30 MJCalibration.cc \
Note:
See TracChangeset
for help on using the changeset viewer.