コード例 #1
0
ファイル: WriteStiEvents.C プロジェクト: star-bnl/star-sti
void WriteStiEvents(Int_t nevents=1,
	            const Char_t *Mainfile = "/star/data22/ITTF/EvalData/MCFiles/auau200/rcf0183_12_300evts.geant.root",
		    const Char_t *outfile= "test.event.root",
		    bool simulated = true)
{

    gSystem->Load("St_base");
    gSystem->Load("StChain");
    gSystem->Load("StUtilities");
    gSystem->Load("St_Tables");
    gSystem->Load("StarClassLibrary");

    gSystem->Load("StIOMaker");
    gSystem->Load("StEvent");
    gSystem->Load("StEmcUtil"); 
    gSystem->Load("StMcEvent");
    gSystem->Load("StMcEventMaker");
    gSystem->Load("StAssociationMaker");

    gSystem->Load("St_db_Maker");
    gSystem->Load("StDbLib");
    gSystem->Load("StDbBroker");
    gSystem->Load("StDbUtilities");
    gSystem->Load("StTpcDb");
    gSystem->Load("StDetectorDbMaker");
    gSystem->Load("StTreeMaker");
    gSystem->Load("StSvtClassLibrary");
    gSystem->Load("StSvtDbMaker");

    gSystem->Load("Sti");
    gSystem->Load("libGui");
    gSystem->Load("StiGui");
//     gSystem->Load("StiEvaluator");
    gSystem->Load("StiMaker");

    chain  = new StChain("StChain");
    StIOMaker *IOMk = new StIOMaker("IO","r",Mainfile); 
    IOMk->SetBranch("*",0,"0");	//deactivate all branches
    //IOMk->SetBranch("dstBranch",0,"r");
    //IOMk->SetBranch("runcoBranch",0,"r");
    IOMk->SetBranch("eventBranch",0,"r");
    IOMk->SetBranch("geantBranch",0,"r");

    dbaseMk = new St_db_Maker("db","MySQL:StarDb","$STAR/StarDb");
    if (simulated) dbaseMk-> SetDateTime(20010801,000000);  
    tpcDbMk  = new StTpcDbMaker("tpcDb");
    svtDbMk  = new StSvtDbMaker("svtDb");
    detDbMk = new StDetectorDbMaker("detDb");


    bool doFit = false;
    bool optimized = false;

    StiMaker* anaMk = StiMaker::instance();
    StiRootIOBroker* stiIO = anaMk->getIOBroker();//StiRootIOBroker::instance();
    stiIO->setTPHFMinPadrow(1);
    stiIO->setTPHFMaxPadrow(45);
    stiIO->setETSFLowerBound(5);
    stiIO->setETSFMaxHits(6);
  
    stiIO->setDoTrackFit(doFit);
  
    //Set Kalman Track Finder (KTF) run-time values:
    stiIO->setKTFMcsCalculated(false);
    stiIO->setKTFElossCalculated(false);
    stiIO->setKTFMaxChi2ForSelection(50);
    stiIO->setKTFBField(.5); //Tesla
    stiIO->setKTFMassHypothesis(.1395); //GeV
    stiIO->setKTFMinContiguousHitCount(2);
    stiIO->setKTFMaxNullCount(40);
    stiIO->setKTFMaxContiguousNullCount(25);
    stiIO->setKTFMinSearchRadius(.5); //cm
    stiIO->setKTFMaxSearchRadius(4.); //cm
    stiIO->setKTFSearchWindowScale(5.); //cm
  
    //Set Local Track Seed Finder (LTSF) run-time values
    stiIO->setLTSFZWindow(5.);
    stiIO->setLTSFYWindow(2.);
    stiIO->setLTSFSeedLength(2);
  
    stiIO->setLTSFDoHelixFit(true);
    stiIO->setLTSFExtrapYWindow(1.);
    stiIO->setLTSFExtrapZWindow(2.);
    stiIO->setLTSFExtrapMaxSkipped(2);
    stiIO->setLTSFExtrapMinLength(4);
    stiIO->setLTSFExtrapMaxLength(5);
    stiIO->setLTSFUseVertex(true);
  
    stiIO->setLTMDeltaR(1.); //10% in r
  
    //Add sectors:
    for (unsigned int sector=1; sector<=12; ++sector) {
	stiIO->addLTSFSector(sector);
    }
    //Add padrows;
    //for (unsigned int padrow=1; padrow<=45; ++padrow) {
    for (unsigned int padrow=6; padrow<=45; padrow+=1) {
	stiIO->addLTSFPadrow(padrow);
    }
    
    //This line has to match the corresponding enumeration in StiIOBroker.h
    enum SeedFinderType {kUndefined=0, kComposite=1, kEvaluable=2};
    //stiIO->setSeedFinderType(kEvaluable);
    stiIO->setSeedFinderType(kComposite);

    //Set up the track filter (this mas to macth the correspoinding enumeration in StiIOBroker.h)
    enum FilterType {kPtFilter=0, kEtaFilter=1, kChi2Filter=2, kNptsFilter=3, kNFitPtsFilter=4,
		     kNGapsFilter=5, kFitPointRatioFilter=6, kPrimaryDcaFilter=7};
    
    stiIO->addFilterType(kPtFilter);
    stiIO->setFilterPtMin(.1); //GeV
    stiIO->setFilterPtMax(50.); //GeV

    stiIO->addFilterType(kEtaFilter);
    stiIO->setFilterEtaMin(-2.);
    stiIO->setFilterEtaMax(2.);

    stiIO->addFilterType(kChi2Filter);
    stiIO->setFilterChi2Max(10.);

    stiIO->addFilterType(kNptsFilter);
    stiIO->setFilterNptsMin(8);

    stiIO->addFilterType(kNFitPtsFilter);
    stiIO->setFilterNFitPtsMin(5);

    stiIO->addFilterType(kNGapsFilter);
    stiIO->setFilterNGapsMax(20);

    stiIO->addFilterType(kPrimaryDcaFilter);
    stiIO->setFilterPrimaryDcaMax(100.);
        
    if (!simulated) stiIO->setSimulated(false);

    if (simulated){
       StMcEventMaker* mcEventReader = mcEventReader = new StMcEventMaker();
       mcEventReader->doUseFtpc = kFALSE;
       mcEventReader->doUseRich = kFALSE;
       mcEventReader->doUseBemc = kFALSE;
       mcEventReader->doUseBsmd = kFALSE;
    }
    cout << "!!!! doEvents: will write out .event.root file !!" << endl << endl;
    StTreeMaker *outMk = new StTreeMaker("EvOut","","bfcTree");
    outMk->SetIOMode("w");
    outMk->SetBranch("eventBranch",outfile,"w");
    outMk->IntoBranch("eventBranch","StEvent");

    if (simulated) StAssociationMaker*	assocMakerIt = new StAssociationMaker();
    if (simulated) assocMakerIt->useInTracker();
    //assocMakerIt->SetDebug();

    chain->PrintInfo();

    Int_t iInit = chain->Init();
    if (iInit) chain->Fatal(iInit,"on init");
    chain->InitRun(0);
    
    //
    // Event loop
    //
    int istat=0,i=1;
 EventLoop: if (i <= nevents && istat!=2) {

     cout << endl << "============================ Event " << i
	  << " start ============================" << endl;

     chain->Clear();
     istat = chain->Make(i);

     if (istat==2) 
         {cout << "Last  event processed. Status = " << istat << endl;}
     if (istat==3) 
         {cout << "Error event processed. Status = " << istat << endl;}

     
     
     i++;
     goto EventLoop;
 }
    i--;
    cout << endl << "============================ Event " << i
	 << " finish ============================" << endl;

    return;
}
コード例 #2
0
ファイル: StAssociator.C プロジェクト: star-bnl/star-macros
void StAssociator(Int_t nevents=1,
const char *MainFile="/afs/rhic.bnl.gov/star/data/samples/*.geant.root")
{

  // Dynamically link needed shared libs
  gSystem->Load("St_base");
  gSystem->Load("StChain");
  gSystem->Load("StBFChain");

  gSystem->Load("St_Tables");
  gSystem->Load("StUtilities");
  gSystem->Load("StIOMaker");
  gSystem->Load("StarClassLibrary");
  gSystem->Load("StDetectorDbMaker");


  gSystem->Load("StTpcDb");
  gSystem->Load("StEvent");
//   gSystem->Load("StEventMaker"); //not needed if event.root branch present
  gSystem->Load("StEmcUtil"); 
  gSystem->Load("StEEmcUtil");
  
  gSystem->Load("StMcEvent");
  gSystem->Load("StMcEventMaker");
  gSystem->Load("StAssociationMaker");
  gSystem->Load("StMcAnalysisMaker");
    
  chain = new StChain("StChain"); 
  chain->SetDebug();
   
  // Now we add Makers to the chain...

  StIOMaker* ioMaker = new StIOMaker("IO","r",MainFile,"bfcTree");
  ioMaker->SetDebug();
  ioMaker->SetIOMode("r");
  ioMaker->SetBranch("*",0,"0");                 //deactivate all branches
  ioMaker->SetBranch("geantBranch",0,"r"); //activate geant Branch
  ioMaker->SetBranch("eventBranch",0,"r"); //activate geant Branch
//   ioMaker->SetBranch("dstBranch",0,"r"); //activate Event Branch
//   ioMaker->SetBranch("runcoBranch",0,"r"); //activate runco Branch

  // Note, the title "events" is used in the Association Maker, so don't change it.
  // StEventMaker is not needed for event.root files
//   StEventMaker*       eventReader   = new StEventMaker("events","title");
//   eventReader->doPrintMemoryInfo = kFALSE;
  StMcEventMaker*     mcEventReader = new StMcEventMaker; // Make an instance...
  StAssociationMaker* associator    = new StAssociationMaker;

  // If you need to use L3 TRIGGER uncomment the line:
  // associator->useL3Trigger();
  //associator->SetDebug();
  // For tracks created with the Sti package (ITTF), uncomment the next line:
  //associator->useInTracker();
  // Switch to use the distance or id association.
  associator->useDistanceAssoc();
  //associator->useIdAssoc();
  // Note: useDistanceAssoc and useIdAssoc are mutually exclusive
  // and they set and unset the same flag.
  // The flag will be set by the call done at the end.
  //associator->doPrintMemoryInfo = kTRUE;
  StMcAnalysisMaker*  examples      = new StMcAnalysisMaker;

  // Define the cuts for the Associations

  StMcParameterDB* parameterDB = StMcParameterDB::instance();  
  // TPC
  parameterDB->setXCutTpc(.6); // 6 mm
  parameterDB->setYCutTpc(.6); // 6 mm
  parameterDB->setZCutTpc(.6); // 6 mm
  parameterDB->setReqCommonHitsTpc(3); // Require 3 hits in common for tracks to be associated
  // FTPC
  parameterDB->setRCutFtpc(.3); // 3 mm
  parameterDB->setPhiCutFtpc(5*(3.1415927/180.0)); // 5 degrees
  parameterDB->setReqCommonHitsFtpc(3); // Require 3 hits in common for tracks to be associated
  // SVT
  parameterDB->setXCutSvt(.08); // 800 um
  parameterDB->setYCutSvt(.08); // 800 um
  parameterDB->setZCutSvt(.08); // 800 um
  parameterDB->setReqCommonHitsSvt(1); // Require 1 hits in common for tracks to be associated
    
    
  // now execute the chain member functions

  chain->PrintInfo();
  Int_t initStat = chain->Init(); // This should call the Init() method in ALL makers
  if (initStat) chain->Fatal(initStat, "during Init()");
    
  int istat=0,iev=1;
 EventLoop: if (iev<=nevents && istat!=2) {
   chain->Clear();
   cout << "---------------------- Processing Event : " << iev << " ----------------------" << endl;
   istat = chain->Make(iev); // This should call the Make() method in ALL makers
   if (istat == 2) { cout << "Last  Event Processed. Status = " << istat << endl; }
   if (istat == 3) { cout << "Error Event Processed. Status = " << istat << endl; }
   iev++; goto EventLoop;
 } // Event Loop
  examples->mAssociationCanvas = new TCanvas("mAssociationCanvas", "Histograms",200,10,600,600);
  TCanvas* myCanvas = examples->mAssociationCanvas;
  myCanvas->Divide(2,2);
  
  myCanvas->cd(1);
  gPad->SetLogy(0);
  examples->mTrackNtuple->Draw("(p-prec)/p:commTpcHits","prec!=0");

  TList* dList = chain->GetMaker("StMcAnalysisMaker")->Histograms();
  TH2F* hitRes = dList->At(0);
  TH1F* momRes = dList->At(1);
  TH2F* coordRc = dList->At(2);
  TH2F* coordMc = dList->At(3);
    
  myCanvas->cd(2);
  gPad->SetLogy(0);
  hitRes->Draw("box");
  
  myCanvas->cd(3);
  gPad->SetLogy(0);
  momRes->Draw();
  
  myCanvas->cd(4);
  gPad->SetLogy(0);
  coordRc->SetMarkerStyle(20);
  coordRc->Draw();
    
  myCanvas->cd(4);
  gPad->SetLogy(0);
  coordMc->SetMarkerColor(2);
  coordMc->SetMarkerStyle(20);
  coordMc->Draw("same");
  
  if(iev>200) chain->Finish(); // This should call the Finish() method in ALL makers,
  // comment it out if you want to keep the objects
  // available at the command line after running
  // the macro.

  // To look at the ntuple after the macro has executed:
  // f1 = new TFile("TrackMapNtuple.root");  //This opens the file, and loads the Ntuple
  // TrackNtuple->Draw("px:pxrec")  //Once loaded, the Ntuple is available by name.
  // To look at the Histograms once the Macro has executed:
  // TList* dList = chain->GetMaker("McAnalysis")->Histograms();
  // TH2F* hitRes = dList->At(0);  //or whatever index from 0 to 3
}
コード例 #3
0
void makePicoDst(const Int_t runnumber=999999,
                 const Char_t *inputFile="/star/institutions/lbl_prod/mlomnitz/SSD_Simu/StEvent/hijing_**.MuDst.root",
                 const Char_t *inputGeant="/star/institutions/lbl_prod/mlomnitz/SSD_Simu/StEvent/hijing_**.McEvent.root",
                 TString outfilename="out",
                 const bool creatingPhiWgt = kFALSE, const int prodMod = 0, const int emcMode=0,
                 const bool createMcBranch = kTRUE
                 
                 ){
    Int_t nEvents = 10000000;
    //Int_t nEvents = 50;
    //Load all the System libraries
    cout<<inputFile<<endl;
    gSystem->Load("libTable");
    gSystem->Load("libPhysics");
    gSystem->Load("St_base");
    gSystem->Load("StChain");
    gSystem->Load("St_Tables");
    gSystem->Load("StUtilities");        // new addition 22jul99
    gSystem->Load("StTreeMaker");
    gSystem->Load("StIOMaker");
    gSystem->Load("StarClassLibrary");
    gSystem->Load("StTriggerDataMaker"); // new starting from April 2003
    gSystem->Load("StBichsel");
    gSystem->Load("StEvent");
    gSystem->Load("StEventUtilities");
    gSystem->Load("StDbLib");
    gSystem->Load("StEmcUtil");
    gSystem->Load("StTofUtil");
    gSystem->Load("StPmdUtil");
    gSystem->Load("StPreEclMaker");
    gSystem->Load("StStrangeMuDstMaker");
    gSystem->Load("StMuDSTMaker");
    if( createMcBranch){
        gSystem->Load("StMcEvent");
        gSystem->Load("StAssociationMaker");
    }
    if(!creatingPhiWgt&&emcMode) {
        gSystem->Load("StTpcDb");
        gSystem->Load("StMcEvent");
        gSystem->Load("StMcEventMaker");
        gSystem->Load("StDaqLib");
        gSystem->Load("libgen_Tables");
        gSystem->Load("libsim_Tables");
        gSystem->Load("libglobal_Tables");
        gSystem->Load("StEmcTriggerMaker");
        gSystem->Load("StEmcUtil");//mine
        gSystem->Load("StEmcRawMaker");
        gSystem->Load("StEmcADCtoEMaker");
        gSystem->Load("StPreEclMaker");
        gSystem->Load("StEpcMaker");
        gSystem->Load("StEmcSimulatorMaker");
        gSystem->Load("StEmcUtil");
        gSystem->Load("StDbBroker");
        gSystem->Load("StDetectorDbMaker");
        gSystem->Load("StDbUtilities");
        gSystem->Load("StEEmcUtil");
        gSystem->Load("StEEmcDbMaker");
        gSystem->Load("St_db_Maker");
        gSystem->Load("StTriggerUtilities");
    }
    
    gSystem->Load("StPicoDstMaker");
    
    chain = new StChain();
    if( createMcBranch ){
        StIOMaker* ioMaker = new StIOMaker("IO","r",inputGeant,"bfcTree");
        ioMaker->SetDebug();
        ioMaker->SetIOMode("r");
        ioMaker->SetBranch("*",0,"0");                 //deactivate all branches
        //ioMaker->SetBranch("geantBranch",0,"r"); //activate geant Branch
        ioMaker->SetBranch("McEventBranch",0,"r"); //activate geant Branch
        ioMaker->SetBranch("eventBranch",0,"r"); //activate geant Branch
        StAssociationMaker* associator    = new StAssociationMaker;
        cout<<"created new StAssociationMaker"<<endl;
        associator->useInTracker();
    }
    
    StMuDstMaker *MuDstMaker = new StMuDstMaker(0,0,"",inputFile,"MuDst",100);
    MuDstMaker->SetStatus("*",0);
    MuDstMaker->SetStatus("MuEvent",1);
    MuDstMaker->SetStatus("PrimaryVertices",1);
    MuDstMaker->SetStatus("PrimaryTracks",1);
    MuDstMaker->SetStatus("GlobalTracks",1);
    MuDstMaker->SetStatus("CovGlobTrack",1);
    //MuDstMaker->SetStatus("BTof*",1);
    //MuDstMaker->SetStatus("Emc*",1);
    
    if(!creatingPhiWgt&&emcMode) {
        St_db_Maker *dbMk = new St_db_Maker("db","MySQL:StarDb","$STAR/StarDb","StarDb");
        
        // Endcap database
        StEEmcDbMaker* eemcDb = new StEEmcDbMaker;
        
        StEmcADCtoEMaker *adc2e = new StEmcADCtoEMaker();
        adc2e->setPrint(false);
        //adc2e->setFillHisto(false);
        //adc2e->setDebug(false); //more histograms
        //adc2e->setSMDRmsCut(0,0);
        adc2e->saveAllStEvent(true);
        //adc2e->setRemoveGhostEvent(false);
        //adc2e->setTallyHist(mTally);
        //adc2e->setDbName("Calibrations/emc/y3");
        
        StPreEclMaker *pre_ecl=new StPreEclMaker();
        pre_ecl->setPrint(kFALSE);
        StEpcMaker *epc=new StEpcMaker();
        epc->setPrint(kFALSE);
        
#if 1
        // Trigger simulator
        StTriggerSimuMaker* trigSimu = new StTriggerSimuMaker;
        trigSimu->setMC(false);
        trigSimu->useBemc();
        trigSimu->useEemc();
        trigSimu->useOnlineDB();
        
        trigSimu->bemc->setConfig(StBemcTriggerSimu::kOffline);
#endif
        
    }
    
    StPicoDstMaker *picoMaker = new StPicoDstMaker(1,Form("st_%i.picoDst.root",runnumber),"picoDst");
    picoMaker->setRunNumber(runnumber);
    picoMaker->setEmcMode(emcMode); // 0-No EMC, 1-EMC ON
    picoMaker->setMcMode(createMcBranch);
    
    
    chain->Init();
    cout<<"chain->Init();"<<endl;
    int total = 0;
    cout<<MuDstMaker->chain()->GetEntries()<<endl;
    if( nEvents > MuDstMaker->chain()->GetEntries() )
    nEvents=MuDstMaker->chain()->GetEntries();
    for (Int_t i=0; i<nEvents; i++){
        if(i%100==0)
        cout << "Working on eventNumber " << i << endl;
        
        chain->Clear();
        int iret = chain->Make(i);
        
        if (iret) { cout << "Bad return code!" << iret << endl; break;}
        
        total++;
        
    }
    
    cout << "****************************************** " << endl;
    cout << "Work done... now its time to close up shop!"<< endl;
    cout << "****************************************** " << endl;
    chain->Finish();
    cout << "****************************************** " << endl;
    cout << "total number of events  " << total << endl;
    cout << "****************************************** " << endl;
    
    delete chain;
    
    
}
コード例 #4
0
ファイル: run_StMcAccpMaker.C プロジェクト: XiaozhiBai/Run12
void run_StMcAccpMaker(const char* file, const char* outfile) 
{
    //Check STAR Library. Please set SL_version to the original star library used 
    // in the production from http://www.star.bnl.gov/devcgi/dbProdOptionRetrv.pl
    string SL_version = "SL12d_embed";
    string env_SL = getenv("STAR");
    if (env_SL.find(SL_version) == string::npos) {
        cout << "Environment Star Library does not match the requested library in run_st_etree.C. Exiting..." << endl;
        return;
    }
    // Load shared libraries
    Load();

    // Create chain
    StChain* chain = new StChain;

    // I/O maker
    StIOMaker* ioMaker = new StIOMaker;
    ioMaker->SetFile(file);
    ioMaker->SetIOMode("r");
    ioMaker->SetBranch("*", 0, "0");
    //ioMaker->SetBranch("McEventBranch",0,"r"); 
    ioMaker->SetBranch("geantBranch", 0, "r");
    ioMaker->SetBranch("eventBranch", 0, "r");

    TString mudstfile = file;
    mudstfile.ReplaceAll(".event.root",".MuDst.root");
    mudstfile.ReplaceAll(".geant.root",".MuDst.root");
    StMuDstMaker* muDstMaker = new StMuDstMaker(0,0,"",mudstfile.Data(),"",100000,"MuDst");

    StMcEventMaker *mcEventMaker = new StMcEventMaker();
    mcEventMaker->doPrintEventInfo = false;
    mcEventMaker->doPrintMemoryInfo = false;

    StAssociationMaker* assoc = new StAssociationMaker;
    assoc->useInTracker();

    //.. see example in CVS: StRoot/macros/mudst/exampleEmc.C
    // Need St_db_Maker for Emc calibration
    St_db_Maker* dbMk = new St_db_Maker("StarDb", "MySQL:StarDb");
    //dbMk->SetMaxEntryTime(20100301,0);
    //dbMk->SetDateTime(20080101,000001);

    StEEmcDbMaker* eemcDb = new StEEmcDbMaker;
    StEmcADCtoEMaker *adc_to_e = new StEmcADCtoEMaker();
    adc_to_e->saveAllStEvent(kTRUE);

    StEmcSimulatorMaker* emcSim = new StEmcSimulatorMaker(); //use this instead to "redo" converstion from geant->adc
    // Makers for clusterfinding
    StPreEclMaker *pre_ecl = new StPreEclMaker();
    pre_ecl->setPrint(kFALSE);
    StEpcMaker *epc = new StEpcMaker();
    epc->setPrint(kFALSE);

    StTriggerSimuMaker* simuTrig = new StTriggerSimuMaker();
    simuTrig->useOfflineDB();

    simuTrig->setMC(2); // 0=data, 1=simulation, 2=embedding
    simuTrig->useBemc();
    simuTrig->useEemc();
    simuTrig->bemc->setConfig(2); // Online==1, Offline==2, Expert==3
    //   simuTrig->bemc->setConfig(StBemcTriggerSimu::kOffline); 
    int col_energy = 200; //.. option: 200, 62, 39
    // std::vector<unsigned int> triggers;
    // triggers.push_back(370542); //
    // triggers.push_back(370522); //

    
    // Monte Carlo event maker
    StMcAccpMaker* analysis = new StMcAccpMaker(simuTrig,outfile,col_energy);//,triggers);

    // Initialize chain
    chain->Init();
    chain->EventLoop(1000000);
    chain->Finish();

    //delete chain;
}