00001
00002
00003 #include <TEventList.h>
00004 #include <TH1.h>
00005 #include <TROOT.h>
00006
00007 unsigned int errorCode = 0;
00008
00009
00010 int count(TTree& t, string name, string cut) {
00011 string cmd = ">>" + name;
00012 t.Draw(cmd.c_str(), cut.c_str());
00013 TEventList *list = (TEventList*)gDirectory->Get(name.c_str());
00014
00015 return list->GetN();
00016 }
00017
00025 double cut(TTree& t, string name, string quantity, double meanCut, double rmsCut, double numberCut, bool prependAbs=true, string cut="1>0") {
00026 string histname = "h" + name;
00027 string cmd = quantity + ">>" + histname + "(100)";
00028 t.Draw(cmd.c_str(), cut.c_str());
00029 TH1* hist = (TH1*)gDirectory->Get(histname.c_str());
00030
00031 if (hist->GetMean() > meanCut) {
00032 ++errorCode;
00033 cout << "Failed mean cut for: " << quantity << " cut: " << meanCut << endl;
00034 }
00035 if (hist->GetRMS() > rmsCut) {
00036 ++errorCode;
00037 cout << "Failed rms cut for: " << quantity << " cut: " << meanCut << endl;
00038 }
00039
00040 ostringstream oss;
00041 if (prependAbs) oss << "abs";
00042 oss << quantity << ">" << numberCut << " && " << cut;
00043 return count(t, name, oss.str())/(double)t.GetEntriesFast();
00044 }