| 1 | /* ======================================================================== *\
|
|---|
| 2 | !
|
|---|
| 3 | ! *
|
|---|
| 4 | ! * This file is part of MARS, the MAGIC Analysis and Reconstruction
|
|---|
| 5 | ! * Software. It is distributed to you in the hope that it can be a useful
|
|---|
| 6 | ! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
|
|---|
| 7 | ! * It is distributed WITHOUT ANY WARRANTY.
|
|---|
| 8 | ! *
|
|---|
| 9 | ! * Permission to use, copy, modify and distribute this software and its
|
|---|
| 10 | ! * documentation for any purpose is hereby granted without fee,
|
|---|
| 11 | ! * provided that the above copyright notice appear in all copies and
|
|---|
| 12 | ! * that both that copyright notice and this permission notice appear
|
|---|
| 13 | ! * in supporting documentation. It is provided "as is" without express
|
|---|
| 14 | ! * or implied warranty.
|
|---|
| 15 | ! *
|
|---|
| 16 | !
|
|---|
| 17 | !
|
|---|
| 18 | ! Author(s): Raquel de los Reyes, 03/2004 <mailto:reyes@gae.ucm.es>
|
|---|
| 19 | !
|
|---|
| 20 | ! Copyright: MAGIC Software Development, 2000-2004
|
|---|
| 21 | !
|
|---|
| 22 | !
|
|---|
| 23 | \* ======================================================================== *//////////////////////////////////////////////////////////////////////////////
|
|---|
| 24 | //
|
|---|
| 25 | // This macro made the check of the DAQ files (.raw files).
|
|---|
| 26 | //
|
|---|
| 27 | // WARNING!: This macro only works if the directory is alphabetically ordered
|
|---|
| 28 | //
|
|---|
| 29 | ///////////////////////////////////////////////////////////////////////////
|
|---|
| 30 | #include "MAGIC.h"
|
|---|
| 31 |
|
|---|
| 32 | void DataAnalysis(const MReadMarsFile *pedfiles,const MReadMarsFile *calfiles,const MReadMarsFile *datafiles,TString directory="./")
|
|---|
| 33 | {
|
|---|
| 34 |
|
|---|
| 35 | TVirtualPad *c;
|
|---|
| 36 |
|
|---|
| 37 | Bool_t batchmode = kTRUE;
|
|---|
| 38 |
|
|---|
| 39 | if(!batchmode)
|
|---|
| 40 | {
|
|---|
| 41 | MStatusDisplay *d = new MStatusDisplay;
|
|---|
| 42 | d->SetLogStream(&gLog, kTRUE); // Disables output to stdout
|
|---|
| 43 | }
|
|---|
| 44 |
|
|---|
| 45 | //
|
|---|
| 46 | // Set up the source run-range
|
|---|
| 47 | //
|
|---|
| 48 | TRegexp run("_[0-9][0-9][0-9][0-9][0-9]_");
|
|---|
| 49 | TRegexp type("_[A-Z]_");
|
|---|
| 50 | TString ped = "", cal = "", data = "", source = "";
|
|---|
| 51 | if(pedfiles->GetEntries()!=0)
|
|---|
| 52 | source = pedfiles->GetFileName();
|
|---|
| 53 | else if(calfiles->GetEntries()!=0)
|
|---|
| 54 | source = calfiles->GetFileName();
|
|---|
| 55 | else
|
|---|
| 56 | source = datafiles->GetFileName();
|
|---|
| 57 |
|
|---|
| 58 | ped = pedfiles->GetFileName();
|
|---|
| 59 | if(calfiles->GetEntries()!=0)
|
|---|
| 60 | cal = calfiles->GetFileName();
|
|---|
| 61 | if(datafiles->GetEntries()!=0)
|
|---|
| 62 | data = datafiles->GetFileName();
|
|---|
| 63 |
|
|---|
| 64 | ped = ped(ped.Index(run)+1,5);
|
|---|
| 65 | cal = cal(cal.Index(run)+1,5);
|
|---|
| 66 | data = data(data.Index(run)+1,5);
|
|---|
| 67 |
|
|---|
| 68 | source = source(source.Index(type)+3,source.Length());
|
|---|
| 69 | source.Remove(source.Last('_'),source.Length());
|
|---|
| 70 |
|
|---|
| 71 | // cout << ped << endl;
|
|---|
| 72 | // cout << cal << endl;
|
|---|
| 73 | // cout << data << endl;
|
|---|
| 74 | // cout << source << endl;
|
|---|
| 75 |
|
|---|
| 76 | // **********************************************************************
|
|---|
| 77 | // ***************************** PEDESTALS ******************************
|
|---|
| 78 | // **********************************************************************
|
|---|
| 79 | if(pedfiles->GetEntries()==0)
|
|---|
| 80 | {
|
|---|
| 81 | cout << "Warning, no entries found in pedestal run(s)!!!"<< endl;
|
|---|
| 82 | break;
|
|---|
| 83 | }
|
|---|
| 84 | MParList plist;
|
|---|
| 85 | MTaskList tlist;
|
|---|
| 86 | plist.AddToList(&tlist);
|
|---|
| 87 |
|
|---|
| 88 | // pedfiles->Print("all");
|
|---|
| 89 | //
|
|---|
| 90 | // Now setup the tasks and tasklist for the pedestals:
|
|---|
| 91 | // ---------------------------------------------------
|
|---|
| 92 | //
|
|---|
| 93 |
|
|---|
| 94 | //tasks
|
|---|
| 95 | pedfiles->DisableAutoScheme();
|
|---|
| 96 | tlist.AddToList(pedfiles);
|
|---|
| 97 |
|
|---|
| 98 | // pedestal tasks and containers
|
|---|
| 99 | MGeomCamMagic geomcam;
|
|---|
| 100 | plist.AddToList(&geomcam);
|
|---|
| 101 | MPedestalCam pedcam;
|
|---|
| 102 | plist.AddToList(&pedcam);
|
|---|
| 103 |
|
|---|
| 104 | MGeomApply geomapl;
|
|---|
| 105 | tlist.AddToList(&geomapl);
|
|---|
| 106 | MPedCalcPedRun pedcalc;
|
|---|
| 107 | tlist.AddToList(&pedcalc);
|
|---|
| 108 |
|
|---|
| 109 | //
|
|---|
| 110 | // Create and setup the eventloop
|
|---|
| 111 | //
|
|---|
| 112 | MEvtLoop evtloop;
|
|---|
| 113 | evtloop.SetParList(&plist);
|
|---|
| 114 | if(!batchmode)
|
|---|
| 115 | evtloop.SetDisplay(d);
|
|---|
| 116 |
|
|---|
| 117 | //
|
|---|
| 118 | // Execute first analysis
|
|---|
| 119 | //
|
|---|
| 120 | cout << "*************************" << endl;
|
|---|
| 121 | cout << "** COMPUTING PEDESTALS **" << endl;
|
|---|
| 122 | cout << "*************************" << endl;
|
|---|
| 123 | if (!evtloop.Eventloop())
|
|---|
| 124 | return;
|
|---|
| 125 |
|
|---|
| 126 | tlist.PrintStatistics();
|
|---|
| 127 |
|
|---|
| 128 | //
|
|---|
| 129 | // Display the pedestal checking plots
|
|---|
| 130 | //
|
|---|
| 131 | if ((d = evtloop.GetDisplay()))
|
|---|
| 132 | TCanvas &c1 = d.AddTab("PEDESTALS");
|
|---|
| 133 | else
|
|---|
| 134 | TCanvas *c1 = new TCanvas();
|
|---|
| 135 | MHCamera meanped(geomcam,"MPedestalCam;ped","Pedestals");
|
|---|
| 136 | meanped.SetCamContent(pedcam, 0);
|
|---|
| 137 | meanped.SetCamError(pedcam, 1);
|
|---|
| 138 | MHCamera rmsped(geomcam,"MPedestalCam;var","Sigma Pedestal");
|
|---|
| 139 | rmsped.SetCamContent(pedcam, 2);
|
|---|
| 140 | c1->Divide(1,2);
|
|---|
| 141 | gPad->SetBorderMode(0);
|
|---|
| 142 | c1->cd(1);
|
|---|
| 143 | meanped.DrawClone("nonewEPhist");
|
|---|
| 144 | c1->cd(2);
|
|---|
| 145 | gPad->SetBorderMode(0);
|
|---|
| 146 | c = gPad;
|
|---|
| 147 | c->Divide(2,1);
|
|---|
| 148 | c->cd(1);
|
|---|
| 149 | meanped.DrawClone("nonewpixelindex");
|
|---|
| 150 | c->cd(2);
|
|---|
| 151 | rmsped.DrawClone("nonewpixelindex");
|
|---|
| 152 |
|
|---|
| 153 | //
|
|---|
| 154 | // Save canvas/display into a postcript file
|
|---|
| 155 | //
|
|---|
| 156 |
|
|---|
| 157 | if ((d = evtloop.GetDisplay()))
|
|---|
| 158 | d->SaveAsPS(directory+source+"_"+ped+"-"+cal+"-"+data+".ps");
|
|---|
| 159 | else
|
|---|
| 160 | c1->Print(directory+source+"_"+ped+"-"+cal+"-"+data+".ps(");
|
|---|
| 161 |
|
|---|
| 162 | if(calfiles->GetEntries()==0)
|
|---|
| 163 | c1->Print(directory+source+"_"+ped+"-"+cal+"-"+data+".ps]");
|
|---|
| 164 |
|
|---|
| 165 | // **********************************************************************
|
|---|
| 166 | // ***************************** CALIBRATION ****************************
|
|---|
| 167 | // **********************************************************************
|
|---|
| 168 | //
|
|---|
| 169 | // Create a empty Parameter List and an empty Task List
|
|---|
| 170 | //
|
|---|
| 171 | if(calfiles->GetEntries()==0)
|
|---|
| 172 | {
|
|---|
| 173 | cout << "Warning, no entries found in calibration run(s)!!!"<< endl;
|
|---|
| 174 | break;
|
|---|
| 175 | }
|
|---|
| 176 | MParList plist2;
|
|---|
| 177 | MTaskList tlist2;
|
|---|
| 178 | plist2.AddToList(&tlist2);
|
|---|
| 179 |
|
|---|
| 180 | // calfiles->Print("all");
|
|---|
| 181 | //
|
|---|
| 182 | // Now setup the new tasks and tasklist for the calibration
|
|---|
| 183 | // ---------------------------------------------------
|
|---|
| 184 | //
|
|---|
| 185 |
|
|---|
| 186 | calfiles->DisableAutoScheme();
|
|---|
| 187 | tlist2.AddToList(calfiles);
|
|---|
| 188 |
|
|---|
| 189 | MExtractedSignalCam sigcam;
|
|---|
| 190 | MArrivalTimeCam timecam;
|
|---|
| 191 | MBadPixelsCam badcam;
|
|---|
| 192 | MCalibrationChargeCam calcam;
|
|---|
| 193 | MCalibrationChargePINDiode pindiode;
|
|---|
| 194 | MCalibrationChargeBlindPix blindpix;
|
|---|
| 195 |
|
|---|
| 196 | MHCalibrationRelTimeCam histtime;
|
|---|
| 197 | MHCalibrationChargeCam histcharge;
|
|---|
| 198 | MHCalibrationChargePINDiode histpin;
|
|---|
| 199 | MHCalibrationChargeBlindPix histblind;
|
|---|
| 200 | //
|
|---|
| 201 | // As long, as we don't have digital modules,
|
|---|
| 202 | // we have to set the color of the pulser LED by hand
|
|---|
| 203 | //
|
|---|
| 204 | blindpix.SetColor(kCT1);
|
|---|
| 205 | pindiode.SetColor(kCT1);
|
|---|
| 206 | //
|
|---|
| 207 | // Get the previously created MPedestalCam and MGeomCamMagic
|
|---|
| 208 | // into the new Parameter List
|
|---|
| 209 | //
|
|---|
| 210 | plist2.AddToList(&pedcam);
|
|---|
| 211 | plist2.AddToList(&geomcam);
|
|---|
| 212 |
|
|---|
| 213 | plist2.AddToList(&sigcam);
|
|---|
| 214 | plist2.AddToList(&timecam);
|
|---|
| 215 | plist2.AddToList(&badcam);
|
|---|
| 216 | plist2.AddToList(&calcam);
|
|---|
| 217 | plist2.AddToList(&histtime);
|
|---|
| 218 | plist2.AddToList(&histcharge);
|
|---|
| 219 | plist2.AddToList(&histpin);
|
|---|
| 220 | plist2.AddToList(&histblind);
|
|---|
| 221 |
|
|---|
| 222 | //
|
|---|
| 223 | // We saw that the signal jumps between slices,
|
|---|
| 224 | // thus take the sliding window
|
|---|
| 225 | //
|
|---|
| 226 | MExtractSignal2 sigcalc2;
|
|---|
| 227 | MExtractPINDiode pincalc;
|
|---|
| 228 | MExtractBlindPixel blindcalc;
|
|---|
| 229 | MArrivalTimeCalc2 timecalc;
|
|---|
| 230 | MCalibrationChargeCalc calcalc;
|
|---|
| 231 |
|
|---|
| 232 | MFillH filltime( "MHCalibrationRelTimeCam" , "MArrivalTimeCam");
|
|---|
| 233 | MFillH fillpin ("MHCalibrationChargePINDiode", "MExtractedSignalPINDiode");
|
|---|
| 234 | MFillH fillblind("MHCalibrationChargeBlindPix", "MExtractedSignalBlindPixel");
|
|---|
| 235 | MFillH fillcam ("MHCalibrationChargeCam" , "MExtractedSignalCam");
|
|---|
| 236 |
|
|---|
| 237 | // Skip the MFillH draw function
|
|---|
| 238 | filltime.SetBit(MFillH::kDoNotDisplay);
|
|---|
| 239 | fillpin.SetBit(MFillH::kDoNotDisplay);
|
|---|
| 240 | fillblind.SetBit(MFillH::kDoNotDisplay);
|
|---|
| 241 | fillcam.SetBit(MFillH::kDoNotDisplay);
|
|---|
| 242 |
|
|---|
| 243 | //
|
|---|
| 244 | // Skip the HiGain vs. LoGain calibration
|
|---|
| 245 | //
|
|---|
| 246 | calcalc.SkipHiLoGainCalibration();
|
|---|
| 247 |
|
|---|
| 248 | //
|
|---|
| 249 | // Apply a filter against cosmics
|
|---|
| 250 | // (was directly in MCalibrationCalc in earlier versions)
|
|---|
| 251 | //
|
|---|
| 252 | MFCosmics cosmics;
|
|---|
| 253 | MContinue cont(&cosmics);
|
|---|
| 254 | //
|
|---|
| 255 | // Get the previously created MGeomApply into the new Task List
|
|---|
| 256 | //
|
|---|
| 257 | tlist2.AddToList(&geomapl);
|
|---|
| 258 |
|
|---|
| 259 | tlist2.AddToList(&sigcalc2);
|
|---|
| 260 | tlist2.AddToList(&pincalc);
|
|---|
| 261 | tlist2.AddToList(&blindcalc);
|
|---|
| 262 | //
|
|---|
| 263 | // In case, you want to skip the cosmics rejection,
|
|---|
| 264 | // uncomment the next line
|
|---|
| 265 | //
|
|---|
| 266 | tlist2.AddToList(&cont);
|
|---|
| 267 | //
|
|---|
| 268 | // In case, you want to skip the somewhat lengthy calculation
|
|---|
| 269 | // of the arrival times using a spline, uncomment the next two lines
|
|---|
| 270 | //
|
|---|
| 271 | tlist2.AddToList(&timecalc);
|
|---|
| 272 | tlist2.AddToList(&filltime);
|
|---|
| 273 |
|
|---|
| 274 | tlist2.AddToList(&fillpin);
|
|---|
| 275 | tlist2.AddToList(&fillblind);
|
|---|
| 276 | tlist2.AddToList(&fillcam);
|
|---|
| 277 | tlist2.AddToList(&calcalc);
|
|---|
| 278 |
|
|---|
| 279 | //
|
|---|
| 280 | // Create and setup the eventloop
|
|---|
| 281 | //
|
|---|
| 282 | MEvtLoop evtloop2;
|
|---|
| 283 | evtloop2.SetParList(&plist2);
|
|---|
| 284 | if(!batchmode)
|
|---|
| 285 | evtloop2.SetDisplay(d);
|
|---|
| 286 |
|
|---|
| 287 | //
|
|---|
| 288 | // Execute second analysis
|
|---|
| 289 | //
|
|---|
| 290 | cout << "***********************************" << endl;
|
|---|
| 291 | cout << "** COMPUTING CALIBRATION FACTORS **" << endl;
|
|---|
| 292 | cout << "***********************************" << endl;
|
|---|
| 293 | if (!evtloop2.Eventloop())
|
|---|
| 294 | return;
|
|---|
| 295 |
|
|---|
| 296 | tlist2.PrintStatistics();
|
|---|
| 297 |
|
|---|
| 298 | //
|
|---|
| 299 | // print the most important results of all pixels to a file
|
|---|
| 300 | //
|
|---|
| 301 | // MLog gauglog;
|
|---|
| 302 | // gauglog.SetOutputFile(Form("%s%s",calcam.GetName(),".txt"),1);
|
|---|
| 303 | // calcam.SetLogStream(&gauglog);
|
|---|
| 304 | // calcam.Print();
|
|---|
| 305 | // calcam.SetLogStream(&gLog);
|
|---|
| 306 |
|
|---|
| 307 | TH1 *hist;
|
|---|
| 308 |
|
|---|
| 309 | //
|
|---|
| 310 | // Display the calibration checking plots
|
|---|
| 311 | //
|
|---|
| 312 | // ---------------------- Conversion factor ---------------------------
|
|---|
| 313 | if ((d = evtloop2.GetDisplay()))
|
|---|
| 314 | TCanvas &c2 = d.AddTab("CONV FACTOR");
|
|---|
| 315 | else
|
|---|
| 316 | TCanvas *c2 = new TCanvas();
|
|---|
| 317 | c2->Divide(1,2);
|
|---|
| 318 | c2->cd(1);
|
|---|
| 319 | gPad->SetBorderMode(0);
|
|---|
| 320 | c = gPad;
|
|---|
| 321 | c->Divide(2,1);
|
|---|
| 322 | gPad->SetBorderMode(0);
|
|---|
| 323 | c->cd(1);
|
|---|
| 324 | gPad->SetBorderMode(0);
|
|---|
| 325 | MHCamera ConvFfactor(geomcam,"Cal;FFactorConv","Conversion Factor to photons (F-Factor method)");
|
|---|
| 326 | ConvFfactor.SetCamContent(calcam, 11);
|
|---|
| 327 | ConvFfactor.DrawClone("nonewpixelindex");
|
|---|
| 328 | c->cd(2);
|
|---|
| 329 | MHCamera ConvBlindPix(geomcam,"Cal;BlindPixConv","Conversion Factor to photons (Blind Pixel method)");
|
|---|
| 330 | ConvBlindPix.SetCamContent(calcam, 17);
|
|---|
| 331 | ConvBlindPix.DrawClone("nonewpixelindex");
|
|---|
| 332 | c2->cd(2);
|
|---|
| 333 | gPad->SetBorderMode(0);
|
|---|
| 334 | MHCamera ConvPINDiode(geomcam,"Cal;PINDiodeConv","Conversion Factor to photons (PINDiode method)");
|
|---|
| 335 | ConvPINDiode.SetCamContent(calcam, 23);
|
|---|
| 336 | ConvPINDiode.DrawClone("nonewpixelindex");
|
|---|
| 337 | // ----------------- Pixels with defects ------------------------------
|
|---|
| 338 | if ((d = evtloop2.GetDisplay()))
|
|---|
| 339 | TCanvas &c3 = d.AddTab("DEFECT PIXELS");
|
|---|
| 340 | else
|
|---|
| 341 | TCanvas *c3 = new TCanvas();
|
|---|
| 342 | c3->Divide(3,2);
|
|---|
| 343 | c3->cd(1);
|
|---|
| 344 | MHCamera PixExc(geomcam,"Cal;Excluded","Pixels previously excluded");
|
|---|
| 345 | PixExc.SetCamContent(calcam, 27);
|
|---|
| 346 | PixExc.DrawClone("nonewpixelindex");
|
|---|
| 347 | c3->cd(2);
|
|---|
| 348 | MHCamera PixNoFit(geomcam,"Cal;NotFitted","Pixels that could not be fitted");
|
|---|
| 349 | PixNoFit.SetCamContent(calcam, 28);
|
|---|
| 350 | PixNoFit.DrawClone("nonewpixelindex");
|
|---|
| 351 | c3->cd(3);
|
|---|
| 352 | MHCamera PixNoValid(geomcam,"Cal;NotValidFit","Pixels with not valid fit results");
|
|---|
| 353 | PixNoValid.SetCamContent(calcam, 29);
|
|---|
| 354 | PixNoValid.DrawClone("nonewpixelindex");
|
|---|
| 355 | c3->cd(4);
|
|---|
| 356 | MHCamera PixFFactor(geomcam,"Cal;FFactorValid","Pixels with valid F-Factor calibration");
|
|---|
| 357 | PixFFactor.SetCamContent(calcam, 35);
|
|---|
| 358 | PixFFactor.DrawClone("nonewpixelindex");
|
|---|
| 359 | c3->cd(5);
|
|---|
| 360 | MHCamera PixBlind(geomcam,"Cal;BlindPixelValid","Pixels with valid BlindPixel calibration");
|
|---|
| 361 | PixBlind.SetCamContent(calcam, 36);
|
|---|
| 362 | PixBlind.DrawClone("nonewpixelindex");
|
|---|
| 363 | c3->cd(6);
|
|---|
| 364 | MHCamera PixPINDiode(geomcam,"Cal;PINdiodeFFactorValid","Pixels with valid PINDiode calibration");
|
|---|
| 365 | PixPINDiode.SetCamContent(calcam, 37);
|
|---|
| 366 | PixPINDiode.DrawClone("nonewpixelindex");
|
|---|
| 367 | // ------------------------- Fitted mean charges ----------------------------
|
|---|
| 368 | if ((d = evtloop2.GetDisplay()))
|
|---|
| 369 | TCanvas &c4 = d.AddTab("FIT CHARGES");
|
|---|
| 370 | else
|
|---|
| 371 | TCanvas *c4 = new TCanvas();
|
|---|
| 372 | c4->Divide(1,2);
|
|---|
| 373 | MHCamera fitmeancharge(geomcam,"Cal;Charge","Fitted Mean Charges");
|
|---|
| 374 | fitmeancharge.SetCamContent(calcam, 0);
|
|---|
| 375 | fitmeancharge.SetCamError(calcam, 1);
|
|---|
| 376 | c4->cd(1);
|
|---|
| 377 | gPad->SetBorderMode(0);
|
|---|
| 378 | fitmeancharge.DrawClone("nonewEPhist");
|
|---|
| 379 | c4->cd(2);
|
|---|
| 380 | c = gPad;
|
|---|
| 381 | gPad->SetBorderMode(0);
|
|---|
| 382 | c->Divide(2,1);
|
|---|
| 383 | c->cd(1);
|
|---|
| 384 | gPad->SetBorderMode(0);
|
|---|
| 385 | fitmeancharge.DrawClone("nonewpixelindex");
|
|---|
| 386 | c->cd(2);
|
|---|
| 387 | gPad->SetBorderMode(0);
|
|---|
| 388 | hist = (TH1*)fitmeancharge->Projection("Charge");
|
|---|
| 389 | hist->SetXTitle("Charge");
|
|---|
| 390 | hist->DrawCopy("hist");
|
|---|
| 391 | // ----------------------- Reduced Sigma per Charge -------------------------
|
|---|
| 392 | if ((d = evtloop2.GetDisplay()))
|
|---|
| 393 | TCanvas &c5 = d.AddTab("RED SIGMA");
|
|---|
| 394 | else
|
|---|
| 395 | TCanvas *c5 = new TCanvas();
|
|---|
| 396 | c5->Divide(1,2);
|
|---|
| 397 | MHCamera redsigmacharge(geomcam,"Cal;RSigmaCharge","Reduced Sigma per Charge");
|
|---|
| 398 | redsigmacharge.SetCamContent(calcam, 7);
|
|---|
| 399 | redsigmacharge.SetCamError(calcam, 8);
|
|---|
| 400 | c5->cd(1);
|
|---|
| 401 | gPad->SetBorderMode(0);
|
|---|
| 402 | redsigmacharge.DrawClone("nonewEPhist");
|
|---|
| 403 | c5->cd(2);
|
|---|
| 404 | c = gPad;
|
|---|
| 405 | gPad->SetBorderMode(0);
|
|---|
| 406 | c->Divide(2,1);
|
|---|
| 407 | c->cd(1);
|
|---|
| 408 | gPad->SetBorderMode(0);
|
|---|
| 409 | redsigmacharge.DrawClone("nonewpixelindex");
|
|---|
| 410 | c->cd(2);
|
|---|
| 411 | gPad->SetBorderMode(0);
|
|---|
| 412 | hist = redsigmacharge->Projection("RSigmaCharge");
|
|---|
| 413 | hist->SetXTitle("Reduced Sigma per Charge");
|
|---|
| 414 | hist->Draw("hist");
|
|---|
| 415 | // ----------------------- Absolute arrival times -------------------------
|
|---|
| 416 | if ((d = evtloop2.GetDisplay()))
|
|---|
| 417 | TCanvas &c6 = d.AddTab("ABS TIMES");
|
|---|
| 418 | else
|
|---|
| 419 | TCanvas *c6 = new TCanvas();
|
|---|
| 420 | c6->Divide(1,2);
|
|---|
| 421 | MHCamera abstime(geomcam,"Cal;AbsTimeMean","Absolute Arrival Times");
|
|---|
| 422 | abstime.SetCamContent(calcam, 42);
|
|---|
| 423 | abstime.SetCamError(calcam, 43);
|
|---|
| 424 | c6->cd(1);
|
|---|
| 425 | gPad->SetBorderMode(0);
|
|---|
| 426 | abstime.DrawClone("nonewEPhist");
|
|---|
| 427 | c6->cd(2);
|
|---|
| 428 | c = gPad;
|
|---|
| 429 | gPad->SetBorderMode(0);
|
|---|
| 430 | c->Divide(2,1);
|
|---|
| 431 | c->cd(1);
|
|---|
| 432 | gPad->SetBorderMode(0);
|
|---|
| 433 | abstime.DrawClone("nonewpixelindex");
|
|---|
| 434 | c->cd(2);
|
|---|
| 435 | gPad->SetBorderMode(0);
|
|---|
| 436 | hist = (TH1*)abstime->Projection("AbsTimeMean");
|
|---|
| 437 | hist->SetXTitle("Absolute arrival time (time slice)");
|
|---|
| 438 | hist->DrawCopy("hist");
|
|---|
| 439 |
|
|---|
| 440 | //
|
|---|
| 441 | // Save canvas/display into a postcript file
|
|---|
| 442 | //
|
|---|
| 443 |
|
|---|
| 444 | if ((d = evtloop2.GetDisplay()))
|
|---|
| 445 | d->SaveAsPS(directory+source+"_"+ped+"-"+cal+"-"+data+".ps");
|
|---|
| 446 | else
|
|---|
| 447 | {
|
|---|
| 448 | c2->Print(directory+source+"_"+ped+"-"+cal+"-"+data+".ps");
|
|---|
| 449 | c3->Print(directory+source+"_"+ped+"-"+cal+"-"+data+".ps");
|
|---|
| 450 | c4->Print(directory+source+"_"+ped+"-"+cal+"-"+data+".ps");
|
|---|
| 451 | c5->Print(directory+source+"_"+ped+"-"+cal+"-"+data+".ps");
|
|---|
| 452 | c6->Print(directory+source+"_"+ped+"-"+cal+"-"+data+".ps");
|
|---|
| 453 | }
|
|---|
| 454 |
|
|---|
| 455 | if(calfiles->GetEntries()!=0)
|
|---|
| 456 | c6->Print(directory+source+"_"+ped+"-"+cal+"-"+data+".ps]");
|
|---|
| 457 |
|
|---|
| 458 | // ********************************************************************
|
|---|
| 459 | // ***************************** DATA *********************************
|
|---|
| 460 | // ********************************************************************
|
|---|
| 461 |
|
|---|
| 462 | if(datafiles->GetEntries()==0)
|
|---|
| 463 | {
|
|---|
| 464 | cout << "Warning, no entries found in data run(s)!!!"<< endl;
|
|---|
| 465 | break;
|
|---|
| 466 | }
|
|---|
| 467 | //
|
|---|
| 468 | // Create an empty Parameter List and an empty Task List
|
|---|
| 469 | //
|
|---|
| 470 | MParList plist3;
|
|---|
| 471 | MTaskList tlist3;
|
|---|
| 472 | plist3.AddToList(&tlist3);
|
|---|
| 473 |
|
|---|
| 474 | // datafiles->Print("all");
|
|---|
| 475 | //
|
|---|
| 476 | // Now setup the new tasks and tasklist for the data
|
|---|
| 477 | // ---------------------------------------------------
|
|---|
| 478 | //
|
|---|
| 479 |
|
|---|
| 480 | datafiles->DisableAutoScheme();
|
|---|
| 481 | tlist3.AddToList(datafiles);
|
|---|
| 482 |
|
|---|
| 483 | // Task containers
|
|---|
| 484 | MExtractedSignalCam sigcam;
|
|---|
| 485 | //
|
|---|
| 486 | // Get the previously created MPedestalCam and MGeomCamMagic
|
|---|
| 487 | // into the new Parameter List
|
|---|
| 488 | //
|
|---|
| 489 | plist3.AddToList(&geomcam);
|
|---|
| 490 | plist3.AddToList(&pedcam);
|
|---|
| 491 |
|
|---|
| 492 | plist3.AddToList(&sigcam);
|
|---|
| 493 |
|
|---|
| 494 | // Display containers
|
|---|
| 495 | MHTimeDiffTime difftime("DiffTime","Differential time between events");
|
|---|
| 496 | plist3.AddToList(&difftime);
|
|---|
| 497 | MBinning binsdifftime("BinningTimeDiff");
|
|---|
| 498 | binsdifftime.SetEdges(200, 0., 0.2);
|
|---|
| 499 | plist3.AddToList(&binsdifftime);
|
|---|
| 500 | MBinning binstime("BinningTime");
|
|---|
| 501 | binstime.SetEdges(10000, 0., 1e10);
|
|---|
| 502 | plist3.AddToList(&binstime);
|
|---|
| 503 |
|
|---|
| 504 | // Data tasks
|
|---|
| 505 | MExtractSignal2 signal2;
|
|---|
| 506 |
|
|---|
| 507 | MFillH fillDiffTime(&difftime,"MRawEvtData");
|
|---|
| 508 | fillDiffTime.SetBit(MFillH::kDoNotDisplay);
|
|---|
| 509 | tlist3.AddToList(&fillDiffTime);
|
|---|
| 510 |
|
|---|
| 511 | //
|
|---|
| 512 | // Get the previously created MGeomApply into the new Task List
|
|---|
| 513 | //
|
|---|
| 514 | tlist3.AddToList(&geomapl);
|
|---|
| 515 | tlist3.AddToList(&signal2);
|
|---|
| 516 |
|
|---|
| 517 | //
|
|---|
| 518 | // Create and setup the eventloop
|
|---|
| 519 | //
|
|---|
| 520 | MEvtLoop evtloop3;
|
|---|
| 521 | evtloop3.SetParList(&plist3);
|
|---|
| 522 | if(!batchmode)
|
|---|
| 523 | evtloop3.SetDisplay(d);
|
|---|
| 524 |
|
|---|
| 525 | //
|
|---|
| 526 | // Execute third analysis
|
|---|
| 527 | //
|
|---|
| 528 | cout << "********************" << endl;
|
|---|
| 529 | cout << "** COMPUTING DATA **" << endl;
|
|---|
| 530 | cout << "********************" << endl;
|
|---|
| 531 | if (!evtloop3.Eventloop())
|
|---|
| 532 | return;
|
|---|
| 533 |
|
|---|
| 534 | tlist3.PrintStatistics();
|
|---|
| 535 |
|
|---|
| 536 | TH1 *hist1;
|
|---|
| 537 | TH2 *hist2;
|
|---|
| 538 |
|
|---|
| 539 | //
|
|---|
| 540 | // Display the data checking canvas
|
|---|
| 541 | //
|
|---|
| 542 | // -------------------- Diffential time of events ---------------------
|
|---|
| 543 | if ((d = evtloop3.GetDisplay()))
|
|---|
| 544 | TCanvas &c9 = d.AddTab("TIME");
|
|---|
| 545 | else
|
|---|
| 546 | TCanvas *c9 = new TCanvas();
|
|---|
| 547 | gStyle->SetPadGridX(kTRUE);
|
|---|
| 548 | gStyle->SetPadGridY(kTRUE);
|
|---|
| 549 | gStyle->SetOptFit();
|
|---|
| 550 | c9->Divide(2,2);
|
|---|
| 551 | hist2 = difftime.GetHist();
|
|---|
| 552 | c9->cd(1);
|
|---|
| 553 | gPad->SetLogy();
|
|---|
| 554 | hist1 = hist2->ProjectionX("ProjX_sumtime", -1, 9999, "E");
|
|---|
| 555 | hist1->SetTitle("Distribution of \\Delta t [s]");
|
|---|
| 556 | hist1->SetXTitle("\\Delta t [s]");
|
|---|
| 557 | hist1->SetYTitle("Counts");
|
|---|
| 558 | hist1->GetXaxis()->SetRange(0,hist1->GetXaxis()->GetNbins());
|
|---|
| 559 | TF1 *f1 = new TF1("f1","[0]*exp(x*[1])",hist1->GetMaximumBin(),hist1->GetXaxis()->GetXmax());
|
|---|
| 560 | hist1->Fit(f1,"");
|
|---|
| 561 | hist1->DrawCopy();
|
|---|
| 562 | c9->cd(2);
|
|---|
| 563 | gPad->SetLogy();
|
|---|
| 564 | hist1 = hist2->ProjectionX("ProjX_sumtime", -1, 9999, "E");
|
|---|
| 565 | hist1->SetTitle("Distribution of \\Delta t [s] (deadtime)");
|
|---|
| 566 | hist1->SetXTitle("\\Delta t [s]");
|
|---|
| 567 | hist1->SetYTitle("Counts");
|
|---|
| 568 | // cout << hist1->GetXaxis()->GetBinCenter(hist1->GetMaximumBin())<< endl;
|
|---|
| 569 | hist1->GetXaxis()->SetRange(0,hist1->GetMaximumBin());
|
|---|
| 570 | hist1->DrawCopy();
|
|---|
| 571 | c9->cd(3);
|
|---|
| 572 | hist1 = difftime.GetHist()->ProjectionY("ProjY_sumtime", -1, 9999, "E");
|
|---|
| 573 | hist1->SetTitle("Distribution of time [s]");
|
|---|
| 574 | hist1->SetXTitle("Time t [s]");
|
|---|
| 575 | hist1->SetYTitle("Counts");
|
|---|
| 576 | hist1->DrawCopy();
|
|---|
| 577 | c9->cd(4);
|
|---|
| 578 |
|
|---|
| 579 | //
|
|---|
| 580 | // Save canvas/display into a postcript file
|
|---|
| 581 | //
|
|---|
| 582 |
|
|---|
| 583 | if ((d = evtloop3.GetDisplay()))
|
|---|
| 584 | d->SaveAsPS(directory+source+"_"+ped+"-"+cal+"-"+data+".ps");
|
|---|
| 585 | else
|
|---|
| 586 | {
|
|---|
| 587 | c9->Print(directory+source+"_"+ped+"-"+cal+"-"+data+".ps)");
|
|---|
| 588 | }
|
|---|
| 589 |
|
|---|
| 590 | }
|
|---|
| 591 |
|
|---|
| 592 | void DAQDataCheck(const TString directory="/remote/data2/data/Magic-DATA/Period014/rootdata/2004_02_10/")
|
|---|
| 593 | {
|
|---|
| 594 |
|
|---|
| 595 | MDirIter Next;
|
|---|
| 596 | Next.AddDirectory(directory,"*_E.root",-1);
|
|---|
| 597 |
|
|---|
| 598 | // Next.Print("all");
|
|---|
| 599 |
|
|---|
| 600 | TString fName="file.root";
|
|---|
| 601 |
|
|---|
| 602 | MReadMarsFile *pedfiles;
|
|---|
| 603 | MReadMarsFile *calfiles;
|
|---|
| 604 | MReadMarsFile *datafiles;
|
|---|
| 605 |
|
|---|
| 606 | TString source="";
|
|---|
| 607 |
|
|---|
| 608 | fName = Next(); // absolut path
|
|---|
| 609 |
|
|---|
| 610 | while(!fName.IsNull())
|
|---|
| 611 | {
|
|---|
| 612 |
|
|---|
| 613 | TString file = fName(fName.Last('/')+1,fName.Length()); // root file name
|
|---|
| 614 | file = file(0,file.Last('_'));
|
|---|
| 615 |
|
|---|
| 616 | // TString run = file(file.First('_')+1,5);
|
|---|
| 617 | // TString type = file(file.Index('_',file.First('_')+1)+1,1);
|
|---|
| 618 | source = file(file.Last('_')+1,file.Length());
|
|---|
| 619 |
|
|---|
| 620 | // Pedestal runs
|
|---|
| 621 | if(fName.Contains("_P_"))
|
|---|
| 622 | pedfiles = new MReadMarsFile("Events");
|
|---|
| 623 | else
|
|---|
| 624 | pedfiles->Rewind();
|
|---|
| 625 |
|
|---|
| 626 | while(fName.Contains("_P_")&&fName.Contains(source))
|
|---|
| 627 | {
|
|---|
| 628 | pedfiles->AddFile(fName);
|
|---|
| 629 | fName = Next();
|
|---|
| 630 | }
|
|---|
| 631 |
|
|---|
| 632 | // Calibration runs
|
|---|
| 633 | if(fName.Contains("_C_")||(!fName.Contains(source)))
|
|---|
| 634 | calfiles = new MReadMarsFile("Events");
|
|---|
| 635 | else
|
|---|
| 636 | calfiles->Rewind();
|
|---|
| 637 |
|
|---|
| 638 | while(fName.Contains("_C_")&&fName.Contains(source))
|
|---|
| 639 | {
|
|---|
| 640 | calfiles->AddFile(fName);
|
|---|
| 641 | fName = Next();
|
|---|
| 642 | }
|
|---|
| 643 |
|
|---|
| 644 | // Data runs
|
|---|
| 645 | if(fName.Contains("_D_")||(!fName.Contains(source)))
|
|---|
| 646 | datafiles = new MReadMarsFile("Events");
|
|---|
| 647 | // else
|
|---|
| 648 | // break;
|
|---|
| 649 | while(fName.Contains("_D_")&&fName.Contains(source))
|
|---|
| 650 | {
|
|---|
| 651 | datafiles->AddFile(fName);
|
|---|
| 652 | fName = Next();
|
|---|
| 653 | }
|
|---|
| 654 |
|
|---|
| 655 | // pedfiles->Print();
|
|---|
| 656 | // calfiles->Print("all");
|
|---|
| 657 | // datafiles->Print("all");
|
|---|
| 658 |
|
|---|
| 659 | DataAnalysis(pedfiles,calfiles,datafiles,directory);
|
|---|
| 660 |
|
|---|
| 661 | cout << "----------------------------------------------" << endl;
|
|---|
| 662 |
|
|---|
| 663 | }
|
|---|
| 664 |
|
|---|
| 665 | }
|
|---|
| 666 |
|
|---|
| 667 |
|
|---|
| 668 |
|
|---|