Changeset 13473


Ignore:
Timestamp:
04/30/12 19:22:44 (12 years ago)
Author:
Jens Buss
Message:
bugfixes after first compilation
File:
1 edited

Legend:

Unmodified
Added
Removed
  • fact/tools/rootmacros/PulseTemplates/pixel.C

    r13465 r13473  
    1919
    2020Pixel::Pixel(
    21         int         pixelID         = 0,
    22         int         maxPulsorder    = 1,
    23         int         verbosityLevel  = 0,
     21        int         pixelID,
     22        int         maxPulsorder,
     23        int         verbosityLevel,
    2424        int         pixelOverlayXaxisLeft,
    2525        int         pixelOverlayXaxisRight,
    2626        int         bSLMean,
    2727        int         gainMean,
    28         const char* options         = "",
     28        TString options
    2929        )
    3030{
     
    3838    mGainMean               = gainMean;
    3939
    40     hMaxOverlay     = (TH2F*) calloc(mMaxPulseOrder, sizeof(TH2F));
    41     hEdgeOverlay    = (TH2F*) calloc(mMaxPulseOrder, sizeof(TH2F));
    42     hMaxProfile     = (TProfile*) calloc(mMaxPulseOrder, sizeof(TProfile));
    43     hEdgeProfile    = (TProfile*) calloc(mMaxPulseOrder, sizeof(TProfile));
    44 
     40//    hMaxOverlay     = (TH2F*) calloc(mMaxPulseOrder, sizeof(TH2F*));
     41    hMaxOverlay = new TH2F*[mMaxPulseOrder];
     42//    hEdgeOverlay    = (TH2F*) calloc(mMaxPulseOrder, sizeof(TH2F*));
     43    hEdgeOverlay = new TH2F*[mMaxPulseOrder];
     44//    hMaxProfile     = (TProfile*) calloc(mMaxPulseOrder, sizeof(TProfile));
     45    hMaxProfile = new TProfile*[mMaxPulseOrder];
     46//    hEdgeProfile    = (TProfile*) calloc(mMaxPulseOrder, sizeof(TProfile));
     47    hEdgeProfile = new TProfile*[mMaxPulseOrder];
    4548    if (mOptions == "S")
    46         hSlopeRisingEdge= (TH1F*) calloc(mMaxPulseOrder, sizeof(TH1F));
     49    {
     50//        hSlopeRisingEdge= (TH1F*) calloc(mMaxPulseOrder, sizeof(TH1F));
     51        hSlopeRisingEdge = new TH1F*[mMaxPulseOrder];
     52    }
    4753    if (mOptions == "R")
    48         hRisingToMaxEdge= (TH1F*) calloc(mMaxPulseOrder, sizeof(TH1F));
     54    {
     55//        hRisingEdgeToMax= (TH1F*) calloc(mMaxPulseOrder, sizeof(TH1F));
     56        hRisingEdgeToMax = new TH1F*[mMaxPulseOrder];
     57    }
    4958    if (mOptions == "P")
    50         hPosOfMax       = (TH1F*) calloc(mMaxPulseOrder, sizeof(TH1F));
     59    {
     60//        hPosOfMax       = (TH1F*) calloc(mMaxPulseOrder, sizeof(TH1F));
     61        hPosOfMax = new TH1F*[mMaxPulseOrder];
     62    }
    5163
    5264    hList           = new TObjArray;
    5365
    5466    BookPixelHistos();
    55     BookDistributionHistos()
     67    BookDistributionHistos();
    5668}
    5769
     
    5971{
    6072    if (mVerbosityLevel > 2) cout << endl << "...delete current pixel histograms" ;
    61     for (int order = 0;
    62          order < mMaxPulseOrder;
    63          order ++)
    64     {
    65         if (mVerbosityLevel > 3) cout << endl << "...deleting hMaxOverlay" << mHistogramId;
    66         delete hMaxOverlay[order];
     73//    for (int order = 0;
     74//         order < mMaxPulseOrder;
     75//         order ++)
     76//    {
     77        if (mVerbosityLevel > 3) cout << endl << "...deleting hMaxOverlay";
     78        delete[] hMaxOverlay;
    6779        hMaxOverlay = NULL;
    68         if (mVerbosityLevel > 3) cout << endl << "...deleting hEdgeOverlay" << mHistogramId;
    69         delete hEdgeOverlay[order];
     80        if (mVerbosityLevel > 3) cout << endl << "...deleting hEdgeOverlay";
     81        delete[] hEdgeOverlay;
    7082        hEdgeOverlay = NULL;
    71         if (mVerbosityLevel > 3) cout << endl << "...deleting hMaxProfile" << mHistogramId;
    72         delete hMaxProfile[order];
     83        if (mVerbosityLevel > 3) cout << endl << "...deleting hMaxProfile";
     84        delete[] hMaxProfile;
    7385        hMaxProfile = NULL;
    74         if (mVerbosityLevel > 3) cout << endl << "...deleting hMaxProfile2" << mHistogramId;
    75         delete hEdgeProfile[order];
     86        if (mVerbosityLevel > 3) cout << endl << "...deleting hMaxProfile2";
     87        delete[] hEdgeProfile;
    7688        hEdgeProfile = NULL;
    77     }
     89//    }
    7890    if (mVerbosityLevel > 3) cout << endl << "...deleting hList";
    7991    delete hList;
     
    97109    if (mVerbosityLevel > 2) cout << endl << "...book pixel histograms" << endl;
    98110    TString histo_name;
    99     for (int order = 0; order < mMaxPulseOrder; order ++)
    100     {
     111
     112    for (int order =0; order > mMaxPulseOrder; order++)
     113    {
     114        histo_name = "hMaxOverlay";
     115        histo_name += order;
     116        hMaxOverlay[order]=new TH2F(
     117                histo_name,
     118                "Overlay of detected pulses of one pulse order for one Pixel",
     119                mPixelOverlayXaxisLeft + mPixelOverlayXaxisRight ,
     120                (-1*mPixelOverlayXaxisLeft)-0.5,
     121                mPixelOverlayXaxisRight-0.5 ,
     122                512,
     123                -55.5,
     124                200.5
     125                );
    101126/*
    102127                SetHistogramAttributes(
     
    107132                            );
    108133                            */
    109         histo_name = "hMaxOverlay";
    110         histo_name += order;
    111134        if (mVerbosityLevel > 3) cout << "...booking " << histo_name << endl;
    112         hMaxOverlay[order] = TH2F(
    113                     histo_name,
    114                     "Overlay of detected pulses of one pulse order for one Pixel",
    115                     mPixelOverlayXaxisLeft + mPixelOverlayXaxisRight ,
    116                     (-1*mPixelOverlayXaxisLeft)-0.5,
    117                     mPixelOverlayXaxisRight-0.5 ,
    118                     512,
    119                     -55.5,
    120                     200.5
    121                     );
    122135        hMaxOverlay[order]->SetAxisRange(
    123136                    mBSLMean - 5,
     
    128141        //hMaxProfile->SetBit(TH2F::kCanRebin);
    129142        hList->Add( hMaxOverlay[order] );
     143    }
     144
     145    for (int order = 0; order < mMaxPulseOrder; order ++)
     146    {
    130147
    131148//------------------------------------------------------------------------
     
    141158        histo_name += order;
    142159        if (mVerbosityLevel > 3) cout << "...booking " << histo_name << endl;
    143         hEdgeOverlay[order] = TH2F(
     160        hEdgeOverlay[order] = new TH2F(
    144161                    histo_name,
    145162                    "Overlay at rising edge of detected pulses of one pulse order for one Pixel ",
     
    172189        histo_name += order;
    173190        if (mVerbosityLevel > 3) cout << "...booking " << histo_name << endl;
    174         hMaxProfile[order] = TProfile(
     191        hMaxProfile[order] = new TProfile(
    175192                    histo_name,
    176193                    "Mean value of each slice in overlay plot (Tprofile)",
     
    201218                    );
    202219                    */
    203             histo_name = "hEdgeProfile";
    204             histo_name += order;
    205             if (mVerbosityLevel > 3) cout << "...booking " << histo_name << endl;
    206             hEdgeProfile[order] = TProfile(
    207                         histo_name,
    208                         "Mean value of each slice in overlay plot (Tprofile)",
    209                         mPixelOverlayXaxisLeft + mPixelOverlayXaxisRight ,//nbinsx
    210                         (-1*mPixelOverlayXaxisLeft)-0.5,                 //xlow
    211                         mPixelOverlayXaxisRight-0.5 ,                    //xup
    212         //                512,                                            //nbinsy
    213                         -55.5,                                          //ylow
    214                         300.5,                                          //yup
    215                         "s");                                           //option
    216             hEdgeProfile[order]->SetLineColor(kRed);
    217             hEdgeProfile[order]->SetAxisRange(
    218                         mBSLMean - 5,
    219                         (mGainMean*(order+1)) + 10,
    220                         "Y");
    221             hEdgeProfile[order]->GetXaxis()->SetTitle( "Timeslices [a.u.]" );
    222             hEdgeProfile[order]->GetYaxis()->SetTitle( "Amplitude [mV]" );
    223             //hMaxProfile->SetBit(TH2F::kCanRebin);
     220        histo_name = "hEdgeProfile";
     221        histo_name += order;
     222        if (mVerbosityLevel > 3) cout << "...booking " << histo_name << endl;
     223        hEdgeProfile[order] = new TProfile(
     224                    histo_name,
     225                    "Mean value of each slice in overlay plot (Tprofile)",
     226                    mPixelOverlayXaxisLeft + mPixelOverlayXaxisRight ,//nbinsx
     227                    (-1*mPixelOverlayXaxisLeft)-0.5,                 //xlow
     228                    mPixelOverlayXaxisRight-0.5 ,                    //xup
     229    //                512,                                            //nbinsy
     230                    -55.5,                                          //ylow
     231                    300.5,                                          //yup
     232                    "s");                                           //option
     233        hEdgeProfile[order]->SetLineColor(kRed);
     234        hEdgeProfile[order]->SetAxisRange(
     235                    mBSLMean - 5,
     236                    (mGainMean*(order+1)) + 10,
     237                    "Y");
     238        hEdgeProfile[order]->GetXaxis()->SetTitle( "Timeslices [a.u.]" );
     239        hEdgeProfile[order]->GetYaxis()->SetTitle( "Amplitude [mV]" );
     240        //hMaxProfile->SetBit(TH2F::kCanRebin);
     241        hList->Add( hEdgeProfile[order] );
     242
    224243    }
    225244    if (mVerbosityLevel > 2) cout << "...done" << endl;
     
    231250void
    232251Pixel::DrawHistograms(
    233         TCanvas*    pixelCanvas     = NULL,
    234         int*        histoFrameNr    = NULL
     252        TCanvas*    pixelCanvas,
     253        int*        histoFrameNr
    235254        )
    236255{
     
    238257    for (int pulse_order = 0; pulse_order < mMaxPulseOrder; pulse_order++)
    239258    {
    240         pixelCanvas[pulse_order]->cd( histoFrameNr[0] );
     259        pixelCanvas[pulse_order].cd( histoFrameNr[0] );
    241260        hMaxOverlay[pulse_order]->Draw("COLZ");
    242         pixelCanvas[pulse_order]->cd( histoFrameNr[2] );
     261        pixelCanvas[pulse_order].cd( histoFrameNr[2] );
    243262        hMaxProfile[pulse_order]->Draw("COLZ");
    244         hMaxProfile2[pulse_order]->Draw("SAME");
    245 
    246         pixelCanvas[pulse_order]->cd( histoFrameNr[1] );
     263        hEdgeProfile[pulse_order]->Draw("SAME");
     264
     265        pixelCanvas[pulse_order].cd( histoFrameNr[1] );
    247266        hEdgeOverlay[pulse_order]->Draw("COLZ");
    248267    }
     
    257276    if (mOptions != "")
    258277    {
    259         if (mVerbosityLevel > 2) cout << endl
    260                                       << "...book distribution histograms"
    261                                       << endl;
    262 
    263             if (mOptions != "S")
     278        TString histo_name;
     279        for (int order =0; order > mMaxPulseOrder; order++)
     280        {
     281            if (mVerbosityLevel > 2) cout << endl
     282                                          << "...book distribution histograms"
     283                                          << endl;
     284
     285            if (mOptions.Contains("S"))
    264286            {
    265                 hSlopeRisingEdge = TH1F (
    266                             "hSlopeRisingEdge",
     287                histo_name = "hSlopeRisingEdge";
     288                histo_name += order;
     289                hSlopeRisingEdge[order] = new TH1F (
     290                            histo_name,
    267291                            "Distribution of rising edge",
    268292                            600,
     
    270294                            10.1
    271295                            );
    272                 hSlopeRisingEdge->GetXaxis()->SetTitle( "Timeslices [a.u.]" );
    273                 hSlopeRisingEdge->GetYaxis()->SetTitle( "counts" );
     296                hSlopeRisingEdge[order]->GetXaxis()->SetTitle( "Timeslices [a.u.]" );
     297                hSlopeRisingEdge[order]->GetYaxis()->SetTitle( "counts" );
     298                hList->Add( hSlopeRisingEdge[order] );
    274299            }
    275300
    276             if (mOptions != "R")
     301            if (mOptions.Contains("R"))
    277302            {
    278                 hRisingToMaxEdge = TH1F (
    279                             "hRisingToMaxEdge",
     303                histo_name = "hRisingEdgeToMax";
     304                histo_name += order;
     305                hRisingEdgeToMax[order] = new TH1F (
     306                            histo_name,
    280307                            "Deviation of rising edge and maximum",
    281308                            600,
     
    283310                            10.1
    284311                            );
    285                 hRisingToMaxEdge->GetXaxis()->SetTitle( "Timeslices [a.u.]" );
    286                 hRisingToMaxEdge->GetYaxis()->SetTitle( "counts" );
     312                hRisingEdgeToMax[order]->GetXaxis()->SetTitle( "Timeslices [a.u.]" );
     313                hRisingEdgeToMax[order]->GetYaxis()->SetTitle( "counts" );
     314                hList->Add( hRisingEdgeToMax[order] );
    287315            }
    288316
    289             if (mOptions != "P")
     317            if (mOptions.Contains("P"))
    290318            {
    291                 hPosOfMax = TH1F (
    292                             "hPosOfMax",
     319                histo_name = "hPosOfMax";
     320                histo_name += order;
     321                hPosOfMax[order] = new TH1F (
     322                            histo_name,
    293323                            "Deviation of rising edge and maximum",
    294324                            600,
     
    296326                            10.1
    297327                            );
    298                 hPosOfMax->GetXaxis()->SetTitle( "Timeslices [a.u.]" );
    299                 hPosOfMax->GetYaxis()->SetTitle( "counts" );
     328                hPosOfMax[order]->GetXaxis()->SetTitle( "Timeslices [a.u.]" );
     329                hPosOfMax[order]->GetYaxis()->SetTitle( "counts" );
     330                hList->Add( hPosOfMax[order] );
    300331            }
    301332
    302         if (mVerbosityLevel > 2) cout << "...done" << endl;
    303     }
    304 }
    305 
    306 
     333            if (mVerbosityLevel > 2) cout << "...done" << endl;
     334        }
     335    }
     336}
     337
     338void
     339Pixel::DrawDistributionHistograms(
     340        TCanvas*    pixelCanvas,
     341        int*        histoFrameNr
     342        )
     343{
     344    if (mVerbosityLevel > 2) cout << endl << "...drawing distribution histograms" ;
     345    for (int pulse_order = 0; pulse_order < mMaxPulseOrder; pulse_order++)
     346    {
     347        pixelCanvas[pulse_order].cd( histoFrameNr[0] );
     348        hSlopeRisingEdge[pulse_order]->Draw();
     349        pixelCanvas[pulse_order].cd( histoFrameNr[1] );
     350        hRisingEdgeToMax[pulse_order]->Draw();
     351
     352        pixelCanvas[pulse_order].cd( histoFrameNr[2] );
     353        hPosOfMax[pulse_order]->Draw();
     354    }
     355}
     356// end of DrawDistributionHistograms
     357//----------------------------------------------------------------------------
     358
     359void
     360Pixel::SavePixelHistograms(
     361        const char* outRootFileName
     362        )
     363{
     364    SaveHistograms(
     365            outRootFileName,
     366            CreateSubDirName( mChid ),
     367            hList,
     368            mVerbosityLevel
     369            );
     370}
    307371
    308372
Note: See TracChangeset for help on using the changeset viewer.