Changeset 2627 for trunk/MagicSoft


Ignore:
Timestamp:
12/09/03 18:25:21 (21 years ago)
Author:
gaug
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars
Files:
6 added
22 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/Changelog

    r2626 r2627  
    44
    55                                                 -*-*- END OF LINE -*-*-
     6 2003/12/09: Markus Gaug
     7
     8   * mhist/MHCamera:
     9        - added feature MHCamError to set errors in histograms of MStatusDisplay
     10
     11   * mhist/MHCalibration*:
     12        - all hists doubles to separate High Gain and Low Gain
     13
     14   * manalysis/MCalibration*
     15        - separate Hi Gain and Lo Gain
     16        - use MExtractSignals to extract charges
     17
     18   * manalysis/MExtractSignals:
     19        - new class to extract signals
     20
     21   * manalysis/MExtractedSignalCam:
     22        - new class to hold extracted signals
     23
     24   * manalysis/MExtractedSignalPix:
     25        - new class to hold extracted signals for pixel
     26
     27   * manalysis/Makefile
     28   * manalysis/AnalysisLinkDef:
     29        - contain MExtractedSignalCam, MExtractedSignalPix, MExtractedSignal
     30
     31   * macros/calibration.C
     32        - EventDisplay which allows to get plot by clicking on pixel
     33
     34
    635 2003/12/08: Thomas Bretz
    736
  • trunk/MagicSoft/Mars/macros/calibration.C

    r2603 r2627  
    2323\* ======================================================================== */
    2424
    25 void calibration(TString pedname="../../Mars-0.8.2/20031102_02399_P_Unavailable_E.root",
    26                  TString calname="../../Mars-0.8.2/20031102_02400_D_Flip500Hz_E.root")
     25void calibration(TString pedname="/data/MAGIC/rootdata/2003_12_01/20031130_03340_P_CrabNebula_E.root",
     26                 TString calname="/data/MAGIC/rootdata/2003_12_01/20031130_03341_C_CrabNebula_E.root")
    2727{
    2828
     
    6262    tlist.AddToList(&fill);
    6363
    64     //    MStatusDisplay *d1 = new MStatusDisplay;
     64    MStatusDisplay *d1 = new MStatusDisplay;
    6565 
    6666    // Set update time to 3s
    67     //    d1->SetUpdateTime(3000);
     67    d1->SetUpdateTime(3000);
    6868 
    6969    //
     
    7272    MEvtLoop evtloop;
    7373    evtloop.SetParList(&plist);
    74     //    evtloop.SetDisplay(d1);       
     74    evtloop.SetDisplay(d1);     
    7575
    7676    //
     
    114114    // we have to set the color of the pulser LED by hand
    115115    //
    116     calcalc.SetPulserColor(MCalibrationCalc::kEBlue);
     116    calcalc.SetPulserColor(MCalibrationCalc::kECT1);
    117117
    118118    tlist2.AddToList(&read2);
     
    145145    cam.Print();
    146146
    147     Int_t pixnr;
    148 
    149     while (1)
    150       {
    151        
    152         cout << "Which pixel number do you want to display? (Press 0 to exit)" << endl;
    153         cin >> pixnr;
    154         if (pixnr == 0)
    155           break;
    156        
    157         if (pixnr >= 577)
    158           break;
    159        
    160         MCalibrationPix *pix = cam->GetCalibrationPix(pixnr);
    161         pix->Draw();
    162    
    163       }
    164    
    165147    //
    166148    // Here we are confronted to a serious bug in ROOT:
     
    174156    MHCamera &disp0  = *h.GetHistByName();
    175157    MHCamera disp1   (geomcam, "MCalibrationCam;q", "Fitted Mean Charges");
    176     MHCamera disp2   (geomcam, "MCalibrationCam;errq", "Error of Fitted Mean Charges");
     158    //    MHCamera disp2   (geomcam, "MCalibrationCam;errq", "Error of Fitted Mean Charges");
    177159    MHCamera disp3   (geomcam, "MCalibrationCam;sigmaq", "Sigma of Fitted Mean Charges");
    178     MHCamera disp4   (geomcam, "MCalibrationCam;errsigmaq", "Error of Sigma of Fitted Mean Charges");
     160    //    MHCamera disp4   (geomcam, "MCalibrationCam;errsigmaq", "Error of Sigma of Fitted Mean Charges");
    179161    MHCamera disp5   (geomcam, "MCalibrationCam;probq", "Probability of Fit");
    180162    MHCamera disp6   (geomcam, "MCalibrationCam;t", "Arrival Times");
     
    183165    MHCamera disp9   (geomcam, "MCalibrationCam;ped", "Pedestals");
    184166    MHCamera disp10  (geomcam, "MCalibrationCam;pedrms", "Pedestal RMS");
    185     MHCamera disp11  (geomcam, "MCalibrationCam;rq", "Reduced Charges");
    186     MHCamera disp12  (geomcam, "MCalibrationCam;rsigma", "Reduced Sigmas");
    187     MHCamera disp13  (geomcam, "MCalibrationCam;phe", "Nr. of Phe's (F-Factor Method)");
    188     MHCamera disp14  (geomcam, "MCalibrationCam;convphe", "Conversion Factor (F-Factor Method)");
    189     MHCamera disp15  (geomcam, "MCalibrationCam;photons", "Nr. of Photons (Blind Pixel Method)");
    190     MHCamera disp16  (geomcam, "MCalibrationCam;convphot", "Conversion Factor (Blind Pixel Method)");
     167    MHCamera disp11  (geomcam, "MCalibrationCam;rsigma", "Reduced Sigmas");
     168    MHCamera disp12  (geomcam, "MCalibrationCam;phe", "Nr. of Phe's (F-Factor Method)");
     169    MHCamera disp13  (geomcam, "MCalibrationCam;convphe", "Conversion Factor (F-Factor Method)");
     170    MHCamera disp14  (geomcam, "MCalibrationCam;photons", "Nr. of Photons (Blind Pixel Method)");
     171    MHCamera disp15  (geomcam, "MCalibrationCam;convphot", "Conversion Factor (Blind Pixel Method)");
    191172
    192173    disp1.SetCamContent(*cam, 0);
    193     disp2.SetCamContent(*cam, 1);
     174    disp1.SetCamError(*cam,1);
     175    //    disp2.SetCamContent(*cam, 1);
     176
    194177    disp3.SetCamContent(*cam, 2);
    195     disp4.SetCamContent(*cam, 3);
     178    disp3.SetCamError(*cam,3);
     179    //    disp4.SetCamContent(*cam, 3);
    196180    disp5.SetCamContent(*cam, 4);
     181
    197182    disp6.SetCamContent(*cam, 5);
     183    disp6.SetCamError(*cam,6);
    198184    disp7.SetCamContent(*cam, 6);
    199185    disp8.SetCamContent(*cam, 7);
     186
    200187    disp9.SetCamContent(*cam, 8);
     188    disp9.SetCamError(*cam,9);
    201189    disp10.SetCamContent(*cam, 9);
     190
    202191    disp11.SetCamContent(*cam, 10);
     192
    203193    disp12.SetCamContent(*cam, 11);
    204194    disp13.SetCamContent(*cam, 12);
    205195    disp14.SetCamContent(*cam, 13);
    206196    disp15.SetCamContent(*cam, 14);
    207     disp16.SetCamContent(*cam, 15);
     197    //    disp16.SetCamError(*cam, 16);
    208198
    209199
    210200    disp1.SetYTitle("Q [FADC counts]");
    211     disp2.SetYTitle("\\Delta Q [FADC counts]");
     201    //    disp2.SetYTitle("\\Delta Q [FADC counts]");
    212202    disp3.SetYTitle("\\sigma_{Q} [FADC counts]");
    213     disp4.SetYTitle("\\Delta {\\sigma_{Q}} [FADC counts]");
     203    //    disp4.SetYTitle("\\Delta {\\sigma_{Q}} [FADC counts]");
    214204    disp5.SetYTitle("P [au]");
    215205    disp6.SetYTitle("T [FADC slices]");
     
    218208    disp9.SetYTitle("P [FADC counts/ slice ]");
    219209    disp10.SetYTitle("RMS_{P} [FADC counts / slice ]");
    220     disp11.SetYTitle("Q [FADC counts]");
    221     disp12.SetYTitle("\\sigma^2_{Q} - RMS^2_{P} [FADC counts^2]");
    222     disp13.SetYTitle("Nr Phe's");
    223     disp14.SetYTitle("Conversion Factor [Phe/FADC count]");
    224     disp15.SetYTitle("Nr Photons");
    225     disp16.SetYTitle("Conversion Factor [Ph/FADC count]");
     210    disp11.SetYTitle("\\sigma^2_{Q} - RMS^2_{P} [FADC counts^2]");
     211    disp12.SetYTitle("Nr Phe's");
     212    disp13.SetYTitle("Conversion Factor [Phe/FADC count]");
     213    disp14.SetYTitle("Nr Photons");
     214    disp15.SetYTitle("Conversion Factor [Ph/FADC count]");
    226215
    227216    MStatusDisplay *d2 = new MStatusDisplay;
     
    230219    d2->SetUpdateTime(1000);
    231220
    232     TCanvas *c1 = &d2->AddTab("Charges Mean");
     221    TCanvas *c1 = &d2->AddTab("Fitted Charges");
    233222    c1->Divide(2, 2);
    234223
     
    238227    gStyle->SetOptStat(1111);
    239228    obj=disp1.DrawCopy("hist");
     229    ((MHCamera*)obj)->AddNotify(*cam);
    240230
    241231    c1->cd(3);
     
    245235    c1->cd(2);
    246236    gStyle->SetOptStat(1101);
    247     obj=disp2.DrawCopy("hist");
     237    obj=disp3.DrawCopy("hist");
     238    ((MHCamera*)obj)->AddNotify(*cam);
    248239
    249240    c1->cd(4);
     
    251242    obj->Draw();
    252243
    253     TCanvas *c11 = &d2->AddTab("Charges Sigma");
    254     c11->Divide(2, 2);
    255 
    256     c11->cd(1);
    257     gStyle->SetOptStat(1101);
    258     obj=disp3.DrawCopy("hist");
    259 
    260     c11->cd(3);
    261     gPad->SetBorderMode(0);
    262     obj->Draw();
    263 
    264     c11->cd(2);
    265     gStyle->SetOptStat(1101);
    266     obj=disp4.DrawCopy("hist");
    267 
    268     c11->cd(4);
    269     gPad->SetBorderMode(0);
    270     obj->Draw();
    271 
    272244
    273245    TCanvas *c12 = &d2->AddTab("Fit Prob.");
     
    277249    gStyle->SetOptStat(1101);
    278250    obj=disp5.DrawCopy("hist");
     251    ((MHCamera*)obj)->AddNotify(*cam);
    279252
    280253    c12->cd(2);
     
    288261    gStyle->SetOptStat(1111);
    289262    obj=disp6.DrawCopy("hist");
     263    ((MHCamera*)obj)->AddNotify(*cam);
    290264
    291265    c2->cd(4);
     
    295269    gStyle->SetOptStat(1101);
    296270    obj=disp7.DrawCopy("hist");
     271    ((MHCamera*)obj)->AddNotify(*cam);
    297272
    298273    c2->cd(5);
     
    302277    gStyle->SetOptStat(1101);
    303278    obj=disp8.DrawCopy("hist");
     279    ((MHCamera*)obj)->AddNotify(*cam);
    304280
    305281    c2->cd(6);
     
    312288    gStyle->SetOptStat(1111);
    313289    obj=disp9.DrawCopy("hist");
     290    ((MHCamera*)obj)->AddNotify(*cam);
    314291
    315292    c3->cd(3);
     
    319296    gStyle->SetOptStat(1111);
    320297    obj=disp10.DrawCopy("hist");
     298    ((MHCamera*)obj)->AddNotify(*cam);
    321299
    322300    c3->cd(4);
     
    324302
    325303    TCanvas *c4 = &d2->AddTab("Reduced Charges");
    326     c4->Divide(2, 2);
     304    c4->Divide(2,1);
    327305
    328306    c4->cd(1);
    329307    gStyle->SetOptStat(1111);
    330308    obj=disp11.DrawCopy("hist");
     309    ((MHCamera*)obj)->AddNotify(*cam);
    331310
    332311    c4->cd(3);
    333     obj->Draw();
    334 
    335     c4->cd(2);
    336     gStyle->SetOptStat(1101);
    337     obj=disp12.DrawCopy("hist");
    338 
    339     c4->cd(4);
    340312    obj->Draw();
    341313
     
    345317    c5->cd(1);
    346318    gStyle->SetOptStat(1111);
     319    obj=disp12.DrawCopy("hist");
     320    ((MHCamera*)obj)->AddNotify(*cam);
     321
     322    c5->cd(3);
     323    obj->Draw();
     324
     325    c5->cd(2);
     326    gStyle->SetOptStat(1101);
    347327    obj=disp13.DrawCopy("hist");
    348 
    349     c5->cd(3);
    350     obj->Draw();
    351 
    352     c5->cd(2);
    353     gStyle->SetOptStat(1101);
    354     obj=disp14.DrawCopy("hist");
     328    ((MHCamera*)obj)->AddNotify(*cam);
    355329
    356330    c5->cd(4);
     
    362336    c6->cd(1);
    363337    gStyle->SetOptStat(1111);
     338    obj=disp14.DrawCopy("hist");
     339    ((MHCamera*)obj)->AddNotify(*cam);
     340
     341    c6->cd(3);
     342    obj->Draw();
     343
     344    c6->cd(2);
     345    gStyle->SetOptStat(1101);
    364346    obj=disp15.DrawCopy("hist");
    365 
    366     c6->cd(3);
    367     obj->Draw();
    368 
    369     c6->cd(2);
    370     gStyle->SetOptStat(1101);
    371     obj=disp16.DrawCopy("hist");
     347    ((MHCamera*)obj)->AddNotify(*cam);
    372348
    373349    c6->cd(4);
    374350    obj->Draw();
    375351
    376 
    377 #endif
    378 
    379352}
    380353
  • trunk/MagicSoft/Mars/manalysis/AnalysisLinkDef.h

    r2581 r2627  
    6969#pragma link C++ class MCalibrationCalc+;
    7070
     71#pragma link C++ class MExtractedSignalCam+;
     72#pragma link C++ class MExtractedSignalPix+;
     73#pragma link C++ class MExtractSignal+;
     74
    7175
    7276#endif
  • trunk/MagicSoft/Mars/manalysis/MCalibrationBlindPix.h

    r2603 r2627  
    4848  Float_t GetErrSigma1() const    { return fErrSigma1;  }
    4949
    50   Float_t GetTime()         const    { return fTime;         }
    51   Float_t GetErrTime()      const    { return fErrTime;      }
     50  Float_t GetTime()      const    { return fTime;         }
     51  Float_t GetErrTime()   const    { return fErrTime;      }
    5252 
    53   Bool_t FillCharge(Int_t q)            { return fHist->FillBlindPixelCharge(q); }
    54   Bool_t FillTime(Int_t t)            { return fHist->FillBlindPixelTime(t); } 
     53  Bool_t FillCharge(Float_t q)    { return fHist->FillBlindPixelCharge(q); }
     54  Bool_t FillTime(Int_t t)        { return fHist->FillBlindPixelTime(t); } 
    5555  Bool_t FillRChargevsTime(Float_t rq, Int_t t) { return fHist->FillBlindPixelChargevsN(rq,t); }   
    5656 
    57   Bool_t IsValid()                 { return fLambda > 0. || fErrLambda > 0.; }
     57  Bool_t IsValid()                { return fLambda > 0. || fErrLambda > 0.; }
    5858 
    5959  Bool_t FitCharge();
  • trunk/MagicSoft/Mars/manalysis/MCalibrationCalc.cc

    r2603 r2627  
    5353//               Every MCalibrationPix holds a histogram class,             //
    5454//               MHCalibrationPixel which itself hold histograms of type:   //
    55 //               HCharge(npix) (distribution of summed FADC time slice entries)  //
    56 //               HTime(npix) (distribution of position of maximum)             //
    57 //               HChargevsN(npix) (distribution of charges vs. event number.     //
    58 //                                                                          //
    59 // PostProcess:  All histograms HCharge(npix) are fitted to a Gaussian           //
    60 //               All histograms HTime(npix) are fitted to a Gaussian           //
    61 //               The histogram HBlindPixelCharge (blind pixel) is fitted to a single     //
    62 //                   PhE fit                                                //
    63 //               The histogram HBlindPixelTime (blind pixel) is fitted to a Gaussian   //
    64 //               The histograms of the PIN Diode are fitted to Gaussians    //
    65 //                                                                          //
    66 //               Fits can be excluded via the commands:                     //
    67 //               MalibrationCam::SetSkipTimeFits()   (skip all time fits)      //
    68 //               MalibrationCam::SetSkipBlindPixelFits()  (skip all blind pixel fits) //
    69 //               MalibrationCam::SetSkipPinDiodeFits()  (skip all PIN Diode fits) //
    70 //                                                                          //
     55//               HCharge(npix) (distribution of summed FADC time slice entries)
     56//               HTime(npix) (distribution of position of maximum)              
     57//               HChargevsN(npix) (distribution of charges vs. event number.
     58//                                                                         
     59// PostProcess:  All histograms HCharge(npix) are fitted to a Gaussian     
     60//               All histograms HTime(npix) are fitted to a Gaussian       
     61//               The histogram HBlindPixelCharge (blind pixel) is fitted to a single     
     62//                   PhE fit                                               
     63//               The histogram HBlindPixelTime (blind pixel) is fitted to a Gaussian   
     64//               The histograms of the PIN Diode are fitted to Gaussians   
     65//                                                                         
     66//               Fits can be excluded via the commands:                     
     67//               MalibrationCam::SetSkipTimeFits()   (skip all time fits)   
     68//               MalibrationCam::SetSkipBlindPixelFits()  (skip all blind pixel fits)
     69//               MalibrationCam::SetSkipPinDiodeFits()  (skip all PIN Diode fits)
     70//                                                                         
    7171//////////////////////////////////////////////////////////////////////////////
    7272
     
    169169      case kEBlue:
    170170        fCalibrations->SetColor(MCalibrationCam::kECBlue);
    171       break;       
     171        break;       
    172172      case kEGreen:
    173173        fCalibrations->SetColor(MCalibrationCam::kECGreen);     
    174       break;
     174        break;
    175175      case kEUV:
    176176        fCalibrations->SetColor(MCalibrationCam::kECUV);           
     177        break;
     178      case kECT1:
     179        fCalibrations->SetColor(MCalibrationCam::kECCT1);           
     180        break;
     181      default:
     182        fCalibrations->SetColor(MCalibrationCam::kECCT1);
    177183      }
    178 
    179 
    180184
    181185    fPedestals = (MPedestalCam*)pList->FindObject("MPedestalCam");
     
    185189        return kFALSE;
    186190      }
    187    
    188191   
    189192    return kTRUE;
     
    245248    MRawEvtPixelIter pixel(fRawEvt);
    246249
     250    //
    247251    // Create a first loop to sort out the cosmics ...
    248252    //
     
    266270        Float_t pedrms = ped.GetPedestalRms();
    267271       
    268         if ((float)sum < (pedes*fNumHiGainSamples)+(1.5*pedrms) )
     272        if ((float)sum < ((pedes*fNumHiGainSamples)+(30.*pedrms)) )
    269273           cosmicpix++;
    270274     }
     
    274278      {
    275279        fCosmics++;
    276         return kTRUE;
     280        return kCONTINUE;
    277281      }
    278282
    279283    pixel.Reset();
    280284
     285    //
     286    // Create a second loop to do fill the calibration histograms
     287    //
     288
    281289    while (pixel.Next())
    282290      {
    283291
    284292        UShort_t sat = 0;
    285         UShort_t lowgainoverflow = 0;
    286293
    287294        const Int_t pixid = pixel.GetPixelId();
    288295
    289         Byte_t *ptr = pixel.GetHiGainSamples();
    290296        Byte_t mid  = pixel.GetIdxMaxHiGainSample();
    291297        UInt_t max  = pixel.GetMaxHiGainSample();
    292298
    293         Int_t sum = (max > gkSaturationLimit              // overflow ?
    294                      ? sat++, pixel.GetSumLoGainSamples() // take Low Gain
    295                      : pixel.GetSumHiGainSamples());      // no overflow
    296 
    297         if (sat)
    298           {
    299 
    300             ptr = pixel.GetLoGainSamples();
    301             max = pixel.GetMaxLoGainSample();
    302             mid = pixel.GetIdxMaxLoGainSample();
    303 
    304             //
    305             //  FIXME: It seems the conversion HiGain LoGain is already
    306             //         performed in the data?!?
    307             //
    308             sum = (max > gkSaturationLimit                // overflow of LoGain ??? -> GimmeABreak!!!
    309                    ? lowgainoverflow++, gkLoGainOverFlow  // OUCH (Florian was maybe right)
    310                    : sum*gkConversionHiLo    );          // OUFF (Florian was wrong) !!
    311                    //                   : sum  );
    312 
    313             if (lowgainoverflow)
    314                 {
    315                   *fLog << err << dbginf << "Warning: Saturation of LoGain reached in pixel: " << pixid << " "
    316                         << "   sum = " << sum << endl;
    317                     fHistOverFlow++;
    318                 }
    319           }
    320 
    321         MPedestalPix    &ped = (*fPedestals)[pixid];
    322         MCalibrationPix &pix = (*fCalibrations)[pixid];
    323        
     299        MPedestalPix    &ped = (*fPedestals)[pixid];
     300        MCalibrationPix &pix = (*fCalibrations)[pixid];
     301
    324302        Float_t pedes  = ped.GetPedestal();
    325         Float_t pedrms = ped.GetPedestalRms();
    326        
     303        Float_t sum;
     304
    327305        //
    328306        // FIXME: This is preliminary, we will change to pedestals per slice!!!
    329307        // Assume pedestals per time slice ==> multiply with number of slices
    330308        //
    331         pedes  *= (sat ? fNumLoGainSamples : fNumHiGainSamples );
    332         pedrms *= (sat ? fNumLoGainSamples : fNumHiGainSamples );
    333 
    334         Float_t rsum      = (float)sum - pedes;
    335        
     309
     310        if (max < gkSaturationLimit)  // take Hi Gain
     311          {
     312            sum = (float)pixel.GetSumHiGainSamples() - pedes*fNumHiGainSamples; 
     313          }
     314        else                          // Lo Gain
     315          {
     316
     317            sat++;
     318            pix.SetHiGainSaturation();
     319
     320            sum = (float)pixel.GetSumLoGainSamples() - pedes*fNumLoGainSamples ;
     321            sum *= gkConversionHiLo;
     322
     323            max = pixel.GetMaxLoGainSample();
     324            mid = pixel.GetIdxMaxLoGainSample();
     325
     326            if (max > gkSaturationLimit)
     327              {
     328                *fLog << err << dbginf
     329                      << "Warning: Saturation of Lo Gain reached in pixel: "
     330                      << pixid << " " << "   sum = " << sum << endl;
     331                fHistOverFlow++;
     332              }
     333
     334          }
     335
    336336        switch(pixid)
    337337          {
     
    339339          case gkCalibrationBlindPixelId:
    340340
    341             //
    342             // FIXME: This works only when the blind pixel ID is much larger than
    343             //        the rest of the pixels (which is the case right now)
    344             //
    345341            if (!blindpixel.FillCharge(sum))
    346342              *fLog << warn <<
     
    351347                "Overflow or Underflow occurred filling Blind Pixel time = " << (int)mid << endl;
    352348           
    353             if (!blindpixel.FillRChargevsTime(rsum,fEvents))
     349            if (!blindpixel.FillRChargevsTime(sum,fEvents))
    354350              *fLog << warn <<
    355351                "Overflow or Underflow occurred filling Blind Pixel eventnr = " << fEvents << endl;
     
    362358              *fLog << warn <<
    363359                "Overflow or Underflow occurred filling HTime: time = " << (int)mid << endl;
    364             if (!pindiode.FillRChargevsTime(rsum,fEvents))
     360            if (!pindiode.FillRChargevsTime(sum,fEvents))
    365361              *fLog << warn <<
    366362                "Overflow or Underflow occurred filling HChargevsN: eventnr = " << fEvents << endl;
     
    368364          default:
    369365
    370             if (!pix.FillCharge(sum))
    371               *fLog << warn << "Could not fill Charge of pixel: " << pixid
    372                     << " signal = " << sum << endl;
    373 
    374             //
    375             // Fill the reduced charge into the control histo for better visibility
    376             //
    377             if (!pix.FillRChargevsTime(rsum,fEvents))
    378               *fLog << warn << "Could not fill red. Charge vs. EvtNr of pixel: " << pixid
    379                     << " signal = " << rsum  << " event Nr: " << fEvents << endl;
    380 
    381 
    382             if (!pix.FillTime((int)mid))
    383             *fLog << warn << "Could not fill Time of pixel: " << pixid << " time = " << (int)mid << endl;
    384 
    385 
     366            if (sat)
     367              {
     368               
     369                if (!pix.FillChargeLoGain(sum))
     370                  *fLog << warn << "Could not fill Lo Gain Charge of pixel: " << pixid
     371                        << " signal = " << sum << endl;
     372
     373                if (!pix.FillTimeLoGain((int)mid))
     374                  *fLog << warn << "Could not fill Lo Gain Time of pixel: "
     375                        << pixid << " time = " << (int)mid << endl;
     376               
     377                //
     378                // Fill the reduced charge into the control histo for better visibility
     379                //
     380                if (!pix.FillRChargevsTimeLoGain(sum,fEvents))
     381                  *fLog << warn << "Could not fill Lo Gain Charge vs. EvtNr of pixel: "
     382                        << pixid << " signal = " << sum  << " event Nr: " << fEvents << endl;
     383               
     384              }
     385            else
     386              {
     387                if (!pix.FillChargeHiGain(sum))
     388                  *fLog << warn << "Could not fill Hi Gain Charge of pixel: " << pixid
     389                        << " signal = " << sum << endl;
     390               
     391                if (!pix.FillTimeHiGain((int)mid))
     392                  *fLog << warn << "Could not fill Hi Gain Time of pixel: "
     393                        << pixid << " time = " << (int)mid << endl;
     394               
     395                if (!pix.FillRChargevsTimeHiGain(sum,fEvents))
     396                  *fLog << warn << "Could not fill Hi Gain Charge vs. EvtNr of pixel: "
     397                        << pixid << " signal = " << sum  << " event Nr: " << fEvents << endl;
     398              }
     399           
    386400          } /* switch(pixid) */
    387401
     
    396410  *fLog << inf << endl;
    397411  *fLog << GetDescriptor() << " Cut Histogram Edges" << endl;
     412
    398413  //
    399414  // Cut edges to make fits and viewing of the hists easier 
     
    414429    {
    415430      if (blindpixel.FitCharge())
    416         if (!fCalibrations->CalcNrPhotInnerPixel())
    417           *fLog << err << dbginf << "Could not calculate Number of photons from the blind pixel " << endl;
     431        {
     432          if (!fCalibrations->CalcNrPhotInnerPixel())
     433            *fLog << err << dbginf << "Could not calculate Number of photons from the blind pixel " << endl;
     434        }
    418435      else
    419         *fLog << err << dbginf << "Could not fit the blind pixel " << endl;
    420      
     436        {
     437          *fLog << err << dbginf << "Could not fit the blind pixel " << endl;
     438        }
     439
    421440      if (!blindpixel.FitTime())
    422441        *fLog << warn << "Could not the Times of the blind pixel " << endl;
  • trunk/MagicSoft/Mars/manalysis/MCalibrationCalc.h

    r2603 r2627  
    5454public:
    5555 
    56   enum PulserColor_t  { kEGreen, kEBlue, kEUV };
     56  enum PulserColor_t  { kEGreen, kEBlue, kEUV, kECT1 };
    5757
    5858private:
  • trunk/MagicSoft/Mars/manalysis/MCalibrationCam.cc

    r2603 r2627  
    5757MCalibrationCam::MCalibrationCam(const char *name, const char *title)
    5858    : fMeanNrPhotAvailable(kFALSE),
    59       fMeanNrPhotInnerPix(-1.)
     59      fMeanNrPhotInnerPix(-1.),
     60      fMeanNrPhotInnerPixErr(-1.)
    6061{
    6162    fName  = name  ? name  : "MCalibrationCam";
     
    153154Bool_t MCalibrationCam::IsPixelFitted(Int_t idx) const
    154155{
    155   return ((*this)[idx].GetRCharge() > 0. && (*this)[idx].GetErrRCharge() > 0.);
     156  return ((*this)[idx].GetCharge() > 0. && (*this)[idx].GetErrCharge() > 0.);
    156157}
    157158
     
    359360    int id = 0;
    360361
     362    *fLog << "Succesfully calibrated pixels:" << endl;
     363    *fLog << endl;
     364
    361365    TIter Next(fPixels);
    362366    MCalibrationPix *pix;
     
    364368    {
    365369
    366         *fLog << id << " Pedestals: " << pix->GetPed() << " +- " << pix->GetPedRms() << " Charge: "
    367               << pix->GetCharge() << " Reduced Charge: " << pix->GetRCharge() << " +- "
    368               << pix->GetSigmaCharge() << " Reduced Sigma: " << pix->GetRSigma() << endl;
    369 
    370         id++;
    371     }
     370      if (pix->GetCharge() >= 0.)
     371        {
     372          *fLog << pix->GetPixId() << " Pedestals: " << pix->GetPed() << " +- " << pix->GetPedRms()
     373                << " Reduced Charge: " << pix->GetCharge() << " +- "
     374                << pix->GetSigmaCharge() << " Reduced Sigma: " << pix->GetRSigma() << endl;
     375          id++;
     376        }
     377    }
     378
     379    *fLog << id << " succesful pixels :-))" << endl;
     380    id = 0;
     381
     382    *fLog << endl;
     383    *fLog << "Pixels with errors:" << endl;
     384    *fLog << endl;
     385
     386    TIter Next2(fPixels);
     387    while ((pix=(MCalibrationPix*)Next2()))
     388    {
     389
     390      if (pix->GetCharge() == -1.)
     391        {
     392          *fLog << pix->GetPixId() << " Pedestals: " << pix->GetPed() << " +- " << pix->GetPedRms()
     393                << " Reduced Charge: " << pix->GetCharge() << " +- "
     394                << pix->GetSigmaCharge() << " Reduced Sigma: " << pix->GetRSigma() << endl;
     395          id++;
     396        }
     397    }
     398    *fLog << id << " pixels with errors :-((" << endl;
     399
    372400}
    373401
     
    379407    {
    380408    case 0:
    381        val = (*this)[idx].GetCharge();
    382         break;
     409      val = (*this)[idx].GetCharge();
     410      break;
    383411    case 1:
    384        val = (*this)[idx].GetErrCharge();
    385         break;
     412      val = (*this)[idx].GetErrCharge();
     413      break;
    386414    case 2:
    387        val = (*this)[idx].GetSigmaCharge();
    388         break;
     415      val = (*this)[idx].GetSigmaCharge();
     416      break;
    389417    case 3:
    390        val = (*this)[idx].GetErrSigmaCharge();
    391         break;
     418      val = (*this)[idx].GetErrSigmaCharge();
     419      break;
    392420    case 4:
    393        val = (*this)[idx].GetChargeProb();
    394         break;
     421      val = (*this)[idx].GetChargeProb();
     422      break;
    395423    case 5:
    396        val = (*this)[idx].GetTime();
    397         break;
     424      val = (*this)[idx].GetTime();
     425      break;
    398426    case 6:
    399        val = (*this)[idx].GetSigmaTime();
    400         break;
     427      val = (*this)[idx].GetSigmaTime();
     428      break;
    401429    case 7:
    402        val = (*this)[idx].GetTimeProb();
    403         break;
     430      val = (*this)[idx].GetTimeProb();
     431      break;
    404432    case 8:
    405        val = (*this)[idx].GetPed();
    406         break;
     433      val = (*this)[idx].GetPed();
     434      break;
    407435    case 9:
    408        val = (*this)[idx].GetPedRms();
    409         break;
     436      val = (*this)[idx].GetPedRms();
     437      break;
    410438    case 10:
    411       val = (*this)[idx].GetRCharge();
     439      val = (*this)[idx].GetRSigma();
    412440      break;
    413441    case 11:
    414       val = (*this)[idx].GetRSigma();
     442      val = (*this)[idx].GetPheFFactorMethod();
    415443      break;
    416444    case 12:
    417       val = (*this)[idx].GetPheFFactorMethod();
     445      val = (*this)[idx].GetConversionFFactorMethod();
    418446      break;
    419447    case 13:
    420       val = (*this)[idx].GetConversionFFactorMethod();
     448      if (idx < 397)
     449        val = (double)fMeanNrPhotInnerPix;
     450      else
     451        val = (double)fMeanNrPhotInnerPix*gkCalibrationOuterPixelArea;
    421452      break;
    422453    case 14:
    423       val = (double)fMeanNrPhotInnerPix;
    424       break;
    425     case 15:
    426       if ((fMeanNrPhotInnerPix > 0. ) && ((*this)[idx].GetRCharge() > 100.))
    427         val = fMeanNrPhotInnerPix / (*this)[idx].GetRCharge();
    428       else
    429         val = -1.;
     454      if ((fMeanNrPhotInnerPix > 0. ) && ((*this)[idx].GetCharge() != -1.))
     455        {
     456          if (idx < 397)
     457            val = fMeanNrPhotInnerPix / (*this)[idx].GetCharge();
     458          else
     459            val = fMeanNrPhotInnerPix*gkCalibrationOuterPixelArea / (*this)[idx].GetCharge();
     460        }
     461      else
     462        {
     463          val = -1.;
     464        }
    430465      break;
    431466    default:
     
    467502                            / gkCalibrationBlindPixelArea;
    468503      break;
     504    case kECCT1:
     505    default:
     506      fMeanNrPhotInnerPix = (mean / gkCalibrationBlindPixelQECT1 )
     507                            *TMath::Power(10,gkCalibrationBlindPixelAttCT1)
     508                            / gkCalibrationBlindPixelArea;
     509      break;
    469510    }
    470511
     
    474515
    475516
    476 
    477 Bool_t MCalibrationCam::GetConversionFactor(Int_t ipx, Float_t &mean, Float_t &err)
     517Bool_t MCalibrationCam::GetConversionFactorBlindPixel(Int_t ipx, Float_t &mean, Float_t &err, Float_t &sigma)
    478518{
    479519 
     
    485525      return kFALSE;
    486526
    487   mean = fMeanNrPhotInnerPix / (*this)[ipx].GetRCharge();
     527  mean = fMeanNrPhotInnerPix / (*this)[ipx].GetCharge();
    488528
    489529  //
    490530  // Not yet ready , sorry
    491531  //
    492   err  = 100000000000.;
     532  err  = -1.;
     533  sigma = -1.;
    493534
    494535  return kTRUE;
    495536}
     537
     538
     539Bool_t MCalibrationCam::GetConversionFactorFFactor(Int_t ipx, Float_t &mean, Float_t &err, Float_t &sigma)
     540{
     541 
     542  if (ipx < 0 || !IsPixelFitted(ipx))
     543    return kFALSE;
     544
     545  Float_t conv = (*this)[ipx].GetConversionFFactorMethod();
     546
     547  if (conv < 0.)
     548    return kFALSE;
     549
     550  mean = conv;
     551
     552  //
     553  // Not yet ready , sorry
     554  //
     555  err  = -1.;
     556  sigma = -1.;
     557
     558  return kTRUE;
     559}
  • trunk/MagicSoft/Mars/manalysis/MCalibrationCam.h

    r2603 r2627  
    3838  MCalibrationPINDiode *fPINDiode;   //! containing PIN Diode data with fit results   
    3939
     40  Bool_t  fMeanNrPhotAvailable;
    4041  Float_t fMeanNrPhotInnerPix;       // The mean number of photons in an inner pixel 
    4142  Float_t fMeanNrPhotInnerPixErr;    // The uncertainty about the number of photons in an inner pixel 
    42   Bool_t  fMeanNrPhotAvailable;
    4343
    4444public:
    4545 
    46   enum CalibrationColor_t { kECGreen, kECBlue, kECUV };
     46  enum CalibrationColor_t { kECGreen, kECBlue, kECUV, kECCT1 };
    4747
    4848private:
     
    8989  void SetColor(CalibrationColor_t color)    { fColor = color; }
    9090
    91   Bool_t GetConversionFactor(Int_t ipx, Float_t &mean, Float_t &err);
     91  Bool_t GetConversionFactorFFactor(Int_t ipx, Float_t &mean, Float_t &err, Float_t &sigma);
     92  Bool_t GetConversionFactorBlindPixel(Int_t ipx, Float_t &mean, Float_t &err, Float_t &sigma);
    9293 
    9394  ClassDef(MCalibrationCam, 1)  // Storage Container for all calibration information of the camera
  • trunk/MagicSoft/Mars/manalysis/MCalibrationConfig.h

    r2603 r2627  
    1515
    1616// The conversion factor between High Gain and Low Gain
    17 const UShort_t gkConversionHiLo = 10.;
     17const Float_t gkConversionHiLo = 10.;
    1818
    1919// The penalty constant to produce overflow in the histogram
     
    2929const Float_t gkCalibrationBlindPixelQEBlue  = 0.226;
    3030const Float_t gkCalibrationBlindPixelQEUV    = 0.247;
     31const Float_t gkCalibrationBlindPixelQECT1   = 0.247;
    3132
    3233// Attenuation factor Blind Pixel (three colours)
     
    3435const Float_t gkCalibrationBlindPixelAttBlue  = 1.96;
    3536const Float_t gkCalibrationBlindPixelAttUV    = 1.95;
     37const Float_t gkCalibrationBlindPixelAttCT1   = 1.95;
    3638
    3739// Area of Blind Pixel w.r.t. Inner Pixel
    3840const Float_t gkCalibrationBlindPixelArea     = 0.25;
     41
     42// Area of Outer Pixel w.r.t. Inner Pixel
     43const Float_t gkCalibrationOuterPixelArea     = 4.00;
    3944
    4045// ----- PIN DIODE ------------------------//
  • trunk/MagicSoft/Mars/manalysis/MCalibrationPINDiode.cc

    r2603 r2627  
    7979Bool_t MCalibrationPINDiode::FitCharge()
    8080{
    81   if(!fHist->FitCharge())
     81  if(!fHist->FitChargeHiGain())
    8282    return kFALSE;
    8383
     
    9494{
    9595
    96   if(!fHist->FitTime())
     96  if(!fHist->FitTimeHiGain())
    9797    return kFALSE;
    9898
  • trunk/MagicSoft/Mars/manalysis/MCalibrationPINDiode.h

    r2603 r2627  
    3333  void Clear(Option_t *o="");
    3434 
    35   void SetPed(Float_t ped)         { fPed      = ped;      }
     35  void SetPed(Float_t ped)          { fPed      = ped;      }
    3636  void SetPedRms(Float_t pedrms)    { fPedRms   = pedrms; }
    3737
    3838  Bool_t IsValid() const { return fRCharge >=0 || fErrRCharge >= 0; }
    3939
    40   Bool_t FillCharge(Int_t q)            { return fHist->FillCharge(q); }
    41   Bool_t FillTime(Int_t t)            { return fHist->FillTime(t); } 
    42   Bool_t FillRChargevsTime(Float_t rq, Int_t t) { return fHist->FillChargevsN(rq,t); }   
     40  Bool_t FillCharge(Float_t q)      { return fHist->FillChargeHiGain(q); }
     41  Bool_t FillTime(Int_t t)          { return fHist->FillTimeHiGain(t); } 
     42  Bool_t FillRChargevsTime(Float_t rq, Int_t t) { return fHist->FillChargevsNHiGain(rq,t); }   
    4343 
    4444  Bool_t FitCharge();
  • trunk/MagicSoft/Mars/manalysis/MCalibrationPix.cc

    r2603 r2627  
    5050      fSigmaCharge(-1.),
    5151      fErrSigmaCharge(-1.),
     52      fRSigma(-1.),
    5253      fChargeProb(-1.),
    5354      fPed(-1.),
     
    5657      fSigmaTime(-1.),
    5758      fTimeProb(-1.),
    58       fRCharge(-1.),
    59       fErrRCharge(-1.),
    60       fRSigma(-1.),
    6159      fFactor(1.3),
    6260      fPheFFactorMethod(-1.),
    63       fConversionFFactorMethod(-1.)
     61      fConversionFFactorMethod(-1.),
     62      fHiGainSaturation(kFALSE)
    6463{
    6564
     
    102101
    103102  if (fPed && fPedRms)
    104     fHist->SetLowerFitRange(fPed + 1.5*fPedRms);
     103    fHist->SetLowerFitRange(3.5*fPedRms);
     104  //    fHist->SetLowerFitRange(fPed + 3.5*fPedRms);
    105105  else
    106106    *fLog << warn << "Cannot set lower fit range to suppress cosmics: Pedestals not available" << endl;
    107107
    108   if(!fHist->FitCharge())
     108
     109  if (fHiGainSaturation)
    109110    {
    110       *fLog << warn << "Could not fit charges of pixel " << fPixId << endl;
    111       fHist->PrintChargeFitResult();
    112       return kFALSE;
     111      if(!fHist->FitChargeLoGain())
     112        {
     113          *fLog << warn << "Could not fit Lo Gain charges of pixel " << fPixId << endl;
     114          fHist->PrintChargeFitResult();
     115          return kFALSE;
     116        }
     117    }
     118  else
     119    {
     120      if(!fHist->FitChargeHiGain())
     121        {
     122          *fLog << warn << "Could not fit Hi Gain charges of pixel " << fPixId << endl;
     123          fHist->PrintChargeFitResult();
     124          return kFALSE;
     125        }
    113126    }
    114127 
     128
    115129  fCharge         = fHist->GetChargeMean();
    116130  fErrCharge      = fHist->GetChargeMeanErr();
     
    122136    {
    123137     
    124     fRCharge      = fCharge - fPed;
    125     fErrRCharge   = TMath::Sqrt(fErrCharge*fErrCharge + fPedRms*fPedRms);
    126 
    127138    fRSigma       = (fSigmaCharge*fSigmaCharge) - (fPedRms*fPedRms);
    128139
    129140    if (fRSigma > 0. )
    130141      {
    131        fPheFFactorMethod =  fFactor * fRCharge*fRCharge / fRSigma;
    132        fConversionFFactorMethod = fPheFFactorMethod / fRCharge ;
     142       fPheFFactorMethod =  fFactor * fCharge*fCharge / fRSigma;
     143       fConversionFFactorMethod = fPheFFactorMethod /   fCharge ;
    133144      }
    134145    else
     
    144155}
    145156
     157
    146158void MCalibrationPix::SetPedestal(Float_t ped, Float_t pedrms)
    147159{
     
    150162  fPedRms = pedrms;
    151163 
    152   if ((fRCharge == -1.) && (fCharge > 0.))
    153     fRCharge = fCharge - fPed;
    154   if ((fErrRCharge == -1.) && (fErrCharge > 0.))
    155     fErrRCharge   = TMath::Sqrt(fErrCharge*fErrCharge + fPedRms*fPedRms);
    156 
    157164}
    158165
     
    160167{
    161168
    162   if(!fHist->FitTime())
     169  if (fHiGainSaturation)
    163170    {
    164       *fLog << warn << "Could not fit times of pixel " << fPixId << endl;
    165       fHist->PrintTimeFitResult();
    166       return kFALSE;
     171      if(!fHist->FitTimeLoGain())
     172        {
     173          *fLog << warn << "Could not fit Lo Gain times of pixel " << fPixId << endl;
     174          fHist->PrintTimeFitResult();
     175          return kFALSE;
     176        }
    167177    }
    168 
     178  else
     179    {
     180      if(!fHist->FitTimeHiGain())
     181        {
     182          *fLog << warn << "Could not fit Hi Gain times of pixel " << fPixId << endl;
     183          fHist->PrintTimeFitResult();
     184          return kFALSE;
     185        }
     186    }
     187   
    169188  fTime       = fHist->GetTimeMean();
    170189  fSigmaTime  = fHist->GetTimeSigma();
  • trunk/MagicSoft/Mars/manalysis/MCalibrationPix.h

    r2603 r2627  
    1414  Int_t   fPixId;           // the pixel Id
    1515 
    16   Float_t fCharge;              // The mean charge after the fit
    17   Float_t fErrCharge;           // The error of mean charge after the fit
     16  Float_t fCharge;              // The mean reduced charge after the fit
     17  Float_t fErrCharge;           // The error of reduced mean charge after the fit
    1818  Float_t fSigmaCharge;         // The sigma of the mean charge after the fit
    1919  Float_t fErrSigmaCharge;      // The error of the sigma of the mean charge after the fit
     20  Float_t fRSigma;              // The reduced squares of sigmas after the fit
    2021  Float_t fChargeProb;          // The probability of the fit function
    2122
     
    2728  Float_t fTimeProb;            // The probability of the fit function
    2829 
    29   Float_t fRCharge;             // The reduced mean charge after the fit
    30   Float_t fErrRCharge;          // The error of the reduced mean charge after the fit 
    31   Float_t fRSigma;              // The reduced squares of sigmas after the fit
    32  
    3330  Float_t fFactor;                  // The laboratory F-factor
    3431  Float_t fPheFFactorMethod;        // The number of Phe's calculated after the F-factor method
    3532  Float_t fConversionFFactorMethod; // The conversion factor to Phe's calculated after the F-factor method
     33
     34  Bool_t fHiGainSaturation;     // Is Lo-Gain used at all?
    3635
    3736  MHCalibrationPixel *fHist;    //! Pointer to the histograms performing the fits, etc. 
     
    4544
    4645  Float_t GetCharge()         const    { return fCharge;         }
    47   Float_t GetRCharge()        const    { return fRCharge;        }
    4846  Float_t GetRSigma()         const    { return fRSigma;         }
    4947   
    5048  Float_t GetErrCharge()      const    { return fErrCharge;      }
    51   Float_t GetErrRCharge()     const    { return fErrRCharge;     }   
    5249  Float_t GetChargeProb()     const    { return fChargeProb;     }   
    5350 
    5451  Float_t GetSigmaCharge()    const    { return fSigmaCharge;    }
    5552  Float_t GetErrSigmaCharge() const    { return fErrSigmaCharge; }
    56   Float_t GetTime()         const    { return fTime;         }
    57   Float_t GetSigmaTime()    const    { return fSigmaTime;    }
    58   Float_t GetTimeProb()     const    { return fTimeProb;     }   
     53  Float_t GetTime()           const    { return fTime;         }
     54  Float_t GetSigmaTime()      const    { return fSigmaTime;    }
     55  Float_t GetTimeProb()       const    { return fTimeProb;     }   
    5956 
    60   Float_t GetPed()          const    { return fPed;       }
    61   Float_t GetPedRms()       const    { return fPedRms;    }   
     57  Float_t GetPed()            const    { return fPed;       }
     58  Float_t GetPedRms()         const    { return fPedRms;    }   
    6259
    6360  void SetPedestal(Float_t ped, Float_t pedrms);
     61  void SetHiGainSaturation()                 { fHiGainSaturation = kTRUE; fHist->SetUseLoGain(); }
    6462
    65   Bool_t FillCharge(Int_t q)           { return fHist->FillCharge(q); }
    66   Bool_t FillTime(Int_t t)             { return fHist->FillTime(t); } 
    67   Bool_t FillRChargevsTime(Float_t rq, Int_t t) { return fHist->FillChargevsN(rq,t); }   
     63  Bool_t FillChargeHiGain(Float_t q)   { return fHist->FillChargeHiGain(q); }
     64  Bool_t FillTimeHiGain(Int_t t)       { return fHist->FillTimeHiGain(t); } 
     65  Bool_t FillRChargevsTimeHiGain(Float_t rq, Int_t t) { return fHist->FillChargevsNHiGain(rq,t); }   
     66
     67  Bool_t FillChargeLoGain(Float_t q)   { return fHist->FillChargeLoGain(q); }
     68  Bool_t FillTimeLoGain(Int_t t)       { return fHist->FillTimeLoGain(t); } 
     69  Bool_t FillRChargevsTimeLoGain(Float_t rq, Int_t t) { return fHist->FillChargevsNLoGain(rq,t); }   
    6870 
    69   Bool_t IsValid()          const    { return fRCharge >=0 || fErrRCharge >= 0; }
    70   Int_t  GetPixId()         const    { return fPixId;   }
     71  Bool_t IsValid()            const    { return fCharge >=0 || fErrCharge >= 0; }
     72  Int_t  GetPixId()           const    { return fPixId;   }
    7173  void   DefinePixId(Int_t i);
    7274 
     
    7476  Bool_t FitTime();
    7577 
    76   MHCalibrationPixel *GetHist() const  { return fHist;  }
    77   virtual void Draw(Option_t *opt="")   { fHist->Draw(opt); }
     78  MHCalibrationPixel *GetHist() const   { return fHist;     }
     79  void Draw(Option_t *opt="")           { fHist->Draw(opt); }
    7880 
    7981  Float_t GetPheFFactorMethod()           const { return fPheFFactorMethod;           } 
  • trunk/MagicSoft/Mars/manalysis/Makefile

    r2581 r2627  
    7575           MCalibrationBlindPix.cc  \
    7676           MCalibrationPINDiode.cc  \
    77            MCalibrationCam.cc
     77           MCalibrationCam.cc \
     78           MExtractedSignalCam.cc \
     79           MExtractedSignalPix.cc \
     80           MExtractSignal.cc
    7881
    7982SRCS    = $(SRCFILES)
  • trunk/MagicSoft/Mars/mhist/MHCalibrationBlindPixel.cc

    r2603 r2627  
    6969
    7070    // Create a large number of bins, later we will rebin
    71     fBlindPixelChargefirst = 0;
     71    fBlindPixelChargefirst = -1000.;
    7272    fBlindPixelChargelast  = gkStartBlindPixelBinNr;
    73     fBlindPixelChargenbins = gkStartBlindPixelBinNr;
    74 
    75     fHBlindPixelCharge = new TH1I("HBlindPixelCharge","Distribution of Summed FADC Slices",fBlindPixelChargenbins,fBlindPixelChargefirst,fBlindPixelChargelast);
     73    fBlindPixelChargenbins = gkStartBlindPixelBinNr+(int)fBlindPixelChargefirst;
     74
     75    fHBlindPixelCharge = new TH1F("HBlindPixelCharge","Distribution of Summed FADC Slices",
     76                                  fBlindPixelChargenbins,fBlindPixelChargefirst,fBlindPixelChargelast);
    7677    fHBlindPixelCharge->SetXTitle("Sum FADC Slices");
    7778    fHBlindPixelCharge->SetYTitle("Nr. of events");
     
    313314  const Double_t lambda_guess = 0.2;
    314315  const Double_t mu_0_guess = fHBlindPixelCharge->GetBinCenter(fHBlindPixelCharge->GetMaximumBin());
    315   const Double_t si_0_guess = mu_0_guess/10.;
     316  const Double_t si_0_guess = mu_0_guess/5.;
    316317  const Double_t mu_1_guess = mu_0_guess + 50.;
    317318  const Double_t si_1_guess = si_0_guess + si_0_guess;
  • trunk/MagicSoft/Mars/mhist/MHCalibrationBlindPixel.h

    r2603 r2627  
    3232private:
    3333
    34   TH1I* fHBlindPixelCharge;        //-> Histogram with the single Phe spectrum
     34  TH1F* fHBlindPixelCharge;        //-> Histogram with the single Phe spectrum
    3535  TH1F* fHBlindPixelErrCharge;     //-> Variance of summed FADC slices
    3636  TH1I* fHBlindPixelTime;        //-> Variance of summed FADC slices
     
    8383  ~MHCalibrationBlindPixel();
    8484
    85   Bool_t FillBlindPixelCharge(Int_t q)         { return fHBlindPixelCharge->Fill(q) > -1;  } 
    86   Bool_t FillErrBlindPixelCharge(Float_t errq) { return fHBlindPixelErrCharge->Fill(errq) > -1; }
    87   Bool_t FillBlindPixelTime(Int_t t)         { return fHBlindPixelTime->Fill(t) > -1;  }
     85  Bool_t FillBlindPixelCharge(Float_t q)             { return fHBlindPixelCharge->Fill(q) > -1;  } 
     86  Bool_t FillErrBlindPixelCharge(Float_t errq)       { return fHBlindPixelErrCharge->Fill(errq) > -1; }
     87  Bool_t FillBlindPixelTime(Int_t t)                 { return fHBlindPixelTime->Fill(t) > -1;  }
    8888  Bool_t FillBlindPixelChargevsN(Stat_t rq, Int_t t) { return fHBlindPixelChargevsN->Fill(t,rq) > -1;  } 
    8989 
     
    123123  void ChangeFitFunc(BlindPixelFitFunc fitfunc, Int_t par=5);
    124124
    125 
    126125  void CutAllEdges();
    127126  void Draw(Option_t *option="");
    128127
    129   ClassDef(MHCalibrationBlindPixel, 0)
     128  ClassDef(MHCalibrationBlindPixel, 1)
    130129};
    131130
  • trunk/MagicSoft/Mars/mhist/MHCalibrationConfig.h

    r2603 r2627  
    77//                                                                         //
    88// Contains all configuration data of the Calibration                      //
    9 //                                                                         //
     9//                       i                                                  //
    1010/////////////////////////////////////////////////////////////////////////////
    1111
  • trunk/MagicSoft/Mars/mhist/MHCalibrationPINDiode.cc

    r2603 r2627  
    6767
    6868    // Create a large number of bins, later we will rebin
    69     fChargeFirst = 0;
    70     fChargeLast  = gkStartPINDiodeBinNr;
    71     fChargeNbins = gkStartPINDiodeBinNr;
     69    fChargeFirstHiGain = -1000.;
     70    fChargeLastHiGain  = gkStartPINDiodeBinNr;
     71    fChargeNbinsHiGain = gkStartPINDiodeBinNr;
    7272
    73     fHPCharge = new TH1I("HPCharge","Distribution of Summed FADC Slices",fChargeNbins,fChargeFirst,fChargeLast);
     73    fHPCharge = new TH1I("HPCharge","Distribution of Summed FADC Slices",
     74                         fChargeNbinsHiGain,fChargeFirstHiGain,fChargeLastHiGain);
    7475    fHPCharge->SetXTitle("Sum FADC Slices");
    7576    fHPCharge->SetYTitle("Nr. of events");
  • trunk/MagicSoft/Mars/mhist/MHCalibrationPixel.cc

    r2603 r2627  
    6565        fTimeGausFit(NULL),
    6666        fFitLegend(NULL),
    67         fLowerFitRange(0.),
     67        fLowerFitRange(-2000.),
     68        fChargeFirstHiGain(-2000.5),
     69        fChargeLastHiGain(9999.5),
     70        fChargeNbinsHiGain(12000),
     71        fChargeFirstLoGain(-2000.5),
     72        fChargeLastLoGain(9999.5),
     73        fChargeNbinsLoGain(1200),
    6874        fFitOK(kFALSE),
    6975        fChargeChisquare(-1.),
     
    7278        fTimeChisquare(-1.),
    7379        fTimeProb(-1.),
    74         fTimeNdf(-1)
     80        fTimeNdf(-1),
     81        fUseLoGain(kFALSE)
    7582{
    7683
     
    7986
    8087    // Create a large number of bins, later we will rebin
    81     fChargeFirst = -0.5;
    82     fChargeLast  = 10000. - 0.5;
    83     fChargeNbins = 20000;
    84 
    85     fHCharge = new TH1I("HCharge","Distribution of Summed FADC Slices Pixel ",
    86                    fChargeNbins,fChargeFirst,fChargeLast);
    87     fHCharge->SetXTitle("Sum FADC Slices");
    88     fHCharge->SetYTitle("Nr. of events");
    89     fHCharge->Sumw2();
    90 
    91     fHCharge->SetDirectory(NULL);
     88    fHChargeHiGain = new TH1F("HChargeHiGain","Distribution of Summed FADC Hi Gain Slices Pixel ",
     89                              fChargeNbinsHiGain,fChargeFirstHiGain,fChargeLastHiGain);
     90    fHChargeHiGain->SetXTitle("Sum FADC Slices (Hi Gain)");
     91    fHChargeHiGain->SetYTitle("Nr. of events");
     92    fHChargeHiGain->Sumw2();
     93
     94    fHChargeHiGain->SetDirectory(NULL);
     95
     96    fHChargeLoGain = new TH1F("HChargeLoGain","Distribution of Summed FADC Lo Gain Slices Pixel ",
     97                              fChargeNbinsLoGain,fChargeFirstLoGain,fChargeLastLoGain);
     98    fHChargeLoGain->SetXTitle("Sum FADC Slices (Lo Gain)");
     99    fHChargeLoGain->SetYTitle("Nr. of events");
     100    fHChargeLoGain->Sumw2();
     101
     102    fHChargeLoGain->SetDirectory(NULL);
    92103
    93104    Axis_t tfirst = -0.5;
     
    95106    Int_t  ntbins = 16;
    96107
    97     fHTime = new TH1I("HTime","Distribution of Mean Arrival Times Pixel ",
    98                   ntbins,tfirst,tlast);
    99     fHTime->SetXTitle("Mean Arrival Times [FADC slice nr]");
    100     fHTime->SetYTitle("Nr. of events");
    101     fHTime->Sumw2();
    102 
    103     fHTime->SetDirectory(NULL);
    104 
    105     TString qvsntitle = "Sum of Charges vs. Event Number Pixel ";
     108    fHTimeHiGain = new TH1I("HTimeHiGain","Distribution of Mean Arrival Hi Gain Times Pixel ",
     109                            ntbins,tfirst,tlast);
     110    fHTimeHiGain->SetXTitle("Mean Arrival Times [Hi Gain FADC slice nr]");
     111    fHTimeHiGain->SetYTitle("Nr. of events");
     112    fHTimeHiGain->Sumw2();
     113
     114    fHTimeHiGain->SetDirectory(NULL);
     115
     116    fHTimeLoGain = new TH1I("HTimeLoGain","Distribution of Mean Arrival Lo Gain Times Pixel ",
     117                            ntbins,tfirst,tlast);
     118    fHTimeLoGain->SetXTitle("Mean Arrival Times [Lo Gain FADC slice nr]");
     119    fHTimeLoGain->SetYTitle("Nr. of events");
     120    fHTimeLoGain->Sumw2();
     121
     122    fHTimeLoGain->SetDirectory(NULL);
    106123
    107124    // We define a reasonable number and later enlarge it if necessary
     
    110127    Axis_t nlast  = (Axis_t)nqbins - 0.5;
    111128
    112     fHChargevsN = new TH1I("HChargevsN",qvsntitle.Data(),
    113                      nqbins,nfirst,nlast);
    114     fHChargevsN->SetXTitle("Event Nr.");
    115     fHChargevsN->SetYTitle("Sum of FADC slices");
    116 
    117     fHChargevsN->SetDirectory(NULL);
     129    fHChargevsNHiGain = new TH1I("HChargevsNHiGain","Sum of Hi Gain Charges vs. Event Number Pixel ",
     130                                 nqbins,nfirst,nlast);
     131    fHChargevsNHiGain->SetXTitle("Event Nr.");
     132    fHChargevsNHiGain->SetYTitle("Sum of Hi Gain FADC slices");
     133
     134    fHChargevsNHiGain->SetDirectory(NULL);
     135
     136    fHChargevsNLoGain = new TH1I("HChargevsNLoGain","Sum of Lo Gain Charges vs. Event Number Pixel ",
     137                                 nqbins,nfirst,nlast);
     138    fHChargevsNLoGain->SetXTitle("Event Nr.");
     139    fHChargevsNLoGain->SetYTitle("Sum of Lo Gain FADC slices");
     140
     141    fHChargevsNLoGain->SetDirectory(NULL);
    118142
    119143}
     
    122146{
    123147
    124   delete fHCharge;
    125   delete fHTime;
    126   delete fHChargevsN;
     148  delete fHChargeHiGain;
     149  delete fHTimeHiGain;
     150  delete fHChargevsNHiGain;
     151
     152  delete fHChargeLoGain;
     153  delete fHTimeLoGain;
     154  delete fHChargevsNLoGain;
    127155
    128156  if (fChargeGausFit)
     
    141169  fPixId = id;
    142170 
    143   TString nameQ = TString(fHCharge->GetName());
    144   nameQ += id;
    145   fHCharge->SetName(nameQ.Data());
    146 
    147   TString nameT = TString(fHTime->GetName());
    148   nameT += id;
    149   fHTime->SetName(nameT.Data());
    150 
    151   TString nameQvsN  = TString(fHChargevsN->GetName());
    152   nameQvsN += id;
    153   fHChargevsN->SetName(nameQvsN.Data());
    154 
    155   TString titleQ = TString(fHCharge->GetTitle());
    156   titleQ += id;
    157   fHCharge->SetTitle(titleQ.Data());
    158 
    159   TString titleT = TString(fHTime->GetTitle());
    160   titleT += id;
    161   fHTime->SetTitle(titleT.Data());
    162 
    163   TString titleQvsN  = TString(fHChargevsN->GetTitle());
    164   titleQvsN += id;
    165   fHChargevsN->SetTitle(titleQvsN.Data());
     171  TString nameQHiGain = TString(fHChargeHiGain->GetName());
     172  nameQHiGain += id;
     173  fHChargeHiGain->SetName(nameQHiGain.Data());
     174
     175  TString nameTHiGain = TString(fHTimeHiGain->GetName());
     176  nameTHiGain += id;
     177  fHTimeHiGain->SetName(nameTHiGain.Data());
     178
     179  TString nameQvsNHiGain  = TString(fHChargevsNHiGain->GetName());
     180  nameQvsNHiGain += id;
     181  fHChargevsNHiGain->SetName(nameQvsNHiGain.Data());
     182
     183  TString titleQHiGain = TString(fHChargeHiGain->GetTitle());
     184  titleQHiGain += id;
     185  fHChargeHiGain->SetTitle(titleQHiGain.Data());
     186
     187  TString titleTHiGain = TString(fHTimeHiGain->GetTitle());
     188  titleTHiGain += id;
     189  fHTimeHiGain->SetTitle(titleTHiGain.Data());
     190
     191  TString titleQvsNHiGain  = TString(fHChargevsNHiGain->GetTitle());
     192  titleQvsNHiGain += id;
     193  fHChargevsNHiGain->SetTitle(titleQvsNHiGain.Data());
     194
     195
     196  TString nameQLoGain = TString(fHChargeLoGain->GetName());
     197  nameQLoGain += id;
     198  fHChargeLoGain->SetName(nameQLoGain.Data());
     199
     200  TString nameTLoGain = TString(fHTimeLoGain->GetName());
     201  nameTLoGain += id;
     202  fHTimeLoGain->SetName(nameTLoGain.Data());
     203
     204  TString nameQvsNLoGain  = TString(fHChargevsNLoGain->GetName());
     205  nameQvsNLoGain += id;
     206  fHChargevsNLoGain->SetName(nameQvsNLoGain.Data());
     207
     208  TString titleQLoGain = TString(fHChargeLoGain->GetTitle());
     209  titleQLoGain += id;
     210  fHChargeLoGain->SetTitle(titleQLoGain.Data());
     211
     212  TString titleTLoGain = TString(fHTimeLoGain->GetTitle());
     213  titleTLoGain += id;
     214  fHTimeLoGain->SetTitle(titleTLoGain.Data());
     215
     216  TString titleQvsNLoGain  = TString(fHChargevsNLoGain->GetTitle());
     217  titleQvsNLoGain += id;
     218  fHChargevsNLoGain->SetTitle(titleQvsNLoGain.Data());
    166219}
    167220
     
    170223{
    171224 
    172   for (Int_t i = fHCharge->FindBin(fChargeFirst);
    173        i <= fHCharge->FindBin(fChargeLast); i++)
    174     fHCharge->SetBinContent(i, 1.e-20);
     225  for (Int_t i = fHChargeHiGain->FindBin(fChargeFirstHiGain);
     226       i <= fHChargeHiGain->FindBin(fChargeLastHiGain); i++)
     227    fHChargeHiGain->SetBinContent(i, 1.e-20);
    175228
    176229  for (Int_t i = 0; i < 16; i++)
    177       fHTime->SetBinContent(i, 1.e-20);
    178  
    179   fChargeLast     = 9999.5;
    180 
    181   fHCharge->GetXaxis()->SetRangeUser(0.,fChargeLast);
     230      fHTimeHiGain->SetBinContent(i, 1.e-20);
     231 
     232  fChargeLastHiGain     = 9999.5;
     233
     234  fHChargeLoGain->GetXaxis()->SetRangeUser(0.,fChargeLastLoGain);
     235
     236 for (Int_t i = fHChargeLoGain->FindBin(fChargeFirstLoGain);
     237       i <= fHChargeLoGain->FindBin(fChargeLastLoGain); i++)
     238    fHChargeLoGain->SetBinContent(i, 1.e-20);
     239
     240  for (Int_t i = 0; i < 16; i++)
     241      fHTimeLoGain->SetBinContent(i, 1.e-20);
     242 
     243  fChargeLastLoGain     = 9999.5;
     244
     245  fHChargeLoGain->GetXaxis()->SetRangeUser(0.,fChargeLastLoGain);
    182246
    183247  return;
     
    192256{
    193257
    194   fHCharge->Reset();
    195   fHTime->Reset();
     258  fHChargeHiGain->Reset();
     259  fHTimeHiGain->Reset();
     260  fHChargeLoGain->Reset();
     261  fHTimeLoGain->Reset();
    196262
    197263  return kTRUE;
     
    240306  fFitLegend->AddText(line8);
    241307
    242 
    243308  if (fFitOK)
    244309    fFitLegend->AddText("Result of the Fit: OK");
     
    266331    gROOT->SetSelectedPad(NULL);
    267332
    268     c->Divide(2,2);
     333    c->Divide(2,4);
    269334
    270335    c->cd(1);
     
    273338    gPad->SetTicks();
    274339
    275     fHCharge->Draw(opt);
    276    
    277     if (fChargeGausFit)
    278       {
    279         if (fFitOK)
    280           fChargeGausFit->SetLineColor(kGreen);         
    281         else
    282           fChargeGausFit->SetLineColor(kRed);
    283 
    284         fChargeGausFit->Draw("same");
    285         c->Modified();
    286         c->Update();
    287       }
    288 
    289    
    290     c->cd(2);
    291     DrawLegend();
    292     c->Update();
    293 
    294     c->cd(3);
    295     gStyle->SetOptStat(1111111);
    296 
    297     gPad->SetLogy(1);
    298     fHTime->Draw(opt);
    299 
    300     if (fTimeGausFit)
    301       {
    302         if (fTimeChisquare > 1.)
    303           fTimeGausFit->SetLineColor(kRed);
    304         else
    305           fTimeGausFit->SetLineColor(kGreen);
    306 
    307         fTimeGausFit->Draw("same");
    308         c->Modified();
    309         c->Update();
    310       }
    311    
     340    fHChargeHiGain->DrawCopy(opt);
     341
    312342    c->Modified();
    313343    c->Update();
    314344
    315     c->cd(4);
    316     fHChargevsN->Draw(opt);
    317 }
    318 
    319 
    320 
    321 Bool_t MHCalibrationPixel::FitTime(Axis_t rmin, Axis_t rmax, Option_t *option)
     345    if (fUseLoGain)
     346      {
     347        c->cd(2);
     348        gPad->SetLogy(1);
     349        gPad->SetTicks();
     350        fHChargeLoGain->DrawCopy(opt);
     351   
     352        if (fChargeGausFit)
     353          {
     354            if (fFitOK)
     355              fChargeGausFit->SetLineColor(kGreen);         
     356            else
     357              fChargeGausFit->SetLineColor(kRed);
     358           
     359            fChargeGausFit->DrawCopy("same");
     360          }
     361
     362        c->cd(4);
     363        DrawLegend();
     364
     365      }
     366    else
     367      {
     368        if (fChargeGausFit)
     369          {
     370            if (fFitOK)
     371              fChargeGausFit->SetLineColor(kGreen);         
     372            else
     373              fChargeGausFit->SetLineColor(kRed);
     374           
     375            fChargeGausFit->DrawCopy("same");
     376          }
     377        c->cd(2);
     378        gPad->SetLogy(1);
     379        gPad->SetTicks();
     380        fHChargeLoGain->DrawCopy(opt);
     381        c->cd(3);
     382        DrawLegend();
     383      }
     384
     385    c->Modified();
     386    c->Update();
     387   
     388    c->cd(5);
     389    gStyle->SetOptStat(1111111);
     390
     391    gPad->SetLogy(1);
     392    fHTimeHiGain->DrawCopy(opt);
     393    c->Modified();
     394    c->Update();
     395
     396    if (fUseLoGain)
     397      {
     398
     399        c->cd(6);
     400        gPad->SetLogy(1);
     401        fHTimeLoGain->DrawCopy(opt);
     402        c->Modified();
     403        c->Update();
     404       
     405        if (fTimeGausFit)
     406          {
     407            if (fTimeChisquare > 1.)
     408              fTimeGausFit->SetLineColor(kRed);
     409            else
     410              fTimeGausFit->SetLineColor(kGreen);
     411           
     412            fTimeGausFit->DrawCopy("same");
     413          }
     414      }
     415    else
     416      { 
     417        if (fTimeGausFit)
     418          {
     419            if (fTimeChisquare > 1.)
     420              fTimeGausFit->SetLineColor(kRed);
     421            else
     422              fTimeGausFit->SetLineColor(kGreen);
     423           
     424            fTimeGausFit->DrawCopy("same");
     425            c->Modified();
     426            c->Update();
     427          }
     428
     429        c->cd(6);
     430        gPad->SetLogy(1);
     431        fHTimeLoGain->DrawCopy(opt);   
     432      }
     433    c->Modified();
     434    c->Update();
     435   
     436    c->cd(7);
     437    fHChargevsNHiGain->DrawCopy(opt);
     438    c->Modified();
     439    c->Update();
     440
     441    c->cd(8);
     442    fHChargevsNLoGain->DrawCopy(opt);
     443    c->Modified();
     444    c->Update();
     445
     446}
     447
     448
     449
     450Bool_t MHCalibrationPixel::FitTimeHiGain(Axis_t rmin, Axis_t rmax, Option_t *option)
    322451{
    323452
     
    328457  rmax = (rmax != 0.) ? rmax : 9.;
    329458
    330   const Stat_t   entries     = fHTime->GetEntries();
    331   const Double_t mu_guess    = fHTime->GetBinCenter(fHTime->GetMaximumBin());
     459  const Stat_t   entries     = fHTimeHiGain->GetEntries();
     460  const Double_t mu_guess    = fHTimeHiGain->GetBinCenter(fHTimeHiGain->GetMaximumBin());
    332461  const Double_t sigma_guess = (rmax - rmin)/2.;
    333462  const Double_t area_guess  = entries/gkSq2Pi;
     
    350479  fTimeGausFit->SetRange(rmin,rmax);
    351480
    352   fHTime->Fit(fTimeGausFit,option);
     481  fHTimeHiGain->Fit(fTimeGausFit,option);
    353482
    354483  rmin = fTimeGausFit->GetParameter(1) - 3.*fTimeGausFit->GetParameter(2);
     
    356485  fTimeGausFit->SetRange(rmin,rmax); 
    357486
    358   fHTime->Fit(fTimeGausFit,option);
     487  fHTimeHiGain->Fit(fTimeGausFit,option);
    359488
    360489  fTimeChisquare = fTimeGausFit->GetChisquare();
     
    375504}
    376505
    377 Bool_t MHCalibrationPixel::FitCharge(Option_t *option)
     506Bool_t MHCalibrationPixel::FitTimeLoGain(Axis_t rmin, Axis_t rmax, Option_t *option)
     507{
     508
     509  if (fTimeGausFit)
     510    return kFALSE;
     511
     512  rmin = (rmin != 0.) ? rmin : 4.;
     513  rmax = (rmax != 0.) ? rmax : 9.;
     514
     515  const Stat_t   entries     = fHTimeLoGain->GetEntries();
     516  const Double_t mu_guess    = fHTimeLoGain->GetBinCenter(fHTimeLoGain->GetMaximumBin());
     517  const Double_t sigma_guess = (rmax - rmin)/2.;
     518  const Double_t area_guess  = entries/gkSq2Pi;
     519
     520  TString name = TString("GausTime");
     521  name += fPixId;
     522  fTimeGausFit = new TF1(name.Data(),"gaus",rmin,rmax); 
     523
     524  if (!fTimeGausFit)
     525    {
     526    *fLog << err << dbginf << "Could not create fit function for Gauss fit" << endl;
     527    return kFALSE;
     528    }
     529
     530  fTimeGausFit->SetParameters(area_guess,mu_guess,sigma_guess);
     531  fTimeGausFit->SetParNames("Area","#mu","#sigma");
     532  fTimeGausFit->SetParLimits(0,0.,entries);
     533  fTimeGausFit->SetParLimits(1,rmin,rmax);
     534  fTimeGausFit->SetParLimits(2,0.,(rmax-rmin));
     535  fTimeGausFit->SetRange(rmin,rmax);
     536
     537  fHTimeLoGain->Fit(fTimeGausFit,option);
     538
     539  rmin = fTimeGausFit->GetParameter(1) - 3.*fTimeGausFit->GetParameter(2);
     540  rmax = fTimeGausFit->GetParameter(1) + 3.*fTimeGausFit->GetParameter(2);
     541  fTimeGausFit->SetRange(rmin,rmax); 
     542
     543  fHTimeLoGain->Fit(fTimeGausFit,option);
     544
     545  fTimeChisquare = fTimeGausFit->GetChisquare();
     546  fTimeNdf       = fTimeGausFit->GetNDF();
     547  fTimeProb      = fTimeGausFit->GetProb();
     548
     549  fTimeMean      = fTimeGausFit->GetParameter(1);
     550  fTimeSigma     = fTimeGausFit->GetParameter(2);
     551
     552  if (fTimeChisquare > 1.)
     553    {
     554      *fLog << warn << "Fit of the Arrival times failed ! " << endl;
     555      return kFALSE;
     556    }
     557 
     558  return kTRUE;
     559
     560}
     561
     562Bool_t MHCalibrationPixel::FitChargeHiGain(Option_t *option)
    378563{
    379564
     
    384569  // Get the fitting ranges
    385570  //
    386   Axis_t rmin = (fLowerFitRange != 0.) ? fLowerFitRange : fChargeFirst;
     571  Axis_t rmin = (fLowerFitRange != 0.) ? fLowerFitRange : fChargeFirstHiGain;
    387572  Axis_t rmax = 0.;
    388573
     
    391576  // otherwise the fit goes gaga because of high number of dimensions ...
    392577  //
    393   const Stat_t   entries    = fHCharge->GetEntries();
     578  const Stat_t   entries    = fHChargeHiGain->GetEntries();
    394579  const Double_t area_guess = entries/gkSq2Pi;
    395   const Double_t mu_guess   = fHCharge->GetBinCenter(fHCharge->GetMaximumBin());
     580  const Double_t mu_guess   = fHChargeHiGain->GetBinCenter(fHChargeHiGain->GetMaximumBin());
    396581  const Double_t sigma_guess = mu_guess/15.;
    397582
     
    399584  name += fPixId;
    400585
    401   fChargeGausFit = new TF1(name.Data(),"gaus",rmin,fChargeLast);
     586  fChargeGausFit = new TF1(name.Data(),"gaus",rmin,fChargeLastHiGain);
    402587
    403588  if (!fChargeGausFit)
     
    410595  fChargeGausFit->SetParNames("Area","#mu","#sigma");
    411596  fChargeGausFit->SetParLimits(0,0.,entries);
    412   fChargeGausFit->SetParLimits(1,rmin,fChargeLast);
    413   fChargeGausFit->SetParLimits(2,0.,fChargeLast-rmin);
    414   fChargeGausFit->SetRange(rmin,fChargeLast);
    415 
    416   fHCharge->Fit(fChargeGausFit,option);
     597  fChargeGausFit->SetParLimits(1,rmin,fChargeLastHiGain);
     598  fChargeGausFit->SetParLimits(2,0.,fChargeLastHiGain-rmin);
     599  fChargeGausFit->SetRange(rmin,fChargeLastHiGain);
     600
     601  fHChargeHiGain->Fit(fChargeGausFit,option);
    417602 
    418603  Axis_t rtry = fChargeGausFit->GetParameter(1) - 2.5*fChargeGausFit->GetParameter(2);
     
    422607  fChargeGausFit->SetRange(rmin,rmax); 
    423608
    424   fHCharge->Fit(fChargeGausFit,option);
     609  fHChargeHiGain->Fit(fChargeGausFit,option);
    425610
    426611  //  rmin = fChargeGausFit->GetParameter(1) - 2.5*fChargeGausFit->GetParameter(2);
     
    428613  //  fChargeGausFit->SetRange(rmin,rmax); 
    429614
    430   // fHCharge->Fit(fChargeGausFit,option);
     615  // fHChargeHiGain->Fit(fChargeGausFit,option);
    431616
    432617  fChargeChisquare = fChargeGausFit->GetChisquare();
     
    455640}
    456641
     642
     643Bool_t MHCalibrationPixel::FitChargeLoGain(Option_t *option)
     644{
     645
     646  if (fChargeGausFit)
     647    return kFALSE;
     648
     649  //
     650  // Get the fitting ranges
     651  //
     652  Axis_t rmin = (fLowerFitRange != 0.) ? fLowerFitRange : fChargeFirstLoGain;
     653  Axis_t rmax = 0.;
     654
     655  //
     656  // First guesses for the fit (should be as close to reality as possible,
     657  // otherwise the fit goes gaga because of high number of dimensions ...
     658  //
     659  const Stat_t   entries    = fHChargeLoGain->GetEntries();
     660  const Double_t area_guess = entries/gkSq2Pi;
     661  const Double_t mu_guess   = fHChargeLoGain->GetBinCenter(fHChargeLoGain->GetMaximumBin());
     662  const Double_t sigma_guess = mu_guess/15.;
     663
     664  TString name = TString("ChargeGausFit");
     665  name += fPixId;
     666
     667  fChargeGausFit = new TF1(name.Data(),"gaus",rmin,fChargeLastLoGain);
     668
     669  if (!fChargeGausFit)
     670    {
     671    *fLog << err << dbginf << "Could not create fit function for Gauss fit" << endl;
     672    return kFALSE;
     673    }
     674 
     675  fChargeGausFit->SetParameters(area_guess,mu_guess,sigma_guess);
     676  fChargeGausFit->SetParNames("Area","#mu","#sigma");
     677  fChargeGausFit->SetParLimits(0,0.,entries);
     678  fChargeGausFit->SetParLimits(1,rmin,fChargeLastLoGain);
     679  fChargeGausFit->SetParLimits(2,0.,fChargeLastLoGain-rmin);
     680  fChargeGausFit->SetRange(rmin,fChargeLastLoGain);
     681
     682  fHChargeLoGain->Fit(fChargeGausFit,option);
     683 
     684  Axis_t rtry = fChargeGausFit->GetParameter(1) - 2.5*fChargeGausFit->GetParameter(2);
     685 
     686  rmin = (rtry < rmin ? rmin : rtry);
     687  rmax = fChargeGausFit->GetParameter(1) + 2.5*fChargeGausFit->GetParameter(2);
     688  fChargeGausFit->SetRange(rmin,rmax); 
     689
     690  fHChargeLoGain->Fit(fChargeGausFit,option);
     691
     692  //  rmin = fChargeGausFit->GetParameter(1) - 2.5*fChargeGausFit->GetParameter(2);
     693  //  rmax = fChargeGausFit->GetParameter(1) + 2.5*fChargeGausFit->GetParameter(2);
     694  //  fChargeGausFit->SetRange(rmin,rmax); 
     695
     696  // fHChargeLoGain->Fit(fChargeGausFit,option);
     697
     698  fChargeChisquare = fChargeGausFit->GetChisquare();
     699  fChargeNdf       = fChargeGausFit->GetNDF();
     700  fChargeProb      = fChargeGausFit->GetProb();
     701  fChargeMean      = fChargeGausFit->GetParameter(1);
     702  fChargeMeanErr   = fChargeGausFit->GetParError(1);
     703  fChargeSigma     = fChargeGausFit->GetParameter(2);
     704  fChargeSigmaErr  = fChargeGausFit->GetParError(2);
     705
     706  //
     707  // The fit result is accepted under condition
     708  // The Probability is greater than gkProbLimit (default 0.01 == 99%)
     709  //
     710  if (fChargeProb < gkProbLimit)
     711    {
     712      *fLog << warn << "Prob: " << fChargeProb << " is smaller than the allowed value: " << gkProbLimit << endl;
     713      fFitOK = kFALSE;
     714      return kFALSE;
     715    }
     716 
     717 
     718  fFitOK = kTRUE;
     719   
     720  return kTRUE;
     721}
     722
    457723 
    458724void MHCalibrationPixel::CutAllEdges()
    459725{
    460726
    461   Int_t nbins = 50;
    462 
    463   CutEdges(fHCharge,nbins);
    464 
    465   fChargeFirst = fHCharge->GetBinLowEdge(fHCharge->GetXaxis()->GetFirst());
    466   fChargeLast  = fHCharge->GetBinLowEdge(fHCharge->GetXaxis()->GetLast())+fHCharge->GetBinWidth(0);
    467   fChargeNbins = nbins;
    468 
    469   CutEdges(fHChargevsN,0);
     727  Int_t nbins = 30;
     728
     729  CutEdges(fHChargeHiGain,nbins);
     730
     731  fChargeFirstHiGain = fHChargeHiGain->GetBinLowEdge(fHChargeHiGain->GetXaxis()->GetFirst());
     732  fChargeLastHiGain  = fHChargeHiGain->GetBinLowEdge(fHChargeHiGain->GetXaxis()->GetLast())
     733                      +fHChargeHiGain->GetBinWidth(0);
     734  fChargeNbinsHiGain = nbins;
     735
     736  CutEdges(fHChargeLoGain,nbins);
     737
     738  fChargeFirstLoGain = fHChargeLoGain->GetBinLowEdge(fHChargeLoGain->GetXaxis()->GetFirst());
     739  fChargeLastLoGain  = fHChargeLoGain->GetBinLowEdge(fHChargeLoGain->GetXaxis()->GetLast())
     740                      +fHChargeLoGain->GetBinWidth(0);
     741  fChargeNbinsLoGain = nbins;
     742
     743  CutEdges(fHChargevsNHiGain,0);
     744  CutEdges(fHChargevsNLoGain,0);
    470745
    471746}
  • trunk/MagicSoft/Mars/mhist/MHCalibrationPixel.h

    r2603 r2627  
    3131protected:
    3232
    33   TH1I* fHCharge;              //-> Summed FADC slices
    34   TH1I* fHTime;                //-> Mean arrival time in number of FADC sice
    35   TH1I* fHChargevsN;           //-> Summed Charge vs. Event Nr.
     33  TH1F* fHChargeHiGain;              //-> Summed FADC slices
     34  TH1I* fHTimeHiGain;                //-> Mean arrival time in number of FADC sice
     35  TH1I* fHChargevsNHiGain;           //-> Summed Charge vs. Event Nr.
     36 
     37  TH1F* fHChargeLoGain;              //-> Summed FADC slices
     38  TH1I* fHTimeLoGain;                //-> Mean arrival time in number of FADC sice
     39  TH1I* fHChargevsNLoGain;           //-> Summed Charge vs. Event Nr.
    3640 
    3741  TF1* fChargeGausFit;
     
    4145 
    4246  Axis_t  fLowerFitRange;
    43   Axis_t  fChargeFirst;
    44   Axis_t  fChargeLast;
    45   Int_t   fChargeNbins;
     47  Axis_t  fChargeFirstHiGain;
     48  Axis_t  fChargeLastHiGain;
     49  Int_t   fChargeNbinsHiGain;
     50
     51  Axis_t  fChargeFirstLoGain;
     52  Axis_t  fChargeLastLoGain;
     53  Int_t   fChargeNbinsLoGain;
    4654
    4755  Bool_t fFitOK;
     
    6270  Double_t fTimeMean;
    6371  Double_t fTimeSigma;
     72
     73  Bool_t fUseLoGain;
    6474 
    6575  virtual void DrawLegend();
     
    7585  Bool_t Fill(const MParContainer *, const Stat_t w=1) { return kTRUE; }
    7686
    77   Bool_t FillCharge(Int_t q)               { return fHCharge->Fill(q)      > -1; }
    78   Bool_t FillTime(Int_t t)                 { return fHTime->Fill(t)        > -1; }
    79   Bool_t FillChargevsN(Float_t q, Int_t n) { return fHChargevsN->Fill(n,q) > -1; }
     87  Bool_t FillChargeLoGain(Float_t q)             { return fHChargeLoGain->Fill(q)      > -1; }
     88  Bool_t FillTimeLoGain(Int_t t)                 { return fHTimeLoGain->Fill(t)        > -1; }
     89  Bool_t FillChargevsNLoGain(Float_t q, Int_t n) { return fHChargevsNLoGain->Fill(n,q) > -1; }
    8090
    81   const TH1I *GetHCharge()                 { return fHCharge;    }
    82   const TH1I *GetHCharge() const           { return fHCharge;    }
     91  Bool_t FillChargeHiGain(Float_t q)             { return fHChargeHiGain->Fill(q)      > -1; }
     92  Bool_t FillTimeHiGain(Int_t t)                 { return fHTimeHiGain->Fill(t)        > -1; }
     93  Bool_t FillChargevsNHiGain(Float_t q, Int_t n) { return fHChargevsNHiGain->Fill(n,q) > -1; }
     94
     95  void SetUseLoGain()                      { fUseLoGain = kTRUE; }
     96
     97  const TH1F *GetHCharge()                 { return fHChargeHiGain;    }
     98  const TH1F *GetHCharge() const           { return fHChargeHiGain;    }
    8399
    84100  const Double_t GetChargeMean()     const { return fChargeMean;    }
     
    100116  const Int_t    GetTimeNdf()         const { return fTimeNdf;       }   
    101117 
    102   const TH1I *GetHTime()                    { return fHTime; }
    103   const TH1I *GetHTime()              const { return fHTime; }
     118  const TH1I *GetHTime()                    { return fHTimeHiGain; }
     119  const TH1I *GetHTime()              const { return fHTimeHiGain; }
    104120 
    105   const TH1I *GetHChargevsN()               { return fHChargevsN; }
    106   const TH1I *GetHChargevsN()         const { return fHChargevsN; }
     121  const TH1I *GetHChargevsN()               { return fHChargevsNHiGain; }
     122  const TH1I *GetHChargevsN()         const { return fHChargevsNHiGain; }
    107123 
    108   Bool_t FitCharge(Option_t *option="RQ0"); 
    109   Bool_t FitTime(Axis_t rmin=0, Axis_t rmax=0, Option_t *option="RQ0");   
     124  Bool_t FitChargeHiGain(Option_t *option="RQ0"); 
     125  Bool_t FitTimeHiGain(Axis_t rmin=0, Axis_t rmax=0, Option_t *option="RQ0");   
     126
     127  Bool_t FitChargeLoGain(Option_t *option="RQ0"); 
     128  Bool_t FitTimeLoGain(Axis_t rmin=0, Axis_t rmax=0, Option_t *option="RQ0");   
    110129
    111130  virtual void Draw(Option_t *option="");
  • trunk/MagicSoft/Mars/mhist/MHCamera.cc

    r2586 r2627  
    739739// ------------------------------------------------------------------------
    740740//
     741// Call this function to add a MCamEvent on top of the present contents.
     742//
     743void MHCamera::SetCamError(const MCamEvent &evt, Int_t type)
     744{
     745
     746    if (fNcells<=1 || IsFreezed())
     747        return;
     748
     749    // FIXME: Security check missing!
     750    for (Int_t idx=0; idx<fNcells-2; idx++)
     751    {
     752        Double_t val=0;
     753        if (evt.GetPixelContent(val, idx, *fGeomCam, type)/* && !IsUsed(idx)*/)
     754            SetUsed(idx);
     755
     756        SetBinError(idx+1, val); // FIXME: Slow!
     757    }
     758}
     759
     760
     761
     762// ------------------------------------------------------------------------
     763//
    741764// Call this function to add a MHCamera on top of the present contents.
    742765// Type:
  • trunk/MagicSoft/Mars/mhist/MHCamera.h

    r2586 r2627  
    124124    virtual void     SetCamContent(const TArrayD &evt, const TArrayC *used=NULL) { Reset(); AddCamContent(evt, used); }
    125125    virtual void     SetCamContent(const MHCamera &d, Int_t type=0) { Reset(); AddCamContent(d, type); fEntries=d.fEntries; }
     126
     127    virtual void     SetCamError(const MCamEvent &event, Int_t type=0);
     128
    126129    virtual void     CntCamContent(const MCamEvent &evt, Double_t threshold, Int_t type=0);
    127130    virtual void     CntCamContent(const TArrayD &evt, Double_t threshold, Bool_t ispos=kTRUE);
Note: See TracChangeset for help on using the changeset viewer.