Changeset 3754
- Timestamp:
- 04/15/04 16:29:37 (21 years ago)
- Location:
- trunk/MagicSoft/Mars
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/Changelog
r3753 r3754 21 21 22 22 * macros/calibration.C 23 - added a function FindColor to extract the colour by filename,23 - added a function FindColor() to extract the colour by filename, 24 24 works if there is indeed a colour or if the run nubmer is smaller 25 25 than 20000 -> take ct1 26 27 * macros/bootcampstandardanalysis.C 28 - updated the macro to the cvs-standard used at the Udine bootcamp 29 26 30 27 31 * mcalib/MCalibrateRelTimes.[h,cc] -
trunk/MagicSoft/Mars/macros/bootcampstandardanalysis.C
r3436 r3754 17 17 ! 18 18 ! Author(s): Javier López, 12/2003 <mailto:jlopez@ifae.es> 19 ! 20 ! Copyright: MAGIC Software Development, 2000-2003 19 ! Markus Gaug , 04/2004 <mailto:markus@ifae.es> 20 ! 21 ! Copyright: MAGIC Software Development, 2000-2004 21 22 ! 22 23 ! 23 24 \* ======================================================================== */ 25 ///////////////////////////////////////////////////////////////////////////// 26 // 27 // bootcampstandardanalysis.C 28 // 29 // Updated version of the macro designed at the Wuerzburg bootcamp and 30 // compatible with the latest changes in Mars for general usage at the 31 // Udine bootcamp. 32 // 33 // Needs as arguments the run number of a pedestal file ("*_P_*.root"), 34 // one of a calibration file ("*_C_*.root") and one of a data file 35 // ("*_D_*.root"). Performs the pedestal calculation, the calibration 36 /// constants calculation and the calibration of the data. 37 // 38 // The TString inpath has to be set correctly. 39 // 40 // The macro searches for the pulser colour which corresponds to the calibration 41 // run number. If the run number is smaller than 20000, pulser colour "CT1" 42 // is assumed, otherwise, it searches for the strings "green", "blue", "uv" or 43 // "ct1" in the filenames. If no colour or multiple colours are found, the 44 // execution is aborted. 45 // 46 ////////////////////////////////////////////////////////////////////////////////// 47 const TString inpath = "/mnt/Data/rootdata/CrabNebula/2004_02_10/"; 48 const Int_t dpedrun = 14607; 49 const Int_t dcalrun1 = 14608; 50 const Int_t dcalrun2 = 0; 51 const Int_t ddatrun1 = 14609; 52 const Int_t ddatrun2 = 14614; 53 const Bool_t usedisplay = kTRUE; 54 55 void bootcampstandardanalysis(const Int_t prun=dpedrun, // pedestal file 56 const Int_t crun1=dcalrun1, const Int_t crun2=dcalrun2, // calibration file(s) 57 const Int_t drun1=ddatrun1, const Int_t drun2=ddatrun2 // data files(s) 58 ) 59 60 { 61 62 MRunIter pruns; 63 MRunIter cruns; 64 MRunIter druns; 65 66 pruns.AddRun(prun,inpath); 67 68 if (crun2==0) 69 cruns.AddRun(crun1,inpath); 70 else 71 cruns.AddRuns(crun1,crun2,inpath); 72 73 MCalibrationCam::PulserColor_t color; 74 75 if (crun1 < 20000) 76 color = MCalibrationCam::kCT1; 77 else 78 color = FindColor((MDirIter*)&cruns); 79 80 if (color == MCalibrationCam::kNONE) 81 { 82 TTimer timer("gSystem->ProcessEvents();", 50, kFALSE); 83 84 while (1) 85 { 86 timer.TurnOn(); 87 TString input = Getline("Could not find the correct colour: Type 'q' to exit, " 88 "green, blue, uv or ct1 to go on: "); 89 timer.TurnOff(); 90 91 if (input=="q\n") 92 return ; 93 94 if (input=="green") 95 color = MCalibrationCam::kGREEN; 96 if (input=="blue") 97 color = MCalibrationCam::kBLUE; 98 if (input=="uv") 99 color = MCalibrationCam::kUV; 100 if (input=="ct1") 101 color = MCalibrationCam::kCT1; 102 } 103 } 104 105 if (drun2==0) 106 druns.AddRun(drun1,inpath); 107 else 108 druns.AddRuns(drun1,drun2,inpath); 109 110 // 111 // Now setup the tasks and tasklist for the pedestals: 112 // --------------------------------------------------- 113 // 114 MBadPixelsCam badcam; 115 MGeomCamMagic geomcam; 116 MGeomApply geomapl; 117 // 118 // If you want to exclude pixels from the beginning, read 119 // an ascii-file with the corr. pixel numbers (see MBadPixelsCam) 120 // 121 // badcam.AsciiRead("badpixels.dat"); 122 123 /************************************/ 124 /* FIRST LOOP: PEDESTAL COMPUTATION */ 125 /************************************/ 126 127 MJPedestal pedloop; 128 pedloop.SetInput(&pruns); 129 if (usedisplay) 130 { 131 MStatusDisplay *display = new MStatusDisplay; 132 display->SetUpdateTime(3000); 133 display->Resize(850,700); 134 pedloop.SetDisplay(display); 135 } 136 pedloop.SetBadPixels(badcam); 137 138 if (!pedloop.Process()) 139 return; 140 141 /****************************************/ 142 /* SECOND LOOP: CALIBRATION COMPUTATION */ 143 /****************************************/ 144 145 // 146 // Now setup the new tasks for the calibration: 147 // --------------------------------------------------- 148 // 149 MCalibrationQECam qecam; 150 MJCalibration calloop; 151 calloop.SetColor(color); 152 calloop.SetInput(&cruns); 153 // 154 // Use as signal extractor MExtractSignal: 155 // 156 calloop.SetExtractorLevel(1); 157 // 158 // Set the corr. cams: 159 // 160 calloop.SetQECam(qecam); 161 calloop.SetBadPixels(pedloop.GetBadPixels()); 162 // 163 // The next two commands are for the display: 164 // 165 if (usedisplay) 166 { 167 calloop.SetDisplay(display); 168 calloop.SetDataCheck(); 169 } 170 171 // 172 // Apply rel. time calibration: 173 // 174 calloop.SetRelTimeCalibration(); 175 // 176 // Use as arrival time extractor MArrivalTimeCalc2: 177 // 178 calloop.SetArrivalTimeLevel(2); 179 180 // 181 // Do the event-loop: 182 // 183 if (!calloop.Process(pedloop.GetPedestalCam())) 184 return; 185 186 187 /*************************************/ 188 /* THIRD LOOP: PEDESTAL CALIBRATION */ 189 /*************************************/ 190 191 // 192 // Create a empty Parameter List and an empty Task List 193 // 194 MParList plist3; 195 MTaskList tlist3; 196 plist3.AddToList(&tlist3); 197 198 // 199 // Now setup the tasks and tasklist to calculate the pedestal rms in number of photons 200 // ----------------------------------------------------------------------------------- 201 // 202 203 MCerPhotEvt nphot; 204 MPedPhotCam nphotrms; 205 206 plist3.AddToList(&geomcam); 207 208 // 209 // Retrieve the cameras from the previous runs: 210 // 211 plist3.AddToList(&pedloop.GetPedestalCam()); 212 plist3.AddToList(&calloop.GetCalibrationCam()); 213 plist3.AddToList(&calloop.GetQECam()); 214 plist3.AddToList(&calloop.GetRelTimeCam()); 215 plist3.AddToList(&calloop.GetBadPixels()); 216 plist3.AddToList(&nphot); 217 plist3.AddToList(&nphotrms); 218 219 //tasks 220 MReadMarsFile read3("Events"); 221 read3.DisableAutoScheme(); 222 static_cast<MRead&>(read3).AddFiles(pruns); 223 224 MExtractSignal extsig; 225 MCalibrate photcalc; 226 photcalc.SetCalibrationMode(MCalibrate::kFfactor); 227 // MPedPhotCalc photrmscalc; //It doesn't exist yet 228 229 tlist3.AddToList(&read3); 230 tlist3.AddToList(&geomapl); 231 tlist3.AddToList(&extsig); 232 tlist3.AddToList(&photcalc); 233 // tlist3.AddToList(&photrmscalc); 234 235 // 236 // Create and setup the eventloop 237 // 238 MEvtLoop evtloop3; 239 evtloop3.SetParList(&plist3); 240 241 // 242 // Execute first analysis 243 // 244 if (!evtloop3.Eventloop()) 245 return; 246 247 tlist3.PrintStatistics(); 248 249 /*************************************/ 250 /* FOURTH LOOP: DATA CALIBRATION */ 251 /*************************************/ 252 253 // 254 // Create a empty Parameter List and an empty Task List 255 // 256 MParList plist4; 257 MTaskList tlist4; 258 plist4.AddToList(&tlist4); 259 260 // 261 // Now setup the tasks and tasklist to analize the data 262 // ----------------------------------------------------- 263 // 264 265 plist4.AddToList(&geomcam); 266 // 267 // Retrieve the cameras from the previous runs: 268 // 269 plist4.AddToList(&pedloop.GetPedestalCam()); 270 plist4.AddToList(&calloop.GetCalibrationCam()); 271 plist4.AddToList(&calloop.GetQECam()); 272 plist4.AddToList(&calloop.GetRelTimeCam()); 273 plist4.AddToList(&calloop.GetBadPixels()); 274 plist4.AddToList(&nphot); 275 plist4.AddToList(&nphotrms); 276 277 MArrivalTime times; 278 plist4.AddToList(×); 279 280 //tasks 281 MReadMarsFile read4("Events"); 282 read4.DisableAutoScheme(); 283 static_cast<MRead&>(read4).AddFiles(druns); 284 285 MArrivalTimeCalc2 timecalc; 286 MCalibrateRelTimes timecal; 287 288 tlist4.AddToList(&read4); 289 tlist4.AddToList(&geomapl); 290 tlist4.AddToList(&extsig); 291 tlist4.AddToList(&timecalc); 292 tlist4.AddToList(&photcalc); 293 tlist4.AddToList(&timecal); 294 295 // 296 // Create and setup the eventloop 297 // 298 MEvtLoop evtloop4; 299 evtloop4.SetParList(&plist4); 300 301 if (!evtloop4.PreProcess()) 302 303 return; 304 305 TCanvas *c1 = new TCanvas; 306 MHCamera disp1(geomcam); 307 disp1.SetPrettyPalette(); 308 //disp1.SetInvDeepBlueSeaPalette() 309 disp1.Draw(); 310 gPad->SetLogy(); 311 gPad->cd(1); 312 313 /* 314 TCanvas *c2 = new TCanvas; 315 MHCamera disp2(geomcam); 316 disp2.SetPrettyPalette(); 317 //disp2.SetInvDeepBlueSeaPalette() 318 disp2.Draw(); 319 gPad->SetLogy(); 320 gPad->cd(1); 321 */ 322 while (tlist4.Process()) 323 { 324 disp1.SetCamContent(nphot); 325 326 gPad->Modified(); 327 gPad->Update(); 328 329 /* 330 disp2.SetCamContent(times); 331 332 gPad->Modified(); 333 gPad->Update(); 334 */ 335 336 // Remove the comments if you want to go through the file 337 // event-by-event: 338 if (!HandleInput()) 339 break; 340 } 341 342 evtloop4.PostProcess(); 343 344 } 24 345 25 346 Bool_t HandleInput() … … 46 367 } 47 368 48 void bootcampstandardanalysis( 49 TString pedname="/mnt/magic_data/Data/rootdata/2003_11_29/20031128_03127_P_Crab-Nebula_E.root", 50 TString calname="/mnt/magic_data/Data/rootdata/2003_11_29/20031128_03128_C_Crab-Nebula_E.root", 51 TString dataname="/mnt/magic_data/Data/rootdata/2003_11_29/20031128_03200_D_Crab-Nebula_E.root") 369 MCalibrationCam::PulserColor_t FindColor(MDirIter* run) 52 370 { 53 54 // Before starting be sure you have the pedestal, calibration and data runs names 55 // if (pedname != NULL) 56 // cout << endl << "usage: bootcampstandardanalysis.C()" << endl; 57 58 // 59 // Create a empty Parameter List and an empty Task List 60 // The tasklist is identified in the eventloop by its name 61 // 62 MParList plist; 63 64 MTaskList tlist; 65 plist.AddToList(&tlist); 66 67 // 68 // Now setup the tasks and tasklist for the pedestals: 69 // --------------------------------------------------- 70 // 71 72 MPedestalCam pedcam; 73 plist.AddToList(&pedcam); 74 75 76 //tasks 77 MReadMarsFile read("Events", pedname); 78 read.DisableAutoScheme(); 79 80 MGeomApply geomapl; 81 MPedCalcPedRun pedcalc; 82 MGeomCamMagic geomcam; 83 84 tlist.AddToList(&read); 85 tlist.AddToList(&geomapl); 86 tlist.AddToList(&pedcalc); 87 88 // 89 // Create and setup the eventloop 90 // 91 MEvtLoop evtloop; 92 evtloop.SetParList(&plist); 93 94 // 95 // Execute first analysis 96 // 97 if (!evtloop.Eventloop()) 98 return; 99 100 tlist.PrintStatistics(); 101 102 // 103 // Create a empty Parameter List and an empty Task List 104 // 105 MParList plist2; 106 107 MTaskList tlist2; 108 plist2.AddToList(&tlist2); 109 110 111 // 112 // Now setup the new tasks and tasklist for the calibration 113 // --------------------------------------------------- 114 // 115 116 MBadPixelsCam badcam; 117 MCalibrationChargeCam calcam; 118 MExtractedSignalCam sigcam; 119 MCalibrationChargePINDiode pindiode; 120 MCalibrationChargeBlindPix blindpix; 121 122 // 123 // As long, as we don't have digital modules, 124 // we have to set the color of the pulser LED by hand 125 // 126 // calcam.SetColor(MCalibrationChargeCam::kECT1); 127 blindpix.SetColor(MCalibrationChargeBlindpix:kECT1); 128 129 plist2.AddToList(&geomcam); 130 plist2.AddToList(&badcam); 131 plist2.AddToList(&pedcam); 132 plist2.AddToList(&calcam); 133 plist2.AddToList(&sigcam); 134 plist2.AddToList(&pindiode); 135 plist2.AddToList(&blindpix); 136 137 // hists 138 MFillH fillpin( "MHCalibrationChargePINDiode", "MExtractedSignalPINDiode"); 139 MFillH fillblind("MHCalibrationChargeBlindPix", "MExtractedSignalBlindPix"); 140 MFillH fillcam( "MHCalibrationChargeCam" , "MExtractedSignalCam"); 141 142 //tasks 143 MReadMarsFile read2("Events", calname); 144 read2.DisableAutoScheme(); 145 146 MExtractPINDiode pincalc; 147 MExtractBlindPixel blindcalc; 148 MExtractSignal sigsig; 149 MCalibrationChargeCalc calcalc; 150 151 // 152 // Apply a filter against cosmics 153 // (was directly in MCalibrationCalc in earlier versions) 154 // 155 MFCosmics cosmics; 156 MContinue cont(&cosmics); 157 158 tlist2.AddToList(&read2); 159 tlist2.AddToList(&geomapl); 160 tlist2.AddToList(&blindcalc); 161 tlist2.AddToList(&pincalc); 162 tlist2.AddToList(&sigsig); 163 // 164 // In case, you want to skip the cosmics rejection, 165 // uncomment the next line 166 // 167 tlist2.AddToList(&cont); 168 // 169 // tlist2.AddToList(&fillpin); 170 tlist2.AddToList(&fillblind); 171 tlist2.AddToList(&fillcam); 172 tlist2.AddToList(&calcalc); 173 // 174 // Create and setup the eventloop 175 // 176 MEvtLoop evtloop2; 177 evtloop2.SetParList(&plist2); 178 179 // 180 // Execute second analysis 181 // 182 if (!evtloop2.Eventloop()) 183 return; 184 185 tlist2.PrintStatistics(); 186 187 188 // 189 // Create a empty Parameter List and an empty Task List 190 // 191 MParList plist3; 192 193 MTaskList tlist3; 194 plist3.AddToList(&tlist3); 195 196 // 197 // Now setup the tasks and tasklist to calculate the pedestal rms in number of photons 198 // ----------------------------------------------------------------------------------- 199 // 200 201 MCerPhotEvt nphot; 202 MPedPhotCam nphotrms; 203 204 plist3.AddToList(&geomcam); 205 plist3.AddToList(&pedcam); 206 plist3.AddToList(&calcam); 207 plist3.AddToList(&nphot); 208 plist3.AddToList(&nphotrms); 209 210 //tasks 211 MReadMarsFile read3("Events", pedname); 212 read3.DisableAutoScheme(); 213 214 MExtractSignal extsig; 215 MCalibrate photcalc; 216 // MPedPhotCalc photrmscalc; //It doesn't exist yet 217 218 tlist3.AddToList(&read3); 219 tlist3.AddToList(&geomapl); 220 tlist3.AddToList(&extsig); 221 tlist3.AddToList(&photcalc); 222 // tlist3.AddToList(&photrmscalc); 223 224 // 225 // Create and setup the eventloop 226 // 227 MEvtLoop evtloop3; 228 evtloop3.SetParList(&plist3); 229 230 231 // 232 // Execute first analysis 233 // 234 if (!evtloop3.Eventloop()) 235 return; 236 237 tlist3.PrintStatistics(); 238 239 // 240 // Create a empty Parameter List and an empty Task List 241 // 242 MParList plist4; 243 244 MTaskList tlist4; 245 plist4.AddToList(&tlist4); 246 247 // 248 // Now setup the tasks and tasklist to analize the data 249 // ----------------------------------------------------- 250 // 251 252 plist4.AddToList(&geomcam); 253 plist4.AddToList(&pedcam); 254 plist4.AddToList(&calcam); 255 plist4.AddToList(&nphot); 256 plist4.AddToList(&nphotrms); 257 258 //tasks 259 MReadMarsFile read4("Events", dataname); 260 read4.DisableAutoScheme(); 261 262 263 MExtractSignal extsig; 264 MCalibrate photcalc; 265 266 tlist4.AddToList(&read4); 267 tlist4.AddToList(&geomapl); 268 tlist4.AddToList(&extsig); 269 tlist4.AddToList(&photcalc); 270 271 // 272 // Create and setup the eventloop 273 // 274 MEvtLoop evtloop4; 275 evtloop4.SetParList(&plist4); 276 277 if (!evtloop4.PreProcess()) 278 return; 279 280 TCanvas *c = new TCanvas; 281 MHCamera display(geomcam); 282 display.SetPrettyPalette(); 283 //display.SetInvDeepBlueSeaPalette() 284 display.Draw(); 285 gPad->SetLogy(); 286 gPad->cd(1); 287 288 while (tlist4.Process()) 289 { 290 display.SetCamContent(nphot); 291 292 gPad->Modified(); 293 gPad->Update(); 294 295 // Remove the comments if you want to go through the file 296 // event-by-event: 297 if (!HandleInput()) 298 break; 371 372 MCalibrationCam::PulserColor_t col = MCalibrationCam::kNONE; 373 374 TString filenames; 375 376 while (!(filenames=run->Next()).IsNull()) 377 { 378 379 filenames.ToLower(); 380 381 if (filenames.Contains("green")) 382 if (col == MCalibrationCam::kNONE) 383 { 384 cout << "Found colour: Green in " << filenames << endl; 385 col = MCalibrationCam::kGREEN; 386 } 387 else if (col != MCalibrationCam::kGREEN) 388 { 389 cout << "Different colour found in " << filenames << "... abort" << endl; 390 return MCalibrationCam::kNONE; 391 } 392 393 if (filenames.Contains("blue")) 394 if (col == MCalibrationCam::kNONE) 395 { 396 cout << "Found colour: Blue in " << filenames << endl; 397 col = MCalibrationCam::kBLUE; 398 } 399 else if (col != MCalibrationCam::kBLUE) 400 { 401 cout << "Different colour found in " << filenames << "... abort" << endl; 402 return MCalibrationCam::kNONE; 403 } 404 405 if (filenames.Contains("uv")) 406 if (col == MCalibrationCam::kNONE) 407 { 408 cout << "Found colour: Uv in " << filenames << endl; 409 col = MCalibrationCam::kUV; 410 } 411 else if (col != MCalibrationCam::kUV) 412 { 413 cout << "Different colour found in " << filenames << "... abort" << endl; 414 return MCalibrationCam::kNONE; 415 } 416 417 if (filenames.Contains("ct1")) 418 if (col == MCalibrationCam::kNONE) 419 { 420 cout << "Found colour: Ct1 in " << filenames << endl; 421 col = MCalibrationCam::kCT1; 422 } 423 else if (col != MCalibrationCam::kCT1) 424 { 425 cout << "Different colour found in " << filenames << "... abort" << endl; 426 return MCalibrationCam::kNONE; 427 } 428 299 429 } 300 301 302 303 evtloop4.PostProcess(); 304 430 431 432 433 if (col == MCalibrationCam::kNONE) 434 cout << "No colour found in filenames of runs: " << ((MRunIter*)run)->GetRunsAsString() 435 << "... abort" << endl; 436 437 return col; 305 438 }
Note:
See TracChangeset
for help on using the changeset viewer.