Пример #1
0
node* treeList(node *n)
{
  node *temp;

  if(n -> right == NULL && n -> left == NULL)
    {
      n -> left = n;
      n -> right = n;
      return(n);
    }

  else if(n -> right == NULL && n -> left != NULL)
    {
      n = appendL(n, treeList(n -> left));
      return(n);
    }

  else if(n -> left == NULL && n -> right != NULL)
    {
      n = appendR(n, treeList(n -> right));
      return(n);
    }
  
  else
    {
      temp = n -> right;
      n = appendL(n, treeList(n -> left));
      n = appendR(n, treeList(temp));
      return(n);
    }
}
Пример #2
0
int main()
{
  node *root = NULL, *rootb = NULL, *rooth = NULL, *temp;
  int sum = 25, *a, l = 0;
  a = (int *)malloc(sizeof(int));

  root = insert(root, 10);
  root = insert(root, 7);
  root = insert(root, 6);
  root = insert(root, 8);
  root = insert(root, 13);
  root = insert(root, 15);
  root = insert(root, 11);

  printf("Part2: Size: \t%d\n", size(root, 0));
  printf("Part3: Depth: \t%d\n", maxDepth(root));
  printf("Part4: Min: \t%d\n", minValue(root));
  printf("Part5: Post: \t");printPostorder(root);printf("\n");
  printf("Part6: Path Sum: %d %s\n", sum, hasPathSum(root, sum)?"True":"False");
  printf("Part7: Leaf Paths");printPaths(root, a, l);
  printf("\n");
  inorder(root);printf("\n");
  printf("Part8: Mirror: ");mirror(root);inorder(root);printf("\n");

  rootb = insert(rootb, 10);
  rootb = insert(rootb, 7);
  rootb = insert(rootb, 6);
  rootb = insert(rootb, 8);
  rootb = insert(rootb, 13);
  rootb = insert(rootb, 15);
  rootb = insert(rootb, 11);

  printf("Part9: doubleTree: ");doubleTree(rootb);inorder(rootb);printf("\n");
  printf("Part10: sameTree: %s\n", sameTree(root, root)?"True":"False");
  mirror(root);
  printf("Part11: isBST: %s\n", isBST(root)?"True":"False");
  printf("Part12: Tree list: ");
  rooth = treeList(root);
  temp = rooth -> left;
  printf("%d ", rooth -> data);
  while(temp != rooth)
    {
      printf("%d ", temp -> data);
      temp = temp -> left;
    }
  printf("\n");

  return(0);
}
Пример #3
0
int main(int argc, char* argv[]){

  const int Nparam=3;   // NUMBER OF PARAMETERS

  if(argc!=Nparam+1){
    std::cout << "main() : arcg = " << argc << " is different from " << Nparam+1 <<". Exiting." << std::endl;
    std::cout << "Usage  : ./main inputList.txt treeList.txt outputFile" << std::endl;
    exit (1);
  };
  
  std::string inputList(argv[1]);
  std::string treeList (argv[2]);
  std::string outFile  (argv[3]);
  
  analysisClassL1 analysis (inputList, treeList, outFile);
  
  analysis.run();
}
void makePairs(int nEntries=-1, int iHalf=0, int nHalf=1,
	       TString dirOut="/home/llr/cms/ndaci/SKWork/macro/skEfficiency/tagAndProbe/EfficiencyStudy/Study2012/forgot/",
	       TString dirIn="/data_CMS/cms/ndaci/ndaci_2012/SingleElectron/Update/forgot/Elepairs/",
	       TString data="yep",
	       TString nameChain="produceNtuple/eIDSimpleTree", 
	       int iJson=-1, TString RunPhase="2011A", bool debug=false)
{
  // Output Log
  ofstream outlog(dirOut+"log.txt",ios::out);

  outlog << " <--------------------------------- START --------------------------------->" << endl;

  // Process the tree
  if(debug) cout << "process the tree" << endl;

  vector<TString> treeList(1);
  treeList[0]="/afs/cern.ch/user/t/thennequ/private/CMSSW_6_2_0/tree_testFastSim_TPG.root";
  if(data=="Run2012A_13Jul") {
    treeList = list_Run2012A_13Jul();
  }
  else if(data=="Run2012A_06Aug") {
    treeList = list_Run2012A_06Aug();
  }
  else if(data=="Run2012B_13Jul") {
    treeList = list_Run2012B_13Jul();
  }
  else if(data=="Run2012C_24Aug") {
    treeList = list_Run2012C_24Aug();
  }
  else if(data=="Run2012C_PRV2") {
    treeList = list_Run2012C_PRV2();
  }
  else if(data=="Run2012D_PRV1") {
    treeList = list_2012D_PRV1();
  }
  else if(data=="Run2012D_PRV1_up") {
    treeList = list_2012D_PRV1_up();
  }
  else if(data=="SingEle_ReReco08Nov") {
    treeList = list_SingEle_ReReco08Nov();
  }
  else if(data=="SingEle_ReReco19Nov") {
    treeList = list_SingEle_ReReco19Nov();
  }
  else if(data=="DYee_Fall11") {
    treeList = list_DYee_Fall11();
  }
  /**else {
  
  }**/

  int n,n1,n2;

  n = treeList.size() / nHalf ;
  n1 = iHalf * n ;

  if( iHalf < (nHalf-1) )
    n2 = (iHalf+1) * n ;

  else if( iHalf == nHalf-1 )
    n2 = treeList.size();

  for(int i = n1 ; i < n2 ; i++) {

    if(debug) cout << "process file #" << i << " (n1=" << n1 << " ; n2=" << n2 << ")" << endl;
    cout<<"process "<<i<<endl;
    process(nameChain,treeList[i],i,nEntries,dirOut,dirIn,outlog,iJson,RunPhase,debug);

    if(debug) cout << "processed" << endl;
  }

  outlog << " <--------------------------------- DONE --------------------------------->" << endl;
  if(debug) cout << "DONE" << endl;

}