예제 #1
0
파일: ppsort.C 프로젝트: velicanu/UserCode
void stdsort(int startline = 0, string flist = "")
{
  //! Define the input and output file and HiForest
  string buffer;
  vector<string> listoffiles;
  int nlines = 0;
  ifstream infile(flist.data());

  if (!infile.is_open()) {
    cout << "Error opening file. Exiting." << endl;
    return;
  } else {
    while (!infile.eof()) {
      infile >> buffer;
      listoffiles.push_back(buffer);
      nlines++;
    }
  }
  cout<<" here"<<endl;
  HiForest *c = new HiForest(listoffiles[startline].data(),0,0,0,0,true);
  TFile * outf = new TFile(Form("sortedHiForest_%d.root",startline),"recreate");
  c->outf = outf;
  c->SetOutputFile("null",true);

  c->LoadNoTrees();
  c->hasEvtTree = true;
  //! loop through all the events once to construct the cent,vz pair array we'll be sorting over
  cout << "Constructing the cent:vz pair array..." << endl;
  for (int i=0;i<c->GetEntries();i++)
  {
    c->GetEntry(i);
    pair<int,double> centvz;
    centvz.first = c->evt->hiBin;
    centvz.second = c->evt->vz;
    evtCentVz.push_back(centvz);
    if (i%1000==0) cout <<i<<" / "<<c->GetEntries()<<" "<<c->setupOutput<<endl;
  }
  c->ResetBooleans();
  //! Make the index array which will get sorted on first centrality
  int evtindecies[c->GetEntries()];
  for (int i=0;i<c->GetEntries();i++)
  {
    evtindecies[i] = i;
  }
  
  cout << "Sorting the cent:vz pair array..." << " "<<c->setupOutput<<endl;
  //! Sort the index array first on the centrality bin, then on the vz of the entry at that index
  qsort (evtindecies, c->GetEntries(), sizeof(int), comparecentvz);
  
  //! Now fill the tree in the new order
  cout << "Filling the tree in the sorted order..." << " "<<c->setupOutput<<endl;
  for (int i=0;i<c->GetEntries();i++)
  {
    c->GetEntry(evtindecies[i]);
    c->FillOutput();
    if (i%1000==0) cout <<i<<" / "<<c->GetEntries()<<" "<<c->setupOutput<<endl;
  }

  delete c;
}
예제 #2
0
void skimTree(char *infname = "../JetSample/hiForest_Jet80or95_GR_R_53_LV6_12Mar2014_0000CET_Track8_Jet21_0.root")
{
   // Define the input file and HiForest
   HiForest *c = new HiForest(infname);
    c->hasHltTree=0;
   c->hasPFTree=0;
   c->hasPhotonTree=0;
   c->hasTowerTree=0;
   c->hasHbheTree=0;
   c->hasEbTree=0;
   c->hasGenpTree=0;
   c->hasGenParticleTree=0;   
   c->hasAk5CaloJetTree=0;
   c->hasAkPu2CaloJetTree=0;
   c->hasAkPu3CaloJetTree=0;
   c->hasAkPu4CaloJetTree=0;
   c->hasAkPu5CaloJetTree=0;
   c->hasAkPu2JetTree=0;
   c->hasAkPu3JetTree=0;
   c->hasAkPu4JetTree=0;
   c->hasAkPu5JetTree=0;
   c->hasAkVs2PFJetTree=0;
   c->hasAkVs3PFJetTree=0;
   c->hasAkVs4PFJetTree=0;
   c->hasAkVs5PFJetTree=0;
   c->SetOutputFile("skim_jet.root");

   int filtered=0;
   // Main loop
   for (int i=0;i<c->GetEntries();i++)
   {
      c->GetEntry(i);
      if (i%1000==0) cout <<filtered<<" "<<i<<" / "<<c->GetEntries()<<endl;
      //if (c->evt.hiBin>=20) continue;
      int flag=0;
      int flag2=0;
      for (int j=0;j<c->akVs3Calo.nref;j++) {
        if (fabs(c->akVs3Calo.jteta[j])>2) continue;
	if (c->akVs3Calo.jtpt[j]>120) flag=1;
	if (c->akVs3Calo.jtpt[j]>50) flag2++;
	if (flag>=1&&flag2>=2) break;
      }
        if (flag>=1&&flag2>=2) {
	   c->FillOutput(); // Write output forest
	   filtered++;
	}  
   }

   delete c;
}
예제 #3
0
void correlateEvent(char *infname = "0.root", char *mbname = "mb.root", char *outfname = "matched_Jet.root",int startEntry=0,int endEntry=0)
{
   // Define the input file and HiForest

   HiForest *d = new HiForest(mbname);
   turnOffBranches(d);
   d->SetOutputFile(outfname);
   cout <<"good good"<<endl;

   HiForest *c = new HiForest(infname);
   turnOffBranches(c);
   int filtered=0;
   int idx=0;
   // Main loop
   if (endEntry==0) endEntry=c->GetEntries();

   for (int i=startEntry;i<=endEntry;i++)
   {
      c->GetEntry(i);
      if (i%100==0) cout <<filtered<<" "<<i<<" / "<<c->GetEntries()<<endl;
      int nMatched=0;

      while (nMatched<20)
      {
         idx++;
         cout <<i<<" / " << c->GetEntries() << " / "<<idx<<" / "<<nMatched<<"\r";
         if (idx>=d->GetEntries()) idx=0;
         if (idx==i) continue;
         d->evtTree->GetEntry(idx);
         if ((fabs(c->evt.hiBin-d->evt.hiBin)/(double)c->evt.hiBin)>0.05) continue;
         if ((fabs(c->evt.vz-d->evt.vz)>1)) continue;

         d->skimTree->GetEntry(idx);
         if (!(d->skim.pcollisionEventSelection && d->skim.pHBHENoiseFilter )) continue;        
         
         nMatched++;
         d->GetEntry(idx);
         d->FillOutput(); // Write output forest 
      }   
         cout <<std::endl;
   }

   delete c;
   delete d;
}
예제 #4
0
파일: noiseSkim.C 프로젝트: yenjie/pPbAna
void noiseSkim(char *infname = "/d100/yjlee/hiForest/PromptReco2011/HIHighPt/skim_Photon35/merged_HIData2011_HIHighPt_highPtExercise_photonSkim35GeVEB.root")
{
   // Define the input file and HiForest
   HiForest *c = new HiForest(infname);
   c->SetOutputFile("skim_jet.root");

   // Main loop
   for (int i=0;i<c->GetEntries();i++)
   {
      c->GetEntry(i);
      if (i%1000==0) cout <<i<<" / "<<c->GetEntries()<<endl;
      
      if (c->akPu3PF.jtpt[0]>=98||c->akPu2PF.jtpt[0]>=98&&c->akPu4PF.jtpt[0]>98){
         c->FillOutput(); // Write output forest
      }
   }

   delete c;
}
예제 #5
0
// void sortforestCentVz(double etCut=40, char *infname = "/mnt/hadoop/cms/store/user/velicanu/forest/HiForestTrack_v3.root")
// void sortforestCentVz(double etCut=40, char *infname = "/mnt/hadoop/cms/store/user/velicanu/HIHighPt/HIRun2011_hiHighPtTrack_PromptSkim_forest_v0/9902eec616cc8b0649a7a8bb69754615/HiForest_998_1_rJ1.root")
// void sortforestCentVz(double etCut=40, char *infname = "/net/hisrv0001/home/dav2105/hdir/HIHighPt/HIRun2011_hiHighPtTrack_PromptSkim_forest_v0/9902eec616cc8b0649a7a8bb69754615/HiForest_1000_1_8wo.root")
// void sortforestCentVz(double etCut=40, char *infname = "/net/hisrv0001/home/dav2105/hdir/HIHighPt/HIRun2011_hiHighPtTrack_PromptSkim_forest_v0/9902eec616cc8b0649a7a8bb69754615/HiForest_1001_1_TRm.root")
void frankforestsort(int startline = 0)
{
  //! Define the input and output file and HiForest
  string buffer;
  vector<string> listoffiles;
  int nlines = 0;
  // ifstream infile("/net/hidsk0001/d00/scratch/dav2105/forest/jobsort/jet80sortlist.txt");
  ifstream infile("/net/hidsk0001/d00/scratch/dav2105/forest/jobsort/frankjet80sortlist.txt");
  // ifstream infile("/net/hidsk0001/d00/scratch/dav2105/forest/jobsort/sortlist.txt");

  if (!infile.is_open()) {
    cout << "Error opening file. Exiting." << endl;
    return;
  } else {
    while (!infile.eof()) {
      infile >> buffer;
      listoffiles.push_back(buffer);
      nlines++;
    }
  }
  cout<<" here"<<endl;
  HiForest *c = new HiForest(listoffiles[startline].data(),0,0,0,0,true);
  // c->SetOutputFile(Form("sortedHiForest_%d.root",startline));
  TFile * outf = new TFile(Form("sortedHiForest_%d.root",startline),"recreate");
  c->outf = outf;
  c->SetOutputFile("null",true);

  
  //! loop through all the events once to construct the cent,vz pair array we'll be sorting over
  cout << "Constructing the cent:vz pair array..." << endl;
  for (int i=0;i<c->GetEntries();i++)
  {
    c->GetEntry(i);
    pair<int,double> centvz;
    centvz.first = c->evt->hiBin;
    centvz.second = c->evt->vz;
    evtCentVz.push_back(centvz);
    if (i%1000==0) cout <<i<<" / "<<c->GetEntries()<<" "<<c->setupOutput<<endl;
    // if (i > 1000) break;
  }
  
  //! Make the index array which will get sorted on first centrality
  int evtindecies[c->GetEntries()];
  for (int i=0;i<c->GetEntries();i++)
  {
    evtindecies[i] = i;
    // if (i > 1000) break;
	// cout << "In original loop | " << evtindecies[i] << " : (" << evtCentVz[evtindecies[i]].first <<" , "<<evtCentVz[evtindecies[i]].second << endl;
  }
  
  cout << "Sorting the cent:vz pair array..." << " "<<c->setupOutput<<endl;
  //! Sort the index array first on the centrality bin, then on the vz of the entry at that index
  qsort (evtindecies, c->GetEntries(), sizeof(int), comparecentvz);
  // qsort (evtindecies, 1000, sizeof(int), comparecentvz);
  
  //! Now fill the tree in the new order
  cout << "Filling the tree in the sorted order..." << " "<<c->setupOutput<<endl;
  for (int i=0;i<c->GetEntries();i++)
  {
    c->GetEntry(evtindecies[i]);
    c->FillOutput();
	// cout << "In fill loop | " << evtindecies[i] << " : (" << evtCentVz[evtindecies[i]].first <<" , "<<evtCentVz[evtindecies[i]].second << endl;
    if (i%1000==0) cout <<i<<" / "<<c->GetEntries()<<" "<<c->setupOutput<<endl;
    // if (i > 1000) break;
  }

  delete c;
}