Changeset 9062 for trunk/MagicSoft/Mars/datacenter/macros/fillcalib.C
- Timestamp:
- 07/31/08 17:41:29 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/datacenter/macros/fillcalib.C
r8951 r9062 61 61 #include <iostream> 62 62 63 #include <TEnv.h>64 #include <TRegexp.h>65 66 63 #include <TH1.h> 67 64 … … 74 71 #include "MStatusArray.h" 75 72 #include "MHCamera.h" 73 #include "MSequence.h" 76 74 #include "MGeomCamMagic.h" 77 75 #include "MBadPixelsCam.h" … … 145 143 if (!h) 146 144 { 147 cout << " WARNING - Could not find histogram HRelTimeHiGainArea0." << endl;145 cout << "ERROR - Could not find histogram HRelTimeHiGainArea0 in Time." << endl; 148 146 return 2; 149 147 } … … 156 154 if (!h) 157 155 { 158 cout << " WARNING - Could not find histogram HRelTimeHiGainArea1." << endl;156 cout << "ERROR - Could not find histogram HRelTimeHiGainArea1 in Time." << endl; 159 157 return 2; 160 158 } … … 167 165 if (!c) 168 166 { 169 cout << " WARNING - Could not find MHCamera TotalConv." << endl;167 cout << "ERROR - Could not find MHCamera TotalConv in Conversion." << endl; 170 168 return 2; 171 169 } … … 182 180 TString meanconvouter=Form("%6.3f", meanconvo); 183 181 184 //Getting sequ# from filename 185 TString sequence = fname(TRegexp("calib[0-9]+[.]root$")); 186 if (sequence.IsNull()) 187 { 188 cout << "WARNING - Could get sequence# from filename: " << fname << endl; 189 return 2; 190 } 191 192 Int_t seq = atoi(sequence.Data()+5); 182 //Getting relative charge rms 183 c = (MHCamera*)arr.FindObjectInCanvas("RMSperMean", "MHCamera", "FitCharge"); 184 if (!c) 185 { 186 cout << "ERROR - Could not find MHCamera RMSperMean in FitCharge." << endl; 187 return 2; 188 } 189 190 Stat_t relrmsi = c->GetMedianSectors(TArrayI(6, s0), inner); 191 Stat_t relrmso = c->GetMedianSectors(TArrayI(6, s0), outer); 192 TString relrmsinner=Form("%6.3f", relrmsi); 193 TString relrmsouter=Form("%6.3f", relrmso); 194 195 //Getting relative charge rms 196 c = (MHCamera*)arr.FindObjectInCanvas("NumPhes", "MHCamera", "FitCharge"); 197 if (!c) 198 { 199 cout << "ERROR - Could not find MHCamera NumPhes in FitCharge." << endl; 200 return 2; 201 } 202 203 Stat_t numphei = c->GetMedianSectors(TArrayI(6, s0), inner); 204 Stat_t numpheo = c->GetMedianSectors(TArrayI(6, s0), outer); 205 TString numpheinner=Form("%5.1f", numphei); 206 TString numpheouter=Form("%5.1f", numpheo); 207 208 MSequence seq; 209 if (seq.Read("sequence[0-9]{8}[.]txt|MSequence")<=0) 210 { 211 cout << "ERROR - Could not find sequence in file: " << fname << endl; 212 return 2; 213 } 214 if (!seq.IsValid()) 215 { 216 cout << "ERROR - Sequence read from file inavlid: " << fname << endl; 217 return 2; 218 } 193 219 194 220 //getting the ratio of calibration events used … … 196 222 if (!h) 197 223 { 198 cout << " WARNING- Could not find histogram ArrTime;avg." << endl;199 return 2; 200 } 201 202 UInt_t nevts = h->GetEntries();224 cout << "ERROR - Could not find histogram ArrTime;avg." << endl; 225 return 2; 226 } 227 228 UInt_t nevts = TMath::Nint(h->GetEntries()); 203 229 204 230 TString query; 205 231 query = Form("SELECT SUM(fNumEvents) FROM RunData " 206 "LEFT JOIN RunType ON RunType.fRunTypeKEY=RunData.fRunTypeKEY " 207 "WHERE fSequenceFirst=%d AND RunType.fRunTypeName='Calibration'", 208 seq); 232 "LEFT JOIN RunType USING (fRunTypeKEY) " 233 "WHERE fSequenceFirst=%d AND fTelescopeNumber=%d AND " 234 "RunType.fRunTypeName='Calibration'", 235 seq.GetSequence(), seq.GetTelescope()); 209 236 210 237 TSQLResult *res = serv.Query(query); … … 228 255 delete res; 229 256 230 cout << "Sequence #" << seq << endl; 231 cout << " Unsuitable: (i/o) " << Form("%3d %3d", (int)unsin, (int)unsout) << endl; // Unbrauchbar 232 cout << " Unreliable: (i/o) " << Form("%3d %3d", (int)unrin, (int)unrout) << endl; // Unzuverlaessig 233 cout << " Isolated: (i/o) " << Form("%3d %3d", (int)isoin, (int)isoout) << endl; // Isolated (unbrauchbar) 234 cout << " Max.Cluster: " << Form("%3d", (int)clumax) << endl; // Max Cluster 235 cout << " Arr Time inner: " << meaninner << " +- " << rmsinner << endl; 236 cout << " Arr Time outer: " << meanouter << " +- " << rmsouter << endl; 237 cout << " Mean Conv inner: " << meanconvinner << endl; 238 cout << " Mean Conv outer: " << meanconvouter << endl; 239 cout << " Ratio Calib Evts: " << ratiocal << endl; 257 cout << "Sequence M" << seq.GetTelescope() << ":" << seq.GetSequence() << endl; 258 cout << " Unsuitable: (i/o) " << Form("%3d %3d", (int)unsin, (int)unsout) << endl; // Unbrauchbar 259 cout << " Unreliable: (i/o) " << Form("%3d %3d", (int)unrin, (int)unrout) << endl; // Unzuverlaessig 260 cout << " Isolated: (i/o) " << Form("%3d %3d", (int)isoin, (int)isoout) << endl; // Isolated (unbrauchbar) 261 cout << " Max.Cluster: " << Form("%3d", (int)clumax) << endl; // Max Cluster 262 cout << " Arr Time inner: " << meaninner << " +- " << rmsinner << endl; 263 cout << " Arr Time outer: " << meanouter << " +- " << rmsouter << endl; 264 cout << " Mean Conv inner: " << meanconvinner << endl; 265 cout << " Mean Conv outer: " << meanconvouter << endl; 266 cout << " Rel.charge rms in: " << relrmsinner << endl; 267 cout << " Rel.charge rms out: " << relrmsouter << endl; 268 cout << " Med. num phe inner: " << numpheinner << endl; 269 cout << " Med. num phe outer: " << numpheouter << endl; 270 cout << " Ratio Calib Evts: " << ratiocal << endl; 271 272 // FIXME: Fill calibration charge 240 273 241 274 //inserting or updating the information in the database 242 275 TString vars = 243 Form(" fUnsuitableInner=%d, " 276 Form(" fSequenceFirst=%d, " 277 " fTelescopeNumber=%d, " 278 " fUnsuitableInner=%d, " 244 279 " fUnsuitableOuter=%d, " 245 280 " fUnreliableInner=%d, " … … 254 289 " fConvFactorInner=%s, " 255 290 " fConvFactorOuter=%s, " 256 " fRatioCalEvents=%s ", 291 " fRatioCalEvents=%s, " 292 " fRelChargeRmsInner=%s, " 293 " fRelChargeRmsOuter=%s, " 294 " fMedNumPheInner=%s, " 295 " fMedNumPheOuter=%s ", 296 seq.GetSequence(), seq.GetTelescope(), 257 297 (int)unsin, (int)unsout, (int)unrin, 258 298 (int)unrout, (int)isoin, (int)isoout, (int)clumax, … … 260 300 meanouter.Data(), rmsouter.Data(), 261 301 meanconvinner.Data(), meanconvouter.Data(), 262 ratiocal.Data()); 263 264 return serv.InsertUpdate("Calibration", "fSequenceFirst", 265 Form("%d", seq), vars.Data()) ? 1 : 2; 302 ratiocal.Data(), 303 relrmsinner.Data(), relrmsouter.Data(), 304 numpheinner.Data(), numpheouter.Data() 305 ); 306 307 TString where = Form("fSequenceFirst=%d AND fTelescopeNumber=%d", 308 seq.GetSequence(), seq.GetTelescope()); 309 310 return serv.InsertUpdate("Calibration", vars, where) ? 1 : 2; 266 311 } 267 312 268 313 int fillcalib(TString fname, Bool_t dummy=kTRUE) 269 314 { 270 TEnv env("sql.rc"); 271 272 MSQLMagic serv(env); 315 MSQLMagic serv("sql.rc"); 273 316 if (!serv.IsConnected()) 274 317 {
Note:
See TracChangeset
for help on using the changeset viewer.