Changeset 9062 for trunk/MagicSoft/Mars/datacenter/macros/fillstar.C
- Timestamp:
- 07/31/08 17:41:29 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/datacenter/macros/fillstar.C
r8996 r9062 59 59 #include <iomanip> 60 60 61 #include <TRegexp.h> 62 61 #include <TFile.h> 63 62 #include <TH1.h> 64 63 #include <TH2.h> 65 64 #include <TGraph.h> 66 #include <TProfile.h>67 #include <TFile.h>68 #include <TSQLResult.h>69 #include <TSQLRow.h>70 65 71 66 #include "MSQLMagic.h" … … 73 68 #include "MHCamera.h" 74 69 #include "MHMuonPar.h" 70 #include "MSequence.h" 75 71 #include "MStatusArray.h" 76 #include "MGeomCamMagic.h"77 72 #include "MBadPixelsCam.h" 73 #include "MHEffectiveOnTime.h" 78 74 79 75 using namespace std; … … 104 100 if (!hsparks) 105 101 { 106 cout << " WARNING- Reading of Sparks failed." << endl;102 cout << "ERROR - Reading of Sparks failed." << endl; 107 103 return 2; 108 104 } … … 111 107 if (!hcog) 112 108 { 113 cout << " WARNING- Reading of MHHillas failed." << endl;109 cout << "ERROR - Reading of MHHillas failed." << endl; 114 110 return 2; 115 111 } … … 118 114 if (!hmuon) 119 115 { 120 cout << " WARNING- Reading of MHMuon failed." << endl;116 cout << "ERROR - Reading of MHMuon failed." << endl; 121 117 return 2; 122 118 } … … 132 128 } 133 129 134 Double_t inhom = TMath::RMS(6, val)*6/hcog->GetEntries()*100; 135 inhom = TMath::Nint(inhom*10)/10.; 130 Float_t inhom = TMath::RMS(6, val)*6/hcog->GetEntries()*100; 136 131 TString inhomogen = Form("%5.1f", inhom); 137 132 138 Float_t mw 139 Float_t psf 140 TString PSF = Form("%5.1f", psf<0?0:psf);133 Float_t mw = hmuon->GetMeanWidth(); 134 Float_t psf = 70.205*mw - 28.055; 135 TString PSF = Form("%5.1f", (psf<0?0:psf)); 141 136 Int_t num = (int)hmuon->GetEntries(); 142 137 … … 147 142 if (!h) 148 143 { 149 cout << " WARNING- Reading of Islands failed." << endl;144 cout << "ERROR - Reading of Islands failed." << endl; 150 145 return 2; 151 146 } … … 154 149 155 150 h = (TH1*)arr.FindObjectInCanvas("EffOnTheta", "TH1D", "EffOnTime"); 151 152 Float_t effon = h ? h->Integral() : -1; 153 154 h = (TH1*)arr.FindObjectInCanvas("Cleaned;avg", "TH1D", "Cleaned"); 156 155 if (!h) 157 156 { 158 cout << "WARNING - Reading of EffOnTheta failed." << endl; 159 return 2; 160 } 161 162 Float_t effon = h->Integral(); 157 cout << "ERROR - Reading of Cleaned;avg failed." << endl; 158 return 2; 159 } 160 161 if (effon<0) 162 effon = h->GetEntries()/100; 163 163 164 Float_t mrate = num/effon; 164 165 TString muonrate = Form("%6.2f", mrate<0?0:mrate); 165 Int_t effontime = TMath::Nint(effon); 166 167 h = (TH1*)arr.FindObjectInCanvas("ProjDeltaT", "TH1D", "EffOnTime"); 168 if (!h) 169 { 170 cout << "WARNING - Reading of ProjDeltaT failed." << endl; 171 return 2; 172 } 166 TString effontime = Form("%.1f", effon); 173 167 174 168 Int_t numsparks = (int)hsparks->GetEntries(); 175 169 Int_t numevents = (int)h->GetEntries() - numsparks; 176 Int_t datarate = (int)(numevents/effon);170 Int_t datarate = TMath::Nint(numevents/effon); 177 171 178 172 TString sparkrate = Form("%5.2f", numsparks/effon); … … 181 175 sparkrate="0.00"; 182 176 177 MHEffectiveOnTime *ontm = (MHEffectiveOnTime*)arr.FindObjectInCanvas("MHEffectiveOnTime", "MHEffectiveOnTime", "EffOnTime"); 178 TString totontime = ontm ? Form("%d", TMath::Nint(ontm->GetTotalTime())) : "NULL"; 179 TString relontime = ontm ? Form("%.2f", effon/ontm->GetTotalTime()*100) : "NULL"; 180 183 181 TGraph *g = (TGraph*)arr.FindObjectInCanvas("Humidity", "TGraph", "MHWeather"); 184 if (!g) 185 { 186 cout << "WARNING - Reading of Humidity failed." << endl; 187 return 2; 188 } 182 189 183 TString maxhum = CheckGraph(g) ? Form("%5.1f", TMath::MaxElement(g->GetN(), g->GetY())) : "NULL"; 190 184 TString avghum = CheckGraph(g) ? Form("%5.1f", g->GetMean(2)) : "NULL"; 191 185 192 186 g = (TGraph*)arr.FindObjectInCanvas("Temperature", "TGraph", "MHWeather"); 193 if (!g) 194 { 195 cout << "WARNING - Reading of Temperature failed." << endl; 196 return 2; 197 } 187 198 188 TString avgtemp = CheckGraph(g) ? Form("%5.1f", g->GetMean(2)) : "NULL"; 199 189 200 190 g = (TGraph*)arr.FindObjectInCanvas("WindSpeed", "TGraph", "MHWeather"); 201 if (!g) 202 { 203 cout << "WARNING - Reading of WindSpeed failed." << endl; 204 return 2; 205 } 191 206 192 TString avgwind = CheckGraph(g) ? Form("%5.1f", g->GetMean(2)) : "NULL"; 207 193 208 194 g = (TGraph*)arr.FindObjectInCanvas("Cloudiness", "TGraph", "MHWeather"); 209 if (!g) 210 cout << "WARNING - Reading of Cloudiness failed." << endl; 211 195 //if (!g) 196 // cout << "WARNING - Reading of Cloudiness failed." << endl; 212 197 TString avgclouds = CheckGraph(g) ? Form("%5.1f", g->GetMean(2)) : "NULL"; 213 198 TString rmsclouds = CheckGraph(g) ? Form("%5.1f", g->GetRMS(2)) : "NULL"; 214 199 215 200 g = (TGraph*)arr.FindObjectInCanvas("TempSky", "TGraph", "MHWeather"); 216 if (!g)217 cout << "WARNING - Reading of TempSky failed." << endl;201 //if (!g) 202 // cout << "WARNING - Reading of TempSky failed." << endl; 218 203 TString avgsky = CheckGraph(g) ? Form("%5.1f", g->GetMean(2)+200) : "NULL"; 219 204 220 205 221 206 g = (TGraph*)arr.FindObjectInCanvas("NumStars", "TGraph", "MHPointing"); 222 if (!g) 223 cout << "WARNING - Reading of NumStars failed." << endl; 224 207 //if (!g) 208 // cout << "WARNING - Reading of NumStars failed." << endl; 225 209 TString numstarsmed = CheckGraph(g) ? Form("%5.1f", TMath::Median(g->GetN(), g->GetY())) : "NULL"; 226 210 TString numstarsrms = CheckGraph(g) ? Form("%5.1f", g->GetRMS(2)) : "NULL"; 227 211 228 212 g = (TGraph*)arr.FindObjectInCanvas("NumStarsCor", "TGraph", "MHPointing"); 229 if (!g) 230 cout << "WARNING - Reading of NumStarsCor failed." << endl; 231 213 //if (!g) 214 // cout << "WARNING - Reading of NumStarsCor failed." << endl; 232 215 TString numcorsmed = CheckGraph(g) ? Form("%5.1f", TMath::Median(g->GetN(), g->GetY())) : "NULL"; 233 216 TString numcorsrms = CheckGraph(g) ? Form("%5.1f", g->GetRMS(2)) : "NULL"; 234 217 235 218 g = (TGraph*)arr.FindObjectInCanvas("Brightness", "TGraph", "MHPointing"); 236 if (!g) 237 cout << "WARNING - Reading of SkyBrightness failed." << endl; 238 219 //if (!g) 220 // cout << "WARNING - Reading of SkyBrightness failed." << endl; 239 221 TString skybrightnessmed = CheckGraph(g) ? Form("%5.1f", TMath::Median(g->GetN(), g->GetY())) : "NULL"; 240 222 TString skybrightnessrms = CheckGraph(g) ? Form("%5.1f", g->GetRMS(2)) : "NULL"; 241 223 242 TString sequence = fname(TRegexp("star[0-9]+[.]root$")); 243 if (sequence.IsNull()) 244 { 245 cout << "WARNING - Could not determine sequence# from filename: " << fname << endl; 246 return 2; 247 } 248 249 Int_t seq = atoi(sequence.Data()+5); 250 251 cout << "Sequence #" << seq << endl; 224 MSequence seq; 225 if (seq.Read("sequence[0-9]{8}|MSequence")<=0) 226 { 227 cout << "ERROR - Could not find sequence in file: " << fname << endl; 228 return 2; 229 } 230 if (!seq.IsValid()) 231 { 232 cout << "ERROR - Sequence read from file inavlid: " << fname << endl; 233 return 2; 234 } 235 236 cout << "Sequence M" << seq.GetTelescope() << ":" << seq.GetSequence() << endl; 252 237 cout << " Inhomogeneity " << inhomogen << endl; 253 238 cout << " PSF [mm] " << PSF << endl; … … 255 240 cout << " Ratio [%] " << ratio << endl; 256 241 cout << " Muon Number " << num << endl; 257 cout << " EffOnTime [s] " << effontime << endl; 242 cout << " Eff. OnTime [s] " << effontime << endl; 243 cout << " Tot. OnTime [s] " << totontime << endl; 244 cout << " Rel. OnTime [%] " << relontime << endl; 258 245 cout << " Muon Rate [Hz] " << muonrate << endl; 259 246 cout << " # of Events (w/o sparks) " << numevents << endl; … … 271 258 cout << " Skybrightness " << skybrightnessmed << " +/- " << skybrightnessrms << endl; 272 259 273 TString vars = Form(" fMeanNumberIslands=%s," 260 TString vars = Form(" fSequenceFirst=%d, " 261 " fTelescopeNumber=%d, " 262 " fMeanNumberIslands=%s," 274 263 " fRatio=%s," 275 264 " fMuonNumber=%d," 276 " fEffOnTime=%d," 265 " fEffOnTime=%s," 266 " fTotOnTime=%s," 277 267 " fMuonRate=%s," 278 268 " fPSF=%s," … … 293 283 " fBrightnessRMS=%s," 294 284 " fInhomogeneity=%s ", 285 seq.GetSequence(), seq.GetTelescope(), 295 286 islands.Data(), ratio.Data(), 296 num, effontime ,287 num, effontime.Data(), totontime.Data(), 297 288 muonrate.Data(), PSF.Data(), 298 289 datarate, sparkrate.Data(), maxhum.Data(), … … 304 295 inhomogen.Data()); 305 296 306 return serv.InsertUpdate("Star", "fSequenceFirst", Form("%d", seq), vars); 297 TString where = Form("fSequenceFirst=%d AND fTelescopeNumber=%d", 298 seq.GetSequence(), seq.GetTelescope()); 299 300 return serv.InsertUpdate("Star", vars, where) ? 1 : 2; 307 301 } 308 302
Note:
See TracChangeset
for help on using the changeset viewer.