#include "dreco.h" #include "PHNodeIterator.h" #include "RunToTimeObjy.hh" #include "dMuiRoadsWrapper.h" #include "dMuiRoadRawRelWrapper.h" #include "dMutCalibCathodesWrapper.h" #include "PHIODataNode.h" #include "PHDataNode.h" #include "PhHistogramFactory.hh" #include "PHVector.h" #include "Lvl2Event.h" #include "Lvl2DecisionOutv1.h" #include "EventHeaderv1.h" #include "dMuoTracksWrapper.h" #include "dMuoTrackRoadRelWrapper.h" #include "dMuiRawWrapper.h" // Display #include "PhenixRun.hh" #include "PhEventDisplay.hh" #include "PhMuiDisplay.hh" #include "PhCanvas.hh" #include "mMuiInitModule.h" // Level2 includes #include "L2MuiTracks.h" //This Must come after event display includes #include "L2BbcZdcCentrality.h" #include "dMuiClustersWrapper.h" #include "dMuiRoadClusterRelWrapper.h" // MicroDst #include "TFile.h" #include "TNtuple.h" // Refit #include "mMuoRecoModule.h" #include "mfm_setfscale.h" #include "mfm_getfscale.h" #include "TriggerHelper.h" EventHeader* eventheader = NULL; // Event Display bool first_event = true; bool use_embedding = false; // Refit PHCompositeNode* motherNode; mMuoRecoModule* mMuoReco = 0; PHNodeIOManager *dstOut = 0; //Embedding variables PHNodeIOManager *dst2IOManager; PHCompositeNode* dst2Node; int mergeMui(PHCompositeNode* mainNode, PHCompositeNode* embedNode); int mergeMut(PHCompositeNode* mainNode, PHCompositeNode* embedNode); // MicroDst int nevt; TFile* microdst; TNtuple* Dimuons; TNtuple* SingleMus; int totalRefit = 0; int totalOnDst = 0; int totalProcessed = 0; int RefitFlag = 1; bool simulationFlag = false; int dinit(){ cout<SetCompressionLevel(3); return 0; } int close_all() { mMuoReco->end(motherNode); delete dstOut; } int setup_all() { nevt = 0; return 0; } int process_event(PHCompositeNode* topNode) { nevt++; TriggerHelper fTrigHelper(topNode); //Process only minbias events //if(!fTrigHelper.IsEventMinBias()) //{ // cout<<"Skipping non-minbias event!\n"; // return 0; //} if(first_event){ if (RefitFlag){ //Refind and fit muon tracks setup_refit(topNode); } // Print once the dst contents topNode->print(); first_event = false; } // user Analysis Modules if (RefitFlag){ //Refind and fit muon tracks ana_refit(motherNode); } if (RefitFlag && dstOut){ //Write out new dst information dstOut->write(topNode); } return 0; } //-------------------------------------------------------------------- REFIT CODE int setup_refit(PHCompositeNode* topNode) { // Create a mother node to fake the reconstruction structure motherNode = new PHCompositeNode("TOP"); PHNodeIterator* mainIter = new PHNodeIterator(motherNode); PHCompositeNode* muiNode = new PHCompositeNode("MUI"); motherNode->addNode(muiNode); PHCompositeNode* mutNode = new PHCompositeNode("MUT"); motherNode->addNode(mutNode); // PHCompositeNode* prdfNode = new PHCompositeNode("PRDF"); // motherNode->addNode(prdfNode); PHCompositeNode* evaNode = new PHCompositeNode("EVA"); motherNode->addNode(evaNode); PHCompositeNode* parNode = new PHCompositeNode("PAR"); motherNode->addNode(parNode); // Add the topNode aka the dst node to the mother node motherNode->addNode(topNode); //Another DST node for embedding //Should not be added to the motherNode dst2Node = new PHCompositeNode("DST"); // Specify a new dst file: PHNodeIOManager *dstOut = 0; mMuoReco = new mMuoRecoModule; mMuoReco->first_event(motherNode); // Read the 2nd dst file if(use_embedding) { // Open the geant evaluation file in an elegant way dst2IOManager = new PHNodeIOManager("dstin2.root", PHReadOnly); if (dst2IOManager==0) { cout << "File 2nd Dst for embedding needed for embedding not exist" << endl; cout << "Embedding will not be performed!!!\n"; use_embedding = false; } } } int ana_refit(PHCompositeNode *topNode) { int TrackonDst = 0; int TrackRefit = 0; int RoadonDst = 0; int RoadRefit = 0; PHIODataNode::iterator dMuoTracks(topNode); if(dMuoTracks.find("dMuoTracks")==0) { cout<<"dMuoTracks Not Found.\n"; } PHIODataNode::iterator dMuiRoads(topNode); if(dMuiRoads.find("dMuiRoads")==0) { cout<<"dMuiRoads Not Found.\n"; } if(use_embedding) { //Read in the file dst2IOManager->read(dst2Node); mMuoReco->event_embed(topNode, dst2Node); mMuoReco->event_cluster(topNode); } TrackonDst = (*dMuoTracks).RowCount(); RoadonDst = (*dMuiRoads).RowCount(); totalOnDst += RoadonDst; totalProcessed++; mMuoReco->event_reco(topNode); TrackRefit = (*dMuoTracks).RowCount(); RoadRefit = (*dMuiRoads).RowCount(); totalRefit+= RoadRefit; if ( (TrackonDst+TrackRefit) > 0 || (RoadonDst+RoadRefit) > 0) cout << "Tracks ondst / refit : " << TrackonDst << " / " << TrackRefit << " Roads " << RoadonDst << "/" << RoadRefit << endl; } //------------------------------------------------------------------ DISPLAY CODE int setup_display(PHCompositeNode* topNode) { mMuiInitModule mMuiInit; PHTimeStamp t_search(2001,8,8,0,0,0); mMuiInit.SetSearchTimeStamp(t_search); mMuiInit.event(topNode); PhenixRun* phenix = new PhenixRun("Phenix-Run","Phenix-Run", topNode); gPhenix->GetDisplay()->AddSubsystem(new PhMuiDisplay("Mui-Display","Mui-Display")); gPhenix->StartRun(); PhEventDisplay* dmuon = new PhEventDisplay("Main",gClient->GetRoot(),1000,1000,gPhenix->GetDisplay()->GetList()); PhCanvas* can = (PhCanvas*)(dmuon->GetCanvas()); can->DefaultRange(-800,-800,-800,800,800,800);//in cm dmuon->Popup(); can->ResetRange(); return 0; } int ana_display(PHCompositeNode* topNode) { gPhenix->event(topNode); gPhenix->Draw(); return 0; }