Changeset 13485 for fact


Ignore:
Timestamp:
05/01/12 12:02:11 (12 years ago)
Author:
Jens Buss
Message:
put construction of debug histograms into an own function
File:
1 edited

Legend:

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

    r13472 r13485  
    143143
    144144    // Temporary Objects
    145     TH1F*       debugHistos = NULL;
     145    TH1F*       debugHistos     = NULL;
    146146    //TH2F*       hOverlayTemp = NULL;
    147147    //TH1D*       hProjPeak = NULL;
    148     TH1F*       hTesthisto = NULL;
    149     TH2F*       hTesthisto2 = NULL;
     148    TH1F*       hTesthisto      = NULL;
     149    TH2F*       hTesthisto2     = NULL;
    150150
    151151    //Histogram Parameters
    152     Int_t       gPixelOverlayXaxisLeft = 0;
     152    Int_t       gPixelOverlayXaxisLeft  = 0;
    153153    Int_t       gPixelOverlayXaxisRight = 0;
    154154
    155155    //Root-File Objects
    156156//    TObjArray*  hList[sampleSetSize] = {NULL};
    157     TObjArray*  hRootList = NULL;
    158 
    159     TCanvas**   cgpPixelPulses  = NULL;
    160     TCanvas *   cFiltered       = NULL;
     157    TObjArray*  hRootList           = NULL;
     158
     159    TCanvas**   cgpPixelPulses      = NULL;
     160    TCanvas**   cgpDistributions    = NULL;
     161    TCanvas*    cFiltered           = NULL;
     162    TCanvas*    cgpTestHistos       = NULL;
    161163
    162164//----------------------------------------------------------------------------
     
    165167
    166168void BookDebugHistos(int );
    167 //void BookPixelHistos(int, int, int, int );
    168169void BookTestHistos( int );
    169170
     
    172173
    173174void FillHistograms(Pixel*, vector<Region>*, int, int, int, int);
    174 //void DrawPulseHistograms(int);
    175175void DrawTestHistograms( int);
     176void ProduceDebugHistos( vector<Region> *pZXings);
    176177
    177178void UpdateCanvases( int, int);
     
    209210{
    210211//----------------------------------------------------------------------------
    211 // set global variables
     212// Initialize Pixel
     213//----------------------------------------------------------------------------
     214    Pixel** pixel = new Pixel*[sampleSetSize];
     215
     216//----------------------------------------------------------------------------
     217//      Save-Root-File Settings
     218//----------------------------------------------------------------------------
     219    CreateRootFile( OutRootFileName, verbosityLevel );
     220
     221//----------------------------------------------------------------------------
     222//      root global Settings
    212223//----------------------------------------------------------------------------
    213224
    214225    gGainMean = GainMean;
    215226    gBSLMean = BSLMean;
    216 
    217 //----------------------------------------------------------------------------
    218 // Initialize Pixel
    219 //----------------------------------------------------------------------------
    220     Pixel** pPixelSet = new Pixel*[sampleSetSize];
    221 
    222 //----------------------------------------------------------------------------
    223 //      Save-Root-File Settings
    224 //----------------------------------------------------------------------------
    225     CreateRootFile( OutRootFileName, verbosityLevel );
    226 
    227 
    228 //----------------------------------------------------------------------------
    229 //      root global Settings
    230 //----------------------------------------------------------------------------
    231 
    232227    gPixelOverlayXaxisLeft = OverlayWindowLeft;
    233228    gPixelOverlayXaxisRight = OverlayWindowRight;
     
    237232//    gPad->SetGrid();
    238233
     234//----------------------------------------------------------------------------
     235//      root Canvas Settings
     236//----------------------------------------------------------------------------
     237    //Canvas Pad numbering
    239238    int pulsesCanvasFrameNrs[4] = {
    240239        1,  // Top left
     
    244243    };
    245244
    246     //Canvases
    247     cgpPixelPulses = new TCanvas*[maxPulseOrder];
    248     TCanvas*    cgpTestHistos                   = NULL;
     245    //Canvas Pad numbering
     246    int distributionCanvasFrameNrs[4] = {
     247        1,  // Top left
     248        2,  // Top right
     249        3,  // bottom left
     250        4   // bootom right
     251    };
    249252
    250253    if (ProduceGraphic)
    251254    {
     255
     256        //Canvases
     257        cgpPixelPulses      = new TCanvas*[maxPulseOrder];
     258        cgpDistributions    = new TCanvas*[maxPulseOrder];
     259
    252260        //TCanvas*    gpcDevelopment = NULL;
    253261        TString cName   = "";
    254262        TString cTitle  = "";
    255263
     264        //naming of pulse canvases
    256265        for (
    257266             int pulse_order = maxPulseOrder - 1;
     
    268277        }
    269278
     279
    270280        // Create (pointer to) Canvases, which are used in every run,
    271281        // also in 'non-debug' runs
    272282                // Canvases only need if spike Debug, but I want to deklare
    273283                // the pointers anyway ...
    274 
    275284        if (spikeDebug)
    276285        {
     
    279288        }
    280289
     290        //additional Test histograms
    281291        cgpTestHistos = new TCanvas( "cgpTestHistos", "Test Histograms", 801, 0, 800, 800 );
    282292        cgpTestHistos->Divide(2,0);
    283293    }
     294
    284295//-----------------------------------------------------------------------------
    285296// Filter-Settings
     
    357368    }
    358369
    359     // Book the histograms
     370//-----------------------------------------------------------------------------
     371// Book the histograms
     372//-----------------------------------------------------------------------------
     373
    360374    BookDebugHistos(verbosityLevel );
    361375    BookTestHistos( verbosityLevel );
     376
     377
     378//-----------------------------------------------------------------------------
     379// Main Cycle
     380//-----------------------------------------------------------------------------
     381
    362382//-------------------------------------
    363383// Loop over Pixel Sets
     
    376396                 << firstPixelOfSample+sampleSetSize-1 << endl;
    377397        }
    378 //        BookPixelHistos(
    379 //                    sampleSetSize,
    380 //                    firstPixelOfSample,
    381 //                    maxPulseOrder,
    382 //                    verbosityLevel
    383 //                    );
    384398
    385399//--------------------------------------------------------------------
    386 // Loops over Every Event of Pixel
     400// Loop over every Event of Pixel Set
    387401//--------------------------------------------------------------------
    388402        for ( int ev = firstevent; ev < firstevent + nevents; ev++)
     
    401415// Loops over every Pixel of a Set of Pixels
    402416//--------------------------------------------------------------------
    403             for ( int pixel = firstPixelOfSample;
    404                   pixel < sampleSetSize || pixel < firstpixel + npixel;
    405                 pixel++ )
     417            for ( int pixelID = firstPixelOfSample;
     418                  pixelID < sampleSetSize || pixelID < firstpixel + npixel;
     419                pixelID++ )
    406420            {
    407421                if (verbosityLevel > 0)
    408422                {
    409423                 cout << "-------------------------------------" << endl
    410                       << "...processing Pixel: " << pixel
     424                      << "...processing Pixel: " << pixelID
    411425                      << "/" << firstpixel + npixel << endl;
    412426                }
    413427
    414                 pPixelSet[pixel] = new Pixel(
    415                             pixel,
    416                             maxPulseOrder,
    417                             verbosityLevel,
    418                             gPixelOverlayXaxisLeft,
    419                             gPixelOverlayXaxisRight,
    420                             gBSLMean,
    421                             gGainMean,
    422                             histoOptions
    423                             );
     428//-------------------------------------
     429// Create individual Pixel
     430//-------------------------------------
     431                if (ev == firstevent)
     432                {
     433                    pixel[pixelID] = new Pixel(
     434                                pixelID,
     435                                maxPulseOrder,
     436                                verbosityLevel,
     437                                gPixelOverlayXaxisLeft,
     438                                gPixelOverlayXaxisRight,
     439                                gBSLMean,
     440                                gGainMean,
     441                                histoOptions
     442                                );
     443                }
    424444
    425445//-------------------------------------
     
    429449                applyDrsCalibration(
    430450                            Ameas,
    431                             pixel,
     451                            pixelID,
    432452                            12,
    433453                            12,
     
    487507//-----------------------------------------------------------------------------
    488508                FillHistograms(
    489                             pPixelSet[pixel],
     509                            pixel[pixelID],
    490510                            pZXings,
    491511                            AmplWindowWidth,
     
    500520                if ( spikeDebug )
    501521                {
    502                     // TODO do this correct. The vectors should be the rigt ones... this is just luck
    503                     debugHistos[Ameas_].GetXaxis()->Set(Ameas.size() , -0.5 , Ameas.size()-0.5);
    504                     debugHistos[Vcorr_].GetXaxis()->Set(Ameas.size() , -0.5 , Ameas.size()-0.5);
    505                     debugHistos[Vslide_].GetXaxis()->Set(Ameas.size() , -0.5 , Ameas.size()-0.5);
    506                     debugHistos[Vcfd_].GetXaxis()->Set(Ameas.size() , -0.5 , Ameas.size()-0.5);
    507                     debugHistos[Vcfd2_].GetXaxis()->Set(Ameas.size() , -0.5 , Ameas.size()-0.5);
    508 
    509                     for ( unsigned int sl = 0; sl < gRegionOfInterest; sl++)
    510                     {
    511                        debugHistos[Ameas_].SetBinContent(sl, Ameas[sl]);
    512                        debugHistos[Vcorr_].SetBinContent(sl, Vcorr[sl]);
    513                        debugHistos[Vslide_].SetBinContent( sl, Vslide[sl] );
    514                        debugHistos[Vcfd_].SetBinContent( sl, Vcfd[sl] );
    515                        debugHistos[Vcfd2_].SetBinContent( sl, Vcfd2[sl] );
    516                     }
    517 
    518 
    519                     cFiltered->cd(1);
    520                     gPad->SetGrid();
    521                     debugHistos[Ameas_].Draw();
    522 
    523                     cFiltered->cd(2);
    524                     gPad->SetGrid();
    525                     debugHistos[Vcorr_].Draw();
    526 
    527                     cFiltered->cd(3);
    528                     gPad->SetGrid();
    529                     debugHistos[Vslide_].Draw();
    530 
    531                     TBox *OneBox;
    532                     vector<TBox*> MyBoxes;
    533                     for (unsigned int i=0; i<pZXings->size(); i++){
    534                             OneBox = new TBox(
    535                                     pZXings->at(i).maxPos -10 ,
    536                                     pZXings->at(i).maxVal -0.5,
    537                                     pZXings->at(i).maxPos +10 ,
    538                                     pZXings->at(i).maxVal +0.5);
    539                             OneBox->SetLineColor(kBlue);
    540                             OneBox->SetLineWidth(1);
    541                             OneBox->SetFillStyle(0);
    542                             OneBox->SetFillColor(kRed);
    543                             MyBoxes.push_back(OneBox);
    544                             OneBox->Draw();
    545                     }
    546 
    547         //            cFiltered->cd(3);
    548         //            gPad->SetGrid();
    549         //            debugHistos[Vcfd2_].Draw();
    550         //            TLine *zeroline = new TLine(0, 0, 1024, 0);
    551         //            zeroline->SetLineColor(kBlue);
    552         //            zeroline->Draw();
    553 
    554                     cFiltered->Update();
    555 
    556 
    557                     //Process gui events asynchronously during input
    558                     TTimer timer("gSystem->ProcessEvents();", 50, kFALSE);
    559                     timer.TurnOn();
    560                     TString input = Getline("Type 'q' to exit, <return> to go on: ");
    561                     timer.TurnOff();
    562                     if (input=="q\n") {
    563                             breakout=true;
    564                     }
    565 
    566                     //TODO!!!!!!!!!
    567                     // do some Garbage collection ...
    568                     // all the Objects on the heap should be deleted here.
    569 
     522                    ProduceDebugHistos( pZXings );
    570523                }// end of if(spikeDebug)
    571524
     
    586539                                )
    587540                            {
    588                                 pPixelSet[pixel]->DrawHistograms(
     541                                pixel[pixelID]->DrawHistograms(
    589542                                            cgpPixelPulses[order],
    590543                                            pulsesCanvasFrameNrs
     
    626579//-------------------------------------
    627580
    628         for ( int pixel = firstPixelOfSample;
    629               pixel < sampleSetSize || pixel < firstpixel + npixel;
    630             pixel++ )
     581        for ( int pixelID = firstPixelOfSample;
     582              pixelID < sampleSetSize || pixelID < firstpixel + npixel;
     583            pixelID++ )
    631584        {
    632585            //here is what happends at the end of each loop over all Events
    633 //            pPixelSet[pixel]->DrawHistograms(
     586//            pixel[pixelID]->DrawHistograms(
    634587//                        cgpPixelPulses,
    635588//                        pulsesCanvasFrameNrs
     
    638591            SaveHistograms(     //save histograms of generell results into output root file
    639592                        OutRootFileName,
    640                         CreateSubDirName(pPixelSet[pixel]->mChid),
    641                         pPixelSet[pixel]->hList,
     593                        CreateSubDirName(pixel[pixelID]->mChid),
     594                        pixel[pixelID]->hList,
    642595                        verbosityLevel
    643596                        );
     
    652605
    653606            //Save Histograms of Pixels into Output rootfile
    654             pPixelSet[pixel]->SavePixelHistograms( OutRootFileName );
     607            pixel[pixelID]->SavePixelHistograms( OutRootFileName );
    655608
    656609
     
    668621            }
    669622
    670             delete pPixelSet[pixel];
     623            delete pixel[pixelID];
    671624
    672625            if (verbosityLevel > 2)
     
    759712
    760713
    761 void BookDebugHistos( int verbosityLevel )
     714void
     715BookDebugHistos( int verbosityLevel )
    762716{
    763717    if (verbosityLevel > 2) cout << endl << "...book histograms" << endl;
     
    788742
    789743
    790 void FillHistograms(
     744void
     745FillHistograms(
    791746        Pixel* CurrentPixel,
    792747        vector<Region>* pZXings,
     
    877832//----------------------------------------------------------------------------
    878833
    879 void DrawTestHistograms(
     834void
     835DrawTestHistograms(
    880836        int verbosityLevel
    881837        )
     
    891847//----------------------------------------------------------------------------
    892848
    893 void UpdateCanvases(
     849void
     850UpdateCanvases(
    894851        int verbosityLevel,
    895852        int max_pulse_order
    896853        )
    897854{
    898     if (verbosityLevel > 3) cout << endl << "...updating canvases TODO CANVAS" ;
     855    if (verbosityLevel > 3) cout << endl << "...updating canvases" ;
    899856    for (int pulse_order = 0; pulse_order < max_pulse_order; pulse_order++)
    900857    {
    901 //        cgpPixelPulses[pulse_order]->Modified();
    902 //        cgpPixelPulses[pulse_order]->Update();
    903 //        cgpTestHistos->Modified();
    904 //        cgpTestHistos->Update();
     858        cgpPixelPulses[pulse_order]->Modified();
     859        cgpPixelPulses[pulse_order]->Update();
     860        cgpTestHistos->Modified();
     861        cgpTestHistos->Update();
    905862    }
    906863}
     
    914871        )
    915872{
    916     if (verbosityLevel > 2) cout << endl << "...delete pixel Canvas TODO CANVAS" ;
    917 //    for (int pulse_order = 0; pulse_order < maxPulseOrder; pulse_order ++)
    918 //    {
    919 //        delete cgpPixelPulses[pulse_order];
    920 //    }
     873    if (verbosityLevel > 2) cout << endl << "...delete pixel Canvases" ;
     874    for (int pulse_order = 0; pulse_order < maxPulseOrder; pulse_order ++)
     875    {
     876        delete cgpPixelPulses[pulse_order];
     877    }
     878    delete[] cgpPixelPulses;
    921879}
    922880
     
    924882//----------------------------------------------------------------------------
    925883
    926 
     884void
     885ProduceDebugHistos(
     886        vector<Region>* pZXings
     887        )
     888{
     889    // TODO do this correct. The vectors should be the rigt ones... this is just luck
     890    debugHistos[Ameas_].GetXaxis()->Set(Ameas.size() , -0.5 , Ameas.size()-0.5);
     891    debugHistos[Vcorr_].GetXaxis()->Set(Ameas.size() , -0.5 , Ameas.size()-0.5);
     892    debugHistos[Vslide_].GetXaxis()->Set(Ameas.size() , -0.5 , Ameas.size()-0.5);
     893    debugHistos[Vcfd_].GetXaxis()->Set(Ameas.size() , -0.5 , Ameas.size()-0.5);
     894    debugHistos[Vcfd2_].GetXaxis()->Set(Ameas.size() , -0.5 , Ameas.size()-0.5);
     895
     896    for ( unsigned int sl = 0; sl < gRegionOfInterest; sl++)
     897    {
     898       debugHistos[Ameas_].SetBinContent(sl, Ameas[sl]);
     899       debugHistos[Vcorr_].SetBinContent(sl, Vcorr[sl]);
     900       debugHistos[Vslide_].SetBinContent( sl, Vslide[sl] );
     901       debugHistos[Vcfd_].SetBinContent( sl, Vcfd[sl] );
     902       debugHistos[Vcfd2_].SetBinContent( sl, Vcfd2[sl] );
     903    }
     904
     905
     906    cFiltered->cd(1);
     907    gPad->SetGrid();
     908    debugHistos[Ameas_].Draw();
     909
     910    cFiltered->cd(2);
     911    gPad->SetGrid();
     912    debugHistos[Vcorr_].Draw();
     913
     914    cFiltered->cd(3);
     915    gPad->SetGrid();
     916    debugHistos[Vslide_].Draw();
     917
     918    TBox *OneBox;
     919    vector<TBox*> MyBoxes;
     920    for (unsigned int i=0; i<pZXings->size(); i++){
     921            OneBox = new TBox(
     922                    pZXings->at(i).maxPos -10 ,
     923                    pZXings->at(i).maxVal -0.5,
     924                    pZXings->at(i).maxPos +10 ,
     925                    pZXings->at(i).maxVal +0.5);
     926            OneBox->SetLineColor(kBlue);
     927            OneBox->SetLineWidth(1);
     928            OneBox->SetFillStyle(0);
     929            OneBox->SetFillColor(kRed);
     930            MyBoxes.push_back(OneBox);
     931            OneBox->Draw();
     932    }
     933
     934//            cFiltered->cd(3);
     935//            gPad->SetGrid();
     936//            debugHistos[Vcfd2_].Draw();
     937//            TLine *zeroline = new TLine(0, 0, 1024, 0);
     938//            zeroline->SetLineColor(kBlue);
     939//            zeroline->Draw();
     940
     941    cFiltered->Update();
     942
     943
     944    //Process gui events asynchronously during input
     945    TTimer timer("gSystem->ProcessEvents();", 50, kFALSE);
     946    timer.TurnOn();
     947    TString input = Getline("Type 'q' to exit, <return> to go on: ");
     948    timer.TurnOff();
     949    if (input=="q\n") {
     950            breakout=true;
     951    }
     952
     953    //TODO!!!!!!!!!
     954    // do some Garbage collection ...
     955    // all the Objects on the heap should be deleted here.
     956
     957}// end of if(spikeDebug)
Note: See TracChangeset for help on using the changeset viewer.