| 1 | /********************** FPulseOverlay ***********************
|
|---|
| 2 | * read FACT raw data
|
|---|
| 3 | * remove spikes
|
|---|
| 4 | * calculate baseline
|
|---|
| 5 | * find peaks (CFD and normal discriminator)
|
|---|
| 6 | + search for Peaks in data
|
|---|
| 7 | + put peaks into different histos depending on Amplitude
|
|---|
| 8 | + draw histos for single, double, tripple, ....Photonpulses
|
|---|
| 9 | + draw Parameterdevelopment
|
|---|
| 10 | so it can be used for detection of other peaks
|
|---|
| 11 | *************************************************************/
|
|---|
| 12 | //----------------------------------------------------------------------------
|
|---|
| 13 | // root libraries
|
|---|
| 14 | //----------------------------------------------------------------------------
|
|---|
| 15 |
|
|---|
| 16 | #include <TROOT.h>
|
|---|
| 17 | #include <TCanvas.h>
|
|---|
| 18 | #include <TProfile.h>
|
|---|
| 19 | #include <TTimer.h>
|
|---|
| 20 | #include <TH1F.h>
|
|---|
| 21 | #include <TH2F.h>
|
|---|
| 22 | #include <Getline.h>
|
|---|
| 23 | #include <TLine.h>
|
|---|
| 24 | #include <TBox.h>
|
|---|
| 25 | #include <TMath.h>
|
|---|
| 26 | #include <TFile.h>
|
|---|
| 27 | #include <TStyle.h>
|
|---|
| 28 | #include <TString.h>
|
|---|
| 29 | #include <TObjArray.h>
|
|---|
| 30 |
|
|---|
| 31 | #include <stdio.h>
|
|---|
| 32 | #include <stdint.h>
|
|---|
| 33 | #include <cstdio>
|
|---|
| 34 | #include <iostream>
|
|---|
| 35 | #include <fstream>
|
|---|
| 36 | using namespace std;
|
|---|
| 37 |
|
|---|
| 38 | #define NPIX 1440
|
|---|
| 39 | #define NCELL 1024
|
|---|
| 40 | #define FAD_MAX_SAMPLES 1024
|
|---|
| 41 | #define HAVE_ZLIB
|
|---|
| 42 |
|
|---|
| 43 | //----------------------------------------------------------------------------
|
|---|
| 44 | // rootmacros
|
|---|
| 45 | //----------------------------------------------------------------------------
|
|---|
| 46 |
|
|---|
| 47 | //#include "../fits.h"
|
|---|
| 48 |
|
|---|
| 49 | #include "../openFits.h"
|
|---|
| 50 | //#include "../openFits.c"
|
|---|
| 51 |
|
|---|
| 52 | #include "../discriminator.h"
|
|---|
| 53 | //#include "../discriminator.C"
|
|---|
| 54 | #include "../zerosearch.h"
|
|---|
| 55 | //#include "../zerosearch.C"
|
|---|
| 56 | # include "../factfir.h"
|
|---|
| 57 | //#include "../factfir.C"
|
|---|
| 58 |
|
|---|
| 59 | //#include "../DrsCalibration.C"
|
|---|
| 60 | #include "../DrsCalibration.h"
|
|---|
| 61 |
|
|---|
| 62 | #include "../SpikeRemoval.h"
|
|---|
| 63 | //#include "../SpikeRemoval.C"
|
|---|
| 64 |
|
|---|
| 65 | #include "rootfilehandler.h"
|
|---|
| 66 | //#include "rootfilehandler.C"
|
|---|
| 67 |
|
|---|
| 68 | #include "pixel.h"
|
|---|
| 69 | //#include "pixel.C"
|
|---|
| 70 |
|
|---|
| 71 |
|
|---|
| 72 | //----------------------------------------------------------------------------
|
|---|
| 73 | // Decleration of global variables
|
|---|
| 74 | //----------------------------------------------------------------------------
|
|---|
| 75 |
|
|---|
| 76 | bool breakout=false;
|
|---|
| 77 |
|
|---|
| 78 | vector<int16_t> AllPixelDataVector;
|
|---|
| 79 | vector<int16_t> StartCellVector;
|
|---|
| 80 | unsigned int CurrentEventID;
|
|---|
| 81 | size_t PXLxROI;
|
|---|
| 82 | UInt_t gRegionOfInterest;
|
|---|
| 83 | UInt_t NumberOfPixels;
|
|---|
| 84 | TString histotitle;
|
|---|
| 85 |
|
|---|
| 86 | size_t TriggerOffsetROI, RC;
|
|---|
| 87 | size_t drs_n;
|
|---|
| 88 | vector<float> drs_basemean;
|
|---|
| 89 | vector<float> drs_gainmean;
|
|---|
| 90 | vector<float> drs_triggeroffsetmean;
|
|---|
| 91 |
|
|---|
| 92 | vector<float> Ameas(FAD_MAX_SAMPLES); // copy of the data (measured amplitude
|
|---|
| 93 | vector<float> Vcorr(FAD_MAX_SAMPLES); // corrected Values
|
|---|
| 94 | vector<float> Vslide(FAD_MAX_SAMPLES); // sliding average result
|
|---|
| 95 | vector<float> Vcfd(FAD_MAX_SAMPLES); // CDF result
|
|---|
| 96 | vector<float> Vcfd2(FAD_MAX_SAMPLES); // CDF result + 2nd sliding average
|
|---|
| 97 |
|
|---|
| 98 | int gNEvents=0;
|
|---|
| 99 | float gGainMean = 9;
|
|---|
| 100 | float gBSLMean = 0;
|
|---|
| 101 |
|
|---|
| 102 | //typedef struct{
|
|---|
| 103 | // double maxAmpl;
|
|---|
| 104 | // int countOfMax;
|
|---|
| 105 | // } OverlayMaximum;
|
|---|
| 106 |
|
|---|
| 107 | //typedef struct{
|
|---|
| 108 | // TString name;
|
|---|
| 109 | // TString title;
|
|---|
| 110 | // TString xTitle;
|
|---|
| 111 | // TString yTitle;
|
|---|
| 112 | // float yMax;
|
|---|
| 113 | // float yMin;
|
|---|
| 114 | //} histAttrib_t;
|
|---|
| 115 |
|
|---|
| 116 | //histAttrib_t* gHistoAttrib[maxPulseOrder];
|
|---|
| 117 | //histAttrib_t* gProfileAttrib[maxPulseOrder];
|
|---|
| 118 |
|
|---|
| 119 |
|
|---|
| 120 | // histograms
|
|---|
| 121 | const int Number_Of_Debug_Histo_Types = 7;
|
|---|
| 122 |
|
|---|
| 123 | const unsigned int
|
|---|
| 124 | Ameas_ = 0,
|
|---|
| 125 | N1mean_ = 1,
|
|---|
| 126 | Vcorr_ = 2,
|
|---|
| 127 | Vtest_ = 3,
|
|---|
| 128 | Vslide_ = 4,
|
|---|
| 129 | Vcfd_ = 5,
|
|---|
| 130 | Vcfd2_ = 6;
|
|---|
| 131 |
|
|---|
| 132 | //const char* gHistoTypes[8] = {
|
|---|
| 133 | // "hMaxOverlay",
|
|---|
| 134 | // "hPixelMax",
|
|---|
| 135 | // "hEdgeOverlay",
|
|---|
| 136 | // "hMaxProfile",
|
|---|
| 137 | // "hAllPixelOverlay",
|
|---|
| 138 | // "hAllPixelMax",
|
|---|
| 139 | // "hAllPixelMaxGaus",
|
|---|
| 140 | // "hAllPixelProfile"
|
|---|
| 141 | //};
|
|---|
| 142 |
|
|---|
| 143 | //----------------------------------------------------------------------------
|
|---|
| 144 | // Initialisation of histograms
|
|---|
| 145 | //----------------------------------------------------------------------------
|
|---|
| 146 |
|
|---|
| 147 | // Temporary Objects
|
|---|
| 148 | TH1F* debugHistos = NULL;
|
|---|
| 149 | //TH2F* hOverlayTemp = NULL;
|
|---|
| 150 | //TH1D* hProjPeak = NULL;
|
|---|
| 151 | TH1F* hTesthisto = NULL;
|
|---|
| 152 | TH2F* hTesthisto2 = NULL;
|
|---|
| 153 |
|
|---|
| 154 | //Histogram Parameters
|
|---|
| 155 | Int_t gPixelOverlayXaxisLeft = 0;
|
|---|
| 156 | Int_t gPixelOverlayXaxisRight = 0;
|
|---|
| 157 |
|
|---|
| 158 | //Root-File Objects
|
|---|
| 159 | // TObjArray* hList[sampleSetSize] = {NULL};
|
|---|
| 160 | TObjArray* hRootList = NULL;
|
|---|
| 161 |
|
|---|
| 162 | TCanvas** cgpPixelPulses = NULL;
|
|---|
| 163 | TCanvas** cgpDistributions = NULL;
|
|---|
| 164 | TCanvas* cFiltered = NULL;
|
|---|
| 165 | TCanvas* cgpTestHistos = NULL;
|
|---|
| 166 |
|
|---|
| 167 | //----------------------------------------------------------------------------
|
|---|
| 168 | // Functions
|
|---|
| 169 | //----------------------------------------------------------------------------
|
|---|
| 170 |
|
|---|
| 171 | void BookDebugHistos(int );
|
|---|
| 172 | void BookTestHistos( int );
|
|---|
| 173 |
|
|---|
| 174 | //void DeletePixelHistos(int );
|
|---|
| 175 | //void SaveHistograms( const char*, const char*, TObjArray*, int );
|
|---|
| 176 |
|
|---|
| 177 | void FillHistograms(Pixel*, vector<Region>*, int, int, TString, int, int);
|
|---|
| 178 | void DrawTestHistograms( int);
|
|---|
| 179 | void ProduceDebugHistos( vector<Region> *pZXings);
|
|---|
| 180 |
|
|---|
| 181 | void UpdateCanvases( int, int);
|
|---|
| 182 | void DeletePixelCanvases( int, int );
|
|---|
| 183 |
|
|---|
| 184 | //----------------------------------------------------------------------------
|
|---|
| 185 | //----------------------------------------------------------------------------
|
|---|
| 186 | // MAIN - Funtion
|
|---|
| 187 | //----------------------------------------------------------------------------
|
|---|
| 188 | //----------------------------------------------------------------------------
|
|---|
| 189 | int FPulseOverlay(
|
|---|
| 190 | const char* datafilename = "../../data/2011/11/09/20111109_006.fits.gz",
|
|---|
| 191 | const char* drsfilename = "../../data/2011/11/09/20111109_003.drs.fits.gz",
|
|---|
| 192 | const char* OutRootFileName = "../../analysis/FPulseTemplate/20111109_006/20111109_006.pulses.root",
|
|---|
| 193 | bool ProduceGraphic = false,
|
|---|
| 194 | bool spikeDebug = false,
|
|---|
| 195 | bool debugPixel = false,
|
|---|
| 196 | bool testmode = false,
|
|---|
| 197 | bool saveResults = false,
|
|---|
| 198 | int verbosityLevel = 6, // different verbosity levels can be implemented here
|
|---|
| 199 | int firstevent = 1, // Hast to be between 1 and infinity NOT 0!!!!
|
|---|
| 200 | int nevents = 10,
|
|---|
| 201 | int firstpixel = 0,
|
|---|
| 202 | int npixel = -1,
|
|---|
| 203 | int sampleSetSize = 40,
|
|---|
| 204 | int maxPulseOrder = 3,
|
|---|
| 205 | int AmplWindowWidth = 14, //Width of Window for selection of pulses to histograms
|
|---|
| 206 | TString histoOptions = "S",
|
|---|
| 207 | float GainMean = 8,
|
|---|
| 208 | float BSLMean = -1, //4 Histogramms will be drawn, decide how far pulsehights differ from eachother
|
|---|
| 209 | int avg1 = 8,
|
|---|
| 210 | int avg2 = 8,
|
|---|
| 211 | int OverlayWindowLeft = 70,
|
|---|
| 212 | int OverlayWindowRight = 230,
|
|---|
| 213 | int refresh_rate = 500 //refresh rate for canvases
|
|---|
| 214 | )
|
|---|
| 215 | {
|
|---|
| 216 | //----------------------------------------------------------------------------
|
|---|
| 217 | // Initialize Pixel
|
|---|
| 218 | //----------------------------------------------------------------------------
|
|---|
| 219 | Pixel** pixel = new Pixel*[sampleSetSize];
|
|---|
| 220 |
|
|---|
| 221 | for (int i = 0 ; i < sampleSetSize; i++)
|
|---|
| 222 | {
|
|---|
| 223 | pixel[i] = NULL;
|
|---|
| 224 | }
|
|---|
| 225 | //----------------------------------------------------------------------------
|
|---|
| 226 | // Save-Root-File Settings
|
|---|
| 227 | //----------------------------------------------------------------------------
|
|---|
| 228 | if (saveResults)
|
|---|
| 229 | {
|
|---|
| 230 | CreateRootFile( OutRootFileName, verbosityLevel );
|
|---|
| 231 | }
|
|---|
| 232 |
|
|---|
| 233 | //----------------------------------------------------------------------------
|
|---|
| 234 | // root global Settings
|
|---|
| 235 | //----------------------------------------------------------------------------
|
|---|
| 236 |
|
|---|
| 237 | gGainMean = GainMean;
|
|---|
| 238 | gBSLMean = BSLMean;
|
|---|
| 239 | gPixelOverlayXaxisLeft = OverlayWindowLeft;
|
|---|
| 240 | gPixelOverlayXaxisRight = OverlayWindowRight;
|
|---|
| 241 |
|
|---|
| 242 | gStyle->SetPalette(1,0);
|
|---|
| 243 | gROOT->SetStyle("Plain");
|
|---|
| 244 | // gPad->SetGrid();
|
|---|
| 245 |
|
|---|
| 246 | //----------------------------------------------------------------------------
|
|---|
| 247 | // root Canvas Settings
|
|---|
| 248 | //----------------------------------------------------------------------------
|
|---|
| 249 | //Canvas Pad numbering
|
|---|
| 250 | int pulsesCanvasFrameNrs[4] = {
|
|---|
| 251 | 1, // Top left
|
|---|
| 252 | 2, // Top right
|
|---|
| 253 | 3, // bottom left
|
|---|
| 254 | 4 // bootom right
|
|---|
| 255 | };
|
|---|
| 256 |
|
|---|
| 257 | //Canvas Pad numbering
|
|---|
| 258 | int distributionCanvasFrameNrs[4] = {
|
|---|
| 259 | 1, // Top left
|
|---|
| 260 | 2, // Top right
|
|---|
| 261 | 3, // bottom left
|
|---|
| 262 | 4 // bootom right
|
|---|
| 263 | };
|
|---|
| 264 |
|
|---|
| 265 | if (ProduceGraphic)
|
|---|
| 266 | {
|
|---|
| 267 |
|
|---|
| 268 | //Canvases
|
|---|
| 269 | cgpPixelPulses = new TCanvas*[maxPulseOrder];
|
|---|
| 270 | cgpDistributions = new TCanvas*[maxPulseOrder];
|
|---|
| 271 |
|
|---|
| 272 | //TCanvas* gpcDevelopment = NULL;
|
|---|
| 273 | TString cName = "";
|
|---|
| 274 | TString cTitle = "";
|
|---|
| 275 |
|
|---|
| 276 | //naming of pulse canvases
|
|---|
| 277 | for (
|
|---|
| 278 | int pulse_order = maxPulseOrder - 1;
|
|---|
| 279 | pulse_order >= 0 ;
|
|---|
| 280 | pulse_order--
|
|---|
| 281 | )
|
|---|
| 282 | {
|
|---|
| 283 | cName ="cgpDistributions";
|
|---|
| 284 | cName += pulse_order;
|
|---|
| 285 | cTitle ="Pulses of Order: ";
|
|---|
| 286 | cTitle += pulse_order;
|
|---|
| 287 | cgpDistributions[pulse_order] = new TCanvas(cName,cTitle, 0,pulse_order*20,800,800);
|
|---|
| 288 | cgpDistributions[pulse_order]->Divide(2, 2);
|
|---|
| 289 | cName ="cgpPixelPulses";
|
|---|
| 290 | cName += pulse_order;
|
|---|
| 291 | cTitle ="Pulses of Order: ";
|
|---|
| 292 | cTitle += pulse_order;
|
|---|
| 293 | cgpPixelPulses[pulse_order] = new TCanvas(cName,cTitle, 0,pulse_order*20,800,800);
|
|---|
| 294 | cgpPixelPulses[pulse_order]->Divide(2, 2);
|
|---|
| 295 | }
|
|---|
| 296 |
|
|---|
| 297 |
|
|---|
| 298 | // Create (pointer to) Canvases, which are used in every run,
|
|---|
| 299 | // also in 'non-debug' runs
|
|---|
| 300 | // Canvases only need if spike Debug, but I want to deklare
|
|---|
| 301 | // the pointers anyway ...
|
|---|
| 302 | if (spikeDebug)
|
|---|
| 303 | {
|
|---|
| 304 | cFiltered = new TCanvas("cFiltered","filtered DRS Waveforms", 1,310,400,300);
|
|---|
| 305 | cFiltered->Divide(1, 3);
|
|---|
| 306 | }
|
|---|
| 307 |
|
|---|
| 308 | //additional Test histograms
|
|---|
| 309 | cgpTestHistos = new TCanvas( "cgpTestHistos", "Test Histograms", 801, 0, 800, 800 );
|
|---|
| 310 | cgpTestHistos->Divide(2,0);
|
|---|
| 311 | }
|
|---|
| 312 |
|
|---|
| 313 | //-----------------------------------------------------------------------------
|
|---|
| 314 | // Filter-Settings
|
|---|
| 315 | //-----------------------------------------------------------------------------
|
|---|
| 316 | // CFD filter settings
|
|---|
| 317 | int k_cfd = 10;
|
|---|
| 318 | vector<double> a_cfd(k_cfd, 0);
|
|---|
| 319 | double b_cfd = 1.;
|
|---|
| 320 | a_cfd[0]=-0.75;
|
|---|
| 321 | a_cfd[k_cfd-1]=1.;
|
|---|
| 322 |
|
|---|
| 323 | //-----------------------------------------------------------------------------
|
|---|
| 324 | // prepare datafile
|
|---|
| 325 | //-----------------------------------------------------------------------------
|
|---|
| 326 |
|
|---|
| 327 | // Open the data file
|
|---|
| 328 |
|
|---|
| 329 | fits * datafile;
|
|---|
| 330 | // Opens the raw data file and 'binds' the variables given as
|
|---|
| 331 | // Parameters to the data file. So they are filled with
|
|---|
| 332 | // raw data as soon as datafile->GetRow(int) is called.
|
|---|
| 333 | gNEvents = openDataFits(
|
|---|
| 334 | datafilename,
|
|---|
| 335 | &datafile,
|
|---|
| 336 | AllPixelDataVector,
|
|---|
| 337 | StartCellVector,
|
|---|
| 338 | CurrentEventID,
|
|---|
| 339 | gRegionOfInterest,
|
|---|
| 340 | NumberOfPixels,
|
|---|
| 341 | PXLxROI,
|
|---|
| 342 | verbosityLevel
|
|---|
| 343 | );
|
|---|
| 344 |
|
|---|
| 345 | if (gNEvents == 0)
|
|---|
| 346 | {
|
|---|
| 347 | cout << "return code of OpenDataFile:" << datafilename<< endl;
|
|---|
| 348 | cout << "is zero -> aborting." << endl;
|
|---|
| 349 | return 1;
|
|---|
| 350 | }
|
|---|
| 351 |
|
|---|
| 352 | if (verbosityLevel > 0)
|
|---|
| 353 | {
|
|---|
| 354 | cout << endl <<"number of events in file: "<< gNEvents << "\t";
|
|---|
| 355 | }
|
|---|
| 356 |
|
|---|
| 357 | if ( nevents == -1 || nevents > gNEvents ) nevents = gNEvents; // -1 means all!
|
|---|
| 358 |
|
|---|
| 359 | if (verbosityLevel > 0)
|
|---|
| 360 | {
|
|---|
| 361 | cout <<"of, which "<< nevents << " will be processed"<< endl;
|
|---|
| 362 | cout <<"Total # of Pixel: "<< NumberOfPixels << "\t";
|
|---|
| 363 | }
|
|---|
| 364 |
|
|---|
| 365 | if ( npixel == -1 || npixel > (int)NumberOfPixels ) npixel = (int)NumberOfPixels; // -1 means all!
|
|---|
| 366 |
|
|---|
| 367 | if (verbosityLevel > 0)
|
|---|
| 368 | {
|
|---|
| 369 | cout <<"of, which "<< npixel << " will be processed"<< endl;
|
|---|
| 370 | }
|
|---|
| 371 |
|
|---|
| 372 | //Get the DRS calibration
|
|---|
| 373 | RC = openCalibFits(
|
|---|
| 374 | drsfilename,
|
|---|
| 375 | drs_basemean,
|
|---|
| 376 | drs_gainmean,
|
|---|
| 377 | drs_triggeroffsetmean,
|
|---|
| 378 | TriggerOffsetROI
|
|---|
| 379 | );
|
|---|
| 380 |
|
|---|
| 381 | if (RC == 0)
|
|---|
| 382 | {
|
|---|
| 383 | cout << "return code of openCalibFits:" << drsfilename << endl;
|
|---|
| 384 | cout << "is zero -> aborting." << endl;
|
|---|
| 385 | return 1;
|
|---|
| 386 | }
|
|---|
| 387 |
|
|---|
| 388 | //-----------------------------------------------------------------------------
|
|---|
| 389 | // Book the histograms
|
|---|
| 390 | //-----------------------------------------------------------------------------
|
|---|
| 391 |
|
|---|
| 392 | if (spikeDebug)
|
|---|
| 393 | BookDebugHistos(verbosityLevel );
|
|---|
| 394 |
|
|---|
| 395 | if (testmode)
|
|---|
| 396 | BookTestHistos( verbosityLevel );
|
|---|
| 397 |
|
|---|
| 398 |
|
|---|
| 399 | //-----------------------------------------------------------------------------
|
|---|
| 400 | // Main Cycle
|
|---|
| 401 | //-----------------------------------------------------------------------------
|
|---|
| 402 |
|
|---|
| 403 | //-------------------------------------
|
|---|
| 404 | // Loop over Pixel Sets
|
|---|
| 405 | //-------------------------------------
|
|---|
| 406 | for ( int firstPixelOfSample = firstpixel;
|
|---|
| 407 | firstPixelOfSample < firstpixel + npixel;
|
|---|
| 408 | firstPixelOfSample += sampleSetSize )
|
|---|
| 409 | {
|
|---|
| 410 |
|
|---|
| 411 | if (verbosityLevel == 0)
|
|---|
| 412 | {
|
|---|
| 413 | cout << "------------------------------------------------" << endl
|
|---|
| 414 | << "...processing Sample from Pixel "
|
|---|
| 415 | << firstPixelOfSample
|
|---|
| 416 | << " to Pixel "
|
|---|
| 417 | << firstPixelOfSample+sampleSetSize-1 << endl;
|
|---|
| 418 | }
|
|---|
| 419 |
|
|---|
| 420 | //--------------------------------------------------------------------
|
|---|
| 421 | // Loop over every Event of Pixel Set
|
|---|
| 422 | //--------------------------------------------------------------------
|
|---|
| 423 | for ( int ev = firstevent ; ev < firstevent + nevents; ev++)
|
|---|
| 424 | {
|
|---|
| 425 | // Get an Event --> consists of 1440 Pixel ...erm....data
|
|---|
| 426 | cout << endl << "processing event " << ev << endl;
|
|---|
| 427 | datafile->GetRow( ev );
|
|---|
| 428 |
|
|---|
| 429 | if (verbosityLevel == 1)
|
|---|
| 430 | {
|
|---|
| 431 | cout << "-------------------------------------" << endl
|
|---|
| 432 | << "...processing Sample from Pixel "
|
|---|
| 433 | << firstPixelOfSample
|
|---|
| 434 | << " to Pixel "
|
|---|
| 435 | << firstPixelOfSample+sampleSetSize-1
|
|---|
| 436 | << "... Event: " << CurrentEventID
|
|---|
| 437 | << "/" << nevents << endl;
|
|---|
| 438 | }
|
|---|
| 439 |
|
|---|
| 440 | //--------------------------------------------------------------------
|
|---|
| 441 | // Loops over every Pixel of a Set of Pixels
|
|---|
| 442 | //--------------------------------------------------------------------
|
|---|
| 443 | for ( int pixelID = firstPixelOfSample;
|
|---|
| 444 | pixelID < firstPixelOfSample + sampleSetSize
|
|---|
| 445 | && pixelID < firstpixel + npixel;
|
|---|
| 446 | pixelID++ )
|
|---|
| 447 | {
|
|---|
| 448 | if (verbosityLevel > 1)
|
|---|
| 449 | {
|
|---|
| 450 | cout << "-------------------------------------" << endl
|
|---|
| 451 | << "...processing Sample from Pixel "
|
|---|
| 452 | << firstPixelOfSample
|
|---|
| 453 | << " to Pixel "
|
|---|
| 454 | << firstPixelOfSample+sampleSetSize-1
|
|---|
| 455 | << "... Event: " << CurrentEventID
|
|---|
| 456 | << "/" << nevents << endl
|
|---|
| 457 | << " Pixel: " << pixelID
|
|---|
| 458 | << "/" << firstpixel + npixel -1 << endl;
|
|---|
| 459 | }
|
|---|
| 460 |
|
|---|
| 461 | //-------------------------------------
|
|---|
| 462 | // Create individual Pixel
|
|---|
| 463 | //-------------------------------------
|
|---|
| 464 | if (ev == firstevent)
|
|---|
| 465 | {
|
|---|
| 466 | pixel[pixelID] = new Pixel(
|
|---|
| 467 | pixelID,
|
|---|
| 468 | maxPulseOrder,
|
|---|
| 469 | verbosityLevel,
|
|---|
| 470 | gPixelOverlayXaxisLeft,
|
|---|
| 471 | gPixelOverlayXaxisRight,
|
|---|
| 472 | gBSLMean,
|
|---|
| 473 | gGainMean,
|
|---|
| 474 | histoOptions
|
|---|
| 475 | );
|
|---|
| 476 | cout << "Created Pixel# Set " << pixelID
|
|---|
| 477 | << " Pixel# Get " << pixel[pixelID]->mChid
|
|---|
| 478 | << " Adress " << &pixel[pixelID] << endl;
|
|---|
| 479 |
|
|---|
| 480 | }
|
|---|
| 481 |
|
|---|
| 482 | //-------------------------------------
|
|---|
| 483 | // Apply Calibration
|
|---|
| 484 | //-------------------------------------
|
|---|
| 485 | if (verbosityLevel > 2) cout << "...applying DrsCalibration";
|
|---|
| 486 | applyDrsCalibration(
|
|---|
| 487 | Ameas,
|
|---|
| 488 | pixelID,
|
|---|
| 489 | 12,
|
|---|
| 490 | 12,
|
|---|
| 491 | drs_basemean,
|
|---|
| 492 | drs_gainmean,
|
|---|
| 493 | drs_triggeroffsetmean,
|
|---|
| 494 | gRegionOfInterest,
|
|---|
| 495 | AllPixelDataVector,
|
|---|
| 496 | StartCellVector
|
|---|
| 497 | );
|
|---|
| 498 | if (verbosityLevel > 2) cout << "...done " << endl;
|
|---|
| 499 |
|
|---|
| 500 | //-------------------------------------
|
|---|
| 501 | // Apply Filters
|
|---|
| 502 | //-------------------------------------
|
|---|
| 503 | // finds spikes in the raw data, and interpolates the value
|
|---|
| 504 | // spikes are: 1 or 2 slice wide, positive non physical artifacts
|
|---|
| 505 | if (verbosityLevel > 2) cout << "...removeing Spikes";
|
|---|
| 506 | cout << "blaaa" << endl;
|
|---|
| 507 | cout << "blaaa" << endl;
|
|---|
| 508 |
|
|---|
| 509 | removeSpikes (Ameas, Vcorr);
|
|---|
| 510 | if (verbosityLevel > 2) cout << "...done " << endl;
|
|---|
| 511 |
|
|---|
| 512 | // filter Vcorr with sliding average using FIR filter function
|
|---|
| 513 | if (verbosityLevel > 2) cout << "...applying sliding average filter";
|
|---|
| 514 | sliding_avg(Vcorr, Vslide, avg1);
|
|---|
| 515 | if (verbosityLevel > 2) cout << "...done " << endl;
|
|---|
| 516 |
|
|---|
| 517 | // filter Vslide with CFD using FIR filter function
|
|---|
| 518 | if (verbosityLevel > 2) cout << "...apllying factfir filter";
|
|---|
| 519 | factfir(b_cfd , a_cfd, k_cfd, Vslide, Vcfd);
|
|---|
| 520 | if (verbosityLevel > 2) cout << "...done " << endl;
|
|---|
| 521 |
|
|---|
| 522 | // filter Vcfd with sliding average using FIR filter function
|
|---|
| 523 | if (verbosityLevel > 2) cout << "...applying 2nd sliding average filter";
|
|---|
| 524 | sliding_avg(Vcfd, Vcfd2, avg2);
|
|---|
| 525 | if (verbosityLevel > 2) cout << "...done " << endl;
|
|---|
| 526 | cout << "miauuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu" << endl;
|
|---|
| 527 |
|
|---|
| 528 | //-------------------------------------
|
|---|
| 529 | // Search vor Zero crossings
|
|---|
| 530 | //-------------------------------------
|
|---|
| 531 | if (verbosityLevel > 2) cout << endl << "...searching zero crossings" ;
|
|---|
| 532 | // peaks in Ameas[] are found by searching for zero crossings
|
|---|
| 533 | // in Vcfd2
|
|---|
| 534 | // first Argument 1 means ... *rising* edge
|
|---|
| 535 | // second Argument 1 means ... search with stepsize 1 ... 10 is okay as well
|
|---|
| 536 | vector<Region>* pZXings = zerosearch( Vcfd2 , 1 , 8);
|
|---|
| 537 | // pZXings means "zero cross ings"
|
|---|
| 538 | EnlargeRegion(*pZXings, 10, 10);
|
|---|
| 539 | findAbsMaxInRegions(*pZXings, Vslide);
|
|---|
| 540 | removeMaximaBelow( *pZXings, 3.0);
|
|---|
| 541 | removeRegionWithMaxOnEdge( *pZXings, 2);
|
|---|
| 542 | removeRegionOnFallingEdge( *pZXings, 100);
|
|---|
| 543 | findTimeOfHalfMaxLeft(*pZXings, Vcorr, gBSLMean, 5, 10, verbosityLevel );
|
|---|
| 544 | if (verbosityLevel > 2) cout << "...done" << endl;
|
|---|
| 545 |
|
|---|
| 546 | //-----------------------------------------------------------------------------
|
|---|
| 547 | // Fill Overlay Histos
|
|---|
| 548 | //-----------------------------------------------------------------------------
|
|---|
| 549 | cout << endl << "Filling Histograms of Pixel# [Set] " << pixelID
|
|---|
| 550 | << " Pixel# [Got] " << pixel[pixelID]->mChid
|
|---|
| 551 | << " Adress " << &pixel[pixelID] << endl;
|
|---|
| 552 | // FillHistograms(
|
|---|
| 553 | // pixel[pixelID],
|
|---|
| 554 | // pZXings,
|
|---|
| 555 | // AmplWindowWidth,
|
|---|
| 556 | // ev,
|
|---|
| 557 | // histoOptions,
|
|---|
| 558 | // maxPulseOrder,
|
|---|
| 559 | // verbosityLevel
|
|---|
| 560 | // );
|
|---|
| 561 | cout << endl << "got out of fillhisto" << endl;
|
|---|
| 562 | //-----------------------------------------------------------------------------
|
|---|
| 563 | // Spike Debug
|
|---|
| 564 | //-----------------------------------------------------------------------------
|
|---|
| 565 | if ( spikeDebug )
|
|---|
| 566 | {
|
|---|
| 567 | ProduceDebugHistos( pZXings );
|
|---|
| 568 | }// end of if(spikeDebug)
|
|---|
| 569 |
|
|---|
| 570 | delete pZXings;
|
|---|
| 571 | if (breakout) break;
|
|---|
| 572 | //-------------------------------------
|
|---|
| 573 | // Draw 1. Set of Pixel Histograms
|
|---|
| 574 | //-------------------------------------
|
|---|
| 575 | if ((ev % refresh_rate) == 0)
|
|---|
| 576 | {
|
|---|
| 577 | if (ProduceGraphic)
|
|---|
| 578 | {
|
|---|
| 579 | if (debugPixel)
|
|---|
| 580 | {
|
|---|
| 581 | for ( int order = 0;
|
|---|
| 582 | order < maxPulseOrder;
|
|---|
| 583 | order++
|
|---|
| 584 | )
|
|---|
| 585 | {
|
|---|
| 586 | pixel[pixelID]->DrawHistograms(
|
|---|
| 587 | cgpPixelPulses[order],
|
|---|
| 588 | pulsesCanvasFrameNrs
|
|---|
| 589 | );
|
|---|
| 590 | }
|
|---|
| 591 | if (testmode)
|
|---|
| 592 | {
|
|---|
| 593 | DrawTestHistograms(
|
|---|
| 594 | verbosityLevel
|
|---|
| 595 | );
|
|---|
| 596 | }
|
|---|
| 597 |
|
|---|
| 598 | UpdateCanvases(
|
|---|
| 599 | verbosityLevel,
|
|---|
| 600 | maxPulseOrder
|
|---|
| 601 | );
|
|---|
| 602 | }
|
|---|
| 603 | }
|
|---|
| 604 | }
|
|---|
| 605 |
|
|---|
| 606 | if (breakout) break;
|
|---|
| 607 |
|
|---|
| 608 | if (verbosityLevel > 1)
|
|---|
| 609 | {
|
|---|
| 610 | cout << endl << "...End of Pixel"
|
|---|
| 611 | << endl << "-------------------------------------"<< endl;
|
|---|
| 612 | }
|
|---|
| 613 | }//End of Loop over Sample
|
|---|
| 614 | //-------------------------------------
|
|---|
| 615 | // end of Loops over Sample
|
|---|
| 616 | //-------------------------------------
|
|---|
| 617 |
|
|---|
| 618 | cout << endl << "Last Pixel# [Set] " << (firstPixelOfSample + sampleSetSize-1);
|
|---|
| 619 | cout << " Pixel# [Got] " << pixel[firstPixelOfSample + sampleSetSize-1]->mChid
|
|---|
| 620 | << " Adress " << &pixel[firstPixelOfSample + sampleSetSize-1]
|
|---|
| 621 | << " Adress [Got]" << &pixel[firstPixelOfSample + sampleSetSize-1]->mChid;
|
|---|
| 622 |
|
|---|
| 623 | }//End of Loop over Events
|
|---|
| 624 | //-------------------------------------
|
|---|
| 625 | // end of Loops over Events
|
|---|
| 626 | //-------------------------------------
|
|---|
| 627 |
|
|---|
| 628 |
|
|---|
| 629 |
|
|---|
| 630 | //-------------------------------------
|
|---|
| 631 | // Draw Pixel Histogramms of Overlay Spectra
|
|---|
| 632 | //-------------------------------------
|
|---|
| 633 |
|
|---|
| 634 | for ( int pixelID = firstPixelOfSample;
|
|---|
| 635 | pixelID < firstPixelOfSample + sampleSetSize
|
|---|
| 636 | && pixelID < firstpixel + npixel;
|
|---|
| 637 | pixelID++ )
|
|---|
| 638 | {
|
|---|
| 639 | //here is what happends at the end of each loop over all Events
|
|---|
| 640 | // pixel[pixelID]->DrawHistograms(
|
|---|
| 641 | // cgpPixelPulses,
|
|---|
| 642 | // pulsesCanvasFrameNrs
|
|---|
| 643 | // );
|
|---|
| 644 |
|
|---|
| 645 | // SaveHistograms( //save histograms of generell results into output root file
|
|---|
| 646 | // OutRootFileName,
|
|---|
| 647 | // CreateSubDirName(pixel[pixelID]->mChid),
|
|---|
| 648 | // pixel[pixelID]->hList,
|
|---|
| 649 | // saveResults,
|
|---|
| 650 | // verbosityLevel
|
|---|
| 651 | // );
|
|---|
| 652 |
|
|---|
| 653 | if (ProduceGraphic)
|
|---|
| 654 | {
|
|---|
| 655 | UpdateCanvases(
|
|---|
| 656 | verbosityLevel,
|
|---|
| 657 | maxPulseOrder
|
|---|
| 658 | );
|
|---|
| 659 | }
|
|---|
| 660 |
|
|---|
| 661 | //Save Histograms of Pixels into Output rootfile
|
|---|
| 662 | cout << endl << "Saving Pixel# [Set] " << pixelID
|
|---|
| 663 | << " Pixel# [Got] " << pixel[pixelID]->mChid
|
|---|
| 664 | << " Adress " << &pixel[pixelID];
|
|---|
| 665 | pixel[pixelID]->SavePixelHistograms( OutRootFileName, saveResults );
|
|---|
| 666 |
|
|---|
| 667 |
|
|---|
| 668 | if (debugPixel)
|
|---|
| 669 | {
|
|---|
| 670 | //Process gui events asynchronously during input
|
|---|
| 671 | cout << endl;
|
|---|
| 672 | TTimer timer("gSystem->ProcessEvents();", 50, kFALSE);
|
|---|
| 673 | timer.TurnOn();
|
|---|
| 674 | TString input = Getline("Type 'q' to exit, <return> to go on: ");
|
|---|
| 675 | timer.TurnOff();
|
|---|
| 676 | if (input=="q\n") {
|
|---|
| 677 | break;
|
|---|
| 678 | }
|
|---|
| 679 | }
|
|---|
| 680 |
|
|---|
| 681 | cout << endl << "Deleting Pixel# [Set] " << pixelID
|
|---|
| 682 | << " Pixel# [Got] " << pixel[pixelID]->mChid
|
|---|
| 683 | << " Adress " << &pixel[pixelID]
|
|---|
| 684 | << " ChidAdress " << &pixel[pixelID]->mChid ;
|
|---|
| 685 | delete pixel[pixelID];
|
|---|
| 686 |
|
|---|
| 687 | if (verbosityLevel > 2)
|
|---|
| 688 | {
|
|---|
| 689 | cout << endl << "...End of Pixel-Set"
|
|---|
| 690 | << endl << "------------------------------------------------"
|
|---|
| 691 | << endl;
|
|---|
| 692 | }
|
|---|
| 693 | }
|
|---|
| 694 | }
|
|---|
| 695 | // End of Loop over all Pixels
|
|---|
| 696 |
|
|---|
| 697 | //-------------------------------------
|
|---|
| 698 | // Draw Histograms
|
|---|
| 699 | //-------------------------------------
|
|---|
| 700 |
|
|---|
| 701 | SaveHistograms( //save histograms of generell results into output root file
|
|---|
| 702 | OutRootFileName,
|
|---|
| 703 | "root",
|
|---|
| 704 | hRootList,
|
|---|
| 705 | saveResults,
|
|---|
| 706 | verbosityLevel
|
|---|
| 707 | );
|
|---|
| 708 |
|
|---|
| 709 | if (ProduceGraphic)
|
|---|
| 710 | {
|
|---|
| 711 | UpdateCanvases(
|
|---|
| 712 | verbosityLevel,
|
|---|
| 713 | maxPulseOrder
|
|---|
| 714 | );
|
|---|
| 715 |
|
|---|
| 716 | //Process gui events asynchronously during input
|
|---|
| 717 | cout << endl;
|
|---|
| 718 | TTimer timer("gSystem->ProcessEvents();", 50, kFALSE);
|
|---|
| 719 | timer.TurnOn();
|
|---|
| 720 | Getline("Press <return> to go on");
|
|---|
| 721 | timer.TurnOff();
|
|---|
| 722 |
|
|---|
| 723 | DeletePixelCanvases(
|
|---|
| 724 | maxPulseOrder,
|
|---|
| 725 | verbosityLevel
|
|---|
| 726 | );
|
|---|
| 727 | }
|
|---|
| 728 | return( 0 );
|
|---|
| 729 | }
|
|---|
| 730 | //----------------------------------------------------------------------------
|
|---|
| 731 | // end of main function
|
|---|
| 732 | //-----------------------------------------------------------------------------
|
|---|
| 733 |
|
|---|
| 734 |
|
|---|
| 735 |
|
|---|
| 736 |
|
|---|
| 737 | //-----------------------------------------------------------------------------
|
|---|
| 738 | // Funktions
|
|---|
| 739 | //-----------------------------------------------------------------------------
|
|---|
| 740 |
|
|---|
| 741 | /*
|
|---|
| 742 | ich erzeuge sowas wie 36 pixel mit ca 20 Histogrammen pro pixel
|
|---|
| 743 | wie viel speicher braucht das?
|
|---|
| 744 | Ich brauche eine möglichkeit jedes dieser histogramme zu identifizieren
|
|---|
| 745 | am besten ein array oder eine liste oder einen abstracten datentyp mit den histogrammen als attribute.
|
|---|
| 746 | ne klasse wäre super
|
|---|
| 747 |
|
|---|
| 748 | */
|
|---|
| 749 |
|
|---|
| 750 | void BookTestHistos( int verbosityLevel )
|
|---|
| 751 | {
|
|---|
| 752 | if (verbosityLevel > 2) cout << endl << "...book pixel histograms" << endl;
|
|---|
| 753 |
|
|---|
| 754 | hTesthisto = new TH1F (
|
|---|
| 755 | "hTesthisto",
|
|---|
| 756 | "Deviation of rising edge and maximum",
|
|---|
| 757 | 600,
|
|---|
| 758 | -10.1,
|
|---|
| 759 | 10.1
|
|---|
| 760 | );
|
|---|
| 761 | hTesthisto->GetXaxis()->SetTitle( "Timeslices [a.u.]" );
|
|---|
| 762 | hTesthisto->GetYaxis()->SetTitle( "counts" );
|
|---|
| 763 |
|
|---|
| 764 | hTesthisto2 = new TH2F (
|
|---|
| 765 | "hTesthisto2",
|
|---|
| 766 | "Deviation of rising edge and maximum by event #",
|
|---|
| 767 | gNEvents,
|
|---|
| 768 | 250,
|
|---|
| 769 | 800,
|
|---|
| 770 | 600,
|
|---|
| 771 | -10.1,
|
|---|
| 772 | 10.1
|
|---|
| 773 | );
|
|---|
| 774 | // hTesthisto2->GetXaxis()->SetTitle( "Timeslices [a.u.]" );
|
|---|
| 775 | // hTesthisto2->GetYaxis()->SetTitle( "counts" );
|
|---|
| 776 | // hTesthisto2->SetMarkerStyle( 2 );
|
|---|
| 777 |
|
|---|
| 778 | if (verbosityLevel > 2) cout << "...done" << endl;
|
|---|
| 779 | }
|
|---|
| 780 | //end of BookTestHistos
|
|---|
| 781 | //----------------------------------------------------------------------------
|
|---|
| 782 |
|
|---|
| 783 |
|
|---|
| 784 | void
|
|---|
| 785 | BookDebugHistos( int verbosityLevel )
|
|---|
| 786 | {
|
|---|
| 787 | if (verbosityLevel > 2) cout << endl << "...book histograms" << endl;
|
|---|
| 788 | hRootList = new TObjArray;
|
|---|
| 789 | debugHistos = new TH1F[ Number_Of_Debug_Histo_Types ];
|
|---|
| 790 | for ( int type = 0; type < Number_Of_Debug_Histo_Types; type++){
|
|---|
| 791 | debugHistos[ type ].SetBins(1024, 0, 1024);
|
|---|
| 792 | debugHistos[ type ].SetLineColor(1);
|
|---|
| 793 | debugHistos[ type ].SetLineWidth(2);
|
|---|
| 794 | debugHistos[ type ].SetStats(false);
|
|---|
| 795 |
|
|---|
| 796 | // set X axis paras
|
|---|
| 797 | debugHistos[ type ].GetXaxis()->SetLabelSize(0.08);
|
|---|
| 798 | debugHistos[ type ].GetXaxis()->SetTitleSize(0.08);
|
|---|
| 799 | debugHistos[ type ].GetXaxis()->SetTitleOffset(1.0);
|
|---|
| 800 | debugHistos[ type ].GetXaxis()->SetTitle(Form("Time slice [%.1f ns/slice]", 1./2.));
|
|---|
| 801 |
|
|---|
| 802 | // set Y axis paras
|
|---|
| 803 | debugHistos[ type ].GetYaxis()->SetLabelSize(0.08);
|
|---|
| 804 | debugHistos[ type ].GetYaxis()->SetTitleSize(0.08);
|
|---|
| 805 | debugHistos[ type ].GetYaxis()->SetTitleOffset(0.3);
|
|---|
| 806 | debugHistos[ type ].GetYaxis()->SetTitle("Amplitude [mV]");
|
|---|
| 807 | }
|
|---|
| 808 | if (verbosityLevel > 2) cout << "...done" << endl;
|
|---|
| 809 | }
|
|---|
| 810 | // end of BookDebugHistos
|
|---|
| 811 | //----------------------------------------------------------------------------
|
|---|
| 812 |
|
|---|
| 813 |
|
|---|
| 814 | void
|
|---|
| 815 | FillHistograms(
|
|---|
| 816 | Pixel* CurrentPixel,
|
|---|
| 817 | vector<Region>* pZXings,
|
|---|
| 818 | int AmplWindowWidth,
|
|---|
| 819 | int eventNumber,
|
|---|
| 820 | TString histoOptions,
|
|---|
| 821 | int maxPulseOrder,
|
|---|
| 822 | int verbosityLevel
|
|---|
| 823 | )
|
|---|
| 824 | {
|
|---|
| 825 | cout << endl << "begin Pixel " << CurrentPixel->mChid << endl;
|
|---|
| 826 | if (verbosityLevel > 2) cout << endl << "...filling pulse histograms" ;
|
|---|
| 827 | bool use_this_peak=false;
|
|---|
| 828 | int order_of_pulse=0;
|
|---|
| 829 | vector<Region>::iterator reg;
|
|---|
| 830 | cout << endl << "begin for " << endl;
|
|---|
| 831 | //Loop over all found zerocrossings in Region
|
|---|
| 832 | for (reg = pZXings->begin() ; reg < pZXings->end() ; reg++)
|
|---|
| 833 | {
|
|---|
| 834 | cout << endl << "for" << endl;
|
|---|
| 835 | //skip those who are at the Rim of the ROI
|
|---|
| 836 | if (reg->maxPos < 12 || (unsigned int) reg->maxPos > gRegionOfInterest-12)
|
|---|
| 837 | {
|
|---|
| 838 | if (verbosityLevel > 2) cout << endl << "\t...out of range" << endl;
|
|---|
| 839 | continue;
|
|---|
| 840 | }
|
|---|
| 841 | cout << endl << "def" << endl;
|
|---|
| 842 | // Define axis range of Histogram
|
|---|
| 843 | int Left = reg->maxPos - gPixelOverlayXaxisLeft;
|
|---|
| 844 | int Right = reg->maxPos + gPixelOverlayXaxisRight;
|
|---|
| 845 | int EdgeLeft = reg->halfRisingEdgePos - gPixelOverlayXaxisLeft;
|
|---|
| 846 | int EdgeRight = reg->halfRisingEdgePos + gPixelOverlayXaxisRight;
|
|---|
| 847 |
|
|---|
| 848 | if (Left < 0) Left = 0;
|
|---|
| 849 | if (EdgeLeft < 0) EdgeLeft = 0;
|
|---|
| 850 | if (Right > (int)Ameas.size() ) Right = Ameas.size();
|
|---|
| 851 | if (EdgeRight > (int)Ameas.size() ) EdgeRight = Ameas.size();
|
|---|
| 852 |
|
|---|
| 853 |
|
|---|
| 854 | // hTesthisto2->Fill( eventNumber, reg->slopeOfRisingEdge ) ;
|
|---|
| 855 |
|
|---|
| 856 | if (verbosityLevel > 2) cout << endl << "\t...choosing Histogram" ;
|
|---|
| 857 |
|
|---|
| 858 | //determine order of pulse and which histogram shall be filled
|
|---|
| 859 | // if (verbosityLevel > 2)
|
|---|
| 860 | cout << endl << "\t...choosing Histogram" ;
|
|---|
| 861 | for(int order = 0; order < maxPulseOrder; order++)
|
|---|
| 862 | {
|
|---|
| 863 | if (Ameas[reg->maxPos] >= ((gGainMean*(order+1)) - (AmplWindowWidth/2))
|
|---|
| 864 | && Ameas[reg->maxPos] < ((gGainMean*(order+1)) + AmplWindowWidth/2))
|
|---|
| 865 | {
|
|---|
| 866 | if (verbosityLevel > 2) cout << "...#" << order ;
|
|---|
| 867 | order_of_pulse = order;
|
|---|
| 868 | use_this_peak = true;
|
|---|
| 869 | break;
|
|---|
| 870 | }
|
|---|
| 871 | else if (order >= (maxPulseOrder - 1))
|
|---|
| 872 | {
|
|---|
| 873 | use_this_peak = false;
|
|---|
| 874 | if (verbosityLevel > 2) cout << "...NONE" << endl ;
|
|---|
| 875 | }
|
|---|
| 876 | if (use_this_peak)
|
|---|
| 877 | {
|
|---|
| 878 | if ( histoOptions.Contains("S") )
|
|---|
| 879 | {
|
|---|
| 880 | // if (verbosityLevel > 2)
|
|---|
| 881 | cout << endl << "\t...filling Edge Histogram" ;
|
|---|
| 882 | CurrentPixel->hSlopeRisingEdge[order]->Fill( reg->slopeOfRisingEdge ) ;
|
|---|
| 883 | }
|
|---|
| 884 | }
|
|---|
| 885 | }
|
|---|
| 886 | cout << endl << "middle" << endl;
|
|---|
| 887 | //Fill overlay und profile histograms
|
|---|
| 888 | if (use_this_peak){
|
|---|
| 889 | // if (verbosityLevel > 2)
|
|---|
| 890 | cout << "...filling" ;
|
|---|
| 891 | for ( int pos = Left; pos < Right; pos++){
|
|---|
| 892 | // if ();
|
|---|
| 893 | CurrentPixel->hMaxOverlay[order_of_pulse]->Fill( pos - (reg->maxPos), Ameas[pos]) ;
|
|---|
| 894 | CurrentPixel->hMaxProfile[order_of_pulse]->Fill( pos - (reg->maxPos), Ameas[pos]) ;
|
|---|
| 895 | }
|
|---|
| 896 | for ( int pos = EdgeLeft; pos < EdgeRight; pos++){
|
|---|
| 897 | // cout << endl << "###filling edge histo###" << endl;
|
|---|
| 898 | CurrentPixel->hEdgeOverlay[order_of_pulse]->Fill( pos - (reg->halfRisingEdgePos), Ameas[pos]) ;
|
|---|
| 899 | CurrentPixel->hEdgeProfile[order_of_pulse]->Fill( pos - (reg->halfRisingEdgePos), Ameas[pos]) ;
|
|---|
| 900 | // cout << endl << "######" << endl;
|
|---|
| 901 | }
|
|---|
| 902 | if (verbosityLevel > 2) cout << "...done" << endl;
|
|---|
| 903 | }
|
|---|
| 904 | //Breakout option
|
|---|
| 905 | if (breakout)
|
|---|
| 906 | break;
|
|---|
| 907 | }
|
|---|
| 908 | if (verbosityLevel > 2) cout << "...done" << endl;
|
|---|
| 909 | cout << endl << "end" << endl;
|
|---|
| 910 | }
|
|---|
| 911 | // end of FillHistograms
|
|---|
| 912 | //----------------------------------------------------------------------------
|
|---|
| 913 |
|
|---|
| 914 | void
|
|---|
| 915 | DrawTestHistograms(
|
|---|
| 916 | int verbosityLevel
|
|---|
| 917 | )
|
|---|
| 918 | {
|
|---|
| 919 | if (verbosityLevel > 2) cout << endl << "...drawing pulse histograms TODO CANVAS" ;
|
|---|
| 920 |
|
|---|
| 921 | // cgpTestHistos->cd(1);
|
|---|
| 922 | // hTesthisto->Draw();
|
|---|
| 923 | // cgpTestHistos->cd(2);
|
|---|
| 924 | // hTesthisto2->Draw("BOX");
|
|---|
| 925 | }
|
|---|
| 926 | // end of DrawTestHistograms
|
|---|
| 927 | //----------------------------------------------------------------------------
|
|---|
| 928 |
|
|---|
| 929 | void
|
|---|
| 930 | UpdateCanvases(
|
|---|
| 931 | int verbosityLevel,
|
|---|
| 932 | int max_pulse_order
|
|---|
| 933 | )
|
|---|
| 934 | {
|
|---|
| 935 | if (verbosityLevel > 3) cout << endl << "...updating canvases" ;
|
|---|
| 936 | for (int pulse_order = 0; pulse_order < max_pulse_order; pulse_order++)
|
|---|
| 937 | {
|
|---|
| 938 | cgpPixelPulses[pulse_order]->Modified();
|
|---|
| 939 | cgpPixelPulses[pulse_order]->Update();
|
|---|
| 940 | cgpTestHistos->Modified();
|
|---|
| 941 | cgpTestHistos->Update();
|
|---|
| 942 | }
|
|---|
| 943 | }
|
|---|
| 944 | // end of UpdateCanvases
|
|---|
| 945 | //----------------------------------------------------------------------------
|
|---|
| 946 |
|
|---|
| 947 | void
|
|---|
| 948 | DeletePixelCanvases(
|
|---|
| 949 | int maxPulseOrder,
|
|---|
| 950 | int verbosityLevel
|
|---|
| 951 | )
|
|---|
| 952 | {
|
|---|
| 953 | if (verbosityLevel > 2) cout << endl << "...delete pixel Canvases" ;
|
|---|
| 954 | for (int pulse_order = 0; pulse_order < maxPulseOrder; pulse_order++ )
|
|---|
| 955 | {
|
|---|
| 956 | delete cgpPixelPulses[pulse_order];
|
|---|
| 957 | delete cgpDistributions[pulse_order];
|
|---|
| 958 | }
|
|---|
| 959 | delete[] cgpPixelPulses;
|
|---|
| 960 | delete[] cgpDistributions;
|
|---|
| 961 | }
|
|---|
| 962 |
|
|---|
| 963 | //----------------------------------------------------------------------------
|
|---|
| 964 | //----------------------------------------------------------------------------
|
|---|
| 965 |
|
|---|
| 966 | void
|
|---|
| 967 | ProduceDebugHistos(
|
|---|
| 968 | vector<Region>* pZXings
|
|---|
| 969 | )
|
|---|
| 970 | {
|
|---|
| 971 | // TODO do this correct. The vectors should be the rigt ones... this is just luck
|
|---|
| 972 | debugHistos[Ameas_].GetXaxis()->Set(Ameas.size() , -0.5 , Ameas.size()-0.5);
|
|---|
| 973 | debugHistos[Vcorr_].GetXaxis()->Set(Ameas.size() , -0.5 , Ameas.size()-0.5);
|
|---|
| 974 | debugHistos[Vslide_].GetXaxis()->Set(Ameas.size() , -0.5 , Ameas.size()-0.5);
|
|---|
| 975 | debugHistos[Vcfd_].GetXaxis()->Set(Ameas.size() , -0.5 , Ameas.size()-0.5);
|
|---|
| 976 | debugHistos[Vcfd2_].GetXaxis()->Set(Ameas.size() , -0.5 , Ameas.size()-0.5);
|
|---|
| 977 |
|
|---|
| 978 | for ( unsigned int sl = 0; sl < gRegionOfInterest; sl++)
|
|---|
| 979 | {
|
|---|
| 980 | debugHistos[Ameas_].SetBinContent(sl, Ameas[sl]);
|
|---|
| 981 | debugHistos[Vcorr_].SetBinContent(sl, Vcorr[sl]);
|
|---|
| 982 | debugHistos[Vslide_].SetBinContent( sl, Vslide[sl] );
|
|---|
| 983 | debugHistos[Vcfd_].SetBinContent( sl, Vcfd[sl] );
|
|---|
| 984 | debugHistos[Vcfd2_].SetBinContent( sl, Vcfd2[sl] );
|
|---|
| 985 | }
|
|---|
| 986 |
|
|---|
| 987 |
|
|---|
| 988 | cFiltered->cd(1);
|
|---|
| 989 | gPad->SetGrid();
|
|---|
| 990 | debugHistos[Ameas_].Draw();
|
|---|
| 991 |
|
|---|
| 992 | cFiltered->cd(2);
|
|---|
| 993 | gPad->SetGrid();
|
|---|
| 994 | debugHistos[Vcorr_].Draw();
|
|---|
| 995 |
|
|---|
| 996 | cFiltered->cd(3);
|
|---|
| 997 | gPad->SetGrid();
|
|---|
| 998 | debugHistos[Vslide_].Draw();
|
|---|
| 999 |
|
|---|
| 1000 | TBox *OneBox;
|
|---|
| 1001 | vector<TBox*> MyBoxes;
|
|---|
| 1002 | for (unsigned int i=0; i<pZXings->size(); i++){
|
|---|
| 1003 | OneBox = new TBox(
|
|---|
| 1004 | pZXings->at(i).maxPos -10 ,
|
|---|
| 1005 | pZXings->at(i).maxVal -0.5,
|
|---|
| 1006 | pZXings->at(i).maxPos +10 ,
|
|---|
| 1007 | pZXings->at(i).maxVal +0.5);
|
|---|
| 1008 | OneBox->SetLineColor(kBlue);
|
|---|
| 1009 | OneBox->SetLineWidth(1);
|
|---|
| 1010 | OneBox->SetFillStyle(0);
|
|---|
| 1011 | OneBox->SetFillColor(kRed);
|
|---|
| 1012 | MyBoxes.push_back(OneBox);
|
|---|
| 1013 | OneBox->Draw();
|
|---|
| 1014 | }
|
|---|
| 1015 |
|
|---|
| 1016 | // cFiltered->cd(3);
|
|---|
| 1017 | // gPad->SetGrid();
|
|---|
| 1018 | // debugHistos[Vcfd2_].Draw();
|
|---|
| 1019 | // TLine *zeroline = new TLine(0, 0, 1024, 0);
|
|---|
| 1020 | // zeroline->SetLineColor(kBlue);
|
|---|
| 1021 | // zeroline->Draw();
|
|---|
| 1022 |
|
|---|
| 1023 | cFiltered->Update();
|
|---|
| 1024 |
|
|---|
| 1025 |
|
|---|
| 1026 | //Process gui events asynchronously during input
|
|---|
| 1027 | TTimer timer("gSystem->ProcessEvents();", 50, kFALSE);
|
|---|
| 1028 | timer.TurnOn();
|
|---|
| 1029 | TString input = Getline("Type 'q' to exit, <return> to go on: ");
|
|---|
| 1030 | timer.TurnOff();
|
|---|
| 1031 | if (input=="q\n") {
|
|---|
| 1032 | breakout=true;
|
|---|
| 1033 | }
|
|---|
| 1034 |
|
|---|
| 1035 | //TODO!!!!!!!!!
|
|---|
| 1036 | // do some Garbage collection ...
|
|---|
| 1037 | // all the Objects on the heap should be deleted here.
|
|---|
| 1038 |
|
|---|
| 1039 | }// end of if(spikeDebug)
|
|---|
| 1040 |
|
|---|
| 1041 |
|
|---|
| 1042 | int main()
|
|---|
| 1043 | {
|
|---|
| 1044 |
|
|---|
| 1045 | FPulseOverlay();
|
|---|
| 1046 | return 0;
|
|---|
| 1047 |
|
|---|
| 1048 | }
|
|---|