source: trunk/MagicSoft/Mars/mjobs/MJPedestal.cc@ 6820

Last change on this file since 6820 was 6820, checked in by tbretz, 20 years ago
*** empty log message ***
File size: 40.4 KB
Line 
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): Thomas Bretz, 1/2004 <mailto:tbretz@astro.uni-wuerzburg.de>
19! Author(s): Markus Gaug, 4/2004 <mailto:markus@ifae.es>
20!
21! Copyright: MAGIC Software Development, 2000-2005
22!
23!
24\* ======================================================================== */
25
26/////////////////////////////////////////////////////////////////////////////
27//
28// MJPedestal
29//
30// Resource file entries are case sensitive!
31//
32/////////////////////////////////////////////////////////////////////////////
33#include "MJPedestal.h"
34
35// root classes
36#include <TF1.h>
37#include <TEnv.h>
38#include <TFile.h>
39#include <TLine.h>
40#include <TLatex.h>
41#include <TString.h>
42#include <TCanvas.h>
43#include <TSystem.h>
44#include <TLegend.h>
45#include <TPad.h>
46#include <TEnv.h>
47#include <TH2F.h>
48
49// mars core
50#include "MLog.h"
51#include "MLogManip.h"
52
53#include "MTaskEnv.h"
54#include "MSequence.h"
55#include "MRunIter.h"
56#include "MParList.h"
57#include "MTaskList.h"
58#include "MEvtLoop.h"
59
60#include "MStatusDisplay.h"
61#include "MFEventSelector.h"
62
63// Other basic classes
64#include "MExtractTimeAndCharge.h"
65
66// parameter containers
67#include "MGeomCam.h"
68#include "MHCamera.h"
69#include "MPedestalPix.h"
70
71#include "MCalibrationPedCam.h"
72#include "MCalibrationPix.h"
73#include "MHPedestalPix.h"
74#include "MHCalibrationPulseTimeCam.h"
75#include "MCalibrationPulseTimeCam.h"
76
77// tasks
78#include "MReadMarsFile.h"
79#include "MRawFileRead.h"
80#include "MRawEvtData.h"
81#include "MGeomApply.h"
82#include "MBadPixelsMerge.h"
83#include "MFillH.h"
84#include "MPedCalcPedRun.h"
85#include "MPedCalcFromLoGain.h"
86#include "MFTriggerPattern.h"
87
88#include <fstream>
89
90ClassImp(MJPedestal);
91
92using namespace std;
93
94const TString MJPedestal::fgReferenceFile = "mjobs/pedestalref.rc";
95const TString MJPedestal::fgBadPixelsFile = "mjobs/badpixels_0_559.rc";
96const Float_t MJPedestal::fgExtractWinLeft = 2.5;
97const Float_t MJPedestal::fgExtractWinRight = 5.0;
98// --------------------------------------------------------------------------
99//
100// Default constructor.
101//
102// Sets:
103// - fExtractor to NULL,
104// - fExtractType to kUsePedRun
105// - fStorage to Normal Storage
106// - fExtractorResolution to kFALSE
107//
108MJPedestal::MJPedestal(const char *name, const char *title)
109 : fExtractor(NULL), fDisplayType(kDisplayDataCheck),
110 fExtractType(kUsePedRun), fExtractionType(kFundamental), fIsUseHists(kFALSE)
111{
112 fName = name ? name : "MJPedestal";
113 fTitle = title ? title : "Tool to create a pedestal file (MPedestalCam)";
114
115 SetUsePedRun();
116 SetPathIn("");
117 SetReferenceFile();
118 SetBadPixelsFile();
119
120 SetExtractWinLeft();
121 SetExtractWinRight();
122 //
123 // Default references for case that no value references file is there
124 // (should not occur)
125 //
126
127 fPedestalMin = 4.;
128 fPedestalMax = 16.;
129 fPedRmsMin = 0.;
130 fPedRmsMax = 20.;
131 fRefPedClosedLids = 9.635;
132 fRefPedExtraGalactic = 9.93;
133 fRefPedGalactic = 10.03;
134 fRefPedRmsClosedLidsInner = 1.7;
135 fRefPedRmsExtraGalacticInner = 5.6;
136 fRefPedRmsGalacticInner = 6.92;
137 fRefPedRmsClosedLidsOuter = 1.7;
138 fRefPedRmsExtraGalacticOuter = 3.35;
139 fRefPedRmsGalacticOuter = 4.2;
140}
141
142MJPedestal::~MJPedestal()
143{
144 if (fExtractor)
145 delete fExtractor;
146}
147
148const char* MJPedestal::GetOutputFile() const
149{
150 const TString name(GetOutputFileName());
151 if (name.IsNull())
152 return "";
153
154 return Form("%s/%s", fPathOut.Data(), name.Data());
155}
156
157const char* MJPedestal::GetOutputFileName() const
158{
159
160 if (fSequence.IsValid())
161 return Form("pedest%08d.root", fSequence.GetSequence());
162
163 if (!fRuns)
164 return "";
165
166 return Form("%s-F0.root", (const char*)fRuns->GetRunsAsFileName());
167}
168
169//---------------------------------------------------------------------------------
170//
171// Try to read an existing MPedestalCam from a previously created output file.
172// If found, also an MBadPixelsCam and the corresponding display is read.
173//
174// In case of Storage type "kNoStorage" or if the file is not found or the
175// MPedestalCam cannot be read, return kFALSE, otherwise kTRUE.
176//
177Bool_t MJPedestal::ReadPedestalCam()
178{
179 const TString fname = GetOutputFile();
180
181 const Bool_t fileexist = !gSystem->AccessPathName(fname, kFileExists);
182 if (!fileexist)
183 {
184 *fLog << inf << "Input file " << fname << " not found, will create pedestals" << endl;
185 return kFALSE;
186 }
187
188 *fLog << inf << "Reading pedestals from file: " << fname << endl;
189
190 TFile file(fname, "READ");
191 if (fPedestalCamIn.Read()<=0)
192 {
193 *fLog << err << "Unable to read incoming MPedestalCam from " << fname << endl;
194 return kFALSE;
195 }
196
197 if (fPedestalCamOut.Read()<=0)
198 {
199 *fLog << err << "Unable to read outgoing MPedestalCam from " << fname << endl;
200 return kFALSE;
201 }
202
203 if (file.FindKey("MBadPixelsCam"))
204 {
205 MBadPixelsCam bad;
206 if (bad.Read()<=0)
207 {
208 *fLog << err << "Unable to read MBadPixelsCam from " << fname << endl;
209 return kFALSE;
210 }
211 fBadPixels.Merge(bad);
212 }
213
214 if (fDisplay && !fDisplay->GetCanvas("Pedestals"))
215 fDisplay->Read();
216
217 return kTRUE;
218}
219
220MExtractor *MJPedestal::ReadCalibration() const
221{
222 const TString fname = Form("%s/calib%08d.root",fPathIn.Data(), fSequence.GetSequence());
223
224 *fLog << inf << "Reading extractor from file: " << fname << endl;
225
226 TFile file(fname, "READ");
227 if (!file.IsOpen())
228 {
229 *fLog << err << dbginf << "ERROR - Could not open file " << fname << endl;
230 return NULL;
231 }
232
233 TObject *o = file.Get("ExtractSignal");
234 if (o && !o->InheritsFrom(MExtractor::Class()))
235 {
236 *fLog << err << dbginf << "ERROR - ExtractSignal read from " << fname << " doesn't inherit from MExtractor!" << endl;
237 return NULL;
238 }
239
240 return o ? (MExtractor*)o->Clone("ExtractSignal") : NULL;
241}
242
243Bool_t MJPedestal::WriteExtractor() const
244{
245
246 const TString name = Form("pedy%08d.root",fSequence.GetSequence());
247 const TString fname = Form("%s/%s",fPathIn.Data(),name.Data());
248
249 *fLog << inf << "Updating extractor in file: " << fname << endl;
250
251 TFile file(fname, fOverwrite?"RECREATE":"NEW");
252 if (!file.IsOpen())
253 {
254 *fLog << err << dbginf << "ERROR - Could not open file " << fname << endl;
255 *fLog << err << dbginf << "Maybe, file " << fname << " already exists, call callisto with option -f then." << endl;
256 return kFALSE;
257 }
258
259 TObjArray cont;
260 cont.Add(fExtractor);
261
262 return WriteContainer(cont);
263}
264
265//---------------------------------------------------------------------------------
266//
267// Display the results.
268// If Display type "kDataCheck" was chosen, also the reference lines are displayed.
269//
270void MJPedestal::DisplayResult(MParList &plist)
271{
272 if (!fDisplay)
273 return;
274
275 //
276 // Update display
277 //
278 TString title = fDisplay->GetTitle();
279 title += "-- Pedestal ";
280 if (fSequence.IsValid())
281 title += fSequence.GetName();
282 else
283 if (fRuns) // FIXME: What to do if an environmentfile was used?
284 title += fRuns->GetRunsAsString();
285 title += " --";
286 fDisplay->SetTitle(title);
287
288 //
289 // Get container from list
290 //
291 MGeomCam &geomcam = *(MGeomCam*)plist.FindObject("MGeomCam");
292 // MCalibrationPedCam &calpedcam = *(MCalibrationPedCam*)plist.FindObject("MCalibrationPedCam");
293
294 //
295 // Create container to display
296 //
297 MHCamera disp0 (geomcam, "MPedestalCam;ped", "Mean Pedestal");
298 MHCamera disp1 (geomcam, "MPedestalCam;RMS", "Pedestal RMS");
299 MHCamera disp2 (geomcam, "MCalibPedCam;histmean", "Mean Pedestal (Hist.)");
300 MHCamera disp3 (geomcam, "MCalibPedCam;histsigma", "Pedestal RMS (Hist.)");
301 MHCamera disp4 (geomcam, "MCalibPedCam;ped", "Mean Pedestal");
302 MHCamera disp5 (geomcam, "MCalibPedCam;RMS", "Pedestal RMS");
303 MHCamera disp6 (geomcam, "MCalibDiffCam;ped", "Diff. Mean Pedestal (Hist.)");
304 MHCamera disp7 (geomcam, "MCalibDiffCam;RMS", "Diff. Pedestal RMS (Hist.)");
305 MHCamera disp8 (geomcam, "MCalibDiffCam;ped", "Diff. Mean Pedestal");
306 MHCamera disp9 (geomcam, "MCalibDiffCam;AbsRMS", "Diff. Abs. Pedestal RMS");
307 MHCamera disp10(geomcam, "MCalibDiffCam;RelRMS", "Diff. Rel. Pedestal RMS");
308
309 disp0.SetCamContent(fPedestalCamOut, 0);
310 disp0.SetCamError (fPedestalCamOut, 1);
311
312 disp1.SetCamContent(fPedestalCamOut, 2);
313 disp1.SetCamError (fPedestalCamOut, 3);
314
315 /*
316 if (fIsUseHists)
317 {
318 disp2.SetCamContent(calpedcam, 0);
319 disp2.SetCamError (calpedcam, 1);
320
321 disp3.SetCamContent(calpedcam, 2);
322 disp3.SetCamError (calpedcam, 3);
323
324 disp4.SetCamContent(calpedcam, 5);
325 disp4.SetCamError (calpedcam, 6);
326
327 disp5.SetCamContent(calpedcam, 7);
328 disp5.SetCamError (calpedcam, 8);
329
330 for (UInt_t i=0;i<geomcam.GetNumPixels();i++)
331 {
332
333 MPedestalPix &ped = fPedestalCamOut[i];
334 MCalibrationPix &hist = calpedcam [i];
335 MBadPixelsPix &bad = fBadPixels[i];
336
337 if (bad.IsUnsuitable())
338 continue;
339
340 disp6.Fill(i,ped.GetPedestal()-hist.GetHiGainMean());
341 disp6.SetUsed(i);
342
343 disp7.Fill(i,hist.GetHiGainSigma()-ped.GetPedestalRms());
344 if (TMath::Abs(ped.GetPedestalRms()-hist.GetHiGainSigma()) < 4.0)
345 disp7.SetUsed(i);
346
347 disp8.Fill(i,ped.GetPedestal()-hist.GetLoGainMean());
348 disp8.SetUsed(i);
349
350 disp9.Fill(i,hist.GetLoGainSigma()-ped.GetPedestalRms());
351 if (TMath::Abs(hist.GetLoGainSigma() - ped.GetPedestalRms()) < 4.0)
352 disp9.SetUsed(i);
353 }
354 }
355 */
356
357 if (fExtractionType!=kFundamental/*fExtractorResolution*/)
358 {
359 for (UInt_t i=0;i<geomcam.GetNumPixels();i++)
360 {
361
362 MPedestalPix &pedo = fPedestalCamOut[i];
363 MPedestalPix &pedi = fPedestalCamIn[i];
364 MBadPixelsPix &bad = fBadPixels[i];
365
366 if (bad.IsUnsuitable())
367 continue;
368
369 const Float_t diff = pedo.GetPedestalRms()-pedi.GetPedestalRms();
370 const Float_t sum = 0.5*(pedo.GetPedestalRms()+pedi.GetPedestalRms());
371
372 disp9.Fill(i,pedo.GetPedestalRms()-pedi.GetPedestalRms());
373 if (pedo.IsValid() && pedi.IsValid())
374 disp9.SetUsed(i);
375
376 disp10.Fill(i,sum == 0. ? 0. : diff/sum);
377 if (pedo.IsValid() && pedi.IsValid() && sum != 0.)
378 disp10.SetUsed(i);
379 }
380 }
381
382 disp0.SetYTitle("P [cts/slice]");
383 disp1.SetYTitle("P_{rms} [cts/slice]");
384 disp2.SetYTitle("Hist. Mean [cts/slice]");
385 disp3.SetYTitle("Hist. Sigma [cts/slice]");
386 disp4.SetYTitle("Calc. Mean [cts/slice]");
387 disp5.SetYTitle("Calc. RMS [cts/slice]");
388 disp6.SetYTitle("Diff. Mean [cts/slice]");
389 disp7.SetYTitle("Diff. RMS [cts/slice]");
390 disp8.SetYTitle("Diff. Mean [cts/slice]");
391 disp9.SetYTitle("Abs.Diff.RMS [cts/slice]");
392 disp10.SetYTitle("Rel.Diff.RMS [1]");
393
394 //
395 // Display data
396 //
397 if (fDisplayType != kDisplayDataCheck && fExtractionType==kFundamental/*fExtractorResolution*/)
398 {
399 TCanvas &c3 = fDisplay->AddTab("Pedestals");
400 c3.Divide(2,3);
401
402 disp0.CamDraw(c3, 1, 2, 1);
403 disp1.CamDraw(c3, 2, 2, 6);
404 return;
405 }
406
407#if 0
408 if (fIsUseHists)
409 {
410
411 TCanvas &c3 = fDisplay->AddTab("Extractor Hist.");
412 c3.Divide(2,3);
413
414 disp2.CamDraw(c3, 1, 2, 1);
415 disp3.CamDraw(c3, 2, 2, 5);
416
417 TCanvas &c4 = fDisplay->AddTab("Extractor Calc.");
418 c4.Divide(2,3);
419
420 disp4.CamDraw(c4, 1, 2, 1);
421 disp5.CamDraw(c4, 2, 2, 5);
422
423 /*
424 TCanvas &c5 = fDisplay->AddTab("Difference Hist.");
425 c5.Divide(2,3);
426
427 disp6.CamDraw(c5, 1, 2, 1);
428 disp7.CamDraw(c5, 2, 2, 5);
429 */
430
431 TCanvas &c6 = fDisplay->AddTab("Difference Calc.");
432 c6.Divide(2,3);
433
434 disp8.CamDraw(c6, 1, 2, 1);
435 disp9.CamDraw(c6, 2, 2, 5);
436 return;
437 }
438#endif
439 if (fDisplayType == kDisplayDataCheck)
440 {
441
442 TCanvas &c3 = fDisplay->AddTab(fExtractionType!=kFundamental/*fExtractorResolution*/ ? "PedExtrd" : "Ped");
443 c3.Divide(2,3);
444
445 c3.cd(1);
446 gPad->SetBorderMode(0);
447 gPad->SetTicks();
448 MHCamera *obj1=(MHCamera*)disp0.DrawCopy("hist");
449 //
450 // for the datacheck, fix the ranges!!
451 //
452 if (fExtractionType==kFundamental/*!fExtractorResolution*/)
453 {
454 obj1->SetMinimum(fPedestalMin);
455 obj1->SetMaximum(fPedestalMax);
456 }
457 //
458 // Set the datacheck sizes:
459 //
460 FixDataCheckHist((TH1D*)obj1);
461 //
462 // set reference lines
463 //
464 DisplayReferenceLines(obj1,0);
465 //
466 // end reference lines
467 //
468 c3.cd(3);
469 gPad->SetBorderMode(0);
470 obj1->SetPrettyPalette();
471 obj1->Draw();
472
473 c3.cd(5);
474 gPad->SetBorderMode(0);
475 gPad->SetTicks();
476 TH1D *obj2 = (TH1D*)obj1->Projection(obj1->GetName());
477 obj2->Draw();
478 obj2->SetBit(kCanDelete);
479 obj2->Fit("gaus","Q");
480 obj2->GetFunction("gaus")->SetLineColor(kYellow);
481 //
482 // Set the datacheck sizes:
483 //
484 FixDataCheckHist(obj2);
485 obj2->SetStats(1);
486
487 c3.cd(2);
488 gPad->SetBorderMode(0);
489 gPad->SetTicks();
490 MHCamera *obj3=(MHCamera*)disp1.DrawCopy("hist");
491 //
492 // for the datacheck, fix the ranges!!
493 //
494 obj3->SetMinimum(fPedRmsMin);
495 obj3->SetMaximum(fPedRmsMax);
496 //
497 // Set the datacheck sizes:
498 //
499 FixDataCheckHist((TH1D*)obj3);
500 //
501 // set reference lines
502 //
503 DisplayReferenceLines(obj3,1);
504
505 c3.cd(4);
506 gPad->SetBorderMode(0);
507 obj3->SetPrettyPalette();
508 obj3->Draw();
509
510 c3.cd(6);
511 gPad->SetBorderMode(0);
512
513 if (geomcam.InheritsFrom("MGeomCamMagic"))
514 {
515 TArrayI inner(1);
516 inner[0] = 0;
517
518 TArrayI outer(1);
519 outer[0] = 1;
520
521 TArrayI s0(6);
522 s0[0] = 6;
523 s0[1] = 1;
524 s0[2] = 2;
525 s0[3] = 3;
526 s0[4] = 4;
527 s0[5] = 5;
528
529 TArrayI s1(3);
530 s1[0] = 6;
531 s1[1] = 1;
532 s1[2] = 2;
533
534 TArrayI s2(3);
535 s2[0] = 3;
536 s2[1] = 4;
537 s2[2] = 5;
538
539 TVirtualPad *pad = gPad;
540 pad->Divide(2,1);
541
542 TH1D *inout[2];
543 inout[0] = disp1.ProjectionS(s0, inner, "Inner");
544 inout[1] = disp1.ProjectionS(s0, outer, "Outer");
545 FixDataCheckHist(inout[0]);
546 FixDataCheckHist(inout[1]);
547
548 inout[0]->SetTitle(Form("%s %s",disp1.GetTitle(),"Inner"));
549 inout[1]->SetTitle(Form("%s %s",disp1.GetTitle(),"Outer"));
550
551
552 for (int i=0; i<2; i++)
553 {
554 pad->cd(i+1);
555 gPad->SetBorderMode(0);
556 gPad->SetTicks();
557
558 inout[i]->SetDirectory(NULL);
559 inout[i]->SetLineColor(kRed+i);
560 inout[i]->SetBit(kCanDelete);
561 inout[i]->Draw();
562 inout[i]->Fit("gaus", "Q");
563
564 TLegend *leg2 = new TLegend(0.6,0.2,0.9,0.55);
565 leg2->SetHeader(inout[i]->GetName());
566 leg2->AddEntry(inout[i], inout[i]->GetName(), "l");
567
568 //
569 // Display the outliers as dead and noisy pixels
570 //
571 DisplayOutliers(inout[i]);
572
573 //
574 // Display the two half of the camera separately
575 //
576 TH1D *half[2];
577 half[0] = disp1.ProjectionS(s1, i==0 ? inner : outer , "Sector 6-1-2");
578 half[1] = disp1.ProjectionS(s2, i==0 ? inner : outer , "Sector 3-4-5");
579
580 for (int j=0; j<2; j++)
581 {
582 half[j]->SetLineColor(kRed+i+2*j+1);
583 half[j]->SetDirectory(NULL);
584 half[j]->SetBit(kCanDelete);
585 half[j]->Draw("same");
586 leg2->AddEntry(half[j], half[j]->GetName(), "l");
587 }
588 leg2->Draw();
589 delete leg2;
590 }
591 return;
592 }
593 }
594
595 if (fExtractionType!=kFundamental/*fExtractorResolution*/)
596 {
597
598 TCanvas &c3 = fDisplay->AddTab(fExtractionType==kWithExtractor?"PedExtrd":"PedRndm");
599 c3.Divide(2,3);
600
601 disp0.CamDraw(c3, 1, 2, 1);
602 disp1.CamDraw(c3, 2, 2, 6);
603
604 TCanvas &c13 = fDisplay->AddTab(fExtractionType==kWithExtractor?"DiffExtrd":"DiffRndm");
605 c13.Divide(2,3);
606
607 disp9.CamDraw(c13, 1, 2, 5);
608 disp10.CamDraw(c13, 2, 2, 5);
609 return;
610 }
611}
612
613
614void MJPedestal::DisplayReferenceLines(MHCamera *cam, const Int_t what) const
615{
616
617 Double_t x = cam->GetNbinsX();
618
619 const MGeomCam *geom = cam->GetGeometry();
620
621 if (geom->InheritsFrom("MGeomCamMagic"))
622 x = what ? 397 : cam->GetNbinsX();
623
624 TLine line;
625 line.SetLineStyle(kDashed);
626 line.SetLineWidth(3);
627 line.SetLineColor(kBlue);
628
629 TLegend *leg = new TLegend(0.6,0.75,0.9,0.99);
630 leg->SetBit(kCanDelete);
631
632 if (fExtractionType==kWithExtractorRndm && !(what))
633 {
634 TLine *l0 = line.DrawLine(0,0.,cam->GetNbinsX(),0.);
635 l0->SetBit(kCanDelete);
636 leg->AddEntry(l0, "Reference","l");
637 leg->Draw();
638 return;
639 }
640
641 line.SetLineColor(kBlue);
642 TLine *l1 = line.DrawLine(0, what ? fRefPedRmsGalacticInner : fRefPedGalactic,
643 x, what ? fRefPedRmsGalacticInner : fRefPedGalactic);
644 l1->SetBit(kCanDelete);
645 line.SetLineColor(kYellow);
646 TLine *l2 = line.DrawLine(0, what ? fRefPedRmsExtraGalacticInner : fRefPedExtraGalactic,
647 x, what ? fRefPedRmsExtraGalacticInner : fRefPedExtraGalactic);
648 l2->SetBit(kCanDelete);
649 line.SetLineColor(kMagenta);
650 TLine *l3 = line.DrawLine(0, what ? fRefPedRmsClosedLidsInner : fRefPedClosedLids,
651 x, what ? fRefPedRmsClosedLidsInner : fRefPedClosedLids);
652 l3->SetBit(kCanDelete);
653
654 if (geom->InheritsFrom("MGeomCamMagic"))
655 if (what)
656 {
657 const Double_t x2 = cam->GetNbinsX();
658
659 line.SetLineColor(kBlue);
660 line.DrawLine(398, fRefPedRmsGalacticOuter,
661 x2, fRefPedRmsGalacticOuter);
662
663 line.SetLineColor(kYellow);
664 line.DrawLine(398, fRefPedRmsExtraGalacticOuter,
665 x2, fRefPedRmsExtraGalacticOuter);
666
667 line.SetLineColor(kMagenta);
668 line.DrawLine(398, fRefPedRmsClosedLidsOuter,
669 x2, fRefPedRmsClosedLidsOuter);
670 }
671
672
673 leg->AddEntry(l1, "Galactic Source","l");
674 leg->AddEntry(l2, "Extra-Galactic Source","l");
675 leg->AddEntry(l3, "Closed Lids","l");
676 leg->Draw();
677}
678
679void MJPedestal::DisplayOutliers(TH1D *hist) const
680{
681 const Float_t mean = hist->GetFunction("gaus")->GetParameter(1);
682 const Float_t lolim = mean - 3.5*hist->GetFunction("gaus")->GetParameter(2);
683 const Float_t uplim = mean + 3.5*hist->GetFunction("gaus")->GetParameter(2);
684 const Stat_t dead = hist->Integral(0,hist->FindBin(lolim)-1);
685 const Stat_t noisy = hist->Integral(hist->FindBin(uplim)+1,hist->GetNbinsX()+1);
686
687 TLatex deadtex;
688 deadtex.SetTextSize(0.06);
689 deadtex.DrawLatex(0.1,hist->GetBinContent(hist->GetMaximumBin())/1.1,Form("%3i dead pixels",(Int_t)dead));
690
691 TLatex noisytex;
692 noisytex.SetTextSize(0.06);
693 noisytex.DrawLatex(0.1,hist->GetBinContent(hist->GetMaximumBin())/1.2,Form("%3i noisy pixels",(Int_t)noisy));
694}
695
696void MJPedestal::FixDataCheckHist(TH1D *hist) const
697{
698 hist->SetDirectory(NULL);
699 hist->SetStats(0);
700
701 //
702 // set the labels bigger
703 //
704 TAxis *xaxe = hist->GetXaxis();
705 TAxis *yaxe = hist->GetYaxis();
706
707 xaxe->CenterTitle();
708 yaxe->CenterTitle();
709 xaxe->SetTitleSize(0.06);
710 yaxe->SetTitleSize(0.06);
711 xaxe->SetTitleOffset(0.8);
712 yaxe->SetTitleOffset(0.5);
713 xaxe->SetLabelSize(0.05);
714 yaxe->SetLabelSize(0.05);
715}
716
717/*
718Bool_t MJPedestal::WriteEventloop(MEvtLoop &evtloop) const
719{
720 if (fOutputPath.IsNull())
721 return kTRUE;
722
723 const TString oname(GetOutputFile());
724
725 *fLog << inf << "Writing to file: " << oname << endl;
726
727 TFile file(oname, fOverwrite?"RECREATE":"NEW", "File created by MJPedestal", 9);
728 if (!file.IsOpen())
729 {
730 *fLog << err << "ERROR - Couldn't open file " << oname << " for writing..." << endl;
731 return kFALSE;
732 }
733
734 if (evtloop.Write(fName)<=0)
735 {
736 *fLog << err << "Unable to write MEvtloop to " << oname << endl;
737 return kFALSE;
738 }
739
740 return kTRUE;
741}
742*/
743
744void MJPedestal::SetExtractor(MExtractor* ext)
745{
746 if (ext)
747 {
748 if (fExtractor)
749 delete fExtractor;
750 fExtractor = ext ? (MExtractor*)ext->Clone(ext->GetName()) : NULL;
751 }
752 else
753 fExtractor = 0;
754}
755
756// --------------------------------------------------------------------------
757//
758// Read the following values from resource file:
759//
760// PedestalMin
761// PedestalMax
762//
763// PedRmsMin
764// PedRmsMax
765//
766// RefPedClosedLids
767// RefPedExtraGalactic
768// RefPedGalactic
769//
770// RefPedRmsClosedLidsInner
771// RefPedRmsExtraGalacticInner
772// RefPedRmsGalacticInner
773// RefPedRmsClosedLidsOuter
774// RefPedRmsExtraGalacticOuter
775// RefPedRmsGalacticOuter
776//
777void MJPedestal::ReadReferenceFile()
778{
779 TEnv refenv(fReferenceFile);
780
781 fPedestalMin = refenv.GetValue("PedestalMin",fPedestalMin);
782 fPedestalMax = refenv.GetValue("PedestalMax",fPedestalMax);
783 fPedRmsMin = refenv.GetValue("PedRmsMin",fPedRmsMin);
784 fPedRmsMax = refenv.GetValue("PedRmsMax",fPedRmsMax);
785 fRefPedClosedLids = refenv.GetValue("RefPedClosedLids",fRefPedClosedLids);
786 fRefPedExtraGalactic = refenv.GetValue("RefPedExtraGalactic",fRefPedExtraGalactic);
787 fRefPedGalactic = refenv.GetValue("RefPedGalactic",fRefPedGalactic);
788 fRefPedRmsClosedLidsInner = refenv.GetValue("RefPedRmsClosedLidsInner",fRefPedRmsClosedLidsInner);
789 fRefPedRmsExtraGalacticInner = refenv.GetValue("RefPedRmsExtraGalacticInner",fRefPedRmsExtraGalacticInner);
790 fRefPedRmsGalacticInner = refenv.GetValue("RefPedRmsGalacticInner",fRefPedRmsGalacticInner);
791 fRefPedRmsClosedLidsOuter = refenv.GetValue("RefPedRmsClosedLidsOuter",fRefPedRmsClosedLidsOuter);
792 fRefPedRmsExtraGalacticOuter = refenv.GetValue("RefPedRmsExtraGalacticOuter",fRefPedRmsExtraGalacticOuter);
793 fRefPedRmsGalacticOuter = refenv.GetValue("RefPedRmsGalacticOuter",fRefPedRmsGalacticOuter);
794}
795
796// --------------------------------------------------------------------------
797//
798// The following resource options are available:
799//
800// Do a datacheck run (read raw-data and enable display)
801// Prefix.DataCheck: Yes, No <default>
802//
803// Setup display type
804// Prefix.Display: normal <default>, datacheck, none
805//
806// Use cosmic data instead of pedestal data (DatRuns)
807// Prefix.UseData: Yes, No <default>
808//
809// Write an output file with pedestals and status-display
810// Prefix.DisableOutput: Yes, No <default>
811//
812// Name of a file containing reference values (see ReadReferenceFile)
813// Prefix.ReferenceFile: filename
814// (see ReadReferenceFile)
815//
816Bool_t MJPedestal::CheckEnvLocal()
817{
818 if (HasEnv("Display"))
819 {
820 TString type = GetEnv("Display", "normal");
821 type.ToLower();
822 if (type==(TString)"normal")
823 fDisplayType = kDisplayNormal;
824 if (type==(TString)"datacheck")
825 fDisplayType = kDisplayDataCheck;
826 if (type==(TString)"none")
827 fDisplayType = kDisplayNone;
828 }
829
830
831 SetExtractWinLeft (GetEnv("ExtractWinLeft", fExtractWinLeft ));
832 SetExtractWinRight(GetEnv("ExtractWinRight", fExtractWinRight));
833
834 if (!MJCalib::CheckEnvLocal())
835 return kFALSE;
836
837 if (HasEnv("UseData"))
838 fExtractType = GetEnv("UseData",kFALSE) ? kUseData : kUsePedRun;
839
840 if (IsUseMC() && fExtractType==kUseData)
841 {
842 // The reason is, that the standard data files contains empty
843 // (untriggered) events. If we would loop over the default 500
844 // first events of the data file you would calculate the
845 // pedestal from only some single events...
846 *fLog << inf;
847 *fLog << "Sorry, you cannot extract the starting pedestal from the first" << endl;
848 *fLog << "events in your data files... using pedestal file instead. The" << endl;
849 *fLog << "result should not differ..." << endl;
850 fExtractType = kUsePedRun;
851 }
852
853
854 if (HasEnv("UseHists"))
855 if (GetEnv("UseHists",kFALSE))
856 fIsUseHists = kTRUE;
857
858 SetNoStorage(GetEnv("DisableOutput", IsNoStorage()));
859
860 MTaskEnv tenv("ExtractSignal");
861 tenv.SetDefault(fExtractor);
862
863 if (tenv.ReadEnv(*GetEnv(), GetEnvPrefix()+".ExtractSignal", GetEnvDebug()>2)==kERROR)
864 return kFALSE;
865
866 if (fExtractor==tenv.GetTask())
867 return kTRUE;
868
869 if (!tenv.GetTask()->InheritsFrom(MExtractor::Class()))
870 {
871 *fLog << err << "ERROR: ExtractSignal from resource file doesn't inherit from MExtractor.... abort." << endl;
872 return kFALSE;
873 }
874
875 SetExtractor((MExtractor*)tenv.GetTask());
876
877 fBadPixelsFile = GetEnv("BadPixelsFile",fBadPixelsFile.Data());
878 fReferenceFile = GetEnv("ReferenceFile",fReferenceFile.Data());
879 ReadReferenceFile();
880
881 return kTRUE;
882}
883
884//---------------------------------------------------------------------------------
885//
886// Try to write the created MPedestalCam in the output file.
887// If possible, also an MBadPixelsCam and the corresponding display is written.
888//
889// In case of Storage type "kNoStorage" or if any of the containers
890// cannot be written, return kFALSE, otherwise kTRUE.
891//
892Bool_t MJPedestal::WriteResult()
893{
894 if (IsNoStorage())
895 return kTRUE;
896
897 TObjArray cont;
898
899 cont.Add(&fPedestalCamOut);
900 cont.Add(&fBadPixels);
901
902 return WriteContainer(cont, GetOutputFileName(),fOverwrite?"RECREATE":"NEW");
903}
904
905Bool_t MJPedestal::Process()
906{
907 if (!ReadPedestalCam())
908 return ProcessFile();
909
910 return kTRUE;
911}
912
913Bool_t MJPedestal::ProcessFile()
914{
915 if (!fSequence.IsValid())
916 {
917 if (!fRuns)
918 {
919 *fLog << err << "Neither AddRuns nor SetSequence nor SetEnv was called... abort." << endl;
920 return kFALSE;
921 }
922 if (fRuns && fRuns->GetNumRuns() != fRuns->GetNumEntries())
923 {
924 *fLog << err << "Number of files found doesn't match number of runs... abort."
925 << fRuns->GetNumRuns() << " vs. " << fRuns->GetNumEntries() << endl;
926 return kFALSE;
927 }
928 }
929
930 if (!CheckEnv())
931 return kFALSE;
932
933 // --------------------------------------------------------------------------------
934
935 const TString type = IsUseData() ? "data" : "pedestal";
936
937 *fLog << inf;
938 fLog->Separator(GetDescriptor());
939 *fLog << "Calculate MPedestalCam from " << type << "-runs ";
940 if (fSequence.IsValid())
941 *fLog << fSequence.GetName() << endl;
942 else
943 if (fRuns)
944 *fLog << fRuns->GetRunsAsString() << endl;
945 else
946 *fLog << "in Resource File." << endl;
947 *fLog << endl;
948
949 // --------------------------------------------------------------------------------
950
951 MParList plist;
952 MTaskList tlist;
953 plist.AddToList(&tlist);
954 plist.AddToList(this); // take care of fDisplay!
955
956 MReadMarsFile read("Events");
957 MRawFileRead rawread(NULL);
958
959 MDirIter iter;
960 if (fSequence.IsValid())
961 {
962 const Int_t n0 = IsUseData()
963 ? fSequence.SetupDatRuns(iter, fPathData, "D", IsUseRawData())
964 : fSequence.SetupPedRuns(iter, fPathData, "P", IsUseRawData());
965 const Int_t n1 = IsUseData()
966 ? fSequence.GetNumDatRuns()
967 : fSequence.GetNumPedRuns();
968 if (n0==0)
969 {
970 *fLog << err << "ERROR - No " << type << " input files of sequence found in " << (fPathData.IsNull()?"<default>":fPathData.Data()) << endl;
971 return kFALSE;
972 }
973 if (n0!=n1)
974 {
975 *fLog << err << "ERROR - Number of " << type << " files found (" << n0 << ") in " << (fPathData.IsNull()?"<default>":fPathData.Data()) << " doesn't match number of files in sequence (" << n1 << ")" << endl;
976 return kFALSE;
977 }
978 }
979
980 if (IsUseRawData())
981 {
982 if (fRuns || fSequence.IsValid())
983 rawread.AddFiles(fSequence.IsValid() ? iter : *fRuns);
984 tlist.AddToList(&rawread);
985 }
986 else
987 {
988 read.DisableAutoScheme();
989 if (fRuns || fSequence.IsValid())
990 read.AddFiles(fSequence.IsValid() ? iter : *fRuns);
991 tlist.AddToList(&read);
992 }
993
994 // Setup Tasklist
995 plist.AddToList(&fPedestalCamOut);
996 plist.AddToList(&fBadPixels);
997
998 //
999 // Read bad pixels from outside
1000 //
1001 if (!fBadPixelsFile.IsNull())
1002 {
1003 *fLog << inf << "Excluding: " << fBadPixelsFile << endl;
1004 ifstream fin(fBadPixelsFile.Data());
1005 fBadPixels.AsciiRead((istream&)fin);
1006 }
1007
1008 MGeomApply geomapl;
1009 MBadPixelsMerge merge(&fBadPixels);
1010
1011 MPedCalcPedRun pedcalc;
1012 pedcalc.SetPedestalUpdate(kFALSE);
1013
1014 MPedCalcFromLoGain pedlogain;
1015 pedlogain.SetPedestalUpdate(kFALSE);
1016
1017 MHPedestalCam hpedcam;
1018 if (fExtractionType != kFundamental)
1019 hpedcam.SetRenorm(kTRUE);
1020 // fPedestalHist.SetRenorm(kTRUE);
1021 // fPedestalHist.SetPedestalsOut(&fPedestalCamOut);
1022 hpedcam.SetPedestalsOut(&fPedestalCamOut);
1023
1024 MPedestalCam pedinter;
1025 pedinter.SetName("MPedestalCamIntermediate");
1026
1027 MFillH fillped(&hpedcam, "MPedestalCamIntermediate", "FillPedCam");
1028 // MFillH fillped(&fPedestalHist, "MPedestalCamIntermediate", "FillPedCam");
1029 MFillH fillpul("MHCalibrationPulseTimeCam", "MRawEvtData", "FillPulseTime");
1030 fillped.SetBit(MFillH::kDoNotDisplay);
1031 fillpul.SetBit(MFillH::kDoNotDisplay);
1032
1033 tlist.AddToList(&geomapl);
1034 tlist.AddToList(&merge);
1035
1036 if (!fPathIn.IsNull())
1037 {
1038 fExtractor = ReadCalibration();
1039 if (!fExtractor)
1040 return kFALSE;
1041
1042 *fLog << all;
1043 *fLog << underline << "Signal Extractor found in calibration file:" << endl;
1044 fExtractor->Print();
1045 *fLog << endl;
1046 }
1047
1048 MFEventSelector sel;
1049 sel.SetNumSelectEvts(0);
1050
1051 if (fExtractor)
1052 {
1053 fExtractor->SetFilter(&sel);
1054 tlist.AddToList(&sel);
1055 tlist.AddToList(fExtractor);
1056 }
1057
1058 MFTriggerPattern fcalib("CalibFilter");
1059 fcalib.RequireCalibration();
1060 fcalib.SetInverted();
1061
1062 if (fIsPulsePosCheck)
1063 {
1064 fillpul.SetFilter(&fcalib);
1065 tlist.AddToList(&fillpul);
1066 }
1067
1068 // ----------------------------------------------------------------------
1069 // Now we make sure, that in all cases the ranges are setup correctly
1070 // ----------------------------------------------------------------------
1071 MTaskEnv taskenv("ExtractPedestal");
1072 switch (fExtractType)
1073 {
1074 case kUsePedRun:
1075 // In case other than 'fundamental' second argument is obsolete
1076 // pedcalc.SetExtractWindow(0,14); // kUsePedRun (take default from class)
1077 taskenv.SetDefault(&pedcalc);
1078 tlist.AddToList(&taskenv);
1079 break;
1080
1081 case kUseData:
1082 // In case other than 'fundamental' second argument is obsolete
1083 // pedlogain.SetExtractWindow(15,14); // kUseData (take default from class)
1084 taskenv.SetDefault(&pedlogain);
1085 tlist.AddToList(&taskenv);
1086 break;
1087 }
1088
1089 if (fIsUseHists)
1090 {
1091 if (fExtractor->InheritsFrom("MExtractTimeAndCharge"))
1092 hpedcam.SetFitStart(-10.*((MExtractTimeAndCharge*)fExtractor)->GetWindowSizeHiGain());
1093
1094 pedcalc.SetIntermediateStorage();
1095 pedlogain.SetIntermediateStorage();
1096 plist.AddToList(&pedinter);
1097 plist.AddToList(&hpedcam);
1098 // plist.AddToList(&fPedestalHist);
1099 tlist.AddToList(&fillped);
1100 }
1101
1102 pedcalc.SetPedestalsIn(&fPedestalCamIn);
1103 pedlogain.SetPedestalsIn(&fPedestalCamIn);
1104
1105 pedcalc.SetPedestalsInter(&pedinter);
1106 pedlogain.SetPedestalsInter(&pedinter);
1107 pedcalc.SetPedestalsOut(&fPedestalCamOut);
1108 pedlogain.SetPedestalsOut(&fPedestalCamOut);
1109
1110 // kFundamental
1111 if (fExtractor)
1112 {
1113
1114 if (fExtractionType!=kFundamental)
1115 {
1116 pedcalc.SetRandomCalculation(fExtractionType==kWithExtractorRndm);
1117 pedlogain.SetRandomCalculation(fExtractionType==kWithExtractorRndm);
1118
1119 pedcalc.SetExtractor((MExtractTimeAndCharge*)fExtractor);
1120 pedlogain.SetExtractor((MExtractTimeAndCharge*)fExtractor);
1121 }
1122
1123 if (fExtractor->InheritsFrom("MExtractTimeAndCharge"))
1124 {
1125
1126 const Float_t f = 0.1+fExtractor->GetHiGainFirst();
1127 const Int_t win = ((MExtractTimeAndCharge*)fExtractor)->GetWindowSizeHiGain();
1128 pedcalc.SetExtractWindow((Int_t)f, win);
1129 pedlogain.SetExtractWindow((Int_t)(15+f), win);
1130
1131 }
1132 else
1133 {
1134 const Float_t f = 0.1+fExtractor->GetHiGainFirst();
1135 const Float_t n = 0.1+fExtractor->GetNumHiGainSamples();
1136 pedcalc.SetExtractWindow((Int_t)f, (Int_t)n);
1137 pedlogain.SetExtractWindow((Int_t)(15+f), (Int_t)n);
1138
1139 if (fExtractionType!=kFundamental)
1140 {
1141 *fLog << inf;
1142 *fLog << "Signal extractor doesn't inherit from MExtractTimeAndCharge..." << endl;
1143 *fLog << " --> falling back to fundamental pedestal extraction." << endl;
1144 fExtractionType=kFundamental;
1145 }
1146 }
1147
1148
1149 }
1150 else
1151 {
1152 *fLog << warn << GetDescriptor() << ": WARNING - No extractor has been handed over! " << endl;
1153 *fLog << "Taking default window for pedestal extraction. The calculated pedestal RMS" << endl;
1154 *fLog << "will probably not match with future pedestal RMS' from different extraction" << endl;
1155 *fLog << "windows." << endl;
1156 }
1157
1158 /*
1159 switch (fExtractType)
1160 {
1161 case kUseData:
1162 *fLog << all << "TYPE: USEDATA " << fExtractor << endl;
1163 taskenv.SetDefault(&pedlogain);
1164 tlist.AddToList(&taskenv);
1165
1166 if (!SetupExtractor(plist, pedlogain))
1167 {
1168 *fLog << all << "SETTING TO: " << fExtractor << " " << fExtractor->GetNumHiGainSamples() << endl;
1169 fExtractor->Print();
1170 pedlogain.SetExtractWindow(15, (Int_t)TMath::Nint(fExtractor->GetNumHiGainSamples()));
1171 }
1172 break;
1173
1174 case kUsePedRun:
1175 *fLog << all << "TYPE: USEPEDRUN " << fExtractor << endl;
1176 taskenv.SetDefault(&pedcalc);
1177 tlist.AddToList(&taskenv);
1178
1179 if (!SetupExtractor(plist, pedcalc))
1180 pedcalc.SetExtractWindow(fExtractor->GetHiGainFirst(), TMath::Nint(fExtractor->GetNumHiGainSamples()));
1181 break;
1182
1183 case kUseHists:
1184 if (!fExtractor)
1185 {
1186 *fLog << err << GetDescriptor() << " - ERROR: ";
1187 *fLog << "Extraction Type is kUseHists, but no extractor was set" << endl;
1188 return kFALSE;
1189 }
1190
1191 tlist.AddToList(fExtractor);
1192 tlist.AddToList(&fillped);
1193 break;
1194 } */
1195
1196 /*
1197 if (!fPathIn.IsNull())
1198 {
1199 delete fExtractor;
1200 fExtractor = 0;
1201 }
1202 */
1203
1204
1205 //
1206 // Execute the eventloop
1207 //
1208 MEvtLoop evtloop(fName);
1209 evtloop.SetParList(&plist);
1210 evtloop.SetDisplay(fDisplay);
1211 evtloop.SetLogStream(fLog);
1212 if (!SetupEnv(evtloop))
1213 return kFALSE;
1214
1215 // if (!WriteEventloop(evtloop))
1216 // return kFALSE;
1217
1218 // Execute first analysis
1219 if (!evtloop.Eventloop(fMaxEvents))
1220 {
1221 *fLog << err << GetDescriptor() << ": Failed." << endl;
1222 return kFALSE;
1223 }
1224
1225 tlist.PrintStatistics();
1226
1227 fExtractor->SetFilter(0);
1228
1229 if (fIsPixelCheck)
1230 {
1231 MHPedestalCam *hcam = (MHPedestalCam*)plist.FindObject("MHPedestalCam");
1232 if (hcam)
1233 {
1234 MHPedestalPix &pix1 = (MHPedestalPix&)(*hcam)[fCheckedPixId];
1235 pix1.DrawClone("");
1236 }
1237 }
1238
1239 if (fDisplayType!=kDisplayNone)
1240 DisplayResult(plist);
1241
1242 if (!WriteResult())
1243 return kFALSE;
1244
1245 if (fIsPulsePosCheck)
1246 {
1247
1248 MHCalibrationPulseTimeCam *hcam = (MHCalibrationPulseTimeCam*)plist.FindObject("MHCalibrationPulseTimeCam");
1249 if (fIsPixelCheck)
1250 {
1251 hcam->DrawClone();
1252 gPad->SaveAs(Form("%s/PulsePosTest_all.root",fPathOut.Data()));
1253 MHCalibrationPix &pix = (*hcam)[fCheckedPixId];
1254 pix.DrawClone();
1255 gPad->SaveAs(Form("%s/PulsePosTest_Pixel%04d.root",fPathOut.Data(),fCheckedPixId));
1256 }
1257
1258 MCalibrationPulseTimeCam *cam = (MCalibrationPulseTimeCam*)plist.FindObject("MCalibrationPulseTimeCam");
1259 MRawEvtData *data = (MRawEvtData*)plist.FindObject("MRawEvtData");
1260 if (cam)
1261 {
1262 const Float_t meanpulsetime = cam->GetAverageArea(0).GetHiGainMean();
1263 const Float_t rmspulsetime = cam->GetAverageArea(0).GetHiGainRms();
1264 *fLog << all << "Mean pulse time (cosmics): " << meanpulsetime << "+-" << rmspulsetime << endl;
1265 const Int_t newfirst = (Int_t)(meanpulsetime-fExtractWinLeft);
1266 Int_t wshigain = fExtractor->InheritsFrom("MExtractTimeAndCharge")
1267 ? ((MExtractTimeAndCharge*)fExtractor)->GetWindowSizeHiGain()
1268 : 6;
1269 if (wshigain > 6)
1270 wshigain = 6;
1271 Int_t wslogain = fExtractor->InheritsFrom("MExtractTimeAndCharge")
1272 ? ((MExtractTimeAndCharge*)fExtractor)->GetWindowSizeLoGain()
1273 : 6;
1274 if (wslogain > 6)
1275 wslogain = 6;
1276 const Int_t newlast = (Int_t)(meanpulsetime+fExtractWinRight);
1277 *fLog << all << underline
1278 << "Try to set new range limits: ("<<newfirst<<","<<newlast<<"+"<<wshigain
1279 <<","<<newfirst-1<<","<<newlast<<"+"<<wslogain<<")"<<endl;
1280 if (newfirst < 0)
1281 {
1282 *fLog << err << "Pulse is too much to the left, cannot go below 0! " << endl;
1283 return kFALSE;
1284 }
1285 if (newlast+wshigain > data->GetNumHiGainSamples()+data->GetNumLoGainSamples()-1)
1286 {
1287 *fLog << err << "Pulse is too much to the right, cannot go beyond limits! "
1288 << " Cannot extract at all! ... " << endl;
1289 return kFALSE;
1290 }
1291 if (newlast+wslogain > data->GetNumLoGainSamples())
1292 {
1293 *fLog << err << "Pulse is too much to the right, cannot go beyond logaie limits! " << endl;
1294 *fLog << endl;
1295 *fLog << "Try to use a different extractor (e.g. with a window size of only 4 sl.) or:" << endl;
1296 *fLog << "Set the limit to a lower value (callisto.rc: line 310): " << endl;
1297 *fLog << " MJPedestalY2:ExtractWinRight: 5.0 " << endl;
1298 *fLog << "(ATTENTION, you will lose late cosmics pulses!)" << endl;
1299 *fLog << endl;
1300 return kFALSE;
1301 }
1302 fExtractor->SetRange(newfirst,newlast+wshigain,
1303 newfirst>0?newfirst-1:newfirst,data->GetNumLoGainSamples()-1);
1304 if (!WriteExtractor())
1305 {
1306 *fLog << err << "Could not write the changes to disk, abort... " << endl;
1307 return kFALSE;
1308 }
1309 }
1310 else
1311 {
1312 *fLog << err << "Could not determine mean pulse position, abort... " << endl;
1313 return kFALSE;
1314 }
1315 }
1316
1317
1318 *fLog << all << GetDescriptor() << ": Done." << endl;
1319 *fLog << endl << endl;
1320
1321 return kTRUE;
1322}
Note: See TracBrowser for help on using the repository browser.