void exampleStMuIOMaker(const char* file="/star/data14/reco/productionCentral/ReversedFullField/P02ge/2001/324/st_physics_2324001_raw_0006.MuDst.root") { gROOT->LoadMacro("$STAR/StRoot/StMuDSTMaker/COMMON/macros/loadSharedLibraries.C"); loadSharedLibraries(); StMuDebug::setLevel(0); int counter=0; int iret=0; StMuIOMaker* maker = new StMuIOMaker("MuDst"); maker->SetFileAndOpen(file); // maker->SetFileName("st_physics_2313018_raw_0029.MuDst.root"); TMemStat memStat("exampleMuIO"); StMuDst* mu; // evtid is an unique id of an event in a run which may involve several files! // it is different from sequential index in a run which starts from "0"! // for ( int evtid=80673; evtid<80694; evtid++) { // for ( int evtid=6300; evtid<6321; evtid++) { // iret = maker->Make( StUKey(2271008,evtid) ); // iret = maker->Make( StUKey(2313018,evtid) ); // alterative for ( int i=0; i<20; i++) { // iret = maker->Make(); // read an event in natural sequential iret = maker->Make(i); // read an event with seqential index if ( iret == kStOK) { StMuDst* mu = maker->muDst(); if ( !mu ) continue; // if(i%10 != 0) continue; // take a look at branches of tracks int n; n= mu->globalTracks()->GetEntries(); for (int l=0; l<n; l++) globalPt.Fill(mu->globalTracks(l)->pt()); n= mu->primaryTracks()->GetEntries(); for (int l=0; l<n; l++) primaryPt.Fill(mu->primaryTracks(l)->pt()); n= mu->l3Tracks()->GetEntries(); for (int l=0; l<n; l++) {l3Pt.Fill( mu->l3Tracks(l)->pt() );} // take a look at event branch StMuEvent* muEvent = mu->event(); int referenceMultiplicity = muEvent->refMult(); refMult.Fill(referenceMultiplicity); cout << "#" << i << " index=" << maker->currentIndex() // cout << "eventId =" << evtid << " index=" << maker->currentIndex() << " refmult= "<< referenceMultiplicity << " used= "<< memStat.Used() << " size= "<< memStat.ProgSize() << endl; counter++; } } cout << " # of events:" << counter << endl; globalPt.Draw(); primaryPt.Draw("same"); l3Pt.Draw("same"); TFile f("testMuIO.root","RECREATE"); globalPt.Write(); primaryPt.Write(); l3Pt.Write(); refMult.Write(); f.Close(); }
void dlMudst(/*string fileList*/){ string fileList = "./xml/schedB57622DD24C1A0ECDF3F996978585EA7_4.list"; // string fileList = "./xml/testlist.list"; gROOT->Macro("/star/u/klandry/ucladisk/2012IFF/StRoot/LoadLibs.C"); gROOT->LoadMacro("$STAR/StRoot/StMuDSTMaker/COMMON/macros/loadSharedLibraries.C"); loadSharedLibraries(); gSystem->Load("StarMagField"); gSystem->Load("StMagF"); gSystem->Load("StTpcDb"); // gSystem->Load("StDbUtilities"); gSystem->Load("StDaqLib"); gSystem->Load("StDbBroker"); gSystem->Load("StDetectorDbMaker"); gSystem->Load("StDbUtilities"); gSystem->Load("St_db_Maker"); gSystem->Load("StEvent"); gSystem->Load("StEventMaker"); gSystem->Load("StarMagField"); gSystem->Load("StTofUtil"); gSystem->Load("StTofMaker"); //gSystem->Load("libtpc_Tables"); gSystem->Load("libGeom"); gSystem->Load("St_g2t"); gSystem->Load("geometry"); gSystem->Load("St_geant_Maker"); gSystem->Load("StTofMuDstReader"); TFile* outfile = new TFile("/star/u/klandry/ucladisk/2012IFF/2012Mudstshort.root","Recreate"); char* outputname = "testout.root"; StChain* muChain = new StChain(); StMuDstMaker* muDstMaker = new StMuDstMaker(0,0,"",fileList.c_str(),"",100000,"MuDst"); muDstMaker->SetStatus("BTofHeader",1) ; // Turn on the global track data muDstMaker->SetStatus("TofRawData",1); muDstMaker->SetStatus("TofData",1); muDstMaker->SetStatus("TofHit",1); //StTofMuDstReader *tofMaker = new StTofMuDstReader("tofMaker",outputname,muDstMaker); StMuDst* muDst; TTree* tree = new TTree("mudst","mudst"); tree->Branch("muDst", &muDst); TH1D* hSigmaPiontof = new TH1D("tofsigmapion","tofsigmapion",100,-10,10); TH1D* hSigmaPiontpc = new TH1D("tpcsigmapion","tpcsigmapion",100,-10,10); int iEvent = 0; while (muChain->Make(iEvent) == kStOK) { muDst = muDstMaker->muDst(); cout << "number of TOF Hits " << muDst->numberOfTofHit() << endl; for (int iHit=0; iHit<muDst->numberOfTofHit(); iHit++) { StMuTofHit *tof = (StMuTofHit*)muDst->tofHit(iHit); //StMuBTofHit* bTofHit = muDst->btofHit(iHit); if (!muDst->tofHit(iHit)) { cout << "jdflksfjldsfjlsdjf" << endl; } //hSigmaPiontof->Fill(tofHit->sigmaPion()); //cout << "tofFilled" << endl; } for (int iTrack=0; iTrack<muDst->numberOfPrimaryTracks(); iTrack++) { StMuTrack* track = muDst->primaryTracks(iTrack); hSigmaPiontpc->Fill(track->nSigmaPion()); //cout << "tpcFilled" << endl; } //cout << muDstMaker->muDst()->event()->runId() << endl; //cout << muDst->event()->runId() << endl; tree->Fill(); iEvent++; if (iEvent%1000 == 0) { cout << iEvent << endl; //cout << muDst->event->runId() << endl; } if (iEvent == 1000){break;} } tree->Write(); hSigmaPiontof->Write(); hSigmaPiontpc->Write(); outfile->Write(); }