00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00121
#include <Stiostream.h>
00122
#include "StLaserEventMaker.h"
00123
#include "St_DataSetIter.h"
00124
#include "tpc/St_tcl_Module.h"
00125
#include "tpc/St_tph_Module.h"
00126
#include "tpc/St_tpt_Module.h"
00127
#include "tables/St_tfc_adcxyz_Table.h"
00128
#include "tables/St_tpt_track_Table.h"
00129
#include "tables/St_starClockOnl_Table.h"
00130
#include "TTree.h"
00131
#include "StLaserEvent/StLaserEvent.h"
00132
#include "tables/St_tpcDriftVelocity_Table.h"
00133
#include "tables/St_type_index_Table.h"
00134
#include "tables/St_dst_vertex_Table.h"
00135
#include "StTpcDb/StTpcDb.h"
00136
#include "StDetectorDbMaker/StDetectorDbClock.h"
00137
#include "TMath.h"
00138
#include "TFile.h"
00139 ClassImp(
StLaserEventMaker)
00140
00141
00142
StLaserEventMaker::
StLaserEventMaker(const
char *name):
00143
StMaker(name),
00144 m_clock(0),
00145 m_tpg_pad_plane(0),
00146 m_type(0),
00147 m_tpt_pars(0),
00148 event(0)
00149 {
00150
00151 mHistOut=kTRUE;
00152 m_mklaser=kTRUE;
00153 m_lasers =kTRUE;
00154 m_rowmin=14;
00155 m_rowmax=45;
00156 }
00157
00158 StLaserEventMaker::~StLaserEventMaker(){}
00159
00160
00161 void StLaserEventMaker::Clear(Option_t *option){
00162
if (
event)
event->Clear(option);
00163 StMaker::Clear(option);
00164 }
00165
00166
00168 Int_t
StLaserEventMaker::InitRun(
int RunId){
00169
00170
00171 m_tpg_pad_plane =(St_tpg_pad_plane *) GetChain()->FindObject(
"tpg_pad_plane");
00172
if (!m_tpg_pad_plane) Error(
"Init",
"tpc/tpgpar is not initialized. \n");
00173 assert(m_tpg_pad_plane);
00174
00175
00176
00177 TDataSet *tpcpars = GetInputDB(
"tpc/tclpars");
00178 assert(tpcpars);
00179
00180 TDataSetIter gime(tpcpars);
00181 m_type = (St_tcl_tpc_index_type *) gime(
"type");
00182
if (!m_type) Error(
"Init",
" Clustering parameters have not been initialized");
00183 assert(m_type);
00184
00185
00186 tpcpars = GetInputDB(
"tpc/tptpars");
00187 gime.Reset(tpcpars);
00188 m_tpt_pars = (St_tpt_pars* ) gime(
"tpt_pars");
00189
if (!(m_tpt_pars))
00190 Error(
"Init",
"tpt parameters have not been initialized" );
00191 assert(m_tpt_pars);
00192
00193
00194 LOG_INFO <<
"Making the laser TTree" << endm;
00195
event =
new StLaserEvent();
00196 GetTFile()->cd();
00197 m_laser =
new TTree(
"laser",
"Tpc laser track tree");
00198 m_laser->SetAutoSave(100000000);
00199 Int_t bufsize= 64000;
00200 Int_t split = 99;
00201
if (split) bufsize /= 4;
00202 m_laser->Branch(
"event",
"StLaserEvent",&
event, bufsize, split);
00203
00204
00205 LOG_INFO <<
"Making Histograms" << endm;
00206 fzLaser =
new TH1F(
"fzLaser",
"fzLaser",100,-200,200);
00207 fzlWestHigh =
new TH1F(
"fzlWestHigh",
"fzlWestHigh",100,165,190);
00208 fzlWestLow =
new TH1F(
"fzlWestLow",
"fzlWestLow",100,15,40);
00209 fzlEastHigh =
new TH1F(
"fzlEastHigh",
"fzlEastHigh",100,-190,-165);
00210 fzlEastLow =
new TH1F(
"fzlEastLow",
"fzlEastLow",100,-40,-15);
00211 numberTracks =
new TH1F(
"numberTracks",
"numberTracks",100,5,2005);
00212 numberEvents =
new TH1F(
"numberEvents",
"numberEvents",2,0,2);
00213 driftVelocityRec =
new TH1F(
"driftVelocityRec",
"driftVelocityRec",100,5000000,6000000);
00214 AddHist(fzLaser);
00215 AddHist(fzlEastHigh);
00216 AddHist(fzlEastLow);
00217 AddHist(fzlWestHigh);
00218 AddHist(fzlWestLow);
00219 AddHist(numberTracks);
00220 AddHist(numberEvents);
00221 AddHist(driftVelocityRec);
00222 date = 0;
00223 time = 0;
00224
00225
return kStOk;
00226 }
00227
00228
00229 Int_t
StLaserEventMaker::Make(){
00230
00231
if (date==0) {date = GetDate();LOG_INFO <<
"date = " << date << endm;}
00232
if (time==0) {time = GetTime();LOG_INFO <<
"time = " << time << endm;}
00233
00234 TDataSet *tpc_data = GetInputDS(
"tpc_hits");
00235
if (!tpc_data)
return kStWarn;
00236
00237
00238 TDataSetIter gime(tpc_data);
00239 St_tcl_tphit *tphit = (St_tcl_tphit *) gime(
"tphit");
00240
if (!tphit)
return kStWarn;
00241
#if 0
00242
00243
00244
if(tphit && m_undoExB){
00245 LOG_INFO <<
" correct the hits for ExB effects" << endm;
00246 tcl_tphit_st *h = tphit->GetTable();
00247
for (
int i = 0;i<tphit->GetNRows();i++,h++){
00248 UndoExB(&h->x,&h->y,&h->z);
00249 }
00250 }
00251
00252
if(m_undoDistort){
00253 m_mag =
new StMagUtilities() ;
00254 Float_t x[3], xprime[3];
00255 tcl_tphit_st *spc = tphit->GetTable();
00256
for(Int_t i=0; i<tphit->GetNRows(); i++, spc++){
00257
00258 x[0] = spc->x;
00259 x[1] = spc->y;
00260 x[2] = spc->z;
00261 m_mag->
UndoDistortion(x,xprime);
00262 spc->x = xprime[0];
00263 spc->y = xprime[1];
00264 spc->z = xprime[2];
00265 }
00266 }
00267
00268
#endif
00269
St_tpt_track *tptrack =
new St_tpt_track(
"tptrack",maxNofTracks);
00270 m_DataSet->Add(tptrack);
00271
00272 St_dst_vertex *clusterVertex =
new St_dst_vertex(
"clusterVertex",1);
00273 Add(clusterVertex);
00274
00275
00276
00277
00278
if (Debug()) LOG_INFO <<
" start tpt run " << endm;
00279
00280 Int_t Res_tpt = tpt(m_tpt_pars,tphit,tptrack,clusterVertex);
00281
00282
00283
if (Res_tpt != kSTAFCV_OK) {
00284 LOG_INFO <<
"Problem with tpt... returns " <<Res_tpt<< endm;
00285
return kStErr;}
00286
00287
if (Debug()) LOG_INFO <<
" finish tpt run " << endm;
00288
00289 MakeHistograms();
00290
return kStOK;
00291 }
00292
00293
00298
void StLaserEventMaker::MakeHistograms()
00299 {
00300 Int_t evno = 0;
00301 Float_t C_RAD_PER_DEG = 0.017453292;
00302
if (m_mklaser) {
00303
00304 evno = GetEventNumber();
00305 m_runno =
GetRunNumber();
00306 Float_t m_drivel = gStTpcDb->DriftVelocity();
00307 driftVelocityReco = m_drivel;
00308 driftVelocityRec->Fill(driftVelocityReco);
00309 Float_t m_tzero = gStTpcDb->Electronics()->tZero();
00310 Float_t l_clockNominal = gStTpcDb->Electronics()->samplingFrequency();
00311 clockNominal = l_clockNominal;
00312
00313
00314
00315
00316
00317
00318
00319
00320
00321
00322
00323
00324
00325 StDetectorDbClock* dbclock = StDetectorDbClock::instance();
00326
double freq = dbclock->getCurrentFrequency()/1000000.0;
00327 clock = freq;
00328 Float_t m_trigger = gStTpcDb->triggerTimeOffset();
00329 m_date = GetDate();
00330 m_time = GetTime();
00331
00332
00333
00334 event->SetHeader(evno, m_runno, m_date, m_time,
00335 m_tzero, m_drivel, m_clock, m_trigger);
00336 LOG_INFO <<
"Event "<< evno <<
" Run " << m_runno << endm;
00337 LOG_INFO <<
" tZero "<< m_tzero <<
" trigger " << m_trigger << endm;
00338 LOG_INFO <<
" clock "<< m_clock <<
" clockNominal " << l_clockNominal << endm;
00339 LOG_INFO <<
" drivel " << m_drivel << endm;
00340 LOG_INFO <<
" freq "<< freq << endm;
00341
00342
00343
00344 TDataSetIter tpc_tracks(m_DataSet);
00345 St_tpt_track * n_track = (St_tpt_track *) tpc_tracks[
"tptrack"];
00346 Int_t ntks=n_track->GetNRows();
00347
00348
00349 Int_t *sector =
new Int_t[ntks];
00350 Float_t *xl =
new Float_t[ntks];
00351 Float_t *yl =
new Float_t[ntks];
00352 Float_t *zl =
new Float_t[ntks];
00353 Float_t *phil =
new Float_t[ntks];
00354 tpt_track_st *ta = n_track->GetTable();
00355
for(
int itk=0;itk<ntks;itk++,ta++){
00356
if(m_lasers){
00357 DOCA(ta->r0, ta->phi0, ta->z0, ta->psi, ta->tanl, ta->curvature,
00358 ta->q, §or[itk], &xl[itk], &yl[itk], &zl[itk]);
00359 }
00360
else
00361
POCA(ta->r0, ta->phi0, ta->z0, ta->psi, ta->tanl, ta->curvature,
00362 ta->q, &xl[itk], &yl[itk], &zl[itk], &phil[itk]);
00363 }
00364
00365 St_tfc_adcxyz *n_adc = 0;
00366 St_tcl_tphit *n_hit = 0;
00367 St_tcl_tpcluster *n_clus = 0;
00368 TDataSet *tpc_hits = GetDataSet(
"tpc_hits");
00369
if (tpc_hits) {
00370 TDataSetIter tpc_data(tpc_hits);
00371 n_hit = (St_tcl_tphit *) tpc_data[
"tphit"];
00372 n_clus = (St_tcl_tpcluster *) tpc_data[
"tpcluster"];
00373 }
00374
if(n_hit){
00375 tcl_tphit_st *h = n_hit->GetTable();
00376
for (
int i = 0;i<n_hit->GetNRows();i++,h++){
00377
00378
00379 Float_t xhold = h->x;Float_t yhold = h->y;
00380 UndoExB(&h->x,&h->y,&h->z);
00381 Float_t exbdx = h->x - xhold;Float_t exbdy = h->y - yhold;
00382 h->x = xhold;h->y = yhold;
00383 Int_t tof = h->track/1000;
00384
if(tof){
00385 tpt_track_st *te = n_track->GetTable();
00386
for(
int itrk=0;itrk<ntks;itrk++,te++){
00387
if(te->id == tof){
00388 Float_t x1 = te->r0*cos(te->phi0*C_RAD_PER_DEG);
00389 Float_t y1 = te->r0*sin(te->phi0*C_RAD_PER_DEG);
00390 Float_t z1 = te->z0;
00391 Float_t radius = 1.0/te->curvature;
00392 Float_t psic = (te->psi + te->q*90)*C_RAD_PER_DEG;
00393 Float_t xc = x1-radius*cos(psic);
00394 Float_t yc = y1-radius*sin(psic);
00395 Float_t resy = (TMath::Sqrt((h->x-xc)*(h->x-xc)+(h->y-yc)*(h->y-yc))
00396 -radius)/cos(h->alpha*C_RAD_PER_DEG);
00397 Float_t resz = h->z-z1-te->tanl*
00398 TMath::Sqrt((h->x-x1)*(h->x-x1) + (h->y-y1)*(h->y-y1));
00399 Float_t phi = te->psi;
00400
00401
event->AddHit(h->q,h->x,h->y,h->z,h->row,h->track, h->flag,
00402 sector[itrk],zl[itrk],phi,te->invp*te->q,te->nfit,
00403 resy,resz,h->alpha,h->lambda,h->prf,h->zrf,exbdx,exbdy);
00404 }
00405 }
00406 }
00407
else
00408
event->AddHit(h->q,h->x,h->y,h->z,h->row,h->track, h->flag,
00409 0,0,0,0,0,0,0,h->alpha,h->lambda,h->prf,h->zrf,exbdx,exbdy);
00410 }
00411 LOG_INFO << n_hit->GetNRows() <<
" hits, " ;
00412 }
00413 tpt_track_st *t = n_track->GetTable();
00414 Int_t ngtk=0;
00415
for(
int itrk=0;itrk<ntks;itrk++,t++){
00416
if (t->flag>0){
00417 ngtk++;
00418 Float_t phi = t->psi;
00419 Float_t tlam = t->tanl;
00420
event->AddTrack(t->flag,t->hitid,t->id,t->id_globtrk,
00421 t->ndedx, t->nfit, t->nrec, t->npos, t->q,
00422 t->chisq[0], t->chisq[1], t->dedx[0], t->invp, t->curvature,
00423 phi, tlam, t->phi0, t->r0, t->z0, sector[itrk],xl[itrk],
00424 yl[itrk],zl[itrk], phil[itrk] );
00425 Float_t fzl = zl[itrk];
00426 Float_t nfits = t->nfit;
00427
if (fzl > 165 && fzl < 190 && nfits > 15) fzlWestHigh->Fill(fzl);
00428
if (fzl > 15 && fzl < 40 && nfits > 15) fzlWestLow->Fill(fzl);
00429
if (fzl > -190 && fzl < -165 && nfits > 15) fzlEastHigh->Fill(fzl);
00430
if (fzl > -40 && fzl < -15 && nfits > 15) fzlEastLow->Fill(fzl);
00431 fzLaser->Fill(fzl);
00432 }
00433 }
00434 numberTracks->Fill(ngtk);
00435 numberEvents->Fill(1);
00436 LOG_INFO << ntks <<
" total tracks " << ngtk <<
" good tracks" << endm;
00437
delete [] sector;
00438
delete [] xl;
00439
delete [] yl;
00440
delete [] zl;
00441 Int_t npixwrit=0;
00442
00443
00444 TDataSet *tpc_raw = GetDataSet(
"tpc_hits");
00445
if(tpc_raw){
00446 TDataSetIter tpcadc(tpc_raw);
00447 n_adc = (St_tfc_adcxyz *) tpcadc[
"adcxyz"];
00448 }
00449
if(n_adc){
00450
00451 tfc_adcxyz_st *p = n_adc->GetTable();
00452 LOG_INFO << n_adc->GetNRows() <<
" pixels in adcxyz table, " ;
00453
for(
int iadc=0;iadc<n_adc->GetNRows();iadc++,p++){
00454
if(p->row >=m_rowmin && p->row<=m_rowmax){
00455
event->AddPixel(100*p->sector+p->row,p->pad,p->bucket,
00456 p->adc,p->x,p->y,p->z);
00457 npixwrit++;
00458 }
00459 }
00460 }
00461 LOG_INFO << npixwrit <<
" pixels written to event " << evno << endm;
00462
00463 m_laser->Fill();
00464 }
00465 }
00466
00467
00468
00474 void StLaserEventMaker::DOCA(Float_t r0,Float_t phi0,Float_t z0,
00475 Float_t psi, Float_t tanl, Float_t curvature, Int_t q,
00476 Int_t *sector, Float_t *xl, Float_t *yl, Float_t *zl) {
00477
static const Float_t zcut[13]={-165,-140,-105,-75,-45,-15,
00478 15,45,75,105,135,165,195};
00479
static const Float_t zpt[12] = {-179.2, -151.6, -120.5, -90.7, -59.6,
00480 -32.0, 32.0, 59.7, 90.7, 120.6, 151.7, 179.2 };
00481
static const Float_t xpt[12][6]={
00482 { -171.674,-168.918,2.731,171.654,168.907,-2.745},
00483 { -171.445,-169.099,2.294,171.448,169.164,-2.286},
00484 { -172.108,-169.118,2.955,172.127,169.136,-2.962},
00485 { -171.636,-169.594,2.063,171.599,169.566,-2.054},
00486 { -172.343,-169.602,2.713,172.347,169.595,-2.738},
00487 { -172.096,-169.816,2.272,172.117,169.813,-2.247},
00488 { 172.090,169.791,-2.264,-172.120,-169.841,2.256},
00489 { 172.312,169.576,-2.745,-172.316,-169.548,2.747},
00490 { 171.627,169.547,-2.013,-171.652,-169.570,2.062},
00491 { 172.099,169.149,-2.943,-172.100,-169.161,2.977},
00492 { 171.411,169.102,-2.320,-171.410,-169.134,2.292},
00493 { 171.665,168.924,-2.760,-171.664,-168.913,2.745},
00494
00495 };
00496
static const Float_t ypt[12][6]={
00497 {95.937,-100.671,-196.611,-95.927,100.693,196.647},
00498 {96.312,-100.322,-196.623,-96.288,100.308,196.577},
00499 {95.959,-101.048,-197.049,-95.954,101.068,197.007},
00500 {96.718,-100.234,-197.018,-96.708,100.282,197.027},
00501 {96.341,-101.054,-197.440,-96.322,101.066,197.397},
00502 {96.729,-100.653,-197.399,-96.649,100.681,197.387},
00503 {96.744,-100.674,-197.391,-96.676,100.665,197.433},
00504 {96.361,-101.048,-197.385,-96.350,101.162,197.403},
00505 {96.695,-100.269,-196.969,-96.716,100.287,196.998},
00506 {95.944,-101.073,-197.026,-95.949,101.083,197.022},
00507 {96.303,-100.273,-196.630,-96.294,100.281,196.626},
00508 {95.918,-100.714,-196.637,-95.929,100.702,196.627},
00509 };
00510 Float_t x, y, z, disxy;
00511 Int_t iz;
00512
for (iz=0;iz<13;iz++)
if(z0<zcut[iz])
break;
00513
00514 *sector = 99; *xl = 0.0; *yl = 0.0; *zl = 0.0;
00515
if(iz==6)
return;
00516
if(iz>6)iz--;
00517
if(iz>11)
return;
00518
00519
00520 Float_t ang = 0.017453292 * phi0;
00521 Float_t x0 = r0 * cos(ang);
00522 Float_t y0 = r0 * sin(ang);
00523 ang = 0.017453292 * psi;
00524 Float_t px = cos(ang); Float_t py = sin(ang);
00525 Float_t test = 200.0;
00526
if(curvature>0.000001)
00527 {
00528
00529
00530 Double_t xc = x0 + q*py/curvature;
00531 Double_t yc = y0 - q*px/curvature;
00532
for (
int i=0;i<6;i++){
00533 Float_t xp = xpt[iz][i]; Float_t yp= ypt[iz][i];
00534 Double_t d = xc - xp; Double_t a = yc - yp;
00535 Double_t c = d/a;
00536 Double_t dy = 1./TMath::Sqrt(1. + c*c)/curvature;
00537 Double_t dx = c*dy;
00538
if(a<0) { x = xc + dx; y = yc + dy;}
00539
else { x = xc - dx; y = yc - dy;}
00540 Float_t disq = (x-xp)*(x-xp) + (y-yp)*(y-yp);
00541
if (disq<test) {test=disq;
00542 *xl=x; *yl=y; *sector = 2*i+14;
00543
if(iz>5) *sector-=12;
00544 Float_t sign =1.0;
00545
if((*xl*px+*yl*py)<0) sign=-1.0;
00546 disxy = TMath::Sqrt((x-x0)*(x-x0)+ (y-y0)*(y-y0));
00547 *zl = z0 + sign*tanl*disxy;}
00548 }
00549 }
00550
else
00551 {
00552
00553 Float_t slope = tan(psi*0.017453292);
00554 Float_t ax = 1./(x0 - y0/slope);
00555 Float_t ay = 1./(y0 - x0*slope);
00556
for (
int i=0;i<6;i++){
00557 Float_t xp = xpt[iz][i]; Float_t yp= ypt[iz][i];
00558 Float_t d = ax*ax +ay*ay;
00559 x = (ax + ay*ay*xp - ax*ay*yp)/d;
00560 y = (ay + ax*ax*yp - ax*ay*xp)/d;
00561 Float_t sign =1.0;
00562
if((x*px+y*py)<0) sign=-1.0;
00563 disxy = TMath::Sqrt((x-x0)*(x-x0)+ (y-y0)*(y-y0));
00564 z = z0 + sign*tanl*disxy;
00565
if(TMath::Abs(z-zpt[iz])<15.0){
00566 Float_t disq = (x-xp)*(x-xp) + (y-yp)*(y-yp);
00567
if (disq<test) {
00568 test=disq;
00569 *xl=x; *yl=y; *zl=z; *sector = 2*i+14;
00570
if(iz>5) *sector-=12;
00571 }
00572 }
00573 }
00574 }
00575 }
00576
00577
00581 void StLaserEventMaker::POCA(Float_t r0,Float_t phi0,Float_t z0,
00582 Float_t psi, Float_t tanl, Float_t curvature, Int_t q,
00583 Float_t *xl, Float_t *yl, Float_t *zl, Float_t *phil) {
00584 Float_t x, y, z, disxy, xp = 0.15, yp = 0.15;
00585 *xl = 100.0; *yl = 100.0; *zl = 0.0, *phil=0.0;
00586
00587 Float_t ang = 0.017453292 * phi0;
00588 Float_t x0 = r0 * cos(ang);
00589 Float_t y0 = r0 * sin(ang);
00590 ang = 0.017453292 * psi;
00591 Float_t px = cos(ang); Float_t py = sin(ang);
00592 Float_t test = 200.0;
00593
if(curvature>0.0001)
00594 {
00595
00596 Float_t xc = x0 + q*py/curvature;
00597 Float_t yc = y0 - q*px/curvature;
00598 Float_t d = xc - xp; Float_t a = yc - yp;
00599 Float_t c = d/a;
00600 Float_t dy = 1./TMath::Sqrt(1. + c*c)/curvature;
00601 Float_t dx = c*dy;
00602
if(a<0) { x = xc + dx; y = yc + dy;}
00603
else { x = xc - dx; y = yc - dy;}
00604 Float_t disq = (x-xp)*(x-xp) + (y-yp)*(y-yp);
00605
if (disq<test) {
00606 *xl=x; *yl=y;
00607 disxy = TMath::Sqrt((x-x0)*(x-x0)+ (y-y0)*(y-y0));
00608 *zl = z0 - tanl*disxy;
00609
00610 *phil = 57.29578*atan(a/d) +90.0;
00611
if(a*q*(*phil-90.0)<0)*phil+=180.0;
00612 }
00613 }
00614
else
00615 {
00616
00617 Float_t slope = tan(psi*0.017453292);
00618 Float_t ax = 1./(x0 - y0/slope);
00619 Float_t ay = 1./(y0 - x0*slope);
00620 Float_t d = ax*ax +ay*ay;
00621 x = (ax + ay*ay*xp - ax*ay*yp)/d;
00622 y = (ay + ax*ax*yp - ax*ay*xp)/d;
00623
00624 disxy = TMath::Sqrt((x-x0)*(x-x0)+ (y-y0)*(y-y0));
00625 z = z0 + -tanl*disxy;
00626 Float_t disq = (x-xp)*(x-xp) + (y-yp)*(y-yp);
00627
if (disq<test) {
00628 *xl=x; *yl=y; *zl=z; *phil=psi;
00629 }
00630 }
00631 }
00632
00633
00634
00635
00636
00637
00638
00639
00640
00641
00642
00643
00644
00645
00646
00647
00648
00649
void StLaserEventMaker::UndoExB(Float_t *x, Float_t *y, Float_t *z){
00650
00651
const float TAU_1 = 0.35e-10 ;
00652
const float TAU_2 = 0.29e-10 ;
00653
const double PI = 3.14159265 ;
00654
const double ZSCALE = 105.0 ;
00655
const double ROFF = 126.7 ;
00656
const double RSCALE = 66.7 ;
00657
00658
00659
00660
00661
00662
const float Bmax = 2500. ;
00663
const int NCOEFF =22;
00664
const int PCOEFF =19;
00665
00666
00667
double ncoef [22] = { 0.86519044E-01, 0.53515316E-01, 0.76126441E-01,
00668 -0.25630806E-01, 0.39710304E-01,-0.23678712E-01,
00669 0.21143267E-01, 0.21130090E-01,-0.27967561E-01,
00670 0.14842647E-01, 0.18729207E-01, 0.91055100E-02,
00671 0.12635363E-01, 0.12567390E-01,-0.10256438E-01,
00672 0.71242234E-02, 0.49913415E-02,-0.40337429E-02,
00673 0.31642346E-02,-0.82095956E-02,-0.64247543E-02,
00674 0.36472205E-02 } ;
00675
00676
int ibasng [22][3] = { { 10, 0, 0},{ 20, 10, 0},{ 10, 10, 0},
00677 { 0, 20, 0},{ 20, 0, 0},{ 30, 0, 0},
00678 { 0, 30, 0},{ 0, 0, 0},{ 30, 10, 0},
00679 { 10, 20, 0},{ 20, 20, 0},{ 0, 40, 0},
00680 { 0, 10, 20},{ 10, 30, 0},{ 30, 20, 0},
00681 { 10, 0, 40},{ 0, 0, 50},{ 40, 0, 0},
00682 { 0, 0, 40},{ 10, 10, 30},{ 0, 10, 30},
00683 { 0, 0, 30} } ;
00684
00685
double pcoef [19] = {-0.56271269E-01, 0.56316758E-01, 0.32334931E-01,
00686 -0.40870593E-01,-0.26015326E-01, 0.30634023E-01,
00687 -0.19830788E-01, 0.51648488E-01, 0.81722594E-02,
00688 -0.21299166E-01,-0.21224224E-01, 0.11237955E-01,
00689 -0.91026999E-02,-0.76372695E-02, 0.12071229E-01,
00690 0.11819910E-01,-0.99196176E-02, 0.49532689E-02,
00691 0.58692146E-02 } ;
00692
00693
int ibasps [19][3] = {{ 20, 10, 0},{ 10, 0, 0},{ 0, 10, 0},
00694 { 20, 0, 0},{ 30, 10, 0},{ 0, 20, 0},
00695 { 0, 30, 0},{ 10, 10, 0},{ 0, 0, 0},
00696 { 30, 0, 0},{ 20, 20, 0},{ 10, 20, 0},
00697 { 0, 40, 0},{ 0, 0, 20},{ 10, 30, 0},
00698 { 10, 0, 20},{ 30, 20, 0},{ 40, 0, 0},
00699 { 10, 0, 30} } ;
00700
00701
00702
double Omega, Const_1, Const_2 ;
00703
double p, p0, p1, p2, phi ;
00704
float r, xv[3] ;
00705
float brobz, delxy[2], xp, yp, zp ;
00706
int num ;
00707
00708
00709 Omega = Bmax * 8.9875518e6 / 0.511 ;
00710 Const_1 = Omega*TAU_1 / ( 1. + Omega*TAU_1*Omega*TAU_1 ) ;
00711 Const_2 = Omega*TAU_2*Omega*TAU_2 / ( 1. + Omega*TAU_2*Omega*TAU_2 ) ;
00712 xp = *x;
00713 yp = *y;
00714 zp = *z;
00715 r = TMath::Sqrt( xp*xp + yp*yp ) ;
00716 xv[1] = ( r - ROFF ) / RSCALE ;
00717 phi = atan2( yp, xp ) ;
00718
if ( phi < 0 ) phi = phi + 2*PI ;
00719 xv[2] = ( phi - PI ) / PI ;
00720
00721 brobz = 0.0 ;
00722
00723
if ( zp < 0 )
00724
00725 {
00726 xv[0] = ( zp + ZSCALE ) / ZSCALE ;
00727
for (
int k = 0 ; k < NCOEFF ; k++ )
00728 {
00729 p = 1 ;
00730
for (
int i = 0 ; i < 3 ; i++ )
00731 {
00732 num = ibasng[k][i] / 10 ;
00733
if ( num != 0 )
00734 {
00735 p0 = 1.0 ;
00736 p1 = xv[i] ;
00737
for (
int j = 2 ; j <= num ; j++ )
00738 {
00739 p2 = 2 * xv[i] * p1 - p0 ;
00740 p0 = p1 ;
00741 p1 = p2 ;
00742 }
00743 p = p * p1 ;
00744 }
00745 }
00746 brobz = brobz + ncoef[k] * p ;
00747 }
00748 delxy[0] = brobz * (Const_2*cos(phi) + Const_1*sin(phi)) ;
00749 delxy[1] = brobz * (Const_2*sin(phi) - Const_1*cos(phi)) ;
00750 }
00751
00752
else
00753
00754 {
00755 xv[0] = ( zp - ZSCALE ) / ZSCALE ;
00756
for (
int k = 0 ; k < PCOEFF ; k++ )
00757 {
00758 p = 1 ;
00759
for (
int i = 0 ; i < 3 ; i++ )
00760 {
00761 num = ibasps[k][i] / 10 ;
00762
if ( num != 0 )
00763 {
00764 p0 = 1.0 ;
00765 p1 = xv[i] ;
00766
for (
int j = 2 ; j <= num ; j++ )
00767 {
00768 p2 = 2 * xv[i] * p1 - p0 ;
00769 p0 = p1 ;
00770 p1 = p2 ;
00771 }
00772 p = p * p1 ;
00773 }
00774 }
00775 brobz = brobz + pcoef[k] * p ;
00776 }
00777 delxy[0] = -brobz * (Const_2*cos(phi) + Const_1*sin(phi)) ;
00778 delxy[1] = -brobz * (Const_2*sin(phi) - Const_1*cos(phi)) ;
00779 }
00780 xp = xp + delxy[0];
00781 yp = yp + delxy[1];
00782
00783 *x = xp; *y = yp; *z = zp;
00784 }
00785
00786
00787 Int_t
StLaserEventMaker::Finish() {
00788
if (numberTracks){
00789
00790
if (fzlIntegralEastHigh()/nEvents() < 1. || fzlIntegralEastLow()/nEvents() < 1.) {
00791 gMessMgr->
Warning() <<
"StLaserEventMaker::no east laser events. Drift Velocity east and west will be the same!!! " << endm;
00792
if (nTracks() >= minValidTracks/2.) {
00793 velocityWest = 147.164*driftVelocityReco/fabs(fzlAverageWestHigh()-fzlAverageWestLow());
00794 velocityEast = velocityWest;
00795
00796
00797
00798 velocityEast = velocityEast*(1./(1.-velocityEast/29979245800.));
00799 velocityWest = velocityWest*(1./(1.-velocityWest/29979245800.));
00800
00801 velocityEast = velocityEast*clock/clockNominal;
00802 velocityWest = velocityWest*clock/clockNominal;
00803 velocityEast = velocityEast/1000000.0;
00804 velocityWest = velocityWest/1000000.0;
00805
if ((velocityWest > 5.) && (velocityEast > 5.)) {
00806 WriteTableToFile();
00807 }
else {
00808 gMessMgr->
Error() <<
"StLaserEventMaker:: no laser events. Drift Velocity East = " << velocityEast <<
" and Drift Velocity West = " << velocityWest <<
" which is lower than the minimum of " <<
" 5.0 cm/us" << endm;
00809 }
00810 }
else {
00811 gMessMgr->
Error() <<
"StLaserEventMaker:: no laser events. Number Tracks = " << numberTracks->GetMean() <<
" which is lower than the minimum of " << minValidTracks/2. <<
" tracks requested for good laser events when one of the lasers (east or west) is down. No table will be written" << endm;
00812 }
00813 }
else {
00814
00815
if (fzlIntegralWestHigh()/nEvents() < 1. || fzlIntegralWestLow()/nEvents() < 1.) {
00816 gMessMgr->
Warning() <<
"StLaserEventMaker:: no west laser events. Drift Velocity east and west will be the same!!! " << endm;
00817
if (nTracks() >= minValidTracks/2.) {
00818 velocityEast = 147.199*driftVelocityReco/fabs(fzlAverageEastHigh()-fzlAverageEastLow());
00819 velocityWest = velocityEast;
00820
00821
00822
00823 velocityEast = velocityEast*(1./(1.-velocityEast/29979245800.));
00824 velocityWest = velocityWest*(1./(1.-velocityWest/29979245800.));
00825
00826 velocityEast = velocityEast*clock/clockNominal;
00827 velocityWest = velocityWest*clock/clockNominal;
00828 velocityEast = velocityEast/1000000.0;
00829 velocityWest = velocityWest/1000000.0;
00830
if ((velocityWest > 5.) && (velocityEast > 5.)) {
00831 WriteTableToFile();
00832 }
else {
00833 gMessMgr->
Error() <<
"StLaserEventMaker:: no laser events. Drift Velocity East = " << velocityEast <<
" and Drift Velocity West = " << velocityWest <<
" which is lower than the minimum of " <<
" 5.0 cm/us" << endm;
00834 }
00835 }
else {
00836 gMessMgr->
Error() <<
"StLaserEventMaker:: no laser events. Number Tracks = " << numberTracks->GetMean() <<
" which is lower than the minimum of " << minValidTracks/2. <<
" tracks requested for good laser events when one of the lasers (east or west) is down. No table will be written" << endm;
00837 }
00838 }
else {
00839
00840
if (nTracks() >= minValidTracks) {
00841 velocityEast = 147.199*driftVelocityReco/fabs(fzlAverageEastHigh()-fzlAverageEastLow());
00842 velocityWest = 147.164*driftVelocityReco/fabs(fzlAverageWestHigh()-fzlAverageWestLow());
00843
00844
00845
00846 velocityEast = velocityEast*(1./(1.-velocityEast/29979245800.));
00847 velocityWest = velocityWest*(1./(1.-velocityWest/29979245800.));
00848
00849 velocityEast = velocityEast*clock/clockNominal;
00850 velocityWest = velocityWest*clock/clockNominal;
00851 velocityEast = velocityEast/1000000.0;
00852 velocityWest = velocityWest/1000000.0;
00853
if ((velocityWest > 5.) && (velocityEast > 5.)) {
00854 WriteTableToFile();
00855 }
else {
00856 gMessMgr->
Error() <<
"StLaserEventMaker:: no laser events. Drift Velocity East = " << velocityEast <<
" and Drift Velocity West = " << velocityWest <<
" which is lower than the minimum of " <<
" 5.0 cm/us" << endm;
00857 }
00858 }
else {
00859 gMessMgr->
Error() <<
"StLaserEventMaker:: no laser events. Number Tracks = " << numberTracks->GetMean() <<
" which is lower than the minimum of " << minValidTracks <<
" tracks requested for good laser events. No table will be written" << endm;
00860 }
00861 }
00862 }
00863 }
else {
00864 gMessMgr->
Error() <<
"StLaserEventMaker:: completly empty. Are sure you called this maker on laser events ?? No table will be written ... " << endm;
00865 }
00866
00867
if (mHistOut){
00868 WriteHistFile();
00869 }
00870
return StMaker::Finish();
00871 }
00872
00873
00875 void StLaserEventMaker::PrintInfo() {
00876 LOG_INFO <<
"**************************************************************" << endm;
00877 LOG_INFO <<
"* $Id: StLaserEventMaker.cxx,v 1.38 2007/10/16 15:28:42 fisyak Exp $" << endm;;
00878 LOG_INFO <<
"**************************************************************" << endm;
00879
00880
if (Debug()) StMaker::PrintInfo();
00881 }
00882
00883
00884
void StLaserEventMaker::WriteTableToFile(){
00885
char filename[80];
00886
00887 sprintf(filename,
"./StarDb/Calibrations/tpc/tpcDriftVelocity.%08d.%06d.C",date,time);
00888 TString dirname = gSystem->DirName(filename);
00889
if (gSystem->OpenDirectory(dirname.Data())==0) {
00890
if (gSystem->mkdir(dirname.Data())) {
00891 LOG_INFO <<
"Directory " << dirname <<
" creation failed" << endm;
00892 LOG_INFO <<
"Putting tpcDriftVelocity.C in current directory" << endm;
00893
for (
int i=0;i<80;i++){filename[i]=0;}
00894 sprintf(filename,
"tpcDriftVelocity.%08d.%06d.C",date,time);
00895 }
00896 }
00897 ofstream *out =
new ofstream(filename);
00898 driftTable()->SavePrimitive(*out,
"");
00899
return;
00900 }
00901
00902 St_tpcDriftVelocity* StLaserEventMaker::driftTable(){
00903 St_tpcDriftVelocity* table =
new St_tpcDriftVelocity(
"tpcDriftVelocity",1);
00904 tpcDriftVelocity_st* row = table->GetTable();
00905 row->cathodeDriftVelocityEast = 0.0;
00906 row->cathodeDriftVelocityWest = 0.0;
00907 row->laserDriftVelocityEast = velocityEast;
00908 row->laserDriftVelocityWest = velocityWest;
00909 table->SetNRows(1);
00910
return table;
00911 }
00912
00913
void StLaserEventMaker::WriteHistFile(){
00914
char filename[80];
00915 sprintf(filename,
"laserhist.%08d.%06d.root",date,time);
00916 TFile out(filename,
"RECREATE");
00917 GetHistList()->Write();
00918 out.Close();
00919 }
00920
00921
00922
double StLaserEventMaker::fzlAverageEastHigh(){
00923
int nBins = fzlEastHigh->GetNbinsX();
00924
int binMax = fzlEastHigh->GetMaximumBin();
00925
int minBin = TMath::Max(1,binMax-20);
00926
int maxBin = TMath::Min(nBins,binMax+20);
00927 fzlEastHigh->GetXaxis()->SetRange(minBin,maxBin);
00928
double mean = fzlEastHigh->GetMean();
00929 fzlEastHigh->GetXaxis()->SetRange(1,nBins);
00930
return mean;
00931 };
00932
double StLaserEventMaker::fzlAverageEastLow(){
00933
int nBins = fzlEastLow->GetNbinsX();
00934
int binMax = fzlEastLow->GetMaximumBin();
00935
int minBin = TMath::Max(1,binMax-20);
00936
int maxBin = TMath::Min(nBins,binMax+20);
00937 fzlEastLow->GetXaxis()->SetRange(minBin,maxBin);
00938
double mean = fzlEastLow->GetMean();
00939 fzlEastLow->GetXaxis()->SetRange(1,nBins);
00940
return mean;
00941 };
00942
double StLaserEventMaker::fzlAverageWestHigh(){
00943
int nBins = fzlWestHigh->GetNbinsX();
00944
int binMax = fzlWestHigh->GetMaximumBin();
00945
int minBin = TMath::Max(1,binMax-20);
00946
int maxBin = TMath::Min(nBins,binMax+20);
00947 fzlWestHigh->GetXaxis()->SetRange(minBin,maxBin);
00948
double mean = fzlWestHigh->GetMean();
00949 fzlWestHigh->GetXaxis()->SetRange(1,nBins);
00950
return mean;
00951 };
00952
double StLaserEventMaker::fzlAverageWestLow(){
00953
int nBins = fzlWestLow->GetNbinsX();
00954
int binMax = fzlWestLow->GetMaximumBin();
00955
int minBin = TMath::Max(1,binMax-20);
00956
int maxBin = TMath::Min(nBins,binMax+20);
00957 fzlWestLow->GetXaxis()->SetRange(minBin,maxBin);
00958
double mean = fzlWestLow->GetMean();
00959 fzlWestLow->GetXaxis()->SetRange(1,nBins);
00960
return mean;
00961 }
00962
double StLaserEventMaker::nTracks(){
double mean = numberTracks->GetMean();
return mean;};
00963
double StLaserEventMaker::fzlIntegralEastHigh(){
double integral = fzlEastHigh->Integral();
return integral;};
00964
double StLaserEventMaker::fzlIntegralEastLow(){
double integral = fzlEastLow->Integral();
return integral;};
00965
double StLaserEventMaker::fzlIntegralWestHigh(){
double integral = fzlWestHigh->Integral();
return integral;};
00966
double StLaserEventMaker::fzlIntegralWestLow(){
double integral = fzlWestLow->Integral();
return integral;};
00967
double StLaserEventMaker::nEvents(){
double integral = numberEvents->Integral();
return integral;};
00968