#ifndef __NEXTEVENT__ #define __NEXTEVENT__ //---------- hades etc ------------- #include "hades.h" #include "hrecevent.h" #include "heventheader.h" #include "hcategory.h" #include "hphysicsconstants.h" #include "hgeomtransform.h" #include "hmdcsizescells.h" //---------- detector def ---------- #include "hgeantdef.h" #include "hmdcdef.h" #include "hmdctrackddef.h" #include "hmdctrackgdef.h" #include "richdef.h" #include "tofdef.h" #include "showerdef.h" #include "rpcdef.h" #include "hparticledef.h" //--------- data objects ----------- #include "hmetamatch2.h" #include "hmdccal1sim.h" #include "hmdcseg.h" #include "hmdcsegsim.h" #include "hmdctrkcand.h" #include "hsplinetrack.h" #include "hrktrackB.h" #include "hshowerhitsim.h" #include "htofhit.h" #include "htofhitsim.h" #include "htofcluster.h" #include "htofclustersim.h" #include "hrichhit.h" #include "hrichhitsim.h" #include "hrpccluster.h" #include "hrpcclustersim.h" #include "hparticlecand.h" #include "hparticlecandsim.h" //--------- helpers ----------- #include "hgeomvector.h" #include "hcategorymanager.h" #include "hparticletracksorter.h" #include "TROOT.h" #include "TString.h" #include "TSystem.h" #include "TRandom.h" #include "TStopwatch.h" #include "TApplication.h" #include "TEveManager.h" #include "TEveScene.h" #include "TEveElement.h" #include "TEveLine.h" #include "TEvePointSet.h" #include "TEveQuadSet.h" #include "TEveViewer.h" #include "TGLabel.h" #include "TGFrame.h" #include "TGButton.h" #include "TGNumberEntry.h" #include "TGButtonGroup.h" #include "TGNumberEntry.h" #include "TGWindow.h" #include "TGLayout.h" #include #include #include "hedhelpers.h" #include "hedhitobjects.h" #include "hedgui.h" #include "userFunc.C" // selectLeptonsBeta() is defined here using namespace std; //--------------------------------------------------------- // NEXT EVENT // This macro will load a new event into memory. // It performs a call to Hades event loop. After // running the event loop the full event is available // in memory. The different detector hits can be selected // by the user, tranformed and added to the event scene of // Eve. All objects of the previous event scene will be // destroyed. // // // Class HEDEvtNavHandler : event handler connect to GUI // // this Class keeps provides selectEvent() function connected // to the "next Event" button. The function then calls // nextEventLoop() or nextEvent() depending if the the loop // box is checked. // HEDEvtNavHandler holds the user defined TEveElementLists // which are inserted in the Event Scene of TEveManager. The // user has to clean and fill this lists inside nextEvent(). // The lists appear in "Eve" tab of the GUI in "Scenes/Event scene". // The regions to be modified are marked \"## USER ACTION ##\" //--------------------------------------------------------- class HEDEvtNavHandler { static HEDEvtNavHandler* gEDEvtNavHandler; //################## USER ACTION ########################## // declare all list of elements // add as many as you need TEveElementList* vertexlist; HEDGroup* sectors; HEDGroup* particlecandNoLep; HEDGroup* particlecandLep; HEDGroup* particlecandHad; HEDGroup* richpadplane; HEDGroup* richhitpadplane; HEDGroup2D* allMdcWires; HEDMdcWireManager* wires; //######################################################### private: HEDEvtNavHandler(){ gEDEvtNavHandler = this; //################## USER ACTION ########################## // create all list of elements // which have been declared. They // have to added to event scene // cleared in ech event vertexlist = new TEveElementList("vertex","vertex"); sectors = new HEDGroup ("sectors" ,"sectors" ,6,"Sector"); particlecandNoLep= new HEDGroup ("particlecandNoLep","particlecandNoLep",6,"particlecandNoLep"); particlecandLep = new HEDGroup ("particlecandLep" ,"particlecandLep" ,6,"particlecandLep"); particlecandHad = new HEDGroup ("particlecandHad" ,"particlecandHad" ,6,"particlecandHad"); richpadplane = new HEDGroup ("richpadplane" ,"richpadplane" ,6,"richpadplane"); richhitpadplane = new HEDGroup ("richhitpadplane" ,"richhitpadplane" ,6,"richhitpadplane"); allMdcWires = new HEDGroup2D ("allMdcwires" ,"allMdcwires" ,6,4,"Sector","Module"); wires = new HEDMdcWireManager(); TEveScene* eveEv = gEve->GetEventScene(); // add all list of elements to event scene // they will appear in "Eve" tab of the GUI // in "Scenes/Event scene" with the defined // names. Bool_t sectorsTopLevel = kTRUE; // kTRUE = add gropups that they appear under sector top level gEve->AddElement(vertexlist ,eveEv); if(sectorsTopLevel) { gEve->AddElement(sectors ,eveEv); for(Int_t s = 0;s < 6; s ++){ sectors->getList(s)->AddElement(particlecandLep ->getList(s)); sectors->getList(s)->AddElement(particlecandNoLep->getList(s)); sectors->getList(s)->AddElement(particlecandHad ->getList(s)); sectors->getList(s)->AddElement(richpadplane ->getList(s)); sectors->getList(s)->AddElement(richhitpadplane ->getList(s)); } } else { gEve->AddElement(particlecandLep ,eveEv); gEve->AddElement(particlecandNoLep ,eveEv); gEve->AddElement(particlecandHad ,eveEv); gEve->AddElement(richpadplane ,eveEv); gEve->AddElement(richhitpadplane ,eveEv); } gEve->AddElement(allMdcWires ,eveEv); allMdcWires ->SetRnrSelfChildren(kFALSE,kFALSE); // do not show by default //######################################################### } public: static HEDEvtNavHandler* getHandler(){ // Singleton if(gEDEvtNavHandler == 0){ gEDEvtNavHandler = new HEDEvtNavHandler(); } return gEDEvtNavHandler; } void selectEvent(){ // this function is connected to "next Event" button // calls nextEventLoop() or nextEvent() depending // if the loop checkbox has been set HEDSetup* setup = HEDSetup::getEDSetup(); if(setup->fCheckTimed->IsOn() ){ // loop events nextEventLoop(); } else { nextEvent(); // one event } } Int_t nextEvent() { // this function loads one event into memory and // fills the graphics objects which should be // displayed in the GUI. This is the "User playground" TStopwatch timer; timer.Reset(); timer.Start(); Bool_t drawParticleCand = kTRUE; Bool_t drawRichPadPlane = kTRUE; Bool_t drawRichCompound = kTRUE; Bool_t drawMdcWires = kTRUE; // ROOT 5.26 : clear annotions (if any at all) //gEve->GetViewers()->DeleteAnnotations(); TEveScene* eveEv = gEve->GetEventScene(); if(eveEv){ // clean up last event //################## USER ACTION ########################## // cleanup all list of elements // don't destroy sectors ! vertexlist ->DestroyElements(); particlecandNoLep ->DestroyElements(); particlecandLep ->DestroyElements(); particlecandHad ->DestroyElements(); richpadplane ->DestroyElements(); richhitpadplane ->DestroyElements(); allMdcWires ->DestroyElements(); //######################################################### } if(gHades) { //----------break if last event is reached------------- if(!gHades->eventLoop(1)) return -1; //----------------looping data------------------------- //################## USER ACTION ########################## HCategory* mdcSegCat = (HCategory*) gHades->getCurrentEvent()->getCategory(catMdcSeg); HCategory* mdcCal1Cat = (HCategory*) gHades->getCurrentEvent()->getCategory(catMdcCal1); HCategory* tofHitCat = (HCategory*) gHades->getCurrentEvent()->getCategory(catTofHit); HCategory* tofClustCat = (HCategory*) gHades->getCurrentEvent()->getCategory(catTofCluster); HCategory* rpcClustCat = (HCategory*) gHades->getCurrentEvent()->getCategory(catRpcCluster); HCategory* showerHitCat = (HCategory*) gHades->getCurrentEvent()->getCategory(catShowerHit); HCategory* richHitCat = (HCategory*) gHades->getCurrentEvent()->getCategory(catRichHit); HCategory* particleCandCat = (HCategory*) gHades->getCurrentEvent()->getCategory(catParticleCand); //--------------------------CONFIGURATION PARTICLE SORTER---------------------- //At begin of the program (outside the event loop) HParticleTrackSorter sorter; sorter.init(); // get catgegory pointers etc... sorter.resetFlags(kTRUE,kTRUE,kTRUE,kTRUE); // reset all flags for flags (0-28) ,reject,used,lepton Int_t nCandLep = sorter.fill(selectLeptonsBeta); // fill only good leptons Int_t nCandLepBest = sorter.selectBest(HParticleTrackSorter::kIsBestRKRKMETA,HParticleTrackSorter::kIsLepton); Int_t nCandHad = sorter.fill(HParticleTrackSorter::selectHadrons); // fill only good hadrons (already marked good leptons will be skipped) Int_t nCandHadBest = sorter.selectBest(HParticleTrackSorter::kIsBestRKRKMETA,HParticleTrackSorter::kIsHadron); //--------------------------END CONFIGURATION PARTICLE SORTER------------------- Int_t seqNumber = gHades->getCurrentEvent()->getHeader()->getEventSeqNumber(); Int_t runNumber = gHades->getCurrentEvent()->getHeader()->getEventRunNumber(); //--------------------------------------------------------- HGeomVector pVertex; HEDTransform::calcVertexPoint(pVertex); // for print later vertexlist->AddElement(new HEDVertex()); //--------------------------------------------------------- //--------------------------------------------------------- // RICH if(drawRichPadPlane){ for(Int_t s = 0 ; s < 6; s ++){ richpadplane->AddElement(s,new HEDRichPadPlane(s)); // rich pads fired on cal level } } if(drawRichCompound && richHitCat){ HRichHitSim* richhit; HEDRichCompound* edrichcompound; Int_t size = richHitCat->getEntries(); for(Int_t i = 0; i < size; i ++){ richhit = HCategoryManager::getObject(richhit,richHitCat,i); if(richhit){ Int_t s = richhit->getSector(); edrichcompound = new HEDRichCompound(richhit); edrichcompound ->SetLineColor(kRed); edrichcompound ->SetMarkerColor(kYellow); if(richhit->getRadius() < 0) edrichcompound ->SetLineStyle(7); richhitpadplane->AddElement(s,edrichcompound); } } } //--------------------------------------------------------- //--------------------------------------------------------- if(drawMdcWires && mdcCal1Cat){ HMdcCal1Sim* cal; HEDMdcWire* edmdcwire; Int_t s,m,l,c; Int_t size = mdcCal1Cat->getEntries(); wires->fill(); // make wire usage statistics for this event for(Int_t i = 0; i < size; i ++){ cal = HCategoryManager::getObject(cal,mdcCal1Cat,i); if(cal){ cal->getAddress(s,m,l,c); Int_t ntimes = wires->isUsedNtimes(s,m,l,c); if(ntimes >= 0) { edmdcwire = new HEDMdcWire(cal); if(ntimes == 0) edmdcwire ->SetLineColor(kRed-2); // unused by segment fitter if(ntimes == 1) edmdcwire ->SetLineColor(kBlue); // unique wire if(ntimes > 1 ) edmdcwire ->SetLineColor(kMagenta); // multiple used allMdcWires->AddElement(s,m,edmdcwire); } } } } //--------------------------------------------------------- //--------------------------------------------------------- if(drawParticleCand && particleCandCat){ HParticleCandSim* cand; Int_t size = particleCandCat->getEntries(); for(Int_t i = 0; i < size; i ++){ cand = HCategoryManager::getObject(cand,particleCandCat,i); if(cand){ HEDParticleCand* edcand = 0; Int_t s = cand->getSector(); // Fill all objects. Group them into different lists // Groups get different colors. //--------------------------------------------------------- // Candidates with matched Ring (wide window), // but not accepted as lepton by HParticleTrackSorter // Includes incomplete tracks (eg. no outer MDC or META) if(cand->getRichInd() >= 0 && !cand->isFlagBit(kIsLepton)){ edcand = new HEDParticleCand(cand); edcand->SetLineColor(kMagenta); particlecandNoLep->AddElement(s,edcand); } //--------------------------------------------------------- //--------------------------------------------------------- // Candidates accepted as leptons by HParticleTrackSorter // Full tracks with RICH and accepted after sorting if(cand->isFlagBit(kIsLepton)){ edcand = new HEDParticleCand(cand); edcand->SetLineColor(kRed); particlecandLep->AddElement(s,edcand); } //--------------------------------------------------------- // Candidates accepted by HParticleTrackSorter // which do not belong to the groups above // Full tracks, no incomlete tracks here if(!cand->isFlagBit(kIsLepton) && !(cand->getRichInd() >= 0 && !cand->isFlagBit(kIsLepton)) && cand->isFlagBit(kIsUsed)){ edcand = new HEDParticleCand(cand); // selcted no rings edcand->SetLineColor(kGreen); particlecandHad->AddElement(s,edcand); } //--------------------------------------------------------- //--------------------------------------------------------- // Ghost tracks get dshed lines if(edcand && cand->isGhostTrack()) edcand->SetLineStyle(7); //--------------------------------------------------------- } } // end loop particlecand } // end particlecand //--------------------------------------------------------- cout<<"-----------------------------------------------------------------"<getEntries() <<" RICH HITS " <getEntries() <<" MDC SEGMENTS "<getEntries() <<" TOF HITS " <getEntries() <<" TOF CLUSTER " <getEntries() <<" RPC CLUSTER " <getEntries()<<" SHOWER HITS " <