|
Laura++
3.6.0
A maximum likelihood fitting package for performing Dalitz-plot analysis.
|
Go to the documentation of this file.
35 #include "TObjArray.h"
45 const TString& outputFileName,
46 const TString& treeName ) :
47 inputFileName_( inputFileName ),
48 outputFileName_( outputFileName ),
49 treeName_( treeName ),
72 TObjArray* leaves = inputTree_->GetListOfLeaves();
73 Int_t nLeaves = leaves->GetEntries();
75 std::cout << "Setting branches for input tree \"" << inputTree_->GetName() << "\" with "
76 << nEntries_ << " entries..." << std::endl;
82 for ( Int_t iLeaf( 3 ); iLeaf < nLeaves; ++iLeaf ) {
84 TLeaf* leaf = dynamic_cast<TLeaf* >( ( *leaves )[iLeaf] );
85 TString type = leaf->GetTypeName();
86 TString name = leaf->GetName();
87 Int_t size = leaf->GetNdata();
89 if ( ( type != "Double_t" ) || ( size != 1 ) ) {
93 std::pair<std::map<TString, Double_t>::iterator, bool> result = otherVars_.insert(
94 std::make_pair( name, 0.0 ) );
95 std::map<TString, Double_t>::iterator iter = result.first;
96 bool ok = result.second;
102 std::cout << "Set branch addresses for " << otherVars_.size() + 3 << " branches.\n"
108 std::cout << "Creating branches for output tree \"" << tree->GetName() << "\"..." << std::endl;
110 tree->Branch( "iExpt", & iExpt_, "iExpt/I" );
111 tree->Branch( "fitStatus", & fitStatus_, "fitStatus/I" );
112 tree->Branch( "NLL", & NLL_, "NLL/D" );
113 tree->Branch( "EDM", & EDM_, "EDM/D" );
115 for ( std::map<TString, Double_t>::iterator iter = otherVars_.begin(); iter != otherVars_.end();
117 TString name = iter->first;
118 Double_t* address = &( iter->second );
119 TString thirdBit = name;
122 tree->Branch( name, address, thirdBit );
124 std::cout << "Created " << otherVars_.size() << " branches.\n" << std::endl;
129 inputTree_->SetBranchStatus( "iExpt", kTRUE );
130 inputTree_->SetBranchStatus( "fitStatus", kTRUE );
134 for ( std::map<TString, Double_t>::iterator iter = otherVars_.begin(); iter != otherVars_.end();
136 TString name = iter->first;
145 delete ( iter->second );
160 if ( ! textFile.good() ) {
161 std::cerr << "Problem opening file: \"" << inputFileName_ << "\", exiting..." << std::endl;
162 gSystem->Exit( EXIT_FAILURE );
172 TString inputFileName = "";
173 while ( inputFileName.ReadLine( textFile ) && ( ! inputFileName.IsNull() ) ) {
174 if ( inputFileName.EndsWith( ".root" ) && ! inputFileName.BeginsWith( "#" ) ) {
175 std::cout << inputFileName << std::endl;
178 std::cout << inputFileName << "\t *** Skipped ***" << std::endl;
197 std::cout << "Setting up the map..." << std::flush;
199 for ( Int_t i( 0 ); i < numExpts; ++i ) {
200 bestNLL_.insert( std::make_pair( i, std::make_pair( 0.0, -1 ) ) );
201 worstNLL_.insert( std::make_pair( i, std::make_pair( 0.0, -1 ) ) );
202 allNLLs_.insert( std::make_pair( i, std::vector<Double_t>() ) );
205 std::cout << " done.\n" << std::endl;
211 std::cout << "Starting to store best entry info..." << std::endl;
212 for ( Int_t j( 0 ); j < nEntries_; ++j ) {
215 std::cout << "Examining entry " << j << std::endl;
225 if ( ( NLL_ < curBestNLL ) || ( curBestEntry == -1 ) ) {
231 if ( ( NLL_ > curWorstNLL ) || ( curWorstEntry == -1 ) ) {
236 std::cout << "Finished storing best entry info.\n" << std::endl;
238 std::cout << "Creating NLL histograms..." << std::flush;
240 for ( Int_t i( 0 ); i < numExpts; ++i ) {
243 Double_t range = max - min;
244 if ( range < 1e-3 ) {
251 TString name( "expt" );
254 histo = new TH1F( name, "", 100, min, max );
255 for ( std::vector<Double_t>::const_iterator iter = allNLLs_[i].begin();
258 histo->Fill( *iter );
260 nllHistos_.insert( std::make_pair( i, histo ) );
262 std::cout << " done.\n" << std::endl;
267 std::ofstream fout( "best-fit.txt" );
270 std::cout << "Starting to retrieve best entries and fill output tree." << std::endl;
271 for ( Int_t i( 0 ); i < numExpts; ++i ) {
272 Int_t bestEntry = bestNLL_[i].second;
273 if ( bestEntry != -1 ) {
277 if ( ( numExpts < 100 ) || ( i % ( numExpts / 100 ) == 0 ) ) {
278 std::cout << "Writing out experiment " << i << std::endl;
280 TString bestFit( inputTree_->GetCurrentFile()->GetName() );
281 bestFit.Remove( 0, 3 );
282 Int_t index = bestFit.Index( "_" );
284 index = bestFit.Index( "." );
286 bestFit.Remove( index );
287 fout << "Experiment " << i << " BestFit " << bestFit << std::endl;
289 std::cout << "Finished filling best entries in output tree.\n" << std::endl;
292 std::cout << "Writing output file." << std::endl;
const TString & name() const The parameter name.
Double_t range() const The range allowed for the parameter.
|