Changeset 8602 for trunk/MagicSoft
- Timestamp:
- 06/25/07 14:06:05 (17 years ago)
- Location:
- trunk/MagicSoft/Mars
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/Changelog
r8601 r8602 18 18 19 19 -*-*- END OF LINE -*-*- 20 21 22 2007/06/25 Daniel Hoehne 23 24 * datacenter/scripts/linkmc: 25 - implemented execution of fillcamera.C, now first a mc camera file 26 is linked and then fillcamera.C runs for this file 27 28 * datacenter/macros/fillcamera.C: 29 - bugfix: the macro doesn't giva a seg-fault anymore (thanks to Thomas) 30 - arranged the structure more clearly 31 20 32 21 33 -
trunk/MagicSoft/Mars/datacenter/macros/fillcamera.C
r8538 r8602 16 16 ! 17 17 ! 18 ! Author(s): Thomas Bretz, 11/2005<mailto:tbretz@astro.uni-wuerzburg.de>18 ! Author(s): Thomas Bretz, 06/2007 <mailto:tbretz@astro.uni-wuerzburg.de> 19 19 ! Author(s): Daniela Dorner, 11/2005 <mailto:dorner@astro.uni-wuerzburg.de> 20 ! Author(s): Daniel Hoehne, 0 5/2007 <mailto:hoehne@astro.uni-wuerzburg.de>20 ! Author(s): Daniel Hoehne, 06/2007 <mailto:hoehne@astro.uni-wuerzburg.de> 21 21 ! 22 22 ! Copyright: MAGIC Software Development, 2000-2007 … … 36 36 // 37 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 38 // 42 39 // … … 59 56 #include "MSQLServer.h" 60 57 #include "MSQLMagic.h" 61 #include "MGeomCamMagic.h"62 58 63 59 #include "MMcRunHeader.hxx" … … 73 69 74 70 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) 71 114 72 int Process(MSQLMagic &serv, TString fname, Bool_t dummy) 115 73 { … … 118 76 { 119 77 cout << "ERROR - Could not find file " << fname << endl; 120 return 0;121 } 122 123 //124 // Get tree RunHeaders from file125 //78 return 2; 79 } 80 81 // 82 // Get tree RunHeaders from file 83 // 126 84 TTree *tree = dynamic_cast<TTree*>(file.Get("RunHeaders")); 127 85 if (!tree) 128 86 { 129 87 cout << "ERROR - Tree RunHeaders not found in file " << fname << endl; 130 return 0; 131 } 132 // 133 // Get branch MMcCorsikaRunHeader from tree RunHeaders 134 // 88 return 2; 89 } 90 91 // 92 // Get branch MMcCorsikaRunHeader from tree RunHeaders 93 // 135 94 TBranch *b1 = tree->GetBranch("MMcCorsikaRunHeader."); 136 95 if (!b1) 137 96 { 138 97 cout << "ERROR - Branch MMcCorsikaRunHeader. not found in file " << fname << endl; 139 return 0;140 } 141 142 MMcCorsikaRunHeader *runheader1 = new MMcCorsikaRunHeader();98 return 2; 99 } 100 101 MMcCorsikaRunHeader *runheader1 = 0; 143 102 b1->SetAddress(&runheader1); 144 // 145 // Get branch MMcConfigRunHeader from tree RunHeaders 146 // 103 104 // 105 // Get branch MMcConfigRunHeader from tree RunHeaders 106 // 147 107 TBranch *b2 = tree->GetBranch("MMcConfigRunHeader."); 148 108 if (!b2) 149 109 { 150 110 cout << "ERROR - Branch MMcConfigRunHeader. not found in file " << fname << endl; 151 return 0;152 } 153 154 MMcConfigRunHeader *runheader2 = new MMcConfigRunHeader();111 return 2; 112 } 113 114 MMcConfigRunHeader *runheader2 = 0; 155 115 b2->SetAddress(&runheader2); 156 // 157 // Get branch MMcRunHeader from tree RunHeaders 158 // 116 117 // 118 // Get branch MMcRunHeader from tree RunHeaders 119 // 159 120 TBranch *b3 = tree->GetBranch("MMcRunHeader."); 160 121 if (!b3) 161 122 { 162 123 cout << "ERROR - Branch MMcRunHeader. not found in file " << fname << endl; 163 return 0;164 } 165 166 MMcRunHeader *runheader3 = new MMcRunHeader();124 return 2; 125 } 126 127 MMcRunHeader *runheader3 = 0; 167 128 b3->SetAddress(&runheader3); 168 // 169 // Get branch MMcFadcRunHeader from tree RunHeaders 170 // 129 130 // 131 // Get branch MMcFadcRunHeader from tree RunHeaders 132 // 171 133 TBranch *b4 = tree->GetBranch("MMcFadcHeader."); 172 134 if (!b4) 173 135 { 174 136 cout << "ERROR - Branch MMcFadcHeader. not found in file " << fname << endl; 175 return 0;176 } 177 178 MMcFadcHeader *fadcheader = new MMcFadcHeader();137 return 2; 138 } 139 140 MMcFadcHeader *fadcheader = 0; 179 141 b4->SetAddress(&fadcheader); 180 // 181 // Get branch MRawRunHearder from tree RunHeaders 182 // 142 143 // 144 // Get branch MRawRunHearder from tree RunHeaders 145 // 183 146 TBranch *b5 = tree->GetBranch("MRawRunHeader."); 184 147 if (!b5) 185 148 { 186 149 cout << "ERROR - Branch MRawRunHeader. not found in file " << fname << endl; 187 return 0;188 } 189 190 MRawRunHeader *rawheader = new MRawRunHeader();150 return 2; 151 } 152 153 MRawRunHeader *rawheader = 0; 191 154 b5->SetAddress(&rawheader); 192 155 193 156 tree->GetEvent(0); 194 // 195 // Get tree Events from file 196 // 157 158 // 159 // Get tree Events from file 160 // 197 161 TTree *tree2 = dynamic_cast<TTree*>(file.Get("Events")); 198 162 if (!tree2) 199 163 { 200 164 cout << "ERROR - Tree Events not found in file " << fname << endl; 201 return 0; 202 } 203 // 204 // Get branch MMcEvtBasic from tree Events 205 // 165 return 2; 166 } 167 168 // 169 // Get branch MMcEvtBasic from tree Events 170 // 206 171 TBranch *b6 = tree2->GetBranch("MMcEvtBasic."); 207 172 if (!b6) 208 173 { 209 174 cout << "ERROR - Branch MMcEvtBasic. not found in file " << fname << endl; 210 return 0;211 } 212 213 MMcEvtBasic *evtbasic = new MMcEvtBasic();175 return 2; 176 } 177 178 MMcEvtBasic *evtbasic = 0; 214 179 b6->SetAddress(&evtbasic); 215 180 216 181 tree2->GetEvent(0); 217 182 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); 183 Double_t misptx = runheader2->GetMissPointingX(); 184 Double_t mispty = runheader2->GetMissPointingY(); 185 Double_t pointspreadx = runheader2->GetPointSpreadX(); 186 Double_t tmin = runheader3->GetShowerThetaMin(); 187 Double_t tmax = runheader3->GetShowerThetaMax(); 188 UInt_t numsimshow = runheader3->GetNumSimulatedShowers(); 189 UInt_t numevents = tree2->GetEntries(); 190 191 TString elow = Form("%5.1f", runheader1->GetELowLim()); 192 TString eupp = Form("%5.1f", runheader1->GetEUppLim()); 193 TString slope = Form("%5.1f", runheader1->GetSlopeSpec()); 194 TString wobble = Form("%5.0f", runheader1->GetWobbleMode()); 195 TString corsika1 = Form("%5.0f", runheader1->GetCorsikaVersion()); 196 TString psf = Form("%5.1f", runheader2->GetPointSpread()); 197 TString psfx = Form("%5.2f", pointspreadx); 198 TString psfy = Form("%5.2f", runheader2->GetPointSpreadY()); 199 TString psfadd = Form("%5.2f", TMath::Hypot(runheader2->GetPointSpreadX(), runheader2->GetPointSpread())); 200 TString mirrfrac = Form("%5.2f", runheader2->GetMirrorFraction()); 201 TString misx = Form("%5.2f", misptx); 202 TString misy = Form("%5.2f", mispty); 203 TString reflector = Form("%5.0f", runheader3->GetReflVersion()); 204 TString camera = Form("%5.0f", runheader3->GetCamVersion()); 205 TString imax = Form("%5.1f", runheader3->GetImpactMax()); 206 TString numphe = Form("%5.1f", runheader3->GetNumPheFromDNSB()); 207 TString pmin = Form("%5.1f", runheader3->GetShowerPhiMin()); 208 TString pmax = Form("%5.1f", runheader3->GetShowerPhiMax()); 209 TString numss = Form("%7.0i", numsimshow); 210 TString thetamin = Form("%5.1f", tmin); 211 TString thetamax = Form("%5.1f", tmax); 212 TString ped = Form("%5.1f", fadcheader->GetPedestal(1)); 213 TString low2high = Form("%5.1f", fadcheader->GetLow2HighGain()); 214 TString amplfadc = Form("%5.1f", fadcheader->GetAmplitud()); 215 TString amplfadco = Form("%5.1f", fadcheader->GetAmplitudOuter()); 216 TString enoise = Form("%5.1f", fadcheader->GetElecNoise(1)); 217 TString dnoise = Form("%5.1f", fadcheader->GetDigitalNoise(1)); 255 218 256 219 TH1I h("myhist", "", 1, -0.5, 0.5); 257 220 tree2->Draw("MRawEvtData.GetNumPixels()>>myhist", "", "goff"); 258 221 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 } 222 223 TString numtrig = Form("%7.0i", TMath::Nint(h.GetBinContent(2))); 224 TString numevt = Form("%7.0i", numevents); 225 TString partid = Form("%5.0f", evtbasic->GetPartId()); 226 TString partname = evtbasic->GetParticleName(); 227 228 // Bestimmung von fakewobble aus file 229 // Kombination aus Wobble(0,1) und MissPoint 230 TString wobblemod="Wobble"; 231 232 // Fake Wobble: als ObservationModeKEY 4 einfügen? 233 if (wobblemod != 1) 234 wobblemod = misptx == 0 && mispty == 0 ? "On" : "Fake Wobble"; 354 235 355 236 Float_t pointsfx=TMath::Floor(pointspreadx*10); … … 357 238 TString pointsfuncx=Form("%5.1f",pointsfx); 358 239 359 // Float_t cos1=TMath::DegToRad(tmin);360 // Float_t cos2=TMath::DegToRad(tmax);361 240 Float_t zBin=TMath::Nint((1-((TMath::Cos(tmin*TMath::Pi()/180)+TMath::Cos(tmax*TMath::Pi()/180))/2))*100); 362 241 zBin=TMath::Nint(zBin); 363 242 364 // folgende Werte werden aus dem Pfadnamen gewonnen !!!neue Pfadstuktur!!! 365 //RunNumber243 // folgende Werte werden aus dem Pfadnamen gewonnen 244 // RunNumber 366 245 TRegexp reg2("_[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]_"); 367 246 TString Run = fname(reg2); 368 247 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 248 if (RunNum < 1 || RunNum > 99999) 249 { 250 cout << "ERROR - RunNumber wrong value" << endl; 251 return 2; 252 } 253 254 // PointSpreadFunction 377 255 TRegexp reg4("/[12][0-9]/"); 378 256 TString pointsf = fname(reg4); 379 257 Int_t Point = atoi(pointsf.Data()+1); 380 381 258 if (Point < 0 || Point > 99) 382 259 { 383 260 cout << "ERROR - PointSpreadFunction wrong value" << endl; 384 385 return 0; 386 } 387 388 // zbin 261 return 2; 262 } 263 264 // zbin 389 265 TRegexp reg1("/19[0-9][0-9]/"); 390 266 TString zbin = fname(reg1); 391 267 Int_t ZBin = atoi(zbin.Data()+3); 392 393 268 if (ZBin < 0 || ZBin > 99) 394 269 { 395 270 cout << "ERROR - zbin wrong value" << endl; 396 return 0;397 } 398 399 // WobbleMode271 return 2; 272 } 273 274 // WobbleMode 400 275 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; 276 TString wm = fname(reg3); /* weist WM den extrahierten Wert zu */ 277 Int_t wob = atoi(wm.Data()+1); /* schneidet fuehrenden '/' ab */ 278 279 280 // Umrechnung von WobbleModus Bezeichnung in 'wobble', 'nowobble', 'fakewobble' 281 TString wobmode; // dieser Wert wird in 'MCDB' Tabelle 'WobbleMode' eingetragen 282 switch (wob) 283 { 284 case 1: 285 case 3: 286 wobmode = "Wobble"; 287 break; 288 289 case 2: 290 case 4: 291 case 7: 292 case 8: 293 wobmode = "On"; 294 break; 295 296 case 5: 297 case 6: 298 wobmode = "Fake Wobble"; 299 break; 300 301 default: 302 cout << "ERROR - ObservationMode wrong value" << endl; 303 return 2; 304 } 446 305 447 306 … … 451 310 cout << "--- From File ---" << endl; 452 311 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; 312 cout << endl; 313 cout << "Energy Range " << elow << " < E < " << eupp << endl; 314 cout << "SpectralIndex " << slope << endl; 315 cout << "ObservationMode " << wobblemod << endl; 316 cout << "CorsikaVer " << corsika1 << endl; 317 cout << "ReflVer " << reflector << endl; 318 cout << "CamVer " << camera << endl; 319 cout << "ParticleId " << partid << endl; 320 cout << "ParticleName " << partname << endl; 321 cout << "PointSpread " << psf << endl; 322 cout << "PointSpreadXY " << psfx << " /" << psfy << endl; 323 cout << "AdditionPSF " << psfadd << endl; 324 cout << "MispointingXY " << misx << " /" << misy <<endl; 325 cout << "NumSimShowers " << numss << endl; 326 cout << "ImpactMax " << imax << endl; 327 cout << "NumEvents " << numevt << endl; 328 cout << "NumTriggers " << numtrig << endl; 329 cout << "NumPheFromDNSB " << numphe << endl; 330 cout << "Pedestal " << ped << endl; 331 cout << "Low2HighGain " << low2high << endl; 332 cout << "AmplitudeFADC " << amplfadc << endl; 333 cout << "AmplFADCOuter " << amplfadco << endl; 334 cout << "ElecNoise " << enoise << endl; 335 cout << "DigiNoise " << dnoise << endl; 336 cout << "PhiMin " << pmin << endl; 337 cout << "PhiMax " << pmax << endl; 338 cout << "ThetaMin " << thetamin << endl; 339 cout << "ThetaMax " << thetamax << endl; 340 cout << "Zenith range " << tmin << " to " << tmax << endl; 341 cout << "MirrorFraction " << mirrfrac << endl; 342 cout << endl; 343 494 344 cout << endl; 495 345 cout << "--- key's from mcdb tables ---" << endl; 496 346 cout << endl; 497 347 498 499 // Int_t corsikakey = QueryNameKEY(serv, dummy, "CorsikaVersion", Form("%d",CorVer));500 501 // Int_t corsikakey = QueryNameKEY(serv, dummy, "CorsikaVersion", corsika1.Data());502 348 Int_t corsikakey = serv.QueryKeyOfName("CorsikaVersion", corsika1.Data()); 349 Int_t reflectorkey = serv.QueryKeyOfName("ReflectorVersion", reflector.Data()); 350 Int_t camerakey = serv.QueryKeyOfName("CameraVersion", camera.Data()); 351 Int_t observationkey = serv.QueryKeyOfName("ObservationMode", wobblemod.Data()); 352 Int_t particlekey = serv.QueryKeyOfName("MCParticle", partname.Data()); 353 503 354 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 355 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 356 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 357 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 358 cout << "particlekey: " << particlekey << endl; 359 360 cout << endl; 361 cout << endl; 531 362 cout << "--- From File ---" << endl; 532 363 cout << endl; 533 cout << "WobbleMode " << WobbleMod << endl;534 cout << "PSF " << pointsfuncx << endl;535 cout << "zBin " << zBin << endl;364 cout << "WobbleMode " << wobblemod << endl; 365 cout << "PSF " << pointsfuncx << endl; 366 cout << "zBin " << zBin << endl; 536 367 cout << endl; 537 368 cout << "--- From FileName ---" << endl; 538 369 cout << endl; 539 cout << "WobbleMode " << WobMode << endl;540 cout << "RunNum 541 cout << "PSF 542 cout << "ZBin 543 cout << "WobbleMode( Pfad) " << Wob << endl;544 cout << endl; 545 cout << "--- Check ---" << endl; 546 cout << endl; 547 548 if (WobbleMod!=WobMode){370 cout << "WobbleMode " << wobmode << endl; 371 cout << "RunNum " << RunNum << endl; 372 cout << "PSF " << Point << endl; 373 cout << "ZBin " << ZBin << endl; 374 cout << "WobbleMode(dir) " << wob << endl; 375 cout << endl; 376 377 378 if (wobblemod!=wobmode) 379 { 549 380 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){ 381 return 2; 382 } 383 if (pointsfx!=Point) 384 { 556 385 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){ 386 return 2; 387 } 388 if (zBin!=ZBin) 389 { 563 390 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 391 return 2; 392 } 393 394 TString vars = 395 Form("fELowLim=%s, fEUppLim=%s, fSlopeSpec=%s, " 396 "fImpactMax=%s, fNumSimulatedShowers=%d, fNumEvents=%d, " 397 "fNumPheFromDNSB=%s, fZBin=%d, fThetaMin=%s, " 398 "fThetaMax=%s, fPointSpread=%s, fPointSpreadX=%s, " 399 "fPointSpreadY=%s, fPedesMean=%s, fLow2HighGain=%s, ", 400 elow.Data(), eupp.Data(), slope.Data(), imax.Data(), 401 numsimshow, numevents, numphe.Data(), 402 zBin, thetamin.Data(), thetamax.Data(), psf.Data(), 403 psfx.Data(), psfy.Data(), ped.Data(), low2high.Data()); 404 vars += 405 Form("fAmplFadc=%s, fAmplFadcOuter=%s, fElectricNoise=%s, " 406 "fDigitalNoise=%s, fRunNumber=%d, fMisspointingX=%s, " 407 "fMissPointingY=%s, fCorsikaVersionKEY =%d, " 408 "fReflectorVersionKEY=%d, fCameraVersionKEY=%d, " 409 "fObservationModeKEY=%d, fMCParticleKEY=%d, " 410 "fSequenceFirst=0 ", 411 amplfadc.Data(), amplfadco.Data(), enoise.Data(), 412 dnoise.Data(), RunNum, misx.Data(), misy.Data(), corsikakey, 413 reflectorkey, camerakey, observationkey, particlekey); 414 415 // Comming soon (-1: dummy, 0: failed, 1: succeeded) 416 // return serv.InsertUpdate("MCRunData", "fRunNumber", RunData()+1, vars); 417 418 if (!serv.ExistStr("fRunNumber", "MCRunData", Run.Data()+1)) 419 if (!serv.Insert("MCRunData", vars)==kFALSE) 420 return 2; 666 421 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 } 422 if (!serv.Update("MCRunData", vars, Form("fRunNumber=%d", Run))==kFALSE) 423 return 2; 758 424 759 425 return 1; … … 764 430 TEnv env("sql.rc"); 765 431 766 // MSQLServer serv(env);767 432 MSQLMagic serv(env); 768 433 if (!serv.IsConnected()) 769 434 { 770 435 cout << "ERROR - Connection to database failed." << endl; 771 return 2;436 return 0; 772 437 } 773 438 … … 776 441 cout << endl; 777 442 cout << "fillcamera" << endl; 778 cout << "--------- " << endl;443 cout << "----------" << endl; 779 444 cout << endl; 780 445 cout << "Connected to " << serv.GetName() << endl; … … 783 448 784 449 return Process(serv, fname, dummy); 785 786 450 } -
trunk/MagicSoft/Mars/datacenter/scripts/linkmc
r8482 r8602 19 19 # 20 20 # Author(s): Daniela Dorner 12/2005 <mailto:dorner@astro.uni-wuerzburg.de> 21 # Author(s): Daniel Hoehne 06/2007 <mailto:hoehne@astro.uni-wuerzburg.de> 21 22 # 22 23 # Copyright: MAGIC Software Development, 2000-2007 … … 28 29 # to a structure from which the files can be processed more easily with the 29 30 # automatic analysis. 31 # Furthermore the content of the files is filled in the database running 32 # fillcamera.C. 30 33 # This script is not yet running automatically. 31 34 # … … 38 41 # /magic/montecarlo/rawfiles/README.txt 39 42 # 40 # First the data files are linked and then in each new directory also the 41 # pedestal and calibration file is linked. 42 # 43 # First a file is linked and then fillcamera.C is executed. In case of an 44 # error in fillcamera.C the link is removed. 45 # In each new directory also the pedestal and calibration file is linked. 46 # 47 # ======================================================================== 48 43 49 44 50 source `dirname $0`/sourcefile … … 48 54 set -C 49 55 50 scriptlog=$runlogpath/$prog am-`date +%F`.log56 scriptlog=$runlogpath/$program-`date +%F`.log 51 57 date >> $scriptlog 2>&1 52 58 … … 70 76 71 77 # observation modes 72 modes=("" "Gammawobble+" "Gammanowobble0" "GammawobbleHE+" "GammanowobbleHE0" "Gammawobble0" "GammawobbleHE0" "Gammadiffuse0" "Protonnowobble0" )73 # be carful:78 modes=("" "Gammawobble+" "Gammanowobble0" "GammawobbleHE+" "GammanowobbleHE0" "Gammawobble0" "GammawobbleHE0" "Gammadiffuse0" "Protonnowobble0" "ProtonnowobbleHE0") 79 # be careful: 74 80 # w- not yet foreseen in this script 75 81 … … 107 113 108 114 109 #get runnumber 115 110 116 runno=`cat $next` 111 117 112 118 #get files, which have to be linked 113 camfiles=`find $mccampath -type f | grep -v Cal_and_Ped `119 camfiles=`find $mccampath -type f | grep -v Cal_and_Ped | sort` 114 120 115 121 printprocesslog "INFO linking new camerafiles starting with runno $runno" 116 122 for camfile in ${camfiles[@]} 117 123 do 124 125 118 126 #continue, if file is already linked 119 if grep $camfile $processed >> $scriptlog 2>&1 127 if find $mcpath/* -lname '$mccampath*.root' -printf %l'\n' | grep $camfile >> $scriptlog 2>&1 128 # if grep $camfile $processed >> $scriptlog 2>&1 120 129 then 121 130 continue 122 131 fi 132 133 123 134 printprocesslog "INFO linking $file" 124 135 file=`basename $camfile` #filename … … 129 140 wobble=`echo $file | cut -d_ -f6 | cut -c 2` #mode from filename 130 141 particle=`echo $file | cut -d_ -f1` #particle type from filename 131 psf=`echo $camfile | cut -d/ -f 5| cut -c 6,8` #psf from path132 133 particledir=`echo $camfile | cut -d/ -f 4` #particletype from path134 wobbledir=`echo $camfile | cut -d/ -f 6` #mode from path142 psf=`echo $camfile | cut -d/ -f6 | cut -c 6,8` #psf from path 143 144 particledir=`echo $camfile | cut -d/ -f5` #particletype from path 145 wobbledir=`echo $camfile | cut -d/ -f7` #mode from path 135 146 136 147 #build mode name … … 167 178 echo $runno >| $next 168 179 180 linkmclogpath=$logpath/$program/$no2 181 makedir $linkmclogpath >> $scriptlog 2>&1 182 linkmclog=$linkmclogpath/$program-$no2.log 183 169 184 #link file 185 echo "linking file $camfile" 170 186 ln -sv $camfile $newfile >> $scriptlog 2>&1 171 #add filename to processed file 172 echo $camfile >> $processed 187 188 # run fillcamera.C. In case of success the camfile is written to .processed. In case of an error the link is removed 189 echo "run fillcamera for mc run $no2" >> $scriptlog 2>&1 190 check2=`root -q -b $macrospath/fillcamera.C+\("\"$newfile\""\,kTRUE\) | tee $linkmclog | intgrep` 191 case $check2 in 192 1) echo " check2=$check2 -> everything ok " >> $scriptlog 2>&1 193 printprocesslog "INFO done fillcamera successfully for mc run $no2" 194 # add filename to .processed 195 echo $camfile >> $processed 196 ;; 197 0) echo " check2=$check2 -> no connection to db -> continue..." >> $scriptlog 2>&1 198 printprocesslog "WARN connection to DB failed, removing link" 199 check="no" 200 # remove link 201 rm $newfile >> $scriptlog 2>&1 202 ;; 203 *) echo " check2=$check2 -> ERROR -> step has to be repeated" >> $scriptlog 2>&1 204 printprocesslog "ERROR fillcamera failed for mc run $no2, removing link" 205 check=$check2 206 # remove link 207 rm $newfile >> $scriptlog 2>&1 208 ;; 209 esac 173 210 174 211 done … … 178 215 #get files 179 216 pedfile=`find $mccampath/Cal_and_Ped -name *_P_*.root` 217 218 180 219 calfile=`find $mccampath/Cal_and_Ped -name *_C_*.root` 220 221 181 222 echo "calfile"$calfile >> $scriptlog 2>&1 182 223 echo "pedfile"$pedfile >> $scriptlog 2>&1 … … 186 227 then 187 228 "too many files in the directory $mccampath/Cal_and_Ped -> exit" >> $scriptlog 2>&1 229 230 231 rm -v $lockfile >> $scriptlog 2>&1 232 exit 188 233 printprocesslog "ERROR too many ped and cal files found in $mccampath/Cal_and_Ped" 189 234 finish >> $scriptlog 2>&1 … … 196 241 do 197 242 #continue, if directory has already linked C and P run 198 cont=`ls $dir/*_0000 [12]_[CP]_MonteCarlo_E.root 2>/dev/null | wc -w`243 cont=`ls $dir/*_0000000[12]_[CP]_MonteCarlo_E.root 2>/dev/null | wc -w` 199 244 if [ "$cont" == "2" ] >> $scriptlog 2>&1 200 245 then
Note:
See TracChangeset
for help on using the changeset viewer.