Classes | Functions
rootgINukeVal.C File Reference
#include <iostream>
#include <fstream>
#include <sstream>
#include <list>
#include <TMath.h>
#include <TCanvas.h>
#include <TError.h>
#include <TTree.h>
#include <string>
#include <TCollection.h>
#include <TNtuple.h>
#include <vector>
#include <typeinfo>
#include <genieStyle.C>

Go to the source code of this file.

Classes

class  DataFile
 
class  FormatFile
 

Functions

string trim (string in)
 
int rootgINukeVal (char *fFile, char *dataDir=".", char *ROOTDir=".", char *saveDir=".")
 

Function Documentation

int rootgINukeVal ( char *  fFile,
char *  dataDir = ".",
char *  ROOTDir = ".",
char *  saveDir = "." 
)

Definition at line 458 of file rootgINukeVal.C.

459 {
460  string tFile (fFile);
461  string dDir (dataDir);
462  int legendSize; //counting entries in legend
463  float TextSize, y1; //adjusted font size and lower bound on legend
464  FormatFile format (tFile);
465  TCanvas* cans;
466  set_root_env();
467  size_t curRecord=1;
468  bool doCurrent = false;
469  doCurrent = format.process(curRecord);
470  if(doCurrent == false){
471  //This if statement shouldn't be necessary, but if it
472  // isn't here, the while loop tries to execute anyways...
473  cout<<"Format File not found"<<endl;
474  return 0;
475  }
476  while(doCurrent == true){
477  cout<<format.numOfType("GENIE")<<" root files and "<<format.numOfType("EXPERIMENTAL")<<" published data files "<<endl;
478 
479  int legendSize = format.numOfType("GENIE") + format.numOfType("EXPERIMENTAL");
480  stringstream convert;
481  //gStyle->SetErrorX(0);
482  //gStyle->SetStyle(genieStyle);
483  set_root_env();
484  Double_t size = 0;
485  Int_t num = 0;
486  Int_t target = 0;
487  Int_t A = 0;
488  Double_t factor = 0;
489  TH1F* htemp = 0;
490  bool good = false;
491  //gROOT->SetStyle("T2K");
492 
493  //the FormatFile class holds the graph limits as strings, converting here
494  Double_t xl, yl, xu, yu;
495  convert.str(format.xl); convert.clear();
496  convert >> xl;
497  convert.str(format.yl); convert.clear();
498  convert >> yl;
499  convert.str(format.xu); convert.clear();
500  convert >> xu;
501  convert.str(format.yu); convert.clear();
502  convert >> yu;
503 
504  //Creating a new canvas and setting some parameters
505  string canName;
506  canName.assign(curRecord,'*');
507  cans= new TCanvas(canName.c_str(),format.fetchGTitle().c_str());
508  cans->cd();
509  TPad* curP = gPad;
510  if(format.logx==true){gPad->SetLogx(1);}
511  if(format.logy==true){gPad->SetLogy(1);}
512 
513  TextSize = .035;
514  y1 = 1.05-(.075*legendSize);//1, .075
515 
516  TLegend* leg1 = new TLegend(.52,y1,1,1,"");//.6
517  leg1->SetTextSize(TextSize);
518  //TLegend* leg1 = new TLegend(.6,.8,1,1,"");
519 
520  //Get the frame, set parameters, redraw frame
521  TH1F* hf1 = (TH1F*) cans->DrawFrame(xl,yl,xu,yu);
522  hf1->SetTitle(format.mtitle.c_str());
523  if(format.type.compare("Angle")==0){
524  hf1->GetXaxis()->SetTitle("cos(#theta)");
525  hf1->GetYaxis()->SetTitle("#frac{d#sigma}{d#Omega} [#frac{mb}{sr}]");
526  }
527  else if(format.type.compare("Momentum")==0){
528  hf1->GetXaxis()->SetTitle("Momentum [Mev]");
529  hf1->GetYaxis()->SetTitle("#frac{d#sigma}{dp} [#frac{mb}{MeV}]");
530  }
531  else if(format.type.compare("XS")==0){
532  hf1->GetXaxis()->SetTitle("Energy [MeV]");
533  hf1->GetYaxis()->SetTitle("#sigma (mb)");
534  }
535  else{
536  hf1->GetXaxis()->SetTitle("Energy [MeV]");
537  hf1->GetYaxis()->SetTitle("#frac{d#sigma}{d#OmegadE} [#frac{mb}{sr#upointMev}]");
538  }
539  //hf1->GetXaxis()->SetNdivisions(-50202);
540  hf1->GetYaxis()->CenterTitle();
541  hf1->Draw();
542 
543 
544  //Loop over each GINUKE file, scaling and drawing each
545  int numRoots = format.numOfType("GENIE");
546  int k;
547  int markerStyle=20;
548 
549 
550  for(k=0;k<numRoots;k++){
551  DataFile* simData = format.makeDataFile(k,ROOTDir,"GENIE");
552  if(format.type.compare("XS")==0){
553  cans->cd();
554  //Do things completely differently
555  int curCol = simData->color;
556  simData->dataTuple->SetMarkerColor(curCol);
557  simData->dataTuple->SetMarkerStyle(markerStyle);
558  markerStyle++;
559  simData->dataTuple->SetLineStyle(2);//2
560  simData->dataTuple->SetLineColor(curCol);
561  cout<<"About to draw tuple"<<endl;
562  //simData->dataTuple->Draw();
563  cout<<simData->cut.c_str()<<endl;
564  simData->dataTuple->Draw(simData->cut.c_str(),"","line psame L");
565  leg1->AddEntry(simData->dataTuple,simData->title.c_str(),"P");
566  cout<<"Tuple drawn"<<endl;
567  }
568  else{
569  TCanvas* tempVas = new TCanvas("tempName","No title");
570  tempVas->cd();
571  //TPad* curP = gPad;
572  string newCut = simData->cut;
573  newCut = newCut +"&&"+simData->cols+"<="+format.xu;
574  newCut = newCut + "&&"+simData->cols+">"+format.xl;
575  simData->dataTree->Draw(simData->cols.c_str(),newCut.c_str(), "L");
576  //tempVas is used in order to not clobber cans's htemp
577  if(simData->valid()){
578 
579  //Grab the associated histogram from tempVas, apply scaling factor
580  htemp = (TH1F*) gPad->GetPrimitive("htemp");
581  TH1F* hist1;
582  TH1F* hist1error;
583  good=false;
584  //Make sure that something actually existed in the cut
585  if (htemp != 0x0) {
586  good=true;
587  hist1 = (TH1F*) htemp->Clone("hist1");
588  size = hist1->GetBinWidth(1);
589  hist1->Sumw2();
590  hist1->Rebin(format.binFactor);
591  num = simData->dataTree->GetEntries();
592  simData->dataTree->SetBranchAddress("tgt",&target);
593  simData->dataTree->GetEntry(1);
594  A = (target/10) - (target/10000)*1000;
595  factor = TMath::Power(3*1.4*TMath::Power(A,(1.0/3.0)),2)*10.0/(2*num*simData->dcth);
596  hist1->Scale(factor,"width");
597  int curCol = simData->color;
598  hist1->SetMarkerColor(curCol);
599  hist1->SetMarkerStyle(markerStyle);
600  markerStyle++;
601  hist1->SetLineStyle(2);
602  hist1->SetLineColor(curCol);
603  }
604  else{
605  cout<<"Nothing was found in the cut of "<<simData->filename<<endl;
606  }
607  if(good){
608  //Draw a copy of histogram to cans on top of any other histograms already there
609  cans->cd();
610  //TPad* curP = gPad;
611  leg1->AddEntry(hist1,simData->title.c_str());
612  hist1->DrawCopy("e1 psame");//e1 psame
613  hist1->Draw("hist l same");
614 
615  //make and draw an extra histogram to have solid error bars
616  hist1error = (TH1F*) hist1->Clone("hist1error");
617  hist1error->SetLineStyle(1);
618  hist1error->DrawCopy("e1 same");
619  }
620  }
621  else{
622  cout<<"Something is wrong with data file "<<simData->filename<<endl;
623  cans->cd();
624  }
625  tempVas->Close();
626  }
627  }
628 
629  //Draw all of the Experimental files, I'm pretty sure that this will only handle
630  // the simple tree type generated from the .txt type data files.
631  cans->cd();
632  TPad* curP = gPad;
633  int numFiles = format.numOfType("EXPERIMENTAL");
634 
635  /*
636  int j = 0;
637 
638  for(j=0;j<3;j++){
639  DataFile* experimental = format.makeDataFile(0,dDir,"EXPERIMENTAL");
640  TGraphErrors* data1;
641  if(format.type.compare("XS")==0){
642  experimental->dataTuple->Draw(experimental->cut.c_str(),"","goff");
643  data1 = new TGraphErrors(experimental->dataTuple->GetSelectedRows(),experimental->dataTuple->GetV1(), experimental->dataTuple->GetV2(),experimental->dataTuple->GetV3(),experimental->dataTuple->GetV4());
644  }
645  else{
646  experimental->dataTree->Draw(experimental->cols.c_str(),"","goff");
647  data1 = new TGraphErrors(experimental->dataTree->GetSelectedRows(),experimental->dataTree->GetV2(), experimental->dataTree->GetV1(),0,experimental->dataTree->GetV3());
648  }
649  //data1->SetLineStyle(0);
650  data1->SetMarkerColor(experimental->color);
651  data1->SetMarkerStyle(markerStyle);
652  markerStyle++;
653  leg1->AddEntry(data1,experimental->title.c_str(),"P");
654  data1->Draw("p same");
655  }
656  */
657 
658  for(j=0;j<numFiles;j++){
659  DataFile* experimental = format.makeDataFile(j,dDir,"EXPERIMENTAL");
660  TGraphErrors* data1;
661  if(format.type.compare("XS")==0){
662  experimental->dataTuple->Draw(experimental->cut.c_str(),"","goff");
663  data1 = new TGraphErrors(experimental->dataTuple->GetSelectedRows(),experimental->dataTuple->GetV1(), experimental->dataTuple->GetV2(),experimental->dataTuple->GetV3(),experimental->dataTuple->GetV4());
664  }
665  else{
666  experimental->dataTree->Draw(experimental->cols.c_str(),"","goff");
667  data1 = new TGraphErrors(experimental->dataTree->GetSelectedRows(),experimental->dataTree->GetV2(), experimental->dataTree->GetV1(),0,experimental->dataTree->GetV3());
668  }
669  data1->SetLineStyle(3);
670  data1->SetMarkerColor(experimental->color);
671  data1->SetMarkerStyle(markerStyle);
672  markerStyle++;
673  leg1->AddEntry(data1,experimental->title.c_str(),"P");
674  data1->Draw("p same");
675  }
676 
677 
678  //Draw the legend
679 
680  //set_root_env();
681  leg1->SetLineWidth(2);
682  leg1->Draw();
683 
684  //add_plot_label("THIS IS A TEST #alpha #Alpha#gamma", .5, .5, .05);
685 
686  //Save the record
687  string saveName(saveDir);
688  saveName = saveName+"/"+format.savename+".png";
689  cans->SaveAs(saveName.c_str());
690 
691  //Try to find the next record
692  curRecord++;
693  cout<<"\nLooking for next record:"<<endl;
694  doCurrent = format.process(curRecord);
695  }
696  cout<<"No more records found, exiting"<<endl;
697  //delete [] entryArray;
698  return 0;
699 }
bool valid()
Definition: rootgINukeVal.C:96
TLegend * leg1
Definition: f2_nu.C:538
string cols
Definition: rootgINukeVal.C:83
string cut
Definition: rootgINukeVal.C:85
the ParameterSet object passed in for the configuration of a destination should be the only source that can affect the behavior of that destination This is to eliminate the dependencies of configuring a destination from multiple mostly from the defaults It suppresses possible glitches about changing the configuration file somewhere outside of a destination segament might still affect the behavior of that destination In the previous configuration for a specific the value of a certain e may come from following and have been suppressed It the configuring ParameterSet object for each destination will be required to carry a parameter list as complete as possible If a parameter still cannot be found in the ParameterSet the configuration code will go look for a hardwired default directly The model is a great simplicity comparing with the previous especially when looking for default values Another great advantage is most of the parameters now have very limited places that allows to appear Usually they can only appear at one certain level in a configuration file For in the old configuring model or in a default ParameterSet object inside of a or in a category or in a severity object This layout of multiple sources for a single parameter brings great confusion in both writing a configuration and in processing the configuration file Under the new the only allowed place for the parameter limit to appear is inside of a category which is inside of a destination object Other improvements simplify the meaning of a destination name In the old a destination name has multiple folds of meanings the e cout and cerr have the special meaning of logging messages to standard output or standard error the name also serves as the output filename if the destination is a file these names are also references to look up for detailed configurations in configuring the MessageFacility The multi purpose of the destination name might cause some unwanted behavior in either writing or parsing the configuration file To amend in the new model the destination name is now merely a name for a which might represent the literal purpose of this or just an id All other meanings of the destinations names now go into the destination ParameterSet as individual such as the type parameter and filename parameter Following is the deatiled rule for the new configuring Everything that is related with MessageFacility configuration must be wrapped in a single ParameterSet object with the name MessageFacility The MessageFacility ParameterSet object contains a series of top level parameters These parameters can be chosen a vector of string listing the name of debug enabled models Or use *to enable debug messages in all modules a vector of string a vector of string a vector of string a ParameterSet object containing the list of all destinations The destinations ParameterSet object is a combination of ParameterSet objects for individual destinations There are two types of destinations that you can insert in the destinations ParameterSet ordinary including cout
float dcth
Definition: rootgINukeVal.C:86
string title
Definition: rootgINukeVal.C:82
TNtuple * dataTuple
Definition: rootgINukeVal.C:99
TTree * dataTree
Definition: rootgINukeVal.C:98
int num
Definition: f2_nu.C:119
static std::string format(PyObject *obj, unsigned int pos, unsigned int indent, unsigned int maxlen)
Definition: fhiclmodule.cc:305
string filename
Definition: rootgINukeVal.C:80
string trim ( string  in)

Definition at line 65 of file rootgINukeVal.C.

65  {
66  size_t f = in.find_first_not_of(' ',0);
67  size_t l = in.find_last_not_of(' ',0);
68  if(l-f-1 > f){
69  in = in.substr(f,l-f-1);
70  }
71  return in;
72 }
FILE * f
Definition: loadlibs.C:26
This add method has three it adds this message xid and id to the appropriate and it updates the dynamic information in counts The sequence is as the static apppropriate and timespan will be in the mapped CountAndLimit and there will be no need to recompute them If this xid is not yet in see if the category is in limits if the appropriate counts struct can be formed by using the precedence rules above to combine the limit and interval found in limits along with the severityLimits and severityIntervals arrays found in the ELlimitsTable Along the way the limits map for this category is filled in