G4exception Descriptive Essay

G4RootAnalysisManager.cc

Go to the documentation of this file.
00001 00002 00003 00004 00005 00006 00007 00008 00009 00010 00011 00012 00013 00014 00015 00016 00017 00018 00019 00020 00021 00022 00023 00024 00025 00026 00027 00028 00029 00030 #include "G4RootAnalysisManager.hh"00031 #include "G4UnitsTable.hh"00032 00033 #include <iostream>00034 00035 G4RootAnalysisManager* G4RootAnalysisManager::fgInstance = 0; 00036 00037 00038G4RootAnalysisManager* G4RootAnalysisManager::Instance() 00039 { 00040 if ( fgInstance == 0 ) { 00041 fgInstance = newG4RootAnalysisManager(); 00042 } 00043 00044 return fgInstance; 00045 } 00046 00047 00048G4RootAnalysisManager::G4RootAnalysisManager() 00049 : G4VAnalysisManager("Root"), 00050 fFile(0), 00051 fHistoDirectory(0), 00052 fNtupleDirectory(0), 00053 fH1Vector(), 00054 fH2Vector(), 00055 fH1NameIdMap(), 00056 fH2NameIdMap(), 00057 fNtuple(0), 00058 fNtupleBooking(0), 00059 fNtupleIColumnMap(), 00060 fNtupleFColumnMap(), 00061 fNtupleDColumnMap() 00062 { 00063 if ( fgInstance ) { 00064 G4ExceptionDescription description; 00065 description << " "00066 << "G4RootAnalysisManager already exists."00067 << "Cannot create another instance."; 00068 G4Exception("G4RootAnalysisManager::G4RootAnalysisManager()", 00069 "Analysis_F001", FatalException, description); 00070 } 00071 00072 fgInstance = this; 00073 } 00074 00075 00076G4RootAnalysisManager::~G4RootAnalysisManager() 00077 { 00078 std::vector<tools::histo::h1d*>::iterator it; 00079 for (it = fH1Vector.begin(); it != fH1Vector.end(); it++ ) { 00080 delete (*it); 00081 } 00082 00083 std::vector<tools::histo::h2d*>::iterator it2; 00084 for (it2 = fH2Vector.begin(); it2 != fH2Vector.end(); it2++ ) { 00085 delete (*it2); 00086 } 00087 00088 delete fNtuple; 00089 delete fNtupleBooking; 00090 delete fFile; 00091 00092 fgInstance = 0; 00093 } 00094 00095 00096 00097 00098 00099 00100 G4bool G4RootAnalysisManager::CreateHistoDirectory() 00101 { 00102 if ( fHistoDirectoryName == "" ) { 00103 00104 fHistoDirectory = &(fFile->dir()); 00105 returntrue; 00106 } 00107 00108 #ifdef G4VERBOSE00109 if ( fpVerboseL4 ) 00110 fpVerboseL4->Message("create", "directory for histograms", fHistoDirectoryName); 00111 #endif00112 00113 fHistoDirectory = fFile->dir().mkdir(fHistoDirectoryName); 00114 if ( ! fHistoDirectory ) { 00115 G4ExceptionDescription description; 00116 description << " "00117 << "cannot create directory " << fHistoDirectoryName; 00118 G4Exception("G4RootAnalysisManager::CreateHistoDirectory()", 00119 "Analysis_W002", JustWarning, description); 00120 returnfalse; 00121 } 00122 #ifdef G4VERBOSE00123 else { 00124 if ( fpVerboseL2 ) 00125 fpVerboseL2->Message("create", "directory for histograms", fHistoDirectoryName); 00126 } 00127 #endif00128 returntrue; 00129 } 00130 00131 00132 G4bool G4RootAnalysisManager::CreateNtupleDirectory() 00133 { 00134 if ( fNtupleDirectoryName == "" ) { 00135 00136 fNtupleDirectory = &(fFile->dir()); 00137 returntrue; 00138 } 00139 00140 #ifdef G4VERBOSE00141 if ( fpVerboseL4 ) 00142 fpVerboseL400143 ->Message("create", "directory for ntuples", fNtupleDirectoryName); 00144 #endif00145 00146 fNtupleDirectory = fFile->dir().mkdir(fNtupleDirectoryName); 00147 if ( ! fNtupleDirectory ) { 00148 G4ExceptionDescription description; 00149 description << " "00150 << "cannot create directory " << fNtupleDirectoryName; 00151 G4Exception("G4RootAnalysisManager::CreateNtupleDirectory()", 00152 "Analysis_W002", JustWarning, description); 00153 returnfalse; 00154 } 00155 #ifdef G4VERBOSE00156 else { 00157 if ( fpVerboseL2 ) 00158 fpVerboseL200159 ->Message("create", "directory for ntuples", fNtupleDirectoryName); 00160 } 00161 #endif00162 returntrue; 00163 } 00164 00165 00166 void G4RootAnalysisManager::CreateNtupleFromBooking() 00167 { 00168 00169 00170 if ( fNtuple || (! fNtupleBooking) ) return; 00171 00172 #ifdef G4VERBOSE00173 if ( fpVerboseL4 ) 00174 fpVerboseL4->Message("create from booking", "ntuple", fNtupleBooking->m_name); 00175 #endif00176 fNtuple = new tools::wroot::ntuple(*fNtupleDirectory, *fNtupleBooking); 00177 00178 if ( fNtupleBooking->m_columns.size() ) { 00179 00180 const std::vector<tools::ntuple_booking::col_t>& columns 00181 = fNtupleBooking->m_columns; 00182 std::vector<tools::ntuple_booking::col_t>::const_iterator it; 00183 G4int index = 0; 00184 for ( it = columns.begin(); it!=columns.end(); ++it) { 00185 if ( (*it).second == tools::_cid(int(0) ) ) { 00186 G4cout << "adding int " << fNtuple->find_column<int>((*it).first) << G4endl; 00187 fNtupleIColumnMap[index++] = fNtuple->find_column<int>((*it).first); 00188 } 00189 elseif( (*it).second == tools::_cid(float(0) ) ) { 00190 fNtupleFColumnMap[index++] = fNtuple->find_column<float>((*it).first); 00191 } 00192 elseif((*it).second== tools::_cid(double(0))) { 00193 fNtupleDColumnMap[index++] = fNtuple->find_column<double>((*it).first); 00194 } 00195 else { 00196 G4ExceptionDescription description; 00197 description << " "00198 << "Unsupported column type " << (*it).first; 00199 G4Exception("G4RootAnalysisManager::CreateNtupleFromBooking()", 00200 "Analysis_W004", JustWarning, description); 00201 } 00202 } 00203 } 00204 } 00205 00206 00207 tools::wroot::ntuple::column<int>* 00208 G4RootAnalysisManager::GetNtupleIColumn(G4intid) const00209 { 00210 std::map<G4int, tools::wroot::ntuple::column<int>* >::const_iterator it 00211 = fNtupleIColumnMap.find(id); 00212 if ( it == fNtupleIColumnMap.end() ) { 00213 G4ExceptionDescription description; 00214 description << " " << "column " << id << " does not exist."; 00215 G4Exception("G4RootAnalysisManager::GetNtupleIColumn()", 00216 "Analysis_W009", JustWarning, description); 00217 return 0; 00218 } 00219 00220 return it->second; 00221 } 00222 00223 00224 tools::wroot::ntuple::column<float>* 00225 G4RootAnalysisManager::GetNtupleFColumn(G4intid) const00226 { 00227 std::map<G4int, tools::wroot::ntuple::column<float>* >::const_iterator it 00228 = fNtupleFColumnMap.find(id); 00229 if ( it == fNtupleFColumnMap.end() ) { 00230 G4ExceptionDescription description; 00231 description << " " << "column " << id << " does not exist."; 00232 G4Exception("G4RootAnalysisManager::GetNtupleFColumn()", 00233 "Analysis_W009", JustWarning, description); 00234 return 0; 00235 } 00236 00237 return it->second; 00238 } 00239 00240 00241 00242 tools::wroot::ntuple::column<double>* 00243 G4RootAnalysisManager::GetNtupleDColumn(G4intid) const00244 { 00245 std::map<G4int, tools::wroot::ntuple::column<double>* >::const_iterator it 00246 = fNtupleDColumnMap.find(id); 00247 if ( it == fNtupleDColumnMap.end() ) { 00248 G4ExceptionDescription description; 00249 description << " " << "column " << id << " does not exist."; 00250 G4Exception("G4RootAnalysisManager::GetNtupleDColumn()", 00251 "Analysis_W009", JustWarning, description); 00252 return 0; 00253 } 00254 00255 return it->second; 00256 } 00257 00258 00259 G4bool G4RootAnalysisManager::Reset() 00260 { 00261 00262 00263 G4bool finalResult = true; 00264 00265 std::vector<tools::histo::h1d*>::iterator it; 00266 for (it = fH1Vector.begin(); it != fH1Vector.end(); it++ ) { 00267 G4bool result = (*it)->reset(); 00268 if ( ! result ) finalResult = false; 00269 } 00270 00271 std::vector<tools::histo::h2d*>::iterator it2; 00272 for (it2 = fH2Vector.begin(); it2 != fH2Vector.end(); it2++ ) { 00273 G4bool result = (*it2)->reset(); 00274 if ( ! result ) finalResult = false; 00275 } 00276 00277 00278 00279 fNtuple = 0; 00280 00281 return finalResult; 00282 } 00283 00284 00285 void G4RootAnalysisManager::UpdateTitle(G4String& title, 00286 constG4String& unitName, 00287 constG4String& fcnName) const00288 { 00289 if ( fcnName != "none" ) { title += " "; title += fcnName; title += "("; } 00290 if ( unitName != "none" ) { title += " ["; title += unitName; title += "]";} 00291 if ( fcnName != "none" ) { title += ")"; } 00292 } 00293 00294 00295 00296 00297 00298 00299G4boolG4RootAnalysisManager::WriteOnAscii(std::ofstream& output) 00300 { 00301 00302 00303 00304 00305 00306 00307 for ( G4int i=0; i<G4int(fH1Vector.size()); ++i ) { 00308 G4intid = i + fFirstHistoId; 00309 G4HnInformation* info = GetH1Information(id); 00310 00311 if ( ! info->fAscii ) continue; 00312 tools::histo::h1d* h1 = fH1Vector[i]; 00313 00314 #ifdef G4VERBOSE00315 if ( fpVerboseL3 ) 00316 fpVerboseL3->Message("write on ascii", "h1d", info->fName); 00317 #endif00318 00319 output << "\n 1D histogram " << id << ": " << h1->title() 00320 << "\n \n \t X \t\t Y" << G4endl; 00321 00322 for (G4int j=0; j< G4int(h1->axis().bins()); ++j) { 00323 output << " " << j << "\t"00324 << h1->axis().bin_center(j) << "\t"00325 << h1->bin_height(i) << G4endl; 00326 } 00327 } 00328 00329 returntrue; 00330 } 00331 00332 00333 tools::histo::h1d* G4RootAnalysisManager::GetH1InFunction(G4intid, 00334 G4String functionName, G4bool warn, 00335 G4bool onlyIfActive) const00336 { 00337 G4int index = id - fFirstHistoId; 00338 if ( index < 0 || index >= G4int(fH1Vector.size()) ) { 00339 if ( warn) { 00340 G4String inFunction = "G4RootAnalysisManager::"; 00341 inFunction += functionName; 00342 G4ExceptionDescription description; 00343 description << " " << "histogram " << id << " does not exist."; 00344 G4Exception(inFunction, "Analysis_W007", JustWarning, description); 00345 } 00346 return 0; 00347 } 00348 00349 00350 if ( fActivation && onlyIfActive && ( ! GetActivation(kH1, id) ) ) { 00351 return 0; 00352 } 00353 00354 return fH1Vector[index]; 00355 } 00356 00357 00358 tools::histo::h2d* G4RootAnalysisManager::GetH2InFunction(G4intid, 00359 G4String functionName, G4bool warn, 00360 G4bool onlyIfActive) const00361 { 00362 G4int index = id - fFirstHistoId; 00363 if ( index < 0 || index >= G4int(fH2Vector.size()) ) { 00364 if ( warn) { 00365 G4String inFunction = "G4RootAnalysisManager::"; 00366 inFunction += functionName; 00367 G4ExceptionDescription description; 00368 description << " " << "histogram " << id << " does not exist."; 00369 G4Exception(inFunction, "Analysis_W007", JustWarning, description); 00370 } 00371 return 0; 00372 } 00373 00374 00375 if ( fActivation && onlyIfActive && ( ! GetActivation(kH2, id) ) ) { 00376 return 0; 00377 } 00378 00379 return fH2Vector[index]; 00380 } 00381 00382 00383 00384 00385 00386 00387G4boolG4RootAnalysisManager::OpenFile(constG4String& fileName) 00388 { 00389 00390 fFileName = fileName; 00391 00392 00393 G4String name(fileName); 00394 if ( name.find(".") == std::string::npos ) { 00395 name.append("."); 00396 name.append(GetFileType()); 00397 } 00398 00399 #ifdef G4VERBOSE00400 if ( fpVerboseL4 ) 00401 fpVerboseL4->Message("open", "analysis file", name); 00402 #endif00403 00404 00405 if ( fFile ) delete fFile; 00406 00407 fFile = new tools::wroot::file(std::cout, name); 00408 if ( ! fFile->is_open() ) { 00409 G4ExceptionDescription description; 00410 description << " " << "Cannot open file " << fileName; 00411 G4Exception("G4RootAnalysisManager::OpenFile()", 00412 "Analysis_W001", JustWarning, description); 00413 returnfalse; 00414 } 00415 00416 00417 if ( ! CreateHistoDirectory() ) returnfalse; 00418 if ( ! CreateNtupleDirectory() ) returnfalse; 00419 00420 00421 if ( fNtupleBooking && ( ! fNtuple ) ) 00422 CreateNtupleFromBooking(); 00423 00424 fLockFileName = true; 00425 fLockHistoDirectoryName = true; 00426 fLockNtupleDirectoryName = true; 00427 00428 #ifdef G4VERBOSE00429 if ( fpVerboseL1 ) 00430 fpVerboseL1->Message("open", "analysis file", name); 00431 #endif00432 00433 returntrue; 00434 } 00435 00436 00437G4boolG4RootAnalysisManager::Write() 00438 { 00439 00440 for ( G4int i=0; i<G4int(fH1Vector.size()); ++i ) { 00441 G4intid = i + fFirstHistoId; 00442 G4HnInformation* info = GetH1Information(id); 00443 00444 if ( fActivation && ( ! info->fActivation ) ) continue; 00445 tools::histo::h1d* h1 = fH1Vector[i]; 00446 #ifdef G4VERBOSE00447 if ( fpVerboseL3 ) 00448 fpVerboseL3->Message("write", "h1d", info->fName); 00449 #endif00450 G4bool result 00451 = to(*fHistoDirectory,*h1,info->fName); 00452 if ( ! result ) { 00453 G4ExceptionDescription description; 00454 description << " " << "saving histogram " << info->fName << " failed"; 00455 G4Exception("G4RootAnalysisManager::Write()", 00456 "Analysis_W003", JustWarning, description); 00457 returnfalse; 00458 } 00459 } 00460 00461 00462 for ( G4int i=0; i<G4int(fH2Vector.size()); ++i ) { 00463 G4intid = i + fFirstHistoId; 00464 G4HnInformation* info = GetH2Information(id); 00465 00466 if ( fActivation && ( ! info->fActivation ) ) continue; 00467 tools::histo::h2d* h2 = fH2Vector[i]; 00468 #ifdef G4VERBOSE00469 if ( fpVerboseL3 ) 00470 fpVerboseL3->Message("write", "h2d", info->fName); 00471 #endif00472 G4bool result 00473 = to(*fHistoDirectory,*h2,info->fName); 00474 if ( ! result ) { 00475 G4ExceptionDescription description; 00476 description << " " << "saving histogram " << info->fName << " failed"; 00477 G4Exception("G4RootAnalysisManager::Write()", 00478 "Analysis_W003", JustWarning, description); 00479 returnfalse; 00480 } 00481 } 00482 00483 #ifdef G4VERBOSE00484 if ( fpVerboseL4 ) 00485 fpVerboseL4->Message("write", "file", GetFullFileName()); 00486 #endif00487 00488 unsignedintn; 00489 G4bool result = fFile->write(n); 00490 00491 #ifdef G4VERBOSE00492 if ( fpVerboseL1 ) 00493 fpVerboseL1->Message("write", "file", GetFullFileName(), result); 00494 #endif00495 00496 00497 if ( IsAscii() ) { 00498 G4bool result2 = WriteAscii(); 00499 result = result && result2; 00500 } 00501 00502 return result; 00503 } 00504 00505 00506G4boolG4RootAnalysisManager::CloseFile() 00507 { 00508 G4bool result = true; 00509 00510 #ifdef G4VERBOSE00511 if ( fpVerboseL4 ) 00512 fpVerboseL4->Message("close", "file", GetFullFileName()); 00513 #endif00514 00515 00516 result = Reset(); 00517 if ( ! result ) { 00518 G4ExceptionDescription description; 00519 description << " " << "Resetting data failed"; 00520 G4Exception("G4RootAnalysisManager::Write()", 00521 "Analysis_W002", JustWarning, description); 00522 result = false; 00523 } 00524 00525 00526 fFile->close(); 00527 fLockFileName = false; 00528 00529 #ifdef G4VERBOSE00530 if ( fpVerboseL1 ) 00531 fpVerboseL1->Message("close", "file", GetFullFileName()); 00532 #endif00533 00534 return result; 00535 } 00536 00537 00538G4intG4RootAnalysisManager::CreateH1(constG4String& name, constG4String& title, 00539 G4int nbins, G4double xmin, G4double xmax, 00540 constG4String& unitName, constG4String& fcnName) 00541 { 00542 #ifdef G4VERBOSE00543 if ( fpVerboseL4 ) 00544 fpVerboseL4->Message("create", "H1", name); 00545 #endif00546 G4int index = fH1Vector.size(); 00547 G4double unit = GetUnitValue(unitName); 00548 G4Fcn fcn = GetFunction(fcnName); 00549 tools::histo::h1d* h1 00550 = new tools::histo::h1d(title, nbins, fcn(xmin), fcn(xmax)); 00551 00552 00553 00554 G4String axisTitle; 00555 UpdateTitle(axisTitle,unitName, fcnName); 00556 h1->add_annotation(tools::histo::key_axis_x_title(), axisTitle); 00557 00558 fH1Vector.push_back(h1); 00559 AddH1Information(name, unitName, fcnName, unit, fcn); 00560 00561 fLockFirstHistoId = true; 00562 #ifdef G4VERBOSE00563 if ( fpVerboseL2 ) 00564 fpVerboseL2->Message("create", "H1", name); 00565 #endif00566 fH1NameIdMap[name] = index + fFirstHistoId; 00567 return index + fFirstHistoId; 00568 } 00569 00570 00571G4intG4RootAnalysisManager::CreateH2(constG4String& name, constG4String& title, 00572 G4int nxbins, G4double xmin, G4double xmax, 00573 G4int nybins, G4double ymin, G4double ymax, 00574 constG4String& xunitName, constG4String& yunitName, 00575 constG4String& xfcnName, constG4String& yfcnName) 00576 00577 { 00578 #ifdef G4VERBOSE00579 if ( fpVerboseL4 ) 00580 fpVerboseL4->Message("create", "H2", name); 00581 #endif00582 G4int index = fH2Vector.size(); 00583 G4double xunit = GetUnitValue(xunitName); 00584 G4double yunit = GetUnitValue(yunitName); 00585 G4Fcn xfcn = GetFunction(xfcnName); 00586 G4Fcn yfcn = GetFunction(yfcnName); 00587 tools::histo::h2d* h2 00588 = new tools::histo::h2d(title, 00589 nxbins, xfcn(xmin), xfcn(xmax), 00590 nybins, yfcn(ymin), yfcn(ymax)); 00591 00592 00593 00594 G4String xaxisTitle; 00595 G4String yaxisTitle; 00596 UpdateTitle(xaxisTitle, xunitName, xfcnName); 00597 UpdateTitle(yaxisTitle, yunitName, yfcnName); 00598 h2->add_annotation(tools::histo::key_axis_x_title(), xaxisTitle); 00599 h2->add_annotation(tools::histo::key_axis_y_title(), yaxisTitle); 00600 00601 fH2Vector.push_back(h2); 00602 AddH2Information(name, xunitName, yunitName, xfcnName, yfcnName, 00603 xunit, yunit, xfcn, yfcn); 00604 00605 fLockFirstHistoId = true; 00606 #ifdef G4VERBOSE00607 if ( fpVerboseL2 ) 00608 fpVerboseL2->Message("create", "H2", name); 00609 #endif00610 fH2NameIdMap[name] = index + fFirstHistoId; 00611 return index + fFirstHistoId; 00612 } 00613 00614 00615G4boolG4RootAnalysisManager::SetH1(G4intid, 00616 G4int nbins, G4double xmin, G4double xmax, 00617 constG4String& unitName, constG4String& fcnName) 00618 { 00619 tools::histo::h1d* h1d = GetH1InFunction(id, "SetH1", false, false); 00620 if ( ! h1d ) returnfalse; 00621 00622 G4HnInformation* info = GetH1Information(id); 00623 #ifdef G4VERBOSE00624 if ( fpVerboseL4 ) 00625 fpVerboseL4->Message("configure", "H1", info->fName); 00626 #endif00627 00628 G4double unit = GetUnitValue(unitName); 00629 G4Fcn fcn = GetFunction(fcnName); 00630 h1d->configure(nbins, fcn(xmin), fcn(xmax)); 00631 info->fXUnitName = unitName; 00632 info->fYUnitName = unitName; 00633 info->fXFcnName = fcnName; 00634 info->fYFcnName = fcnName; 00635 info->fXUnit = unit; 00636 info->fYUnit = unit; 00637 info->fXFcn = fcn; 00638 info->fYFcn = fcn; 00639 SetActivation(kH1, id, true); 00640 00641 G4String axisTitle; 00642 UpdateTitle(axisTitle,unitName, fcnName); 00643 h1d->add_annotation(tools::histo::key_axis_x_title(), axisTitle); 00644 00645 returntrue; 00646 } 00647 00648 00649G4boolG4RootAnalysisManager::SetH2(G4intid, 00650 G4int nxbins, G4double xmin, G4double xmax, 00651 G4int nybins, G4double ymin, G4double ymax, 00652 constG4String& xunitName, constG4String& yunitName, 00653 constG4String& xfcnName, constG4String& yfcnName) 00654 { 00655 tools::histo::h2d* h2d = GetH2InFunction(id, "SetH2", false, false); 00656 if ( ! h2d ) returnfalse; 00657 00658 G4HnInformation* info = GetH2Information(id); 00659 #ifdef G4VERBOSE00660 if ( fpVerboseL4 ) 00661 fpVerboseL4->Message("configure", "H2", info->fName); 00662 #endif00663 00664 G4double xunit = GetUnitValue(xunitName); 00665 G4double yunit = GetUnitValue(yunitName); 00666 G4Fcn xfcn = GetFunction(xfcnName); 00667 G4Fcn yfcn = GetFunction(yfcnName); 00668 h2d->configure(nxbins, xfcn(xmin), xfcn(xmax), 00669 nybins, yfcn(ymin), yfcn(ymax)); 00670 00671 info->fXUnitName = xunitName; 00672 info->fYUnitName = yunitName; 00673 info->fXFcnName = xfcnName; 00674 info->fYFcnName = yfcnName; 00675 info->fXUnit = xunit; 00676 info->fYUnit = yunit; 00677 info->fXFcn = xfcn; 00678 info->fYFcn = yfcn; 00679 SetActivation(kH2, id, true); 00680 00681 G4String xaxisTitle; 00682 G4String yaxisTitle; 00683 UpdateTitle(xaxisTitle, xunitName, xfcnName); 00684 UpdateTitle(yaxisTitle, yunitName, yfcnName); 00685 h2d->add_annotation(tools::histo::key_axis_x_title(), xaxisTitle); 00686 h2d->add_annotation(tools::histo::key_axis_y_title(), yaxisTitle); 00687 00688 returntrue; 00689 } 00690 00691 00692G4boolG4RootAnalysisManager::ScaleH1(G4intid, G4double factor) 00693 { 00694 tools::histo::h1d* h1d = GetH1InFunction(id, "ScaleH1", false, false); 00695 if ( ! h1d ) returnfalse; 00696 00697 return h1d->scale(factor); 00698 } 00699 00700 00701G4boolG4RootAnalysisManager::ScaleH2(G4intid, G4double factor) 00702 { 00703 tools::histo::h2d* h2d = GetH2InFunction(id, "ScaleH2", false, false); 00704 if ( ! h2d ) returnfalse; 00705 00706 return h2d->scale(factor); 00707 } 00708 00709 00710voidG4RootAnalysisManager::CreateNtuple(constG4String& name, 00711 constG4String& title) 00712 { 00713 if ( fNtupleBooking ) { 00714 G4ExceptionDescription description; 00715 description << " "00716 << "Ntuple already exists. "00717 << "(Only one ntuple is currently supported.)"; 00718 G4Exception("G4RootAnalysisManager::CreateNtuple()", 00719 "Analysis_W006", JustWarning, description); 00720 return; 00721 } 00722 00723 00724 if ( fFile && ( ! fNtupleDirectory ) ) { 00725 if ( ! CreateNtupleDirectory() ) return; 00726 } 00727 00728 #ifdef G4VERBOSE00729 if ( fpVerboseL4 ) 00730 fpVerboseL4->Message("create", "ntuple", name); 00731 #endif00732 00733 00734 fNtupleBooking = new tools::ntuple_booking(); 00735 fNtupleBooking->m_name = name; 00736 fNtupleBooking->m_title = title; 00737 00738 00739 00740 if ( fFile ) { 00741 fNtuple = new tools::wroot::ntuple(*fNtupleDirectory, name, title); 00742 00743 } 00744 00745 #ifdef G4VERBOSE00746 if ( fpVerboseL2 ) 00747 fpVerboseL2->Message("create", "ntuple", name); 00748 #endif00749 } 00750 00751 00752G4intG4RootAnalysisManager::CreateNtupleIColumn(constG4String& name) 00753 { 00754 #ifdef G4VERBOSE00755 if ( fpVerboseL4 ) 00756 fpVerboseL4->Message("create", "ntuple I column", name); 00757 #endif00758 00759 if ( ! fNtupleBooking ) { 00760 G4ExceptionDescription description; 00761 description << " "00762 << "Ntuple has to be created first. "; 00763 G4Exception("G4RootAnalysisManager::CreateNtupleIColumn()", 00764 "Analysis_W005", JustWarning, description); 00765 return -1; 00766 } 00767 00768 00769 G4int index = fNtupleBooking->m_columns.size(); 00770 fNtupleBooking->add_column<int>(name); 00771 00772 00773 if ( fNtuple ) { 00774 tools::wroot::ntuple::column<int>* column 00775 = fNtuple->create_column<int>(name); 00776 fNtupleIColumnMap[index] = column; 00777 } 00778 00779 fLockFirstNtupleColumnId = true; 00780 00781 #ifdef G4VERBOSE00782 if ( fpVerboseL2 ) 00783 fpVerboseL2->Message("create", "ntuple I column", name); 00784 #endif00785 00786 return index + fFirstNtupleColumnId; 00787 } 00788 00789 00790G4intG4RootAnalysisManager::CreateNtupleFColumn(constG4String& name) 00791 { 00792 #ifdef G4VERBOSE00793 if ( fpVerboseL4 ) 00794 fpVerboseL4->Message("create", "ntuple F column", name); 00795 #endif00796 00797 if ( ! fNtupleBooking ) { 00798 G4ExceptionDescription description; 00799 description << " "00800 << "Ntuple has to be created first. "; 00801 G4Exception("G4RootAnalysisManager::CreateNtupleFColumn()", 00802 "Analysis_W005", JustWarning, description); 00803 return -1; 00804 } 00805 00806 00807 G4int index = fNtupleBooking->m_columns.size(); 00808 fNtupleBooking->add_column<float>(name); 00809 00810

TIP Sheet
WRITING A DESCRIPTIVE ESSAY

The aim of description is to make sensory details vividly present to the reader. Although it may be only in school that you are asked to write a specifically descriptive essay, description is an important element in many kinds of writing. Description embedded in an argument paper, for example, may be intended to make a position more persuasive. However, in this TIP Sheet we will discuss the descriptive essay as it is commonly assigned by instructors as an exercise in organizing sensory information and choosing vivid details.

Showing vs. telling
Sensory details are details of smell, taste, texture, and sound as well as sight. If you choose "showing" words, those that supply vivid sensory details appropriate to your subject and purpose, you will succeed in showing rather than telling. "Telling" words are usually vague or ambiguous; they can be interpreted in a variety of ways. The following first example mostly makes statements about what is lacking in the room, whereas the second example describes the sights, textures, smells, and sounds of the empty room:

Telling:
The empty room smelled stale and was devoid of furniture or floor covering; the single window lacked curtains or blinds of any kind.

Showing:
The apartment smelled of old cooking odors, cabbage, and mildew; our sneakers squeaked sharply against the scuffed wood floors, which reflected a haze of dusty sunlight from the one cobwebbed, gritty window.

"Showing" uses very specific details: cabbage and mildew, scuffed and dusty floors, unwashed windows. Though the writer of the second example does not actually use the word "empty," she nevertheless suggests emptiness and disuse. The suggestion of emptiness in the second example is more vivid than the statement of emptiness in the first. If you don't think the first example is vague, look at another possible interpretation of that empty room:

 

Showing:
The sharp odor of fresh paint cut through the smell of newsprint. Four stacked cartons of inkjet printer paper sat squarely in the middle of a concrete floor, illuminated by a shaft of morning light from a sparkling chrome-framed window on the opposite wall.

Do not mistake explanation for description. Explanation is a kind of telling that interjects background material that does not contain sensory details or contribute to the overall effect–a character's motives or history, for example:

Explanation:
The tenants had moved out a week earlier because the house was being sold to a developer. No one had bothered to dust or clean because they assumed the apartment was going to be knocked down and replaced with single-family homes like those built just a block away.

When description devolves into explanation (telling rather than showing), it becomes boring.

Observing details
Once you are ready to abandon the attempt to explain or to tell about, evaluate your subject in terms of visual, auditory, and other sensory details. Think in concrete terms. The more you are interested in and connected to the subject, the easier it will be to interest your reader, so if you describe a person, choose a person whose characteristics stand out to you. If you describe a place or a thing, choose one that is meaningful to you.

You are painting a picture that must be as clear and real as possible, so observe carefully and, preferably, in person. Note what sets this subject apart from others like it. If the subject is a person, include physical characteristics and mannerisms. Describe abstractions such as personality traits only insofar as you can observe them. For example, do not tell the reader your biology instructor is a neat, meticulous person; show your reader the instructor's "dust-free computer monitor and stacks of papers with corners precisely aligned, each stack sitting exactly three thumb-widths from the edge of the desk." How a subject interacts with others is fair game for description if you can observe the interaction. On the other hand, a subject's life history and world perspective may not be, unless you can infer them, for example, from the photos on his walls or the books on his bookshelf.

Similarly, if the subject of your description is an object or a place, you may include not only its physical appearance but also its geographic, historical, or emotional relevance-as long as you show or suggest it using sensory details, and avoid explaining.

Deciding on a purpose
Even description for description's sake should have a purpose. Is there an important overall impression you wish to convey? A central theme or general point? This is your thesis; organize your essay around it. For example, you might describe your car as your home away from home, full of snack foods, changes of clothing, old issues of the Chico News & Review, textbooks, and your favorite music. Or, you might describe your car as an immaculate, beautiful, pampered woman on whom you lavish attention and money. Just don't describe your car in cold, clinical detail, front to back (or bottom to top, or inside to outside) without having in mind the purpose, the overall impression you want to create. To achieve this impression, you should not necessarily include all details; use only those that suit your purpose.

Avoid telling a story unless it is of central importance to the description or an understanding of it. Keep background information to an absolute minimum or avoid it altogether.

Organizing
Extended description that lacks organization has a confusing, surreal quality and easily loses readers' interest, so choose an organizational plan. Use whatever progression seems logical–left to right, inside to outside, top to bottom-and stick to it. For example, it does not make sense to describe a person's facial features and hair, then his sonorous voice and impressive vocabulary, and then return to details about his eyebrows and glasses.

A quote from your subject or a brief anecdote about him or her may provide an interesting introduction (or conclusion); dialogue can be a great way to add interest to a descriptive essay. In your introduction, you might be permitted to make general, abstract statements (tell about) your subject or supply background information, as long as you demonstrate these points concretely later in the body of your essay.

Use vivid nouns, verbs, and adjectives, and appropriate metaphors, similes, comparisons, and contrasts. Avoid clichés.

Like the introduction, the conclusion is another place you can get away with reflecting about your subject: Why did you write this description? What is its significance to you? To your reader? If you have achieved your purpose, your conclusion should only confirm in the reader's mind what you have already shown him by your use of selected sensory details.

0 thoughts on “G4exception Descriptive Essay”

    -->

Leave a Comment

Your email address will not be published. Required fields are marked *