Example #1
0
int main( int argc, char ** argv ) {
	std::string OutputFileName( argv[ 1 ] );
	if( argc >= 4 ) {
		unsigned long init[4]={0x123, 0x234, 0x345, 0x456}, length=4;
		init_by_array(init, length);
	
		for( int i = 0; i < 10; ++i ) {
        		Simulation Australia( atol( argv[ 2 ] ) );
	        	Australia.Start( OutputFileName.c_str(  ), atoi( argv[ 3 ] ) );
	        	
	        	Australia.Stop(  );
	        	
	        	OutputFileName += "1";
	        }
        }
        else {
        	std::cout << "Error: missing arguments" << std::endl;
        	std::cout << "Reminder: Simulation OutputFileName MaxNumberOfRabbits LifeTimeInMonths" << std::endl;
        }
        
        return 0;
}
Example #2
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();
   }
}
Example #3
0
//_____________________________________________________________________
void bfcMixer_TpcSvtSsd(const Int_t Nevents=500,Int_t isSvtIn=1, Int_t isSsdIn=1,
		    const Char_t *daqfile="/star/rcf/test/daq/2007/113/8113044/st_physics_8113044_raw_1040042.daq",
		    const Char_t *tagfile="/star/rcf/test/embedding/2007ProductionMinBias/FullField/P08if/2007/113/8113044/st_physics_8113044_raw_1040042.tags.root",
		    const Double_t pt_low=0.1,
		    const Double_t pt_high=5.0,
		    const Double_t eta_low=-1.1,
		    const Double_t eta_high=1.1,
	            const Double_t vzlow=-175.0,
		    const Double_t vzhigh=175.0,
		    const Int_t pid=8,
		    const Double_t mult = 100.,
                    const std::vector<Int_t> triggers = 0,
                    const Char_t* prodName = "P08icAuAu",
                    const Char_t* mode="flatpt"
) {
  // Separate DB timestamp to add it in both chain1 and chain3
  TString DbVP06idpp("DbV20060729 ");
  TString DbVP07icCuCu("DbV20070518 ");
  TString DbVP08icAuAu("DbV20080418 ");

  // production chains for P06id - p+p 200 GeV (Run6)
  TString prodP06idpp("pp2006b ITTF OSpaceZ2 OGridLeak3D VFMCE -VFPPVnoCTB -hitfilt");

  // production chain for P07ib
//  TString prodP07ib("P2005b DbV20070518 MakeEvent ITTF Iana ToF spt SsdIt SvtIt pmdRaw SCEbyE OGridLeak OShortR OSpaceZ2 ssd_daq");// KeepSvtHit hitfilt skip1row");

  // production chain for P07ic - Cu+Cu 200 GeV (Run5)
  TString prodP07icCuCu("P2005b DbV20070518 MakeEvent ITTF ToF ssddat spt SsdIt SvtIt pmdRaw OGridLeak OShortR OSpaceZ2 KeepSvtHit skip1row VFMCE -VFMinuit -hitfilt");

  // production chain for P08if
//    TString prodP08if("B2007g DbV20080418 adcOnly MakeEvent ITTF Iana ToF spt SsdIt SvtIt pmdRaw SCEbyE  OShortR trgd Corr5 OSpaceZ2 ssd_daq KeepSvtHit -hitfilt VFMCE");// KeepSvtHit hitfilt skip1row");

  // Production chain for P08ic Au+Au 200 GeV (Run7)
  TString prodP08icAuAu("B2007g ITTF adcOnly IAna KeepSvtHit VFMCE -hitfilt l3onl emcDY2 fpd ftpc trgd ZDCvtx svtIT ssdIT Corr5 -dstout");

  TString geomP06id("ry2006");
  TString geomP07ic("ry2005f");
  TString geomP08ic("ry2007g");
//  TString chain1Opt("in magF tpcDb adcOnly NoDefault -ittf NoOutput");
  TString chain1Opt("in magF tpcDb NoDefault -ittf NoOutput");
  TString chain2Opt("NoInput PrepEmbed gen_T geomT sim_T trs -ittf -tpc_daq nodefault");

  TString chain3Opt("");
  if( prodName == "P06idpp") {
    chain1Opt.Prepend(DbVP06idpp);
    chain2Opt += " "; chain2Opt += geomP06id;
    chain3Opt = prodP06idpp ;
  }
  else if( prodName == "P07ic" ){
    chain1Opt.Prepend(DbVP07icCuCu);
    chain2Opt += " "; chain2Opt += geomP07ic;
    chain3Opt = prodP07icCuCu;
  }
  else if ( prodName == "P08icAuAu" ){
    chain1Opt.Prepend(DbVP08icAuAu);
    chain2Opt += " "; chain2Opt += geomP08ic;
    chain3Opt = prodP08icAuAu ;
  }
  else{
    cout << "Choice prodName does not correspond to known chain. Processing impossible. " << endl;
    return;
  }
  //  chain3Opt += " Embedding onlraw GeantOut MiniMcMk McAna IdTruth -in NoInput,useInTracker EmbeddingShortCut"; 
//  chain3Opt += " Embedding onlraw McEvent McEvOut GeantOut MiniMcMk McAna IdTruth -in NoInput,useInTracker -hitfilt EmbeddingShortCut"; 
  chain3Opt += " TpcMixer Embedding onlraw McEvent McEvOut GeantOut MiniMcMk McAna IdTruth -in NoInput,useInTracker -hitfilt -TrsPileUp -TrsToF";
  //  chain3Opt += " Embedding onlraw McEvent McEvOut GeantOut IdTruth -in NoInput -hitfilt EmbeddingShortCut"; 

  if (isSvtIn) chain3Opt += " SvtEmbed";
  if (isSsdIn) {
    chain1Opt += ",ssddat";
    chain2Opt += ",ssd,McEvent,-spt";
    chain3Opt += ",SsdEmbed";
  }

  if( prodName == "P06idpp") {
    chain3Opt.Prepend(DbVP06idpp);
    chain3Opt += " "; chain3Opt += geomP06id;
  }
  else if( prodName == "P07ic" ){
    chain3Opt.Prepend(DbVP07icCuCu);
    chain3Opt += " "; chain3Opt += geomP07ic;
  }
  else if ( prodName == "P08icAuAu" ){
    chain3Opt.Prepend(DbVP08icAuAu);
    chain3Opt += " "; chain3Opt += geomP08ic;
  }
  else{
    cout << "Choice prodName does not correspond to known chain. Processing impossible. " << endl;
    return;
  }

  // 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,chain1Opt,daqfile);
  chain1 = chain;
  chain1->SetName("One"); 
  Chain->cd();
  //________________________________________________________________________________  
  bfc(-1,chain2Opt);
  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.05);
    trsMk->SetMode(0);
  }
  //________________________________________________________________________________
  //  gSystem->Load("StFtpcMixerMaker");
  //  StFtpcMixerMaker  *ftpcmixer = new StFtpcMixerMaker("FtpcMixer","daq","trs");
  //________________________________________________________________________________
  TString OutputFileName(gSystem->BaseName(daqfile));
  OutputFileName.ReplaceAll("*","");
  OutputFileName.ReplaceAll(".daq","");
  //  OutputFileName.Append("_emb.root");
  OutputFileName.Append(".root");
  bfc(-1,chain3Opt,0,OutputFileName);
  chain3 = chain;
  chain3->SetName("Three"); 
  Chain->cd();
  Chain->cd();
  //________________________________________________________________________________
  {
    TDatime t;
    gMessMgr->QAInfo() << Form("Run is started at Date/Time %i/%i",t.GetDate(),t.GetTime()) << endm;
  }
  gMessMgr->QAInfo() << Form("Run on %s in %s",gSystem->HostName(),gSystem->WorkingDirectory()) << endm;
  gMessMgr->QAInfo() << Form("with %s", Chain->GetCVS()) << endm;
  // embedded particle set
  StPrepEmbedMaker *embMk = (StPrepEmbedMaker *) Chain->Maker("PrepEmbed");
  if (! embMk) return;
  embMk->SetTagFile(tagfile);
  //            pTlow,ptHigh,etaLow,etaHigh,phiLow,phiHigh
  embMk->SetOpt(  pt_low,    pt_high,  eta_low,    eta_high,    0.,   6.283185, mode); 
  //                pid, mult
  embMk->SetPartOpt(  pid,mult);

  // Set Skip mode (default is OFF)
  embMk->SetSkipMode(kFALSE) ;

  // Make trigger and z-vertex cuts (only if SkipMode is true)
  // Trigger cut
  //   Can put multiple trigger id's 
  if ( !triggers.empty() ){
    for(std::vector<Int_t>::iterator iter = triggers.begin(); iter != triggers.end(); iter++){
      embMk->SetTrgOpt((*iter)) ;
    }
  }

  // z-vertex cuts
  embMk->SetZVertexCut(vzlow, vzhigh) ;

  TAttr::SetDebug(0);
  Chain->SetAttr(".Privilege",0,"*"                ); 	//All  makers are NOT priviliged
  Chain->SetAttr(".Privilege",1,"StBFChain::*" ); 	//StBFChain is priviliged
  Chain->SetAttr(".Privilege",1,"StIOInterFace::*" ); 	//All IO makers are priviliged
  Chain->SetAttr(".Privilege",1,"St_geant_Maker::*"); 	//It is also IO maker
  Chain->SetAttr(".Privilege",1,"StPrepEmbedMaker::*"); //It is also IO maker
  StMaker *SsdEmbed = Chain->Maker("SsdEmbed");
  if (SsdEmbed) {
    cout << "SsdEmbed has been found ----------------------------------------" << endl;
    SsdEmbed->SetInput("SsdRealData","One/.make/SpaStrip/.data/spa_strip");
    SsdEmbed->SetInput("SsdSimuData","Two/.make/SpaStrip/.data/spa_strip");
    StMaker *SsdPoint = Chain->Maker("SsdPoint");
    if (SsdPoint) {
      cout << "SsdPoint has been found----------------------------------------" << endl;
      SsdPoint->SetInput("SpaStrip","SsdEmbed");
    }
  }
  //  Chain->SetDEBUG(0);
  if (Nevents < 0) return;
  Int_t iInit = Chain->Init();
  if (iInit >=  kStEOF) {Chain->FatalErr(iInit,"on init"); return;}
  StMaker *treeMk = Chain->GetMaker("outputStream");

  Chain->EventLoop(Nevents,treeMk);
  gMessMgr->QAInfo() << "Run completed " << endm;
  gSystem->Exec("date");
}
Example #4
0
//_____________________________________________________________________
void bfcMixer_Ftpc(const Int_t Nevents=20,
                   const Char_t *daqfile="/star/rcf/test/daq/2008/emb/st_fmsslow_adc_9069059_raw_1520001.daq",
                   const Char_t *tagfile="/star/rcf/test/daq/2008/emb/daqtags/st_fmsslow_adc_9069059_raw_1520001.tags.root",
                   const Double_t pt_low=0.2,
                   const Double_t pt_high=0.5,
                   const Double_t eta_low=2.25,
                   const Double_t eta_high=4.45,
                   const Double_t vzlow = -50.0,
                   const Double_t vzhigh = 50.0,
                   const Int_t pid=8,
                   const Double_t mult=1,
                   const std::vector<Int_t> triggers = 0,
                   const Char_t *prodName = "P08iepp",
                   const Char_t* type = "FlatPt") {
    // production chains for P08ic - p+p, Au+Au 9 GeV and d+Au
    TString prodP08iepp("DbV20081117 B2008a ITTF IAna ppOpt l3onl emcDY2 fpd ftpc trgd ZDCvtx NosvtIT NossdIT Corr4 OSpaceZ2 OGridLeak3D VFMCE -hitfilt");
//  TString prodP08icpp("DbV20080712,pp2008,ITTF,OSpaceZ2,OGridLeak3D,beamLine,VFMCE,TpxClu -VFPPV -hitfilt");
//  TString prodP08icAuAu9("DbV20080709 P2008 ITTF VFMCE -hitfilt");
//  TString prodP08icAuAu200("DbV20070101 P2008 ITTF VFMCE -hitfilt");
//  TString prodP08icdAu("DbV20080712 P2008 ITTF OSpaceZ2 OGridLeak3D beamLine, VFMCE TpxClu -VFMinuit -hitfilt");
    TString prodP08iedAu("DbV20090213 P2008 ITTF OSpaceZ2 OGridLeak3D beamLine VFMCE TpxClu -VFMinuit -hitfilt");
    TString prodP10iapp("DbV20091001 pp2009c TpcRS ITTF OSpaceZ2 OGridLeak3D beamLine, VFMCE TpcRS -VFMinuit -hitfilt");
    TString geomP08ic("ry2008");
    TString chain1Opt("in,magF,tpcDb,NoDefault,TpxRaw,-ittf,NoOutput");
//  TString chain2Opt("NoInput,PrepEmbed,gen_T,geomT,sim_T,TpcRS,-ittf,-tpc_daq,nodefault");
    TString chain2Opt("NoInput,PrepEmbed,gen_T,geomT,sim_T,ftpcT,trs,fss,-ittf,-tpc_daq,nodefault");
    chain2Opt += " ";
    chain2Opt += geomP08ic;

    TString chain3Opt("");
    if (prodName == "P08icpp") {
        chain3Opt = prodP08icpp;
    }
    else if (prodName == "P08iepp") {
        chain3Opt = prodP08iepp;
    }
    else if (prodName == "P08icAuAu9") {
        chain3Opt = prodP08icAuAu9;
    }
    else if (prodName == "P08icdAu") {
        chain3Opt = prodP08icdAu;
    }
    else if (prodName == "P08iedAu") {
        chain3Opt = prodP08iedAu;
    }
    else if (prodName == "P08icAuAu200") {
        chain3Opt = prodP08icAuAu200;
    }
    else if (prodName == "P10iapp") {
        chain3opt = prodP10iapp;
    }
    else {
        cout << "Choice prodName does not correspond to known chain. Processing impossible. " << endl;
        return;
    }
    chain3Opt += ",Embedding,TpcMixer,GeantOut,MiniMcMk,McAna,-in,NoInput,useInTracker";
    chain3Opt += ",";
    chain3Opt += geomP08ic;
    // 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,chain1Opt,daqfile);
    chain1 = chain;
    chain1->SetName("One");
    Chain->cd();
    //________________________________________________________________________________
    bfc(-1,chain2Opt);
    chain2 = chain;
    chain2->SetName("Two");
    Chain->cd();
#if 1
    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);
    }
#endif
    //________________________________________________________________________________
    gSystem->Load("StFtpcMixerMaker");
    StFtpcMixerMaker  *ftpcmixer = new StFtpcMixerMaker("FtpcMixer","daq","fss");
    ftpcmixer->SetInput("Input1","StDAQReader");
    ftpcmixer->SetInput("Input2","Event");
    //________________________________________________________________________________
    TString OutputFileName(gSystem->BaseName(daqfile));
    OutputFileName.ReplaceAll("*","");
    OutputFileName.ReplaceAll(".daq","");
    //  OutputFileName.Append("_emb.root");
    OutputFileName.Append(".root");
    bfc(-1,chain3Opt,0,OutputFileName);
    chain3 = chain;
    chain3->SetName("Three");
    Chain->cd();
    //________________________________________________________________________________
    StTpcMixerMaker  *mixer = (StTpcMixerMaker *) chain3->Maker("TpcMixer");
    if( prodName == "P08icAuAu200")
    {
        mixer->SetInput("Input1","MixerEvent");
    }
    else
    {
        mixer->SetInput("Input1","TpxRaw/.data/Event");
    }
    mixer->SetInput("Input2","Trs/.const/Event");
    Chain->cd();

#if 0
//............. begin of EMC embedding makers................

    //.............. Add BEmc stuff here ....................
    gSystem->Load("StEmcSimulatorMaker");
    gSystem->Load("StEmcMixerMaker");
    gSystem->Load("StEEmcSimulatorMaker");

    StMcEventMaker* mcEventMaker = new StMcEventMaker();
    StEmcSimulatorMaker *bemcSim   = new StEmcSimulatorMaker();
    StEmcMixerMaker     *bemcMixer = new StEmcMixerMaker();
    chain3->AddAfter("emcRaw",bemcMixer);
    chain3->AddAfter("emcRaw",bemcSim);
    chain3->AddAfter("emcRaw",mcEventMaker);
    bemcMixer->SetDebug(0); // set it to 1 for more printouts
// note, Barrel slow sim is always ON, said Adam

    //........... Add EEmc Stuff ( Simu, and Mixer) here ..............
    StEEmcFastMaker  *eemcFastSim = new StEEmcFastMaker();
    StEEmcMixerMaker *eemcMixer   = new StEEmcMixerMaker();

    /* position B+E EMC makers in the chain
       (order is reverse because 'After' is used - looks funny but is right)
    */
    chain3->AddAfter("emcRaw",eemcMixer);
    chain3->AddAfter("emcRaw",eemcFastSim);

    eemcFastSim->SetEmbeddingMode();
    //  eemcFastSim->SetDebug();
    // eemcMixer->SetDebug();

    bool useEndcapSlowSim = true;
    if(useEndcapSlowSim) { // turn Endcap slow simu On/Off
        StEEmcSlowMaker *slowSim=new StEEmcSlowMaker();
        chain3->AddAfter("EEmcFastSim",slowSim);
        slowSim->setEmbeddingMode();
    }
#endif


    //________________________________________________________________________________
    {
        TDatime t;
        gMessMgr->QAInfo() << Form("Run is started at Date/Time %i/%i",t.GetDate(),t.GetTime()) << endm;
    }
    gMessMgr->QAInfo() << Form("Run on %s in %s",gSystem->HostName(),gSystem->WorkingDirectory()) << endm;
    gMessMgr->QAInfo() << Form("with %s", Chain->GetCVS()) << endm;
    // embedded particle set
    StPrepEmbedMaker *embMk = (StPrepEmbedMaker *) Chain->Maker("PrepEmbed");
    if (! embMk) return;
    cout << "bfcMixer: Setting PID: "<<pid<<endl;
    embMk->SetTagFile(tagfile);
    //            pTlow,ptHigh,etaLow,etaHigh,phiLow,phiHigh
    embMk->SetOpt(  pt_low,    pt_high,  eta_low,    eta_high,    0.,   6.283185, type);
    //                pid, mult
    embMk->SetPartOpt(  pid,mult);

    // Default is no event selections
    embMk->SetSkipMode(kTRUE);

    // Make trigger and z-vertex cuts (only if SkipMode is true)
    // Trigger cut
    //   Can put multiple trigger id's
    if ( !triggers.empty() ) {
        for(std::vector<Int_t>::iterator iter = triggers.begin(); iter != triggers.end(); iter++) {
            embMk->SetTrgOpt((*iter)) ;
        }
    }

    // z-vertex cuts
    embMk->SetZVertexCut(vzlow, vzhigh) ;

    TAttr::SetDebug(0);
    Chain->SetAttr(".Privilege",0,"*"                ); 	//All  makers are NOT priviliged
    Chain->SetAttr(".Privilege",1,"StBFChain::*" ); 	//StBFChain is priviliged
    Chain->SetAttr(".Privilege",1,"StIOInterFace::*" ); 	//All IO makers are priviliged
    Chain->SetAttr(".Privilege",1,"St_geant_Maker::*"); 	//It is also IO maker
    Chain->SetAttr(".Privilege",1,"StPrepEmbedMaker::*"); //It is also IO maker
    //  Chain->SetDEBUG(0);
    if (Nevents < 0) return;
    Int_t iInit = Chain->Init();
    if (iInit >=  kStEOF) {
        Chain->FatalErr(iInit,"on init");
        return;
    }
    StMaker *treeMk = Chain->GetMaker("outputStream");
    Chain->EventLoop(Nevents,treeMk);
    gMessMgr->QAInfo() << "Run completed " << endm;
    gSystem->Exec("date");
}
//_____________________________________________________________________
void bfcMixer_TpcSvtSsd2005(const Int_t Nevents=100,Int_t isSvtIn=1, Int_t isSsdIn=1,
		    const Char_t *daqfile="/star/rcf/test/daq/2005/051/st_physics_adc_6051006_raw_1050001.daq",
		    const Char_t *tagfile="/star/rcf/test/embedding/cuProductionMinBias/FullField/P07ic/2005/051/st_physics_adc_6051006_raw_1050001.tags.root",
		    const Double_t pt_low=0.1,
		    const Double_t pt_high=5.0,
		    const Double_t eta_low=-1.0,
		    const Double_t eta_high=1.0,
		    const Int_t pid=9,
		    const Double_t mult = 0.1) {
  // production chain for P07ib
  TString prodP07ib("P2005b DbV20070518 MakeEvent ITTF Iana ToF spt SsdIt SvtIt pmdRaw SCEbyE OGridLeak OShortR OSpaceZ2 ssd_daq");// KeepSvtHit hitfilt skip1row");
  TString geomP07ib("ry2005f");
  TString chain1Opt("in magF tpcDb NoDefault -ittf NoOutput");
  TString chain2Opt("NoInput PrepEmbed gen_T geomT sim_T trs -ittf -tpc_daq nodefault");
  chain2Opt += " "; chain2Opt += geomP07ib;
  TString chain3Opt = prodP07ib;
  chain3Opt += " TpcMixer Embedding onlraw GeantOut MiniMcMk McAna IdTruth -in NoInput,useInTracker EmbeddingShortCut"; 
  if (isSvtIn) chain3Opt += " SvtEmbed";
  if (isSsdIn) {
    chain1Opt += ",ssddat";
    chain2Opt += ",ssd,McEvent,-spt";
    chain3Opt += ",SsdEmbed";
  }
  chain3Opt += " "; chain3Opt += geomP07ib;
  // 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,chain1Opt,daqfile);
  chain1 = chain;
  chain1->SetName("One"); 
  Chain->cd();
  //________________________________________________________________________________  
  bfc(-1,chain2Opt);
  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(2.67);
  }
  //________________________________________________________________________________
  //  gSystem->Load("StFtpcMixerMaker");
  //  StFtpcMixerMaker  *ftpcmixer = new StFtpcMixerMaker("FtpcMixer","daq","trs");
  //________________________________________________________________________________
  TString OutputFileName(gSystem->BaseName(daqfile));
  OutputFileName.ReplaceAll("*","");
  OutputFileName.ReplaceAll(".daq","");
  //  OutputFileName.Append("_emb.root");
  OutputFileName.Append(".root");
  bfc(-1,chain3Opt,0,OutputFileName);
  chain3 = chain;
  chain3->SetName("Three"); 
  Chain->cd();
  Chain->cd();
  //________________________________________________________________________________
  {
    TDatime t;
    gMessMgr->QAInfo() << Form("Run is started at Date/Time %i/%i",t.GetDate(),t.GetTime()) << endm;
  }
  gMessMgr->QAInfo() << Form("Run on %s in %s",gSystem->HostName(),gSystem->WorkingDirectory()) << endm;
  gMessMgr->QAInfo() << Form("with %s", Chain->GetCVS()) << endm;
  // embedded particle set
  StPrepEmbedMaker *embMk = (StPrepEmbedMaker *) Chain->Maker("PrepEmbed");
  if (! embMk) return;
  embMk->SetTagFile(tagfile);
  //            pTlow,ptHigh,etaLow,etaHigh,phiLow,phiHigh
  embMk->SetOpt(  pt_low,    pt_high,  eta_low,    eta_high,    0.,   6.283185); 
  //                pid, mult
  embMk->SetPartOpt(  pid,mult);
  TAttr::SetDebug(0);
  Chain->SetAttr(".Privilege",0,"*"                ); 	//All  makers are NOT priviliged
  Chain->SetAttr(".Privilege",1,"StBFChain::*" ); 	//StBFChain is priviliged
  Chain->SetAttr(".Privilege",1,"StIOInterFace::*" ); 	//All IO makers are priviliged
  Chain->SetAttr(".Privilege",1,"St_geant_Maker::*"); 	//It is also IO maker
  Chain->SetAttr(".Privilege",1,"StPrepEmbedMaker::*"); //It is also IO maker
  StMaker *SsdEmbed = Chain->Maker("SsdEmbed");
  if (SsdEmbed) {
    cout << "SsdEmbed has been found ----------------------------------------" << endl;
    SsdEmbed->SetInput("SsdRealData","One/.make/SpaStrip/.data/spa_strip");
    SsdEmbed->SetInput("SsdSimuData","Two/.make/SpaStrip/.data/spa_strip");
    StMaker *SsdPoint = Chain->Maker("SsdPoint");
    if (SsdPoint) {
      cout << "SsdPoint has been found----------------------------------------" << endl;
      SsdPoint->SetInput("SpaStrip","SsdEmbed");
    }
  }
  //  Chain->SetDEBUG(0);
  if (Nevents < 0) return;
  Int_t iInit = Chain->Init();
  if (iInit >=  kStEOF) {Chain->FatalErr(iInit,"on init"); return;}
  StMaker *treeMk = Chain->GetMaker("outputStream");
  Chain->EventLoop(Nevents,treeMk);
  gMessMgr->QAInfo() << "Run completed " << endm;
  gSystem->Exec("date");
}