ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/cbrown/Development/Plotting/Modules/GeneralToolBox.C
(Generate patch)

Comparing UserCode/cbrown/Development/Plotting/Modules/GeneralToolBox.C (file contents):
Revision 1.6 by buchmann, Wed Apr 18 12:48:24 2012 UTC vs.
Revision 1.7 by buchmann, Mon Apr 30 08:39:09 2012 UTC

# Line 120 | Line 120 | string topdir(string child) {
120          return tempdirectory.substr(0,ichar);
121        }
122      }
123 +    return "TOPDIRFAILURE";
124   }
125  
126   template < typename CHAR_TYPE,
# Line 279 | Line 280 | void initialize_log() {
280      dout << "        PUBLIC MODE     " << endl;
281    }
282    time_t rawtime;
282  struct tm * timeinfo;
283    time ( &rawtime );
284    dout << "       Analysis run on " << asctime (localtime ( &rawtime ));
285    dout << "____________________________________________________________" << endl;
# Line 298 | Line 298 | void set_directory(string basedir="") {
298    if(basedir.substr(0,1)=="/") basedir=basedir.substr(1,basedir.length()-1);
299    if(basedir.substr(basedir.length()-1,1)!="/") basedir+="/";
300    char currentpath[1024];
301 <  char *path = getcwd(currentpath,1024);
301 >  getcwd(currentpath,1024);
302    PlottingSetup::basedirectory=(string)currentpath+"/Plots/"+basedir;
303    ensure_directory_exists(PlottingSetup::basedirectory);
304    initialize_log();
# Line 323 | Line 323 | string extract_directory(string savethis
323   string extract_root_dir(string name) {
324      int position = -1;
325      if(name.substr(0,1)=="/") name=name.substr(1,name.length()-1);
326 <    for(int ipos=0;ipos<name.length();ipos++) {
326 >    for(int ipos=0;ipos<(int)name.length();ipos++) {
327          if(name.substr(ipos,1)=="/") position=ipos;
328      }
329      if(position==-1) return "";
# Line 333 | Line 333 | string extract_root_dir(string name) {
333   string extract_root_filename(string name) {
334      int position = -1;
335      if(name.substr(0,1)=="/") name=name.substr(1,name.length()-1);
336 <    for(int ipos=0;ipos<name.length();ipos++) {
336 >    for(int ipos=0;ipos<(int)name.length();ipos++) {
337          if(name.substr(ipos,1)=="/") position=ipos;
338      }
339      return name.substr(position+1,name.length()-position-1);
# Line 416 | Line 416 | void write_entry(string entry,int width,
416    int currwidth=entry.size();
417    while(currwidth<width) {
418      entry=" "+entry;
419 <    if(entry.size()<width) entry=entry+" ";
419 >    if((int)entry.size()<width) entry=entry+" ";
420      currwidth=entry.size();
421    }
422    bool do_special=false;
# Line 430 | Line 430 | void write_entry(string entry,int width,
430   void make_nice_table(vector<vector <string> > &entries) {
431    int ncolumns=write_first_line(entries);
432    int cellwidth=(int)(((float)(60-(ncolumns+1)))/(ncolumns));
433 <  for(int iline=0;iline<entries.size();iline++) {
433 >  for(int iline=0;iline<(int)entries.size();iline++) {
434      vector<string> currline = entries[iline];
435      dout << " |";
436 <    for(int ientry=0;ientry<currline.size();ientry++) {
436 >    for(int ientry=0;ientry<(int)currline.size();ientry++) {
437        write_entry(currline[ientry],cellwidth);
438      }
439      dout << endl;
# Line 445 | Line 445 | void make_nice_table(vector<vector <stri
445   void make_nice_jzb_table(vector<vector <string> > &entries) {
446    int ncolumns=write_first_line(entries);
447    int cellwidth=(int)(((float)(60-(ncolumns+1)))/(ncolumns));
448 <  for(int iline=0;iline<entries.size();iline++) {
448 >  for(int iline=0;iline<(int)entries.size();iline++) {
449      vector<string> currline = entries[iline];
450      dout << " |";
451 <    for(int ientry=0;ientry<currline.size();ientry++) {
451 >    for(int ientry=0;ientry<(int)currline.size();ientry++) {
452        write_entry(currline[ientry],cellwidth,iline,ientry);
453      }
454      dout << endl;
# Line 599 | Line 599 | TGraph* make_nice_ratio(int nbins,float
599      bincontent[i]=0;
600      errors[i]=0;
601    }
602 <  float currlimit=binning[0];
602 > //  float currlimit=binning[0];
603    int currtoplim=1;
604    for(int ibin=1;ibin<=histo->GetNbinsX();ibin++)
605    {
# Line 637 | Line 637 | TGraphAsymmErrors *histRatio(TH1F *h1,TH
637          int absJZBbinsNumber = binning.size()-1;
638          TGraphAsymmErrors* graph = new TGraphAsymmErrors(absJZBbinsNumber);
639          
640 <        for(unsigned int i=0;i<absJZBbinsNumber;i++)
640 >        for(int i=0;i<absJZBbinsNumber;i++)
641          {
642                  float xCenter=h1->GetBinCenter(i+1);
643                  float xWidth=(h1->GetBinWidth(i+1))*0.5;
# Line 749 | Line 749 | void splitupcut(string incut, vector<str
749      int paranthesis_open=0;
750      int substr_start=0;
751      string currchar="";
752 <    for (int ichar=0;ichar<incut.length();ichar++)
752 >    for (int ichar=0;ichar<(int)incut.length();ichar++)
753      {
754          currchar=incut.substr(ichar,1);
755   //        if(currchar=="(") paranthesis_open++;
# Line 762 | Line 762 | void splitupcut(string incut, vector<str
762      partvector.push_back(incut.substr(substr_start,incut.length()-substr_start));
763      if(Verbosity>1) {
764          dout << "[ splitupcut() ] : The cut vector now contains the following elements: "<< endl;
765 <        for (int ipart=0;ipart<partvector.size();ipart++)
765 >        for (int ipart=0;ipart<(int)partvector.size();ipart++)
766          {
767              dout << "     - " << partvector[ipart] << endl;
768          }
# Line 771 | Line 771 | void splitupcut(string incut, vector<str
771  
772   int atleastvalue(string expression, int &morethanlessthan) // takes in an expression such as ">2" or ">=3" and returns e.g. 3 (in both examples)
773   {
774 <  int retval=0;
774 > //  int retval=0;
775    if(expression.substr(0,1)==">"&&expression.substr(1,1)=="=") {
776   //    dout << "The expression " << expression << " is saying that we have at least " << atoi(expression.substr(2,1).c_str()) << " jets" << endl;
777      morethanlessthan=1;
# Line 797 | Line 797 | int atleastvalue(string expression, int
797      morethanlessthan=-1;
798      return 1+atoi(expression.substr(2,1).c_str());
799    }
800 +  
801 +  return -1234567;
802   }
803  
804   int do_jet_cut(string incut, int *nJets) {
# Line 832 | Line 834 | int do_jet_cut(string incut, int *nJets)
834      dout << "Is of type >" << endl;
835      return 0;
836    }
837 +  return -12345;
838   }
839  
840   string interpret_cut(string incut, bool &isJetCut, int *permittednJets)
# Line 897 | Line 900 | string interpret_cuts(vector<string> &cu
900      int finalJetCut=-1;
901      int permittednJets[20];
902      for(int ijet=0;ijet<20;ijet++) permittednJets[ijet]=1;
903 <    int morethanlessthan=0;//-1: less than, 0: exactly, 1: more than
904 <    for(int icut=0;icut<cutparts.size();icut++)
903 > //    int morethanlessthan=0;//-1: less than, 0: exactly, 1: more than
904 >    for(int icut=0;icut<(int)cutparts.size();icut++)
905      {
906          if(icut==0) nicecut<<interpret_cut(cutparts[icut],isJetCut,permittednJets);
907          else {
# Line 963 | Line 966 | TH1F * makehistofromfunction(TF1 *f1,TH1
966    histo->SetTitle(histoname.str().c_str());
967    histo->SetName(histoname.str().c_str());
968    int nbins=histo->GetNbinsX();
969 <  float low=histo->GetBinLowEdge(1);
970 <  float hi=histo->GetBinLowEdge(histo->GetNbinsX())+histo->GetBinWidth(histo->GetNbinsX());
969 > //  float low=histo->GetBinLowEdge(1);
970 > //  float hi=histo->GetBinLowEdge(histo->GetNbinsX())+histo->GetBinWidth(histo->GetNbinsX());
971    
972    for(int i=0;i<=nbins;i++) {
973      histo->SetBinContent(i,(f1->Integral(histo->GetBinLowEdge(i),histo->GetBinLowEdge(i)+histo->GetBinWidth(i)))/histo->GetBinWidth(i));
# Line 1333 | Line 1336 | void save_with_ratio(TH1F *nominator, TH
1336    
1337    Double_t chi2;
1338    Int_t ndf,igood;
1339 <  Double_t res=0.0;
1339 > //  Double_t res=0.0;
1340    Double_t chi2prob = MarcosChi2TestX(nominator,denominator,chi2,ndf,igood,"UW");
1341  
1342    stringstream Chi2text;
# Line 1429 | Line 1432 | vector<string> StringSplit(string str, s
1432          vector<string> results;
1433          
1434          int cutAt;
1435 <        while( (cutAt = str.find_first_of(delim)) != str.npos )
1435 >        while( (cutAt = str.find_first_of(delim)) != (int)str.npos )
1436          {
1437                  if(cutAt > 0)
1438                  {
# Line 1446 | Line 1449 | vector<string> StringSplit(string str, s
1449  
1450   void manually_set_jzb_cuts(vector<float> &jzb_cut,string jzbcut_string) {
1451          vector<string> jzbcutvector = StringSplit(jzbcut_string,",");
1452 <        for(int i=0;i<jzbcutvector.size();i++) {
1452 >        for(int i=0;i<(int)jzbcutvector.size();i++) {
1453                  jzb_cut.push_back(atoi(jzbcutvector[i].c_str()));
1454                  dout << "Added a JZB cut manually at " << atoi(jzbcutvector[i].c_str()) << endl;
1455          }
# Line 1460 | Line 1463 | void process_directory(TString directory
1463          dp = opendir (directory);
1464          if (dp != NULL)
1465          {
1466 <                while (ep = readdir (dp))
1466 >                while ((ep = readdir (dp)))
1467                  {
1468                          string filename=(string)ep->d_name;
1469 <                        if(filename.find(".root")!=-1)
1469 >                        if((int)filename.find(".root")!=-1)
1470                          {
1471                                  files.push_back(string(directory)+filename);
1472                          }
# Line 1550 | Line 1553 | float pSTAR(float mglu, float mlsp, floa
1553   }
1554  
1555   float generalizedpSTAR(float massmother, float massdaughter1, float massdaughter2) {
1553        float mz=91.2;
1556          float res=((massmother*massmother)-(massdaughter1+massdaughter2)*(massdaughter1+massdaughter2));
1557          res*=((massmother*massmother)-(massdaughter1-massdaughter2)*(massdaughter1-massdaughter2));
1558          res=TMath::Sqrt(res)/(2*massmother);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines