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
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
#include "Stiostream.h"
00120
#include "StPixelFastSimMaker.h"
00121
#include "StHit.h"
00122
#include "StEventTypes.h"
00123
#include "StEvent.h"
00124
#include "StRnDHit.h"
00125
#include "StMcEvent.hh"
00126
#include "StMcHit.hh"
00127
#include "StMcIstHit.hh"
00128
00129
#include "StMcPixelHit.hh"
00130
#include "StMcEventTypes.hh"
00131
#ifdef bug1056
00132
#include "Sti/Base/Factory.h"
00133
#include "Sti/StiPlanarShape.h"
00134
#include "Sti/StiCylindricalShape.h"
00135
#include "Sti/StiMaterial.h"
00136
#include "Sti/StiPlacement.h"
00137
#include "Sti/StiDetector.h"
00138
#include "Sti/StiToolkit.h"
00139
#include "Sti/StiDetectorBuilder.h"
00140
#endif
00141
#include <stdio.h>
00142
#include <map>
00143
#include <exception>
00144
using namespace std;
00145
#include <stdexcept>
00146
#include "tables/St_g2t_ist_hit_Table.h"
00147
#include "tables/St_g2t_pix_hit_Table.h"
00148
#include "tables/St_HitError_Table.h"
00149
#ifdef bug1056
00150
#include "Sti/StiHitErrorCalculator.h"
00151
#include "Sti/StiIsActiveFunctor.h"
00152
#include "Sti/StiNeverActiveFunctor.h"
00153
#include "Sti/StiElossCalculator.h"
00154
#include "Sti/StiVMCToolKit.h"
00155
#else
00156
#include "TGeoManager.h"
00157
#include "TGeoMatrix.h"
00158
#endif
00159
#include "StarClassLibrary/StRandom.hh"
00160
#include "tables/St_HitError_Table.h"
00161
#include <fstream>
00162
#include "TFile.h"
00163
#include "TTree.h"
00164
00165 ClassImp(
StPixelFastSimMaker)
00166
00167
00168
StPixelFastSimMaker::~
StPixelFastSimMaker(){ }
00169
00170
int StPixelFastSimMaker::Init()
00171 {
00172 LOG_INFO<<
"StPixelFastSimMaker::Init()"<<endm;
00173
int seed=time(NULL);
00174 myRandom=
new StRandom();
00175 myRandom->setSeed(seed);
00176
00177
00178 mSmear=1;
00179
return kStOk;
00180 }
00181
00182
00183
int StPixelFastSimMaker::InitRun(
int RunNo)
00184 {
00185 LOG_INFO<<
"StPixelFastSimMaker::InitRun"<<endm;
00186
00187 TDataSet *set = GetDataBase(
"Calibrations/tracker");
00188 St_HitError *istTableSet = (St_HitError *)set->Find(
"ist1HitError");
00189 St_HitError *pixelTableSet = (St_HitError *)set->Find(
"PixelHitError");
00190
00191 HitError_st* istHitError = istTableSet->GetTable();
00192 resXIst1 = sqrt(istHitError->coeff[0]);
00193 resZIst1 = sqrt(istHitError->coeff[3]);
00194 HitError_st* pixelHitError = pixelTableSet->GetTable();
00195 resXPix = sqrt(pixelHitError->coeff[0]);
00196 resZPix = sqrt(pixelHitError->coeff[3]);
00197
00198 LoadPixPileUpHits();
00199
00200
00201
return kStOk;
00202 }
00203
00204
00205
void StPixelFastSimMaker::LoadPixPileUpHits()
00206 {
00207 LOG_INFO<<
"+++ loading the PIXEL pileup files +++"<<endm;
00208
00209 pileup_on =
true;
00210
00211 TFile f_pileup(
"pileup.root");
00212
if (f_pileup.IsZombie()) {
00213
00214 pileup_on =
false;
00215
00216 LOG_INFO <<
"no PIXEL pileup file found. Will run with regular setup" << endm;
00217
return;
00218 }
00219
00220 LOG_INFO<<
"+++ Loaded pileup.root for PIXEL pileup simulation +++"<<endm;
00221
00222 TTree* pileup_tree = (TTree*)f_pileup.Get(
"pileup_tree");
00223
00224
const int maxhit = 200000;
00225
float x[maxhit], y[maxhit], z[maxhit], px[maxhit], py[maxhit], pz[maxhit], de[maxhit], ds[maxhit];
00226
long key[maxhit], vid[maxhit];
00227
int layer[maxhit], nhits;
00228
00229 TBranch *b_x = pileup_tree->GetBranch(
"x");
00230 TBranch *b_y = pileup_tree->GetBranch(
"y");
00231 TBranch *b_z = pileup_tree->GetBranch(
"z");
00232 TBranch *b_px = pileup_tree->GetBranch(
"px");
00233 TBranch *b_py = pileup_tree->GetBranch(
"py");
00234 TBranch *b_pz = pileup_tree->GetBranch(
"pz");
00235 TBranch *b_de = pileup_tree->GetBranch(
"de");
00236 TBranch *b_ds = pileup_tree->GetBranch(
"ds");
00237 TBranch *b_key = pileup_tree->GetBranch(
"key");
00238 TBranch *b_vid = pileup_tree->GetBranch(
"vid");
00239 TBranch *b_layer = pileup_tree->GetBranch(
"layer");
00240 TBranch *b_nhits = pileup_tree->GetBranch(
"nhits");
00241 b_x->SetAddress(x);
00242 b_y->SetAddress(y);
00243 b_z->SetAddress(z);
00244 b_px->SetAddress(px);
00245 b_py->SetAddress(py);
00246 b_pz->SetAddress(pz);
00247 b_de->SetAddress(de);
00248 b_ds->SetAddress(de);
00249 b_key->SetAddress(key);
00250 b_vid->SetAddress(vid);
00251 b_layer->SetAddress(layer);
00252 b_nhits->SetAddress(&nhits);
00253
00254 pileup_tree->GetEntry(0);
00255
00256
for(
int ihit = 0; ihit<nhits; ihit++) {
00257 pileup_x.push_back(x[ihit]);
00258 pileup_y.push_back(y[ihit]);
00259 pileup_z.push_back(z[ihit]);
00260
00261 pileup_px.push_back(px[ihit]);
00262 pileup_py.push_back(py[ihit]);
00263 pileup_pz.push_back(pz[ihit]);
00264
00265 pileup_key.push_back(key[ihit]);
00266 pileup_vid.push_back(vid[ihit]);
00267
00268 pileup_de.push_back(de[ihit]);
00269 pileup_ds.push_back(ds[ihit]);
00270 }
00271 }
00272
00273
void StPixelFastSimMaker::AddPixPileUpHit(StMcPixelHitCollection* pixHitCol)
00274 {
00275
for(
unsigned int i = 0; i<pileup_x.size(); i++) {
00276
00277 StThreeVectorD pos(pileup_x[i], pileup_y[i], pileup_z[i]);
00278 StThreeVectorF mom(pileup_px[i], pileup_py[i], pileup_pz[i]);
00279
00280
float de = pileup_de[i];
00281
float ds = pileup_ds[i];
00282
00283
int key = pileup_key[i];
00284
int vid = pileup_vid[i];
00285
00286 StMcPixelHit* pixhit =
new StMcPixelHit(pos, mom, de, ds, key, vid, 0);
00287 pixHitCol->addHit(pixhit);
00288 }
00289 }
00290
00291
00292 Int_t
StPixelFastSimMaker::Make()
00293 {
00294 LOG_INFO<<
"StPixelFastSimMaker::Make()"<<endm;
00295
00296
00297
StEvent* rcEvent = (
StEvent*) GetInputDS(
"StEvent");
00298
if (! rcEvent) {LOG_INFO <<
"No StEvent on input" << endl;
return kStWarn;}
00299
StMcEvent* mcEvent = (
StMcEvent *) GetInputDS(
"StMcEvent");
00300
if (! mcEvent) {LOG_INFO <<
"No StMcEvent on input" << endl;
return kStWarn;}
00301 TDataSetIter geant(GetInputDS(
"geant"));
00302
if (! gGeoManager) GetDataBase(
"VmcGeometry");
00303 g2t_ist_hit_st* g2tIst=0;
00304 g2t_pix_hit_st* g2tPix=0;
00305 St_g2t_ist_hit *g2t_ist_hit=(St_g2t_ist_hit *)geant(
"g2t_ist_hit");
00306 St_g2t_pix_hit *g2t_pix_hit=(St_g2t_pix_hit *)geant(
"g2t_pix_hit");
00307
if(g2t_ist_hit) g2tIst=g2t_ist_hit->GetTable();
00308
if(g2t_pix_hit) g2tPix=g2t_pix_hit->GetTable();
00309
00310
00311
StRnDHitCollection *col =
new StRnDHitCollection;
00312
if (!col )
00313 {
00314 gMessMgr->
Info()<<
"StPixelFastSimMaker -E- no RnDHitCollection!\n";
00315 abort();
00316 }
00317
00318
00319
00320 StThreeVectorF mHitError(0.,0.,0.);
00321
00322
00323 StMcPixelHitCollection* pixHitCol = mcEvent->
pixelHitCollection();
00324
int nPixelPerWaferX=640;
00325
int nPixelPerWaferZ=640;
00326
int nWaferPerLadder=10;
00327
double pixelWidth=.003;
00328
float pixWaferHalf=.96;
00329
unsigned int nPixLadders[2]={9,24};
00330
00331 vector<int> pixels;
00332 vector<StMcPixelHit*> pixLadderHits;
00333 multimap<int,int> pixelToKey;
00334
int vid;
00335
float smearedX,smearedZ;
00336
00337
if (pixHitCol){
00338
int layer,ladder;
00339
int counter_layer1 = 0;
00340
int counter_layer2 = 0;
00341
int counter = 0;
00342
float rad = 0;
00343
if(pileup_on) AddPixPileUpHit(pixHitCol);
00344
00345 Int_t nhits = pixHitCol->numberOfHits();
00346 LOG_DEBUG<<
"There are "<<nhits<<
" pixel hits"<<endm;
00347
if (nhits){
00348 Int_t
id = col->
numberOfHits();
00349
if(g2tPix){
00350
for(
int jj=0;jj<g2t_pix_hit->GetTableSize();jj++)
00351 {
00352 rad = TMath::Sqrt(g2tPix[jj].x[0]*g2tPix[jj].x[0] + g2tPix[jj].x[1]*g2tPix[jj].x[1]);
00353
if((rad>2.2) && (rad<2.7)) {
00354 counter_layer1++;
00355 LOG_DEBUG <<
"radius="<<rad<<
" id="<<g2tPix[jj].id <<
" x="<<g2tPix[jj].x[0]<<
" y="<<g2tPix[jj].x[1]<<
" z="<<g2tPix[jj].x[2]<<
" truth is "<<g2tPix[jj].track_p<<
" dE= "<<g2tPix[jj].de <<
" counter layer 1 =" << counter_layer1 << endm;
00356 }
00357
else if((rad>7.9) && (rad<8.2)) {
00358 counter_layer2++;
00359 LOG_DEBUG <<
"radius="<<rad<<
" id="<<g2tPix[jj].id <<
" x="<<g2tPix[jj].x[0]<<
" y="<<g2tPix[jj].x[1]<<
" z="<<g2tPix[jj].x[2]<<
" truth is "<<g2tPix[jj].track_p<<
" dE= "<<g2tPix[jj].de <<
" counter layer 2 =" << counter_layer2 <<endm;
00360 }
00361 }
00362 }
00363 LOG_DEBUG <<
" there is " << counter_layer1 <<
" hits in the first layer " << endm;
00364 LOG_DEBUG <<
" there is " << counter_layer2 <<
" hits in the second layer " << endm;
00365
00366
for (UInt_t k=0; k<pixHitCol->numberOfLayers(); k++){
00367
if (pixHitCol->layer(k)){
00368 LOG_DEBUG<<
"Layer "<<k+1<<endm;
00369
00370
00371 UInt_t nh = pixHitCol->layer(k)->hits().size();
00372 LOG_DEBUG <<
" Number of hits in layer "<< k+1 <<
" =" << nh << endm;
00373
for (UInt_t i = 0; i < nh; i++){
00374 counter++;
00375
int vid=g2tPix[k].volume_id;
00376
int layer=vid/1000000;
00377
int ladder=(vid%1000000)/10000;
00378 StMcHit *mcH = pixHitCol->layer(k)->hits()[i];
00379 StMcPixelHit* mcPix=dynamic_cast<StMcPixelHit*>(mcH);
00380 TString Path(
"");
00381
if(k==0) Path= Form(
"/HALL_1/CAVE_1/PXMO_1/PXLA_1/PLMI_%i/PLAC_1",mcPix->ladder());
00382
else Path=Form(
"/HALL_1/CAVE_1/PXMO_1/PXL1_2/PLM1_%i/PLA1_1",mcPix->ladder());
00383
00384 LOG_DEBUG<<
"pixel hit layer/ladder is "<<layer<<
"/"<<ladder<<
" and volume id "<<vid<<endm;
00385 gGeoManager->RestoreMasterVolume();
00386 gGeoManager->CdTop();
00387 gGeoManager->cd(Path);
00388
00389
double globalPixHitPos[3]={mcPix->position().x(),mcPix->position().y(),mcPix->position().z()};
00390
double localPixHitPos[3]={0,0,0};
00391 gGeoManager->GetCurrentMatrix()->MasterToLocal(globalPixHitPos,localPixHitPos);
00392 smearedX=distortHit(localPixHitPos[0],resXPix,100);
00393 smearedZ=distortHit(localPixHitPos[2],resZPix,100);
00394 localPixHitPos[0]=smearedX;
00395 localPixHitPos[2]=smearedZ;
00396
double smearedGlobalPixHitPos[3]={0,0,0};
00397 gGeoManager->GetCurrentMatrix()->LocalToMaster(localPixHitPos,smearedGlobalPixHitPos);
00398 StThreeVectorF gpixpos(smearedGlobalPixHitPos);
00399 StThreeVectorD mRndHitError(0.,0.,0.);
00400
00401
StRnDHit* tempHit =
new StRnDHit(gpixpos, mRndHitError, 1, 1., 0, 1, 1,
id++, kPxlId);
00402 tempHit->
setVolumeId(mcPix->volumeId());
00403 tempHit->
setLayer(k+1);
00404 tempHit->
setLadder(mcPix->ladder());
00405 tempHit->
setKey(mcPix->key());
00406 Int_t truth =0;
00407
if((k==0)&&(counter<=counter_layer1)) {
00408 truth = g2tPix[mcPix->key()-1].track_p;
00409 }
00410
else if((k==1)&&(counter<=(counter_layer2+pixHitCol->layer(0)->hits().size())))
00411 {
00412 truth = g2tPix[mcPix->key()-1].track_p;
00413 }
00414 tempHit->
setIdTruth(truth,100);
00415 LOG_DEBUG<<
"key() : "<< mcPix->key()-1 <<
" idTruth: "<< truth <<endm;
00416
00417 LOG_DEBUG<<
"pixel rnd hit location x: "<<tempHit->
position().x()<<
"; y: "<<tempHit->
position().y()<<
"; z: "<<tempHit->
position().z()<<endm;
00418
00419 col->
addHit(tempHit);
00420 }
00421 }
00422 }
00423 }
00424 gMessMgr->
Info() <<
"StPixelFastSimMaker::Make() -I- Loaded "<<nhits<<
"pixel hits. \n";
00425 }
00426
else{
00427 gMessMgr->
Info() <<
"No pixel hits found.\n";
00428 }
00429
00430
00431
const StMcIstHitCollection* istHitCol = mcEvent->
istHitCollection();
00432
00433
00434
int nLadders=24;
00435
int nWafers=12;
00436
unsigned int ladderCount;
00437
unsigned int waferCount;
00438
double pos[3];
00439
double localpos[3];
00440
double gpos[3];
00441
int id=0;
00442
00443 TString Path(
"");
00444
if(istHitCol){
00445 LOG_INFO<<
"ist hit collection found"<<endm;
00446
int nIsthits=istHitCol->numberOfHits();
00447 LOG_DEBUG<<
"there are "<<nIsthits<<
" ist hits"<<endm;
00448 vector<StMcIstHit*> ladderHits;
00449
if(nIsthits){
00450
if(istHitCol->layer(0)){
00451
00452
00453
for(
unsigned int kk=0;kk<istHitCol->layer(0)->hits().size();kk++){
00454 StMcHit* mcH=istHitCol->layer(0)->hits()[kk];
00455 StMcIstHit* mcI=dynamic_cast<StMcIstHit*>(mcH);
00456 LOG_DEBUG<<
"mc ist hit location x: "<<mcI->position().x()<<
"; y: "<<mcI->position().y()<<
"; z: "<<mcI->position().z()<<endm;
00457 TString Path(
"");
00458 Path=Form(
"/HALL_1/CAVE_1/IBMO_1/IBMY_1/IBAM_%i/IBLM_%i/IBSS_1",mcI->ladder(),mcI->wafer());
00459 gGeoManager->RestoreMasterVolume();
00460 gGeoManager->CdTop();
00461 gGeoManager->cd(Path);
00462
double globalIstHitPos[3]={mcI->position().x(),mcI->position().y(),mcI->position().z()};
00463
double localIstHitPos[3]={0,0,0};
00464 gGeoManager->GetCurrentMatrix()->MasterToLocal(globalIstHitPos,localIstHitPos);
00465 smearedX=distortHit(localIstHitPos[0],resXIst1,100);
00466 smearedZ=distortHit(localIstHitPos[2],resZIst1,100);
00467 localIstHitPos[0]=smearedX;
00468 localIstHitPos[2]=smearedZ;
00469
double smearedGlobalIstHitPos[3]={0,0,0};
00470 gGeoManager->GetCurrentMatrix()->LocalToMaster(localIstHitPos,smearedGlobalIstHitPos);
00471 StThreeVectorF gistpos(smearedGlobalIstHitPos);
00472
StRnDHit* tempHit =
new StRnDHit(gistpos, mHitError, 1, 1., 0, 1, 1,
id++, kIstId);
00473 tempHit->
setDetectorId(kIstId);
00474 tempHit->
setVolumeId(mcI->volumeId());
00475 tempHit->
setKey(mcI->key());
00476 tempHit->
setLayer(1);
00477 tempHit->
setLadder(mcI->ladder());
00478 tempHit->
setWafer(mcI->wafer());
00479 tempHit->
setIdTruth(g2tIst[kk].track_p,100);
00480 LOG_DEBUG<<
"ist hit volume id: "<<tempHit->
volumeId()<<endm;
00481 LOG_DEBUG<<
"ist hit ladder/wafer: "<<tempHit->
ladder()<<
"/"<<tempHit->
wafer()<<endm;
00482 col->
addHit(tempHit);
00483 LOG_DEBUG<<
"ist rnd hit location x: "<<tempHit->
position().x()<<
"; y: "<<tempHit->
position().y()<<
"; z: "<<tempHit->
position().z()<<
" idTruth = " << g2tIst[kk].track_p << endm;
00484 }
00485 }
00486 }
00487 }
00488
else{
00489 LOG_INFO <<
"No Ist hits found."<<endm;
00490 }
00491
00492
00493
const StMcFgtHitCollection* fgtHitCol = mcEvent->
fgtHitCollection();
00494
if (fgtHitCol)
00495 {
00496 Int_t nhits = fgtHitCol->numberOfHits();
00497
if (nhits)
00498 {
00499 Int_t
id = 0;
00500
00501
00502
for (UInt_t k=0; k<fgtHitCol->numberOfLayers(); k++){
00503
if (fgtHitCol->layer(k))
00504 {
00505 UInt_t nh = fgtHitCol->layer(k)->hits().size();
00506
for (UInt_t i = 0; i < nh; i++) {
00507 StMcHit *mcH = fgtHitCol->layer(k)->hits()[i];
00508
StRnDHit* tempHit =
new StRnDHit(mcH->position(), mHitError, 1, 1., 0, 1, 1,
id++);
00509 tempHit->
setVolumeId(mcH->volumeId());
00510 tempHit->
setKey(mcH->key());
00511
00512 StMcIstHit *mcI = dynamic_cast<StMcIstHit*>(mcH);
00513
if(mcI){
00514 tempHit->
setLayer(mcI->layer());
00515 tempHit->
setLadder(mcI->ladder());
00516 tempHit->
setWafer(mcI->wafer());
00517
00518 }
00519 col->
addHit(tempHit);
00520 }
00521 }
00522 }
00523 }
00524 }
00525
00526 rcEvent->
setRnDHitCollection(col);
00527
return kStOK;
00528 }
00529
00530 Bool_t StPixelFastSimMaker::accept(
StEvent* event){
00531
return event ?
true :
false;
00532 }
00533
00534 Bool_t StPixelFastSimMaker::accept(
StMcEvent* event){
00535
return event ?
true :
false;
00536 }
00537
00538
double StPixelFastSimMaker::distortHit(
double x,
double res,
double detLength){
00539
double test;
00540
if(mSmear){
00541 test = x + myRandom->gauss(0,res);
00542
while( fabs(test) > detLength){
00543 test = x + myRandom->gauss(0,res);
00544 }
00545
00546
return test;
00547 }
00548
else return x;
00549 }
00550
00551
00552
00553
00554
void StPixelFastSimMaker::smearGaus(StThreeVectorD &mError,
00555
double sigma1,
double sigma2)
00556 {
00557
00558
00559
00560
double u1=-1;
00561
double u2=-1.;
00562
double v1=-1.;
00563
double v2=-1.;;
00564
double r = 2.;
00565
double z1 = 10.;
00566
double z2 = 10.;
00567
while(fabs(z1)>2. || fabs(z2)>2.)
00568 {
00569 r = 2.;
00570
while(r>1.)
00571 {
00572 u1 = rand()/double(RAND_MAX);
00573 u2 = rand()/double(RAND_MAX);
00574 v1 = 2*u1 - 1.;
00575 v2 = 2*u2 - 1.;
00576 r = pow(v1,2) + pow(v2,2);
00577 }
00578 z1 = v1*sqrt(-2.*log(r)/r); z2 = v2*sqrt(-2.*log(r)/r);
00579 }
00580
00581
00582 mError.setX(mError.x()+z1*sigma1/1.e04);
00583 mError.setY(mError.y()+z1*sigma1/1.e04);
00584 mError.setZ(mError.z()+z2*sigma2/1.e04);
00585 }
00586
00587
int StPixelFastSimMaker::sector(
int layer,
int ladder)
00588 {
00589
00590
if (layer ==1)
00591 {
00592
if ( ladder < 4 )
return 1;
00593
if ( ladder < 7 )
return 2;
00594
return 3;
00595 }
00596
else
00597 {
00598
if ( ladder < 9 )
return 1;
00599
if ( ladder < 17 )
return 2;
00600
return 3;
00601 }
00602
00603
00604 }
00605
00606
int StPixelFastSimMaker::secLadder(
int layer,
int ladder)
00607 {
00608
if (layer==1)
00609
return ladder - 3*(sector(layer,ladder)-1);
00610
else
00611
return ladder - 8*(sector(layer,ladder)-1)+3;
00612 }
00613
00614
00615
00616
double StPixelFastSimMaker::phiForLadder(
int layer,
int ladder)
00617 {
00618
int sec = sector(layer,ladder);
00619
int secLad = secLadder(layer,ladder);
00620
00621
double secPhi=0.;
00622
double ladPhi=0.;
00623
switch (sec)
00624 {
00625
case 1:
00626 secPhi=0.;
00627
break;
00628
case 2:
00629 secPhi=120.;
00630
break;
00631
case 3:
00632 secPhi=240.;
00633
break;
00634 }
00635
00636
switch (secLad)
00637 {
00638
case 1:
00639 ladPhi=100.;
00640
break;
00641
case 2:
00642 ladPhi=60.;
00643
break;
00644
case 3:
00645 ladPhi=20.;
00646
break;
00647
case 4:
00648 ladPhi=105.;
00649
break;
00650
case 5:
00651 ladPhi=90.;
00652
break;
00653
case 6:
00654 ladPhi=75.;
00655
break;
00656
case 7:
00657 ladPhi=60.;
00658
break;
00659
case 8:
00660 ladPhi=45.;
00661
break;
00662
case 9:
00663 ladPhi=30.;
00664
break;
00665
case 10:
00666 ladPhi=15.;
00667
break;
00668
case 11:
00669 ladPhi=0.;
00670
break;
00671 }
00672
00673
return secPhi+ladPhi;
00674 }
00675
00676
00677
void StPixelFastSimMaker::shiftHit(StThreeVectorF &position,StThreeVectorF &mom,
int layer,
int ladder)
00678 {
00679
00680
00681
00682 LOG_DEBUG<<
"Pixel Hit in layer "<<layer<<
" and ladder "<<ladder<<
" or sector "<<sector(layer,ladder)<<
" and sector ladder "<<secLadder(layer,ladder)<<endm;
00683
00684 TString Path(
"");
00685 Path = Form(
"/HALL_1/CAVE_1/PXMO_1/PSEC_%i/PLMO_%i/PLAC_1",
00686 sector(layer,ladder),secLadder(layer,ladder));
00687 gGeoManager->RestoreMasterVolume();
00688
00689
00690 gGeoManager->CdTop();
00691 gGeoManager->cd(Path);
00692 TGeoPhysicalNode* node= (TGeoPhysicalNode*)(gGeoManager->GetCurrentNode());
00693
if (!node ) LOG_ERROR<<
"Failed to get node for sector(layer,ladder), secLadder(layer, ladder)"<<endm;
00694
00695
double pos[3]={position.x(),position.y(),position.z()};
00696
double localpos[3]={0,0,0};
00697 gGeoManager->GetCurrentMatrix()->MasterToLocal(pos,localpos);
00698
00699
00700
00701
00702 TGeoHMatrix *hmat = gGeoManager->GetCurrentMatrix();
00703
00704
if (! hmat )
00705 {
00706 LOG_ERROR<<
"Can't shift hit - no hmat."<<endm;
00707 }
00708
00709 Double_t *rot = hmat->GetRotationMatrix();
00710
if (! rot )
00711 {
00712 LOG_ERROR <<
"Can't shift hit - no rotation matrix."<<endm;
00713 }
00714
00715 StThreeVectorD normalVector(rot[1],rot[4],rot[7]);
00716
00717 StThreeVectorF momUnit(mom);
00718 momUnit/=momUnit.magnitude();
00719
00720
00721 momUnit.setPhi( momUnit.phi() - phiForLadder(layer,ladder)*3.141592654/180.);
00722
00723
00724
00725
00726
double dx = (.006)*(momUnit.y()/momUnit.x());
00727
double dz = (.006)*(momUnit.y()/momUnit.z());
00728 localpos[0] = localpos[0] - dx;
00729 localpos[2] = localpos[2] - dz;
00730 localpos[1] = localpos[1] - .006;
00731
00732 gGeoManager->GetCurrentMatrix()->LocalToMaster(localpos,pos);
00733
00734
00735
00736 }