Ejemplo n.º 1
0
void PrintTimer(StMaker *chain)
{
   TIter next(chain->GetMakeList());
   StMaker *maker;

   while (maker = (StMaker *)next()) {
      maker->PrintTimer();
      PrintTimer(maker);
      // Hack to reset timer
      maker->StartTimer(true);
      maker->StopTimer();
   }
}
Ejemplo n.º 2
0
//________________________________________________________________________________
void MakeSvtOnGlobal(){
  gROOT->LoadMacro("bfc.C");
  bfc(0,"mysql,tpcDb,MagF,nodefault");
  StMaker *db = chain->Maker("db");
  if (! db) return;
  db->SetDebug(1);
  for (Int_t i = 0; i < N; i++) {
    if (! StarMagField::Instance()) new StarMagField;
    StarMagField::Instance()->SetFactor(Data[i].field);
    StEvtHddr *header = chain->GetEvtHddr();
    header->SetRunNumber(i+1);
    header->SetDateTime(20050101,i+1);
    chain->MakeEvent();
    db->SetDateTime(Data[i].date,Data[i].time); 
    St_Survey *SvtOnGlobal = (St_Survey *) chain->GetDataBase("Geometry/svt/SvtOnGlobal");
    if (! SvtOnGlobal)  {cout << "SvtOnGlobal has not been found"  << endl; return 0;}
    const TGeoHMatrix &Tpc2Global = gStTpcDb->Tpc2GlobalMatrix();  cout << "Tpc2Global\t"; Tpc2Global.Print();
    TGeoHMatrix GL;
    Survey_st *OnGlobal         = SvtOnGlobal->GetTable();        // SVT and SVT as whole 
    GL.SetRotation(&OnGlobal->r00);
    GL.SetTranslation(&OnGlobal->t0); cout << "GL\t"; GL.Print();
    TGeoHMatrix TPCGL = Tpc2Global * GL;  cout << "TPCGL\t"; TPCGL.Print();
    TGeoHMatrix TPC2Inv = Tpc2Global.Inverse();  cout << "TPC2Inv\t"; TPC2Inv.Print();
    TGeoHMatrix dR;
    dR.RotateX(180./TMath::Pi()*Data[i].alpha*1e-3);
    dR.RotateY(180./TMath::Pi()*Data[i].beta*1e-3); 
    dR.RotateZ(180./TMath::Pi()*Data[i].gamma*1e-3);
    Double_t xyz[3], dxyz[3], drot[3];
    xyz[0] = 1e-4*Data[i].dx;
    xyz[1] = 1e-4*Data[i].dy;
    xyz[2] = 1e-4*Data[i].dz;
    dxyz[0] = 1e-4*Data[i].ddx;
    dxyz[1] = 1e-4*Data[i].ddy;
    dxyz[2] = 1e-4*Data[i].ddz;
    drot[0] = Data[i].dalpha*1e-3;
    drot[1] = Data[i].dbeta*1e-3; 
    drot[2] = Data[i].dgamma*1e-3;
    dR.SetTranslation(xyz);
    cout << "Additional rotation for Svt\t"; dR.Print();
    TGeoHMatrix GLnew = TPC2Inv * dR * TPCGL;  cout << "GLnew\t"; GLnew.Print();
    Double_t *R = GLnew.GetRotationMatrix();
    Survey_st row;
    memcpy(&row.r00, R, 9*sizeof(Double_t));
    Double_t *tr = GLnew.GetTranslation();
    memcpy(&row.t0, tr, 3*sizeof(Double_t));
    memcpy(&row.sigmaRotX, drot, 3*sizeof(Double_t));
    memcpy(&row.sigmaTrX, dxyz, 3*sizeof(Double_t));
    TString fOut =  Form("SvtOnGlobal.%8i.%06i.C", Data[i].date, Data[i].time);
    ofstream out;
    cout << "Create " << fOut << endl;
    out.open(fOut.Data());
    out << "TDataSet *CreateTable() {" << endl;
    out << "  if (!gROOT->GetClass(\"St_Survey\")) return 0;" << endl;
    out << "  Survey_st row = " << endl; 
    out << "\t{0,"; out << endl; out << "\t"; 
    Double_t *r = &(row.r00);
    for (Int_t j = 0; j < 9; j++) out << Form("%f,",r[j]);
    out << endl;
    out << "\t";
    for (Int_t j = 9; j < 12; j++) out << Form("%f,",r[j]); 
    out << endl;
    out << "\t";
    for (Int_t j = 12; j < 18; j++) out << Form("%f,",r[j]);
    out << endl;
    out << "\t";
    out << "\"Run" << Data[i].run << " " << Data[i].comment << "\"};" << endl;
    out << "  St_Survey *tableSet = new St_Survey(\"SvtOnGlobal\",1);" << endl; 
    out << "  tableSet->AddAt(&row.Id, 0);" << endl;
    out << "  return (TDataSet *)tableSet;" << endl;
    out << "}" << endl;
    out.close(); 
  } 
}
Ejemplo n.º 3
0
//_____________________________________________________________________
void bfcMixer_pp2006( Int_t Nevents=10,
			  Char_t *file1="star/data03/daq/2006/120/7120049/st_physics_adc_7120049_raw_1050001.daq", // probably ppLong 2006 run, NOT for real embedding - just for testing
			  //Char_t *file1="st_zerobias_7118049_raw_1110001.daq",// contains 127 events, good foor real embedding
			  // Char_t *file2="eleB.fzd", // one-particle events from Naresh
			  Char_t *file2="mcpi0_hipt_run140_gid7_1000evts.fzd",
			  Int_t useEndcapSlowSim=1
			  // note, Barrel slow sim is always ON, said Adam 
			  ){
  TString path1="/";
  //TString path2="/star/data04/sim/subbanly/electron2006/oneTrack2Keve/fzd/";
    TString path2="/star/u/wzhang/links/gc2002/EEmc/embedData/fzd/";

  // Dynamically link some shared libs
  if (gClassTable->GetID("StBFChain") < 0) Load();

  // Create the main chain object
  chain = new StBFChain("Embedding");
  
  StMaker *saveMk = 0;
  chain->SetFlags("-ittf,NoDefault");
  // Create chain1 object
  chain1 = new StBFChain("One");
  
  saveMk = chain1->cd();
  chain1->SetFlags("in Physics  NoDefault -ittf -trg"); //Akio said OK for '-trg'.
  chain1->Set_IO_Files(path1+file1);
  chain1->Load();
  chain1->Instantiate();

  saveMk->cd();
  
  // Create chain2 object
  chain2 = new StBFChain("Two");
  saveMk = chain2->cd();
  chain2->SetFlags("fzin gen_T geomT sim_T tpc trs -tcl -tpt -PreVtx -tpc_daq -ittf ");   
  chain2->Set_IO_Files(path2+file2);
  chain2->Load();
  chain2->Instantiate();
  St_geant_Maker *geantMk = chain2->GetMaker("geant");
  if (geantMk) geantMk->SetMode(1);   // Mixer mode - do not modify EvtHddr

  // do not rescale dEdx in TRS, it leads to wrong cluster formation, from Jamie
 
  saveMk->cd();

  // Mixer for TPC
  gSystem->Load("StMixerMaker");
  StMixerMaker  *mixer = new StMixerMaker("Mixer","daq","trs");
  chain1->SetInput("Input1","StDAQReader");
  chain2->SetInput("Input2","Event");
  mixer->writeFile("mixer.trs",Nevents);


  // Create chain3 object
  chain3 = new StBFChain("Three");
  saveMk = chain3->cd();
  
  //  options for 2006pp, production=DbV20060915,pp2006b,ITTF,hitfilt
  chain3->SetFlags("Simu NoDefault NoInput onlraw -onlcl  ry2006,tpc_daq,tpcI,svt_daq,SvtD,Physics,Idst,l0,Tree,evout l3onl  fcf emcDY2 fpd trgd ZDCvtx useCDV ITTF tofDat -SvtIT  MuDST -trg  VFPPVnoCTB beamline GeantOut CMuDst dEdxY2 -EventQA");
  // Note, do not freez the DB time stamp or you will not see the latest gains/peds/stat  

  TString tt1=file1;
  TString tt2=file2;
  tt1.ReplaceAll(".daq","");
  tt2.ReplaceAll(".fzd","");
  TString OutputFileName=tt1+"_"+tt2+".root";
  cout <<"BFC: Setting file output to: " <<OutputFileName.Data()<<endl;
  
  chain3->Set_IO_Files(0,OutputFileName.Data());
  chain3->Load();
  chain3->Instantiate();  

  //............. begin of EMC embedding makers................

  //.............. Add BEmc stuff here ....................
  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();
  
  if(useEndcapSlowSim) { // turn Endcap slow simu On/Off 
    StEEmcSlowMaker *slowSim=new StEEmcSlowMaker();
    chain3->AddAfter("EEmcFastSim",slowSim); 
    slowSim->setEmbeddingMode();
  }

  //............. end of EMC embedding makers................
  
  St_geant_Maker *geantMk = (St_geant_Maker *) chain->GetMaker("geant");
  geantMk->SetActive(kTRUE);
  StMaker *tpcdaqMk = chain3->GetMaker("tpc_raw");
  if(!tpcdaqMk )    {
    cout <<" Error: no tpc daq maker. End. "<<endl;
    return;
  }
  tpcdaqMk->SetMode(1);   // Trs
  tpcdaqMk->SetInput("Event","MixerEvent");

  saveMk->cd(); {
    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
  
  if (Nevents >= 0) {
    Int_t iInit = chain->Init();
    chain->ls(5); // list the final chain 
  }


  // chain->SetDEBUG();
  treeMk = chain->GetMaker("tree");
  TBenchmark evnt;
  Int_t iMake = 0, i = 1, iBad = 0;


  StIOMaker *inpMk = (StIOMaker *)chain1->GetMaker("inputStream");
  Int_t ncols, eventnumber, mult, skip=0, oldskip = 0, skiptest=0;
  
  cout <<"BFC - Entering Event Loop"<<endl;
 EventLoop: if (i <= Nevents && iMake != kStEOF && iMake != kStFatal) {
   evnt.Reset();
   evnt.Start("QAInfo:");
   chain->Clear();
   
   iMake = chain->Make(i);
   if (treeMk && iMake == kStErr) {treeMk->Make(i); iBad++;}
   StEvtHddr *fEvtHddr = (StEvtHddr*)chain->GetDataSet("EvtHddr");
   StEvtHddr *fEvtHddrDaq = (StEvtHddr*)chain1->GetDataSet("EvtHddr");
   *fEvtHddr = *fEvtHddrDaq;
   // 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;
 }

  fflush(stdout);
  printf ("QAInfo:Run completed ");
  gSystem->Exec("date");

}
Ejemplo n.º 4
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");
}
Ejemplo n.º 5
0
//_____________________________________________________________________
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");
}
Ejemplo n.º 6
0
//________________________________________________________________________________
void MakeSvtLadderOnShell(){//, Int_t time = 38 ){ // combine SvtBarrelOnGlobal and SvtShellsOnBarrel into SvtShellsOnGlobal
  gROOT->LoadMacro("bfc.C");
  bfc(0,"mysql,db,nodefault");
  StMaker *dbMk = chain->Maker("db");
  if (! dbMk) return;
  dbMk->SetDebug(1);
  StEvtHddr *header = chain->GetEvtHddr();
  header->SetRunNumber(1);
  dbMk->SetDateTime(date,time); 
  header->SetDateTime(date,time);
  chain->MakeEvent();
  dbMk->SetDebug(2);
  dbMk->SetDateTime(date,time); 
  St_Survey *LadderOnShellOld = (St_Survey *) dbMk->GetDataBase("Geometry/svt/LadderOnShell");  // shells in the SVT barrel coordinate system
  if (! (LadderOnShellOld)) return;
  Survey_st *LaddersOnShells = LadderOnShellOld->GetTable();  // shells in the SVT barrel coordinate system
  Int_t NoLadders = LadderOnShellOld->GetNRows();
  St_Survey *LadderOnShell = new St_Survey("LadderOnShell",NoLadders);
#ifdef CutSTEP
  cout << "============================ CutSTEP =========================" << endl;
#endif
  TGeoHMatrix T;
  Double_t tr[3] = {0,0, 23.525};
  // Double_t tr[3] = {0,0, -23.525};
  T.SetTranslation(tr);
  TGeoHMatrix F;
  Double_t flip[9] = {
    1, 0, 0,
    0, 0, 1,
    0, 1, 0
  };
  F.SetRotation(flip);
  TGeoHMatrix TInv = T.Inverse();
  for (Int_t s = 0; s < NoLadders; s++, LaddersOnShells++) {
    TGeoHMatrix LSold, LS, dR, ddR, dddR;
    //    LadderOnShellOld->Print(s,1);
    LSold.SetRotation(&LaddersOnShells->r00);
    LSold.SetTranslation(&LaddersOnShells->t0); cout << "===================== Ladder \t" << s+1 << endl; cout << "\tLSold\t"; LSold.Print();
    Int_t i = -1; 
    for (Int_t k = 0; k < N; k++) {
      if (LaddersOnShells->Id == 1000*Data[k].barrel + Data[k].ladder) {i = k; break;}
    }
    if (i < 0) {
      cout << "Correction for " << LaddersOnShells->Id << " is not found" << endl;
    } else {
      cout << "Ladder " << LaddersOnShells->Id << "\ti " << i 
	   << "\talpha " <<  Data[i].alpha << "+/-" << Data[i].Dalpha
	   << "\tbeta "  <<  Data[i].beta  << "+/-" << Data[i].Dbeta
	   << "\tgamma " <<  Data[i].gamma << "+/-" << Data[i].Dgamma
	   << "\tu " << Data[i].u << "\tv " << Data[i].v << "\tw " << Data[i].w << endl; 
      Double_t xyz[3] = {0, 0, 0};
      //      if (Data[i].Dalpha < 2 && Data[i].Dbeta  < 2 && Data[i].Dgamma < 2) {
#ifndef CutSTEP
	if (Data[i].Dalpha > 0) dR.RotateX(-180./TMath::Pi()*Data[i].alpha*1e-3);
	if (Data[i].Dbeta  > 0) dR.RotateZ(-180./TMath::Pi()*Data[i].beta*1e-3);
	if (Data[i].Dgamma > 0) dR.RotateY(-180./TMath::Pi()*Data[i].gamma*1e-3);
	if (Data[i].Du > 0) xyz[0] =  1e-4*Data[i].u;
	if (Data[i].Dv > 0) xyz[2] =  1e-4*Data[i].v;
	if (Data[i].Dw > 0) xyz[1] =  1e-4*Data[i].w;
#else
	if (Data[i].Dalpha > 0) dR.RotateX(-180./TMath::Pi()*Data[i].alpha*0.5e-3);
	if (Data[i].Dbeta  > 0) dR.RotateZ(-180./TMath::Pi()*Data[i].beta*0.5e-3);
	if (Data[i].Dgamma > 0) dR.RotateY(-180./TMath::Pi()*Data[i].gamma*0.5e-3);
	if (Data[i].Du > 0) xyz[0] =  0.5e-4*Data[i].u;
	if (Data[i].Dv > 0) xyz[2] =  0.5e-4*Data[i].v;
	if (Data[i].Dw > 0) xyz[1] =  0.5e-4*Data[i].w;
#endif
	//      }
      dR.SetTranslation(xyz);
      cout << "dR\t"; dR.Print();
    }
    // 	shellOnGlobal *	ladderOnShell * T * dR * T**-1 * ladderOnSurvey * waferOnLadder 
    // 	shellOnGlobal * ( ladderOnShell * F * T * dR * T**-1 * F ) * ladderOnSurvey * waferOnLadder 
    ddR = T * dR * TInv; cout << "ddR\t" << ddR.Print();
    dddR = F * T * dR * TInv * F; cout << "dddR\t" << dddR.Print();
    //    LS = LSold * dR; cout << "LS_old\t"; LS.Print();
    //    LS = LSold * dddR; cout << "LS_new\t"; LS.Print();
    LS = LSold * ddR; cout << "LS_new\t"; LS.Print();
    Survey_st row = *LaddersOnShells;
    Double_t *r = LS.GetRotationMatrix();
    memcpy(&row.r00, r, 9*sizeof(Double_t));
    Double_t *t = LS.GetTranslation();
    memcpy(&row.t0, t, 3*sizeof(Double_t));
    LadderOnShell->AddAt(&row);
    //    LadderOnShell->Print(LadderOnShell->GetNRows()-1,1);
  }
  TString fOut =  Form("%s.%8i.%06i.C",LadderOnShell->GetName(),date,time);
  ofstream out;
  cout << "Create " << fOut << endl;
  out.open(fOut.Data());
  out << "TDataSet *CreateTable() {" << endl;
  out << "  if (!gROOT->GetClass(\"St_Survey\")) return 0;" << endl;
  out << "  Survey_st row[" << NoLadders << "] = {" << endl; 
  Survey_st *LaddersOnShells = LadderOnShell->GetTable(); 
  for (Int_t i = 0; i < NoLadders; i++, LaddersOnShells++) { 
    out << "    {" << Form("%1i",LaddersOnShells->Id); 
    Double_t *r = &(LaddersOnShells->r00);
    for (Int_t j = 0; j < 9; j++) out << Form(",%8.5f",r[j]);
    for (Int_t j = 9; j < 12; j++) out << Form(",%8.4f",r[j]);
    for (Int_t j = 12; j < 18; j++) out << Form(",%3.1f",r[j]);
    out << ",\"" << Pass << "\"}";
    if (i != NoLadders - 1) out << ",";
    out << endl;
  } 
  out << "  };" << endl;
  out << "  St_Survey *tableSet = new St_Survey(\"" << LadderOnShell->GetName() << "\"," << NoLadders << ");" << endl; 
  out << "  for (Int_t i = 0; i < " << NoLadders << "; i++) tableSet->AddAt(&row[i].Id, i);" << endl; 
  out << "  return (TDataSet *)tableSet;" << endl;
  out << "}" << endl;
  out.close(); 
}