Example #1
0
//_____________________________________________________________________________
void ProofSimple::Begin(TTree * /*tree*/)
{
   // The Begin() function is called at the start of the query.
   // When running with PROOF Begin() is only called on the client.
   // The tree argument is deprecated (on PROOF 0 is passed).

   TString option = GetOption();
   Ssiz_t iopt = kNPOS;

   // Histos array
   if (fInput->FindObject("ProofSimple_NHist")) {
      TParameter<Long_t> *p =
         dynamic_cast<TParameter<Long_t>*>(fInput->FindObject("ProofSimple_NHist"));
      fNhist = (p) ? (Int_t) p->GetVal() : fNhist;
   } else if ((iopt = option.Index("nhist=")) != kNPOS) {
      TString s;
      Ssiz_t from = iopt + strlen("nhist=");
      if (option.Tokenize(s, from, ";") && s.IsDigit()) fNhist = s.Atoi();
   }
   if (fNhist < 1) {
      Abort("fNhist must be > 0! Hint: proof->SetParameter(\"ProofSimple_NHist\","
            " (Long_t) <nhist>)", kAbortProcess);
      return;
   }

   if (fInput->FindObject("ProofSimple_NHist3")) {
      TParameter<Long_t> *p =
         dynamic_cast<TParameter<Long_t>*>(fInput->FindObject("ProofSimple_NHist3"));
      fNhist3 = (p) ? (Int_t) p->GetVal() : fNhist3;
   } else if ((iopt = option.Index("nhist3=")) != kNPOS) {
      TString s;
      Ssiz_t from = iopt + strlen("nhist3=");
      if (option.Tokenize(s, from, ";") && s.IsDigit()) fNhist3 = s.Atoi();
   }

   // Ntuple
   TNamed *nm = dynamic_cast<TNamed *>(fInput->FindObject("ProofSimple_Ntuple"));
   if (nm) {

      // Title is in the form
      //         merge                  merge via file
      //           |<fout>                      location of the output file if merge
      //           |retrieve                    retrieve to client machine
      //         dataset                create a dataset
      //           |<dsname>                    dataset name (default: dataset_ntuple)
      //         |plot                  for a final plot
      //         <empty> or other       keep in memory

      fHasNtuple = 1;
      
      TString ontp(nm->GetTitle());
      if (ontp.Contains("|plot") || ontp == "plot") {
         fPlotNtuple = kTRUE;
         ontp.ReplaceAll("|plot", "");
         if (ontp == "plot") ontp = "";
      }
      if (ontp.BeginsWith("dataset")) fHasNtuple = 2;
   }
}
Example #2
0
void GausBF::Print(Option_t *option) const
{
  TString sopt = option; sopt.ToLower();
  if (sopt == "dump") {
    for (Int_t i = 0; i < Ns1*Ns9*Np; i++) {
      cout << Form(" %10.3e,", _par[i]);
      if (i%6 == 5) cout << endl;
    }
    cout << endl;
  }
  if (sopt.BeginsWith("p")) {
    TString ss = sopt(1, 2);
    if (ss.IsDigit()) {
      Int_t ip = ss.Atoi();
      if (0 <= ip && ip < Np)
	for (Int_t i = 0; i < Ns1; i++) {
	  for (Int_t j = 0; j < Ns9; j++) {
	    AMSPoint p1 = GetP1(i);
	    AMSPoint p9 = GetP9(j);
	    cout << Form("%3d %3d %6.2f %6.2f %7.2f %7.2f %10.3e",
			 i, j, p1.x(), p1.y(),
			       p9.x(), p9.y(), _par[(i*Ns9+j)*Np+ip]) << endl;
	  }
	}
    }
  }
}
//_____________________________________________________________________________
void ProofSimpleFile::Begin(TTree * /*tree*/)
{
   // The Begin() function is called at the start of the query.
   // When running with PROOF Begin() is only called on the client.
   // The tree argument is deprecated (on PROOF 0 is passed).

   TString option = GetOption();

   // Number of histograms (needed in terminate)
   if (fInput->FindObject("ProofSimpleFile_NHist")) {
      TParameter<Long_t> *p =
         dynamic_cast<TParameter<Long_t>*>(fInput->FindObject("ProofSimpleFile_NHist"));
      fNhist = (p) ? (Int_t) p->GetVal() : fNhist;
   } else if ((iopt = option.Index("nhist=")) != kNPOS) {
      TString s;
      Ssiz_t from = iopt + strlen("nhist=");
      if (option.Tokenize(s, from, ";") && s.IsDigit()) fNhist = s.Atoi();
   }
}
Example #4
0
// ======= FIXME: Hall A lib ================================================
//_____________________________________________________________________________
Int_t TrigBitLoc::Configure( const TObjArray* params, Int_t start )
{
  // Initialize CrateLoc from given parmeters

  // Load name, crate, slot, channel
  Int_t ret = CrateLocMulti::Configure( params, start );
  if( ret )
    return ret;

  // Additional parameters: lower and upper TDC cuts
  cutlo = GetString( params, start+4 ).Atoi();
  cuthi = GetString( params, start+5 ).Atoi();
  
  // The bit number is determined from any trailing digits of the name,
  // which must be in the range 0-31
  assert( fName.Length() > 0 ); // else bug in base class Configure()
  Int_t pos = fName.Length()-1, end = pos;
  TString e;
  do {
    e = fName(pos); 
  } while( e.IsDigit() && pos-- > 0 );
  if( pos == end ) { // No digits at the end of the name
    Error( "TrigBitLoc", "Name of trigger bit variable %s must end with bit "
	   "number (0-31). Example: \"bit12\". Fix database.", GetName() );
    return 50;
  }
  e = fName(pos+1,end-pos);
  Int_t val = e.Atoi();
  if( val < 0 || val > 31 ) {
    Error( "TrigBitLoc", "Illegal bit number %d in trigger bit name %s. "
	   "Must be 0-31. Fix database.", val, GetName() );
    return 50;
  }
  bitnum = val;
  
  return 0;
}
Example #5
0
//_____________________________________________________________________________
void ProofSimpleFile::SlaveBegin(TTree * /*tree*/)
{
   // The SlaveBegin() function is called after the Begin() function.
   // When running with PROOF SlaveBegin() is called on each slave server.
   // The tree argument is deprecated (on PROOF 0 is passed).

   TString option = GetOption();

   // Number of histograms (needed in terminate)
   Ssiz_t iopt = kNPOS;
   if (fInput->FindObject("ProofSimpleFile_NHist")) {
      TParameter<Long_t> *p =
         dynamic_cast<TParameter<Long_t>*>(fInput->FindObject("ProofSimpleFile_NHist"));
      fNhist = (p) ? (Int_t) p->GetVal() : fNhist;
   } else if ((iopt = option.Index("nhist=")) != kNPOS) {
      TString s;
      Ssiz_t from = iopt + strlen("nhist=");
      if (option.Tokenize(s, from, ";") && s.IsDigit()) fNhist = s.Atoi();
   }

   // The file for merging
   fProofFile = new TProofOutputFile("SimpleFile.root", "M");
   TNamed *out = (TNamed *) fInput->FindObject("PROOF_OUTPUTFILE");
   if (out) fProofFile->SetOutputFileName(out->GetTitle());
   TDirectory *savedir = gDirectory;
   fFile = fProofFile->OpenFile("RECREATE");
   if (fFile && fFile->IsZombie()) SafeDelete(fFile);
   savedir->cd();

   // Cannot continue
   if (!fFile) {
      TString amsg = TString::Format("ProofSimpleFile::SlaveBegin: could not create '%s':"
                                     " instance is invalid!", fProofFile->GetName());
      Abort(amsg, kAbortProcess);
      return;
   }

   // Histos arrays
   if (CreateHistoArrays() != 0) {
      Abort("ProofSimpleFile::SlaveBegin: could not create histograms", kAbortProcess);
      return;
   }

   // Create directory
   if (!(fFileDir = fFile->mkdir("blue"))) {
      Abort("ProofSimpleFile::SlaveBegin: could not create directory 'blue' in file!",
            kAbortProcess);
      return;
   }

   // Create the histograms
   for (Int_t i=0; i < fNhist; i++) {
      fHistTop[i] = new TH1F(Form("ht%d",i), Form("ht%d",i), 100, -3., 3.);
      fHistTop[i]->SetFillColor(kRed);
      fHistTop[i]->SetDirectory(fFile);
      fHistDir[i] = new TH1F(Form("hd%d",i), Form("hd%d",i), 100, -3., 3.);
      fHistDir[i]->SetFillColor(kBlue);
      fHistDir[i]->SetDirectory(fFileDir);
   }

   // Set random seed
   fRandom = new TRandom3(0);
}
Example #6
0
int main(int argc,char *argv[])
{
  string usage = "\nCNVnator ";
#ifdef CNVNATOR_VERSION
  usage += CNVNATOR_VERSION;
#else
  usage += "v???";
#endif
  usage += "\n\nUsage:\n";
  usage += argv[0];
  usage += " -root out.root  [-genome name] [-chrom 1 2 ...] -tree  file1.bam ...\n";
  usage += argv[0];
  usage += " -root out.root  [-genome name] [-chrom 1 2 ...] -merge file1.root ...\n";
  usage += argv[0];
  usage += " -root file.root [-genome name] [-chrom 1 2 ...] [-d dir] -his bin_size\n";
  usage += argv[0];
  usage += " -root file.root [-chrom 1 2 ...] -stat      bin_size\n";
  usage += argv[0];
  usage += " -root file.root                  -eval      bin_size\n";
  usage += argv[0];
  usage += " -root file.root [-chrom 1 2 ...] -partition bin_size [-ngc]\n";
  // usage += argv[0];
  //usage += " -root file.root [-chrom 1 2 ...] -spartition bin_size [-gc]\n";
  usage += argv[0];
  usage += " -root file.root [-chrom 1 2 ...] -call      bin_size [-ngc]\n";
  usage += argv[0];
  usage += " -root file.root -genotype bin_size [-ngc]\n";
  usage += argv[0];
  usage += " -root file.root -view     bin_size [-ngc]\n";
  usage += argv[0];
  usage += " -pe   file1.bam ... -qual val(20) -over val(0.8) [-f file]\n";
  usage += "\n";
  usage += "Valid genomes (-genome option) are: NCBI36, hg18, GRCh37, hg19\n";

  if (argc < 2) {
    cerr<<"Not enough parameters."<<endl;
    cerr<<usage<<endl;
    return 0;
  }

#ifdef USE_YEPPP
  YepStatus yepStatus = yepLibrary_Init();
  if (yepStatus != YepStatusOk) {
    cerr<<"Yeppp library initialization failed with status "<<yepStatus<<"."<<endl;
    return 1;
  }
#endif

  static const int OPT_TREE       = 0x00001;
  static const int OPT_MERGE      = 0x00002;
  static const int OPT_HIS        = 0x00004;
  static const int OPT_HISMERGE   = 0x00008;
  static const int OPT_STAT       = 0x00010;
  static const int OPT_PARTITION  = 0x00020;
  static const int OPT_EPARTITION = 0x00040;
  static const int OPT_CALL       = 0x00080;
  static const int OPT_VIEW       = 0x00100;
  static const int OPT_GENOTYPE   = 0x00200;
  static const int OPT_EVAL       = 0x00400;
  static const int OPT_PE         = 0x00800;
  static const int OPT_PANEL      = 0x01000;
  static const int OPT_FIT        = 0x02000;

  static const int OPT_SPARTITION = 0x04000;
  static const int OPT_HIS_NEW    = 0x08000;
  static const int OPT_AGGREGATE  = 0x10000;

  // tree, merge, his, stat, partition, spartition, call, view, genotype
  int max_opts = 10000, n_opts = 0, opts[max_opts], bins[max_opts], gbin = 0;
  for (int i = 0;i < n_opts;i++) bins[i] = 0;
  bool useGCcorr = true,useATcorr = false;
  bool forUnique = false,relaxCalling = false;
  string out_root_file(""),call_file(""),group_name("");
  string chroms[1000],data_files[100000],root_files[100000] = {""},dir = ".";
  int n_chroms = 0,n_files = 0,n_root_files = 0,range = 128, qual = 20;
  double over = 0.8;
  Genome *genome = NULL;

  int index = 1;
  while (index < argc) {
    string option = argv[index++];
    if (option == "-tree"  || option == "-merge" || option == "-pe") {
      if (option == "-tree")  opts[n_opts++] = OPT_TREE;
      if (option == "-merge") opts[n_opts++] = OPT_MERGE;
      if (option == "-pe")    opts[n_opts++] = OPT_PE;
      while (index < argc && argv[index][0] != '-')
	if (strlen(argv[index++]) > 0) data_files[n_files++] = argv[index - 1];
    } else if (option == "-his"        || option == "-his_new"    ||
	       option == "-hismerge"   ||
	       option == "-stat"       || option == "-eval"       ||
	       option == "-partition"  || option == "-spartition" ||
	       option == "-epartition" ||
	       option == "-call"       || option == "-view"       ||
	       option == "-genotype"   || option == "-aggregate") {
      int bs = 0;
      if (index < argc && argv[index][0] != '-') {
	TString tmp = argv[index++];
	if (!tmp.IsDigit()) {
	  cerr<<"Bin size must be integer for option '"<<option<<"'."<<endl;
	  cerr<<usage<<endl;
	  return 0;
	}
	bs = tmp.Atoi();
      }
      if (option == "-his")        opts[n_opts] = OPT_HIS;
      if (option == "-hismerge")   opts[n_opts] = OPT_HISMERGE;
      if (option == "-stat")       opts[n_opts] = OPT_STAT;
      if (option == "-partition")  opts[n_opts] = OPT_PARTITION;
      if (option == "-epartition") opts[n_opts] = OPT_EPARTITION;
      if (option == "-spartition") opts[n_opts] = OPT_SPARTITION;
      if (option == "-call")       opts[n_opts] = OPT_CALL;
      if (option == "-view")       opts[n_opts] = OPT_VIEW;
      if (option == "-genotype")   opts[n_opts] = OPT_GENOTYPE;
      if (option == "-his_new")    opts[n_opts] = OPT_HIS_NEW;
      if (option == "-eval")       opts[n_opts] = OPT_EVAL;
      if (option == "-aggregate")  opts[n_opts] = OPT_AGGREGATE;
      bins[n_opts++] = bs;
    } else if (option == "-panel") {
      opts[n_opts++] = OPT_PANEL;
    } else if (option == "-fit")   {
      opts[n_opts++] = OPT_FIT;
      if (index < argc && argv[index][0] != '-') group_name = argv[index++];
      else {
	cout<<"Please provide name of a sample group."<<endl;
	return 0;
      }
    } else if (option == "-outroot") {
      if (index < argc && argv[index][0] != '-') out_root_file = argv[index++];
      else {
	cout<<"Please provide new root-file name."<<endl;
	return 0;
      }
    } else if (option == "-root") {
      while (index < argc && argv[index][0] != '-')
	if (strlen(argv[index++]) > 0)
	  root_files[n_root_files++] = argv[index - 1];
      if (n_root_files == 0) {
	cerr<<"Please provide root-file name."<<endl;
	cerr<<usage<<endl;
	return 0;
      }
    } else if (option == "-outroot") {
      if (index < argc && argv[index][0] != '-') out_root_file = argv[index++];
      else {
	cout<<"Please provide new root-file name."<<endl;
	return 0;
      }
    } else if (option == "-chrom") {
      while (index < argc && argv[index][0] != '-')
	chroms[n_chroms++] = argv[index++];
      if (n_chroms == 0) {
	cerr<<"Provide chromosome names."<<endl;
	cerr<<usage<<endl;
	return 0;
      }
    } else if (option == "-ngc") {
      useGCcorr = false;
    } else if (option == "-at") {
      useATcorr = true;
    } else if (option == "-genome") {
      if (index < argc)	genome = Genome::get(argv[index++]);
    } else if (option == "-d") {
      if (index < argc && argv[index][0] != '-')
	dir = argv[index++];
      else cerr<<"No directory is given."<<endl;
    } else if (option == "-qual") {
      if (index >= argc || argv[index][0] == '-') {
	cerr<<"No quality value is provided."<<endl;
	cerr<<usage<<endl;
	return 0;
      }
      TString tmp = argv[index++];
      if (!tmp.IsDigit()) {
	cerr<<"Quality value must be integer."<<endl;
	cerr<<usage<<endl;
	return 0;
      }
      qual = tmp.Atoi();
    } else if (option == "-over") {
      if (index >= argc || argv[index][0] == '-') {
	cerr<<"No fraction of overlap is provided."<<endl;
	cerr<<usage<<endl;
	return 0;
      }
      TString tmp = argv[index++];
      if (!tmp.IsFloat()) {
	cerr<<"Fraction of overlap must be number."<<endl;
	cerr<<usage<<endl;
	return 0;
      }
      over = tmp.Atof();
    } else if (option == "-f") {
      if (index >= argc || argv[index][0] == '-') {
	cerr<<"No file name is provided."<<endl;
	cerr<<usage<<endl;
	return 0;
      }
      call_file = argv[index++];
    } else if (option == "-unique") {
      forUnique = true;
    } else if (option == "-range") {
      range = atoi(argv[index++]);
    } else if (option == "-relax") {
      relaxCalling = true;
    } else if (option[0] == '-') {
      cerr<<"Unknown option '"<<option<<"'.\n"<<endl;
    }
  }

  if (out_root_file.length() <= 0) out_root_file = root_files[0];
  if (out_root_file.length() <= 0)
    cerr<<"WARNING: no name of root-file provided."<<endl;

  for (int o = 0;o < n_opts;o++) {
    int option = opts[o];
    int bin = bins[o]; if (bin <= 0) bin = gbin;
    if (option == OPT_TREE) { // tree
      HisMaker maker(out_root_file,genome);
      maker.setDataDir(dir);
      maker.produceTrees(chroms,n_chroms,data_files,n_files,forUnique);
    }
    if (option == OPT_MERGE) { // merge
      HisMaker maker(out_root_file,genome);
      maker.mergeTrees(chroms,n_chroms,data_files,n_files);
    }
    if (option == OPT_HIS ||
	option == OPT_HISMERGE) { // his
      HisMaker maker(out_root_file,bin,useGCcorr,genome);
      maker.setDataDir(dir);
      maker.produceHistograms(chroms,n_chroms,root_files,n_root_files,false);
      if (option == OPT_HISMERGE)
	maker.produceHistograms(chroms,n_chroms,root_files,n_root_files,true);
    }
    if (option == OPT_STAT) { // stat
      HisMaker maker(out_root_file,bin,useGCcorr,genome);
      maker.stat(chroms,n_chroms,useATcorr);
    }
    if (option == OPT_PARTITION) { // partition
      HisMaker maker(out_root_file,bin,useGCcorr,genome);
      maker.partition(chroms,n_chroms,false,useATcorr,useGCcorr,false,range);
    }
    if (option == OPT_EPARTITION) { // exome partition
      HisMaker maker(out_root_file,bin,useGCcorr,genome);
      maker.partition(chroms,n_chroms,false,useATcorr,useGCcorr,true,range);
    }
    if (option == OPT_CALL) { // call
      HisMaker maker(out_root_file,bin,useGCcorr,genome);
      maker.callSVs(chroms,n_chroms,useATcorr,useGCcorr,relaxCalling);
    }
    if (option == OPT_VIEW) { // view
      HisMaker maker(out_root_file,bin,useGCcorr,genome);
      TApplication theApp("App",0,0);
      maker.view(root_files,n_root_files,useATcorr,useGCcorr);
      theApp.Run();
    }
    if (option == OPT_GENOTYPE) { // genotype
      HisMaker maker(out_root_file,bin,useGCcorr,genome);
      TApplication theApp("App",0,0);
      maker.genotype(root_files,n_root_files,useATcorr,useGCcorr);
      theApp.Run();
    }
    if (option == OPT_EVAL) { // eval
      HisMaker maker(out_root_file,bin,useGCcorr,genome);
      maker.eval(root_files,n_root_files,useATcorr,useGCcorr);
    }
    if (option == OPT_PE) { // pe
      HisMaker maker("null",genome);
      if (call_file.length() > 0) 
	maker.pe_for_file(call_file,data_files,n_files,over,qual);
      else {
	TApplication theApp("App",0,0);
	maker.pe(data_files,n_files,over,qual);
	theApp.Run();
      }
    }
    if (option == OPT_SPARTITION) { // spartition
      HisMaker maker(out_root_file,bin,useGCcorr,genome);
      maker.partition(chroms,n_chroms,true,useATcorr,useGCcorr,false,range);
    }
    if (option == OPT_HIS_NEW) { // his_new
      HisMaker maker(out_root_file,bin,useGCcorr,genome);
      maker.setDataDir(dir);
      maker.produceHistogramsNew(chroms,n_chroms);
    }
    // EXOnator options
    if (option == OPT_PANEL) { // panel
      EXOnator exonator(out_root_file);
      exonator.makeTables();
    }
    if (option == OPT_FIT) { // fit
      EXOnator exonator(out_root_file);
      exonator.fit(group_name);
    }
    if (option == OPT_AGGREGATE) { // aggregate
      HisMaker maker(out_root_file,bin,useGCcorr,genome);
      maker.setDataDir(dir);
      maker.aggregate(root_files,n_root_files,chroms,n_chroms);
    }
  }

  return 0;
}
Example #7
0
//_____________________________________________________________________________
void ProofSimple::SlaveBegin(TTree * /*tree*/)
{
   // The SlaveBegin() function is called after the Begin() function.
   // When running with PROOF SlaveBegin() is called on each slave server.
   // The tree argument is deprecated (on PROOF 0 is passed).

   TString option = GetOption();
   Ssiz_t iopt = kNPOS;

   // Histos array
   if (fInput->FindObject("ProofSimple_NHist")) {
      TParameter<Long_t> *p =
         dynamic_cast<TParameter<Long_t>*>(fInput->FindObject("ProofSimple_NHist"));
      fNhist = (p) ? (Int_t) p->GetVal() : fNhist;
   } else if ((iopt = option.Index("nhist=")) != kNPOS) {
      TString s;
      Ssiz_t from = iopt + strlen("nhist=");
      if (option.Tokenize(s, from, ";") && s.IsDigit()) fNhist = s.Atoi();
   }
   if (fNhist < 1) {
      Abort("fNhist must be > 0! Hint: proof->SetParameter(\"ProofSimple_NHist\","
            " (Long_t) <nhist>)", kAbortProcess);
      return;
   }
   fHist = new TH1F*[fNhist];

   TString hn;
   // Create the histogram
   for (Int_t i=0; i < fNhist; i++) {
      hn.Form("h%d",i);
      fHist[i] = new TH1F(hn.Data(), hn.Data(), 100, -3., 3.);
      fHist[i]->SetFillColor(kRed);
      fOutput->Add(fHist[i]);
   }
   
   // 3D Histos array
   if (fInput->FindObject("ProofSimple_NHist3")) {
      TParameter<Long_t> *p =
         dynamic_cast<TParameter<Long_t>*>(fInput->FindObject("ProofSimple_NHist3"));
      fNhist3 = (p) ? (Int_t) p->GetVal() : fNhist3;
   } else if ((iopt = option.Index("nhist3=")) != kNPOS) {
      TString s;
      Ssiz_t from = iopt + strlen("nhist3=");
      if (option.Tokenize(s, from, ";") && s.IsDigit()) fNhist3 = s.Atoi();
   }
   if (fNhist3 > 0) {
      fHist3 = new TH3F*[fNhist3];
      Info("Begin", "%d 3D histograms requested", fNhist3);
      // Create the 3D histogram
      for (Int_t i=0; i < fNhist3; i++) {
         hn.Form("h%d_3d",i);
         fHist3[i] = new TH3F(hn.Data(), hn.Data(),
                              100, -3., 3., 100, -3., 3., 100, -3., 3.);
         fOutput->Add(fHist3[i]);
      }
   }
   
   // Histo with labels
   if (fInput->FindObject("ProofSimple_TestLabelMerging")) {
      fHLab = new TH1F("hlab", "Test merging of histograms with automatic labels", 10, 0., 10.);
      fOutput->Add(fHLab);
   }
   
   // Ntuple
   TNamed *nm = dynamic_cast<TNamed *>(fInput->FindObject("ProofSimple_Ntuple"));
   if (nm) {

      // Title is in the form
      //         merge                  merge via file
      //           |<fout>                      location of the output file if merge
      //           |retrieve                    retrieve to client machine
      //         dataset                create a dataset
      //           |<dsname>                    dataset name (default: dataset_ntuple)
      //         |plot                  for a final plot
      //         <empty> or other       keep in memory

      fHasNtuple = 1;
      
      TString ontp(nm->GetTitle());
      if (ontp.Contains("|plot") || ontp == "plot") {
         fPlotNtuple = kTRUE;
         ontp.ReplaceAll("|plot", "");
         if (ontp == "plot") ontp = "";
      }
      TString locfn("SimpleNtuple.root");
      if (ontp.BeginsWith("merge")) {
         ontp.Replace(0,5,"");
         fProofFile = new TProofOutputFile(locfn, "M");
         TString fn;
         Ssiz_t iret = ontp.Index("|retrieve");
         if (iret != kNPOS) {
            fProofFile->SetRetrieve(kTRUE);
            TString rettag("|retrieve");
            if ((iret = ontp.Index("|retrieve=")) != kNPOS) {
               rettag += "=";
               fn = ontp(iret + rettag.Length(), ontp.Length() - iret - rettag.Length());
               if ((iret = fn.Index('|')) != kNPOS) fn.Remove(iret);
               rettag += fn;
            }
            ontp.ReplaceAll(rettag, "");
         }
         Ssiz_t iof = ontp.Index('|');
         if (iof != kNPOS) ontp.Remove(0, iof + 1);
         if (!ontp.IsNull()) {
            fProofFile->SetOutputFileName(ontp.Data());
            if (fn.IsNull()) fn = gSystem->BaseName(TUrl(ontp.Data(), kTRUE).GetFile());
         }
         if (fn.IsNull()) fn = locfn;
         // This will be the final file on the client, the case there is one
         fProofFile->SetTitle(fn);
      } else if (ontp.BeginsWith("dataset")) {
         ontp.Replace(0,7,"");
         Ssiz_t iof = ontp.Index("|");
         if (iof != kNPOS) ontp.Remove(0, iof + 1);
         TString dsname = (!ontp.IsNull()) ? ontp.Data() : "dataset_ntuple";         
         UInt_t opt = TProofOutputFile::kRegister | TProofOutputFile::kOverwrite | TProofOutputFile::kVerify;
         fProofFile = new TProofOutputFile("SimpleNtuple.root",
                                          TProofOutputFile::kDataset, opt, dsname.Data());
         fHasNtuple = 2;
      } else if (!ontp.IsNull()) {
         Warning("SlaveBegin", "ntuple options unknown: ignored (%s)", ontp.Data()); 
      }
      
      // Open the file, if required
      if (fProofFile) {
         // Open the file
         fFile = fProofFile->OpenFile("RECREATE");
         if (fFile && fFile->IsZombie()) SafeDelete(fFile);

         // Cannot continue
         if (!fFile) {
            Info("SlaveBegin", "could not create '%s': instance is invalid!", fProofFile->GetName());
            return;
         }
      }
 
      // Now we create the ntuple
      fNtp = new TNtuple("ntuple","Demo ntuple","px:py:pz:random:i");
      // File resident, if required
      if (fFile) {
         fNtp->SetDirectory(fFile);
         fNtp->AutoSave();
      } else {
         fOutput->Add(fNtp);
      }
   }
   
   // Set random seed
   fRandom = new TRandom3(0);
}
void TriggerInputsForMuonEventCuts ( TString runListFilename, TString selectedInputs="", TString defaultStorage = "raw://" )
{
  AliCDBManager::Instance()->SetDefaultStorage(defaultStorage.Data());
  TObjArray inputsList;
  inputsList.SetOwner();
  
  TObjArray* selectedInputsList = selectedInputs.Tokenize(",");

  // Read input run list
  ifstream inFile(runListFilename.Data());
  TString srun = "";
  if ( inFile.is_open() ) {
    while ( ! inFile.eof() ) {
      srun.ReadLine(inFile,kFALSE);
      if ( ! srun.IsDigit() ) continue;
      
      // For each run, read trigger inputs from OCDB
      Int_t runNumber = srun.Atoi();
      AliCDBManager::Instance()->SetRun(runNumber);
      
      // Get trigger class configuration
      AliCDBEntry* entry = AliCDBManager::Instance()->Get("GRP/CTP/Config");
      if ( ! entry ) continue;
      
      THashList* runInputs = new THashList();
      runInputs->SetOwner();
      runInputs->SetUniqueID((UInt_t)runNumber);
      AliTriggerConfiguration* trigConf = (AliTriggerConfiguration*)entry->GetObject();
      const TObjArray& trigInputsArray = trigConf->GetInputs();
      AliTriggerInput* trigInput = 0x0;
      TIter next(&trigInputsArray);
      while ( ( trigInput = static_cast<AliTriggerInput*>(next()) ) ) {
        if ( selectedInputsList->GetEntriesFast() > 0 && ! selectedInputsList->FindObject(trigInput->GetName()) ) continue;
        Int_t inputId = (Int_t)TMath::Log2(trigInput->GetMask());
        TObjString* currInput = new TObjString(trigInput->GetName());
        currInput->SetUniqueID(inputId);
        runInputs->Add(currInput);
      }
      inputsList.Add(runInputs);
    }
    inFile.close();
  }
  delete selectedInputsList;
  
  // Loop on the trigger inputs
  // and group runs with an equal list of inputs
  Int_t nentries = inputsList.GetEntries();
  TArrayI checkMask(nentries);
  checkMask.Reset(1);
  for ( Int_t irun=0; irun<nentries; irun++ ) {
    if ( checkMask[irun] == 0 ) continue;
    THashList* currList = static_cast<THashList*>(inputsList.At(irun));
    TString runRange = Form("Run range: %u", currList->GetUniqueID());
    for ( Int_t jrun=irun+1; jrun<nentries; jrun++ ) {
      if ( checkMask[jrun] == 0 ) continue;
      THashList* checkList = static_cast<THashList*>(inputsList.At(jrun));
      Bool_t isDifferent = kFALSE;
      for ( Int_t itrig=0; itrig<currList->GetEntries(); itrig++ ) {
        TObjString* currInput = static_cast<TObjString*>(currList->At(itrig));
        TObject* checkInput = checkList->FindObject(currInput->GetName());
        if ( ! checkInput || checkInput->GetUniqueID() != currInput->GetUniqueID() ) {
          isDifferent = kTRUE;
          break;
        }
      } // loop on trigger inputs
      if ( isDifferent ) continue;
      checkMask[jrun] = 0;
      runRange += Form(",%u", checkList->GetUniqueID());
    } // loop on runs
    
    TString outString = "\nSetTrigInputsMap(\"";
    for ( Int_t itrig=0; itrig<currList->GetEntries(); itrig++ ) {
      TObjString* currInput = static_cast<TObjString*>(currList->At(itrig));
      outString += Form("%s:%u,",currInput->GetString().Data(), currInput->GetUniqueID());
    }
    outString.Append("\");\n");
    outString.ReplaceAll(",\"","\"");
    outString += runRange;
    printf("%s\n", outString.Data());
  } // loop on runs
}
Example #9
0
void plotFF(char * infname1 = "/net/pstore01/d00/scratch/frankma/hiroot/pythia100_5k_dijet_000777.root",
            char * infname2 = "/net/pstore01/d00/scratch/frankma/hiroot/pyquen100_5k_dijet_000777.root",
	    // -pythia-
	    TString PythiaAnaNJetEtMin = "90",
	    TString PythiaAnaNJetEtMax = "",
	    TString PythiaAnaAJetEtMin = "50",
	    // -pyquen-
	    TString PyquenAnaNJetEtMin = "90",
	    TString PyquenAnaNJetEtMax = "",
	    TString PyquenAnaAJetEtMin = "50",
	    TString JDPhiMin = "3.0",
	    char * plotdir = "plots",
	    const Int_t NXIBIN = 10,
	    const Double_t XIMAX = 9.,
	    const Double_t XIYMAX = 10,
	    Bool_t check = kFALSE
      )
{
   cout << PythiaAnaNJetEtMin << " " << PythiaAnaNJetEtMax << " " << PythiaAnaAJetEtMin << " "
      << PyquenAnaNJetEtMin << " " << PyquenAnaNJetEtMax << " " << PyquenAnaAJetEtMin
      << endl;
   //=== Setup ana cuts ===
   // --Et--
   TString PythiaAnaJetCut;
   if (!PythiaAnaNJetEtMin.IsDigit())
      terminate(Form("PythiaAnaNJetEtMin: %s is not a digit",PythiaAnaNJetEtMin.Data()));
   PythiaAnaJetCut = "npet>"+PythiaAnaNJetEtMin;
   if (!PythiaAnaNJetEtMax.IsNull()) {
      if (!PythiaAnaNJetEtMax.IsDigit())
	 terminate(Form("PythiaAnaNJetEtMax: %s is not a digit",PythiaAnaNJetEtMax.Data()));
      PythiaAnaJetCut += (" && npet<"+PythiaAnaNJetEtMax);
   }
   if (!PythiaAnaAJetEtMin.IsNull()) {
      if (!PythiaAnaAJetEtMin.IsDigit())
	 terminate(Form("PythiaAnaAJetEtMin: %s is not a digit",PythiaAnaAJetEtMin.Data()));
      PythiaAnaJetCut += (" && apet>"+PythiaAnaAJetEtMin);
   }
   //--
   TString PyquenAnaJetCut;
   if (!PyquenAnaNJetEtMin.IsDigit())
      terminate(Form("PyquenAnaNJetEtMin: %s is not a digit",PyquenAnaNJetEtMin.Data()));
   PyquenAnaJetCut = "npet>"+PyquenAnaNJetEtMin;
   if (!PyquenAnaNJetEtMax.IsNull()) {
      if (!PyquenAnaNJetEtMax.IsDigit())
	 terminate(Form("PyquenAnaNJetEtMax: %s is not a digit",PyquenAnaNJetEtMax.Data()));
      PyquenAnaJetCut += (" && npet<"+PyquenAnaNJetEtMax);
   }
   if (!PyquenAnaAJetEtMin.IsNull()) {
      if (!PyquenAnaAJetEtMin.IsDigit())
	 terminate(Form("PyquenAnaAJetEtMin: %s is not a digit",PyquenAnaAJetEtMin.Data()));
      PyquenAnaJetCut += (" && apet>"+PyquenAnaAJetEtMin);
   }
   // --Opening angle--
   TString JDPhiCut = ("apdphi>" + JDPhiMin);
   PythiaAnaJetCut += (" && " + JDPhiCut);
   PyquenAnaJetCut += (" && " + JDPhiCut);
   
   // --Jet constituent--
   TString AnaNPConeCut = "abs(pndphi)<0.5";
   TString AnaAPConeCut = "abs(padphi)<0.5";
   // --Particle pt--
   TString ParticlePtCut = "ppt>0.5";

   TString PythiaNearFFCut = PythiaAnaJetCut + " && " + AnaNPConeCut + " && " + ParticlePtCut;
   TString PythiaAwayFFCut = PythiaAnaJetCut + " && " + AnaAPConeCut + " && " + ParticlePtCut;
   TString PyquenNearFFCut = PyquenAnaJetCut + " && " + AnaNPConeCut + " && " + ParticlePtCut;
   TString PyquenAwayFFCut = PyquenAnaJetCut + " && " + AnaAPConeCut + " && " + ParticlePtCut;

   printf("\n=========================Cuts setup======================\n");
   printf("Near Pythia FF cut: %s\n",PythiaNearFFCut.Data());
   printf("Away Pythia FF cut: %s\n",PythiaAwayFFCut.Data());
   printf("Near Pyquen FF cut: %s\n",PyquenNearFFCut.Data());
   printf("Away Pyquen FF cut: %s\n",PyquenAwayFFCut.Data());

   bool NoNorm = false;

   //=== Get input files ===
   //---pythia---
   TFile * infile = findFile(infname1);
   TNtuple * ntPythia = dynamic_cast<TNtuple*>(infile->Get("NTTruePFF"));
   TNtuple * ntJetPythia = dynamic_cast<TNtuple*>(infile->Get("NTJetFF"));
   TNtuple * ntJetLeadingPythia = dynamic_cast<TNtuple*>(infile->Get("NTJetLeading"));
   //---pyquen---
   TFile * infile2 = findFile(infname2);
   TNtuple * ntPyquen = dynamic_cast<TNtuple*>(infile2->Get("NTTruePFF"));
   TNtuple * ntJetPyquen = dynamic_cast<TNtuple*>(infile2->Get("NTJetFF"));
   TNtuple * ntJetLeadingPyquen = dynamic_cast<TNtuple*>(infile2->Get("NTJetLeading"));

   //---output---
   TFile * outfile = new TFile(Form("%s/FFHistos.root",plotdir),"RECREATE");

   if (check) {
      printf("\n============================Do Checks======================\n");
      printf("%s\n",infname1);
      printf("%s\n",infname2);
      //---- Check dijet properties ----
      //--- inv mass ---
      drawTree(ntJetPythia, "mass>>hMassPPythia","",drsgFF,"hMassPPythia","Pythia: inv mass of dijet",100,0,1800,true,kRed,1,3);
      drawTree(ntJetPyquen, "mass>>hMassPPyquen","",drdbFF,"hMassPPyquen","draw Pyquen: inv mass of dijet",100,0,1800,true,kBlue,1,3);
      //--- Et ---
      // -pythia-
      drawTree(ntJetPythia, "npet>>hNLPartonPPythia",PythiaNearFFCut.Data(),drsgFF,"hNLPartonPPythia","Pythia: leading partons",HJETETBINS,HJETETMIN,HJETETMAX,0,kRed,1,3);
      drawTree(ntJetPythia, "apet>>hALPartonPPythia",PythiaAwayFFCut.Data(),drdbFF,"hALPartonPPythia","Pythia: leading partons",HJETETBINS,HJETETMIN,HJETETMAX,0,kRed,7,3);
      // -pyquen--
      drawTree(ntJetPyquen, "npet>>hNLPartonPPyquen",PyquenNearFFCut.Data(),drdbFF,"hNLPartonPPyquen","Pyquen: leading partons",HJETETBINS,HJETETMIN,HJETETMAX,0,kBlue,1,3);
      drawTree(ntJetPyquen, "apet>>hALPartonPPyquen",PyquenAwayFFCut.Data(),drdbFF,"hALPartonPPyquen","Pyquen: leading partons",HJETETBINS,HJETETMIN,HJETETMAX,0,kBlue,7,3);
   }
   

   //---- Particles ----
   //--- inclusive angular correlations to leading partons---
   // -near-
   drawTree(ntPyquen, "pndphi>>hnPdPhiPyquen","",drsgFF,"hnPdPhiPyquen",";d#phi(particle,Jet);",100,-0.5*PI,1.5*PI,false,kBlue,1,3);
   drawTree(ntPythia, "pndphi>>hnPdPhiPythia","",drdbFF,"hnPdPhiPythia","Pythia: dphi to leading partons",100,-0.5*PI,1.5*PI,false,kRed,1,3);
   drawTree(ntJetPyquen, "pndphi>>hnPdPhiJetPyquen","",drdbFF,"hnPdPhiJetPyquen","JetPyquen: dphi to leading partons",100,-0.5*PI,1.5*PI,false,kBlue,1,3);
   drawTree(ntJetPythia, "pndphi>>hnPdPhiJetPythia","",drdbFF,"hnPdPhiJetPythia","JetPythia: dphi to leading partons",100,-0.5*PI,1.5*PI,false,kRed,1,3);
   // -away-
//   drawTree(ntPyquen, "padphi>>haPdPhiPyquen","",drdbFF,"haPdPhiPyquen","Pyquen: dphi to leading partons",100,-0.5*PI,1.5*PI,false,kBlue,7,3);
//   drawTree(ntPythia, "padphi>>haPdPhiPythia","",drdbFF,"haPdPhiPythia","draw Pythia: dphi to leading partons",100,-0.5*PI,1.5*PI,false,kRed,7,3);

   //--- inclusive Pt ---
   drawTree(ntPythia, "ppt>>hPPtPythia","",drsgFF,"hPPtPythia","Pythia: Pt of final state particles",100,0,50,true,kRed,1,3);
   drawTree(ntPyquen, "ppt>>hPPtPyquen","",drdbFF,"hPPtPyquen","draw Pyquen: Pt of final state particles",100,0,50,true,kBlue,1,3);

   //=== Get Normalizations ===
   //-- copy cuts --
   printf("\n=====================Calc Nomalizations=======================\n");
   TString PythiaNearLeadingCut = PythiaAnaJetCut.ReplaceAll("pet","ljet");
   TString PythiaAwayLeadingCut = PythiaAnaJetCut.ReplaceAll("pet","ljet");
   TString PyquenNearLeadingCut = PyquenAnaJetCut.ReplaceAll("pet","ljet");
   TString PyquenAwayLeadingCut = PyquenAnaJetCut.ReplaceAll("pet","ljet");
   PythiaNearLeadingCut = PythiaAnaJetCut.ReplaceAll("apdphi","jdphi");
   PythiaAwayLeadingCut = PythiaAnaJetCut.ReplaceAll("apdphi","jdphi");
   PyquenNearLeadingCut = PyquenAnaJetCut.ReplaceAll("apdphi","jdphi");
   PyquenAwayLeadingCut = PyquenAnaJetCut.ReplaceAll("apdphi","jdphi");
   printf("Near Pythia FF cut: %s\n",PythiaNearLeadingCut.Data());
   printf("Away Pythia FF cut: %s\n",PythiaAwayLeadingCut.Data());
   printf("Near Pyquen FF cut: %s\n",PyquenNearLeadingCut.Data());
   printf("Away Pyquen FF cut: %s\n",PyquenAwayLeadingCut.Data());
   //-- draw uncut distributions--
   // --comp with AnaJet
   drawNormHist(infile, "hJetEtDist",drsgFF,"","Jet Et [GeV]","#",1,true,2,7,1,1,1);
   drawNormHist(infile, "hLeadJetEtDist",drdbFF,"","Jet Et [GeV]","#",1,true,2,7,3,1,1);
   drawTree(ntJetLeadingPythia, "nljet>>hCheckNearLJetPythia0","",drdbFF,"hCheckNearLJetPythia0",";Et [GeV];",HJETETBINS,HJETETMIN,HJETETMAX,true,kBlack,1,1,1,8);
   // --from jet leading--
   drawTree(ntJetLeadingPythia, "nljet>>hCheckNearLJetPythia","",drsgFF,"hCheckNearLJetPythia",";Et [GeV];",HJETETBINS,HJETETMIN,HJETETMAX,true,kBlack,1,1,1,8);
   drawTree(ntJetLeadingPyquen, "nljet>>hCheckNearLJetPyquen","",drdbFF,"hCheckNearLJetPyquen",";Et [GeV];",HJETETBINS,HJETETMIN,HJETETMAX,true,kBlue,1,1,1,8);
   drawTree(ntJetLeadingPythia, "aljet>>hCheckAwayLJetPythia","",drdbFF,"hCheckAwayLJetPythia",";Et [GeV];",HJETETBINS,HJETETMIN,HJETETMAX,true,kBlack,7,1,1,8);
   drawTree(ntJetLeadingPyquen, "aljet>>hCheckAwayLJetPyquen","",drdbFF,"hCheckAwayLJetPyquen",";Et [GeV];",HJETETBINS,HJETETMIN,HJETETMAX,true,kBlue,7,1,1,8);
   //-- *apply cuts and calc normalization* --
   Float_t nJetPythia = drawTree(ntJetLeadingPythia, "nljet>>hCheckCutNearLJetPythia",PythiaNearLeadingCut.Data(),drdbFF,"hCheckCutNearLJetPythia",";Et [GeV];",HJETETBINS,HJETETMIN,HJETETMAX,true,kBlack,1,3,1,8);
   Float_t nJetPyquen = drawTree(ntJetLeadingPyquen, "nljet>>hCheckCutNearLJetPyquen",PyquenNearLeadingCut.Data(),drdbFF,"hCheckCutNearLJetPyquen",";Et [GeV];",HJETETBINS,HJETETMIN,HJETETMAX,true,kBlue,1,3,1,8);
   //-- draw also the away side after cut --
   drawTree(ntJetLeadingPythia, "aljet>>hCheckCutAwayLJetPythia",PythiaAwayLeadingCut.Data(),drdbFFE,"hCheckCutAwayLJetPythia",";Et [GeV];",HJETETBINS,HJETETMIN,HJETETMAX,true,kBlack,1,3,1,4);
   drawTree(ntJetLeadingPyquen, "aljet>>hCheckCutAwayLJetPyquen",PyquenAwayLeadingCut.Data(),drdbFFE,"hCheckCutAwayLJetPyquen",";Et [GeV];",HJETETBINS,HJETETMIN,HJETETMAX,true,kBlue,1,3,1,4);
   float nJetPythiaNorm = 1./nJetPythia;
   if (NoNorm) nJetPythiaNorm = 1.;
   printf("nJetPythias: %f,  jnorm: %f\n",nJetPythia,nJetPythiaNorm);
   float nJetPyquenNorm = 1./nJetPyquen;
   if (NoNorm) nJetPyquenNorm = 1.;
   printf("nJetPyquens: %f,  jnorm: %f\n",nJetPyquen,nJetPyquenNorm);

   //=== Finally: plot fragmentation properties ===
   printf("\n===================== Plot FF =======================\n");
   // -near-
   drawTree(ntJetPythia, "log(1/zn)>>hXiNearJetPythia",PythiaNearFFCut.Data(),drsgFFE,"hXiNearJetPythia",";(near) #xi=ln(E_{t}^{Jet}/E_{t}^{Particle});",NXIBIN,0,XIMAX,0,kBlack,1,3,1,8,nJetPythiaNorm,XIYMAX);
   drawTree(ntJetPyquen, "log(1/zn)>>hXiNearJetPyquen",PyquenNearFFCut.Data(),drdbFFE,"hXiNearJetPyquen","JetPyquen: FF of near parton",NXIBIN,0,XIMAX,0,kBlue,1,3,1,8,nJetPyquenNorm,XIYMAX);
   drawTree(ntPyquen, "log(1/zn)>>hXiNearPyquen",PyquenNearFFCut.Data(),drdbFF,"hXiNearPyquen",";(near) #xi=ln(E_{t}^{Jet}/E_{t}^{Particle})",NXIBIN,0,XIMAX,0,kRed-2,1,3,0,0,nJetPyquenNorm,XIYMAX);
   drawTree(ntPythia, "log(1/zn)>>hXiNearPythia",PythiaNearFFCut.Data(),drdbFF,"hXiNearPythia",";#xi=ln(E_{t}^{Jet}/E_{t}^{Particle};",NXIBIN,0,XIMAX,0,kRed,1,3,0,0,nJetPythiaNorm,XIYMAX);
   // -away-
   drawTree(ntJetPythia, "log(1/za)>>hXiAwayJetPythia",PythiaAwayFFCut.Data(),drsgFFE,"hXiAwayJetPythia",";(away) #xi=ln(E_{t}^{Jet}/E_{t}^{Particle});",NXIBIN,0,XIMAX,0,kBlack,1,3,1,8,nJetPythiaNorm,XIYMAX);
   drawTree(ntJetPyquen, "log(1/za)>>hXiAwayJetPyquen",PyquenAwayFFCut.Data(),drdbFFE,"hXiAwayJetPyquen","JetPyquen: FF of near parton",NXIBIN,0,XIMAX,0,kBlue,1,3,1,8,nJetPyquenNorm,XIYMAX);
   drawTree(ntPyquen, "log(1/za)>>hXiAwayPyquen",PyquenAwayFFCut.Data(),drdbFF,"hXiAwayPyquen",";(away) #xi=ln(E_{t}^{Jet}/E_{t}^{Particle})",NXIBIN,0,XIMAX,0,kRed-2,1,3,0,0,nJetPyquenNorm,XIYMAX);
   drawTree(ntPythia, "log(1/za)>>hXiAwayPythia",PythiaAwayFFCut.Data(),drdbFF,"hXiAwayPythia",";#xi=ln(E_{t}^{Jet}/E_{t}^{Particle};",NXIBIN,0,XIMAX,0,kRed,1,3,0,0,nJetPythiaNorm,XIYMAX);

   //---FF ratio2---
   // -parton-
   drawDivHist("hXiNearPyquen","hXiNearPythia",drsgFF,"hNearFFRatio",";#xi_{pyquen}/#xi_{pythia};",NXIBIN,0,XIMAX,0,kRed-2,1,3,0,0,3.);
   drawDivHist("hXiAwayPyquen","hXiAwayPythia",drdbFF,"hAwayFFRatio","draw Away FF ratio: Pyquen/Pythia",NXIBIN,0,XIMAX,0,kRed-2,7,3,1,4);
   // -Jet-
   drawDivHist("hXiNearJetPyquen","hXiNearJetPythia",drdbFFE,"hNearJetFFRatio",";#xi_{pyquen}/#xi_{pythia};",NXIBIN,0,XIMAX,0,kBlue,1,3,1,8);
   drawDivHist("hXiAwayJetPyquen","hXiAwayJetPythia",drdbFFE,"hAwayJetFFRatio","draw Away FF ratio: Pyquen/Pythia",NXIBIN,0,XIMAX,0,kBlue,7,3,1,4);

   //=== Save and exit ===
   printAllCanvases(plotdir);
   outfile->Write();
   outfile->Close();
}