1 | /********************** FPulseOverlay ***********************
|
---|
2 | * read FACT raw data
|
---|
3 | * remove spikes
|
---|
4 | * calculate baseline
|
---|
5 | * find peaks (CFD and normal discriminator)
|
---|
6 | + seagRCh 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 | #include <TF1.h>
|
---|
31 | #include<TSystem.h>
|
---|
32 |
|
---|
33 | #include <stdio.h>
|
---|
34 | #include <stdint.h>
|
---|
35 | #include <cstdio>
|
---|
36 | #include <iostream>
|
---|
37 | #include <fstream>
|
---|
38 | using namespace std;
|
---|
39 |
|
---|
40 | #define NPIX 1440
|
---|
41 | #define FAD_MAX_SAMPLES 1024
|
---|
42 | #define HAVE_ZLIB
|
---|
43 |
|
---|
44 | //----------------------------------------------------------------------------
|
---|
45 | // rootmacros
|
---|
46 | //----------------------------------------------------------------------------
|
---|
47 |
|
---|
48 | //#include "../fits.h"
|
---|
49 |
|
---|
50 | #include "../openFits.h"
|
---|
51 | //#include "../openFits.c"
|
---|
52 |
|
---|
53 | #include "../discriminator.h"
|
---|
54 | //#include "../discriminator.C"
|
---|
55 | #include "../zerosearch.h"
|
---|
56 | //#include "../zerosearch.h"
|
---|
57 | # include "../factfir.h"
|
---|
58 | //#include "../factfir.C"
|
---|
59 |
|
---|
60 | //#include "../DrsCalibration.C"
|
---|
61 | #include "../DrsCalibration.h"
|
---|
62 |
|
---|
63 | #include "../SpikeRemoval.h"
|
---|
64 | //#include "../SpikeRemoval.C"
|
---|
65 |
|
---|
66 | #include "rootfilehandler.h"
|
---|
67 | //#include "rootfilehandler.C"
|
---|
68 |
|
---|
69 | #include "pixel.h"
|
---|
70 | //#include "pixel.C"
|
---|
71 |
|
---|
72 | #include "configfile.h"
|
---|
73 |
|
---|
74 |
|
---|
75 | //----------------------------------------------------------------------------
|
---|
76 | // Decleration of global variables
|
---|
77 | //----------------------------------------------------------------------------
|
---|
78 |
|
---|
79 | bool gBreakout=false;
|
---|
80 |
|
---|
81 | vector<int16_t> gAllPixelDataVector;
|
---|
82 | vector<int16_t> gStartCellVector;
|
---|
83 | unsigned int gCurrentEventID;
|
---|
84 | size_t gPXLxROI;
|
---|
85 | UInt_t gRegionOfInterest;
|
---|
86 | UInt_t gNumberOfPixels;
|
---|
87 | TString ghistotitle;
|
---|
88 |
|
---|
89 | size_t gTriggerOffsetROI;
|
---|
90 | size_t gRC;
|
---|
91 | size_t gDrs_n;
|
---|
92 | vector<float> gDrsBaseMean;
|
---|
93 | vector<float> gDrsGainMean;
|
---|
94 | vector<float> gDrsTriggeroffsetMean;
|
---|
95 |
|
---|
96 | vector<float> gAmeas(FAD_MAX_SAMPLES); // copy of the data (measured amplitude
|
---|
97 | vector<float> gVcorr(FAD_MAX_SAMPLES); // corrected Values
|
---|
98 | vector<float> gVslide(FAD_MAX_SAMPLES); // sliding average result
|
---|
99 | vector<float> gVcfd(FAD_MAX_SAMPLES); // CDF result
|
---|
100 | vector<float> gVcfd2(FAD_MAX_SAMPLES); // CDF result + 2nd sliding average
|
---|
101 |
|
---|
102 | int gNEvents=0;
|
---|
103 | float gGainMean = 9;
|
---|
104 | float gBSLMean = 0;
|
---|
105 |
|
---|
106 | //typedef struct{
|
---|
107 | // double maxAmpl;
|
---|
108 | // int countOfMax;
|
---|
109 | // } OverlayMaximum;
|
---|
110 |
|
---|
111 | //typedef struct{
|
---|
112 | // TString name;
|
---|
113 | // TString title;
|
---|
114 | // TString xTitle;
|
---|
115 | // TString yTitle;
|
---|
116 | // float yMax;
|
---|
117 | // float yMin;
|
---|
118 | //} histAttrib_t;
|
---|
119 |
|
---|
120 | //histAttrib_t* gHistoAttrib[maxPulseOrder];
|
---|
121 | //histAttrib_t* gProfileAttrib[maxPulseOrder];
|
---|
122 |
|
---|
123 |
|
---|
124 | // histograms
|
---|
125 | const int Number_Of_Debug_Histo_Types = 7;
|
---|
126 |
|
---|
127 | const unsigned int
|
---|
128 | gAmeas_ = 0,
|
---|
129 | N1mean_ = 1,
|
---|
130 | gVcorr_ = 2,
|
---|
131 | Vtest_ = 3,
|
---|
132 | gVslide_ = 4,
|
---|
133 | gVcfd_ = 5,
|
---|
134 | gVcfd2_ = 6;
|
---|
135 |
|
---|
136 | //const char* gHistoTypes[8] = {
|
---|
137 | // "hMaxOverlay",
|
---|
138 | // "hPixelMax",
|
---|
139 | // "hEdgeOverlay",
|
---|
140 | // "hMaxProfile",
|
---|
141 | // "hAllPixelOverlay",
|
---|
142 | // "hAllPixelMax",
|
---|
143 | // "hAllPixelMaxGaus",
|
---|
144 | // "hAllPixelProfile"
|
---|
145 | //};
|
---|
146 |
|
---|
147 | //----------------------------------------------------------------------------
|
---|
148 | // Initialisation of histograms
|
---|
149 | //----------------------------------------------------------------------------
|
---|
150 |
|
---|
151 | // Temporary Objects
|
---|
152 | TH1F* debugHistos = NULL;
|
---|
153 | //TH2F* hOverlayTemp = NULL;
|
---|
154 | //TH1D* hProjPeak = NULL;
|
---|
155 | TH1F* hTesthisto = NULL;
|
---|
156 | TH2F* hTesthisto2 = NULL;
|
---|
157 |
|
---|
158 | //Histogram Parameters
|
---|
159 | Int_t gPixelOverlayXaxisLeft = 0;
|
---|
160 | Int_t gPixelOverlayXaxisRight = 0;
|
---|
161 |
|
---|
162 | //Root-File Objects
|
---|
163 | // TObjArray* hList[pixelSetSize] = {NULL};
|
---|
164 | TList* hRootList = NULL;
|
---|
165 |
|
---|
166 | TCanvas** cgpPixelPulses = NULL;
|
---|
167 | TCanvas** cgpDistributions = NULL;
|
---|
168 | TCanvas* cFiltered = NULL;
|
---|
169 | TCanvas* cgpTestHistos = NULL;
|
---|
170 |
|
---|
171 | //----------------------------------------------------------------------------
|
---|
172 | // Functions
|
---|
173 | //----------------------------------------------------------------------------
|
---|
174 |
|
---|
175 | void BookDebugHistos(int );
|
---|
176 | void BookTestHistos( int );
|
---|
177 |
|
---|
178 | //void DeletePixelHistos(int );
|
---|
179 | //void SaveHistograms( const char*, const char*, TObjArray*, int );
|
---|
180 |
|
---|
181 | void FillHistograms(Pixel*, vector<Region>*, int, int, int , bool , int verbosityLevel );
|
---|
182 | void DrawTestHistograms( int);
|
---|
183 | bool ProduceDebugHistos( vector<Region> *pZXings);
|
---|
184 | bool UseThisPulse( int, int, int, float, float bslMean, int maxPulseOrder, int verbosityLevel);
|
---|
185 | void UpdateCanvases( int, int, bool);
|
---|
186 | void DeletePixelCanvases( int, int );
|
---|
187 |
|
---|
188 | int HandleFitsFile(
|
---|
189 | fits * datafile,
|
---|
190 | TString datafilename,
|
---|
191 | TString drsfilename,
|
---|
192 | int nevents,
|
---|
193 | int npixel,
|
---|
194 | int verbosityLevel
|
---|
195 | );
|
---|
196 |
|
---|
197 | void ReadSequenzFile(
|
---|
198 | TString fileName,
|
---|
199 | vector<TString> *fitsFiles,
|
---|
200 | vector<TString> *drsFiles
|
---|
201 | );
|
---|
202 |
|
---|
203 | TString gDataDirectory;
|
---|
204 | TString gHomeDirectory;
|
---|
205 | TString ghostname;
|
---|
206 |
|
---|
207 | //----------------------------------------------------------------------------
|
---|
208 | //----------------------------------------------------------------------------
|
---|
209 | // MAIN - Funtion
|
---|
210 | //----------------------------------------------------------------------------
|
---|
211 | //----------------------------------------------------------------------------
|
---|
212 | int FPulseOverlay_filelist(
|
---|
213 | TString inputPath = "raw/2012/08/02/",
|
---|
214 | TString sequenzFileName = "/home_nfs/isdc/jbbuss/analysis/pulseShape/lists/20120802templ_vs_0mV.csv",
|
---|
215 | // int firstRunId = 18,
|
---|
216 | int nRuns = -1,
|
---|
217 | // TString drsfilename = "20120309_012.drs.fits.gz",
|
---|
218 | TString OutputPath = "analysis/pulseShape/",
|
---|
219 | TString OutRootFileName = "20120802_0mV_newSelectAlg.root",
|
---|
220 | int firstevent = 1, // Hast to be between 1 and infinity NOT 0!!!!
|
---|
221 | int nevents = -1,
|
---|
222 | int firstpixel = 0,
|
---|
223 | int npixel = 1,
|
---|
224 | int pixelSetSize = 150,
|
---|
225 | int maxPulseOrder = 6,
|
---|
226 | int verbosityLevel = 0, // different verbosity levels can be implemented here
|
---|
227 | TString histoOptions = "SRM",
|
---|
228 | int AmplWindowWidth = 7, //Width of Window for selection of pulses to histograms
|
---|
229 | float GainMean = 11,
|
---|
230 | float BSLMean = -2, //4 Histogramms will be drawn, decide how far pulsehights differ from eachother
|
---|
231 | int avg1 = 8,
|
---|
232 | int avg2 = 8,
|
---|
233 | int OverlayWindowLeft = 1024,
|
---|
234 | int OverlayWindowRight = 1024,
|
---|
235 | bool select_pulses = false,
|
---|
236 | bool ProduceGraphic = false,
|
---|
237 | bool spikeDebug = false,
|
---|
238 | bool debugPixel = false,
|
---|
239 | bool stats = true,
|
---|
240 | bool saveResults = true,
|
---|
241 | bool testmode = false,
|
---|
242 | int refresh_rate = 500 //refresh rate for canvases
|
---|
243 | )
|
---|
244 | {
|
---|
245 | //-----------------------------------------------------------------------------
|
---|
246 | // configuration
|
---|
247 | //-----------------------------------------------------------------------------
|
---|
248 |
|
---|
249 | float minPulseAmplitude = 0.3*(GainMean-BSLMean);
|
---|
250 | float maxPulseAmplitude = 2*(GainMean-BSLMean)*maxPulseOrder;
|
---|
251 | int timeLineEdgeWidth = 2;
|
---|
252 | int FallingEdgeWidth = 200;
|
---|
253 | int beginRisingEdge = 5;
|
---|
254 | int endRisingEdge = 10;
|
---|
255 | float risingEdgeMinSlope = 0.5;
|
---|
256 |
|
---|
257 | //-----------------------------------------------------------------------------
|
---|
258 | // prepare datafiles
|
---|
259 | //-----------------------------------------------------------------------------
|
---|
260 |
|
---|
261 | inputPath = SetHostsPaths(false, inputPath );
|
---|
262 |
|
---|
263 | TString fitsFileSuffix = ".fits.gz";
|
---|
264 | TString drsFileSuffix = ".drs.fits.gz";
|
---|
265 |
|
---|
266 | // declare the data file
|
---|
267 | fits * datafile = NULL;
|
---|
268 |
|
---|
269 | // Opens the raw data file and 'binds' the variables given as
|
---|
270 | // Parameters to the data file. So they are filled with
|
---|
271 | // raw data as soon as datafile->GetRow(int) is called.
|
---|
272 |
|
---|
273 | //vector of fits files to read
|
---|
274 | vector<TString> fitsFileNames;
|
---|
275 | vector<TString> drsFileNames;
|
---|
276 |
|
---|
277 | cout << "...reading sequnezfile" << endl;
|
---|
278 | ReadSequenzFile(
|
---|
279 | sequenzFileName,
|
---|
280 | &fitsFileNames,
|
---|
281 | &drsFileNames
|
---|
282 | );
|
---|
283 |
|
---|
284 | cout << "filelist\n" ;
|
---|
285 |
|
---|
286 | //fill vector of fits files to read
|
---|
287 | cout << "generating file list:" << endl;
|
---|
288 | if(nRuns < fitsFileNames.size() && nRuns != -1)
|
---|
289 | {
|
---|
290 | fitsFileNames.resize( nRuns);
|
---|
291 | drsFileNames.resize( nRuns);
|
---|
292 | }
|
---|
293 |
|
---|
294 | for (unsigned int fileNr = 0; fileNr < fitsFileNames.size(); fileNr++)
|
---|
295 | {
|
---|
296 | if ( fileNr >= drsFileNames.size() )
|
---|
297 | {
|
---|
298 | cout << "too less drs-files in vector, skipping rest" << endl;
|
---|
299 | break;
|
---|
300 |
|
---|
301 | drsFileNames.resize(fileNr);
|
---|
302 | fitsFileNames.resize(fileNr);
|
---|
303 | }
|
---|
304 |
|
---|
305 | cout << "...checking raw files";
|
---|
306 | // cout << "\t fits:\t" << fitsFileNames.at(fileNr);
|
---|
307 | // cout << "\n\t\t drs:\t" << drsFileNames.at(fileNr) << endl;
|
---|
308 |
|
---|
309 | //filename/path construction
|
---|
310 | TString fits_filename = inputPath;
|
---|
311 | fits_filename.Append(fitsFileNames.at(fileNr));
|
---|
312 | fits_filename.Append(fitsFileSuffix);
|
---|
313 | TString drs_filename = inputPath;
|
---|
314 | drs_filename.Append(drsFileNames.at(fileNr));
|
---|
315 | drs_filename.Append(drsFileSuffix);
|
---|
316 | cout << "\n\t fits:\t" << fits_filename;
|
---|
317 | cout << "\n\t drs:\t" << drs_filename << endl;
|
---|
318 |
|
---|
319 | //check if files are readable
|
---|
320 | ifstream fitsFile(fits_filename);
|
---|
321 | ifstream drsFile(drs_filename);
|
---|
322 | if (fitsFile.good() && drsFile.good())
|
---|
323 | {
|
---|
324 | //fill vector
|
---|
325 | cout << "...added\n" << endl;
|
---|
326 | fitsFileNames.at(fileNr) = fits_filename;
|
---|
327 | drsFileNames.at(fileNr) = drs_filename;
|
---|
328 | }
|
---|
329 | else {
|
---|
330 | cout << "...FAILED:";
|
---|
331 | cout << "\t deleting line"
|
---|
332 | // << fitsFileNames.at(fileNr)
|
---|
333 | // << " and "
|
---|
334 | // << drsFileNames.at(fileNr)
|
---|
335 | << " from list\n" << endl;
|
---|
336 |
|
---|
337 | fitsFileNames.erase(fitsFileNames.begin()+fileNr);
|
---|
338 | drsFileNames.erase(drsFileNames.begin()+fileNr);
|
---|
339 | fileNr--;
|
---|
340 | // continue;
|
---|
341 | }
|
---|
342 | }
|
---|
343 | cout << endl << "size of file vectors: fits: "
|
---|
344 | << fitsFileNames.size()
|
---|
345 | << " drs: "
|
---|
346 | << drsFileNames.size() << endl;
|
---|
347 |
|
---|
348 | if (fitsFileNames.size() < 1) return 1;
|
---|
349 |
|
---|
350 | //----------------------------------------------------------------------------
|
---|
351 | // Save-Root-File Settings
|
---|
352 | //----------------------------------------------------------------------------
|
---|
353 |
|
---|
354 | OutputPath = SetHostsPaths(true, OutputPath );
|
---|
355 | OutRootFileName.Prepend(OutputPath);
|
---|
356 | // drsfilename = SetHostsPaths(false, drsfilename );
|
---|
357 | // OutRootFileName = SetHostsPaths(true, OutRootFileName );
|
---|
358 | cout << endl;
|
---|
359 | // cout << "drs filename:\t" << drsfilename << endl;
|
---|
360 | // cout << "data filename:\t" << datafilename << endl;
|
---|
361 | cout << "out filename:\t" << OutRootFileName << endl;
|
---|
362 |
|
---|
363 |
|
---|
364 | if (saveResults)
|
---|
365 | {
|
---|
366 | CreateRootFile( OutRootFileName, true, verbosityLevel );
|
---|
367 | }
|
---|
368 |
|
---|
369 |
|
---|
370 |
|
---|
371 |
|
---|
372 |
|
---|
373 | //----------------------------------------------------------------------------
|
---|
374 | // root global Settings
|
---|
375 | //----------------------------------------------------------------------------
|
---|
376 |
|
---|
377 | gGainMean = GainMean;
|
---|
378 | gBSLMean = BSLMean;
|
---|
379 | gPixelOverlayXaxisLeft = OverlayWindowLeft;
|
---|
380 | gPixelOverlayXaxisRight = OverlayWindowRight;
|
---|
381 |
|
---|
382 | gStyle->SetPalette(1,0);
|
---|
383 | gROOT->SetStyle("Plain");
|
---|
384 | // gPad->SetGrid();
|
---|
385 |
|
---|
386 | //----------------------------------------------------------------------------
|
---|
387 | // root Canvas Settings
|
---|
388 | //----------------------------------------------------------------------------
|
---|
389 | //Canvas Pad numbering
|
---|
390 | int pulsesCanvasFrameNrs[4] = {
|
---|
391 | 1, // Top left
|
---|
392 | 2, // Top right
|
---|
393 | 3, // bottom left
|
---|
394 | 4 // bootom right
|
---|
395 | };
|
---|
396 |
|
---|
397 | //Canvas Pad numbering
|
---|
398 | int distributionCanvasFrameNrs[4] = {
|
---|
399 | 1, // Top left
|
---|
400 | 2, // Top right
|
---|
401 | 3, // bottom left
|
---|
402 | 4 // bootom right
|
---|
403 | };
|
---|
404 |
|
---|
405 | if (ProduceGraphic)
|
---|
406 | {
|
---|
407 |
|
---|
408 | //Canvases
|
---|
409 | cgpPixelPulses = new TCanvas*[maxPulseOrder];
|
---|
410 | cgpDistributions = new TCanvas*[maxPulseOrder];
|
---|
411 |
|
---|
412 | //TCanvas* gpcDevelopment = NULL;
|
---|
413 | TString cName = "";
|
---|
414 | TString cTitle = "";
|
---|
415 |
|
---|
416 | //naming of pulse canvases
|
---|
417 | for (
|
---|
418 | int pulse_order = maxPulseOrder - 1;
|
---|
419 | pulse_order >= 0 ;
|
---|
420 | pulse_order--
|
---|
421 | )
|
---|
422 | {
|
---|
423 | cName ="cgpDistributions";
|
---|
424 | cName += pulse_order;
|
---|
425 | cTitle ="Distributions of Pulses with Order of: ";
|
---|
426 | cTitle += pulse_order;
|
---|
427 | cgpDistributions[pulse_order] = new TCanvas(cName,cTitle, 720,pulse_order*20,720,720);
|
---|
428 | cgpDistributions[pulse_order]->Divide(2, 2);
|
---|
429 | cName ="cgpPixelPulses";
|
---|
430 | cName += pulse_order;
|
---|
431 | cTitle ="Overlays of Pulses with Order of: ";
|
---|
432 | cTitle += pulse_order;
|
---|
433 | cgpPixelPulses[pulse_order] = new TCanvas(cName,cTitle, 0,pulse_order*20,720,720);
|
---|
434 | cgpPixelPulses[pulse_order]->Divide(2, 2);
|
---|
435 | }
|
---|
436 |
|
---|
437 |
|
---|
438 | // Create (pointer to) Canvases, which are used in every run,
|
---|
439 | // also in 'non-debug' runs
|
---|
440 | // Canvases only need if spike Debug, but I want to deklare
|
---|
441 | // the pointers anyway ...
|
---|
442 | if (spikeDebug)
|
---|
443 | {
|
---|
444 | cFiltered = new TCanvas("cFiltered","filtered DRS Waveforms", 1080,420,360,360);
|
---|
445 | cFiltered->Divide(1, 3);
|
---|
446 | }
|
---|
447 |
|
---|
448 | if (testmode)
|
---|
449 | {
|
---|
450 | //additional Test histograms
|
---|
451 | cgpTestHistos = new TCanvas( "cgpTestHistos", "Test Histograms", 360, 420, 360, 360 );
|
---|
452 | cgpTestHistos->Divide(2,0);
|
---|
453 | }
|
---|
454 | }
|
---|
455 |
|
---|
456 | //-----------------------------------------------------------------------------
|
---|
457 | // Filter-Settings
|
---|
458 | //-----------------------------------------------------------------------------
|
---|
459 | // CFD filter settings
|
---|
460 | int k_cfd = 10;
|
---|
461 | vector<double> a_cfd(k_cfd, 0);
|
---|
462 | double b_cfd = 1.;
|
---|
463 | a_cfd[0]=-0.75;
|
---|
464 | a_cfd[k_cfd-1]=1.;
|
---|
465 |
|
---|
466 | //-----------------------------------------------------------------------------
|
---|
467 | // Book the histograms
|
---|
468 | //-----------------------------------------------------------------------------
|
---|
469 |
|
---|
470 |
|
---|
471 |
|
---|
472 | if (testmode)
|
---|
473 | {
|
---|
474 | BookTestHistos( verbosityLevel );
|
---|
475 | }
|
---|
476 | //----------------------------------------------------------------------------
|
---|
477 | // Initialize Pixel
|
---|
478 | //----------------------------------------------------------------------------
|
---|
479 | Pixel** pixel = new Pixel*[NPIX];
|
---|
480 |
|
---|
481 | for (int i = 0 ; i < NPIX; i++)
|
---|
482 | {
|
---|
483 | pixel[i] = NULL;
|
---|
484 | }
|
---|
485 |
|
---|
486 |
|
---|
487 | //-----------------------------------------------------------------------------
|
---|
488 | // Main Cycle
|
---|
489 | //-----------------------------------------------------------------------------
|
---|
490 | cout << "------------------Main cylcle------------------------------" << endl;
|
---|
491 |
|
---|
492 | if(npixel == -1) npixel = 1439;
|
---|
493 |
|
---|
494 | if ( pixelSetSize == -1 )
|
---|
495 | {
|
---|
496 | pixelSetSize = firstpixel +npixel;
|
---|
497 | }
|
---|
498 | int lastPixelOfSet = 0;
|
---|
499 | cout << "check " << npixel << endl;
|
---|
500 | //-------------------------------------
|
---|
501 | // Loop over Pixel Sets
|
---|
502 | //-------------------------------------
|
---|
503 | for ( int firstPixelOfSet = firstpixel;
|
---|
504 | firstPixelOfSet < firstpixel + npixel;
|
---|
505 | firstPixelOfSet += pixelSetSize )
|
---|
506 | {
|
---|
507 | lastPixelOfSet = firstPixelOfSet + pixelSetSize-1;
|
---|
508 | if (lastPixelOfSet > firstpixel + npixel)
|
---|
509 | {
|
---|
510 | lastPixelOfSet = firstpixel + npixel;
|
---|
511 | }
|
---|
512 | if (lastPixelOfSet > 1439)
|
---|
513 | {
|
---|
514 | lastPixelOfSet = 1439;
|
---|
515 | }
|
---|
516 | if (verbosityLevel == 0)
|
---|
517 | {
|
---|
518 | cout << "------------------------------------------------" << endl
|
---|
519 | << "...processing Set from Pixel "
|
---|
520 | << firstPixelOfSet
|
---|
521 | << " to Pixel "
|
---|
522 | << lastPixelOfSet << endl;
|
---|
523 | }
|
---|
524 |
|
---|
525 | //-------------------------------------
|
---|
526 | // Loop over Fits Files
|
---|
527 | //-------------------------------------
|
---|
528 |
|
---|
529 | cout << "loop over files" << endl;
|
---|
530 | for( unsigned int fileId = 0; fileId < fitsFileNames.size(); fileId++ )
|
---|
531 | {
|
---|
532 | datafile = NULL;
|
---|
533 | // int return_val = 0;
|
---|
534 | // return_val = HandleFitsFile(
|
---|
535 | // datafile,
|
---|
536 | // datafiles.at(fileId),
|
---|
537 | // drsfilename,
|
---|
538 | // nevents,
|
---|
539 | // npixel,
|
---|
540 | // verbosityLevel
|
---|
541 | // );
|
---|
542 | // if (return_val)
|
---|
543 | // {
|
---|
544 | // cerr << "ERROR" << endl;
|
---|
545 | // return return_val;
|
---|
546 | // }
|
---|
547 | //==================================================
|
---|
548 |
|
---|
549 | // Opens the raw data file and 'binds' the variables given as
|
---|
550 | // Parameters to the data file. So they are filled with
|
---|
551 | // raw data as soon as datafile->GetRow(int) is called.
|
---|
552 | cout << "\nopening " << fitsFileNames.at(fileId) << endl;
|
---|
553 |
|
---|
554 | gNEvents = openDataFits(
|
---|
555 | fitsFileNames.at(fileId),
|
---|
556 | &datafile,
|
---|
557 | gAllPixelDataVector,
|
---|
558 | gStartCellVector,
|
---|
559 | gCurrentEventID,
|
---|
560 | gRegionOfInterest,
|
---|
561 | gNumberOfPixels,
|
---|
562 | gPXLxROI,
|
---|
563 | verbosityLevel
|
---|
564 | );
|
---|
565 |
|
---|
566 | if (gNEvents == 0)
|
---|
567 | {
|
---|
568 | cout << "return code of OpenDataFile:" << fitsFileNames.at(fileId)<< endl;
|
---|
569 | cout << "is zero -> aborting." << endl;
|
---|
570 | return 1;
|
---|
571 | }
|
---|
572 |
|
---|
573 | if (verbosityLevel > 0)
|
---|
574 | {
|
---|
575 | cout << endl <<"number of events in file: "<< gNEvents << "\t";
|
---|
576 | }
|
---|
577 |
|
---|
578 | if ( nevents == -1 || nevents > gNEvents ) nevents = gNEvents; // -1 means all!
|
---|
579 |
|
---|
580 | if (verbosityLevel > 0)
|
---|
581 | {
|
---|
582 | cout <<"of, which "<< nevents << " will be processed"<< endl;
|
---|
583 | cout <<"Total # of Pixel: "<< gNumberOfPixels << "\t";
|
---|
584 | }
|
---|
585 |
|
---|
586 | if ( npixel == -1 || npixel > (int)gNumberOfPixels ) npixel = (int)gNumberOfPixels; // -1 means all!
|
---|
587 |
|
---|
588 | if (verbosityLevel > 0)
|
---|
589 | {
|
---|
590 | cout <<"of, which "<< npixel << " will be processed"<< endl;
|
---|
591 | }
|
---|
592 |
|
---|
593 | //Get the DRS calibration
|
---|
594 | gRC = openCalibFits(
|
---|
595 | drsFileNames.at(fileId),
|
---|
596 | gDrsBaseMean,
|
---|
597 | gDrsGainMean,
|
---|
598 | gDrsTriggeroffsetMean,
|
---|
599 | gTriggerOffsetROI
|
---|
600 | );
|
---|
601 |
|
---|
602 | if (gRC == 0)
|
---|
603 | {
|
---|
604 | cout << "return code of openCalibFits:" << drsFileNames.at(fileId) << endl;
|
---|
605 | cout << "is zero -> aborting." << endl;
|
---|
606 | return 1;
|
---|
607 | }
|
---|
608 |
|
---|
609 | //==================================================================
|
---|
610 |
|
---|
611 | //--------------------------------------------------------------------
|
---|
612 | // Loop over every Event of Pixel Set
|
---|
613 | //--------------------------------------------------------------------
|
---|
614 | for ( int ev = firstevent ; ev < firstevent + nevents; ev++)
|
---|
615 | {
|
---|
616 | // Get an Event --> consists of 1440 Pixel ...erm....data
|
---|
617 | datafile->GetRow( ev - 1 );
|
---|
618 |
|
---|
619 | if (verbosityLevel == 1)
|
---|
620 | {
|
---|
621 | cout << "-------------------------------------" << endl
|
---|
622 | << "...processing Set from Pixel "
|
---|
623 | << firstPixelOfSet
|
---|
624 | << " to Pixel "
|
---|
625 | << lastPixelOfSet
|
---|
626 | << "... Event: " << gCurrentEventID
|
---|
627 | << "/" << nevents << endl;
|
---|
628 | }
|
---|
629 |
|
---|
630 | //--------------------------------------------------------------------
|
---|
631 | // Loops over every Pixel of a Set of Pixels
|
---|
632 | //--------------------------------------------------------------------
|
---|
633 | for ( int pixelID = firstPixelOfSet;
|
---|
634 | pixelID < lastPixelOfSet + 1
|
---|
635 | && pixelID < firstpixel + npixel;
|
---|
636 | pixelID++ )
|
---|
637 | {
|
---|
638 | if (verbosityLevel > 1)
|
---|
639 | {
|
---|
640 | cout << "-------------------------------------" << endl
|
---|
641 | << "...processing Set from Pixel "
|
---|
642 | << firstPixelOfSet
|
---|
643 | << " to Pixel "
|
---|
644 | << lastPixelOfSet
|
---|
645 | << "... Event: " << gCurrentEventID
|
---|
646 | << "/" << nevents << endl
|
---|
647 | << " Pixel: " << pixelID
|
---|
648 | << "/" << firstpixel + npixel -1 << endl;
|
---|
649 | }
|
---|
650 |
|
---|
651 | //-------------------------------------
|
---|
652 | // Create individual Pixel
|
---|
653 | //-------------------------------------
|
---|
654 | if (ev == firstevent && fileId == 0)
|
---|
655 | {
|
---|
656 | pixel[pixelID] = new Pixel(
|
---|
657 | pixelID,
|
---|
658 | maxPulseOrder,
|
---|
659 | verbosityLevel,
|
---|
660 | stats,
|
---|
661 | histoOptions,
|
---|
662 | gPixelOverlayXaxisLeft,
|
---|
663 | gPixelOverlayXaxisRight,
|
---|
664 | gBSLMean,
|
---|
665 | gGainMean
|
---|
666 | );
|
---|
667 | }
|
---|
668 |
|
---|
669 | //-------------------------------------
|
---|
670 | // Apply Calibration
|
---|
671 | //-------------------------------------
|
---|
672 | if (verbosityLevel > 2) cout << "...applying DrsCalibration";
|
---|
673 | applyDrsCalibration(
|
---|
674 | gAmeas,
|
---|
675 | pixelID,
|
---|
676 | 12,
|
---|
677 | 12,
|
---|
678 | gDrsBaseMean,
|
---|
679 | gDrsGainMean,
|
---|
680 | gDrsTriggeroffsetMean,
|
---|
681 | gRegionOfInterest,
|
---|
682 | gAllPixelDataVector,
|
---|
683 | gStartCellVector
|
---|
684 | );
|
---|
685 | if (verbosityLevel > 2) cout << "...done " << endl;
|
---|
686 |
|
---|
687 | //-------------------------------------
|
---|
688 | // Apply Filters
|
---|
689 | //-------------------------------------
|
---|
690 | // finds spikes in the raw data, and interpolates the value
|
---|
691 | // spikes are: 1 or 2 slice wide, positive non physical artifacts
|
---|
692 | if (verbosityLevel > 2) cout << "...removeing Spikes";
|
---|
693 | removeSpikes (gAmeas, gVcorr);
|
---|
694 | if (verbosityLevel > 2) cout << "...done " << endl;
|
---|
695 |
|
---|
696 | // filter gVcorr with sliding average using FIR filter function
|
---|
697 | if (verbosityLevel > 2) cout << "...applying sliding average filter";
|
---|
698 | sliding_avg(gVcorr, gVslide, avg1);
|
---|
699 | if (verbosityLevel > 2) cout << "...done " << endl;
|
---|
700 |
|
---|
701 | // filter gVslide with CFD using FIR filter function
|
---|
702 | if (verbosityLevel > 2) cout << "...apllying factfir filter";
|
---|
703 | factfir(b_cfd , a_cfd, k_cfd, gVslide, gVcfd);
|
---|
704 | if (verbosityLevel > 2) cout << "...done " << endl;
|
---|
705 |
|
---|
706 | // filter gVcfd with sliding average using FIR filter function
|
---|
707 | if (verbosityLevel > 2) cout << "...applying 2nd sliding average filter";
|
---|
708 | sliding_avg(gVcfd, gVcfd2, avg2);
|
---|
709 | if (verbosityLevel > 2) cout << "...done " << endl;
|
---|
710 |
|
---|
711 | //-------------------------------------
|
---|
712 | // Search vor Zero crossings
|
---|
713 | //-------------------------------------
|
---|
714 | if (verbosityLevel > 2) cout << endl << "...seagRChing zero crossings" ;
|
---|
715 | // peaks in gAmeas[] are found by seagRChing for zero crossings
|
---|
716 | // in gVcfd2
|
---|
717 | // first Argument 1 means ... *rising* edge
|
---|
718 | // second Argument 1 means ... seagRCh with stepsize 1 ... 10 is okay as well
|
---|
719 | vector<Region>* pZXings = zerosearch( gVcfd2 , 1 , 8);
|
---|
720 | // pZXings means "zero cross ings"
|
---|
721 | EnlargeRegion(*pZXings, 10, 10);
|
---|
722 | findAbsMaxInRegions(*pZXings, gVslide);
|
---|
723 | removeMaximaBelow( *pZXings, minPulseAmplitude);
|
---|
724 | removeMaximaAbove( *pZXings, maxPulseAmplitude);
|
---|
725 | removeRegionWithMaxOnEdge( *pZXings, timeLineEdgeWidth);
|
---|
726 | removeRegionOnFallingEdge( *pZXings, FallingEdgeWidth);
|
---|
727 | // Calculate the position (sample) of a pulses half maximum
|
---|
728 | findTimeOfHalfMaxLeft(*pZXings, gVslide, gBSLMean, beginRisingEdge, endRisingEdge, verbosityLevel );
|
---|
729 | //sometimes pulses where found with a very flat slope, DISMISS them
|
---|
730 | removeRegionWithToFlatSlope(*pZXings, risingEdgeMinSlope);
|
---|
731 | if (verbosityLevel > 2) cout << "...done" << endl;
|
---|
732 |
|
---|
733 | //-----------------------------------------------------------------------------
|
---|
734 | // Fill Overlay Histos
|
---|
735 | //-----------------------------------------------------------------------------
|
---|
736 | if (verbosityLevel > 2)
|
---|
737 | {
|
---|
738 | cout << endl << "Filling Histograms of Pixel# [Set] " << pixelID
|
---|
739 | << " Pixel# [Got] " << pixel[pixelID]->mChid;
|
---|
740 | }
|
---|
741 | FillHistograms(
|
---|
742 | pixel[pixelID],
|
---|
743 | pZXings,
|
---|
744 | AmplWindowWidth,
|
---|
745 | ev,
|
---|
746 | // histoOptions,
|
---|
747 | maxPulseOrder,
|
---|
748 | select_pulses,
|
---|
749 | verbosityLevel
|
---|
750 | );
|
---|
751 | //-----------------------------------------------------------------------------
|
---|
752 | // Spike Debug
|
---|
753 | //-----------------------------------------------------------------------------
|
---|
754 | if ( spikeDebug )
|
---|
755 | {
|
---|
756 | BookDebugHistos(verbosityLevel );
|
---|
757 | gBreakout = ProduceDebugHistos( pZXings );
|
---|
758 | }// end of if(spikeDebug)
|
---|
759 |
|
---|
760 | delete pZXings;
|
---|
761 | if (gBreakout) break;
|
---|
762 | //-------------------------------------
|
---|
763 | // Draw 1. Set of Pixel Histograms
|
---|
764 | //-------------------------------------
|
---|
765 | if ((ev % refresh_rate) == 0)
|
---|
766 | {
|
---|
767 | if (ProduceGraphic)
|
---|
768 | {
|
---|
769 | if (debugPixel)
|
---|
770 | {
|
---|
771 | // for ( int order = 0;
|
---|
772 | // order < maxPulseOrder;
|
---|
773 | // order++
|
---|
774 | // )
|
---|
775 | // {
|
---|
776 | pixel[firstPixelOfSet]->DrawOverlayHistograms(
|
---|
777 | cgpPixelPulses,
|
---|
778 | pulsesCanvasFrameNrs
|
---|
779 | );
|
---|
780 |
|
---|
781 | pixel[firstPixelOfSet]->DrawDistributionHistograms(
|
---|
782 | cgpDistributions,
|
---|
783 | distributionCanvasFrameNrs
|
---|
784 | );
|
---|
785 | // }
|
---|
786 | if (testmode)
|
---|
787 | {
|
---|
788 | DrawTestHistograms(
|
---|
789 | verbosityLevel
|
---|
790 | );
|
---|
791 | }
|
---|
792 |
|
---|
793 | UpdateCanvases(
|
---|
794 | verbosityLevel,
|
---|
795 | maxPulseOrder,
|
---|
796 | testmode
|
---|
797 | );
|
---|
798 | }
|
---|
799 | }
|
---|
800 | }
|
---|
801 |
|
---|
802 | if (gBreakout) break;
|
---|
803 |
|
---|
804 | if (verbosityLevel > 1)
|
---|
805 | {
|
---|
806 | cout << endl << "...End of Pixel"
|
---|
807 | << endl << "-------------------------------------"<< endl;
|
---|
808 | }
|
---|
809 | }//End of Loop over Set
|
---|
810 | //-------------------------------------
|
---|
811 | // end of Loops over Set
|
---|
812 | //-------------------------------------
|
---|
813 |
|
---|
814 | }//End of Loop over Events
|
---|
815 | //-------------------------------------
|
---|
816 | // end of Loops over Events
|
---|
817 | //-------------------------------------
|
---|
818 |
|
---|
819 | }//End of Loop over Files
|
---|
820 | //-------------------------------------
|
---|
821 | // end of Loops over Files
|
---|
822 | //-------------------------------------
|
---|
823 |
|
---|
824 |
|
---|
825 | //-------------------------------------
|
---|
826 | // Draw Pixel Histogramms of Overlay Spectra
|
---|
827 | //-------------------------------------
|
---|
828 |
|
---|
829 | for ( int pixelID = firstPixelOfSet;
|
---|
830 | pixelID < firstPixelOfSet + pixelSetSize
|
---|
831 | && pixelID < firstpixel + npixel;
|
---|
832 | pixelID++ )
|
---|
833 | {
|
---|
834 | //here is what happends at the end of each loop over all Events
|
---|
835 |
|
---|
836 | if (ProduceGraphic)
|
---|
837 | {
|
---|
838 | pixel[pixelID]->DrawOverlayHistograms(
|
---|
839 | cgpPixelPulses,
|
---|
840 | pulsesCanvasFrameNrs
|
---|
841 | );
|
---|
842 |
|
---|
843 | pixel[pixelID]->DrawDistributionHistograms(
|
---|
844 | cgpDistributions,
|
---|
845 | distributionCanvasFrameNrs
|
---|
846 | );
|
---|
847 |
|
---|
848 | UpdateCanvases(
|
---|
849 | verbosityLevel,
|
---|
850 | maxPulseOrder,
|
---|
851 | testmode
|
---|
852 | );
|
---|
853 | }
|
---|
854 |
|
---|
855 | //Save Histograms of Pixels into Output rootfile
|
---|
856 | if (verbosityLevel > 2)
|
---|
857 | {
|
---|
858 | cout << endl << "Saving Pixel# [Set] " << pixelID
|
---|
859 | << " Pixel# [Got] " << pixel[pixelID]->mChid;
|
---|
860 | }
|
---|
861 | pixel[pixelID]->SavePixelHistograms( OutRootFileName, saveResults );
|
---|
862 |
|
---|
863 |
|
---|
864 | if (debugPixel)
|
---|
865 | {
|
---|
866 | //Process gui events asynchronously during input
|
---|
867 | cout << endl;
|
---|
868 | TTimer timer("gSystem->ProcessEvents();", 50, kFALSE);
|
---|
869 | timer.TurnOn();
|
---|
870 | TString input = Getline("Type 'q' to exit, <return> to go on: ");
|
---|
871 | timer.TurnOff();
|
---|
872 | if (input=="q\n") {
|
---|
873 | break;
|
---|
874 | }
|
---|
875 | }
|
---|
876 |
|
---|
877 | if (verbosityLevel > 2)
|
---|
878 | {
|
---|
879 | cout << endl << "Deleting Pixel# [Set] " << pixelID
|
---|
880 | << " Pixel# [Got] " << pixel[pixelID]->mChid;
|
---|
881 | }
|
---|
882 | delete pixel[pixelID];
|
---|
883 |
|
---|
884 | if (verbosityLevel > 2)
|
---|
885 | {
|
---|
886 | cout << endl << "...End of Pixel-Set"
|
---|
887 | << endl << "------------------------------------------------"
|
---|
888 | << endl;
|
---|
889 | }
|
---|
890 | }
|
---|
891 | }
|
---|
892 | // End of Loop over all Pixels
|
---|
893 |
|
---|
894 | //-------------------------------------
|
---|
895 | // Draw Histograms
|
---|
896 | //-------------------------------------
|
---|
897 | TString test = "root";
|
---|
898 | SaveHistograms( //save histograms of generell results into output root file
|
---|
899 | OutRootFileName,
|
---|
900 | test,
|
---|
901 | hRootList,
|
---|
902 | saveResults,
|
---|
903 | verbosityLevel
|
---|
904 | );
|
---|
905 |
|
---|
906 | if (ProduceGraphic)
|
---|
907 | {
|
---|
908 | UpdateCanvases(
|
---|
909 | verbosityLevel,
|
---|
910 | maxPulseOrder,
|
---|
911 | testmode
|
---|
912 | );
|
---|
913 |
|
---|
914 | //Process gui events asynchronously during input
|
---|
915 | cout << endl;
|
---|
916 | TTimer timer("gSystem->ProcessEvents();", 50, kFALSE);
|
---|
917 | timer.TurnOn();
|
---|
918 | Getline("Press <return> to go on");
|
---|
919 | timer.TurnOff();
|
---|
920 |
|
---|
921 | DeletePixelCanvases(
|
---|
922 | maxPulseOrder,
|
---|
923 | verbosityLevel
|
---|
924 | );
|
---|
925 |
|
---|
926 | if (testmode)
|
---|
927 | delete cgpTestHistos;
|
---|
928 |
|
---|
929 | if (spikeDebug)
|
---|
930 | delete cFiltered;
|
---|
931 | }
|
---|
932 |
|
---|
933 | delete datafile;
|
---|
934 | delete[] pixel;
|
---|
935 |
|
---|
936 | return( 0 );
|
---|
937 | }
|
---|
938 | //----------------------------------------------------------------------------
|
---|
939 | // end of main function
|
---|
940 | //-----------------------------------------------------------------------------
|
---|
941 |
|
---|
942 |
|
---|
943 |
|
---|
944 |
|
---|
945 | //-----------------------------------------------------------------------------
|
---|
946 | // Funktions
|
---|
947 | //-----------------------------------------------------------------------------
|
---|
948 |
|
---|
949 | /*
|
---|
950 | ich erzeuge sowas wie 36 pixel mit ca 20 Histogrammen pro pixel
|
---|
951 | wie viel speicher braucht das?
|
---|
952 | Ich brauche eine möglichkeit jedes dieser histogramme zu identifizieren
|
---|
953 | am besten ein array oder eine liste oder einen abstracten datentyp mit den histogrammen als attribute.
|
---|
954 | ne klasse wäre super
|
---|
955 |
|
---|
956 | */
|
---|
957 |
|
---|
958 | void BookTestHistos( int verbosityLevel )
|
---|
959 | {
|
---|
960 | if (verbosityLevel > 2) cout << endl << "...book pixel histograms" << endl;
|
---|
961 |
|
---|
962 | hTesthisto = new TH1F (
|
---|
963 | "hTesthisto",
|
---|
964 | "Deviation of rising edge and maximum",
|
---|
965 | 600,
|
---|
966 | -10.1,
|
---|
967 | 10.1
|
---|
968 | );
|
---|
969 | hTesthisto->GetXaxis()->SetTitle( "Timeslices [a.u.]" );
|
---|
970 | hTesthisto->GetYaxis()->SetTitle( "counts" );
|
---|
971 |
|
---|
972 | hTesthisto2 = new TH2F (
|
---|
973 | "hTesthisto2",
|
---|
974 | "Deviation of rising edge and maximum by event #",
|
---|
975 | gNEvents,
|
---|
976 | 250,
|
---|
977 | 800,
|
---|
978 | 600,
|
---|
979 | -10.1,
|
---|
980 | 10.1
|
---|
981 | );
|
---|
982 | // hTesthisto2->GetXaxis()->SetTitle( "Timeslices [a.u.]" );
|
---|
983 | // hTesthisto2->GetYaxis()->SetTitle( "counts" );
|
---|
984 | // hTesthisto2->SetMarkerStyle( 2 );
|
---|
985 |
|
---|
986 | if (verbosityLevel > 2) cout << "...done" << endl;
|
---|
987 | }
|
---|
988 | //end of BookTestHistos
|
---|
989 | //----------------------------------------------------------------------------
|
---|
990 |
|
---|
991 |
|
---|
992 | void
|
---|
993 | BookDebugHistos( int verbosityLevel )
|
---|
994 | {
|
---|
995 | if (verbosityLevel > 2) cout << endl << "...book histograms" << endl;
|
---|
996 | hRootList = new TList();
|
---|
997 | debugHistos = new TH1F[ Number_Of_Debug_Histo_Types ];
|
---|
998 | for ( int type = 0; type < Number_Of_Debug_Histo_Types; type++){
|
---|
999 | debugHistos[ type ].SetBins(1024, 0, 1024);
|
---|
1000 | debugHistos[ type ].SetLineColor(1);
|
---|
1001 | debugHistos[ type ].SetLineWidth(2);
|
---|
1002 | debugHistos[ type ].SetStats(false);
|
---|
1003 |
|
---|
1004 | // set X axis paras
|
---|
1005 | debugHistos[ type ].GetXaxis()->SetLabelSize(0.08);
|
---|
1006 | debugHistos[ type ].GetXaxis()->SetTitleSize(0.08);
|
---|
1007 | debugHistos[ type ].GetXaxis()->SetTitleOffset(1.0);
|
---|
1008 | debugHistos[ type ].GetXaxis()->SetTitle(Form("Time slice [%.1f ns/slice]", 1./2.));
|
---|
1009 |
|
---|
1010 | // set Y axis paras
|
---|
1011 | debugHistos[ type ].GetYaxis()->SetLabelSize(0.08);
|
---|
1012 | debugHistos[ type ].GetYaxis()->SetTitleSize(0.08);
|
---|
1013 | debugHistos[ type ].GetYaxis()->SetTitleOffset(0.3);
|
---|
1014 | debugHistos[ type ].GetYaxis()->SetTitle("Amplitude [mV]");
|
---|
1015 | // hRootList->Add( &debugHistos[ type ] );
|
---|
1016 | }
|
---|
1017 | if (verbosityLevel > 2) cout << "...done" << endl;
|
---|
1018 | }
|
---|
1019 | // end of BookDebugHistos
|
---|
1020 | //----------------------------------------------------------------------------
|
---|
1021 |
|
---|
1022 |
|
---|
1023 | void
|
---|
1024 | FillHistograms(
|
---|
1025 | Pixel* CurrentPixel,
|
---|
1026 | vector<Region>* pZXings,
|
---|
1027 | int AmplWindowWidth,
|
---|
1028 | int eventNumber,
|
---|
1029 | int maxPulseOrder,
|
---|
1030 | bool select_pulses,
|
---|
1031 | int verbosityLevel
|
---|
1032 | )
|
---|
1033 | {
|
---|
1034 | //entry counters
|
---|
1035 | int maxOverlayEntries = 0;
|
---|
1036 | int edgeOverlayEntries = 0;
|
---|
1037 | int maxProfileEntries = 0;
|
---|
1038 | int edgeProfileEntries = 0;
|
---|
1039 |
|
---|
1040 |
|
---|
1041 |
|
---|
1042 |
|
---|
1043 | if (verbosityLevel > 2) cout << endl << "...filling pulse histograms" ;
|
---|
1044 | if (verbosityLevel > 3) cout << endl << "...EventNR " << eventNumber ;
|
---|
1045 | bool use_this_peak=false;
|
---|
1046 | int order_of_pulse=0;
|
---|
1047 | vector<Region>::iterator reg;
|
---|
1048 | //Loop over all found zerocrossings in Region
|
---|
1049 | for (reg = pZXings->begin() ; reg < pZXings->end() ; reg++)
|
---|
1050 | {
|
---|
1051 | //skip those who are at the Rim of the ROI
|
---|
1052 | if (reg->maxPos < 12 || (unsigned int) reg->maxPos > gRegionOfInterest-12)
|
---|
1053 | {
|
---|
1054 | if (verbosityLevel > 2) cout << endl << "\t...out of range" << endl;
|
---|
1055 | continue;
|
---|
1056 | }
|
---|
1057 |
|
---|
1058 | // Define axis range of Histogram
|
---|
1059 | int Left = reg->maxPos - gPixelOverlayXaxisLeft;
|
---|
1060 | int Right = reg->maxPos + gPixelOverlayXaxisRight;
|
---|
1061 | int EdgeLeft = reg->halfRisingEdgePos - gPixelOverlayXaxisLeft;
|
---|
1062 | int EdgeRight = reg->halfRisingEdgePos + gPixelOverlayXaxisRight;
|
---|
1063 |
|
---|
1064 | if (Left < 0) Left = 0;
|
---|
1065 | if (EdgeLeft < 0) EdgeLeft = 0;
|
---|
1066 | if (Right > (int)gVcorr.size() ) Right = gVcorr.size();
|
---|
1067 | if (EdgeRight > (int)gVcorr.size() ) EdgeRight = gVcorr.size();
|
---|
1068 |
|
---|
1069 |
|
---|
1070 | if (verbosityLevel > 2) cout << endl << "\t...choosing Histogram" ;
|
---|
1071 | //determine order of pulse and which histogram shall be filled
|
---|
1072 | for ( int order = 0; order < maxPulseOrder; order++)
|
---|
1073 | {
|
---|
1074 | use_this_peak = UseThisPulse(
|
---|
1075 | reg->maxPos,
|
---|
1076 | order,
|
---|
1077 | AmplWindowWidth,
|
---|
1078 | gGainMean,
|
---|
1079 | gBSLMean,
|
---|
1080 | maxPulseOrder,
|
---|
1081 | verbosityLevel
|
---|
1082 | );
|
---|
1083 | if ( use_this_peak)
|
---|
1084 | {
|
---|
1085 | order_of_pulse = order;
|
---|
1086 | break;
|
---|
1087 | }
|
---|
1088 | }
|
---|
1089 | if (select_pulses){
|
---|
1090 | order_of_pulse = 0;
|
---|
1091 | use_this_peak = true;
|
---|
1092 | }
|
---|
1093 | //Fill histograms
|
---|
1094 | if (use_this_peak)
|
---|
1095 | {
|
---|
1096 | //get number of entries of used histograms
|
---|
1097 | maxOverlayEntries = CurrentPixel->hMaxOverlay[order_of_pulse]->GetEntries();
|
---|
1098 | edgeOverlayEntries = CurrentPixel->hEdgeOverlay[order_of_pulse]->GetEntries();
|
---|
1099 | maxProfileEntries = CurrentPixel->hMaxProfile[order_of_pulse]->GetEntries();
|
---|
1100 | edgeProfileEntries = CurrentPixel->hEdgeProfile[order_of_pulse]->GetEntries();
|
---|
1101 |
|
---|
1102 |
|
---|
1103 | //Histograms for Distributions
|
---|
1104 | if (CurrentPixel->mOptions.Contains("S") )
|
---|
1105 | {
|
---|
1106 | if (verbosityLevel > 2)
|
---|
1107 | cout << endl << "\t...filling Edge Histogram" ;
|
---|
1108 | CurrentPixel->hSlopeRisingEdge[order_of_pulse]->Fill( reg->slopeOfRisingEdge ) ;
|
---|
1109 | }
|
---|
1110 |
|
---|
1111 | if (CurrentPixel->mOptions.Contains("R") )
|
---|
1112 | {
|
---|
1113 | if (verbosityLevel > 2)
|
---|
1114 | cout << endl << "\t...filling RisingEdgeToMax Histogram" ;
|
---|
1115 | CurrentPixel->hRisingEdgeToMax[order_of_pulse]->Fill( reg->distanceEdgeToMax ) ;
|
---|
1116 | }
|
---|
1117 |
|
---|
1118 | if (CurrentPixel->mOptions.Contains("M") )
|
---|
1119 | {
|
---|
1120 | if (verbosityLevel > 2)
|
---|
1121 | cout << endl << "\t...filling PosOfMax Histogram" ;
|
---|
1122 | CurrentPixel->hPosOfMax[order_of_pulse]->Fill( reg->maxPos ) ;
|
---|
1123 | }
|
---|
1124 |
|
---|
1125 | //Histograms for Maximum Overlay
|
---|
1126 | for ( int pos = Left; pos < Right; pos++)
|
---|
1127 | {
|
---|
1128 | CurrentPixel->hMaxOverlay[order_of_pulse]->Fill( pos - (reg->maxPos), gVcorr[pos]) ;
|
---|
1129 | CurrentPixel->hMaxProfile[order_of_pulse]->Fill( pos - (reg->maxPos), gVcorr[pos]) ;
|
---|
1130 | }
|
---|
1131 | //Histograms for Edge Overlay
|
---|
1132 | for ( int pos = EdgeLeft; pos < EdgeRight; pos++)
|
---|
1133 | {
|
---|
1134 | CurrentPixel->hEdgeOverlay[order_of_pulse]->Fill( pos - (reg->halfRisingEdgePos), gVcorr[pos]) ;
|
---|
1135 | CurrentPixel->hEdgeProfile[order_of_pulse]->Fill( pos - (reg->halfRisingEdgePos), gVcorr[pos]) ;
|
---|
1136 | }
|
---|
1137 |
|
---|
1138 | //set histogram entries
|
---|
1139 | CurrentPixel->hMaxOverlay[order_of_pulse]->SetEntries( maxOverlayEntries +1 );
|
---|
1140 | CurrentPixel->hEdgeOverlay[order_of_pulse]->SetEntries( edgeOverlayEntries +1 );
|
---|
1141 | CurrentPixel->hMaxProfile[order_of_pulse]->SetEntries( maxProfileEntries +1 );
|
---|
1142 | CurrentPixel->hEdgeProfile[order_of_pulse]->SetEntries( edgeProfileEntries +1 );
|
---|
1143 |
|
---|
1144 | if (verbosityLevel > 2) cout << "...done" << endl;
|
---|
1145 | }
|
---|
1146 |
|
---|
1147 | //gBreakout option
|
---|
1148 | if (gBreakout)
|
---|
1149 | {
|
---|
1150 | break;
|
---|
1151 | }
|
---|
1152 | }
|
---|
1153 | if (verbosityLevel > 2) cout << "...done" << endl;
|
---|
1154 | }
|
---|
1155 | // end of FillHistograms
|
---|
1156 | //----------------------------------------------------------------------------
|
---|
1157 |
|
---|
1158 | bool UseThisPulse(
|
---|
1159 | int maxPos,
|
---|
1160 | int order,
|
---|
1161 | int AmplWindowWidth,
|
---|
1162 | float gainMean,
|
---|
1163 | float bslMean,
|
---|
1164 | int maxPulseOrder,
|
---|
1165 | int verbosityLevel
|
---|
1166 | )
|
---|
1167 | {
|
---|
1168 | //determine if pulse is of given order
|
---|
1169 | bool use_this_peak = false;
|
---|
1170 | if (gVcorr[maxPos] >= ((gainMean*(order+1)) - bslMean - (AmplWindowWidth/2))
|
---|
1171 | && gVcorr[maxPos] < ((gainMean*(order+1)) -bslMean + AmplWindowWidth/2))
|
---|
1172 | {
|
---|
1173 | if (verbosityLevel > 3) cout << "...#" << order ;
|
---|
1174 | use_this_peak = true;
|
---|
1175 | }
|
---|
1176 | else
|
---|
1177 | {
|
---|
1178 | if (verbosityLevel > 3)
|
---|
1179 | {
|
---|
1180 | if (order >= (maxPulseOrder - 1))
|
---|
1181 | {
|
---|
1182 | cout << "...NONE" << endl ;
|
---|
1183 | }
|
---|
1184 | }
|
---|
1185 | use_this_peak = false;
|
---|
1186 | }
|
---|
1187 |
|
---|
1188 | return use_this_peak;
|
---|
1189 | }
|
---|
1190 |
|
---|
1191 |
|
---|
1192 | void
|
---|
1193 | DrawTestHistograms(
|
---|
1194 | int verbosityLevel
|
---|
1195 | )
|
---|
1196 | {
|
---|
1197 | if (verbosityLevel > 2) cout << endl << "...drawing pulse histograms TODO CANVAS" ;
|
---|
1198 |
|
---|
1199 | // cgpTestHistos->cd(1);
|
---|
1200 | // hTesthisto->Draw();
|
---|
1201 | // cgpTestHistos->cd(2);
|
---|
1202 | // hTesthisto2->Draw("BOX");
|
---|
1203 | }
|
---|
1204 | // end of DrawTestHistograms
|
---|
1205 | //----------------------------------------------------------------------------
|
---|
1206 |
|
---|
1207 | void
|
---|
1208 | UpdateCanvases(
|
---|
1209 | int verbosityLevel,
|
---|
1210 | int max_pulse_order,
|
---|
1211 | bool testmode
|
---|
1212 | )
|
---|
1213 | {
|
---|
1214 | if (verbosityLevel > 3) cout << endl << "...updating canvases" ;
|
---|
1215 | for (int pulse_order = 0; pulse_order < max_pulse_order; pulse_order++)
|
---|
1216 | {
|
---|
1217 | cgpPixelPulses[pulse_order]->Modified();
|
---|
1218 | cgpPixelPulses[pulse_order]->Update();
|
---|
1219 | cgpDistributions[pulse_order]->Modified();
|
---|
1220 | cgpDistributions[pulse_order]->Update();
|
---|
1221 | if ( testmode )
|
---|
1222 | {
|
---|
1223 | cgpTestHistos->Modified();
|
---|
1224 | cgpTestHistos->Update();
|
---|
1225 | }
|
---|
1226 | }
|
---|
1227 | }
|
---|
1228 | // end of UpdateCanvases
|
---|
1229 | //----------------------------------------------------------------------------
|
---|
1230 |
|
---|
1231 | void
|
---|
1232 | DeletePixelCanvases(
|
---|
1233 | int maxPulseOrder,
|
---|
1234 | int verbosityLevel
|
---|
1235 | )
|
---|
1236 | {
|
---|
1237 | if (verbosityLevel > 2) cout << endl << "...delete pixel Canvases" ;
|
---|
1238 | for (int pulse_order = 0; pulse_order < maxPulseOrder; pulse_order++ )
|
---|
1239 | {
|
---|
1240 | delete cgpPixelPulses[pulse_order];
|
---|
1241 | delete cgpDistributions[pulse_order];
|
---|
1242 | }
|
---|
1243 | delete[] cgpPixelPulses;
|
---|
1244 | delete[] cgpDistributions;
|
---|
1245 | }
|
---|
1246 |
|
---|
1247 | //----------------------------------------------------------------------------
|
---|
1248 | //----------------------------------------------------------------------------
|
---|
1249 |
|
---|
1250 | bool
|
---|
1251 | ProduceDebugHistos(
|
---|
1252 | vector<Region>* pZXings
|
---|
1253 | )
|
---|
1254 | {
|
---|
1255 | // TODO do this correct. The vectors should be the rigt ones... this is just luck
|
---|
1256 | debugHistos[gAmeas_].GetXaxis()->Set(gAmeas.size() , -0.5 , gAmeas.size()-0.5);
|
---|
1257 | debugHistos[gVcorr_].GetXaxis()->Set(gAmeas.size() , -0.5 , gAmeas.size()-0.5);
|
---|
1258 | debugHistos[gVslide_].GetXaxis()->Set(gAmeas.size() , -0.5 , gAmeas.size()-0.5);
|
---|
1259 | debugHistos[gVcfd_].GetXaxis()->Set(gAmeas.size() , -0.5 , gAmeas.size()-0.5);
|
---|
1260 | debugHistos[gVcfd2_].GetXaxis()->Set(gAmeas.size() , -0.5 , gAmeas.size()-0.5);
|
---|
1261 |
|
---|
1262 | for ( unsigned int sl = 0; sl < gRegionOfInterest; sl++)
|
---|
1263 | {
|
---|
1264 | debugHistos[gAmeas_].SetBinContent(sl, gAmeas[sl]);
|
---|
1265 | debugHistos[gVcorr_].SetBinContent(sl, gVcorr[sl]);
|
---|
1266 | debugHistos[gVslide_].SetBinContent( sl, gVslide[sl] );
|
---|
1267 | debugHistos[gVcfd_].SetBinContent( sl, gVcfd[sl] );
|
---|
1268 | debugHistos[gVcfd2_].SetBinContent( sl, gVcfd2[sl] );
|
---|
1269 | }
|
---|
1270 |
|
---|
1271 | bool has_negative_slope = false;
|
---|
1272 | cFiltered->cd(1);
|
---|
1273 | gPad->SetGrid();
|
---|
1274 | debugHistos[gAmeas_].Draw();
|
---|
1275 |
|
---|
1276 | TF1 *OneEdge;
|
---|
1277 | TLine *OneLine;
|
---|
1278 | TBox *OneBox;
|
---|
1279 | vector<TF1*> MyEdges;
|
---|
1280 | vector<TBox*> MyBoxes;
|
---|
1281 | vector<TBox*> MyLines;
|
---|
1282 |
|
---|
1283 | int left = debugHistos[gAmeas_].GetXaxis()->GetFirst();
|
---|
1284 | int right = debugHistos[gAmeas_].GetXaxis()->GetLast();
|
---|
1285 | vector<Region>::iterator region;
|
---|
1286 | for (region = pZXings->begin() ; region < pZXings->end() ; region++)
|
---|
1287 | {
|
---|
1288 | if (region->slopeOfRisingEdge < 0)
|
---|
1289 | {
|
---|
1290 | has_negative_slope = true;
|
---|
1291 | }
|
---|
1292 | }
|
---|
1293 |
|
---|
1294 | if (has_negative_slope)
|
---|
1295 | {
|
---|
1296 | for (unsigned int i=0; i<pZXings->size(); i++){
|
---|
1297 | Region* reg = &pZXings->at(i);
|
---|
1298 | cout << "Slope is: " << reg->slopeOfRisingEdge << endl;
|
---|
1299 |
|
---|
1300 | // xBegin = (reg->halfRisingEdgePos - reg->distanceEdgeToMax);
|
---|
1301 | // yBegin = reg->integRCeptRisingEdge + reg->slopeOfRisingEdge * (xBegin)
|
---|
1302 |
|
---|
1303 | OneEdge = new TF1(
|
---|
1304 | "OneEdge",
|
---|
1305 | "[0]*x+[1]",
|
---|
1306 | left,
|
---|
1307 | right
|
---|
1308 | );
|
---|
1309 |
|
---|
1310 | OneEdge->SetParameters(
|
---|
1311 | reg->slopeOfRisingEdge,
|
---|
1312 | reg->interceptRisingEdge
|
---|
1313 | );
|
---|
1314 |
|
---|
1315 | OneEdge->SetLineColor(kRed);
|
---|
1316 | OneEdge->SetLineWidth(1);
|
---|
1317 | MyEdges.push_back(OneEdge);
|
---|
1318 |
|
---|
1319 | OneEdge->Draw("SAME");
|
---|
1320 | // delete OneEdge;
|
---|
1321 |
|
---|
1322 | OneBox = new TBox(
|
---|
1323 | pZXings->at(i).maxPos -10 ,
|
---|
1324 | pZXings->at(i).maxVal -0.5,
|
---|
1325 | pZXings->at(i).maxPos +10 ,
|
---|
1326 | pZXings->at(i).maxVal +0.5);
|
---|
1327 | OneBox->SetLineColor(kBlue);
|
---|
1328 | OneBox->SetLineWidth(1);
|
---|
1329 | OneBox->SetFillStyle(0);
|
---|
1330 | OneBox->SetFillColor(kRed);
|
---|
1331 | MyBoxes.push_back(OneBox);
|
---|
1332 | OneBox->Draw();
|
---|
1333 |
|
---|
1334 | OneLine = new TLine(
|
---|
1335 | pZXings->at(i).halfRisingEdgePos,
|
---|
1336 | gAmeas[pZXings->at(i).halfRisingEdgePos],
|
---|
1337 | pZXings->at(i).halfRisingEdgePos,
|
---|
1338 | pZXings->at(i).halfRisingEdgePos * pZXings->at(i).slopeOfRisingEdge + pZXings->at(i).interceptRisingEdge
|
---|
1339 | );
|
---|
1340 | OneLine->SetLineColor(kBlue);
|
---|
1341 | OneLine->SetLineWidth(3);
|
---|
1342 | MyLines.push_back(OneBox);
|
---|
1343 | OneLine->Draw();
|
---|
1344 | }
|
---|
1345 |
|
---|
1346 | cFiltered->cd(2);
|
---|
1347 | gPad->SetGrid();
|
---|
1348 | debugHistos[gVslide_].Draw();
|
---|
1349 | debugHistos[gVcorr_].Draw("SAME");
|
---|
1350 |
|
---|
1351 | for (unsigned int i=0; i<MyEdges.size(); i++){
|
---|
1352 | MyEdges.at(i)->Draw("SAME");
|
---|
1353 | }
|
---|
1354 | for (unsigned int i=0; i<MyBoxes.size(); i++){
|
---|
1355 | MyBoxes.at(i)->Draw();
|
---|
1356 | }
|
---|
1357 | for (unsigned int i=0; i<MyLines.size(); i++){
|
---|
1358 | MyLines.at(i)->Draw();
|
---|
1359 | }
|
---|
1360 |
|
---|
1361 | cFiltered->cd(3);
|
---|
1362 | gPad->SetGrid();
|
---|
1363 | debugHistos[gVcorr_].SetLineColor(kBlue);
|
---|
1364 | debugHistos[gVcorr_].Draw();
|
---|
1365 | debugHistos[gAmeas_].Draw("SAME");
|
---|
1366 | debugHistos[gVslide_].SetLineColor(kRed);
|
---|
1367 | debugHistos[gVslide_].Draw("SAME");
|
---|
1368 | debugHistos[gVcfd_].SetLineColor(kGreen);
|
---|
1369 | debugHistos[gVcfd_].Draw("SAME");
|
---|
1370 | debugHistos[gVcfd2_].SetLineColor(kViolet);
|
---|
1371 | debugHistos[gVcfd2_].Draw("SAME");
|
---|
1372 | for (unsigned int i=0; i<MyEdges.size(); i++){
|
---|
1373 | MyEdges.at(i)->Draw("SAME");
|
---|
1374 | }
|
---|
1375 | for (unsigned int i=0; i<MyBoxes.size(); i++){
|
---|
1376 | MyBoxes.at(i)->Draw();
|
---|
1377 | }
|
---|
1378 | for (unsigned int i=0; i<MyLines.size(); i++){
|
---|
1379 | MyLines.at(i)->Draw();
|
---|
1380 | }
|
---|
1381 |
|
---|
1382 |
|
---|
1383 | // cFiltered->cd(3);
|
---|
1384 | // gPad->SetGrid();
|
---|
1385 | // debugHistos[gVcfd2_].Draw();
|
---|
1386 | // TLine *zeroline = new TLine(0, 0, 1024, 0);
|
---|
1387 | // zeroline->SetLineColor(kBlue);
|
---|
1388 | // zeroline->Draw();
|
---|
1389 |
|
---|
1390 | cFiltered->Update();
|
---|
1391 |
|
---|
1392 |
|
---|
1393 | //Process gui events asynchronously during input
|
---|
1394 | TTimer timer("gSystem->ProcessEvents();", 50, kFALSE);
|
---|
1395 | timer.TurnOn();
|
---|
1396 | TString input = Getline("Type 'q' to exit, <return> to go on: ");
|
---|
1397 | timer.TurnOff();
|
---|
1398 | if (input=="q\n") {
|
---|
1399 | return true;
|
---|
1400 | }
|
---|
1401 |
|
---|
1402 | MyLines.clear();
|
---|
1403 | MyBoxes.clear();
|
---|
1404 | MyEdges.clear();
|
---|
1405 |
|
---|
1406 | // for (unsigned int i=0; i<pZXings->size(); i++)
|
---|
1407 | // {
|
---|
1408 | // delete MyEdges.at(i)
|
---|
1409 | // delete MyBoxes.at(i);
|
---|
1410 | // }
|
---|
1411 | // delete OneBox;
|
---|
1412 | // delete OneEdge;
|
---|
1413 | // delete OneLine;
|
---|
1414 |
|
---|
1415 | // MyEdges.erase();
|
---|
1416 | // MyBoxes.erase();
|
---|
1417 | }
|
---|
1418 |
|
---|
1419 | //TODO!!!!!!!!!
|
---|
1420 | // do some Garbage collection ...
|
---|
1421 | // all the Objects on the heap should be deleted here.
|
---|
1422 | return false;
|
---|
1423 | }// end of if(spikeDebug)
|
---|
1424 |
|
---|
1425 | int HandleFitsFile(
|
---|
1426 | fits * datafile,
|
---|
1427 | TString datafilename,
|
---|
1428 | TString drsfilename,
|
---|
1429 | int nevents,
|
---|
1430 | int npixel,
|
---|
1431 | int verbosityLevel
|
---|
1432 | )
|
---|
1433 | {
|
---|
1434 | // Opens the raw data file and 'binds' the variables given as
|
---|
1435 | // Parameters to the data file. So they are filled with
|
---|
1436 | // raw data as soon as datafile->GetRow(int) is called.
|
---|
1437 | cout << "\nopening " << datafilename << endl;
|
---|
1438 |
|
---|
1439 | gNEvents = openDataFits(
|
---|
1440 | datafilename,
|
---|
1441 | &datafile,
|
---|
1442 | gAllPixelDataVector,
|
---|
1443 | gStartCellVector,
|
---|
1444 | gCurrentEventID,
|
---|
1445 | gRegionOfInterest,
|
---|
1446 | gNumberOfPixels,
|
---|
1447 | gPXLxROI,
|
---|
1448 | verbosityLevel
|
---|
1449 | );
|
---|
1450 |
|
---|
1451 | if (gNEvents == 0)
|
---|
1452 | {
|
---|
1453 | cout << "return code of OpenDataFile:" << datafilename<< endl;
|
---|
1454 | cout << "is zero -> aborting." << endl;
|
---|
1455 | return 1;
|
---|
1456 | }
|
---|
1457 |
|
---|
1458 | if (verbosityLevel > 0)
|
---|
1459 | {
|
---|
1460 | cout << endl <<"number of events in file: "<< gNEvents << "\t";
|
---|
1461 | }
|
---|
1462 |
|
---|
1463 | if ( nevents == -1 || nevents > gNEvents ) nevents = gNEvents; // -1 means all!
|
---|
1464 |
|
---|
1465 | if (verbosityLevel > 0)
|
---|
1466 | {
|
---|
1467 | cout <<"of, which "<< nevents << " will be processed"<< endl;
|
---|
1468 | cout <<"Total # of Pixel: "<< gNumberOfPixels << "\t";
|
---|
1469 | }
|
---|
1470 |
|
---|
1471 | if ( npixel == -1 || npixel > (int)gNumberOfPixels ) npixel = (int)gNumberOfPixels; // -1 means all!
|
---|
1472 |
|
---|
1473 | if (verbosityLevel > 0)
|
---|
1474 | {
|
---|
1475 | cout <<"of, which "<< npixel << " will be processed"<< endl;
|
---|
1476 | }
|
---|
1477 |
|
---|
1478 | //Get the DRS calibration
|
---|
1479 | gRC = openCalibFits(
|
---|
1480 | drsfilename,
|
---|
1481 | gDrsBaseMean,
|
---|
1482 | gDrsGainMean,
|
---|
1483 | gDrsTriggeroffsetMean,
|
---|
1484 | gTriggerOffsetROI
|
---|
1485 | );
|
---|
1486 |
|
---|
1487 | if (gRC == 0)
|
---|
1488 | {
|
---|
1489 | cout << "return code of openCalibFits:" << drsfilename << endl;
|
---|
1490 | cout << "is zero -> aborting." << endl;
|
---|
1491 | return 1;
|
---|
1492 | }
|
---|
1493 | return 0;
|
---|
1494 | }
|
---|
1495 |
|
---|
1496 | void ReadSequenzFile(TString fileName, vector<TString> *fitsFiles, vector<TString> *drsFiles)
|
---|
1497 | {
|
---|
1498 | ifstream seqFile;
|
---|
1499 | seqFile.open(fileName,ios::in);
|
---|
1500 |
|
---|
1501 | TString fitsName, drsName;
|
---|
1502 |
|
---|
1503 | if(!seqFile)
|
---|
1504 | {
|
---|
1505 | cerr << "***** no config-file in the user defined directory.\n"
|
---|
1506 | << "Check the path .\n" << endl;
|
---|
1507 | return;
|
---|
1508 | }
|
---|
1509 |
|
---|
1510 | if(!seqFile.good()) {
|
---|
1511 | cerr << "***** not able to read config-file." << endl;
|
---|
1512 | return;
|
---|
1513 | }
|
---|
1514 |
|
---|
1515 | while(!seqFile.eof())
|
---|
1516 | {
|
---|
1517 | seqFile >> fitsName >> drsName;
|
---|
1518 |
|
---|
1519 | if (!fitsName.IsWhitespace() && !fitsName.IsNull())
|
---|
1520 | {
|
---|
1521 | fitsFiles->push_back(fitsName);
|
---|
1522 |
|
---|
1523 | if (!drsName.IsWhitespace() && !drsName.IsNull())
|
---|
1524 | {
|
---|
1525 | drsFiles->push_back(drsName);
|
---|
1526 | }
|
---|
1527 | else drsFiles->push_back("0");
|
---|
1528 | }
|
---|
1529 | }
|
---|
1530 |
|
---|
1531 | seqFile.close();
|
---|
1532 |
|
---|
1533 | return;
|
---|
1534 | }
|
---|
1535 |
|
---|
1536 |
|
---|
1537 | //int main(int argc,char *argv[])
|
---|
1538 | //{
|
---|
1539 |
|
---|
1540 | // TString test;
|
---|
1541 | // TString gRCFileName;
|
---|
1542 | // TString processType = "overlay";
|
---|
1543 | // bool gRCFileNameCmdSet = false;
|
---|
1544 | // int verbLevel = 0; // different verbosity levels can be implemented here
|
---|
1545 | // bool verbLevelCmdSet = false;
|
---|
1546 | // bool save = false;
|
---|
1547 | // bool produceGraphic = false;
|
---|
1548 |
|
---|
1549 | // // decode arguments
|
---|
1550 | // if(argc < 2)
|
---|
1551 | // {
|
---|
1552 | // printf("no arguements given, using standard arguments\n");
|
---|
1553 | // }
|
---|
1554 |
|
---|
1555 | // // set conditions for functions arguments
|
---|
1556 | // for (int i=1;i<argc;i++)
|
---|
1557 | // {
|
---|
1558 | // test = argv[i];
|
---|
1559 |
|
---|
1560 | // if (test.Contains("--config_file") || test.Contains("-c"))
|
---|
1561 | // {
|
---|
1562 | // cout << "gRC-File: \"" << argv[i + 1] << "\"" << endl;
|
---|
1563 | // gRCFileName = argv[i + 1];
|
---|
1564 | // gRCFileNameCmdSet = true;
|
---|
1565 | // continue;
|
---|
1566 | // }
|
---|
1567 |
|
---|
1568 | // if (test.Contains("--verbosity") || test.Contains("-v"))
|
---|
1569 | // {
|
---|
1570 | // cout << "Verbosity Level: \"" << argv[i + 1] << "\"" << endl;
|
---|
1571 | // verbLevel = atoi(argv[i + 1]);
|
---|
1572 | // continue;
|
---|
1573 | // }
|
---|
1574 |
|
---|
1575 | // if (test.Contains("--save") || test.Contains("-s"))
|
---|
1576 | // {
|
---|
1577 | // cout << "will save results" << endl;
|
---|
1578 | // save = true;
|
---|
1579 | // continue;
|
---|
1580 | // }
|
---|
1581 |
|
---|
1582 | // if (test.Contains("--graphics") || test.Contains("-g"))
|
---|
1583 | // {
|
---|
1584 | // cout << "will produce graphics" << endl;
|
---|
1585 | // produceGraphic = true;
|
---|
1586 | // continue;
|
---|
1587 | // }
|
---|
1588 | // }
|
---|
1589 |
|
---|
1590 | // // reading gRC-File:
|
---|
1591 | // configfile gRCfile( gRCFileName, processType );
|
---|
1592 |
|
---|
1593 | // if (save)
|
---|
1594 | // {
|
---|
1595 | // gRCfile.mSave = save;
|
---|
1596 | // }
|
---|
1597 |
|
---|
1598 | // if (verbLevelCmdSet)
|
---|
1599 | // {
|
---|
1600 | // gRCfile.mVerbLevel = verbLevel;
|
---|
1601 | // }
|
---|
1602 |
|
---|
1603 | // if (produceGraphic)
|
---|
1604 | // {
|
---|
1605 | // gRCfile.mProduceGraphic = produceGraphic;
|
---|
1606 | // }
|
---|
1607 |
|
---|
1608 | // FPulseOverlay(
|
---|
1609 | // gRCfile.mInputPath,
|
---|
1610 | // gRCfile.mDataFileName,
|
---|
1611 | // gRCfile.mDrsFileName,
|
---|
1612 | // gRCfile.mOutputPath,
|
---|
1613 | // gRCfile.mOutputFile,
|
---|
1614 | // gRCfile.mFirstEvent,
|
---|
1615 | // gRCfile.mNumEvents,
|
---|
1616 | // gRCfile.mFirstPixel,
|
---|
1617 | // gRCfile.mNumPixel,
|
---|
1618 | // gRCfile.mPixelSetSize,
|
---|
1619 | // gRCfile.mMaxOrder,
|
---|
1620 | // gRCfile.mVerbLevel,
|
---|
1621 | // gRCfile.mHistoOptions,
|
---|
1622 | // gRCfile.mAmplWindowWidth,
|
---|
1623 | // gRCfile.mGainMean,
|
---|
1624 | // gRCfile.mBSLMean,
|
---|
1625 | // gRCfile.mAvg1,
|
---|
1626 | // gRCfile.mAvg2,
|
---|
1627 | // gRCfile.mOverlayWindowLeft,
|
---|
1628 | // gRCfile.mOverlayWindowRight,
|
---|
1629 | // gRCfile.mProduceGraphic,
|
---|
1630 | // gRCfile.mSpikeDebug,
|
---|
1631 | // gRCfile.mDbgPixel,
|
---|
1632 | // gRCfile.mPrintStats,
|
---|
1633 | // gRCfile.mSave,
|
---|
1634 | // gRCfile.mTestMode,
|
---|
1635 | // gRCfile.mRefreshRate
|
---|
1636 | // );
|
---|
1637 | // return 0;
|
---|
1638 |
|
---|
1639 | //}
|
---|