Пример #1
0
    /**
     * The resolution process
     * @param maxiters the upper bound for iterations on entry, on exit real number of performed iters
     * @param bncs the state of computations 
     * @param recupd true if record was updated
     */
    void solve(long long int& maxiters, BNCState<FT> & bnc, bool& recupd) {
        long long int I = 0;
        BNCSubPrinter<double> subprinter;
        for (; I < maxiters; I++) {
#if 0            
            std::cout << "step " << I << " ^^^^^^^^^^^^^^^^^^\n";
            std::cout << "Record = " << bnc.mRecord->getValue() << "\n";
#endif
#if 0 
            BNBTreeUtils::printTree(*bnc.mTree, subprinter);
            std::cout << "step " << I << " vvvvvvvvvvvvvvvvvv\n";
#endif            


            BNBNode* node = bnc.mTreeManager->get();
            if (node == NULL)
                break;
            BNCSub<FT>* sub = (BNCSub<FT>*) node->mData;


            mCutFactory->getCuts(sub->mBox, sub->mCuts);


            std::vector< Box<FT> > bv;
            std::vector< Cut<FT> > cuts;
            BNBNode* np = node;
            int cutd = 0;
            int n = sub->mBox.mDim;
            bv.push_back(sub->mBox);

            while (np && (cutd++ < mCutLookupDepth)) {
#if 0
                std::cout << "Cuts at node " << cutd << ":\n";
#endif                
                BNCSub<FT>* subp = (BNCSub<FT>*) np->mData;
                applyCuts(subp->mCuts, bv);
                if (bv.empty())
                    break;
                np = np->mParent;
            }
            if (bv.empty()) {
                deleteNode(node);
                continue;
            } else if (bv.size() == 1) {
                Box<FT> b0(n), b1(n), b2(n);
                b0 = bv.at(0);
                bv.pop_back();
                /*
                BoxUtils::divideByLongestEdge(b0, b1, b2);
                bv.push_back(b1);
                bv.push_back(b2);
                 */
                mBoxSplitter->split(b0, bv);
            }
            pushNewSubs(*bnc.mTreeManager, bv, node);
        }
        maxiters = I;
    }
Пример #2
0
void checkOpenHLT::Loop()
{
  gROOT->SetBatch(true);
  // Apply the default trigger cuts
  defaultTriggerCuts_ = true;

  // gROOT->Reset();
  gStyle->SetOptStat(0);
//   In a ROOT session, you can do:
//      Root > .L checkOpenHLT.C
//      Root > checkOpenHLT t
//      Root > t.GetEntry(12); // Fill t data members with entry number 12
//      Root > t.Show();       // Show values of entry 12
//      Root > t.Show(16);     // Read and show values of entry 16
//      Root > t.Loop();       // Loop on all entries
//

//     This is the loop skeleton where:
//    jentry is the global entry number in the chain
//    ientry is the entry number in the current Tree
//  Note that the argument to GetEntry must be:
//    jentry for TChain::GetEntry
//    ientry for TTree::GetEntry and TBranch::GetEntry
//
//       To read only selected branches, Insert statements like:
// METHOD1:
//    fChain->SetBranchStatus("*",0);  // disable all branches
//    fChain->SetBranchStatus("branchname",1);  // activate branchname
// METHOD2: replace line
//    fChain->GetEntry(jentry);       //read all branches
//by  b_branchname->GetEntry(ientry); //read only this branch
   if (fChain == 0) return;

   fChain->SetBranchStatus("*",0);  // disable all branches
   fChain->SetBranchStatus("NohMuL2NoVtx",1);
   fChain->SetBranchStatus("ohMuL2NoVtxPt",1);
   fChain->SetBranchStatus("ohMuL2NoVtxPhi",1);
   fChain->SetBranchStatus("ohMuL2NoVtxEta",1);
   fChain->SetBranchStatus("ohMuL2NoVtxChg",1);
   fChain->SetBranchStatus("ohMuL2NoVtxPtErr",1);
   fChain->SetBranchStatus("ohMuL2NoVtxDr",1);
   fChain->SetBranchStatus("ohMuL2NoVtxDz",1);
   fChain->SetBranchStatus("ohMuL2NoVtxL1idx",1);
   fChain->SetBranchStatus("ohMuL2NoVtxNhits",1);
   fChain->SetBranchStatus("ohMuL2NoVtxNchambers",1);

   // Setup all histograms
   TFile * outputFile = new TFile("CheckOpenHLT.root", "RECREATE");
   TH1F * numMuons = new TH1F("NumMuons", "Number of muons", 5, 0, 4);
   TH1F * num2Muons = new TH1F("Num2Muons", "Number of muons in events with at least 2", 5, 0, 4);

   TString noCutsName("_NoCuts_");
   TString oneValidHitName("_OneValidHit_");
   TString oneValidChamberName("_OneValidChamber_");
   TString parallelismCutName("_ParallelismCut_");

   prepareAllHistograms(noCutsName, outputFile);
   prepareAllHistograms(oneValidHitName, outputFile);
   prepareAllHistograms(oneValidChamberName, outputFile);
   prepareAllHistograms(parallelismCutName, outputFile);

   Long64_t nentries = fChain->GetEntriesFast();
   Long64_t nbytes = 0, nb = 0;
   for (Long64_t jentry=0; jentry<nentries;jentry++) {
      Long64_t ientry = LoadTree(jentry);
      if (ientry < 0) break;
      nb = fChain->GetEntry(jentry);
      nbytes += nb;

      if( jentry%100 == 0 ) std::cout << "Analyzing entry number " << jentry << std::endl;
      // std::cout << "Number of L2 NoVtx muons = " << NohMuL2NoVtx << std::endl;

      numMuons->Fill(NohMuL2NoVtx);

      parallelDiff_ = -99.;
      if( NohMuL2NoVtx > 1 ) {
        TLorentzVector firstMuon = fromPtEtaPhiToPxPyPz(ohMuL2NoVtxPt[0], ohMuL2NoVtxEta[0], ohMuL2NoVtxPhi[0]);
        TLorentzVector secondMuon = fromPtEtaPhiToPxPyPz(ohMuL2NoVtxPt[1], ohMuL2NoVtxEta[1], ohMuL2NoVtxPhi[1]);
        double px1 = firstMuon.Px();
        double py1 = firstMuon.Py();
        double pz1 = firstMuon.Pz();
        double px2 = secondMuon.Px();
        double py2 = secondMuon.Py();
        double pz2 = secondMuon.Pz();
        parallelDiff_ = acos((px1*px2 + py1*py2 + pz1*pz2)/sqrt(px1*px1 + py1*py1 + pz1*pz1)/sqrt(px2*px2 + py2*py2 + pz2*pz2));

	num2Muons->Fill(NohMuL2NoVtx);

        // Skip if need to apply the default trigger cuts and they do not pass the pt cut
        // if( defaultTriggerCuts_ && !(NohMuL2NoVtx > 1 && ohMuL2NoVtxPt[0] > 23 && ohMuL2NoVtxPt[1] > 23) ) continue;

        int arraySize = std::min(NohMuL2NoVtx, 4);

        bool selectOnChambers = false;
        bool selectOnParallelism = false;

        bool selectionArray[4];

        // No cuts
        selectionArray[0] = true;
        selectionArray[1] = true;
        selectionArray[2] = true;
        selectionArray[3] = true;
        fillAllHistograms(noCutsName, arraySize, selectionArray);

        // Fill histograms for the > 0 valid hit cut
        applyCuts(arraySize, selectOnChambers, parallelDiff_, selectOnParallelism, selectionArray);
        fillAllHistograms(oneValidHitName, arraySize, selectionArray);

        // One valid chamber cut
        selectOnChambers = true;
        applyCuts(arraySize, selectOnChambers, parallelDiff_, selectOnParallelism, selectionArray);
        fillAllHistograms(oneValidChamberName, arraySize, selectionArray);

        // Anti-parallel cut
        selectOnParallelism = true;
        applyCuts(arraySize, selectOnChambers, parallelDiff_, selectOnParallelism, selectionArray);
        fillAllHistograms(parallelismCutName, arraySize, selectionArray);
      }
      // if (Cut(ientry) < 0) continue;
   }
   saveAllHistograms(noCutsName);
   saveAllHistograms(oneValidHitName);
   saveAllHistograms(oneValidChamberName);
   saveAllHistograms(parallelismCutName);

   outputFile->Write();
}