#include #include #include #include #include #include #include #include #include #include "AMPTOOLS_DATAIO/ROOTDataReader.h" #include "AMPTOOLS_DATAIO/ROOTDataWriter.h" #include "CLHEP/Vector/LorentzVector.h" #include "TH1F.h" using namespace std; using namespace CLHEP; #define DEFTREENAME "kin" void Usage() { cout << "Usage:\n split_mass [maxEvents]\n"; cout << " split_mass -T [tree name]\n\n"; cout << " overwrites the default ROOT tree name (\"kin\") in output and/or input files\n"; cout << " To specify input and output names delimit with \':\' ex. -T inKin:outKin\n"; cout << " Use -t to update existing files with new tree, instead of overwritting.\n"; exit(1); } pair GetTreeNames(char* treeArg) { pair treeNames(DEFTREENAME,""); string treeArgStr(treeArg); size_t delimPos=treeArgStr.find(':',1); if (delimPos != string::npos){ treeNames.first=treeArgStr.substr(0,delimPos); treeNames.second=treeArgStr.substr(delimPos+1); }else treeNames.second=treeArgStr; return treeNames; } int main( int argc, char* argv[] ){ unsigned int maxEvents = 4294967000; //close to 4byte int range //string treeName( "kin" ); pair treeNames(DEFTREENAME,DEFTREENAME); bool recreate=true; if( argc < 6 ) Usage(); string outBase( argv[2] ); double lowMass = atof( argv[3] ); double highMass = atof( argv[4] ); int numBins = atoi( argv[5] ); // A somewhat convoluted way to allow tree name specification // via "-t [name]" in the arg. list after the standard args if( argc > 6 ) { for(int i=6; i<=7 && i fs = event->particleList(); HepLorentzVector x; // the first two entries in this list are the beam and the recoil // skip them in computing the mass for( vector< HepLorentzVector >::iterator particle = fs.begin() + 2; particle != fs.end(); ++particle ){ x += *particle; } int bin = static_cast< int >( floor( ( x.m() - lowMass ) / step ) ); if( ( bin < numBins ) && ( bin >= 0 ) ){ outFile[bin]->writeEvent( *event ); delete event; } } for( int i = 0; i < numBins; ++i ){ delete outFile[i]; } return 0; }