int main(int ac, char** av){ if(ac < 2){ std::cout << "usage: ./signalAcceptance inputFile[s]" << std::endl; return -1; } TH1F* allCategory = new TH1F("allCategory","all Category",11,0.5,11.5); TH1F* preselCategory = new TH1F("preselCategory","presel Category",11,0.5,11.5); TH1F* photonCategory = new TH1F("photonCategory","reco photon Category",11,0.5,11.5); TH1F* VisAllCategory = new TH1F("VisAllCategory","all Category, Vis",11,0.5,11.5); TH1F* VisPreselCategory = new TH1F("VisPreselCategory","presel Category, Vis",11,0.5,11.5); TH1F* VisPhotonCategory = new TH1F("VisPhotonCategory","reco photon Category, Vis",11,0.5,11.5); TH1F* dROtherGen = new TH1F("dROtherGen", "dROtherGen", 800, 0.0, 4.0); TH1F* parentage = new TH1F("parentage","parentage",30, 0, 30); TH1F* dptOverpt = new TH1F("dptOverpt","dptOverpt", 400, -2.0, 2.0); TH1F* dRrecoGen = new TH1F("dRrecoGen","dRrecoGen", 200, 0.0, 0.2); TH1F* dPhiRecoGen = new TH1F("dPhiRecoGen","dPhiRecoGen", 400, 0.0, 0.2); TH1F* dEtaRecoGen = new TH1F("dEtaRecoGen","dEtaRecoGen", 800, -0.2, 0.2); TH1F* dRGenNearJet = new TH1F("dRGenNearJet","dRGenNearJet", 200, 0.0, 1.0); TH1F* dPhiGenNearJet = new TH1F("dPhiGenNearJet","dPhiGenNearJet", 100, 0.0, 0.5); TH1F* dEtaGenNearJet = new TH1F("dEtaGenNearJet","dEtaGenNearJet", 200, -0.5, 0.5); //TH1F* dRGenNextNearJet = new TH1F("dRGenNextNearJet","dRGenNextNearJet", 600, 0.0, 6.0); //TH1F* dPhiGenNextNearJet = new TH1F("dPhiGenNextNearJet","dPhiGenNextNearJet", 300, 0.0, 3.0); //TH1F* dEtaGenNextNearJet = new TH1F("dEtaGenNextNearJet","dEtaGenNextNearJet", 600, -3.0, 3.0); // object selector Selector* selectorLoose = new Selector(); // create event selectors here EventPick* evtPickLoose = new EventPick("LoosePhotonID"); // do not do jet to photon dR cleaning evtPickLoose->veto_pho_jet_dR = 0.0; EventTree* tree = new EventTree(ac-1, av+1); double PUweight = 1.0; Long64_t nEntr = tree->GetEntries(); for(Long64_t entry=0; entry<nEntr; entry++){ if(entry%10000 == 0) std::cout << "processing entry " << entry << " out of " << nEntr << std::endl; tree->GetEntry(entry); doJER(tree); selectorLoose->process_objects(tree); evtPickLoose->process_event(tree, selectorLoose, PUweight); // fill the histograms fillCategory(tree, allCategory, PUweight); if(evtPickLoose->passPreSel) fillCategory(tree, preselCategory, PUweight); if(evtPickLoose->passAll) fillCategory(tree, photonCategory, PUweight); // fill histograms for gen photon passing the acceptance cuts defined in analysis bool inAcc = false; for(int mcInd=0; mcInd<tree->nMC_; ++mcInd){ if(tree->mcPID->at(mcInd) == 22 && (tree->mcParentage->at(mcInd)==2 || tree->mcParentage->at(mcInd)==10 || tree->mcParentage->at(mcInd)==26) && tree->mcPt->at(mcInd) > 25 && fabs(tree->mcEta->at(mcInd)) < 1.4442){ inAcc = true; } } if(inAcc){ fillCategory(tree, VisAllCategory, PUweight); if(evtPickLoose->passPreSel) fillCategory(tree, VisPreselCategory, PUweight); if(evtPickLoose->passAll) fillCategory(tree, VisPhotonCategory, PUweight); } // have at least one good photon if(!evtPickLoose->passAll) continue; // test //if(overlapMadGraph(tree)) continue; int phoInd = evtPickLoose->Photons.at(0); // experiment with delta R cuts for photons for(int mcInd=0; mcInd<tree->nMC_; ++mcInd){ bool etetamatch = dR(tree->mcEta->at(mcInd),tree->mcPhi->at(mcInd),tree->phoEta_->at(phoInd),tree->phoPhi_->at(phoInd)) < 0.2 && (fabs(tree->phoEt_->at(phoInd) - tree->mcPt->at(mcInd)) / tree->mcPt->at(mcInd)) < 1.0; if( etetamatch && tree->mcPID->at(mcInd) == 22){ // test if(!(tree->mcParentage->at(mcInd)==2 || tree->mcParentage->at(mcInd)==10 || tree->mcParentage->at(mcInd)==26)) continue; // fill histograms for mathced photon candidate parentage->Fill( tree->mcParentage->at(mcInd) ); dptOverpt->Fill( (tree->phoEt_->at(phoInd) - tree->mcPt->at(mcInd)) / tree->mcPt->at(mcInd)); dRrecoGen->Fill( dR(tree->mcEta->at(mcInd),tree->mcPhi->at(mcInd),tree->phoEta_->at(phoInd),tree->phoPhi_->at(phoInd)) ); dPhiRecoGen->Fill( dPhi( tree->phoPhi_->at(phoInd) - tree->mcPhi->at(mcInd) ) ); dEtaRecoGen->Fill( tree->phoEta_->at(phoInd) - tree->mcEta->at(mcInd) ); int closestGenInd = secondMinDrIndex( mcInd, tree ); if(dR(tree->mcEta->at(mcInd), tree->mcPhi->at(mcInd), tree->mcEta->at(closestGenInd), tree->mcPhi->at(closestGenInd)) < 0.01){ std::cout << "closest PID " << tree->mcPID->at(closestGenInd) << " MomPID " << tree->mcMomPID->at(closestGenInd) << std::endl; std::cout << "photon mother PID " << tree->mcMomPID->at(mcInd) << std::endl; } dROtherGen->Fill( dR(tree->mcEta->at(mcInd), tree->mcPhi->at(mcInd), tree->mcEta->at(closestGenInd), tree->mcPhi->at(closestGenInd)) ); int closestJetInd = minDrIndex( tree->mcEta->at(mcInd), tree->mcPhi->at(mcInd), tree->jetEta_, tree->jetPhi_ ); dRGenNearJet->Fill( dR(tree->mcEta->at(mcInd), tree->mcPhi->at(mcInd), tree->jetEta_->at(closestJetInd), tree->jetPhi_->at(closestJetInd) ) ); dPhiGenNearJet->Fill( dPhi( tree->jetPhi_->at(closestJetInd) - tree->mcPhi->at(mcInd) ) ); dEtaGenNearJet->Fill( tree->jetEta_->at(closestJetInd) - tree->mcEta->at(mcInd) ); //closestJetInd = secondMinDrIndex( tree->mcEta->at(mcInd), tree->mcPhi->at(mcInd), tree->jetEta_, tree->jetPhi_ ); //dRGenNextNearJet->Fill( dR(tree->mcEta->at(mcInd), tree->mcPhi->at(mcInd), tree->jetEta_->at(closestJetInd), tree->jetPhi_->at(closestJetInd) ) ); //dPhiGenNextNearJet->Fill( dPhi( tree->jetPhi_->at(closestJetInd) - tree->mcPhi->at(mcInd) ) ); //dEtaGenNextNearJet->Fill( tree->jetEta_->at(closestJetInd) - tree->mcEta->at(mcInd) ); } } } evtPickLoose->print_cutflow(); // write histograms TFile outFile("signalAcc.root","RECREATE"); saveHist(allCategory, &outFile); saveHist(preselCategory, &outFile); saveHist(photonCategory, &outFile); saveHist(VisAllCategory, &outFile); saveHist(VisPreselCategory, &outFile); saveHist(VisPhotonCategory, &outFile); saveHist(dROtherGen, &outFile); saveHist(parentage, &outFile); saveHist(dptOverpt, &outFile); saveHist(dRrecoGen, &outFile); saveHist(dPhiRecoGen, &outFile); saveHist(dEtaRecoGen, &outFile); saveHist(dRGenNearJet, &outFile); saveHist(dPhiGenNearJet, &outFile); saveHist(dEtaGenNearJet, &outFile); //saveHist(dRGenNextNearJet, &outFile); //saveHist(dPhiGenNextNearJet, &outFile); //saveHist(dEtaGenNextNearJet, &outFile); outFile.Close(); delete tree; return 0; }
EventTree* EventTree::FindOrInsert(Accessible* aContainer) { if (!mFirst) { mFirst.reset(new EventTree(aContainer, true)); return mFirst.get(); } EventTree* prevNode = nullptr; EventTree* node = mFirst.get(); do { MOZ_ASSERT(!node->mContainer->IsApplication(), "No event for application accessible is expected here"); MOZ_ASSERT(!node->mContainer->IsDefunct(), "An event target has to be alive"); // Case of same target. if (node->mContainer == aContainer) { return node; } // Check if the given container is contained by a current node Accessible* top = mContainer ? mContainer : aContainer->Document(); Accessible* parent = aContainer; while (parent) { // Reached a top, no match for a current event. if (parent == top) { break; } // We got a match. if (parent->Parent() == node->mContainer) { return node->FindOrInsert(aContainer); } parent = parent->Parent(); MOZ_ASSERT(parent, "Wrong tree"); } // If the given container contains a current node // then // if show or hide of the given node contains a grand parent of the current node // then ignore the current node and its show and hide events // otherwise ignore the current node, but not its show and hide events Accessible* curParent = node->mContainer; while (curParent && !curParent->IsDoc()) { if (curParent->Parent() != aContainer) { curParent = curParent->Parent(); continue; } // Insert the tail node into the hierarchy between the current node and // its parent. node->mFireReorder = false; UniquePtr<EventTree>& nodeOwnerRef = prevNode ? prevNode->mNext : mFirst; UniquePtr<EventTree> newNode(new EventTree(aContainer, mDependentEvents.IsEmpty())); newNode->mFirst = Move(nodeOwnerRef); nodeOwnerRef = Move(newNode); nodeOwnerRef->mNext = Move(node->mNext); // Check if a next node is contained by the given node too, and move them // under the given node if so. prevNode = nodeOwnerRef.get(); node = nodeOwnerRef->mNext.get(); UniquePtr<EventTree>* nodeRef = &nodeOwnerRef->mNext; EventTree* insNode = nodeOwnerRef->mFirst.get(); while (node) { Accessible* curParent = node->mContainer; while (curParent && !curParent->IsDoc()) { if (curParent->Parent() != aContainer) { curParent = curParent->Parent(); continue; } MOZ_ASSERT(!insNode->mNext); node->mFireReorder = false; insNode->mNext = Move(*nodeRef); insNode = insNode->mNext.get(); prevNode->mNext = Move(node->mNext); node = prevNode; break; } prevNode = node; nodeRef = &node->mNext; node = node->mNext.get(); } return nodeOwnerRef.get(); } prevNode = node; } while ((node = node->mNext.get())); MOZ_ASSERT(prevNode, "Nowhere to insert"); MOZ_ASSERT(!prevNode->mNext, "Taken by another node"); // If 'this' node contains the given container accessible, then // do not emit a reorder event for the container // if a dependent show event target contains the given container then do not // emit show / hide events (see Process() method) prevNode->mNext.reset(new EventTree(aContainer, mDependentEvents.IsEmpty())); return prevNode->mNext.get(); }
EventTree* EventTree::FindOrInsert(Accessible* aContainer) { if (!mFirst) { mFirst.reset(new EventTree(aContainer, mDependentEvents.IsEmpty())); return mFirst.get(); } EventTree* prevNode = nullptr; EventTree* node = mFirst.get(); do { MOZ_ASSERT(!node->mContainer->IsApplication(), "No event for application accessible is expected here"); MOZ_ASSERT(!node->mContainer->IsDefunct(), "An event target has to be alive"); // Case of same target. if (node->mContainer == aContainer) { return node; } // Check if the given container is contained by a current node Accessible* top = mContainer ? mContainer : aContainer->Document(); Accessible* parent = aContainer; while (parent) { // Reached a top, no match for a current event. if (parent == top) { break; } // We got a match. if (parent->Parent() == node->mContainer) { // Reject the node if it's contained by a show/hide event target uint32_t evCount = node->mDependentEvents.Length(); for (uint32_t idx = 0; idx < evCount; idx++) { AccMutationEvent* ev = node->mDependentEvents[idx]; if (ev->GetAccessible() == parent) { #ifdef A11Y_LOG if (logging::IsEnabled(logging::eEventTree)) { logging::MsgBegin("EVENTS_TREE", "Rejecting node contained by show/hide"); logging::AccessibleInfo("Node", aContainer); logging::MsgEnd(); } #endif // If the node is rejected, then check if it has related hide event // on stack, and if so, then connect it to the parent show event. if (ev->IsShow()) { AccShowEvent* showEv = downcast_accEvent(ev); Controller(aContainer)-> WithdrawPrecedingEvents(&showEv->mPrecedingEvents); } return nullptr; } } return node->FindOrInsert(aContainer); } parent = parent->Parent(); MOZ_ASSERT(parent, "Wrong tree"); } // If the given container contains a current node // then // if show or hide of the given node contains a grand parent of the current node // then ignore the current node and its show and hide events // otherwise ignore the current node, but not its show and hide events Accessible* curParent = node->mContainer; while (curParent && !curParent->IsDoc()) { if (curParent->Parent() != aContainer) { curParent = curParent->Parent(); continue; } // Insert the tail node into the hierarchy between the current node and // its parent. node->mFireReorder = false; UniquePtr<EventTree>& nodeOwnerRef = prevNode ? prevNode->mNext : mFirst; UniquePtr<EventTree> newNode(new EventTree(aContainer, mDependentEvents.IsEmpty())); newNode->mFirst = Move(nodeOwnerRef); nodeOwnerRef = Move(newNode); nodeOwnerRef->mNext = Move(node->mNext); // Check if a next node is contained by the given node too, and move them // under the given node if so. prevNode = nodeOwnerRef.get(); node = nodeOwnerRef->mNext.get(); UniquePtr<EventTree>* nodeRef = &nodeOwnerRef->mNext; EventTree* insNode = nodeOwnerRef->mFirst.get(); while (node) { Accessible* curParent = node->mContainer; while (curParent && !curParent->IsDoc()) { if (curParent->Parent() != aContainer) { curParent = curParent->Parent(); continue; } MOZ_ASSERT(!insNode->mNext); node->mFireReorder = false; insNode->mNext = Move(*nodeRef); insNode = insNode->mNext.get(); prevNode->mNext = Move(node->mNext); node = prevNode; break; } prevNode = node; nodeRef = &node->mNext; node = node->mNext.get(); } return nodeOwnerRef.get(); } prevNode = node; } while ((node = node->mNext.get())); MOZ_ASSERT(prevNode, "Nowhere to insert"); MOZ_ASSERT(!prevNode->mNext, "Taken by another node"); // If 'this' node contains the given container accessible, then // do not emit a reorder event for the container // if a dependent show event target contains the given container then do not // emit show / hide events (see Process() method) prevNode->mNext.reset(new EventTree(aContainer, mDependentEvents.IsEmpty())); return prevNode->mNext.get(); }