Esempio n. 1
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;
    
    
}
Esempio n. 2
0
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;
}
void bfcread_hist_extract(
  const Char_t *MainFile=
    "/afs/rhic.bnl.gov/star/data/samples/gstar.hist.root",
  const Char_t *MakerHistDir="EventQA",
  const Char_t *TopDirTree="bfcTree",
  Char_t *OutFile=0,
  const Char_t *PrintList="")
{

  cout << "bfcread_hist_extract.C, input hist file = " 
       << MainFile << endl;
  cout << "bfcread_hist_extract.C, directory name for hist = " 
       << MakerHistDir << endl;
  cout << "bfcread_hist_extract.C, top level directory in hist file = " 
       << TopDirTree << endl;

//
    gSystem->Load("St_base");
    gSystem->Load("StChain");
    gSystem->Load("StIOMaker");
    gSystem->Load("StarClassLibrary");
    gSystem->Load("StUtilities");
    gSystem->Load("StAnalysisUtilities");
    gSystem->Load("libglobal_Tables");

// setup chain with IOMaker - can read in .dst.root, .dst.xdf files
  StIOMaker *IOMk = new StIOMaker("IO","r",MainFile,TopDirTree);
  IOMk->SetDebug();
  IOMk->SetIOMode("r");
  IOMk->SetBranch("*",0,"0");                 //deactivate all branches
  IOMk->SetBranch("histBranch",0,"r"); //activate dst Branch


// constructor for other maker (not used in chain)
   StHistUtil   *HU  = new StHistUtil;

// now must set pointer to StMaker so HistUtil can find histograms
//  with StHistUtil methods
// -- input any maker pointer but must cast as type StMaker
   HU->SetPntrToMaker((StMaker *)IOMk);

// ONLY use StIOMaker in chain 
// --- now execute chain member functions - 1 event (histograms) only
  IOMk->Init();
  IOMk->Clear();
  IOMk->Make();

// method to print out list of histograms
// - can do this anytime after they're booked
// - default is to print out QA hist branch
   Int_t NoHist=0;
   //NoHist = HU->ListHists(MakerHistDir);
   TList* dList = HU->FindHists(MakerHistDir);
   if (PrintList) HU->SetDefaultPrintList(MakerHistDir,PrintList);
   NoHist = HU->CopyHists(dList);
   TH1** nh = HU->getNewHist();

   TString name = MainFile;
   if (!OutFile) {
     name.Remove(0,name.Last('/')+1);
     TString name2 = MakerHistDir;
     name2.Remove(0,name2.Last('/')+1);
     name.Insert(name.First('.'),"_");
     name.Insert(name.First('.'),name2);
     OutFile = name.Data();
   }
   cout <<  "Output hist file: " << OutFile << endl;
   TFile* ofile = new TFile(OutFile,"RECREATE");
   for (int i=0; i<NoHist; i++) {
     printf("Extracting: %d. %s : %s\n",
       i+1,nh[i]->GetName(),nh[i]->GetTitle());
     nh[i]->Write();
   }
   ofile->Close();
      
}
Esempio n. 4
0
//_____________________________________________________________________
void bfcZ(const Int_t First,
	 const Int_t Last,
	 const Char_t *Chain="gstar Cy2b tfs -NoHits TpcHitFilter",
	 const Char_t *infile=0,
	 const Double_t zmin=-200, const Double_t zmax=-100,
	 const Char_t *outfile=0,
	 const Char_t *TreeFile=0){ 
  gROOT->LoadMacro("bfc.C");
  bfc(-1,Chain,infile,outfile,TreeFile);
  if (chain->GetOption("TpcHitFilter")) {
    StTpcHitFilterMaker *filtMk = (StTpcHitFilterMaker *) chain->GetMaker("tpc_hit_filter");
    if (filtMk) {
      //      St_tcl_Maker *tclMk= (St_tcl_Maker *) chain->GetMaker("tpc_hits");
      if (zmin < 0 && zmax < 0) filtMk->WestOff();
      if (zmin > 0 && zmax > 0) filtMk->EastOff();
      filtMk->SetZrange(zmin,zmax);
    }
  }
  {
    TDatime t;
    printf ("QAInfo:Run is started at Date/Time %i/%i\n",t.GetDate(),t.GetTime());
    printf ("QAInfo:Run on %s in %s\n",
	    gSystem->HostName(),
	    gSystem->WorkingDirectory());
    printf ("QAInfo: with %s\n", chain->GetCVS());
  }
  // Init the chain and all its makers
  Int_t iTotal = 0, iBad = 0;
  St_XDFFile *xdf_out = 0;
  TBenchmark evnt;
  Int_t iMake = 0, i = First;
  if (Last >= 0) {
    Int_t iInit = chain->Init();
    if (iInit >=  kStEOF) {
      chain->Fatal(iInit,"on init");
      goto END;
    }
    StEvtHddr *hd = (StEvtHddr*)chain->GetDataSet("EvtHddr");
    if (hd) hd->SetRunNumber(-2); // to be sure that InitRun calls at least once
    // skip if any
    if (First > 1) {
      if (chain->GetOption("fzin")) {
	geant = (St_geant_Maker *) chain->GetMaker("geant");
	if (geant) {
	  if (geant->IsActive()) geant->Skip(First-1);
	}
      }
      else {
	StIOMaker *inpMk      = (StIOMaker *)      chain->GetMaker("inputStream");
	if (inpMk) {printf ("Skip %i Events\n",First-1);inpMk->Skip(First-1);}
      }
    }
  }
  xdf_out = chain->GetXdfOut();
  if (chain->GetOption("Event")) evMk  = (StEventMaker   *) chain->GetMaker("StEventMaker");  
  treeMk = chain->GetMaker("OutputStream");
 EventLoop: if (i <= Last && iMake != kStEOF && iMake != kStFatal) {
   evnt.Reset();
   evnt.Start("QAInfo:");
   chain->Clear();
   iMake = chain->Make(i);
   if (iMake <kStEOF) {
     if (xdf_out){
       St_DataSet *dstSet = chain->GetInputDS("dst");
       if (dstSet) xdf_out->NextEventPut(dstSet); // xdf output
     }
     iTotal++;
     if (treeMk && iMake == kStErr) {treeMk->Make(i); iBad++;}
     //    gSystem->Exec("ps ux");
     evnt.Stop("QAInfo:");
     //  evnt.Show("QAInfo:");
     printf ("QAInfo: Done with Event [no. %d/run %d/evt. %d/Date.Time %d.%d/sta %d] Real Time = %10.2f seconds Cpu Time =  %10.2f seconds \n",
	     i,chain->GetRunNumber(),chain->GetEventNumber(),chain->GetDate(), chain->GetTime(),
	     iMake,evnt.GetRealTime("QAInfo:"),evnt.GetCpuTime("QAInfo:"));
   }
   i++; goto EventLoop;
 }
 END:
  fflush(stdout);
  printf ("QAInfo:Run completed ");
  gSystem->Exec("date");
  if (evMk) Event = (StEvent *) chain->GetInputDS("StEvent");
  {
    TDatime t;
    printf ("\nQAInfo:Run is finished at Date/Time %i/%i; Total events processed :%i and not completed: %i\n",
	    t.GetDate(),t.GetTime(),iTotal,iBad);
  }
}
void Example_read_dst_print_tables(
 Int_t nevents=1, 
 const char *MainFile=
"/afs/rhic.bnl.gov/star/data/samples/gstar.dst.root")
{
//
    gSystem->Load("St_base");
    gSystem->Load("StChain");

    gSystem->Load("libglobal_Tables");
    gSystem->Load("libgen_Tables");
    gSystem->Load("libsim_Tables");
    gSystem->Load("libtpc_Tables");

    gSystem->Load("StIOMaker");
    gSystem->Load("StarClassLibrary");

    cout << "  .. Example_read_dst_print_tables.C, have loaded libraries " << endl;

//  Setup top part of chain
    chain = new StChain("bfc");
    chain->SetDebug();
   
//  
// setup chain with IOMaker - can read in .dst.root, .dst.xdf files
  StIOMaker *IOMk = new StIOMaker("IO","r",MainFile,"bfcTree");
  IOMk->SetDebug();
  IOMk->SetIOMode("r");
  IOMk->SetBranch("*",0,"0");                 //deactivate all branches
//  IOMk->SetBranch("tpc_tracks",0,"r"); //activate tpc_tracks Branch
//  IOMk->SetBranch("geantBranch",0,"r"); //activate geant Branch
  IOMk->SetBranch("dstBranch",0,"r"); //activate dst Branch

  
// --- now execute chain member functions
  chain->Init();
 
  for (int iev=0;iev<nevents; iev++)
  {
    chain->Clear();
    int iret = chain->Make();
    if (iret) break;

    cout << endl << endl << 
       " !!! Now print info about event # " << iev << endl;

// ------ List all tables -----------
// GetDataSet is a member function of St_Maker
    Event = chain->GetDataSet("dst");

// ls() returns a virtual void, so don't have to set it = to anything
    if (Event) Event->ls();
   

// ---------------------- globtrk table ---------------------
//  get dataset for globtrk
TDataSet *ds=chain->GetDataSet("dst/globtrk");

if (ds) {

 cout << " Now print info about globtrk table "  << endl;

// create iterator for the dataset
TDataSetIter globtrkiter(ds);

// Du,Pwd return things, but we choose not to keep the return value
globtrkiter.Du();
globtrkiter.Pwd();

// find the table
St_dst_track *glob = (St_dst_track *) globtrkiter.Find("globtrk");

// print out info about it
// using ls() from TDataSetIter
glob->ls();

// Print() is a member function of TTable
//glob->Print(9,1);
//glob->Print(8,1);
//glob->Print(8,2);
//glob->Print(1,1);
glob->Print(0,5);
 

// can't use this method anymore!!! 5June00 Kathy
// get the table header data using member function of TTable
//table_head_st *tdt_h =  glob->GetHeader();
// cout << " header name   = " << tdt_h->name << endl;
// cout << " header type   = " << tdt_h->type << endl;
// cout << " header maxlen = " << tdt_h->maxlen << endl;
// cout << " header nok    = " << tdt_h->nok << endl;


// get the table header data using member functions of TTable
   cout << " table header info:  name = " << glob->GetName() << endl;
   cout << " table header info:  type = " << glob->GetType() << endl;
   cout << " table header info:  #rows used = " << glob->GetNRows() << endl;
   cout << " table header info:  #rows allocated = " << glob->GetTableSize() << endl;
   cout << " table header info:  row size (bytes) = " << glob->GetRowSize() << endl;
   cout << " table header info:  #columns = " << glob->GetNumberOfColumns() << endl;

// get the table and print out info about it (it's printing row 0)
 dst_track_st *sth = glob->GetTable();
 cout << " globtrk: row0 " << endl; 
 cout << "  r0      = " << sth->r0     << endl;
 cout << "  impact  = " << sth->impact << endl;
 cout << "  invpt   = " << sth->invpt  << endl;
 cout << "  z0      = " << sth->z0     << endl;

// now go to next row 
//  - just increment the pointer to do this (probably just STAR-specific
//    way - can't always increment pointers and get to right place!

 sth++;
 cout << " globtrk: row1 " << endl; 
 cout << "  r0      = " << sth->r0     << endl;
 cout << "  impact  = " << sth->impact << endl;
 cout << "  invpt   = " << sth->invpt  << endl;
 cout << "  z0      = " << sth->z0     << endl;

}

//--------------------------------------------------------
  }

  chain->Finish();    
  
}
Esempio n. 6
0
// ------------------ Here is the actual method -----------------------------------------
void doEvents(const Char_t *inname, const Char_t *histname,  const Char_t *ntuplename)
{
  Int_t nEvents = 10;
  Int_t nfiles = 100;

  //
  // First load some shared libraries we need
  //
  if (gClassTable->GetID("TTable") < 0) {
    gSystem->Load("libStar");
    gSystem->Load("libPhysics");
  }  
  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("StTofrMatchMaker");
  //    gSystem->Load("StTofpMatchMaker");
  //    gSystem->Load("StTofCalibMaker");
  //    gSystem->Load("StTofFlowMaker");
  gSystem->Load("StTofrNtupleMaker");

    // Handling depends on whether file is a ROOT file or XDF file
    //
    chain  = new StChain("StChain");
    
    StIOMaker* ioMaker = new StIOMaker();
    ioMaker->SetFile(inname);
    ioMaker->SetIOMode("r");
    ioMaker->SetBranch("*",0,"0");
    ioMaker->SetBranch("eventBranch",0,"r");
    ioMaker->SetDebug(0);
  
    int NwGeant=5000000, IwType=0, NwPaw=0;
    St_geant_Maker *geantMk = new St_geant_Maker("geant",NwGeant,NwPaw,IwType);
    geantMk->LoadGeometry("detp geometry y2008");
    geantMk->SetActive(kFALSE);

   cout<<endl<<"============  Data Base ========="<<endl;
   dbMk = new St_db_Maker("db","MySQL:StarDb","$STAR/StarDb","StarDb");

   StTofrMatchMaker *matchMaker = new StTofrMatchMaker("tofrMatch");
   matchMaker->SetDebug(0);
   matchMaker->SetMode(1);
   matchMaker->setSaveGeometry(kTRUE);
   matchMaker->setCreateHistoFlag(kTRUE);
   matchMaker->setCreateTreeFlag(kTRUE);
   matchMaker->setHistoFileName(histname);
   //matchMaker->setNtupleFileName("test2.root");
   StTofrNtupleMaker *tofrNtuple = new StTofrNtupleMaker("tofrNtuple", ntuplename);
   tofrNtuple->SetDebug(0); 
   tofrNtuple->setInitGeomFromOther(kTRUE);
    //

    // Initialize chain
    //
    Int_t iInit = chain->Init();
    if (iInit) chain->Fatal(iInit,"on init");
    chain->PrintInfo();
    //
    // 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;}
   
   //   gObjectTable->Print();
   i++;
   goto EventLoop;
 }
    
    i--;
  cout<<endl<<"============================ Event "<<i<<" finish ============================"<<endl;

  //
  // Chain Finish
  //
  if (nEvents > 1) {
    chain->Finish();
  }


}
Esempio n. 7
0
void runTrigTreeMaker( const Char_t *file="rcf10063_2_6000evts.MuDst.root", const Char_t* fileOut = "rcf10063_2_6000evts.TrigTree-A.root", Char_t trigVer = 'g', Int_t nevents = 10000000,
                       Int_t flagMC = 1, const Char_t *eemcSetupPath="/star/u/sgliske/Share/StarTrigSimuSetup/" ){
  
   //int flagMC=0;  // 0/1 == Using Real/Simulation data files 
  int useEemc=2; // 0/1 == Exclude/Include EEMC in Trigger Decisions 
  int useBemc=0; // 0/1 == Exclude/Include BEMC in Trigger Decisions 
  int useL2=1;   // 0/1 == Exclude/Include L2 in Trigger Decisions 
  int L2ConfigYear=2006; // possible: 2006, 2008
  int bemcConfig=1; // Online==1, Offline==2, Expert==3
  int playConfig=0; // jan:100_199
  int emcEveDump=0; // extrating raw EMC data in a custom format
  int outputL2Histo=1;//output L2 histos to directory outL2
  TString outDir="./outL2/"; 

  gROOT->LoadMacro("$STAR/StRoot/StMuDSTMaker/COMMON/macros/loadSharedLibraries.C");
  loadSharedLibraries();
  assert( !gSystem->Load("StDetectorDbMaker"));
  assert( !gSystem->Load("StTpcDb"));
  assert( !gSystem->Load("StDbUtilities"));
  assert( !gSystem->Load("StDbBroker"));
  assert( !gSystem->Load("St_db_Maker"));
  assert( !gSystem->Load("StEEmcUtil")); // needed by eemcDb
  assert( !gSystem->Load("StEEmcDbMaker"));
  assert( !gSystem->Load("StDaqLib")); // needed by bemcDb
  assert( !gSystem->Load("StEmcRawMaker"));
  assert( !gSystem->Load("StEmcADCtoEMaker"));
  if (flagMC) {
    assert( !gSystem->Load("StMcEvent"));
    assert( !gSystem->Load("StMcEventMaker"));
    assert( !gSystem->Load("StEmcSimulatorMaker"));
    assert( !gSystem->Load("StEEmcSimulatorMaker"));
    assert( !gSystem->Load("StEpcMaker"));
  }
  assert( !gSystem->Load("StTriggerUtilities"));
   assert( !gSystem->Load("StSpinDbMaker") );
  assert( !gSystem->Load("StEEmcPoolEEmcTreeContainers") );
  assert( !gSystem->Load("StEEmcTreeMaker") );

  gROOT->Macro("LoadLogger.C");
  cout << " loading done " << endl;
  
  chain= new StChain("StChain"); 

  if (flagMC){
    TString geantFile;
    geantFile += file;
    geantFile.ReplaceAll("MuDst.root", "geant.root");
    printf("geantFile=%s\n", geantFile.Data());
    StIOMaker* ioMaker = new StIOMaker();
    ioMaker->SetFile(geantFile);
    ioMaker->SetIOMode("r");
    ioMaker->SetBranch("*",0,"0");             //deactivate all branches
    ioMaker->SetBranch("geantBranch",0,"r");   //activate geant Branch
    StMcEventMaker *evtMaker = new StMcEventMaker();
  }

  //Need MuDstMaker to get data
  printf(" Analyzing file=%s\n",file);  
  StMuDstMaker* muDstMaker =new StMuDstMaker(0,0,"",file,"",1000);

   // just to make sure StEvent is found for the trig simu
   StMuDst2StEventMaker *muDst2StEvent = new StMuDst2StEventMaker();

  //Database -- get a real calibration from the database
  St_db_Maker* dbMk =0;
  if(useEemc || useL2) // full DB access
    dbMk = new St_db_Maker("StarDb","MySQL:StarDb","MySQL:StarDb","$STAR/StarDb");
  else // only Barrel is uploaded, is faster 
    dbMk  = new St_db_Maker("Calibrations","MySQL:Calibrations_emc");
   dbMk->SetAttr("blacklist", "fgt");
   dbMk->SetAttr("blacklist", "svt");
   dbMk->SetAttr("blacklist", "tpc");
   dbMk->SetAttr("blacklist", "ftpc");

    
  // CORRECTION: do not always need to set date and time for MC
  //If MC then must set database time and date
  //If Endcap fast simu is used tower gains in DB do not matter,JB
  //if (flagMC) dbMk->SetDateTime(20060522, 55000);//timestamp R7142018
  
  //Collect all output histograms 
  TObjArray* HList=new TObjArray; 
  
  //Endcap DB
  if(useEemc || useL2) new StEEmcDbMaker("eemcDb");
  

  //Get BEMC adc values
  if (flagMC && useBemc) {
    StEmcSimulatorMaker* emcSim = new StEmcSimulatorMaker(); //use this instead to "redo" converstion from geant->adc
    if (bemcConfig == 1) {
        emcSim->setCheckStatus(kBarrelEmcTowerId,false); //this returns hits regardless of offline tower status
    }
    emcSim->setCalibSpread(kBarrelEmcTowerId,0.15);//spread gains by 15%
  }
  if (flagMC==0 && useBemc){
    StEmcADCtoEMaker *bemcAdc = new StEmcADCtoEMaker();//for real data this sets calibration and status
    if (bemcConfig == 1) {
        bemcAdc->setCheckStatus(kBarrelEmcTowerId,false);
    }
  }

  // original comment: must use slow simulator to get pedestals
  // correct for L2.  New comment: I think this is needed if slow simulator was
  // used in the MC production.
  if (0 && flagMC==1 && useEemc){
    StEEmcSlowMaker *slowSim = new StEEmcSlowMaker("slowSim");

    // note: changing the sampling fraction does not effect the
    // L0 trigger decision.  Also, it is probably better to use the value
    // in the slow simulator, so that it matches data. (S. Gliske,
    // Sept 2012)

    // This 1.3 comes from the iron/air MC, where the sampling
    // fraction was believed to be near 4%, but slow/fast simulator
    // used 5%.

    // Now that the slow/fast simulator uses 0.048, it is a 1.25 scaling factor

    // slowSim->setSamplingFraction(0.0384); // effectively scale all Tower energies with a factor of 1.3 (added by: Ilya Selyuzhenkov; April 11, 2008)

    slowSim->setAddPed(true);
    slowSim->setSmearPed(true);
  }
 
  //Get TriggerMaker
  StTriggerSimuMaker *simuTrig = new StTriggerSimuMaker("StarTrigSimu");
  simuTrig->setHList(HList);
  simuTrig->setMC(flagMC); // must be before individual detectors, to be passed
  simuTrig->useBbc();
  if(useEemc) {
    simuTrig->useEemc(0);//default=0:just process ADC, 1,2:comp w/trgData,see .
    simuTrig->eemc->setSetupPath(eemcSetupPath);
  } 
  if(useBemc){
    simuTrig->useBemc();
    simuTrig->bemc->setConfig(bemcConfig);
  }

  if(flagMC && useEemc==2){
     // pass one argument to M-C as generic switch    
     // Endcap specific params -- ok Jan you need to change this to a default "online" setup
     int eemcDsmSetup[20]; // see StEemcTriggerSimu::initRun() for definition
     memset(eemcDsmSetup, 0,sizeof(eemcDsmSetup));// clear all, may be a bad default

     if( trigVer == 'd' ){
        // valid runs 7130037-7132029
        eemcDsmSetup[0]=6;  // HTthr0
        eemcDsmSetup[1]=12; // HTthr1
        eemcDsmSetup[2]=22; // HTthr2
        eemcDsmSetup[3]=1;  // TPthr0
        eemcDsmSetup[4]=20; // TPthr1
        eemcDsmSetup[5]=31; // TPthr2
     } else if ( trigVer == 'e' ){
        // valid runs 7132045-7133051
        eemcDsmSetup[0]=6;  // HTthr0
        eemcDsmSetup[1]=17; // HTthr1
        eemcDsmSetup[2]=22; // HTthr2
        eemcDsmSetup[3]=1;  // TPthr0
        eemcDsmSetup[4]=20; // TPthr1
        eemcDsmSetup[5]=31; // TPthr2
     } else if ( trigVer == 'f' ){
        // valid runs 7133052-7156040
        eemcDsmSetup[0]=6;  // HTthr0
        eemcDsmSetup[1]=16; // HTthr1
        eemcDsmSetup[2]=22; // HTthr2
        eemcDsmSetup[3]=1;  // TPthr0
        eemcDsmSetup[4]=20; // TPthr1
        eemcDsmSetup[5]=31; // TPthr2
     } else if ( trigVer == 'g' ){
        // test trigger, ht1 & tp2 are 1 DSM (roughly 5%) higher than 'e'
        eemcDsmSetup[0]=6;  // HTthr0
        eemcDsmSetup[1]=18; // HTthr1
        eemcDsmSetup[2]=22; // HTthr2
        eemcDsmSetup[3]=1;  // TPthr0
        eemcDsmSetup[4]=21; // TPthr1
        eemcDsmSetup[5]=31; // TPthr2
   } else if ( trigVer == 'h' || trigVer == 'i' ){
      // test trigger, ht1 & tp2 are 2 DSM (roughly 10%) higher than 'e'
      eemcDsmSetup[0]=6;  // HTthr0
      eemcDsmSetup[1]=19; // HTthr1
      eemcDsmSetup[2]=22; // HTthr2
      eemcDsmSetup[3]=1;  // TPthr0
      eemcDsmSetup[4]=22; // TPthr1
      eemcDsmSetup[5]=31; // TPthr2
     } else {
        cerr << "Invalid trigger version" << endl;
        return;
     };
    eemcDsmSetup[10]=2; //HTTPthrSelc, 2=use_thres_#1

    simuTrig->eemc->setDsmSetup(eemcDsmSetup);    
  }


  StGenericL2Emulator* simL2Mk=0;
  if(useL2) {
    /* 
       NOTE: the following comment was in the rdMu2TrigSimu.C macro,
       but does not seem applicable.  Just use the given
       StarTrigSimuSetup directory, and make sure the given outDir
       exists, all will be well.

       reads all input/setup files from  L2setup-yyyymmdd/
       writes all output files to L2out-yyyymmdd 
       depending on the DB time stamp 
       both dierectiorie MUST exist, setup must be reasonable
    */
    if(L2ConfigYear==2006) simL2Mk= new StL2_2006EmulatorMaker;
    else if(L2ConfigYear==2008) simL2Mk= new StL2_2008EmulatorMaker;
    assert(simL2Mk);
    simL2Mk->setSetupPath(eemcSetupPath);

    simL2Mk->setOutPath(outDir.Data());
    if (flagMC) simL2Mk->setMC();
    simuTrig->useL2(simL2Mk);
  }

  // now the maker to write the tree
  StTrigTreeMaker_t *treeMkr = new StTrigTreeMaker_t( "trigTreeMaker", fileOut, 1 );
  treeMkr->addTrigger( -999 ); // i.e. no trigger cut now

  chain->ls(3);

  cout << "******* Initialize *******" << endl ;
  chain->Init();
  cout << "******* done with initializing *******" << endl;
 
  for (Int_t iev=0;iev<nevents; iev++) {
     if( iev % 100 == 1  )
        cout << "Working on eventNumber:\t" << iev <<"\tof:\t"<<nevents<<endl;

    chain->Clear();
    int iret = chain->Make(iev);
    total++;   
    if (iret % 10 == kStEOF || iret % 10 == kStFatal)  {
      cout << iev << " Bad return code!" << endl;
      break;
    }

    //struct L2gammaResult2006* result = dynamic_cast< L2gammaResult2006* >( simL2Mk->result() );
    //cout << "ZZZ " << result->trigger << endl;

    if( simL2Mk ){
//        const unsigned int* result = simL2Mk->result();
//        cout << "ZZZ " << std::hex << result[0] << result[1] << result[2] << result[3] << result[4] << result[5] << result[6] << result[7] << std::dec
//             << " " << simL2Mk->mAcceptTriggerList.size() << ' ' << simL2Mk->mVetoTriggerList.size() << endl;

//        cout << "ZZZ accept: ";
//        for( Int_t i=0; i<simL2Mk->mAcceptTriggerList.size(); ++i )
//           cout << simL2Mk->mAcceptTriggerList.at(i) << ' ';
//        cout << endl;

//        cout << "ZZZ veto: ";
//        for( Int_t i=0; i<simL2Mk->mVetoTriggerList.size(); ++i )
//           cout << simL2Mk->mVetoTriggerList.at(i) << ' ';
//        cout << endl;

//       cout << "ZZZ " << simuTrig->isTrigger( 137641 ) << endl;
    }
  }

 
  chain->Finish();
  cout << "****************************************** " << endl;
  cout << "total number of events  " << total << endl;
  cout << "****************************************** " << endl;

  if (outputL2Histo==1) {
  
    TString fileMu=file;
    printf("=%s=\n",fileMu.Data());
    if(fileMu.Contains(".lis")) fileMu.ReplaceAll(".lis",".trgSim");
    if(fileMu.Contains(".MuDst.root")) fileMu.ReplaceAll(".MuDst.root",".trgSim");
    TString outF=outDir+fileMu;
    outF+=".hist.root";
    printf("=%s=\n",outF.Data());
    hf=new TFile(outF,"recreate");
    if(hf->IsOpen()) {
       cout << "HList not saved, or seg faults" << endl;
       //HList->Write();
       //printf("\n Histo saved -->%s<\n",outF.Data());
    } 
    else {
      printf("\n Failed to open Histo-file -->%s<, continue\n",outF.Data());
    }
  }
 
}
Esempio n. 8
0
void CorrectResolution(Int_t nevents=100)
{

    // Dynamically link needed shared libs
    gSystem->Load("St_base");
    gSystem->Load("StChain");
    gSystem->Load("St_Tables");
    gSystem->Load("StUtilities");  // new addition 22jul99
    gSystem->Load("StAnalysisUtilities");  // needed by V0dstMaker
    gSystem->Load("StMagF");
    gSystem->Load("StIOMaker");
    gSystem->Load("StarClassLibrary");
    gSystem->Load("StEvent");
    gSystem->Load("StEventMaker");
    gSystem->Load("StHbtMaker");

    cout << "Dynamic loading done" << endl;

    chain = new StChain("StChain"); 
    chain->SetDebug();


#ifndef USE_MICRODST
    
    StIOMaker* ioMaker = new StIOMaker("IO","r","/star/rcf/data07/reco/P00hg/2000/07/st_physics_*dst.root","bfcTree");
    ioMaker->SetDebug();

    ioMaker->SetIOMode("r");
    ioMaker->SetDebug();
    ioMaker->SetBranch("*",0,"0");                 //deactivate all branches
    ioMaker->SetBranch("dstBranch",0,"r"); //activate EventBranch


    StEventMaker* eventMaker = new StEventMaker("events","title");
    cout << "Just instantiated StEventMaker... lets go StHbtMaker!" << endl;
#endif



    // Now we add Makers to the chain...

    StHbtMaker* hbtMaker = new StHbtMaker("HBT","title");
    cout << "StHbtMaker instantiated"<<endl;


    /* -------------- set up of hbt stuff ----- */
    cout << "StHbtMaker::Init - setting up Reader and Analyses..." << endl;

    StHbtManager* TheManager = hbtMaker->HbtManager();

    // here, we instantiate the appropriate StHbtEventReader




#ifdef USE_MICRODST
    StHbtBinaryReader* Reader = new StHbtBinaryReader("-","microDst.lis");
#else
    StStandardHbtEventReader* Reader = new StStandardHbtEventReader;
    Reader->SetTheEventMaker(eventMaker);     // gotta tell the reader where it should read from
#endif


    // here would be the palce to plug in any "front-loaded" Event or Particle Cuts...
    TheManager->SetEventReader(Reader);


    StHbtVertexAnalysis* anal;
    mikesEventCut* FrontLoadedEvcut;
    mikesStarStandardEventCut* evcut;
    mikesTrackCut* trkcut;
    qualityPairCut* qpc;
    ManyPairCuts* MPC;
    EntranceSepPairCut* espc;
    StHbtCoulomb* cc;

    QinvCorrFctn* QinvCF;
    BPLCMSFrame3DCorrFctn* BpLcmsCF;
    char* QinvCF_name;
    char* BP_name;
    int MultLo,MultHi;
    float pTLo,pTHi;
    int charge;

    // SPEED IT UP -- FRONT-LOADED EVENT CUT and TRACK CUT

    FrontLoadedEvcut = new mikesEventCut;  
    FrontLoadedEvcut->SetEventMult(30,100000);
    FrontLoadedEvcut->SetVertZPos(-75.0,75.0);
    Reader->SetEventCut(FrontLoadedEvcut);

    // Removed Front-loaded Track cut

    cout << "READER SET UP.... " << endl;




    /* MOST CENTRAL PIMINUS hi-pT (5) */

    QinvCF_name = "Qinvmm3hi";
    BP_name = "BPLCMSmm3hi";
    MultLo = 174;
    MultHi = 500;
    pTLo = 0.325;
    pTHi = 0.45;
    charge = -1;

    anal = new StHbtVertexAnalysis(10,-75.0,75.0);
    // 1) set the Event cuts for the analysis
    evcut = new mikesStarStandardEventCut;
    evcut->SetEventMult(MultLo,MultHi);      
    evcut->SetVertZPos(-75.0,75.0);   
    anal->SetEventCut(evcut);         
    // 2) set the Track (particle) cuts for the analysis
    trkcut = new mikesTrackCut;  
    trkcut->SetNSigmaPion(-3.0,3.0); 
    trkcut->SetNSigmaKaon(-1000.0,1000.0); 
    trkcut->SetNSigmaProton(-1000.0,1000.0);
    trkcut->SetNHits(5,50);            
    trkcut->SetPt(pTLo,pTHi);
    trkcut->SetRapidity(-0.5,0.5);     
    trkcut->SetDCA(0.0,3.0);           
    trkcut->SetCharge(charge);             
    trkcut->SetMass(0.139);            
    anal->SetFirstParticleCut(trkcut); 
    anal->SetSecondParticleCut(trkcut);
    // 3) set the Pair cuts for the analysis - this one uses ManyPairCuts
    MPC = new ManyPairCuts;
    qpc = new qualityPairCut;
    qpc->SetQualityCut(-0.5,0.6);
    MPC->AddPairCut(qpc);
    espc = new EntranceSepPairCut;
    espc->SetEntranceSepRange(2.5,2000.0);
    MPC->AddPairCut(espc);
    anal->SetPairCut(MPC);         
    // 4) set the number of events to mix (per event)
    anal->SetNumEventsToMix(10);        
    // 5) now set up the correlation functions that this analysis will make
    //    QinvCF = new QinvCorrFctn(QinvCF_name,40,0.0,0.20);
    //    anal->AddCorrFctn(QinvCF);
    BpLcmsCF = new BPLCMSFrame3DCorrFctn(BP_name,40,0.0,0.2);
    cc = new StHbtCoulomb;
    cc->SetRadius(5.0);
    BpLcmsCF->SetCoulombCorrection(cc);
    //
    // now set up momentumResolutionCorrection stuff
    //
    StHbtSmearPair* smear = new StHbtSmearPair;
    smear->SetFractionalPtRes(0.02);
    smear->SetPhiRes_a(0.00112);
    smear->SetPhiRes_b(0.000563);
    smear->SetPhiRes_alpha(-1.51);
    smear->SetThetaRes_a(0.00136);
    smear->SetThetaRes_b(0.000776);
    smear->SetThetaRes_alpha(-1.53);
    BpLcmsCF->SetSmearPair(smear);
    //
    BpLcmsCF->SetLambda(0.65);
    BpLcmsCF->SetRout(4.52);
    BpLcmsCF->SetRside(5.00);
    BpLcmsCF->SetRlong(5.43);


    anal->AddCorrFctn(BpLcmsCF);
    // 7) add the Analysis to the AnalysisCollection
    TheManager->AddAnalysis(anal);



    /* ------------------ end of setting up hbt stuff ------------------ */


  // now execute the chain member functions
  
  if (chain->Init()){ // This should call the Init() method in ALL makers
    cout << "Initialization failed \n";
    goto TheEnd;
  }
  chain->PrintInfo();


  // Event loop
  int istat=0,iev=1;
 EventLoop: if (iev <= nevents && !istat) {
   cout << "StHbtExample -- Working on eventNumber " << iev << " of " << nevents << endl;
   chain->Clear();
   istat = chain->Make(iev);
   if (istat) {cout << "Last event processed. Status = " << istat << endl;}
   iev++; goto EventLoop;
 }


  cout << "StHbtExample -- Done with event loop" << endl;

  chain->Finish(); // This should call the Finish() method in ALL makers

 TheEnd:

  TFile histoOutput("ThreeDHBT.root","recreate");

  for (int ia=0; ia<1; ia++){
    StHbtVertexAnalysis* Vanal = (StHbtVertexAnalysis*)(hbtMaker->HbtManager()->Analysis(ia));
//     QinvCorrFctn* qcf = (QinvCorrFctn*)(Vanal->CorrFctn(0));
//     qcf->Numerator()->Write();
//     qcf->Denominator()->Write();
//     qcf->Ratio()->Write();
    BPLCMSFrame3DCorrFctn* bpcf = (BPLCMSFrame3DCorrFctn*)(Vanal->CorrFctn(0));
    bpcf->Numerator()->Write();
    bpcf->Denominator()->Write();
    bpcf->Ratio()->Write();
    //
    bpcf->mIDNumHisto->Write();
    bpcf->mIDDenHisto->Write();
    bpcf->mIDRatHisto->Write();
    bpcf->mSMNumHisto->Write();
    bpcf->mSMDenHisto->Write();
    bpcf->mSMRatHisto->Write();
    bpcf->mCorrectionHisto->Write();
    bpcf->mCorrCFHisto->Write();
  }

  histoOutput.Close();


}
Esempio n. 9
0
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;
}
Esempio n. 10
0
void OnlineQaTpcRaw(
 Int_t nevents=2, 
 const char *MainFile=
 "/afs/rhic.bnl.gov/star/data/samples/june_2000_st_physics_1164058_raw_0001.daq",
 Int_t nevHistOut=0)
{
//
  cout << " OnlineQaTpcRaw.C: #events to process  = " << nevents << endl;
  cout << " OnlineQaTpcRaw.C: input file name = " << MainFile << endl;
  cout << " OnlineQaTpcRaw.C: #events to write to hist file (0=all) = " << 
            nevHistOut << endl;

// Generate a name for an outHistFile using input file name
//
  fInFile = new TString(MainFile);
  fFileOut = new TString(gSystem->BaseName(fInFile->Data()));
  fFileOut->ReplaceAll(".daq",""); // remove old file extension
  const char *histoDir = "./"; // directory for histos
  fFileOut->Prepend(histoDir);
  const Char_t *outHistFile= fFileOut->Data(); // done


// define other values needed:
   const Char_t *topTree="OnlQaTpcTree";
   const Char_t *makerName="RawTpcQa";


   cout << " OnlineQaTpcRaw.C: output hist file name set to " << 
           outHistFile << ".hist.root" << endl;
   cout << " OnlineQaTpcRaw.C: top level Tree directory set to " << 
           topTree << endl;
   cout << " OnlineQaTpcRaw.C: maker name set to " << 
           makerName << endl;

// load libraries - basic ones needed
    gSystem->Load("St_base");
    gSystem->Load("StChain");
    gSystem->Load("StIOMaker");
    gSystem->Load("StTreeMaker");

// these 2 are for using the StHistUtil class
    gSystem->Load("StUtilities");
    gSystem->Load("StAnalysisUtilities");

// for raw tpc qa maker
    gSystem->Load("StRawTpcQaMaker");


//  Setup top part of chain
    chain = new StChain("OnlineQaTpcRawChain");
    //    chain->SetDebug(0);
   
// now any Maker that gets constructed will be added to the chain
  StIOMaker *IOMk = new StIOMaker("IO","r",MainFile,topTree);
  //IOMk->SetDebug();
    IOMk->SetIOMode("r");

// histogram utility class (this is not a Maker so not used in chain)
    StHistUtil   *HU  = new StHistUtil;
// now must set pointer to any StMaker so HistUtil can find histograms
//  with StHistUtil methods
// -- input any maker pointer but must cast as type StMaker
   HU->SetPntrToMaker((StMaker *)IOMk);


   StRawTpcQaMaker *RTQa = new StRawTpcQaMaker(makerName);

// output hist.root file:
   StTreeMaker* treeMk = new StTreeMaker("tree",outHistFile,topTree);
      treeMk->SetIOMode("w");
      treeMk->SetBranch("histBranch");


// --- now execute chain member functions
  chain->Init();


// method to print out list of histograms - 
//can do this anytime after they're booked
  Int_t NoHist=0;
  NoHist = HU->ListHists(makerName);
  cout << " !!! OnlineQaTpcRaw.C, No. of Hist Booked = " << NoHist << endl;

  int istat=0;
  int iev=0;
  int countev=0;

// Event loop
EventLoop: if (iev < nevents && !istat) {

    chain->Clear();
    istat = chain->Make(iev);
    
//  count # times Make is called
    iev++;

    cout << " Called Make # " << iev << endl; 
    cout << "     istat value returned from chain Make = " << istat <<

endl;

    if (!istat) {

    countev++;

    cout << " processed event # " << countev << endl;

    }  // istat

    else   // if (istat)
      {
      cout << "Last event processed. Status = " << istat << endl;
    }

    goto EventLoop;

}  // EventLoop
     
  cout << endl;
  cout << "QAInfo: End of Job " << endl; 
  cout << "QAInfo: # times Make called = " << iev << endl;
  cout << "QAInfo:  # events read = " << countev << endl;

  chain->Finish();

}
Esempio n. 11
0
//==========================================================================================
void ProcessQQ(const Int_t mode, const Int_t fsti, const Int_t nevents,
	       const Char_t **fileList, const Char_t* dirName)
{
  cout << "Loading libraries ..." << endl;
  gSystem->Load("St_base");
  gSystem->Load("StChain");
  gSystem->Load("StDaqLib");
  gSystem->Load("St_Tables");
  gSystem->Load("StarMagField");
  gSystem->Load("StMagF");
  gSystem->Load("StUtilities");
  gSystem->Load("StTreeMaker");
  gSystem->Load("StIOMaker");
  gSystem->Load("StarClassLibrary");
  gSystem->Load("StDetectorDbMaker");
  gSystem->Load("StTpcDb");
  gSystem->Load("StDbUtilities");
  gSystem->Load("StBichsel");
  gSystem->Load("StTriggerDataMaker");
  gSystem->Load("StEvent");
  gSystem->Load("StEventUtilities");
  gSystem->Load("StMcEvent");
  gSystem->Load("StMcEventMaker");
  gSystem->Load("StAssociationMaker");

  //if( mode & 0x2){
  // EMC specific
  cout << " EMC mode enabled" << endl;
  gSystem->Load("StEmcUtil");
  gSystem->Load("StDbLib");
  gSystem->Load("StDbBroker");
  gSystem->Load("St_db_Maker");
  //}

  if( mode & 0x4){
    // RICH
    cout << " RICH mode enabled" << endl;
    gSystem->Load("StRrsMaker");
    gSystem->Load("StRchMaker");
    gSystem->Load("StRichPIDMaker");
    gSystem->Load("StRichSpectraMaker");
  }

  gSystem->Load("StMcAnalysisMaker");
  gSystem->Load("StStrangeMuDstMaker");
  gSystem->Load("StMuDSTMaker");

  if( mode & 0x2 ){
    // EMC specific
    gSystem->Load("StEmcADCtoEMaker"); // analysis maker
    gSystem->Load("StPreEclMaker");    // analysis maker
    gSystem->Load("StEpcMaker");       // analysis maker
  }
  cout << "Loading done " << endl;


  chain = new StChain("StChain");
  chain->SetDebug();


  StFile *setFiles= new StFile();
  for (int ifil=0; fileList[ifil]; ifil++)
    setFiles->AddFile(fileList[ifil]);


  // ********************************
  // Now we add Makers to the chain...
  // ********************************

  // *************
  // file handling
  // *************
  StIOMaker* ioMaker = new StIOMaker("IOMaker","r",setFiles,"bfcTree");
  ioMaker->SetDebug();

  ioMaker->SetIOMode("r");
  ioMaker->SetDebug();
  ioMaker->SetBranch("*",0,"0");           //deactivate all branches
  ioMaker->SetBranch("eventBranch",0,"r"); //activate evt.root Branch
  ioMaker->SetBranch("emcBranch",0,"r");   //activate evt.root Branch
  ioMaker->SetBranch("runcoBranch",0,"r"); //activate runcoBranch



  // ***********************************************
  // MuDstMaker(s) instantiation / chain activation
  // ***********************************************
  // Common MuDST part
  StStrangeMuDstMaker* v0dst = new StStrangeMuDstMaker("strangeMuDst");
  v0dst->DoV0();      //Set v0MiniDstMaker to find only v0s
  v0dst->DoXi();      //Set v0MiniDstMaker to find only v0s
  v0dst->DoKink();    //Set v0MiniDstMaker to find only v0s
  v0dst->SetNoKeep();

  // RICH part
  if( mode & 0x4 ){
    StRichSpectraMaker* spectraMaker = new StRichSpectraMaker("spectraMaker");
  }

  StAddRunInfoMaker* addRunInfoMaker = new StAddRunInfoMaker();

  StMuDstMaker* maker = new StMuDstMaker(1,1,dirName);
  // You can change the PIDTable map using the above method.
  //maker->setProbabilityPidFile("Path/PIDTable.root");
  maker->setProbabilityPidFile();

  StMuL3Filter* l3Filter = new StMuL3Filter(); maker->setL3TrackFilter(l3Filter);
  StMuFilter* filter = new StMuFilter();       maker->setTrackFilter(filter);

  // EMC part
  if( mode & 0x2){
    St_db_Maker *dbMk = new St_db_Maker("StarDb","MySQL:StarDb");
    StEmcADCtoEMaker *adc = new StEmcADCtoEMaker();
    StPreEclMaker *pre = new StPreEclMaker();
    StEpcMaker *epc = new StEpcMaker();
    StEmcMicroDstMaker *write = new StEmcMicroDstMaker();
    write->setOutputDir(dirName);
  }


  if ( fsti == 1){
    //select for Sti tracks
    filter->addEncodedMethod(263);
  }



  // This should call the Init() method in ALL makers
  chain->Init();
  chain->PrintInfo();

  // Event Loop
  Int_t iev=0;
  for ( ; iev < nevents ; iev++) {
    cout << "-----> Working on eventNumber " << iev << endl;
    chain->Clear();
    int iret = chain->Make(iev); // This should call the Make() method in ALL makers
    if (iret) {
      cout << "Bad return code!" << endl;
      break;
    }
  }
  chain->Finish();    // This should call the Finish() method in ALL makers

  iev--;
  cout << endl << "******************* Last event processed = " << iev << endl;
}
Esempio n. 12
0
void rdSt2spinTest( Int_t nevents=10){

  char *   fname="/star/data03/daq/2005/janMisc/st_physics_6156028_raw_2040010.event.root";
  //char *   fname="/star/data03/daq/2005/janMisc/st_physics_5135068_raw_2020006.event.root";
  initHisto();
  
  gROOT->LoadMacro("$STAR/StRoot/StMuDSTMaker/COMMON/macros/loadSharedLibraries.C");
  loadSharedLibraries();
  cout << " loading done " << endl;
  gSystem->Load("StDbLib");
  gSystem->Load("StDbBroker");
  gSystem->Load("St_db_Maker");
  gSystem->Load("StSpinDbMaker");
    
  // create chain    
  chain = new StChain("bfc"); 
 
  // StIOMaker - to read files ...
  StIOMaker* ioMaker = new StIOMaker();  
  ioMaker->SetFile(fname); 
  ioMaker->SetIOMode("r");
  ioMaker->SetBranch("*",0,"0");  //deactivate all branches
  ioMaker->SetBranch("eventBranch",0,"r");   //activate Event Branch
  ioMaker->SetIOMode("r"); 
 
  St_db_Maker *stDb = new St_db_Maker("StarDb", "MySQL:StarDb");
  spDb=new StSpinDbMaker("spinDb");
  
  gMessMgr->SwitchOff("D");
  gMessMgr->SwitchOn("I");

  chain->ls(3);
  Int_t initStat = chain->Init(); 
  if (initStat) chain->Fatal(initStat, "during Init()");
    
  int istat=0,iev=0;

  // Do the event loop    
  while(1) {
    if (iev>=nevents) break;
    chain->Clear();
    istat = chain->Make(); 
    iev++; 
    if(istat) break; 
    cout << "---------------------- Processing Event : " << iev << " ---------------------- " << istat<<endl;

    if(iev==1){// fill pattern acquired for first event
      // spDb->print(0);
      for(int bx48=0;bx48<120;bx48++){
	int bxStar=spDb->BXstarUsingBX48(bx48);
	if(spDb->isBXfilledUsingBX48(bx48)) hfb->Fill(bxStar);
	//printf("bxStar=%3d   bx48=%3d   fill=%d\n",bxStar,bx48,spDb->isBXfilledUsingBX48(bx48));
      }
    }
    if (istat  == kStEOF || istat == kStFatal) break;
    
    StEvent* mEvent = (StEvent*)chain->GetInputDS("StEvent");
    assert(mEvent);// fix your chain or open the right event file
    StTriggerIdCollection *tic=mEvent->triggerIdCollection();
    assert(tic); 

    StTriggerData* trgD= mEvent->triggerData(); assert(trgD);
    int bx48=trgD->bunchId48Bit();
    int bx7=trgD->bunchId7Bit();
    int bxStar48=spDb->BXstarUsingBX48(bx48);
    int bxStar7=spDb->BXstarUsingBX7(bx7);
    int bxPhase=spDb->offsetBX48minusBX7(bx48,bx7);
    int spin8ev=trgD->spinBit();
    int spin8db=spDb->spin8usingBX48(bx48);
    int spin4db=spDb->spin4usingBX48(bx48);
    //.... do histo
    hbx->Fill(bxStar48);
    hdbx->Fill(bxStar48,bxStar7);
    hs8ev->Fill(bxStar48,spin8ev);
    if(spDb->isBXfilledUsingBX48(bx48)){
      hs8db->Fill(bxStar48,spin8db);
      hs4db->Fill(bxStar48,spin4db);
    }
    int nV=mEvent->numberOfPrimaryVertices();
    printf("eveID=%d  nPrimVert=%d  ", mEvent->id(),nV);
    printf("bx48=%3d bx7= %3d bxPhase=%3d spin8: ev=0x%02x : 0x%02x=db bxStar48=%3d \n",bx48,bx7,bxPhase,spin8ev,spin8db,bxStar48);
    // assert(spin8ev>10);
  } // Event Loop
 hf->Write();
    
}
Esempio n. 13
0
void Run2006SimuTriggerMaker(const char *dir ="",
			     const char* file="/star/data32/reco/pp200/pythia6_205/above_35gev/cdf_a/y2004y/gheisha_on/p05ih/rcf1230_10_4000evts.MuDst.root",
			     const char *fname="/star/data32/reco/pp200/pythia6_205/above_35gev/cdf_a/y2004y/gheisha_on/p05ih/rcf1230_10_4000evts.event.root",
			     const char *filter = "")
{
  int nevents = 10;
  
  gROOT->LoadMacro("$STAR/StRoot/StMuDSTMaker/COMMON/macros/loadSharedLibraries.C");
  loadSharedLibraries();
  gSystem->Load("StTpcDb");
  gSystem->Load("StDetectorDbMaker");
  gSystem->Load("StDbUtilities");
  gSystem->Load("StMcEvent");
  gSystem->Load("StMcEventMaker");
  gSystem->Load("StDaqLib");
  gSystem->Load("StEmcRawMaker");
  gSystem->Load("StEmcADCtoEMaker");
  gSystem->Load("StPreEclMaker");
  gSystem->Load("StEpcMaker");
  gSystem->Load("StEmcSimulatorMaker");
  gSystem->Load("StEmcUtil");
  gSystem->Load("StDbBroker");
  gSystem->Load("St_db_Maker");
  gSystem->Load("StEEmcUtil");
  gSystem->Load("StEEmcDbMaker");
  gSystem->Load("StEmcTriggerMaker");

  double pi = atan(1.0)*4.0;
  cout << " loading done " << endl;
  
  chain= new StChain("StChain"); 
  chain->SetDebug(1);
  gMessMgr->SwitchOff("D");
  gMessMgr->SwitchOff("I");
  
  StIOMaker* ioMaker = new StIOMaker();
  ioMaker->SetFile(fname);
  ioMaker->SetIOMode("r");
  ioMaker->SetBranch("*",0,"0");             //deactivate all branches
  ioMaker->SetBranch("geantBranch",0,"r");   //activate geant Branch

  class StMcEventMaker *mcEventMaker = new StMcEventMaker();
  mcEventMaker->doPrintEventInfo = false;
  mcEventMaker->doPrintMemoryInfo = false;
  
  StMuDebug::setLevel(1); 
  StMuDstMaker* muDstMaker = new StMuDstMaker(0,0,dir,file,filter,1e6,"MuDst");
 
  //Database -- get a real calibration from the database
  St_db_Maker* dbMk = new St_db_Maker("StarDb","MySQL:StarDb","MySQL:StarDb","$STAR/StarDb");
  dbMk->SetDateTime(20060506,214129 ); // for simulation
 
  //to use ideal ideal gains/status/calib uncommment correct line below
  //dbMk->SetFlavor("sim","bemcPed");
  //dbMk->SetFlavor("sim","bemcStatus");
  //dbMk->SetFlavor("sim","bemcCalib");
  //dbMk->SetFlavor("sim","bemcGain");
  //dbMk->SetFlavor("sim","eemcPMTcal");
  //dbMk->SetFlavor("sim","eemcPIXcal");

  chain->ls(3);
 //Database interface
  StDetectorDbMaker* detDbMk = new StDetectorDbMaker();

 //Endcap DB
  StEEmcDbMaker* eemcb = new StEEmcDbMaker("eemcDb");
  
  //StEmcADCtoEMaker *adc = new StEmcADCtoEMaker(); // this will just convert what's in MuDst to ADC, use for data only!
  StEmcSimulatorMaker* emcSim = new StEmcSimulatorMaker(); //use this instead to "redo" converstion from geant->adc
  emcSim->setCalibSpread(kBarrelEmcTowerId, 0.15);
  StPreEclMaker* preEcl = new StPreEclMaker(); //need this to fill new StEvent information
  
  //StEmcTrigger
  StEmcTriggerMaker *emcTrig = new StEmcTriggerMaker("bemctrigger");

  chain->Init();
  chain->PrintInfo();
  
  chain->ls(3);
  TChain* fileChain = muDstMaker->chain(); 


  int BL1_ADC[6];
  int hold=-1;
  for (Int_t iev=0;iev<nevents; iev++) {
    cout << "****************************************** " << endl;
    cout << "Working on eventNumber:\t" << iev <<"\tof:\t"<<nevents<<endl;
    cout << "*************************1***************** " << endl;
    chain->Clear();
    int iret = chain->Make(iev);
    total++;
    if (iret) {
      cout << "Bad return code!" << endl;
      break;
    }

    cout<<"           "<<endl;
    map<int,int>::iterator iter;
    map<int,int> tower;
    map<int,int> tpatch;
    map<int,int> jpatch;

    cout<<endl;
    cout<<endl;
    cout<<" 1101 ht1 = "<<emcTrig->isTrigger(1101)<<" = "<<emcTrig->is2003HT1()<<endl;    
    tower=emcTrig->barrelTowersAboveThreshold(1101);
    cout<<"Total #'s of towers="<<tower.size()<<endl;
    for ( iter=tower.begin();iter !=tower.end(); iter++){
      cout<<"tower id="<<iter->first<<"  adc="<<iter->second<<endl;
      cout<<"old tower id="<<emcTrig->get2003HT1_ID()<<" adc="<<emcTrig->get2003HT1_ADC()<<endl;
    }

    cout<<endl;
    cout<<endl;
    cout<<" 2101 ht1 = "<<emcTrig->isTrigger(2201)<<" = "<<emcTrig->is2003HT1()<<endl;   
    tower=emcTrig->barrelTowersAboveThreshold(2201);
    cout<<"Total #'s of towers="<<tower.size()<<endl;
    for ( iter=tower.begin();iter !=tower.end(); iter++){
      cout<<"tower id="<<iter->first<<"  adc="<<iter->second<<endl;
      cout<<"old tower id="<<emcTrig->get2003HT1_ID()<<" adc="<<emcTrig->get2003HT1_ADC()<<endl;
    }

    cout<<endl;
    cout<<endl;
    cout<<" 2202 ht2 = "<<emcTrig->isTrigger(2202)<<" = "<<emcTrig->is2003HT2()<<endl;   
    tower=emcTrig->barrelTowersAboveThreshold(2202);
    cout<<"Total #'s of towers="<<tower.size()<<endl;
    for ( iter=tower.begin();iter !=tower.end(); iter++){
      cout<<"tower id="<<iter->first<<"  adc="<<iter->second<<endl;
      cout<<"old tower id="<<emcTrig->get2003HT2_ID()<<" adc="<<emcTrig->get2003HT2_ADC()<<endl;
    }

    cout<<endl;
    cout<<endl;
    cout<<" 45201 ht1 = "<<emcTrig->isTrigger(45201)<<" =  "<<emcTrig->is2004HT1()<<endl;   
    tower=emcTrig->barrelTowersAboveThreshold(45201);
    cout<<"Total #'s of towers="<<tower.size()<<endl;
    for ( iter=tower.begin();iter !=tower.end(); iter++){
      cout<<"tower id="<<iter->first<<"  adc="<<iter->second<<endl;
      cout<<"old tower id="<<emcTrig->get2004HT1_ID()<<" adc="<<emcTrig->get2004HT1_ADC()<<endl;
    }

    cout<<endl;
    cout<<endl;
    cout<<" 45202 ht1 = "<<emcTrig->isTrigger(45202)<<" =  "<<emcTrig->is2004HT2()<<endl;   
    tower=emcTrig->barrelTowersAboveThreshold(45202);
    cout<<"Total #'s of towers="<<tower.size()<<endl;
    for ( iter=tower.begin();iter !=tower.end(); iter++){
      cout<<"tower id="<<iter->first<<"  adc="<<iter->second<<endl;
      cout<<"old tower id="<<emcTrig->get2004HT2_ID()<<" adc="<<emcTrig->get2004HT2_ADC()<<endl;
    }

    cout<<endl;
    cout<<endl;
    cout<<" 45206 jp1 = "<<emcTrig->isTrigger(45206)<<" =  "<<emcTrig->is2004JP1()<<endl;   
    jpatch=emcTrig->barrelJetPatchesAboveThreshold(45206);
    cout<<"Total #'s of jpatches="<<jpatch.size()<<endl;
    for ( iter=jpatch.begin();iter !=jpatch.end(); iter++){
      cout<<"jpatch id="<<iter->first<<"  adc="<<iter->second<<endl;
      cout<<"old patch id="<<emcTrig->get2004JP1_ID()<<" adc="<<emcTrig->get2004JP1_ADC()<<endl;
    }

    cout<<endl;
    cout<<endl;
    cout<<" 45207 jp2 = "<<emcTrig->isTrigger(45207)<<"  =  "<<emcTrig->is2004JP2()<<endl;   
    jpatch=emcTrig->barrelJetPatchesAboveThreshold(45207);
    cout<<"Total #'s of jpatches="<<jpatch.size()<<endl;
    for ( iter=jpatch.begin();iter !=jpatch.end(); iter++){
      cout<<"jpatch id="<<iter->first<<"  adc="<<iter->second<<endl;
      cout<<"old patch id="<<emcTrig->get2004JP2_ID()<<" adc="<<emcTrig->get2004JP2_ADC()<<endl;
    }

    cout<<endl;
    cout<<endl;
    cout<<" 127212 ht2 (matrix0)="<<emcTrig->isTrigger(127212)<<endl;
    tower=emcTrig->barrelTowersAboveThreshold(127212);
    cout<<"Total #'s of towers="<<tower.size()<<endl;
    for ( iter=tower.begin();iter !=tower.end(); iter++){
      cout<<"tower id="<<iter->first<<"  adc="<<iter->second<<endl;
    }

    cout<<endl;
    cout<<endl;
    cout<<" 127213 ht2 (matrix1)="<<emcTrig->isTrigger(127213)<<endl;
    tower=emcTrig->barrelTowersAboveThreshold(127213);
    cout<<"Total #'s of towers="<<tower.size()<<endl;
    for ( iter=tower.begin();iter !=tower.end(); iter++){
      cout<<"tower id="<<iter->first<<"  adc="<<iter->second<<endl;
    }

    cout<<endl;
    cout<<endl;
    cout<<" 137213 ht2 (matrix3) ="<<emcTrig->isTrigger(127213)<<endl;
    tower=emcTrig->barrelTowersAboveThreshold(127213);
    cout<<"Total #'s of towers="<<tower.size()<<endl;
    for ( iter=tower.begin();iter !=tower.end(); iter++){
      cout<<"tower id="<<iter->first<<"  adc="<<iter->second<<endl;
    }

    cout<<endl;
    cout<<endl;
    cout<<" 127501 jp0 (matrix1)="<<emcTrig->isTrigger(127501)<<endl;
    jpatch=emcTrig->barrelJetPatchesAboveThreshold(127501);
    cout<<"Total #'s of jpatches="<<jpatch.size()<<endl;
    for ( iter=jpatch.begin();iter !=jpatch.end(); iter++){
      cout<<"jpatch id="<<iter->first<<"  adc="<<iter->second<<endl;
    }

    cout<<endl;
    cout<<endl;
    cout<<" 137501 jp0 (matrix3) ="<<emcTrig->isTrigger(137501)<<endl;
    jpatch=emcTrig->barrelJetPatchesAboveThreshold(137501);
    cout<<"Total #'s of jpatches="<<jpatch.size()<<endl;
    for ( iter=jpatch.begin();iter !=jpatch.end(); iter++){
      cout<<"jpatch id="<<iter->first<<"  adc="<<iter->second<<endl;
    }

    cout<<endl;
    cout<<endl;
    cout<<" 127221 jp1 (matrix1)="<<emcTrig->isTrigger(127221)<<endl;
    jpatch=emcTrig->barrelJetPatchesAboveThreshold(127221);
    cout<<"Total #'s of jpatches="<<jpatch.size()<<endl;
    for ( iter=jpatch.begin();iter !=jpatch.end(); iter++){
      cout<<"jpatch id="<<iter->first<<"  adc="<<iter->second<<endl;
    }

    cout<<endl;
    cout<<endl;
    cout<<" 137221 jp1 (matrix2)="<<emcTrig->isTrigger(137221)<<endl;
    jpatch=emcTrig->barrelJetPatchesAboveThreshold(137221);
    cout<<"Total #'s of jpatches="<<jpatch.size()<<endl;
    for ( iter=jpatch.begin();iter !=jpatch.end(); iter++){
      cout<<"jpatch id="<<iter->first<<"  adc="<<iter->second<<endl;
    }

    cout<<endl;
    cout<<endl;
    cout<<" 137222 jp1 (matrix3)="<<emcTrig->isTrigger(137222)<<endl;
    jpatch=emcTrig->barrelJetPatchesAboveThreshold(127501);
    cout<<"Total #'s of jpatches="<<jpatch.size()<<endl;
    for ( iter=jpatch.begin();iter !=jpatch.end(); iter++){
      cout<<"jpatch id="<<iter->first<<"  adc="<<iter->second<<endl;
    }

    cout<<endl;
    cout<<endl;
    cout<<" 127821 http (matrix1)="<<emcTrig->isTrigger(127821)<<endl;
    tpatch=emcTrig->barrelTriggerPatchesAboveThreshold(127821);
    cout<<"Total #'s of tpatches="<<tpatch.size()<<endl;
    for ( iter=tpatch.begin();iter !=tpatch.end(); iter++){
      cout<<"tpatch id="<<iter->first<<"  adc="<<iter->second<<endl;
    }
    tower=emcTrig->barrelTowersAboveThreshold(127821);
    cout<<"Total #'s of towers="<<tower.size()<<endl;
    for ( iter=tower.begin();iter !=tower.end(); iter++){
        int triggerPatch = emcTrig->barrelTriggerPatchForTower(iter->first);
        cout<<"tower id="<<iter->first<<"  adc="<<iter->second<<"  tp (id,adc)=("<< triggerPatch << "," << tpatch[triggerPatch] << ")" <<endl;
    }

    cout<<endl;
    cout<<endl;
    cout<<" 137821 http (matrix3) ="<<emcTrig->isTrigger(137821)<<endl;
    tpatch=emcTrig->barrelTriggerPatchesAboveThreshold(137821);
    cout<<"Total #'s of tpatches="<<tpatch.size()<<endl;
    for ( iter=tpatch.begin();iter !=tpatch.end(); iter++){
      cout<<"tpatch id="<<iter->first<<"  adc="<<iter->second<<endl;
    }
    tower=emcTrig->barrelTowersAboveThreshold(137821);
    cout<<"Total #'s of towers="<<tower.size()<<endl;
    for ( iter=tower.begin();iter !=tower.end(); iter++){
        int triggerPatch = emcTrig->barrelTriggerPatchForTower(iter->first);
        cout<<"tower id="<<iter->first<<"  adc="<<iter->second<<"  tp (id,adc)=("<< triggerPatch << "," << tpatch[triggerPatch] << ")" <<endl;
    }

    cout<<endl;
    cout<<endl;
    cout<<" 137822 http (matrix4)="<<emcTrig->isTrigger(137822)<<endl;
    tpatch=emcTrig->barrelTriggerPatchesAboveThreshold(137822);
    cout<<"Total #'s of tpatches="<<tpatch.size()<<endl;
    for ( iter=tpatch.begin();iter !=tpatch.end(); iter++){
      cout<<"tpatch id="<<iter->first<<"  adc="<<iter->second<<endl;
    }  
    tower=emcTrig->barrelTowersAboveThreshold(137822);
    cout<<"Total #'s of towers="<<tower.size()<<endl;
    for ( iter=tower.begin();iter !=tower.end(); iter++){
        int triggerPatch = emcTrig->barrelTriggerPatchForTower(iter->first);
        cout<<"tower id="<<iter->first<<"  adc="<<iter->second<<"  tp (id,adc)=("<< triggerPatch << "," << tpatch[triggerPatch] << ")" <<endl;
    }

    cout<<endl;
    cout<<endl;
    cout<<" 117705 jpsi (matrix1)="<<emcTrig->isTrigger(117705)<<endl;
    tower=emcTrig->barrelTowersAboveThreshold(117705);
    cout<<"Total #'s of towers="<<tower.size()<<endl;
    for ( iter=tower.begin();iter !=tower.end(); iter++){
      cout<<"tower id="<<iter->first<<"  adc="<<iter->second<<endl;
    }

    cout<<endl;
    cout<<endl;
    cout<<" 117602 upsilon (matrix1)="<<emcTrig->isTrigger(117602)<<endl;
    tower=emcTrig->barrelTowersAboveThreshold(117602);
    cout<<"Total #'s of towers="<<tower.size()<<endl;
    for ( iter=tower.begin();iter !=tower.end(); iter++){
      cout<<"tower id="<<iter->first<<"  adc="<<iter->second<<endl;
    }

    cout<<endl;
    cout<<endl;
    cout<<" 137602 upsilon (matrix3)="<<emcTrig->isTrigger(137602)<<endl;
    tower=emcTrig->barrelTowersAboveThreshold(137602);
    cout<<"Total #'s of towers="<<tower.size()<<endl;
    for ( iter=tower.begin();iter !=tower.end(); iter++){
      cout<<"tower id="<<iter->first<<"  adc="<<iter->second<<endl;
    }


    cout<<endl;
    cout<<endl;
    cout<<" 127611 http-L2="<<emcTrig->isTrigger(127611)<<endl;
    
    cout<<endl;
    cout<<endl;
    cout<<" 127622 jp0-etot-L2="<<emcTrig->isTrigger(127622)<<endl;
 
    cout<<endl;
    cout<<endl;
    cout<<" 137622  jp0-etot-L2="<<emcTrig->isTrigger(137622)<<endl;

    for (int j=0;j<6;j++){
      BL1_ADC[j]=0.0;
      emcTrig->get2006BL1_ADC(j,&hold);
      BL1_ADC[j]=hold;
      cout<<" 2x1 Patch "<<j<<" = "<<BL1_ADC[j]<<endl;
    }
 

  }

  chain->Finish();
  cout << "****************************************** " << endl;
  cout << "total number of events  " << total << endl;
  cout << "****************************************** " << endl;
 
}
Esempio n. 14
0
void TestIOMaker(Int_t nevents=3,
		 //This file points to 30 events of 10 neg muons w/ pt=.9
		 const char* MainFile="/star/data22/ITTF/data/simple_geant/DEV_10_8_01/*.event.root")
		 //This file points to 5 muons /event
		 //const char* MainFile="/star/data22/ITTF/EvalData/MCNtuple/muon_100_neg.event.root")
    
		 //This file points to 110 events from mevsim (homebrew had. cocktail)
		 //const char* MainFile="/star/data22/ITTF/data/mevsim/10_9_01/*.event.root")
    
		 //This file points to a nightly low density hadronic cocktail reconstruction.
		 //const char* MainFile="/star/rcf/test/dev/trs_redhat61/Tue/year_2001/hc_lowdensity/*.event.root")
{    
    // Dynamically link needed shared libs
    cout <<"Loading St_base"<<endl;
    gSystem->Load("St_base");
    
    cout <<"Loading StChain"<<endl;
    gSystem->Load("StChain");
    
    cout <<"Loading St_Tables"<<endl;
    gSystem->Load("St_Tables");
    
    cout <<"Loading StUtilities"<<endl;
    gSystem->Load("StUtilities");
    
    cout <<"Loading StIOMaker"<<endl;
    gSystem->Load("StIOMaker");
    
    cout <<"Loading StarClassLibrary"<<endl;
    gSystem->Load("StarClassLibrary");
    
    cout <<"Loading DataBase"<<endl;
    gSystem->Load("StDbUtilities");
    gSystem->Load("StDbLib");
    gSystem->Load("StDbBroker");
    gSystem->Load("St_db_Maker");
    gSystem->Load("StTpcDb");
    
    cout <<"Loading StEvent"<<endl;
    gSystem->Load("StEvent");

    cout <<"Loading StEventMaker"<<endl;
    gSystem->Load("StEventMaker");

    cout <<"Loading StEmcUtil"<<endl;
    gSystem->Load("StEmcUtil");
    
    cout <<"Loading StMcEvent"<<endl;
    gSystem->Load("StMcEvent");

    cout <<"Loading StMcEventMaker"<<endl;
    gSystem->Load("StMcEventMaker");

    cout <<"Loading AssociationMaker"<<endl;
    gSystem->Load("StAssociationMaker");
    
    // create a new instance of the chain
    
    chain = new StChain("StChain"); 
    chain->SetDebug();
    
    // 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("dstBranch",0,"r");    //activate Event Branch
    ioMaker->SetBranch("runcoBranch",0,"r");  //activate runco Branch

    //Calibration Maker (StarDB,not a real Database!)
    const char* calibDB = "MySQL:StarDb";
    const char* paramsDB = "$STAR/StarDb";
    St_db_Maker* calibMk = new St_db_Maker("StarDb",calibDB,paramsDB);
    calibMk->SetDateTime("year_2b");
    //calibMk->SetDateTime("year_1h");
    calibMk->SetDebug();

    //Read Tpc Database access
    StTpcDbMaker *tpcDbMk = new StTpcDbMaker("tpcDb");

    //StEventMaker
    StEventMaker*       eventReader   = new StEventMaker("events","title");
    eventReader->doPrintEventInfo = 0;

    //StMcEventMaker
    StMcEventMaker* mcEventReader = new StMcEventMaker();
    
    //Association
    StAssociationMaker* assocMaker = new StAssociationMaker();
    
    cout <<"Calling Init() Methods "<<endl;
    chain->Init();
    
    cout <<"Starting Event Loop"<<endl;

    int istat=0,iev=1;
 EventLoop: if (iev<=nevents && !istat) {
     chain->Clear();
     cout << "---------------------- Processing Event : " << iev << endl;
     istat = chain->Make(iev);
     if (istat) {
	 cout << "Last Event Processed. Status = " << istat << endl;
     }
     iev++; goto EventLoop;
 }
    
    return;
}
Esempio n. 15
0
void DoEqualDaq(char* file="daq/*.daq",int nevents = 500000,char* name = "equal1.root")
{

    //
    // First load some shared libraries we need
    //
    gSystem->Load("St_base");
    gSystem->Load("StChain");
    gSystem->Load("libgen_Tables");
    gSystem->Load("libsim_Tables");
    gSystem->Load("libglobal_Tables");
    gSystem->Load("StUtilities");
    gSystem->Load("StIOMaker");
    gSystem->Load("StTreeMaker");
    gSystem->Load("StarClassLibrary");
    gSystem->Load("StEvent");
    gSystem->Load("StMagF");
    gSystem->Load("libgeometry_Tables");
    gSystem->Load("St_Tables");
    gSystem->Load("StEmcUtil");
  
    gROOT->LoadMacro("$STAR/StRoot/StMuDSTMaker/COMMON/macros/loadSharedLibraries.C");
    loadSharedLibraries();
    gSystem->Load("StDbUtilities");
    gSystem->Load("StDbLib");
    gSystem->Load("StDbBroker");
    gSystem->Load("St_db_Maker");
    gSystem->Load("libgeometry_Tables");
    gSystem->Load("StDaqLib");
    gSystem->Load("StEmcRawMaker");
    gSystem->Load("StEmcADCtoEMaker");
    gSystem->Load("StPreEclMaker");
    gSystem->Load("StEpcMaker");
		     
    gSystem->Load("StEmcCalibrationMaker");


    chain=new StChain("StChain"); 
    chain->SetDebug();
    
    //
    //  Setup IO maker
    //
    StIOMaker *IOMk = new StIOMaker();
    IOMk->SetFile(file);
    IOMk->SetIOMode("r");
    IOMk->SetBranch("*",0,"0");                 //deactivate all branches
    IOMk->SetBranch("daqBranch",0,"r");
    IOMk->SetDebug();
    
    St_db_Maker *db = new St_db_Maker("StarDb","MySQL:StarDb");

    m = new StEmcADCtoEMaker();
    m->saveAllStEvent(kTRUE);
    m->setPrint(kFALSE);

    // This process the EMC event and fill the tables
    // necessary for calibration
    StEmcCalibrationMaker *cal = new StEmcCalibrationMaker();
    char outfile[300];

    // does equalization
    sprintf(outfile,"/home/emc/online/emc/pedestal/equal/%s",name);
    StEmcEqualMaker *equal = new StEmcEqualMaker();
    equal->setFile(outfile);

    //
    // Initialize chain
    //

    Int_t iInit = chain->Init();
    if (iInit) chain->Fatal(iInit,"on init");
    chain->PrintInfo();
    
    int istat=0,i=1;
    
    
     EventLoop: if (i <= nevents && istat!=2) 
     {
       
       cout << endl << "============================ Event " << i<< " start ============================" << endl;
       
       chain->Clear();
       istat = chain->Make();
       
       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;
    
}
Esempio n. 16
0
void rdSt2print(Int_t nevents=100){

  char * fname="/star/data09/reco/ppProductionTrans/FullField/dev/2006/129/7129060/st_physics_7129060_raw_1030002.event.root";

  gROOT->LoadMacro("$STAR/StRoot/StMuDSTMaker/COMMON/macros/loadSharedLibraries.C");
  loadSharedLibraries();
  cout << " loading done " << endl;
     
  // Load my makers

  // create chain    
  chain = new StChain("bfc"); 
  //chain->SetDebug();
  
  // Now we add Makers to the chain...

  // StIOMaker - to read files ...
  StIOMaker* ioMaker = new StIOMaker();  
  //ioMaker->SetFile("photon_bemc.event.root"); 
  ioMaker->SetFile(fname); 
  //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 Event Branch
  ioMaker->SetIOMode("r"); 
 
  // StMcEventMaker
  // StMcEventMaker *mcEventMaker = new StMcEventMaker();

  // My Makers 
  //  StEmcTrigSimuMaker *myMk2=new StEmcTrigSimuMaker("eemcTrigMaker");

  // Now execute the chain Init functions
  chain->PrintInfo();
  chain->ls(3);
  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;

  // Do the event loop    
  while(iev<=nevents && istat!=2) {
    chain->Clear();
    cout << "---------------------- Processing Event : " << iev << " ----------------------" << endl;
    istat = chain->Make(iev); // This should call the Make() method in ALL makers
    iev++; 
    if (istat  == kStEOF || istat == kStFatal) break;
    
    StEvent* mEvent = (StEvent*)chain->GetInputDS("StEvent");
    assert(mEvent);// fix your chain or open the right event file
    
    int nV=mEvent->numberOfPrimaryVertices();
    if(nV==0) continue;
    int iv;
    printf("eveID=%d  nPrimVert=%d\n", mEvent->id(),nV);
    for(iv=0;iv<nV;iv++) {
      StPrimaryVertex *V=mEvent->primaryVertex(iv);
      assert(V);
      StThreeVectorF &r=V->position();
      StThreeVectorF &er=V->positionError();
      printf("iv=%d   Vz=%.2f +/-%.2f \n",iv,r.z(),er.z()  );
      printf("  nDaugh=%d , VFid=%d:: ntr=%d nCtb=%d nBemc=%d nEEmc=%d nTpc=%d sumPt=%.1f rank=%g xchi2=%g\n"
	     ,V->numberOfDaughters(), V->vertexFinderId() ,V->numTracksUsedInFinder()  ,V->numMatchesWithCTB()  ,V-> numMatchesWithBEMC() ,V->numMatchesWithEEMC()  ,V->numTracksCrossingCentralMembrane()  ,V->sumOfTrackPt()  ,V->ranking(), V->chiSquared());
    }
    
    
    StEmcCollection* emcC =(StEmcCollection*)mEvent->emcCollection(); assert(emcC);
    
    //................... print Endcap hits in StEvent
    // printETOW(emcC->detector(13));
    //    printEPRE(emcC->detector(14));
    //printESMD(emcC->detector(15));
    //     printESMD(emcC->detector(16));
    
    // printRaw(emcC->eemcRawData());
    
    //................... print Barrel hits in StEvent
    printRawBEMC(emcC->bemcRawData());
    
  } // Event Loop
  chain->Finish();
  //    delete myMk2;
   
    
}
Esempio n. 17
0
void DoFeeTTreeSimu(Int_t nevents=100){
  //char *fname="/star/data22/MC/balewski/pp4run3/minb200-10k.event.root";
char *fname="minb200-100.event.root";
char *fileT="myFeeMC-minb200-100.root"; // output TTree

  //
  // First load some shared libraries we need
  //    
  gSystem->Load("St_base");
  gSystem->Load("StChain");
  gSystem->Load("libglobal_Tables");
  gSystem->Load("libsim_Tables");
  gSystem->Load("libgen_Tables");
  gSystem->Load("St_Tables");
  gSystem->Load("StDbLib");
  gSystem->Load("StDbBroker");
  gSystem->Load("St_db_Maker"); 
  gSystem->Load("StUtilities");
  gSystem->Load("StIOMaker");
  gSystem->Load("StMagF");
  gSystem->Load("StarClassLibrary");
  gSystem->Load("StAnalysisUtilities");
  gSystem->Load("StEvent");
  gSystem->Load("StTpcDb"); 
  gSystem->Load("StEventMaker"); 
  gSystem->Load("StMcEvent");
  gSystem->Load("StMcEventMaker");
  gSystem->Load("libgeometry_Tables");
  gSystem->Load("StEmcUtil");    
     
if (0){
    cout << " StDBLib mode enabled" << endl;
    gSystem->Load("StDbLib");
    gSystem->Load("StDbBroker");
    gSystem->Load("St_db_Maker");
  }

  // Load my makers
  gSystem->Load("EEmc");
  gSystem->Load("EEfeeRaw");
  gSystem->Load("SteemcDb");
  
  // create chain    
  chain = new StChain("bfc"); 
  //chain->SetDebug();
  
  // Now we add Makers to the chain...

  // StIOMaker - to read files ...
  StIOMaker* ioMaker = new StIOMaker();  
  ioMaker->SetFile(fname); 
  //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 Event Branch
  ioMaker->SetIOMode("r"); 
 
  // StMcEventMaker
  StMcEventMaker *mcEventMaker = new StMcEventMaker();
  
 // My Makers  1
  SteemcDbMaker  *myMk1=new SteemcDbMaker("eemcDBio");
  myMk1->setSectors(1,12);
  myMk1->setTimeStampDay(20021215);  // format: yyyymmdd


  St_db_Maker *dbMk = new St_db_Maker("StarDb","MySQL:StarDb");

  // My Makers  2 
  St2eemcFeeRawMaker * myMk3=new St2eemcFeeRawMaker("St2feeTTree");
//  myMk3->setDb(myMk1);
  
  // Output TTree
  TFile f(fileT,"RECREATE");
  TTree t("fee","A tree with FEE events"); // define branch
  myMk3->setOutTTree(&t);

  // Now execute the chain Init functions
  chain->PrintInfo();
  chain->ls(3);
  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;

  // Do the event loop    
  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
    chain->Finish();
    t.Print();
    
    f.Write();
    printf("\n\n============== TTree closed =========\n\n");
  
    delete myMk3;
    // delete myMk2;
    delete myMk1;

    
}
Esempio n. 18
0
void doEventsQQ(const Int_t nevents=999,
              const Char_t **fileList)
{

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

  gSystem->Load("libgen_Tables");
  gSystem->Load("libsim_Tables");
  gSystem->Load("libglobal_Tables");

  gSystem->Load("StUtilities");
  gSystem->Load("StIOMaker");
  gSystem->Load("StarClassLibrary");
  gSystem->Load("StarMagField");
  gSystem->Load("StMagF");
  gSystem->Load("StEvent");
  gSystem->Load("StDetectorDbMaker");
  gSystem->Load("StTpcDb");
  gSystem->Load("StEventMaker");
  gSystem->Load("St_geom_Maker");
  gSystem->Load("StEventDisplayMaker");


  // Handling depends on whether file is a ROOT file or XDF file

  chain  = new StChain("StChain");

  StFile *setFiles= new StFile();

  for (int ifil=0; fileList[ifil]; ifil++)
  { setFiles->AddFile(fileList[ifil]);}
  
  St_geom_Maker *geom = new St_geom_Maker; // this maker open its own TFile !!!
  StIOMaker *IOMk     = new StIOMaker("IO","r",setFiles,"bfcTree");
  IOMk->SetDebug();

// 		Maker to read events from file or database into StEvent
  StEventMaker *readerMaker =  new StEventMaker ("events","title");
// 		Sample analysis maker
//  StAnalysisMaker *analysisMaker = new  StAnalysisMaker("analysis");
  disp      = new StEventDisplayMaker;
  disp->SetDebug();
  // Create an user's custom filter for "Tracks" 
  St_TLA_EventFilter *trackFilter = new St_TLA_EventFilter();
  disp->SetFilter(trackFilter,StEventDisplayMaker::kTrack);
  

  // Initialize chain
  Int_t iInit = chain->Init();
  if (iInit) chain->Fatal(iInit,"on init");
  chain->PrintInfo();
//  chain->MakeDoc();

  // Event loop
  int istat;
  for (Int_t i=1; i<=nevents; i++) {
    cout << "============================ Event " << i << " start" << endl;
    chain->Clear();
    istat = chain->Make(i);
    if (istat) {
      cout << "Last event processed. Status = " << istat << endl;
      chain->Clear();
      break;
    }
    St_DataSet *set = chain->DataSet("dst");
    if (set)  {
      St_DataSetIter dirt(set);
      dirt.Du();
    }
    cout << "============================ Event " << i << " finish" << endl;
  }

   gROOT->LoadMacro("PadControlPanel.C");
}
Esempio n. 19
0
// ------------------ Here is the actual method -----------------------------------------
void RunStiMaker(Int_t nevents, const Char_t **fileList, const Char_t *qaflag, const Int_t wrStEOut)
{
    Int_t theRunNumber=0;
    bool simulated = true;
    bool doFit = false;
    bool optimized = false;
    char* outfile = "Evaluation.root";
    
    cout <<  endl << endl <<" doEvents -  input # events = " << nevents << endl;
    Int_t ilist=0;
    while(fileList[ilist]){ 
	cout << " doEvents -  input fileList = " << fileList[ilist] << endl;
	ilist++; 
    }
    cout << " doEvents -  input qaflag   = " << qaflag << endl;
    cout << " doEvents -  input wrStEOut = " << wrStEOut << endl << endl << endl;
 
    //
    // First load some shared libraries we need
    //

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

    gSystem->Load("libgen_Tables");
    gSystem->Load("libsim_Tables");
    gSystem->Load("libglobal_Tables");
    gSystem->Load("geometry");

    gSystem->Load("St_g2t");
    gSystem->Load("St_geant_Maker");

    gSystem->Load("StIOMaker");
    gSystem->Load("StTreeMaker");
    gSystem->Load("StarClassLibrary");

    gSystem->Load("St_db_Maker");
    gSystem->Load("StDbLib");
    gSystem->Load("StDbBroker");
    gSystem->Load("StSvtDbMaker");
    gSystem->Load("StDbUtilities");
    gSystem->Load("StTpcDb");
    gSystem->Load("StEvent");
    gSystem->Load("StEventMaker");
    gSystem->Load("StEmcUtil"); 
    gSystem->Load("StMcEvent");
    gSystem->Load("StMcEventMaker");
    gSystem->Load("StAssociationMaker");
    gSystem->Load("StDaqLib");
    gSystem->Load("StDAQMaker");

    gSystem->Load("StSvtClassLibrary");
    gSystem->Load("StSvtDaqMaker");
    gSystem->Load("StSvtSimulationMaker");
    gSystem->Load("StSvtCalibMaker");
    gSystem->Load("StSvtSeqAdjMaker");
    //gSystem->Load("StSvtEvalMaker");
    gSystem->Load("StSvtClusterMaker");

    //cout <<"Loading StMcEventMaker"<<endl;
    //gSystem->Load("StMcEventMaker");

    //cout <<"Loading AssociationMaker"<<endl;
    //gSystem->Load("StAssociationMaker");

    cout <<"Loading Sti"<<endl;
    gSystem->Load("Sti");
    
    cout <<"Loading StiGui"<<endl;
    gSystem->Load("StiGui");
    
    cout <<"Loading StiEvaluator"<<endl;
    gSystem->Load("StiEvaluator");

    cout <<"Loading libGui"<<endl;
    gSystem->Load("libGui");
    
    cout <<"Loading StiMaker"<<endl;
    gSystem->Load("StiMaker");

    cout <<"Loading StItTestMaker"<<endl;
    gSystem->Load("StItTestMaker");
    //
    // Handling depends on whether file is a ROOT file or XDF file
    //
    chain  = new StChain("StChain");

    StFileI *setFiles =0;
    if (fileList) {	//Normal case
	setFiles= new StFile(fileList);
    } else        {	//Grand Challenge
	gSystem->Load("StChallenger");
	setFiles = StChallenger::Challenge();
	setFiles->SetDebug();
	const char *Argv[]= {
	    "-s","daq",                           // list of components needed
	    "-q","mRunNumber=1228023",   // example of user query
	    "-c","/afs/rhic.bnl.gov/star/incoming/GCA/daq/stacs.rc"  // pointer to GC servers for daq
        };
	Int_t Argc=sizeof(Argv)/4;
	setFiles->Init(Argc,Argv);
    }

    StIOMaker *IOMk = new StIOMaker("inputStream","r",setFiles);
    //IOMk->SetBranch("*",0,"0");	//deactivate all branches
    //IOMk->SetBranch("dstBranch",0,"r");
    //IOMk->SetBranch("runcoBranch",0,"r");
    IOMk->SetBranch("eventBranch",0,"r");
    if (simulated) { //addded by MLM
	IOMk->SetBranch("geantBranch",0,"r");
    }
    IOMk->SetDebug();

    St_geant_Maker       *geantMk  = new St_geant_Maker("geant");
    geantMk->SetActive(kFALSE);

    //
    // Maker to read events from file or database into StEvent
    //
    //StEventMaker *readerMaker =  new StEventMaker("events","title");

    //
    // DB maker
    //       
    // dbaseMk = new St_db_Maker("svt","$PWD/svtcvs/StarDb");
    //dbaseMk = new St_db_Maker("db","StarDb");
    dbaseMk = new St_db_Maker("db","MySQL:StarDb","$STAR/StarDb");
    //dbaseMk->SetDateTime("year_1h");
    //dbaseMk->SetDateTime("year_2a");
    dbaseMk-> SetDateTime(20010801,000000);  

    //
    // TPC Db maker
    // 
    tpcDbMk  = new StTpcDbMaker("tpcDb");

    //
    // SVT Db maker
    // 
    svtDbMk  = new StSvtDbMaker("svtDb");

    //StMcEventMaker
    StMcEventMaker* mcEventReader = 0;
    //Association
    StAssociationMaker* assocMaker = 0;
  
    if (simulated) {
	mcEventReader = new StMcEventMaker();
	assocMaker = new StAssociationMaker();
    }
  
    //StiMaker
    StiMaker* anaMk = StiMaker::instance();
  
    cout <<"\n --- Setup StiIOBroker ---\n"<<endl;

    //StiIOBroker
    StiRootIOBroker* stiIO = new StiRootIOBroker();

    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(kFitPointRatioFilter);
    //stiIO->setFilterFitPointRatioMin(.5);
    
    stiIO->addFilterType(kPrimaryDcaFilter);
    stiIO->setFilterPrimaryDcaMax(100.);
        
    stiIO->setSimulated(simulated);
    anaMk->setEvaluationFileName(outfile);
  
    if (simulated) {
	anaMk->setMcEventMaker(mcEventReader);
	anaMk->setAssociationMaker(assocMaker);
    }
  
    //Make Control Window if not batch
    MainFrame* sti=0;
    StiGuiIOBroker* guiIO=0;
    
    if (gROOT->IsBatch()==false) {
	
	cout <<"No batch option detected.  Run Integrated Tracker in Gui Mode."<<endl;
	
	sti = new MainFrame(gClient->GetRoot(), 400, 220);
	
	sti->setStChain(chain);
	sti->setIoMaker(IOMk);
	
	//we're in batch mode
	stiIO->setUseGui(true);
	
	//Maker io gateway
	guiIO = StiGuiIOBroker::instance();
	
	//Values for hits not assigned to tracks
	guiIO->setUnMarkedHitSize(.3);
	guiIO->setUnMarkedHitColor(4);
	guiIO->setUnMarkedHitStyle(8);
	guiIO->setUpdateEachTrack(false);
	
	//Values for hits assigned to tracks
	guiIO->setMarkedHitSize(.3);
	guiIO->setMarkedHitColor(2);
	guiIO->setMarkedHitStyle(3);
    }
    else {
	cout <<"Batch option detector.  Run Integrated Tracker in non-Gui Mode."<<endl;
	stiIO->setUseGui(false);
    }

    cout <<"\n --- Done setting up StiIOBroker --- \n"<<endl;
    
    // WriteOut StEvent
    if (wrStEOut) {
	cout << "!!!! doEvents: will write out .event.root file !!" << endl << endl;
	StIOMaker *outMk = new StIOMaker("EvOut","w","test.event.root","bfcTree");
	//        outMk->SetBranch("eventBranch","test.event.root","w");
	outMk->IntoBranch("evtselBranch","StEvent");
	IOMk->SetNotify("CloseFile",outMk);
	IOMk->SetNotify("OpenFile" ,outMk);
    }


    //
    // test the Ittf tracks in StEvent
    //
    StItTestMaker* itTest = new StItTestMaker("StItTestMaker");
    
    /*
      dbaseMk->Init();
      svtDbMk->setSvtDb_Reader();
      dbaseMk->Make();
      svtDbMk->readSvtConfig();
      svtDbMk->readSvtGeometry();
    */
    
    //
    // Initialize chain
    //

    Int_t iInit = chain->Init();
    if (iInit) chain->Fatal(iInit,"on init");
    //chain->PrintInfo();
    chain->InitRun(theRunNumber);

    //
    // 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;
 }

    //chain->Finish();

    i--;
    cout << endl << "============================ Event " << i
	 << " finish ============================" << endl;

}
Esempio n. 20
0
void rdMu2TrigSimu(char *file="/star/data47/reco/pp200/pythia6_410/9_11gev/cdf_a/y2006c/gheisha_on/p07ic/rcf1309_*_2000evts.MuDst.root"){
  
  int nevents = 200;
  int flagMC=1;  // 0/1 == Using Real/Simulation data files 
  int useEemc=1; // 0/1 == Exclude/Include EEMC in Trigger Decisions 
  int useBemc=1; // 0/1 == Exclude/Include BEMC in Trigger Decisions 
  int useL2=1;   // 0/1 == Exclude/Include L2 in Trigger Decisions 
  int L2ConfigYear=2006; // possible: 2006, 2008
  int bemcConfig=2; // Online==1, Offline==2, Expert==3
  int playConfig=0; // jan:100_199
  int emcEveDump=0; // extrating raw EMC data in a custom format
  int outputL2Histo=0;//output L2 histos to directory outL2
  TString outDir="./outL2/"; 


  gROOT->LoadMacro("$STAR/StRoot/StMuDSTMaker/COMMON/macros/loadSharedLibraries.C");
  loadSharedLibraries();
  assert( !gSystem->Load("StDetectorDbMaker"));
  assert( !gSystem->Load("StDbUtilities"));
  assert( !gSystem->Load("StDbBroker"));
  assert( !gSystem->Load("St_db_Maker"));
  assert( !gSystem->Load("StEEmcUtil")); // needed by eemcDb
  assert( !gSystem->Load("StEEmcDbMaker"));
  assert( !gSystem->Load("StDaqLib")); // needed by bemcDb
  assert( !gSystem->Load("StEmcRawMaker"));
  assert( !gSystem->Load("StEmcADCtoEMaker"));
  if (flagMC) {
    assert( !gSystem->Load("StMcEvent"));
    assert( !gSystem->Load("StMcEventMaker"));
    assert( !gSystem->Load("StEmcSimulatorMaker"));
    assert( !gSystem->Load("StEEmcSimulatorMaker"));
    assert( !gSystem->Load("StEpcMaker"));
  }
  assert( !gSystem->Load("StTriggerUtilities"));

  gROOT->Macro("LoadLogger.C");
  cout << " loading done " << endl;
  
  chain= new StChain("StChain"); 

  if (flagMC){
    TString geantFile;
    geantFile += file;
    geantFile.ReplaceAll("MuDst.root", "geant.root");
    printf("geantFile=%s\n", geantFile.Data());
    StIOMaker* ioMaker = new StIOMaker();
    ioMaker->SetFile(geantFile);
    ioMaker->SetIOMode("r");
    ioMaker->SetBranch("*",0,"0");             //deactivate all branches
    ioMaker->SetBranch("geantBranch",0,"r");   //activate geant Branch
    StMcEventMaker *evtMaker = new StMcEventMaker();
  }

  //Need MuDstMaker to get data
  printf(" Analyzing file=%s\n",file);  
  StMuDstMaker* muDstMaker =new StMuDstMaker(0,0,"",file,"",1000);

  //Database -- get a real calibration from the database
  St_db_Maker* dbMk =0;
  if(useEemc || useL2) // full DB access
    dbMk = new St_db_Maker("StarDb","MySQL:StarDb","MySQL:StarDb","$STAR/StarDb");
  else // only Barrel is uploaded, is faster 
    dbMk  = new St_db_Maker("Calibrations","MySQL:Calibrations_emc");

    
  //If MC then must set database time and date
  //If Endcap fast simu is used tower gains in DB do not matter,JB
  if (flagMC) dbMk->SetDateTime(20060522, 55000);//timestamp R7142018
  
  //Collect all output histograms 
  TObjArray* HList=new TObjArray; 
  
  //Endcap DB
  if(useEemc || useL2) new StEEmcDbMaker("eemcDb");
  

  //Get BEMC adc values
  if (flagMC && useBemc) {
    StEmcSimulatorMaker* emcSim = new StEmcSimulatorMaker(); //use this instead to "redo" converstion from geant->adc
    if (bemcConfig == 1) {
        emcSim->setCheckStatus(kBarrelEmcTowerId,false); //this returns hits regardless of offline tower status
    }
    emcSim->setCalibSpread(kBarrelEmcTowerId,0.15);//spread gains by 15%
  }
  if (flagMC==0 && useBemc){
    StEmcADCtoEMaker *bemcAdc = new StEmcADCtoEMaker();//for real data this sets calibration and status
    if (bemcConfig == 1) {
        bemcAdc->setCheckStatus(kBarrelEmcTowerId,false);
    }
  }

  //must use slow simulator to get pedestals correct for L2
  if (flagMC==1 && useEemc){
    StEEmcSlowMaker *slowSim = new StEEmcSlowMaker("slowSim");
    slowSim->setSamplingFraction(0.0384); // effectively scales all Tower energies with a factor of 1.3 (added by: Ilya Selyuzhenkov; April 11, 2008)
    slowSim->setAddPed(true);
    slowSim->setSmearPed(true);
  }
 
  //Get TriggerMaker
  StTriggerSimuMaker *simuTrig = new StTriggerSimuMaker("StarTrigSimu");
  simuTrig->setHList(HList);
  simuTrig->setMC(flagMC); // must be before individual detectors, to be passed
  simuTrig->useBbc();
  if(useEemc) {
    simuTrig->useEemc(0);//default=0:just process ADC, 1,2:comp w/trgData,see .
    simuTrig->eemc->setSetupPath(eemcSetupPath);
  } 
  if(useBemc){
    simuTrig->useBemc();
    simuTrig->bemc->setConfig(bemcConfig);
  }

  if(flagMC && useEemc==2){
    // pass one argument to M-C as generic switch    
    // Endcap specific params -- ok Jan you need to change this to a default "online" setup
    int eemcDsmSetup[20]; // see StEemcTriggerSimu::initRun() for definition
    memset(eemcDsmSetup, 0,sizeof(eemcDsmSetup));// clear all, may be a bad default
    eemcDsmSetup[0]=3;  // HTthr0
    eemcDsmSetup[1]=12; // HTthr1
    eemcDsmSetup[2]=22; // HTthr2
    eemcDsmSetup[3]=1;  // TPthr0
    eemcDsmSetup[4]=17; // TPthr1
    eemcDsmSetup[5]=31; // TPthr2
    eemcDsmSetup[10]=2; //HTTPthrSelc, 2=use_thres_#1
    simuTrig->eemc->setDsmSetup(eemcDsmSetup);    
  }


  if(useL2) {
    /* 
       reads all input/setup files from  L2setup-yyyymmdd/
       writes all output files to L2out-yyyymmdd 
       depending on the DB time stamp 
       both dierectiorie MUST exist, setup must be reasonable
    */
    StGenericL2Emulator* simL2Mk=0;
    if(L2ConfigYear==2006) simL2Mk= new StL2_2006EmulatorMaker;
    else if(L2ConfigYear==2008) simL2Mk= new StL2_2008EmulatorMaker;
    assert(simL2Mk);
    simL2Mk->setSetupPath(eemcSetupPath);
    simL2Mk->setOutPath(outDir.Data());
    if (flagMC) simL2Mk->setMC();
    simuTrig->useL2(simL2Mk);
  }

  
  //if(emcEveDump) new StJanEventMaker;
    
  StTriggerSimuPlayMaker *playMk= new StTriggerSimuPlayMaker; // to develope user  analysis of trigQA 
  playMk->setConfig(playConfig);
  playMk->setHList(HList);
  
  
  chain->ls(3);
  chain->Init();
 
  for (Int_t iev=0;iev<nevents; iev++) {
    cout << "\n****************************************** " << endl;
    cout << "Working on eventNumber:\t" << iev <<"\tof:\t"<<nevents<<endl;
    cout << "****************************************** " << endl;
    chain->Clear();
    int iret = chain->Make(iev);
    total++;   
    if (iret % 10 == kStEOF || iret % 10 == kStFatal)  {
      cout << "Bad return code!" << endl;
      break;
    }

    int trigID[3]={127213,117211,137611};
    StMuDst *muDst = muDstMaker->muDst();
    StMuEvent *muEvent = muDst->event();    
    StMuTriggerIdCollection trig = muEvent -> triggerIdCollection();
    StTriggerId l1trig = trig.nominal();
    if( l1trig.isTrigger(trigID[0])) {
      cout<<" SimuTrigger 127213 ="<<simuTrig->isTrigger(trigID[0])<<" BEMC="<<simuTrig->bemc->triggerDecision(trigID[0])<<" L2="<<simuTrig->lTwo->triggerDecision(trigID[0])<<endl;
     }
    if( l1trig.isTrigger(trigID[1])) {
      cout<<" SimuTrigger 117211 ="<<simuTrig->isTrigger(trigID[1])<<" BEMC="<<simuTrig->bemc->triggerDecision(trigID[1])<<" L2="<<simuTrig->lTwo->triggerDecision(trigID[1])<<endl;
     }
    if( l1trig.isTrigger(trigID[2])) {
      cout<<" SimuTrigger 137611 ="<<simuTrig->isTrigger(trigID[2])<<" BEMC="<<simuTrig->bemc->triggerDecision(trigID[2])<<" L2="<<simuTrig->lTwo->triggerDecision(trigID[2])<<endl;
    }

    
    StTriggerSimuResult trigResult = simuTrig->detailedResult(trigID[2]);
    if (trigResult.bemcDecision()==1){
       vector<short> towerId = trigResult.highTowerIds();
      for (unsigned i=0; i<towerId.size(); i++) {
      	cout<<" LO Trigger BEMC Tower="<<towerId[i]<<" adc="<<trigResult.highTowerAdc(towerId[i])<<endl;
      }
    }


   if (trigResult.l2Decision()==1){
       vector<short> towerId = trigResult.highTowerIds();
      for (unsigned i=0; i<towerId.size(); i++) {
      	cout<<" L2 Trigger BEMC Tower="<<towerId[i]<<" adc="<<trigResult.highTowerAdc(towerId[i])<<endl;
      }
    }
 
  }

 
  chain->Finish();
  cout << "****************************************** " << endl;
  cout << "total number of events  " << total << endl;
  cout << "****************************************** " << endl;


  if (outputL2Histo==1) {
  
    TString fileMu=file;
    printf("=%s=\n",fileMu.Data());
    if(fileMu.Contains(".lis")) fileMu.ReplaceAll(".lis",".trgSim");
    if(fileMu.Contains(".MuDst.root")) fileMu.ReplaceAll(".MuDst.root",".trgSim");
    TString outF=outDir+fileMu;
    outF+=".hist.root";
    printf("=%s=\n",outF.Data());
    hf=new TFile(outF,"recreate");
    if(hf->IsOpen()) {
      HList->Write();
      printf("\n Histo saved -->%s<\n",outF.Data());
    } 
    else {
      printf("\n Failed to open Histo-file -->%s<, continue\n",outF.Data());
    }
  }
  
  //cout <<Form("sorting done %d of   nEve=%d, CPU rate=%.1f Hz, total time %.1f minute(s) \n\n",total,nEntries,rate,tMnt)<<endl;
 
}
Esempio n. 21
0
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
}
Esempio n. 22
0
/**
 * This is an alternative to bfcMixer_pythia() allowing the user to explicitly
 * specify BFC options for all three chains.
 *
 * Sample input values:
 *
 * daqFileList = "@run10148002.list"
 * fzdFile     = "/path/to/my_pythia.fzd"
 * flag        = "W"
 *
 */
void EmbeddingReco(const int nEvents, const std::string daqFileList, const std::string fzdFile,
   const std::string bfcOptionsChain1, const std::string bfcOptionsChain2, const std::string bfcOptionsChain3,
   const std::string flag)
{
   // Dynamically link some shared libs
   gROOT->LoadMacro("bfc.C");

   if (gClassTable->GetID("StBFChain") < 0) Load();

   //______________Create the main chain object______________________________________
   Chain = new StChain("Embedding");
   //________________________________________________________________________________
   bfc(-1, bfcOptionsChain1.c_str(), daqFileList.c_str());
   chain1 = chain;
   chain1->SetName("One");
   chain1->SetAttr(".call", "SetActive(0)", "St_db_Maker::"); // Use DB cache to reduce overhead
   Chain->cd();
   //________________________________________________________________________________
   bfc(-1, bfcOptionsChain2.c_str(), fzdFile.c_str());
   chain2 = chain;
   chain2->SetName("Two");
   Chain->cd();

   if (chain2->GetOption("TRS")) {
      StTrsMaker *trsMk = (StTrsMaker *) chain2->GetMaker("Trs");

      if (!trsMk) {
         cout << "Cannot find Trs in chain2" << endl;
         return;
      }

      trsMk->setNormalFactor(1.32);
      trsMk->SetMode(0);
   }

   //________________________________________________________________________________
   //  gSystem->Load("StFtpcMixerMaker");
   //  StFtpcMixerMaker  *ftpcmixer = new StFtpcMixerMaker("FtpcMixer","daq","trs");
   //________________________________________________________________________________
   TString OutputFileName(gSystem->BaseName(fzdFile.c_str()));
   OutputFileName.ReplaceAll("*", "");
   OutputFileName.ReplaceAll(".fzd", "");
   //  OutputFileName.Append("_emb.root");
   OutputFileName.Append(".root");
   bfc(-1, bfcOptionsChain3.c_str(), 0, OutputFileName);
   chain3 = chain;
   chain3->SetName("Three");
   Chain->cd();
   //________________________________________________________________________________
   StTpcMixerMaker  *mixer = (StTpcMixerMaker *) chain3->Maker("TpcMixer");

   mixer->SetInput("Input1", "TpxRaw/.data/Event");

	if (bfcOptionsChain2.find("TpcRS") != std::string::npos) {
      mixer->SetInput("Input2", "TpcRS/Event");
   }
   else {
      mixer->SetInput("Input2", "Trs/.const/Event");
   }

   Chain->cd();

   if (flag == "W") {
      // blacklist some detectors to save DB load
      St_db_Maker *dbMk = (St_db_Maker *)chain3->GetMaker("db");
      dbMk->SetAttr("blacklist", "svt");
      dbMk->SetAttr("blacklist", "ssd");
      //  dbMk->SetAttr("blacklist", "ftpc"); // S.F.
   }

   //------------------------------------ EMC MIXERS ------------------------------------
   // Add BEMC mixer to chain3
   StEmcRawMaker *emcRaw = (StEmcRawMaker *)chain3->GetMaker("emcRaw");
   emcRaw->getBemcRaw()->saveAllStEvent(true); // use all 4800 BEMC towers
   gSystem->Load("StEmcMixerMaker");
   StEmcMixerMaker *bemcMixer = new StEmcMixerMaker;
   chain3->AddAfter("EmcSimulator", bemcMixer);
   // Set EEMC fast and slow simulator in embedding mode
   StEEmcFastMaker *eefs = (StEEmcFastMaker *)chain3->GetMaker("eefs");
   eefs->SetEmbeddingMode(); // Use local StEmcCollection
   eefs->UseFullTower(true); // Use full ETOW detector
   StEEmcSlowMaker *eess = new StEEmcSlowMaker;
   eess->setEmbeddingMode(true);
   // Add EEMC mixer to chain3
   StEEmcMixerMaker *eemcMixer = new StEEmcMixerMaker;
   //------------------------------------------------------------------------------------

   //----------------------------- TRIGGER FILTER -----------------------------
   // We want to achieve the following ordering for makers:
   // 1. BBC simulator
   // 2. BEMC simulator
   // 3. BEMC mixer
   // 4. EEMC fast simulator
   // 5. EEMC slow simulator
   // 6. EEMC mixer
   // 7. Pythia event maker
   // 8. Trigger simulator
   // 9. Trigger filter
   // 10. TPC maker

   // Place TPC chain after EMC makers
   chain3->AddAfter("eefs", chain3->GetMaker("tpcChain"));
   chain3->AddAfter("eefs", eemcMixer);
   chain3->AddAfter("eefs", eess);

   if (flag == "Jet") {
      // Place Pythia maker after GEANT maker
      // and trigger filter after EMC makers
      gSystem->Load("StJetSkimEvent");
      gSystem->Load("StMCAsymMaker");
      gSystem->Load("StBfcTriggerFilterMaker");

      StPythiaEventMaker *pythia = new StPythiaEventMaker;
      TString pyfile = gSystem->BaseName(fzdFile.c_str());
      pyfile.ReplaceAll(".fzd", ".pythia.root");
      pythia->SetPythiaFile(pyfile);
      chain3->AddAfter("geant", pythia);

      // Place trigger simulator after EMC makers
      gSystem->Load("StTriggerUtilities");
      StTriggerSimuMaker *trgsim = new StTriggerSimuMaker;
      trgsim->setMC(1);
      // BBC was not used in Run 9 jet triggers
      //trgsim->useBbc();
      //trgsim->bbc->setSource("StEvent");
      trgsim->useBemc();
      trgsim->bemc->setConfig(StBemcTriggerSimu::kOnline);
      trgsim->useEemc();
      trgsim->eemc->setSource("StEvent");

      /*
      trgsim->bemc->setBarrelJetPatchTh0(32);
      trgsim->bemc->setBarrelJetPatchTh1(43);
      trgsim->bemc->setBarrelJetPatchTh2(64);
      */
      trgsim->setBarrelJetPatchTh(0, 32); // set for Run-11 based on trigger versioning page 20130728
      trgsim->setBarrelJetPatchTh(1, 43);
      trgsim->setBarrelJetPatchTh(2, 64);

      trgsim->setOverlapJetPatchTh(0, 32);
      trgsim->setOverlapJetPatchTh(1, 43);
      trgsim->setOverlapJetPatchTh(2, 64);

      trgsim->setEndcapJetPatchTh(0, 32);
      trgsim->setEndcapJetPatchTh(1, 43);
      trgsim->setEndcapJetPatchTh(2, 64);

      trgsim->setBarrelHighTowerTh(0, 11);
      trgsim->setBarrelHighTowerTh(1, 18);
      trgsim->setBarrelHighTowerTh(2, 25);
      trgsim->setBarrelHighTowerTh(3, 31);

      trgsim->setEndcapHighTowerTh(0, 25);
      trgsim->setEndcapHighTowerTh(1, 31);

      //  StBfcTriggerFilterMaker* trgfilt = new StBfcTriggerFilterMaker;
      // no trigger filter for Run-11 VPDMB
      //  trgfilt->SetOkAllEvents(1);
      // The BFC trigger filter will select only JP1, AJP and BHT3 events
      //  trgfilt->SetJP1();
      //  trgfilt->SetAJP();
      //  trgfilt->SetBHT3();

      // Lower all jet patch thresholds by one unit from
      // their values obtained from the database using
      // the current timestamp.
      //trgfilt->changeJPThresh(-1);
      chain3->AddBefore("tpcChain", trgsim);
      //  chain3->AddBefore("tpcChain",trgfilt); // no trigger filter for Run-11 VPDMB

      // Move these makers after trigger decision
      // *** VERY IMPORTANT ***
      // The order of TpxRaw and TpcRS *must* be preserved
      // or the embedding will *not* work. [RT# 2299]
      // http://www.star.bnl.gov/rt2/Ticket/Display.html?id=2299
      StTpcRSMaker *TpcRS = (StTpcRSMaker *)chain2->GetMaker("TpcRS");
      StTpcHitMaker *TpxRaw = (StTpcHitMaker *)chain1->GetMaker("TpxRaw");
      chain3->AddBefore("TpcMixer", TpxRaw);
      chain3->AddBefore("TpcMixer", TpcRS);

#if 0
      // Turn on debugging of DB maker
      St_db_Maker *db = (St_db_Maker *)chain1->GetMaker("db");
      db->SetDebug(2);
#endif

      //--------------------------------------------------------------------------
      TString trgfile = gSystem->BaseName(fzdFile.c_str());
      trgfile.ReplaceAll(".fzd", ".trig.root");
      TFile *ofile = TFile::Open(trgfile, "recreate");
      assert(ofile);
      TH2F *hBarrelHighTowerSimu = new TH2F("hBarrelHighTowerSimu", "BEMC high tower simu;trigger patch;high tower", 300, 0, 300, 64, 0, 64);
      TH2F *hBarrelPatchSumSimu = new TH2F("hBarrelPatchSumSimu", "BEMC patch sum simu;trigger patch;patch sum", 300, 0, 300, 64, 0, 64);
      TH2F *hEndcapHighTowerSimu = new TH2F("hEndcapHighTowerSimu", "EEMC high tower simu;trigger patch;high tower", 90, 0, 90, 64, 0, 64);
      TH2F *hEndcapPatchSumSimu = new TH2F("hEndcapPatchSumSimu", "EEMC patch sum simu;trigger patch;patch sum", 90, 0, 90, 64, 0, 64);
      TH2F *hBarrelJetPatchSimu = new TH2F("hBarrelJetPatchSimu", "BEMC jet patch;jet patch;adc", 18, 0, 18, 160, 0, 160);
      TH2F *hEndcapJetPatchSimu = new TH2F("hEndcapJetPatchSimu", "EEMC jet patch;jet patch;adc", 6, 0, 6, 160, 0, 160);
      TH2F *hOverlapJetPatchSimu = new TH2F("hOverlapJetPatchSimu", "BEMC-EEMC-overlap;jet patch;adc", 6, 0, 6, 160, 0, 160);
   }

   //--------------------------------------------------------------------------
   // Initialize chain
   Chain->Init();
   PrintTimer(Chain);
   puts("Order of makers in BFCMIXER:");
   StMaker::lsMakers(Chain);
   // Event loop
   int mNTotal = 0;
   int mNFailed = 0;
   TBenchmark evnt;
   StIOMaker *inputStream = (StIOMaker *)chain1->GetMaker("inputStream");

   for (int iEvent = 1; iEvent <= nEvents; ++iEvent) {
      evnt.Reset();
      evnt.Start("QAInfo:");
      Chain->Clear();
      int iMake = Chain->Make(iEvent);

      if (iMake == kStErr) ++mNFailed;

      if (inputStream->GetMakeReturn() % 10 == kStEOF) {
         inputStream->Rewind();
         --iEvent;
         continue;
      }

      //if (iMake == kStSkip) continue;
      if (iMake % 10 == kStEOF || iMake % 10 == kStFatal) break;

      ++mNTotal;
      PrintTimer(Chain);
      //--------------------------------------------------------------------------

      if (flag == "Jet") {
         // BEMC high towers and trigger patches
         for (int triggerpatch = 0; triggerpatch < 300; ++triggerpatch) {
            hBarrelHighTowerSimu->Fill(triggerpatch, trgsim->bemc->getBEMC_FEE_HT_ADC()[triggerpatch]);
            hBarrelPatchSumSimu->Fill(triggerpatch, trgsim->bemc->getBEMC_FEE_TP_ADC()[triggerpatch]);
         } // for triggerpatch

         // BEMC jet patches
         for (int jetpatch = 0; jetpatch < 18; ++jetpatch) {
            hBarrelJetPatchSimu->Fill(jetpatch, trgsim->bemc->barrelJetPatchAdc(jetpatch));
         } // for jetpatch

         // EEMC high towers and trigger patches
         for (int triggerpatch = 0; triggerpatch < 90; ++triggerpatch) {
            hEndcapHighTowerSimu->Fill(triggerpatch, trgsim->eemc->getEndcapHighTower(triggerpatch));
            hEndcapPatchSumSimu->Fill(triggerpatch, trgsim->eemc->getEndcapPatchSum(triggerpatch));
         } // for triggerpatch

         // EEMC jet patches
         for (int jetpatch = 0; jetpatch < 6; ++jetpatch) {
            hEndcapJetPatchSimu->Fill(jetpatch, trgsim->eemc->endcapJetPatchAdc(jetpatch));
         } // for jetpatch

         // BEMC-EEMC-overlap jet patches
         for (int i = 0; i < 2; ++i) {
            int jetpatch, adc;
            trgsim->emc->getOverlapJetPatchAdc(i, jetpatch, adc);
            hOverlapJetPatchSimu->Fill(jetpatch, adc);
         } // for i
      } //end of if("jet")

      //--------------------------------------------------------------------------
      evnt.Stop("QAInfo:");
      printf("QAInfo: Done with Event [no. %d/run %d/evt. %d/Date.Time %d.%d/sta %d] Real Time = %10.2f seconds Cpu Time = %10.2f seconds\n", iEvent, Chain->GetRunNumber(), Chain->GetEventNumber(), Chain->GetDate(), Chain->GetTime(), chain3->GetMakeReturn(), evnt.GetRealTime("QAInfo:"), evnt.GetCpuTime("QAInfo:"));
   } // End event loop

   printf("QAInfo:EventLoop completed code %d\n", iMake);
   gSystem->Exec("date");
   TDatime t;
   printf("QAInfo:Run is finished at Date/Time %i/%i; Total events processed: %i and not completed: %i\n", t.GetDate(), t.GetTime(), mNTotal, mNFailed);

   //--------------------------------------------------------------------------
   if (flag == "Jet") {
      ofile->Write();
      ofile->Close();
   }
}
Esempio n. 23
0
void runEEmcMcPi0( Int_t nevents = 1000,
			Char_t *name = "dipi0_10000evts.MuDst.root",
			//Char_t *name = "/star/data05/scratch/hew/JanSample/pi0_set2.MuDst.root",
			Char_t *ofile= "test.root",
			Char_t *path = "/star/u/hew/pi0finder/ezGames/backyard/multiphoton/",
			//Char_t *path = "",///star/data13/reco/pp200/pythia6_205/25_35gev/cdf_a/y2004y/gheisha_on/p05ih/", 
			Int_t nfiles = 100)
		      
{
  
  TString pathname = path; 
  pathname += name;
  TString fileG=name;
  fileG.ReplaceAll("MuDst","geant");
  
  fileG=path+fileG;
  
  //--
  //-- Load shared libraries
  //--
  LoadLibs();
  gSystem->Load("StMcEvent");
  gSystem->Load("StMcEventMaker");

  //assert(!gSystem->Load("StEEmcMcReadMaker"));

  //--
  //-- Create the analysis chain
  //--
  mChain = new StChain("eemcAnalysisChain");
  
  StIOMaker* ioMaker = new StIOMaker();

  printf("%s\n",fileG.Data());
  ioMaker->SetFile(fileG);

  ioMaker->SetIOMode("r");
  ioMaker->SetBranch("*",0,"1");             //deactivate all branches
  ioMaker->SetBranch("geantBranch",0,"r");   //activate geant Branch
  ioMaker->SetBranch("minimcBranch",0,"r");   //activate geant Branch

  
  //--
  //-- MuDst maker for reading input
  //--
  mMuDstMaker = new StMuDstMaker(0,0,path,name,"MuDst",nfiles);
  mMuDstMaker->SetStatus("*",0);
  mMuDstMaker->SetStatus("MuEvent",1);
  mMuDstMaker->SetStatus("EmcAll",1);

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

  //--
  //-- Connect to the STAR databse
  //--
  mStarDatabase = new St_db_Maker("StarDb", "MySQL:StarDb");


#ifdef MONTE_CARLO  
  //--
  //-- Setup ideal gains for processing MC data
  //--
  
  mStarDatabase->SetFlavor("sim","eemcPMTcal");
  mStarDatabase->SetFlavor("sim","eemcPIXcal");
  mStarDatabase->SetFlavor("sim","eemcPMTped");
  mStarDatabase->SetFlavor("sim","eemcPMTstat");
  mStarDatabase->SetFlavor("sim","eemcPMTname");
  mStarDatabase->SetFlavor("sim","eemcADCconf");
  mStarDatabase->SetDateTime(20050101,0);

#endif

  //--
  //-- Initialize EEMC database
  //--
  new StEEmcDbMaker("eemcDb");
  gMessMgr -> SwitchOff("D");
  gMessMgr -> SwitchOn("I");

  mSpinDb = new StSpinDbMaker("mSpinDb");

#ifdef MONTE_CARLO
  //--
  //-- Initialize slow simulator
  //--
  StEEmcSlowMaker *slowSim = new StEEmcSlowMaker("slowSim");
  slowSim->setDropBad(0);   // 0=no action, 1=drop chn marked bad in db
  slowSim->setAddPed(0);    // 0=no action, 1=ped offset from db
  slowSim->setSmearPed(0);  // 0=no action, 1=gaussian ped, width from db
  slowSim->setOverwrite(1); // 0=no action, 1=overwrite muDst values
  slowSim->setNpePerMipSmd(1.0);
 
#endif
 

  //--
  //-- Energy to ADC maker
  //--
  mEEanalysis=new StEEmcA2EMaker("AandE");
  mEEanalysis->database("eemcDb");          // sets db connection
  mEEanalysis->source("MuDst",1);           // sets mudst as input
  mEEanalysis->threshold(3.0,0);            // tower threshold
  mEEanalysis->threshold(3.0,1);            // pre1 threshold 
  mEEanalysis->threshold(3.0,2);            // pre2 threshold
  mEEanalysis->threshold(3.0,3);            // post threshold
//mEEanalysis->threshold(4,5.0);            // smdu threshold
//mEEanalysis->threshold(5,5.0);            // smdv threshold
  mEEanalysis->scale(1.3);                  // scale energies by x1.2
  
  
  //--
  //-- Some simple QA histograms
  //--
  StEEmcQAMaker *eemcQA=new StEEmcQAMaker("eeqa");
  eemcQA->analysis("AandE");
  eemcQA->mudst("MuDst");
//eemcQA->trigger(96261);      // add specified trigger to list  
  eemcQA->nVertexMin=0;        // cut on min number of verticies
  eemcQA->nVertexMax=999;      // cut on max number of verticies


  //--
  //-- Cluster maker.  Generates tower, preshower, postshower clusters
  //-- (using Minesweeper algo) and smd clusters (seed strip w/ truncation).
  //--
  mEEclusters=new StEEmcIUClusterMaker("mEEclusters");
  mEEclusters->analysis("AandE");
  mEEclusters->seedEnergy(0.8,0);       // tower seed energy
  mEEclusters->seedEnergy(1.5/1000.,4); // 2 MeV smd-u strip
  mEEclusters->seedEnergy(1.5/1000.,5); // 2 MeV smd-v strip
  mEEclusters->setSeedFloor(1.0);       // floating seed threshold near clusters
  mEEclusters->setMaxExtent(3);         // maximum distance from seed strip
//mEEclusters->suppress();              // disallows seeds in two strips adjacent to any cluster
  
  //--
  //-- Point maker.  Matches pairs of smd clusters to active towers.
  //-- Energy is divided between points using a tower energy-sharing
  //-- vs position function.
  //--
  mEEpoints=new StEEmcIUPointMaker("mEEpoints");
  //mEEpoints=new StEEmcPointFitMaker("mEEpoints");
  mEEpoints->analysis("AandE");
  mEEpoints->clusters("mEEclusters");
  mEEpoints->setEnergyMode(0);
  mEEpoints->setLimit(10);
  //  mEEpoints -> doPermutations(false);

  // output maker  tracker
  HList=new TObjArray;
  StMcOutputMaker *mySputMk=new StMcOutputMaker("mcRead");
  mySputMk->SetHList(HList);


  //--
  //-- Pi0 mixer, takes the points identified above and mixes pi0 pairs.
  //--
  mEEmixer = new StEEmcIUMixMaker("mEEmixer");
  mEEmixer -> mudst("MuDst");
  mEEmixer -> analysis("AandE");
  mEEmixer -> points("mEEpoints");
  for ( Int_t i=0;i<12;i++ ) // activate all 12 sectors
    mEEmixer->sector(i); 
//mEEmixer->trigger(96251); // specify trigger id(s) to process
//for Monte-Carlo sample, fix vertex to zero. Otherwise, comment it out.
  mEEmixer->fixedVertex(0.,0.,0.);  // fixes the vertex positiion

 
  //pi0 analysis
  mEEpi0analysis=new StEEmcIUPi0Analysis("pi0analy");
  // mEEpi0analysis->trigger(96261);
  //mEEpi0analysis->minbias(96011);
  mEEpi0analysis->mudst("MuDst");
  mEEpi0analysis->points("mEEpoints");
  mEEpi0analysis->mixer("mEEmixer");
  mEEpi0analysis->analysis("AandE"); 
  mEEpi0analysis->spin("mSpinDb");


  //--
  //-- QA/analysis histograms for pi0's
  //--
  //mEEmixqa = new StEEmcMixQAMaker("mEEmixqa");
  //mEEmixqa -> mixer( "mEEmixer", 0.08, 0.18 ); // specify mixer and mass range for gated histograms
  //mEEmixqa -> points( "mEEpoints" );
  //mEEmixqa -> maxPerCluster =   1;  // max number of pairs matched to a cluster of towers
  //mEEmixqa -> maxPerSector  =   100;  // max number of pairs allowed per sector
  //mEEmixqa -> maxPerEvent   = 100;  // max number of pairs allowed per event

  mChain->ls(3);
  mChain->Init();

  //-----------------------------------------------------------------
  //--
  //-- This is where the business happens.  We loop over all events.
  //-- when mChain -> Make() is called, ::Make() will be called on 
  //-- all of the makers created above.

  Int_t stat  = 0;    // error flag
  Int_t count = 0;    // event count
  int TTnumsmdu=0,TTnumsmdv=0,Tnumsmdu=0,Tnumsmdv=0,Tnumpoints=0,Tnumpairs=0,Tnumfp=0,n2clusteru=0,n2clusterv=0,n2point=0,j=0;
  //FILE *fout=fopen("lowratio.txt","w");assert(fout);
  while ( stat == 0 ) {


    //--
    //-- Terminate once we reach nevents --
    //--
    if ( count++ >= nevents && nevents>0 ) break;

    //--
    //-- Call clear on all makers 
    //--
    mChain -> Clear();

    
    //--
    //-- Process the event through all makers 
    //--
    stat = mChain -> Make();

    //--
    //-- Set to printout on every 10th event
    //--
    if ( (count%prescale)==0 ) //continue;
      {
	std::cout << "------------------------------------------------";
	std::cout << "event=" << count << std::endl;
      }
    //--
    //-- Print the number of hits in the towers, pre/postshower layers
    //--
    Int_t nhits[]={0,0,0,0,0,0};
    float umeandiff=0,vmeandiff;
    for ( int i = 0; i < 4; i++ ) {
      //      std::cout << " layer=" << i 
      //		<< " nhits=" << mEEanalysis->numberOfHitTowers(i) << std::endl;
      nhits[i]+=mEEanalysis->numberOfHitTowers(i);
    }

    //--
    //-- Print the total number of smd strips which fired
    //--
    Int_t nu=0,nv=0;
    for ( Int_t sec=0;sec<12;sec++ )
      {
	nu+=mEEanalysis->numberOfHitStrips(sec,0);
	nv+=mEEanalysis->numberOfHitStrips(sec,1);
      }
    nhits[4]=nu;
    nhits[5]=nv;


    //--
    //-- Print number of clusters in each layer
    //--
    Int_t ncl[8]={0,0,0,0,0,0,0,0};
    for ( Int_t i=0;i<12;i++ )
      {
	ncl[0]+=mEEclusters->numberOfClusters(i,0);
	ncl[1]+=mEEclusters->numberOfClusters(i,1);
	ncl[2]+=mEEclusters->numberOfClusters(i,2);
	ncl[3]+=mEEclusters->numberOfClusters(i,3);
	ncl[4]+=mEEclusters->numberOfSmdClusters(i,0);
	ncl[5]+=mEEclusters->numberOfSmdClusters(i,1);
	ncl[6]+=mEEclusters->TnumberOfSmdClusters(i,0);
	ncl[7]+=mEEclusters->TnumberOfSmdClusters(i,1);

      }
    
    // h0->Fill(ncl[4]);
    //h1->Fill(ncl[5]);
    //h3->Fill(mEEpoints -> numberOfPoints());
    if(ncl[4]==2) n2clusteru+=1;
    if(ncl[5]==2) n2clusterv+=1;
    if(mEEpoints->numberOfPoints()==2) n2point+=1;

    
    Tnumsmdu+=ncl[4];
    Tnumsmdv+=ncl[5];
    TTnumsmdu+=ncl[6];
    TTnumsmdv+=ncl[7];
    Tnumpoints+=mEEpoints->numberOfPoints();
    Tnumpairs+=mEEmixer -> numberOfCandidates();
 
  }
  std::cout << "total number of cluster in smdu=" << Tnumsmdu << std::endl;
  std::cout << "total number of cluster in smdv=" << Tnumsmdv << std::endl;
  std::cout << "temp total number of cluster in smdu=" << TTnumsmdu << std::endl;
  std::cout << "temp total number of cluster in smdv=" << TTnumsmdv << std::endl;
  std::cout << "total number of points =" << Tnumpoints << std::endl;
  std::cout << "number of 2cluster/event in Vplane" << n2clusterv << std::endl;
  std::cout << "total number of pairs =" << Tnumpairs << std::endl;
  std::cout << "number of 2cluster/event in Uplane" << n2clusteru << std::endl;
  std::cout << "number of 2point  /event          " << n2point    << std::endl;

  //-----------------------------------------------------------------


  //--
  //-- For debugging purposes, it's often useful to print out the 
  //-- database 
  //--
  mEEmcDatabase = (StEEmcDb*)mChain->GetDataSet("StEEmcDb");
  if (mEEmcDatabase) mEEmcDatabase->exportAscii("dbdump.dat"); 

  //--
  //-- Calls the ::Finish() method on all makers
  //--
  mChain -> Finish(); 


  //--
  //-- Output the QA histograms to disk
  //--
  TFile *file=new TFile(ofile,"RECREATE");

  mEEclusters -> GetHistList() -> Write();
  mEEpoints -> GetHistList() -> Write();
  mEEanalysis->GetHistList()->Write(); 
  mEEpi0analysis->GetHistList()->Write(); 
  mySputMk->GetHistList()->Write();
  mEEmixer->GetHistList()->Write();

  file->Close();



  delete file;


  return;
    
}
Esempio n. 24
0
void rdSt2print(char * fname="aa.event.root", Int_t nevents=4){

  fname="m1.event.root";

  gROOT->LoadMacro("$STAR/StRoot/StMuDSTMaker/COMMON/macros/loadSharedLibraries.C");
  loadSharedLibraries();
  //  assert( !gSystem->Load("StEEmcUtil.so"));

  cout << " loading done " << endl;
     
  // Load my makers
 
  // create chain    
  chain = new StChain("bfc"); 
  //chain->SetDebug();
  
  // Now we add Makers to the chain...

  // StIOMaker - to read files ...
  StIOMaker* ioMaker = new StIOMaker();  
  ioMaker->SetFile(fname); 
  //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 Event Branch
  ioMaker->SetIOMode("r"); 
 
  // StMcEventMaker
  // StMcEventMaker *mcEventMaker = new StMcEventMaker();

  // My Makers 

  // Now execute the chain Init functions
  chain->PrintInfo();
  chain->ls(3);
  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=0;

  // Do the event loop    
  while(1) {
    if (iev>=nevents) break;
    chain->Clear();
    istat = chain->Make(); 
    iev++; 
    if(istat) break; 
    cout << "---------------------- Processing Event : " << iev << " ---------------------- " << istat<<endl;

  
    // if(iev<17) continue;
    if (istat  == kStEOF || istat == kStFatal) break;
    
    StEvent* mEvent = (StEvent*)chain->GetInputDS("StEvent");
    assert(mEvent);// fix your chain or open the right event file
    StTriggerIdCollection *tic=mEvent->triggerIdCollection();
    assert(tic); 

    //    if(! isTrig(tic,trigM)) continue;
    int nV=mEvent->numberOfPrimaryVertices();
    int iv;
    if(nV>1) printf("######\n");
    printf("eveID=%d  nPrimVert=%d\n", mEvent->id(),nV);

    // VERTEX INFO ........................
    for(iv=0;iv<nV;iv++) {
      StPrimaryVertex *V=mEvent->primaryVertex(iv);
      assert(V);
      StThreeVectorF &r=V->position();
      StThreeVectorF &er=V->positionError();
      printf("iv=%d   Vz=%.2f +/-%.2f \n",iv,r.z(),er.z()  );
      printf("  nPrimTr=%d , VFid=%d:: ntrVF=%d nCtb=%d nBemc=%d nEEmc=%d nTpc=%d sumPt=%.1f rank=%g\n"
	     ,V->numberOfDaughters(), V->vertexFinderId() ,V->numTracksUsedInFinder()  ,
	     V->numMatchesWithCTB()  ,V-> numMatchesWithBEMC() ,V->numMatchesWithEEMC()  ,
	     V->numTracksCrossingCentralMembrane()  ,V->sumOfTrackPt()  ,V->ranking());
      
      continue;
      // TRACK INFO ..............
      int nPrTr=0;
      //.... access prim tracks for given vertex
      int itr;
      for(itr=0; itr<V->numberOfDaughters(); itr++) {
	StTrack *track=V-> daughter(itr);
	if(track==0)  continue;
	if (track->flag() <0 ) continue;
	printf("itr=%d pT=%.1f eta=%.2f nFitP=%d DCA=%.1f\n",itr,
	       track->geometry()->momentum().mag(),
	       track->geometry()->momentum().pseudoRapidity(),
	       track->fitTraits().numberOfFitPoints(),
	       track->geometry()->helix().distance(V->position()));
	nPrTr++;
      }      
      printf("  counted nPrimTr=%d \n",nPrTr);
    } // end of loop over vertices
    // mEvent->ls(3);
   
    // FGT INFO .......
    StFgtCollection*   fgtColl= mEvent->            fgtCollection();
 
    printFgt(fgtColl);
    //assert(9==0);
    // EMC INFO ............
    StEmcCollection* emcC =(StEmcCollection*)mEvent->emcCollection(); assert(emcC);
    // print Endcap hits in StEvent
    printETOW(emcC->detector(13));
    //    printEPRE(emcC->detector(14));
    //printESMD(emcC->detector(15));
    //     printESMD(emcC->detector(16));    
    // printRaw(emcC->eemcRawData());
    //printRawBEMC(emcC->bemcRawData());
    
    //  if(iev<=2) 
  
  } // Event Loop
  chain->Finish();

 
    
}
Esempio n. 25
0
void bfcread_histBranch(
 Int_t nevents=1, 
 const char *MainFile=
 "/afs/rhic.bnl.gov/star/data/samples/gstar.dst.root",
  const char *fname="qa_hist.out")
{
//
  cout << " events to process  = " << nevents << endl;
  cout << " Input File Name = " << MainFile << endl;
  cout << " Output file containing printouts = " << fname << endl;

  ofstream fout(fname);

  fout << " Running: bfcread_histBranch.C " << endl;
  fout << " events to process  = " << nevents << endl;
  fout << " Input File Name = " << MainFile << endl;
  fout << " Output file containing printouts = " << fname << endl;
  fout << endl << endl;

    gSystem->Load("St_base");
    gSystem->Load("StChain");
    gSystem->Load("StIOMaker");
    gSystem->Load("libglobal_Tables");

//  Setup top part of chain
    chain = new StChain("bfc");
    chain->SetDebug();
   
  StIOMaker *IOMk = new StIOMaker("IO","r",MainFile,"bfcTree");
  IOMk->SetDebug();
  IOMk->SetIOMode("r");
  IOMk->SetBranch("*",0,"0");                 //deactivate all branches
  IOMk->SetBranch("histBranch",0,"r"); //activate hist Branch

// --- now execute chain member functions
  chain->Init();

  TDataSet *ds=0;
  TDataSet *obj=0;

  int istat=0;
  int i=0;
  int countev=0;
  int countevhds=0;

// Event loop
EventLoop: if (i < nevents && !istat) {

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

//  count # times Make is called
    i++;

// Now look at the data in the event:
    int countObj=0;
    int countHist=0;

    if (!istat) {

    countev++;

    cout << " start event # " << countev << endl;

      ds=chain->GetDataSet("hist");
      TDataSetIter tabiter(ds);
      if (ds) {

        countevhds++;

        TDataSetIter nextHistList(ds);
        St_ObjectSet *histContainer = 0;
        TList *dirList = 0;

// loop over directories:
        while (histContainer = (St_ObjectSet *)nextHistList()) {
          dirList = (TList *) histContainer->GetObject();

	  cout << " QAInfo: found directory: " << 
                    histContainer->GetName() << endl;
	  fout << " QAInfo: found directory: " << 
                    histContainer->GetName() << endl;

          countObj++;

// Notes for future reference (if we want to generalize this...)
//    dirList is returned  0 for non-histogram file
//       in that case, use GetList instead of GetObject 

         TIter nextHist(dirList);
         TObject  *o = 0;

// loop over histograms in the directory:
          while (o= nextHist()) {
           countHist++;
           cout << " QAInfo:   Hist name: " << o->GetName() << 
                     " ==> Title: " << o->GetTitle() << endl; 
           fout << " QAInfo:   Hist name: " << o->GetName() << 
                     " ==> Title: " << o->GetTitle() << endl; 

          } // nextHist
        } // histContainer
      } // ds

    cout << " QAInfo: event # " << countev
            << ", # directories found = " << countObj 
            << ", # hist found = " << countHist
            << endl << endl;


    fout << " QAInfo: event # " << countev
            << ", # directories found = " << countObj 
            << ", # hist found = " << countHist
            << endl << endl;


    } // istat

    else   // if (istat)
      {
      cout << "Last event processed. Status = " << istat << endl;
    }


    goto EventLoop;
} //EventLoop

  cout << endl;
  cout << "QAInfo: End of Job " << endl; 
  cout << "QAInfo: # times Make called = " << i << endl;
  cout << "QAInfo:  # events read = " << countev << endl;
  cout << "QAInfo:   # events with hist dataset = " << countevhds << endl;

  fout << endl;
  fout << "QAInfo: End of Job " << endl;
  fout << "QAInfo: # times Make called = " << i << endl;
  fout << "QAInfo:  # events read = " << countev << endl;
  fout << "QAInfo:   # events with hist dataset = " << countevhds << endl;

 chain->Finish();   
}