1 | /********************** FPulseTemplate ***********************
|
---|
2 | * open a root-file with pulse overlay histograms
|
---|
3 | * calculate most propable Pulse-Shape
|
---|
4 | * compute pulse height and pulse integral spektrum of the peaks
|
---|
5 | + draw histos for single, double, tripple, ....above 100mV Photonpulses
|
---|
6 | + draw Parameterdevelopment depending on photon quantity
|
---|
7 | + form a template (shape depending on number of photons)
|
---|
8 | so it can be used for detection of other peaks
|
---|
9 | *************************************************************/
|
---|
10 |
|
---|
11 | //----------------------------------------------------------------------------
|
---|
12 | // root libraries
|
---|
13 | //----------------------------------------------------------------------------
|
---|
14 |
|
---|
15 | #include <TROOT.h>
|
---|
16 | #include <TCanvas.h>
|
---|
17 | #include <TTimer.h>
|
---|
18 | #include <Getline.h>
|
---|
19 | #include <TMath.h>
|
---|
20 | #include <TFile.h>
|
---|
21 | #include <TStyle.h>
|
---|
22 | #include <TString.h>
|
---|
23 |
|
---|
24 | #include <stdio.h>
|
---|
25 | #include <stdint.h>
|
---|
26 | #include <cstdio>
|
---|
27 | #include <iostream>
|
---|
28 | #include <fstream>
|
---|
29 | using namespace std;
|
---|
30 |
|
---|
31 | #define NPIX 1440
|
---|
32 | #define NCELL 1024
|
---|
33 | #define FAD_MAX_SAMPLES 1024
|
---|
34 | #define MAX_PULS_ORDER 1
|
---|
35 | #define HAVE_ZLIB
|
---|
36 |
|
---|
37 | //----------------------------------------------------------------------------
|
---|
38 | // rootmacros
|
---|
39 | //----------------------------------------------------------------------------
|
---|
40 | #include "rootfilehandler.h"
|
---|
41 | #include "pixel.h"
|
---|
42 | #include "pixelsum.h"
|
---|
43 | #include "templateextractors.h"
|
---|
44 | #include "configfile.h"
|
---|
45 |
|
---|
46 | //----------------------------------------------------------------------------
|
---|
47 | // Decleration of global variables
|
---|
48 | //----------------------------------------------------------------------------
|
---|
49 | bool breakout=false;
|
---|
50 |
|
---|
51 | //----------------------------------------------------------------------------
|
---|
52 | // Initialisation of Root Objects
|
---|
53 | //----------------------------------------------------------------------------
|
---|
54 |
|
---|
55 | // Temporary Objects
|
---|
56 |
|
---|
57 | //Pixelwise Histograms
|
---|
58 |
|
---|
59 | //All Pixel Histograms
|
---|
60 |
|
---|
61 | //Root-File Objects
|
---|
62 | TObjArray* hAllPixelList = NULL;
|
---|
63 | TObjArray* hRootList = NULL;
|
---|
64 |
|
---|
65 | //Canvases
|
---|
66 | TCanvas** cgpPixelPulses = NULL;
|
---|
67 | TCanvas** cgpAllPixelPulses = NULL;
|
---|
68 | TCanvas** cgpDistributions = NULL;
|
---|
69 | //TCanvas* cgpTestHistos = NULL;
|
---|
70 |
|
---|
71 | //----------------------------------------------------------------------------
|
---|
72 | // Functions
|
---|
73 | //----------------------------------------------------------------------------
|
---|
74 | void DeletePixelCanvases( int, int );
|
---|
75 | void
|
---|
76 | UpdateCanvases(
|
---|
77 | int verbosityLevel,
|
---|
78 | int max_pulse_order,
|
---|
79 | bool testmode
|
---|
80 | );
|
---|
81 | //----------------------------------------------------------------------------
|
---|
82 | //----------------------------------------------------------------------------
|
---|
83 | // MAIN - Funtion
|
---|
84 | //----------------------------------------------------------------------------
|
---|
85 | //----------------------------------------------------------------------------
|
---|
86 | int FCalcPulseTemplate(
|
---|
87 | TString InRootFileName = "20120309_018.root",
|
---|
88 | TString InputPath = "analysis/FPulseTemplate/20120309_018/Overlay/",
|
---|
89 | TString OutputRootFileName = "test.root",
|
---|
90 | TString OutPutPath = "analysis/FPulseTemplate/20120309_018/",
|
---|
91 | int firstpixel = 0,
|
---|
92 | int npixel = -1,
|
---|
93 | int pixelSetSize = 200,
|
---|
94 | int maxPulseOrder = 3,
|
---|
95 | TString histoOptions = "SRM",
|
---|
96 | bool ProduceGraphic = true,
|
---|
97 | bool stats = true,
|
---|
98 | bool saveResults = true,
|
---|
99 | // bool fitdata = false,
|
---|
100 | bool debugPixel = false,
|
---|
101 | // int refresh_rate = 500, //refresh rate for canvases
|
---|
102 | int verbosityLevel = 2 // different verbosity levels can be implemented here
|
---|
103 | )
|
---|
104 | {
|
---|
105 |
|
---|
106 | InputPath = SetHostsPaths(true, InputPath );
|
---|
107 | OutPutPath = SetHostsPaths(true, OutPutPath );
|
---|
108 |
|
---|
109 | TString outFile = OutPutPath;
|
---|
110 | outFile += OutputRootFileName;
|
---|
111 |
|
---|
112 | //----------------------------------------------------------------------------
|
---|
113 | // Open-Root-File Settings
|
---|
114 | //----------------------------------------------------------------------------
|
---|
115 | if (verbosityLevel > 0)
|
---|
116 | {
|
---|
117 | cout << endl << "...load root file" << endl;
|
---|
118 | }
|
---|
119 |
|
---|
120 | TFile * inputRootFile
|
---|
121 | = LoadRootFile( InputPath, InRootFileName, verbosityLevel );
|
---|
122 |
|
---|
123 | if (inputRootFile == NULL)
|
---|
124 | {
|
---|
125 | cerr << "input file not readable, check file path!!!" << endl;
|
---|
126 | return(0);
|
---|
127 | }
|
---|
128 | if (saveResults)
|
---|
129 | {
|
---|
130 | CreateRootFile( outFile, true, verbosityLevel );
|
---|
131 | }
|
---|
132 |
|
---|
133 | TFile * outputRootFile
|
---|
134 | = OpenRootFile( OutPutPath, OutputRootFileName, verbosityLevel );
|
---|
135 | //----------------------------------------------------------------------------
|
---|
136 | // Define operation range
|
---|
137 | //----------------------------------------------------------------------------
|
---|
138 | if ( npixel == -1 )
|
---|
139 | {
|
---|
140 | npixel = NPIX - firstpixel;
|
---|
141 | }
|
---|
142 |
|
---|
143 |
|
---|
144 | if ( pixelSetSize == -1 )
|
---|
145 | {
|
---|
146 | pixelSetSize = firstpixel +npixel;
|
---|
147 | }
|
---|
148 |
|
---|
149 | // float GainMean = GainMean; // this has to be extracted from root files
|
---|
150 | // float BSLMean = BSLMean; // this has to be extracted from root files
|
---|
151 |
|
---|
152 | //----------------------------------------------------------------------------
|
---|
153 | // root global Settings
|
---|
154 | //----------------------------------------------------------------------------
|
---|
155 | if (verbosityLevel > 0)
|
---|
156 | {
|
---|
157 | cout << endl << "...setting up root environment" ;
|
---|
158 | }
|
---|
159 |
|
---|
160 | gStyle->SetPalette(1,0);
|
---|
161 | gROOT->SetStyle("Plain");
|
---|
162 | // gPad->SetGrid();
|
---|
163 |
|
---|
164 |
|
---|
165 |
|
---|
166 | //----------------------------------------------------------------------------
|
---|
167 | // root Canvas Settings
|
---|
168 | //----------------------------------------------------------------------------
|
---|
169 | if (verbosityLevel > 0)
|
---|
170 | {
|
---|
171 | cout << endl << "...preparing canvases" << endl;
|
---|
172 | }
|
---|
173 |
|
---|
174 | //Canvas Pad numbering
|
---|
175 | int PixelCanvasFrameNrs[4] = {
|
---|
176 | 1, // Top left
|
---|
177 | 2, // Top right
|
---|
178 | 3, // bottom left
|
---|
179 | 4 // bootom right
|
---|
180 | };
|
---|
181 |
|
---|
182 | //Canvas Pad numbering
|
---|
183 | int AllpixelCanvasFrameNrs[4] = {
|
---|
184 | 1, // Top left
|
---|
185 | 2, // Top right
|
---|
186 | 3, // bottom left
|
---|
187 | 4 // bootom right
|
---|
188 | };
|
---|
189 |
|
---|
190 | if (ProduceGraphic)
|
---|
191 | {
|
---|
192 |
|
---|
193 | //Canvases
|
---|
194 | cgpPixelPulses = new TCanvas*[maxPulseOrder];
|
---|
195 | cgpDistributions = new TCanvas*[maxPulseOrder];
|
---|
196 |
|
---|
197 | //TCanvas* gpcDevelopment = NULL;
|
---|
198 | TString cName = "";
|
---|
199 | TString cTitle = "";
|
---|
200 |
|
---|
201 | //naming of pulse canvases
|
---|
202 | for (
|
---|
203 | int pulse_order = maxPulseOrder - 1;
|
---|
204 | pulse_order >= 0 ;
|
---|
205 | pulse_order--
|
---|
206 | )
|
---|
207 | {
|
---|
208 | cName ="cgpDistributions";
|
---|
209 | cName += pulse_order;
|
---|
210 |
|
---|
211 | cTitle ="Distributions of Pulses with Order of: ";
|
---|
212 | cTitle += pulse_order;
|
---|
213 |
|
---|
214 | cgpDistributions[pulse_order]
|
---|
215 | = new TCanvas(cName,cTitle, 720,pulse_order*20,720,720);
|
---|
216 | cgpDistributions[pulse_order]->Divide(2, 2);
|
---|
217 |
|
---|
218 | cName ="cgpPixelPulses";
|
---|
219 | cName += pulse_order;
|
---|
220 |
|
---|
221 | cTitle ="Overlays of Pulses with Order of: ";
|
---|
222 | cTitle += pulse_order;
|
---|
223 |
|
---|
224 | cgpPixelPulses[pulse_order]
|
---|
225 | = new TCanvas(cName,cTitle, 0,pulse_order*20,720,720);
|
---|
226 | cgpPixelPulses[pulse_order]->Divide(2, 2);
|
---|
227 | }
|
---|
228 | }
|
---|
229 |
|
---|
230 | //-----------------------------------------------------------------------------
|
---|
231 | // Filter-Settings
|
---|
232 | //-----------------------------------------------------------------------------
|
---|
233 |
|
---|
234 |
|
---|
235 | //-----------------------------------------------------------------------------
|
---|
236 | // prepare datafile
|
---|
237 | //-----------------------------------------------------------------------------
|
---|
238 |
|
---|
239 | //----------------------------------------------------------------------------
|
---|
240 | // Initialize Pixels
|
---|
241 | //----------------------------------------------------------------------------
|
---|
242 | if (verbosityLevel > 0)
|
---|
243 | {
|
---|
244 | cout << endl << "...preparing pixels" << endl;
|
---|
245 | }
|
---|
246 |
|
---|
247 | Pixel** pixel = new Pixel*[NPIX];
|
---|
248 |
|
---|
249 | for (int i = 0 ; i < NPIX; i++)
|
---|
250 | {
|
---|
251 | pixel[i] = NULL;
|
---|
252 | }
|
---|
253 |
|
---|
254 | PixelSum* wholeCamera = NULL;
|
---|
255 |
|
---|
256 | bool first_pass = true;
|
---|
257 |
|
---|
258 | //-------------------------------------
|
---|
259 | // Loop over Pixel Sets
|
---|
260 | //-------------------------------------
|
---|
261 | for ( int firstPixelOfSet = firstpixel;
|
---|
262 | firstPixelOfSet < firstpixel + npixel;
|
---|
263 | firstPixelOfSet += pixelSetSize )
|
---|
264 | {
|
---|
265 | if (verbosityLevel >= 0)
|
---|
266 | {
|
---|
267 | cout << "------------------------------------------------"
|
---|
268 | << endl
|
---|
269 | << "...processing Pixel: "
|
---|
270 | << firstPixelOfSet
|
---|
271 | << " to Pixel: "
|
---|
272 | << firstPixelOfSet+pixelSetSize-1
|
---|
273 | << endl;
|
---|
274 | }
|
---|
275 |
|
---|
276 | //--------------------------------------------------------------------
|
---|
277 | // Loops over every Pixel of a Set of Pixels
|
---|
278 | //--------------------------------------------------------------------
|
---|
279 | for ( int pixelID = firstPixelOfSet;
|
---|
280 | pixelID < firstPixelOfSet + pixelSetSize
|
---|
281 | && pixelID < firstpixel + npixel;
|
---|
282 | pixelID++ )
|
---|
283 | {
|
---|
284 | if (verbosityLevel >= 0)
|
---|
285 | {
|
---|
286 | cout << "------------------------------------------------"
|
---|
287 | << endl
|
---|
288 | << "...processing Pixel: "
|
---|
289 | << pixelID << "/"
|
---|
290 | << firstPixelOfSet + pixelSetSize - 1
|
---|
291 | << endl;
|
---|
292 | }
|
---|
293 | if (verbosityLevel > 1)
|
---|
294 | {
|
---|
295 | cout << "-------------------------------------"
|
---|
296 | << endl
|
---|
297 | << "...processing Set from Pixel "
|
---|
298 | << firstPixelOfSet
|
---|
299 | << " to Pixel "
|
---|
300 | << firstPixelOfSet+pixelSetSize-1
|
---|
301 | << " Pixel: " << pixelID
|
---|
302 | << "/" << firstpixel + npixel -1
|
---|
303 | << endl;
|
---|
304 | }
|
---|
305 |
|
---|
306 | //-------------------------------------
|
---|
307 | // Create individual Pixel
|
---|
308 | //-------------------------------------
|
---|
309 | if (verbosityLevel > 3)
|
---|
310 | {
|
---|
311 | cout << "...creating pixel: " << pixelID << endl;
|
---|
312 | }
|
---|
313 |
|
---|
314 | pixel[pixelID] = new Pixel(
|
---|
315 | pixelID,
|
---|
316 | maxPulseOrder, ///One should get this from the file
|
---|
317 | verbosityLevel,
|
---|
318 | stats,
|
---|
319 | "L",
|
---|
320 | 70, ///TODO: get it from the root file
|
---|
321 | 230, ///TODO: get it from the root file
|
---|
322 | -1, ///TODO: get it from the root file
|
---|
323 | 9, ///TODO: get it from the root file
|
---|
324 | inputRootFile,
|
---|
325 | outputRootFile
|
---|
326 | );
|
---|
327 |
|
---|
328 | if (breakout) break;
|
---|
329 |
|
---|
330 | //Preparing Camera
|
---|
331 | if (first_pass)
|
---|
332 | {
|
---|
333 | if (verbosityLevel > 0)
|
---|
334 | {
|
---|
335 | cout << endl << "...preparing camera" << endl;
|
---|
336 | }
|
---|
337 |
|
---|
338 | wholeCamera = new PixelSum(
|
---|
339 | "AllPixel",
|
---|
340 | 1440,
|
---|
341 | maxPulseOrder,
|
---|
342 | verbosityLevel,
|
---|
343 | stats,
|
---|
344 | "",
|
---|
345 | pixel[pixelID]->mPixelOverlayXaxisLeft,
|
---|
346 | pixel[pixelID]->mPixelOverlayXaxisRight ,
|
---|
347 | pixel[pixelID]->mBSLMean ,
|
---|
348 | pixel[pixelID]->mGainMean ,
|
---|
349 | outputRootFile
|
---|
350 | );
|
---|
351 |
|
---|
352 | first_pass = false;
|
---|
353 | }
|
---|
354 | //-------------------------------------
|
---|
355 | // Histogramms of Maximas in Overlay Spectra
|
---|
356 | //-------------------------------------
|
---|
357 |
|
---|
358 | for ( int pulse_order = 0 ;
|
---|
359 | pulse_order < pixel[pixelID]->mMaxPulseOrder ;
|
---|
360 | pulse_order ++)
|
---|
361 | {
|
---|
362 | if (verbosityLevel > 2)
|
---|
363 | {
|
---|
364 | cout << "-------------------------------------"
|
---|
365 | << endl
|
---|
366 | << "...processing Set from Pixel "
|
---|
367 | << firstPixelOfSet
|
---|
368 | << " to Pixel "
|
---|
369 | << firstPixelOfSet+pixelSetSize-1
|
---|
370 | << " Pixel: " << pixelID
|
---|
371 | << "/" << firstpixel + npixel -1
|
---|
372 | << " Pulse-Order: " << pulse_order
|
---|
373 | << endl;
|
---|
374 | }
|
---|
375 |
|
---|
376 | // Calculate Max Prop. Value of each slice
|
---|
377 | //-------------------------------------
|
---|
378 |
|
---|
379 | //from Maximum Overlay
|
---|
380 | if (verbosityLevel > 2)
|
---|
381 | {
|
---|
382 | cout << "...extracting templates from Maximum Overlay "
|
---|
383 | << endl;
|
---|
384 | }
|
---|
385 |
|
---|
386 | ExtractPulseTemplate(
|
---|
387 | pixel[pixelID],
|
---|
388 | "Maximum",
|
---|
389 | pulse_order,
|
---|
390 | verbosityLevel
|
---|
391 | );
|
---|
392 |
|
---|
393 | //from Edge Overlay
|
---|
394 | if (verbosityLevel > 2)
|
---|
395 | {
|
---|
396 | cout << "...extracting templates from Edge Overlay "
|
---|
397 | << endl;
|
---|
398 | }
|
---|
399 | ExtractPulseTemplate(
|
---|
400 | pixel[pixelID],
|
---|
401 | "Edge",
|
---|
402 | pulse_order,
|
---|
403 | verbosityLevel
|
---|
404 | );
|
---|
405 |
|
---|
406 | if ( saveResults )
|
---|
407 | {
|
---|
408 | WritePixelTemplateToCsv(
|
---|
409 | pixel[pixelID],
|
---|
410 | OutPutPath,
|
---|
411 | "Maximum",
|
---|
412 | pulse_order,
|
---|
413 | verbosityLevel
|
---|
414 | );
|
---|
415 |
|
---|
416 | WritePixelTemplateToCsv(
|
---|
417 | pixel[pixelID],
|
---|
418 | OutPutPath,
|
---|
419 | "Edge",
|
---|
420 | pulse_order,
|
---|
421 | verbosityLevel
|
---|
422 | );
|
---|
423 | }
|
---|
424 |
|
---|
425 | if (ProduceGraphic && debugPixel)
|
---|
426 | {
|
---|
427 | pixel[pixelID]->DrawTemplateHistograms(
|
---|
428 | cgpPixelPulses,
|
---|
429 | PixelCanvasFrameNrs
|
---|
430 | );
|
---|
431 |
|
---|
432 | pixel[pixelID]->DrawEdgeTemplateHistograms(
|
---|
433 | cgpPixelPulses,
|
---|
434 | PixelCanvasFrameNrs
|
---|
435 | );
|
---|
436 | }
|
---|
437 | //-------------------------------------
|
---|
438 | // Fill Histogramms of Camera
|
---|
439 | //-------------------------------------
|
---|
440 |
|
---|
441 | wholeCamera->hMaxOverlay[pulse_order]->Add(
|
---|
442 | pixel[pixelID]->hMaxOverlay[pulse_order]
|
---|
443 | );
|
---|
444 |
|
---|
445 | wholeCamera->hMaxProfile[pulse_order]->Add(
|
---|
446 | pixel[pixelID]->hMaxProfile[pulse_order]
|
---|
447 | );
|
---|
448 |
|
---|
449 | wholeCamera->hEdgeOverlay[pulse_order]->Add(
|
---|
450 | pixel[pixelID]->hEdgeOverlay[pulse_order]
|
---|
451 | );
|
---|
452 |
|
---|
453 | wholeCamera->hEdgeProfile[pulse_order]->Add(
|
---|
454 | pixel[pixelID]->hEdgeProfile[pulse_order]
|
---|
455 | );
|
---|
456 |
|
---|
457 |
|
---|
458 | if (verbosityLevel > 2)
|
---|
459 | {
|
---|
460 | cout << endl
|
---|
461 | << "...End of pulseorder "
|
---|
462 | << pulse_order
|
---|
463 | << endl;
|
---|
464 | }
|
---|
465 |
|
---|
466 | }
|
---|
467 | // End of Loop over pulsorder of current Pixel
|
---|
468 |
|
---|
469 | if (ProduceGraphic && debugPixel)
|
---|
470 | {
|
---|
471 | UpdateCanvases(
|
---|
472 | verbosityLevel,
|
---|
473 | MAX_PULS_ORDER,
|
---|
474 | false
|
---|
475 | );
|
---|
476 | }
|
---|
477 |
|
---|
478 | if (debugPixel)
|
---|
479 | {
|
---|
480 | //Process gui events asynchronously during input
|
---|
481 | cout << endl;
|
---|
482 | TTimer timer("gSystem->ProcessEvents();", 50, kFALSE);
|
---|
483 | timer.TurnOn();
|
---|
484 | TString input = Getline("Type 'q' to exit, <return> to go on: ");
|
---|
485 | timer.TurnOff();
|
---|
486 | if (input=="q\n")
|
---|
487 | {
|
---|
488 | break;
|
---|
489 | }
|
---|
490 | }
|
---|
491 | if ( saveResults )
|
---|
492 | {
|
---|
493 | pixel[pixelID]->SavePixelHistograms(
|
---|
494 | outFile,
|
---|
495 | saveResults
|
---|
496 | );
|
---|
497 | }
|
---|
498 |
|
---|
499 | //deleteCurrent Pixel from Heap
|
---|
500 | delete pixel[pixelID];
|
---|
501 | pixel[pixelID] = NULL;
|
---|
502 |
|
---|
503 | if (verbosityLevel > 2)
|
---|
504 | {
|
---|
505 | cout << endl
|
---|
506 | << "...End of Pixel"
|
---|
507 | << endl
|
---|
508 | << "------------------------------------------------"
|
---|
509 | << endl;
|
---|
510 | }
|
---|
511 | }
|
---|
512 | // End of Loop over all Pixels of set
|
---|
513 |
|
---|
514 | if (verbosityLevel > 1)
|
---|
515 | {
|
---|
516 | cout << endl
|
---|
517 | << "...End of Loop over all Pixels of set"
|
---|
518 | << endl
|
---|
519 | << "------------------------------------------------"
|
---|
520 | << endl;
|
---|
521 | }
|
---|
522 | }
|
---|
523 | // End of Loop over all Pixelsets
|
---|
524 |
|
---|
525 | if (verbosityLevel > 0)
|
---|
526 | {
|
---|
527 | cout << endl
|
---|
528 | << "...End of Loop over all Pixelsets"
|
---|
529 | << endl
|
---|
530 | << "------------------------------------------------"
|
---|
531 | << endl;
|
---|
532 | }
|
---|
533 |
|
---|
534 | delete[] pixel;
|
---|
535 | pixel = NULL;
|
---|
536 |
|
---|
537 | //-------------------------------------
|
---|
538 | // Draw All Pixel Histograms
|
---|
539 | //-------------------------------------
|
---|
540 |
|
---|
541 | for ( int pulse_order = 0 ;
|
---|
542 | pulse_order < wholeCamera->mMaxPulseOrder ;
|
---|
543 | pulse_order ++)
|
---|
544 | {
|
---|
545 | if (verbosityLevel > 2)
|
---|
546 | {
|
---|
547 | cout << "-------------------------------------"
|
---|
548 | << endl
|
---|
549 | << "...processing Pulse-Order: "
|
---|
550 | << pulse_order;
|
---|
551 | }
|
---|
552 |
|
---|
553 | // Calculate Max Prop. Value of each slice
|
---|
554 | //-------------------------------------
|
---|
555 |
|
---|
556 | //from Maximum Overlay
|
---|
557 | ExtractPulseTemplate(
|
---|
558 | wholeCamera,
|
---|
559 | "Maximum",
|
---|
560 | pulse_order,
|
---|
561 | verbosityLevel
|
---|
562 | );
|
---|
563 | if ( saveResults )
|
---|
564 | {
|
---|
565 | WritePixelTemplateToCsv(
|
---|
566 | wholeCamera,
|
---|
567 | OutPutPath,
|
---|
568 | "Maximum",
|
---|
569 | pulse_order,
|
---|
570 | verbosityLevel
|
---|
571 | );
|
---|
572 | }
|
---|
573 |
|
---|
574 | //from Edge Overlay
|
---|
575 | ExtractPulseTemplate(
|
---|
576 | wholeCamera,
|
---|
577 | "Edge",
|
---|
578 | pulse_order,
|
---|
579 | verbosityLevel
|
---|
580 | );
|
---|
581 | if ( saveResults )
|
---|
582 | {
|
---|
583 | WritePixelTemplateToCsv(
|
---|
584 | wholeCamera,
|
---|
585 | OutPutPath,
|
---|
586 | "Edge",
|
---|
587 | pulse_order,
|
---|
588 | verbosityLevel
|
---|
589 | );
|
---|
590 | }
|
---|
591 |
|
---|
592 | if (ProduceGraphic)
|
---|
593 | {
|
---|
594 | wholeCamera->DrawTemplateHistograms(
|
---|
595 | cgpPixelPulses,
|
---|
596 | AllpixelCanvasFrameNrs
|
---|
597 | );
|
---|
598 |
|
---|
599 | wholeCamera->DrawEdgeTemplateHistograms(
|
---|
600 | cgpPixelPulses,
|
---|
601 | AllpixelCanvasFrameNrs
|
---|
602 | );
|
---|
603 | }
|
---|
604 | } //EOF: Draw All Pixel Histograms
|
---|
605 |
|
---|
606 |
|
---|
607 | //-------------------------------------
|
---|
608 | // Save All Pixel Histograms
|
---|
609 | //-------------------------------------
|
---|
610 | if ( saveResults )
|
---|
611 | {
|
---|
612 | wholeCamera->SavePixelHistograms(
|
---|
613 | outFile,
|
---|
614 | saveResults
|
---|
615 | );
|
---|
616 | }
|
---|
617 |
|
---|
618 | if (ProduceGraphic)
|
---|
619 | {
|
---|
620 | UpdateCanvases(
|
---|
621 | verbosityLevel,
|
---|
622 | MAX_PULS_ORDER,
|
---|
623 | false
|
---|
624 | );
|
---|
625 |
|
---|
626 | //Process gui events asynchronously during input
|
---|
627 | cout << endl;
|
---|
628 | TTimer timer("gSystem->ProcessEvents();", 50, kFALSE);
|
---|
629 | timer.TurnOn();
|
---|
630 | TString input = Getline("press <return> to exit: ");
|
---|
631 | timer.TurnOff();
|
---|
632 | if (input=="q\n")
|
---|
633 | {
|
---|
634 | break;
|
---|
635 | }
|
---|
636 | }
|
---|
637 |
|
---|
638 | //-------------------------------------
|
---|
639 | // Delete Objects on Heap
|
---|
640 | //-------------------------------------
|
---|
641 | delete wholeCamera;
|
---|
642 | if (ProduceGraphic)
|
---|
643 | {
|
---|
644 | DeletePixelCanvases( maxPulseOrder ,verbosityLevel );
|
---|
645 | }
|
---|
646 | delete inputRootFile;
|
---|
647 | delete outputRootFile;
|
---|
648 |
|
---|
649 | return( 0 );
|
---|
650 | }
|
---|
651 | //----------------------------------------------------------------------------
|
---|
652 | // end of main function
|
---|
653 | //-----------------------------------------------------------------------------
|
---|
654 |
|
---|
655 |
|
---|
656 |
|
---|
657 |
|
---|
658 | //-----------------------------------------------------------------------------
|
---|
659 | // Funktions
|
---|
660 | //-----------------------------------------------------------------------------
|
---|
661 | void
|
---|
662 | DeletePixelCanvases(
|
---|
663 | int maxPulseOrder,
|
---|
664 | int verbosityLevel
|
---|
665 | )
|
---|
666 | {
|
---|
667 | if (verbosityLevel > 2)
|
---|
668 | {
|
---|
669 | cout << endl
|
---|
670 | << "...delete pixel Canvases"
|
---|
671 | << endl;
|
---|
672 | }
|
---|
673 |
|
---|
674 | for ( int pulse_order = 0; pulse_order < maxPulseOrder; pulse_order++ )
|
---|
675 | {
|
---|
676 | delete cgpPixelPulses[pulse_order];
|
---|
677 | cgpPixelPulses[pulse_order] = NULL;
|
---|
678 |
|
---|
679 | delete cgpDistributions[pulse_order];
|
---|
680 | cgpDistributions[pulse_order] = NULL;
|
---|
681 | }
|
---|
682 |
|
---|
683 | delete[] cgpPixelPulses;
|
---|
684 | cgpPixelPulses = NULL;
|
---|
685 |
|
---|
686 | delete[] cgpDistributions;
|
---|
687 | cgpDistributions = NULL;
|
---|
688 | }
|
---|
689 |
|
---|
690 | void
|
---|
691 | UpdateCanvases(
|
---|
692 | int verbosityLevel,
|
---|
693 | int max_pulse_order,
|
---|
694 | bool testmode
|
---|
695 | )
|
---|
696 | {
|
---|
697 | if (verbosityLevel > 3)
|
---|
698 | {
|
---|
699 | cout << endl << "...updating canvases" << endl;
|
---|
700 | }
|
---|
701 | for (int pulse_order = 0; pulse_order < max_pulse_order; pulse_order++)
|
---|
702 | {
|
---|
703 | cgpPixelPulses[pulse_order]->Modified();
|
---|
704 | cgpPixelPulses[pulse_order]->Update();
|
---|
705 |
|
---|
706 | cgpDistributions[pulse_order]->Modified();
|
---|
707 | cgpDistributions[pulse_order]->Update();
|
---|
708 | // if ( testmode )
|
---|
709 | // {
|
---|
710 | // cgpTestHistos->Modified();
|
---|
711 | // cgpTestHistos->Update();
|
---|
712 | // }
|
---|
713 | }
|
---|
714 | }
|
---|
715 | //-----------------------------------------------------------------------------
|
---|
716 | // MAIN Funktion for C compilation
|
---|
717 | //-----------------------------------------------------------------------------
|
---|
718 |
|
---|
719 | int main(int argc,char *argv[])
|
---|
720 | {
|
---|
721 | // Int_t index;
|
---|
722 | TString test;
|
---|
723 | TString rcFileName;
|
---|
724 | TString processType = "template";
|
---|
725 | bool rcFileNameCmdSet = false;
|
---|
726 | int verbLevel = 0; // different verbosity levels can be implemented here
|
---|
727 | bool verbLevelCmdSet = false;
|
---|
728 | bool save = false;
|
---|
729 | bool produceGraphic = false;
|
---|
730 |
|
---|
731 | // TString inputRootFile = "test.root";
|
---|
732 | // TString inputPath = "";
|
---|
733 | // TString outputRootFile = "test.root";
|
---|
734 | // TString outPutPath = "";
|
---|
735 | // int firstPixel = 0;
|
---|
736 | // int nPixel = -1;
|
---|
737 | // int pixelSetSize = 40;
|
---|
738 | // int maxOrder = 3;
|
---|
739 | // bool dbgPixel = false;
|
---|
740 | // bool fitdata = false;
|
---|
741 | // bool printStats = false;
|
---|
742 |
|
---|
743 | // decode arguments
|
---|
744 | if(argc < 2)
|
---|
745 | {
|
---|
746 | printf("no arguements given, using standard arguments\n");
|
---|
747 | }
|
---|
748 |
|
---|
749 | // set conditions for functions arguments
|
---|
750 | for (int i=1;i<argc;i++)
|
---|
751 | {
|
---|
752 | test = argv[i];
|
---|
753 |
|
---|
754 | if (test.Contains("--config-file") || test.Contains("-c"))
|
---|
755 | {
|
---|
756 | cout << "RC-File: \"" << argv[i + 1] << "\"" << endl;
|
---|
757 | rcFileName = argv[i + 1];
|
---|
758 | rcFileNameCmdSet = true;
|
---|
759 | continue;
|
---|
760 | }
|
---|
761 |
|
---|
762 | if (test.Contains("--verbosity") || test.Contains("-v"))
|
---|
763 | {
|
---|
764 | cout << "Verbosity Level: \"" << argv[i + 1] << "\"" << endl;
|
---|
765 | verbLevel = atoi(argv[i + 1]);
|
---|
766 | continue;
|
---|
767 | }
|
---|
768 |
|
---|
769 | if (test.Contains("--save") || test.Contains("-s"))
|
---|
770 | {
|
---|
771 | cout << "will save results" << endl;
|
---|
772 | save = true;
|
---|
773 | continue;
|
---|
774 | }
|
---|
775 |
|
---|
776 | if (test.Contains("--graphics") || test.Contains("-g"))
|
---|
777 | {
|
---|
778 | cout << "will produce graphics" << endl;
|
---|
779 | produceGraphic = true;
|
---|
780 | continue;
|
---|
781 | }
|
---|
782 | }
|
---|
783 |
|
---|
784 | // reading rc-File:
|
---|
785 | if (rcFileNameCmdSet)
|
---|
786 | {
|
---|
787 | configfile rcfile( rcFileName, processType );
|
---|
788 |
|
---|
789 | if (save)
|
---|
790 | {
|
---|
791 | rcfile.mSave = save;
|
---|
792 | }
|
---|
793 |
|
---|
794 | if (verbLevelCmdSet)
|
---|
795 | {
|
---|
796 | rcfile.mVerbLevel = verbLevel;
|
---|
797 | }
|
---|
798 |
|
---|
799 | if (produceGraphic)
|
---|
800 | {
|
---|
801 | rcfile.mProduceGraphic = produceGraphic;
|
---|
802 | }
|
---|
803 |
|
---|
804 | //
|
---|
805 | FCalcPulseTemplate(
|
---|
806 | rcfile.mInputFile,
|
---|
807 | rcfile.mInputPath,
|
---|
808 | rcfile.mOutputFile,
|
---|
809 | rcfile.mOutputPath,
|
---|
810 | rcfile.mFirstPixel,
|
---|
811 | rcfile.mNumPixel,
|
---|
812 | rcfile.mPixelSetSize,
|
---|
813 | rcfile.mMaxOrder,
|
---|
814 | rcfile.mHistoOptions,
|
---|
815 | rcfile.mProduceGraphic,
|
---|
816 | rcfile.mPrintStats,
|
---|
817 | rcfile.mSave,
|
---|
818 | rcfile.mDbgPixel,
|
---|
819 | rcfile.mVerbLevel
|
---|
820 | );
|
---|
821 | }
|
---|
822 | else
|
---|
823 | {
|
---|
824 | cout << "user: check if configfile is set correctly in cmd" << endl;
|
---|
825 | }
|
---|
826 |
|
---|
827 | return 0;
|
---|
828 | }
|
---|