1 | /* ======================================================================== *\
|
---|
2 | !
|
---|
3 | ! *
|
---|
4 | ! * This file is part of MARS, the MAGIC Analysis and Reconstruction
|
---|
5 | ! * Software. It is distributed to you in the hope that it can be a useful
|
---|
6 | ! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
|
---|
7 | ! * It is distributed WITHOUT ANY WARRANTY.
|
---|
8 | ! *
|
---|
9 | ! * Permission to use, copy, modify and distribute this software and its
|
---|
10 | ! * documentation for any purpose is hereby granted without fee,
|
---|
11 | ! * provided that the above copyright notice appear in all copies and
|
---|
12 | ! * that both that copyright notice and this permission notice appear
|
---|
13 | ! * in supporting documentation. It is provided "as is" without express
|
---|
14 | ! * or implied warranty.
|
---|
15 | ! *
|
---|
16 | !
|
---|
17 | !
|
---|
18 | ! Author(s): Thomas Bretz, 11/2005 <mailto:tbretz@astro.uni-wuerzburg.de>
|
---|
19 | ! Author(s): Daniela Dorner, 11/2005 <mailto:dorner@astro.uni-wuerzburg.de>
|
---|
20 | ! Author(s): Daniel Hoehne, 05/2007 <mailto:hoehne@astro.uni-wuerzburg.de>
|
---|
21 | !
|
---|
22 | ! Copyright: MAGIC Software Development, 2000-2007
|
---|
23 | !
|
---|
24 | !
|
---|
25 | \* ======================================================================== */
|
---|
26 |
|
---|
27 | /////////////////////////////////////////////////////////////////////////////
|
---|
28 | //
|
---|
29 | // fillcamera.C
|
---|
30 | // ============
|
---|
31 | //
|
---|
32 | // This macro is used to read the camera-output files.
|
---|
33 | //
|
---|
34 | // Make sure, that database and password are corretly set in a resource
|
---|
35 | // file called sql.rc and the resource file is found.
|
---|
36 | //
|
---|
37 | // Returns 0 in case of failure and 1 in case of success.
|
---|
38 | //
|
---|
39 | //
|
---|
40 | // At the moment the macro works but produces a segmentation violation.
|
---|
41 | //
|
---|
42 | //
|
---|
43 | /////////////////////////////////////////////////////////////////////////////
|
---|
44 | #include <iostream>
|
---|
45 | #include <iomanip>
|
---|
46 |
|
---|
47 | #include <TEnv.h>
|
---|
48 | #include <TRegexp.h>
|
---|
49 |
|
---|
50 | #include <TFile.h>
|
---|
51 | #include <TTree.h>
|
---|
52 | #include <TBranch.h>
|
---|
53 |
|
---|
54 | #include <TH1.h>
|
---|
55 |
|
---|
56 | #include <TSQLResult.h>
|
---|
57 | #include <TSQLRow.h>
|
---|
58 |
|
---|
59 | #include "MSQLServer.h"
|
---|
60 | #include "MSQLMagic.h"
|
---|
61 | #include "MGeomCamMagic.h"
|
---|
62 |
|
---|
63 | #include "MMcRunHeader.hxx"
|
---|
64 | #include "MMcConfigRunHeader.h"
|
---|
65 | #include "MMcCorsikaRunHeader.h"
|
---|
66 | #include "MMcFadcHeader.hxx"
|
---|
67 | #include "MMcEvtBasic.h"
|
---|
68 | #include "MGeomCamMagic.h"
|
---|
69 | #include "MRawRunHeader.h"
|
---|
70 |
|
---|
71 | #include <math.h>
|
---|
72 | #include <MBinning.h>
|
---|
73 |
|
---|
74 | using namespace std;
|
---|
75 | // --------------------------------------------------------------------------
|
---|
76 | //
|
---|
77 | // Checks whether an entry is already existing
|
---|
78 | //
|
---|
79 | Bool_t ExistStr(MSQLServer &serv, const char *column, const char *table, Int_t test)
|
---|
80 | {
|
---|
81 | TString query(Form("SELECT %s FROM %s WHERE %s='%d'", column, table, column, test));
|
---|
82 | TSQLResult *res = serv.Query(query);
|
---|
83 | if (!res)
|
---|
84 | return kFALSE;
|
---|
85 |
|
---|
86 | TSQLRow *row;
|
---|
87 |
|
---|
88 | Bool_t rc = kFALSE;
|
---|
89 | while ((row=res->Next()))
|
---|
90 | {
|
---|
91 | if ((*row)[0])
|
---|
92 | {
|
---|
93 | rc = kTRUE;
|
---|
94 | break;
|
---|
95 | }
|
---|
96 | }
|
---|
97 |
|
---|
98 | delete res;
|
---|
99 |
|
---|
100 | return rc;
|
---|
101 | }
|
---|
102 | /*
|
---|
103 | //
|
---|
104 | // Function to transform zenithangle range to zbin (not needed any more)
|
---|
105 | //
|
---|
106 | Double_t ThetaToZBin(Double_t tmin, Double_t tmax)
|
---|
107 | {
|
---|
108 | double result=TMath::Nint(100*(1-TMath::Cos(((tmin+tmax)/2)*TMath::DegToRad())));
|
---|
109 | return result;
|
---|
110 | }
|
---|
111 | */
|
---|
112 |
|
---|
113 | //int Process(MSQLServer &serv, TString fname, Bool_t dummy)
|
---|
114 | int Process(MSQLMagic &serv, TString fname, Bool_t dummy)
|
---|
115 | {
|
---|
116 | TFile file(fname, "READ");
|
---|
117 | if (!file.IsOpen())
|
---|
118 | {
|
---|
119 | cout << "ERROR - Could not find file " << fname << endl;
|
---|
120 | return 0;
|
---|
121 | }
|
---|
122 |
|
---|
123 | //
|
---|
124 | // Get tree RunHeaders from file
|
---|
125 | //
|
---|
126 | TTree *tree = dynamic_cast<TTree*>(file.Get("RunHeaders"));
|
---|
127 | if (!tree)
|
---|
128 | {
|
---|
129 | cout << "ERROR - Tree RunHeaders not found in file " << fname << endl;
|
---|
130 | return 0;
|
---|
131 | }
|
---|
132 | //
|
---|
133 | // Get branch MMcCorsikaRunHeader from tree RunHeaders
|
---|
134 | //
|
---|
135 | TBranch *b1 = tree->GetBranch("MMcCorsikaRunHeader.");
|
---|
136 | if (!b1)
|
---|
137 | {
|
---|
138 | cout << "ERROR - Branch MMcCorsikaRunHeader. not found in file " << fname << endl;
|
---|
139 | return 0;
|
---|
140 | }
|
---|
141 |
|
---|
142 | MMcCorsikaRunHeader *runheader1 = new MMcCorsikaRunHeader();
|
---|
143 | b1->SetAddress(&runheader1);
|
---|
144 | //
|
---|
145 | // Get branch MMcConfigRunHeader from tree RunHeaders
|
---|
146 | //
|
---|
147 | TBranch *b2 = tree->GetBranch("MMcConfigRunHeader.");
|
---|
148 | if (!b2)
|
---|
149 | {
|
---|
150 | cout << "ERROR - Branch MMcConfigRunHeader. not found in file " << fname << endl;
|
---|
151 | return 0;
|
---|
152 | }
|
---|
153 |
|
---|
154 | MMcConfigRunHeader *runheader2 = new MMcConfigRunHeader();
|
---|
155 | b2->SetAddress(&runheader2);
|
---|
156 | //
|
---|
157 | // Get branch MMcRunHeader from tree RunHeaders
|
---|
158 | //
|
---|
159 | TBranch *b3 = tree->GetBranch("MMcRunHeader.");
|
---|
160 | if (!b3)
|
---|
161 | {
|
---|
162 | cout << "ERROR - Branch MMcRunHeader. not found in file " << fname << endl;
|
---|
163 | return 0;
|
---|
164 | }
|
---|
165 |
|
---|
166 | MMcRunHeader *runheader3 = new MMcRunHeader();
|
---|
167 | b3->SetAddress(&runheader3);
|
---|
168 | //
|
---|
169 | // Get branch MMcFadcRunHeader from tree RunHeaders
|
---|
170 | //
|
---|
171 | TBranch *b4 = tree->GetBranch("MMcFadcHeader.");
|
---|
172 | if (!b4)
|
---|
173 | {
|
---|
174 | cout << "ERROR - Branch MMcFadcHeader. not found in file " << fname << endl;
|
---|
175 | return 0;
|
---|
176 | }
|
---|
177 |
|
---|
178 | MMcFadcHeader *fadcheader = new MMcFadcHeader();
|
---|
179 | b4->SetAddress(&fadcheader);
|
---|
180 | //
|
---|
181 | // Get branch MRawRunHearder from tree RunHeaders
|
---|
182 | //
|
---|
183 | TBranch *b5 = tree->GetBranch("MRawRunHeader.");
|
---|
184 | if (!b5)
|
---|
185 | {
|
---|
186 | cout << "ERROR - Branch MRawRunHeader. not found in file " << fname << endl;
|
---|
187 | return 0;
|
---|
188 | }
|
---|
189 |
|
---|
190 | MRawRunHeader *rawheader = new MRawRunHeader();
|
---|
191 | b5->SetAddress(&rawheader);
|
---|
192 |
|
---|
193 | tree->GetEvent(0);
|
---|
194 | //
|
---|
195 | // Get tree Events from file
|
---|
196 | //
|
---|
197 | TTree *tree2 = dynamic_cast<TTree*>(file.Get("Events"));
|
---|
198 | if (!tree2)
|
---|
199 | {
|
---|
200 | cout << "ERROR - Tree Events not found in file " << fname << endl;
|
---|
201 | return 0;
|
---|
202 | }
|
---|
203 | //
|
---|
204 | // Get branch MMcEvtBasic from tree Events
|
---|
205 | //
|
---|
206 | TBranch *b6 = tree2->GetBranch("MMcEvtBasic.");
|
---|
207 | if (!b6)
|
---|
208 | {
|
---|
209 | cout << "ERROR - Branch MMcEvtBasic. not found in file " << fname << endl;
|
---|
210 | return 0;
|
---|
211 | }
|
---|
212 |
|
---|
213 | MMcEvtBasic *evtbasic = new MMcEvtBasic();
|
---|
214 | b6->SetAddress(&evtbasic);
|
---|
215 |
|
---|
216 | tree2->GetEvent(0);
|
---|
217 |
|
---|
218 |
|
---|
219 |
|
---|
220 | Float_t emin = runheader1->GetELowLim();
|
---|
221 | TString elow = Form("%5.1f",emin);
|
---|
222 | Float_t emax = runheader1->GetEUppLim();
|
---|
223 | TString eupp = Form("%5.1f",emax);
|
---|
224 |
|
---|
225 | Float_t slopespec = runheader1->GetSlopeSpec();
|
---|
226 | TString slope = Form("%5.1f",slopespec);
|
---|
227 |
|
---|
228 | Float_t wobblemode = runheader1->GetWobbleMode();
|
---|
229 | TString wobble = Form("%5.0f",wobblemode);
|
---|
230 |
|
---|
231 | Float_t corsvers1 = runheader1->GetCorsikaVersion();
|
---|
232 | TString corsika1 = Form("%5.0f",corsvers1);
|
---|
233 |
|
---|
234 | Float_t pointspread = runheader2->GetPointSpread();
|
---|
235 | TString psf = Form("%5.1f",pointspread);
|
---|
236 | Float_t pointspreadx = runheader2->GetPointSpreadX();
|
---|
237 | TString psfx = Form("%5.2f",pointspreadx);
|
---|
238 | Float_t pointspready = runheader2->GetPointSpreadY();
|
---|
239 | TString psfy = Form("%5.2f",pointspready);
|
---|
240 | Float_t pointspreadadd = TMath::Hypot(runheader2->GetPointSpreadX(), runheader2->GetPointSpread());
|
---|
241 | TString psfadd = Form("%5.2f",pointspreadadd);
|
---|
242 |
|
---|
243 | Float_t mispointingx = runheader2->GetMissPointingX();
|
---|
244 | TString misx = Form("%5.2f",mispointingx);
|
---|
245 | Float_t mispointingy = runheader2->GetMissPointingY();
|
---|
246 | TString misy = Form("%5.2f",mispointingy);
|
---|
247 |
|
---|
248 | Float_t reflvers = runheader3->GetReflVersion();
|
---|
249 | TString reflector = Form("%5.0f",reflvers);
|
---|
250 | Float_t camvers = runheader3->GetCamVersion();
|
---|
251 | TString camera = Form("%5.0f",camvers);
|
---|
252 |
|
---|
253 | Float_t impactmax = runheader3->GetImpactMax();
|
---|
254 | TString imax = Form("%5.1f",impactmax);
|
---|
255 |
|
---|
256 | TH1I h("myhist", "", 1, -0.5, 0.5);
|
---|
257 | tree2->Draw("MRawEvtData.GetNumPixels()>>myhist", "", "goff");
|
---|
258 | h.SetDirectory(0);
|
---|
259 | UInt_t numtriggers = TMath::Nint(h.GetBinContent(2));
|
---|
260 | TString numtrig = Form("%7.0i",numtriggers);
|
---|
261 |
|
---|
262 | UInt_t numsimshow = runheader3->GetNumSimulatedShowers();
|
---|
263 | TString numss = Form("%7.0i",numsimshow);
|
---|
264 | UInt_t numevents = tree2->GetEntries();
|
---|
265 | TString numevt = Form("%7.0i",numevents);
|
---|
266 |
|
---|
267 | Float_t numphednsb = runheader3->GetNumPheFromDNSB();
|
---|
268 | TString numphe = Form("%5.1f",numphednsb);
|
---|
269 |
|
---|
270 | Float_t pedestal = fadcheader->GetPedestal(1);
|
---|
271 | TString ped = Form("%5.1f",pedestal);
|
---|
272 | Float_t low2highgain = fadcheader->GetLow2HighGain();
|
---|
273 | TString low2high = Form("%5.1f",low2highgain);
|
---|
274 |
|
---|
275 | Float_t amplitude = fadcheader->GetAmplitud();
|
---|
276 | TString amplfadc = Form("%5.1f",amplitude);
|
---|
277 | Float_t amplitudo = fadcheader->GetAmplitudOuter();
|
---|
278 | TString amplfadco = Form("%5.1f",amplitudo);
|
---|
279 |
|
---|
280 | Float_t elecnoise = fadcheader->GetElecNoise(1);
|
---|
281 | TString enoise = Form("%5.1f",elecnoise);
|
---|
282 | Float_t diginoise = fadcheader->GetDigitalNoise(1);
|
---|
283 | TString dnoise = Form("%5.1f",diginoise);
|
---|
284 |
|
---|
285 | Float_t phimin = runheader3->GetShowerPhiMin();
|
---|
286 | TString pmin = Form("%5.1f",phimin);
|
---|
287 | Float_t phimax = runheader3->GetShowerPhiMax();
|
---|
288 | TString pmax = Form("%5.1f",phimax);
|
---|
289 |
|
---|
290 | Float_t particleid = evtbasic->GetPartId();
|
---|
291 | TString partid = Form("%5.0f",particleid);
|
---|
292 | TString partname = evtbasic->GetParticleName();
|
---|
293 | // TString partname = Form("%5.1f",particlename);
|
---|
294 |
|
---|
295 | Double_t tmin = runheader3->GetShowerThetaMin();
|
---|
296 | TString thetamin = Form("%5.1f",tmin);
|
---|
297 | Double_t tmax = runheader3->GetShowerThetaMax();
|
---|
298 | TString thetamax = Form("%5.1f",tmax);
|
---|
299 |
|
---|
300 | Float_t mirrorfraction = runheader2->GetMirrorFraction();
|
---|
301 | TString mirrfrac = Form("%5.2f",mirrorfraction);
|
---|
302 | // Float_t reflectivity = runheader2->GetMirrors()->GetReflectivity()->GetArray();
|
---|
303 | // TString refl = Form("%5.2f",reflectivity);
|
---|
304 |
|
---|
305 |
|
---|
306 | //workaround for getting the spotsize in cm from PointSpreadX (for path)
|
---|
307 | /*
|
---|
308 | Double_t psfx=runheader2->GetPointSpreadX();
|
---|
309 | cout << "psfx=" << psfx << endl;
|
---|
310 | psfx=psfx*10;
|
---|
311 | Int_t psfxint= (int) psfx;
|
---|
312 | psfx=psfxint;
|
---|
313 | psfx=psfx/10;
|
---|
314 | cout << "PSF for path=" << psfx << endl;
|
---|
315 | */
|
---|
316 |
|
---|
317 |
|
---|
318 |
|
---|
319 |
|
---|
320 | /*
|
---|
321 | // Bestimmung von fakewobble aus file
|
---|
322 | // Kombination aus Wobble(0,1) und MissPoint
|
---|
323 | TString WobbleMod;
|
---|
324 |
|
---|
325 | if (wobblemode != 0){
|
---|
326 | WobbleMod = "wobble";
|
---|
327 | }
|
---|
328 | else
|
---|
329 | {
|
---|
330 | if (mispointingx == 0 && mispointingy == 0){
|
---|
331 | WobbleMod = "nowobble";
|
---|
332 | }
|
---|
333 | else{
|
---|
334 | WobbleMod = "fakewobble";
|
---|
335 | }
|
---|
336 | }
|
---|
337 | */
|
---|
338 | /* Bestimmung von fakewobble aus file */
|
---|
339 | /* Kombination aus Wobble(0,1) und MissPoint */
|
---|
340 | TString WobbleMod;
|
---|
341 |
|
---|
342 | if (wobblemode == 1){
|
---|
343 | WobbleMod = "Wobble";
|
---|
344 | }
|
---|
345 | else
|
---|
346 | {
|
---|
347 | if (mispointingx == 0 && mispointingy == 0){
|
---|
348 | WobbleMod = "On";
|
---|
349 | }
|
---|
350 | else{
|
---|
351 | WobbleMod = "Fake Wobble"; // als ObservationModeKEY 4 einfügen?
|
---|
352 | }
|
---|
353 | }
|
---|
354 |
|
---|
355 | Float_t pointsfx=TMath::Floor(pointspreadx*10);
|
---|
356 | pointsfx=TMath::Nint(pointsfx);
|
---|
357 | TString pointsfuncx=Form("%5.1f",pointsfx);
|
---|
358 |
|
---|
359 | // Float_t cos1=TMath::DegToRad(tmin);
|
---|
360 | // Float_t cos2=TMath::DegToRad(tmax);
|
---|
361 | Float_t zBin=TMath::Nint((1-((TMath::Cos(tmin*TMath::Pi()/180)+TMath::Cos(tmax*TMath::Pi()/180))/2))*100);
|
---|
362 | zBin=TMath::Nint(zBin);
|
---|
363 |
|
---|
364 | // folgende Werte werden aus dem Pfadnamen gewonnen !!!neue Pfadstuktur!!!
|
---|
365 | // RunNumber
|
---|
366 | TRegexp reg2("_[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]_");
|
---|
367 | TString Run = fname(reg2);
|
---|
368 | Int_t RunNum = atoi(Run.Data()+1);
|
---|
369 |
|
---|
370 | if (RunNum < 1 || RunNum > 99999)
|
---|
371 | {
|
---|
372 | cout << "ERROR - RunNumber wrong value" << endl;
|
---|
373 | return 0;
|
---|
374 | }
|
---|
375 |
|
---|
376 | // PointSpreadFunction
|
---|
377 | TRegexp reg4("/[12][0-9]/");
|
---|
378 | TString pointsf = fname(reg4);
|
---|
379 | Int_t Point = atoi(pointsf.Data()+1);
|
---|
380 |
|
---|
381 | if (Point < 0 || Point > 99)
|
---|
382 | {
|
---|
383 | cout << "ERROR - PointSpreadFunction wrong value" << endl;
|
---|
384 |
|
---|
385 | return 0;
|
---|
386 | }
|
---|
387 |
|
---|
388 | // zbin
|
---|
389 | TRegexp reg1("/19[0-9][0-9]/");
|
---|
390 | TString zbin = fname(reg1);
|
---|
391 | Int_t ZBin = atoi(zbin.Data()+3);
|
---|
392 |
|
---|
393 | if (ZBin < 0 || ZBin > 99)
|
---|
394 | {
|
---|
395 | cout << "ERROR - zbin wrong value" << endl;
|
---|
396 | return 0;
|
---|
397 | }
|
---|
398 |
|
---|
399 | // WobbleMode
|
---|
400 | TRegexp reg3("/0[0-9]/"); /*extrahiert '/0X' mit X= 1-8 */
|
---|
401 | TString WM = fname(reg3); /* weist WM den extrahierten Wert zu */
|
---|
402 | Int_t Wob = atoi(WM.Data()+1); /* schneidet fuehrenden '/' ab */
|
---|
403 |
|
---|
404 | if (Wob < 1 || Wob > 8)
|
---|
405 | {
|
---|
406 | cout << "ERROR - ObservationMode wrong value" << endl;
|
---|
407 | return 0;
|
---|
408 | }
|
---|
409 |
|
---|
410 |
|
---|
411 | /* wandelt numerischen Wert in WobbleModus Bezeichnung um */
|
---|
412 |
|
---|
413 | const TString wobbleModes[] = {
|
---|
414 | "", // 0 wird nicht verwendet, daher ein leeres Feld
|
---|
415 | "Gammawobble+",
|
---|
416 | "Gammanowobble0",
|
---|
417 | "GammawobbleHE+",
|
---|
418 | "GammanowobbleHE0",
|
---|
419 | "Gammawobble0",
|
---|
420 | "GammawobbleHE0",
|
---|
421 | "Gammadiffuse0"
|
---|
422 | "Protonnowobble0",
|
---|
423 | };
|
---|
424 |
|
---|
425 | /* Umrechnung von WobbleModus Bezeichnung in 'wobble', 'nowobble', 'fakewobble' */
|
---|
426 | TString WobMode; /* dieser Wert wird in 'MCDB' Tabelle 'WobbleMode' eingetragen */
|
---|
427 |
|
---|
428 | if (Wob == 1 || Wob == 3){
|
---|
429 | WobMode = "Wobble";
|
---|
430 | }
|
---|
431 | if (Wob == 2 || Wob == 4 || Wob == 7 || Wob == 8){
|
---|
432 | WobMode = "On";
|
---|
433 | }
|
---|
434 | if (Wob == 5 || Wob == 6){
|
---|
435 | WobMode = "Fake Wobble";
|
---|
436 | }
|
---|
437 |
|
---|
438 |
|
---|
439 | /* MGeomCamMagic m;
|
---|
440 | cout << fadcheader->GetAmplitud() << endl;
|
---|
441 | cout << fadcheader->GetCameraMean(m, 0)<< endl;
|
---|
442 | cout << fadcheader->GetCameraMean(m, 1)<< endl;
|
---|
443 | */
|
---|
444 |
|
---|
445 | cout << "File " << fname << endl;
|
---|
446 |
|
---|
447 |
|
---|
448 | cout << endl;
|
---|
449 | cout << endl;
|
---|
450 |
|
---|
451 | cout << "--- From File ---" << endl;
|
---|
452 |
|
---|
453 | // cout << wobblemode << endl;
|
---|
454 | // cout << wobble << endl;
|
---|
455 | cout << endl;
|
---|
456 | cout << elow << " < E < " << eupp << endl;
|
---|
457 | cout << "SpectralIndex " << slope << endl;
|
---|
458 | cout << "WobbleMode " << WobbleMod << endl;
|
---|
459 | cout << "ObservationMode " << WobbleMod << endl;
|
---|
460 | cout << "CorsikaVer " << corsika1 << endl;
|
---|
461 | cout << "ReflVer " << reflector << endl;
|
---|
462 | cout << "CamVer " << camera << endl;
|
---|
463 | cout << "ParticleId " << partid << endl;
|
---|
464 | cout << "ParticleName " << partname << endl;
|
---|
465 | cout << "PointSpread " << psf << endl;
|
---|
466 | cout << "PointSpreadXY " << psfx << " /" << psfy << endl;
|
---|
467 | cout << "AdditionPSF " << psfadd << endl;
|
---|
468 | cout << "MispointingXY " << misx << " /" << misy <<endl;
|
---|
469 | cout << "NumSimShowers " << numss << endl;
|
---|
470 | cout << "ImpactMax " << imax << endl;
|
---|
471 | cout << "NumEvents " << numevt << endl;
|
---|
472 | cout << "NumTriggers " << numtrig << endl;
|
---|
473 | cout << "NumPheFromDNSB " << numphe << endl;
|
---|
474 | cout << "Pedestal " << ped << endl;
|
---|
475 | cout << "Low2HighGain " << low2high << endl;
|
---|
476 | cout << "AmplitudeFADC " << amplfadc << endl;
|
---|
477 | cout << "AmplFADCOuter " << amplfadco << endl;
|
---|
478 | cout << "ElecNoise " << enoise << endl;
|
---|
479 | cout << "DigiNoise " << dnoise << endl;
|
---|
480 | cout << "PhiMin " << pmin << endl;
|
---|
481 | cout << "PhiMax " << pmax << endl;
|
---|
482 | cout << "ThetaMin " << thetamin << endl;
|
---|
483 | cout << "ThetaMax " << thetamax << endl;
|
---|
484 |
|
---|
485 | // cout << "Zenith range=" << runheader3->GetShowerThetaMin() << "to" << runheader3->GetShowerThetaMax() << endl;
|
---|
486 | cout << "Zenith range " << tmin << " to " << tmax << endl;
|
---|
487 |
|
---|
488 | // cout << "zbin " << ThetaToZBin(tmin,tmax) << endl;
|
---|
489 |
|
---|
490 | cout << "MirrorFraction " << mirrfrac << endl;
|
---|
491 | // cout << "Reflectivity " << refl << endl;
|
---|
492 |
|
---|
493 | cout << endl;
|
---|
494 | cout << endl;
|
---|
495 | cout << "--- key's from mcdb tables ---" << endl;
|
---|
496 | cout << endl;
|
---|
497 |
|
---|
498 |
|
---|
499 | // Int_t corsikakey = QueryNameKEY(serv, dummy, "CorsikaVersion", Form("%d",CorVer));
|
---|
500 |
|
---|
501 | // Int_t corsikakey = QueryNameKEY(serv, dummy, "CorsikaVersion", corsika1.Data());
|
---|
502 | Int_t corsikakey = serv.QueryKeyOfName("CorsikaVersion", corsika1.Data());
|
---|
503 | cout << "corsikakey: " << corsikakey << endl;
|
---|
504 |
|
---|
505 | // Int_t reflectorkey = QueryNameKEY(serv, dummy, "ReflectorVersion", reflector.Data());
|
---|
506 | Int_t reflectorkey = serv.QueryKeyOfName("ReflectorVersion", reflector.Data());
|
---|
507 | cout << "reflectorkey: " << reflectorkey << endl;
|
---|
508 |
|
---|
509 | // Int_t camerakey = QueryNameKEY(serv, dummy, "CameraVersion", camera.Data());
|
---|
510 | Int_t camerakey = serv.QueryKeyOfName("CameraVersion", camera.Data());
|
---|
511 | cout << "camerakey: " << camerakey << endl;
|
---|
512 |
|
---|
513 | // Int_t wobblekey = QueryNameKEY(serv, dummy, "WobbleMode",Form("%s",WobbleMod.Data()));
|
---|
514 | Int_t wobblekey = serv.QueryKeyOfName("WobbleMode", WobbleMod.Data());
|
---|
515 | cout << "wobblekey: " << wobblekey << endl;
|
---|
516 |
|
---|
517 | // Int_t observationkey = QueryNameKEY(serv, dummy, "ObservationMode",Form("%s",WobbleMod.Data()));
|
---|
518 | Int_t observationkey = serv.QueryKeyOfName("ObservationMode", WobbleMod.Data());
|
---|
519 | cout << "observationkey: " << observationkey << endl;
|
---|
520 |
|
---|
521 | // Int_t particlekey = QueryNameKEY(serv, dummy, "MCParticle", Form("%s",partname.Data()));
|
---|
522 | Int_t particlekey = serv.QueryKeyOfName("MCParticle", partname.Data());
|
---|
523 | cout << "particlekey: " << particlekey << endl;
|
---|
524 | cout << endl;
|
---|
525 | cout << endl;
|
---|
526 |
|
---|
527 | // TRegexp reg1("/Spot_[0123456789.]*/");
|
---|
528 | // TRegexp reg2("/[a-zA-Z]*wobble[a-zA-Z]*/");
|
---|
529 | // TRegexp reg3("_zbin[0-9]+_");
|
---|
530 |
|
---|
531 | cout << "--- From File ---" << endl;
|
---|
532 | cout << endl;
|
---|
533 | cout << "WobbleMode " << WobbleMod << endl;
|
---|
534 | cout << "PSF " << pointsfuncx << endl;
|
---|
535 | cout << "zBin " << zBin << endl;
|
---|
536 | cout << endl;
|
---|
537 | cout << "--- From FileName ---" << endl;
|
---|
538 | cout << endl;
|
---|
539 | cout << "WobbleMode " << WobMode << endl;
|
---|
540 | cout << "RunNum " << RunNum << endl;
|
---|
541 | cout << "PSF " << Point << endl;
|
---|
542 | cout << "ZBin " << ZBin << endl;
|
---|
543 | cout << "WobbleMode(Pfad) " << Wob << endl;
|
---|
544 | cout << endl;
|
---|
545 | cout << "--- Check ---" << endl;
|
---|
546 | cout << endl;
|
---|
547 |
|
---|
548 | if (WobbleMod!=WobMode){
|
---|
549 | cout << "Error, WobbleMode in file and filename are not the same" << endl;
|
---|
550 | return 0;
|
---|
551 | }
|
---|
552 | else{
|
---|
553 | cout << "WobbleMode correct" << endl;
|
---|
554 | }
|
---|
555 | if (pointsfx!=Point){
|
---|
556 | cout << "Error, PSF in file and filename are not the same" << endl;
|
---|
557 | return 0;
|
---|
558 | }
|
---|
559 | else{
|
---|
560 | cout << "PSF correct" << endl;
|
---|
561 | }
|
---|
562 | if (zBin!=ZBin){
|
---|
563 | cout << "Error, ZBin in file and filename are not the same" << endl;
|
---|
564 | return 0;
|
---|
565 | }
|
---|
566 | else{
|
---|
567 | cout << "ZBin correct" << endl;
|
---|
568 | }
|
---|
569 |
|
---|
570 | delete runheader1;
|
---|
571 | delete runheader2;
|
---|
572 | delete runheader3;
|
---|
573 | delete fadcheader;
|
---|
574 | delete rawheader;
|
---|
575 | delete evtbasic;
|
---|
576 |
|
---|
577 |
|
---|
578 | TString query;
|
---|
579 |
|
---|
580 | if (!ExistStr(serv, "fRunNumber", "MCRunData", RunNum ))
|
---|
581 | {
|
---|
582 | query = Form(" INSERT INTO MCRunData SET"
|
---|
583 | " fELowLim=%s,"
|
---|
584 | " fEUppLim=%s, "
|
---|
585 | " fSlopeSpec=%s, "
|
---|
586 | " fImpactMax=%s, "
|
---|
587 | " fNumSimulatedShowers=%d, "
|
---|
588 | " fNumEvents=%d, "
|
---|
589 | " fNumPheFromDNSB=%s, "
|
---|
590 | " fzbin=%d, "
|
---|
591 | " fThetaMin=%s, "
|
---|
592 | " fThetaMax=%s, "
|
---|
593 | " fPointSpread=%s, "
|
---|
594 | " fPointSpreadX=%s, "
|
---|
595 | " fPointSpreadY=%s, "
|
---|
596 | " fPedesMean=%s, "
|
---|
597 | " fLow2HighGain=%s, "
|
---|
598 | " fAmplFadc=%s, "
|
---|
599 | " fAmplFadcOuter=%s, "
|
---|
600 | " fElectricNoise=%s, "
|
---|
601 | " fDigitalNoise=%s, "
|
---|
602 | " fRunNumber=%d, "
|
---|
603 | " fMisspointingX=%s, "
|
---|
604 | " fMissPointingY=%s, "
|
---|
605 | " fCorsikaVersionKEY =%d, "
|
---|
606 | " fReflectorVersionKEY=%d, "
|
---|
607 | " fCameraVersionKEY=%d, "
|
---|
608 | " fWobbleModeKEY=%d, "
|
---|
609 | " fObservationModeKEY=%d, "
|
---|
610 | " fMCParticleKEY=%d, "
|
---|
611 | " fSequenceFirst=0 ",
|
---|
612 | elow.Data(), eupp.Data(), slope.Data(), imax.Data(), numsimshow, numevents, numphe.Data(),
|
---|
613 | zBin, thetamin.Data(), thetamax.Data(), psf.Data(), psfx.Data(), psfy.Data(), ped.Data(), low2high.Data(),
|
---|
614 | amplfadc.Data(), amplfadco.Data(), enoise.Data(), dnoise.Data(), RunNum,
|
---|
615 | misx.Data(), misy.Data(), corsikakey, reflectorkey, camerakey, wobblekey, observationkey, particlekey );
|
---|
616 |
|
---|
617 | }
|
---|
618 |
|
---|
619 | //
|
---|
620 | // not yet implemented
|
---|
621 | //
|
---|
622 |
|
---|
623 | /*
|
---|
624 | if (!ExistStr(serv, "fRunNumber", "MCRunData", RunNum ))
|
---|
625 | {
|
---|
626 | query = Form(" fELowLim=%s,"
|
---|
627 | " fEUppLim=%s, "
|
---|
628 | " fSlopeSpec=%s, "
|
---|
629 | " fImpactMax=%s, "
|
---|
630 | " fNumSimulatedShowers=%d, "
|
---|
631 | " fNumEvents=%d, "
|
---|
632 | " fNumPheFromDNSB=%s, "
|
---|
633 | " fzbin=%d, "
|
---|
634 | " fThetaMin=%s, "
|
---|
635 | " fThetaMax=%s, "
|
---|
636 | " fPointSpread=%s, "
|
---|
637 | " fPointSpreadX=%s, "
|
---|
638 | " fPointSpreadY=%s, "
|
---|
639 | " fPedesMean=%s, "
|
---|
640 | " fLow2HighGain=%s, "
|
---|
641 | " fAmplFadc=%s, "
|
---|
642 | " fAmplFadcOuter=%s, "
|
---|
643 | " fElectricNoise=%s, "
|
---|
644 | " fDigitalNoise=%s, "
|
---|
645 | " fRunNumber=%d, "
|
---|
646 | " fMisspointingX=%s, "
|
---|
647 | " fMissPointingY=%s, "
|
---|
648 | " fCorsikaVersionKEY =%d, "
|
---|
649 | " fReflectorVersionKEY=%d, "
|
---|
650 | " fCameraVersionKEY=%d, "
|
---|
651 | " fWobbleModeKEY=%d, "
|
---|
652 | " fObservationModeKEY=%d, "
|
---|
653 | " fMCParticleKEY=%d, "
|
---|
654 | " fSequenceFirst=0 ",
|
---|
655 | elow.Data(), eupp.Data(), slope.Data(), imax.Data(), numsimshow, numevents, numphe.Data(),
|
---|
656 | zBin, thetamin.Data(), thetamax.Data(), psf.Data(), psfx.Data(), psfy.Data(), ped.Data(), low2high.Data(),
|
---|
657 | amplfadc.Data(), amplfadco.Data(), enoise.Data(), dnoise.Data(), RunNum,
|
---|
658 | misx.Data(), misy.Data(), corsikakey, reflectorkey, camerakey, wobblekey, observationkey, particlekey );
|
---|
659 | }
|
---|
660 |
|
---|
661 | if (serv.Insert("MCRunData", query)==kFALSE)
|
---|
662 | return 2;
|
---|
663 | */
|
---|
664 |
|
---|
665 |
|
---|
666 | else
|
---|
667 | {
|
---|
668 |
|
---|
669 | query = Form(" UPDATE MCRunData SET "
|
---|
670 | " fELowLim=%s,"
|
---|
671 | " fEUppLim=%s, "
|
---|
672 | " fSlopeSpec=%s, "
|
---|
673 | " fImpactMax=%s, "
|
---|
674 | " fNumSimulatedShowers=%d, "
|
---|
675 | " fNumEvents=%d, "
|
---|
676 | " fNumPheFromDNSB=%s, "
|
---|
677 | " fzbin=%d, "
|
---|
678 | " fThetaMin=%s, "
|
---|
679 | " fThetaMax=%s, "
|
---|
680 | " fPointSpread=%s, "
|
---|
681 | " fPointSpreadX=%s, "
|
---|
682 | " fPointSpreadY=%s, "
|
---|
683 | " fPedesMean=%s, "
|
---|
684 | " fLow2HighGain=%s, "
|
---|
685 | " fAmplFadc=%s, "
|
---|
686 | " fAmplFadcOuter=%s, "
|
---|
687 | " fElectricNoise=%s, "
|
---|
688 | " fDigitalNoise=%s, "
|
---|
689 | " fMisspointingX=%s, "
|
---|
690 | " fMissPointingY=%s, "
|
---|
691 | " fCorsikaVersionKEY =%d, "
|
---|
692 | " fReflectorVersionKEY=%d, "
|
---|
693 | " fCameraVersionKEY=%d, "
|
---|
694 | " fWobbleModeKEY=%d, "
|
---|
695 | " fObservationModeKEY=%d, "
|
---|
696 | " fMCParticleKEY=%d, "
|
---|
697 | " WHERE fRunNumber=%d ",
|
---|
698 | elow.Data(), eupp.Data(), slope.Data(), imax.Data(), numsimshow, numevents, numphe.Data(),
|
---|
699 | zBin, thetamin.Data(), thetamax.Data(), psf.Data(), psfx.Data(), psfy.Data(), ped.Data(), low2high.Data(),
|
---|
700 | amplfadc.Data(), amplfadco.Data(), enoise.Data(), dnoise.Data(),
|
---|
701 | misx.Data(), misy.Data(), corsikakey, reflectorkey, camerakey, wobblekey, observationkey, particlekey, RunNum );
|
---|
702 |
|
---|
703 | }
|
---|
704 | //
|
---|
705 | // not yet implemented
|
---|
706 | //
|
---|
707 |
|
---|
708 | /*
|
---|
709 | query = Form(" fELowLim=%s,"
|
---|
710 | " fEUppLim=%s, "
|
---|
711 | " fSlopeSpec=%s, "
|
---|
712 | " fImpactMax=%s, "
|
---|
713 | " fNumSimulatedShowers=%d, "
|
---|
714 | " fNumEvents=%d, "
|
---|
715 | " fNumPheFromDNSB=%s, "
|
---|
716 | " fzbin=%d, "
|
---|
717 | " fThetaMin=%s, "
|
---|
718 | " fThetaMax=%s, "
|
---|
719 | " fPointSpread=%s, "
|
---|
720 | " fPointSpreadX=%s, "
|
---|
721 | " fPointSpreadY=%s, "
|
---|
722 | " fPedesMean=%s, "
|
---|
723 | " fLow2HighGain=%s, "
|
---|
724 | " fAmplFadc=%s, "
|
---|
725 | " fAmplFadcOuter=%s, "
|
---|
726 | " fElectricNoise=%s, "
|
---|
727 | " fDigitalNoise=%s, "
|
---|
728 | " fMisspointingX=%s, "
|
---|
729 | " fMissPointingY=%s, "
|
---|
730 | " fCorsikaVersionKEY =%d, "
|
---|
731 | " fReflectorVersionKEY=%d, "
|
---|
732 | " fCameraVersionKEY=%d, "
|
---|
733 | " fWobbleModeKEY=%d, "
|
---|
734 | " fObservationModeKEY=%d, "
|
---|
735 | " fMCParticleKEY=%d ",
|
---|
736 | elow.Data(), eupp.Data(), slope.Data(), imax.Data(), numsimshow, numevents, numphe.Data(),
|
---|
737 | zBin, thetamin.Data(), thetamax.Data(), psf.Data(), psfx.Data(), psfy.Data(), ped.Data(), low2high.Data(),
|
---|
738 | amplfadc.Data(), amplfadco.Data(), enoise.Data(), dnoise.Data(),
|
---|
739 | misx.Data(), misy.Data(), corsikakey, reflectorkey, camerakey, wobblekey, observationkey, particlekey );
|
---|
740 |
|
---|
741 | }
|
---|
742 | */
|
---|
743 |
|
---|
744 |
|
---|
745 | // if (serv.Update("MCRunData", query, "fRunNumber")==kFALSE)
|
---|
746 | // return 2;
|
---|
747 |
|
---|
748 |
|
---|
749 | if (dummy)
|
---|
750 | return 0;
|
---|
751 |
|
---|
752 | TSQLResult *res = serv.Query(query);
|
---|
753 | if (!res)
|
---|
754 | {
|
---|
755 | cout << "ERROR - Query failed: " << query << endl;
|
---|
756 | return 0;
|
---|
757 | }
|
---|
758 |
|
---|
759 | return 1;
|
---|
760 | }
|
---|
761 |
|
---|
762 | int fillcamera(TString fname, Bool_t dummy=kTRUE)
|
---|
763 | {
|
---|
764 | TEnv env("sql.rc");
|
---|
765 |
|
---|
766 | // MSQLServer serv(env);
|
---|
767 | MSQLMagic serv(env);
|
---|
768 | if (!serv.IsConnected())
|
---|
769 | {
|
---|
770 | cout << "ERROR - Connection to database failed." << endl;
|
---|
771 | return 2;
|
---|
772 | }
|
---|
773 |
|
---|
774 | serv.SetIsDummy(dummy);
|
---|
775 |
|
---|
776 | cout << endl;
|
---|
777 | cout << "fillcamera" << endl;
|
---|
778 | cout << "---------" << endl;
|
---|
779 | cout << endl;
|
---|
780 | cout << "Connected to " << serv.GetName() << endl;
|
---|
781 | cout << "File: " << fname << endl;
|
---|
782 | cout << endl;
|
---|
783 |
|
---|
784 | return Process(serv, fname, dummy);
|
---|
785 |
|
---|
786 | }
|
---|