48 #include "StSstUtil/StSstBarrel.hh"
53 #include "StSstHitCollection.h"
54 #include "StarClassLibrary/StThreeVectorF.hh"
55 #include "tables/St_spa_strip_Table.h"
56 #include "tables/St_ssdPedStrip_Table.h"
58 #include "tables/St_scf_cluster_Table.h"
59 #include "tables/St_scm_spt_Table.h"
60 #include "tables/St_sdm_calib_db_Table.h"
62 #include "tables/St_sstDimensions_Table.h"
63 #include "tables/St_sstConfiguration_Table.h"
64 #include "tables/St_sstWafersPosition_Table.h"
65 #include "tables/St_sstStripCalib_Table.h"
66 #include "tables/St_sstSlsCtrl_Table.h"
68 #include "tables/St_sls_strip_Table.h"
69 #include "tables/St_ssdStripCalib_Table.h"
70 #include "tables/St_slsCtrl_Table.h"
71 #include "tables/St_sls_strip_Table.h"
72 #include "tables/St_spa_strip_Table.h"
73 #include "StSstUtil/StSstLadder.hh"
74 #include "StSstUtil/StSstWafer.hh"
75 #include "StSstUtil/StSstClusterControl.h"
76 #include "StSstDynamicControl.h"
77 #include "StSstStripList.hh"
78 #include "StSstStrip.hh"
79 #include "StSstUtil/StSstClusterList.hh"
80 #include "StSstUtil/StSstCluster.hh"
81 #include "StSstUtil/StSstPointList.hh"
82 #include "StSstUtil/StSstPoint.hh"
83 #include "SystemOfUnits.h"
84 #include "StarMagField.h"
86 #include "StMessMgr.h"
88 #include "tables/St_ssdNoise_Table.h"
90 #include "tables/St_sstGainCalibWafer_Table.h"
91 #include "tables/St_sstNoise_Table.h"
92 #include "tables/St_sstWaferConfiguration_Table.h"
94 #include "StMcEvent/StMcSsdHitCollection.hh"
95 #include "StMcEvent.hh"
96 #include "StEventTypes.h"
97 #include "StMcEventTypes.hh"
98 #include "StSstUtil/StSstConsts.h"
100 #include "TDataSetIter.h"
109 memset (first, 0, last-first);
111 setSstParameters(dimensions);
113 setLorentzShift(dimensions);
115 mNLadder = config[0].nMaxLadders;
116 for (Int_t i=0;i<mNLadder;i++) {
118 if (config && config[0].ladderIsPresent[i]==0)
123 for (Int_t iLad=0; iLad < mNLadder; iLad++){
124 mLadders[iLad] =
new StSstLadder(iLad,mSstLayer,mNWaferPerLadder,mNStripPerSide);
125 if (Debug()) mLadders[iLad]->SetDebug(Debug());
129 StSstBarrel::~StSstBarrel(){
134 void StSstBarrel::setSstParameters(sstDimensions_st *geom_par){
135 mDimensions = geom_par;
138 mDetectorLargeEdge = 2.*geom_par[0].waferHalfActLength;
139 mDetectorSmallEdge = 2.*geom_par[0].waferHalfActWidth;
141 mNWaferPerLadder = geom_par[0].wafersPerLadder;
142 mNStripPerSide = geom_par[0].stripPerSide;
143 mStripPitch = geom_par[0].stripPitch;
144 mTheta = geom_par[0].stereoAngle;
147 void StSstBarrel::setLorentzShift(sstDimensions_st *geom_par){
148 Float_t center[3] = {0,0,0};
149 Float_t B[3] = {0,0,0};
151 StarMagField::Instance()->BField(center,B);
153 Float_t scale = 1.61;
154 Float_t tan_theta_h = scale*TMath::ATan(TMath::Tan(21*2*TMath::Pi()/360)*(B[2]/40.));
155 Float_t tan_theta_e = scale*TMath::ATan(TMath::Tan( 8*2*TMath::Pi()/360)*(B[2]/40.));
156 mShift_hole = geom_par[0].waferHalfThickness*tan_theta_h;
157 mShift_elec = geom_par[0].waferHalfThickness*tan_theta_e;
161 void StSstBarrel::debugUnPeu (Int_t monladder, Int_t monwafer){
162 for (Int_t i=0;i<this->getNumberOfLadders();i++)
164 if (this->mLadders[i]->getLadderNumb()==monladder)
166 LOG_INFO<<
" Ladder "<<monladder<<
" found"<<endm;
167 this->mLadders[i]->debugUnPeu(monwafer);
172 void StSstBarrel::initLadders(St_sstWafersPosition *wafpos) {
for (Int_t iLad = 0; iLad < mNLadder; iLad++) mLadders[iLad]->initWafers(wafpos);}
174 void StSstBarrel::Reset() {
for (Int_t iLad = 0; iLad < mNLadder; iLad++) mLadders[iLad]->Reset();}
176 Int_t StSstBarrel::readStripFromTable(St_spa_strip *spa_strip){
177 spa_strip_st *strip = spa_strip->GetTable();
179 Int_t NumberOfStrip = 0;
186 Int_t iPedestal = 120;
187 Int_t idMcHit[5] = {0,0,0,0,0};
188 Int_t idMcTrack[5] = {0,0,0,0,0};
190 for (Int_t i = 0 ; i < spa_strip->GetNRows(); i++)
192 nStrip = (int)(strip[i].id_strip/100000.);
193 idWaf = strip[i].id_strip-10000*((int)(strip[i].id_strip/10000.));
194 iWaf = idWaferToWafer(idWaf);
195 iLad = (int)(idWaf - mSstLayer*1000 - (iWaf+1)*100 - 1);
196 iSide = (strip[i].id_strip - nStrip*100000 - idWaf)/10000;
197 for (e = 0 ; e < 5;e++) {
198 idMcHit[e] = strip[i].id_mchit[e];
199 idMcTrack[e] = strip[i].id_mctrack[e];
201 StSstStrip *newStrip =
new StSstStrip(nStrip, strip[i].adc_count, sigma, iPedestal, idMcHit,idMcTrack);
202 mLadders[iLad]->mWafers[iWaf]->
addStrip(newStrip, iSide);
204 NumberOfStrip = spa_strip->GetNRows();
205 return NumberOfStrip;
208 Int_t StSstBarrel::writeNoiseToFile(St_spa_strip *spa_strip){
209 spa_strip_st *strip = spa_strip->GetTable();
210 St_ssdStripCalib *stripCal =
new St_ssdStripCalib(
"ssdStripCalib",spa_strip->GetNRows());
211 ssdStripCalib_st noise_strip;
212 for (Int_t i = 0 ; i < spa_strip->GetNRows(); i++)
214 noise_strip.id=strip[i].id_strip;
215 noise_strip.pedestals=(short) strip[i].id_mchit[0];
216 noise_strip.rms=(short) strip[i].adc_count;
217 stripCal->AddAt(&noise_strip);
219 TFile f1(
"ssdStripCalib.root",
"NEW");
222 return spa_strip->GetNRows();
225 Int_t StSstBarrel::writeNewNoiseToFile3(St_ssdPedStrip *spa_ped_strip,
char myLabel[]){
226 char *name =
new char[100] ;
227 ssdPedStrip_st *strip = spa_ped_strip->GetTable();
228 St_ssdNoise *StripCal =
new St_ssdNoise(
"ssdNoise",spa_ped_strip->GetNRows());
229 ssdNoise_st temp[mNLadder* mNWaferPerLadder];
230 memset(temp, 0, (mNLadder* mNWaferPerLadder)*
sizeof(ssdNoise_st));
237 Int_t N = spa_ped_strip->GetNRows();
238 for (Int_t i=0; i< N;i++) {
239 if (strip[i].id_strip>0 && strip[i].id_strip<=76818620) {
240 nStrip = (int)(strip[i].id_strip/100000.);
241 idWaf = strip[i].id_strip-10000*((int)(strip[i].id_strip/10000.));
242 iWaf = (int)((idWaf - mSstLayer*1000)/100 - 1);
243 iLad = (int)(idWaf - mSstLayer*1000 - (iWaf+1)*100 - 1);
244 iSide = (strip[i].id_strip - nStrip*100000 - idWaf)/10000;
245 wafer = iLad*mNWaferPerLadder +iWaf;
246 if (iSide == 0) temp[wafer].rmsp[nStrip-1] = (
unsigned char)strip[i].noise;
247 if (iSide == 1) temp[wafer].rmsn[nStrip-1] = (
unsigned char)strip[i].noise;
250 for(Int_t i=0;i<mNLadder* mNWaferPerLadder;i++) {
252 StripCal->AddAt(&temp[i]);
254 sprintf(name,
"%s%s%s",
"ssdNoise.",myLabel,
".root");
255 TFile f1(name,
"RECREATE",
"SSD ped and noise file",9);
258 return spa_ped_strip->GetNRows();
264 Int_t StSstBarrel::writeNoiseToFile(St_ssdPedStrip *spa_ped_strip,
char myLabel[]){
265 char *name =
new char[100] ;
266 ssdPedStrip_st *strip = spa_ped_strip->GetTable();
267 St_ssdStripCalib *stripCal =
new St_ssdStripCalib(
"ssdStripCalib",spa_ped_strip->GetNRows());
268 ssdStripCalib_st noise_strip;
269 for (Int_t i = 0 ; i < spa_ped_strip->GetNRows(); i++)
271 noise_strip.id=strip[i].id_strip;
272 noise_strip.pedestals= (
unsigned char) strip[i].pedestal;
273 noise_strip.rms=(
unsigned char) strip[i].noise;
274 stripCal->AddAt(&noise_strip);
276 sprintf(name,
"%s%s%s",
"ssdStripCalib.",myLabel,
".root");
277 TFile f1(name,
"RECREATE",
"SSD ped and noise file",9);
280 return spa_ped_strip->GetNRows();
287 sdm_calib_db_st *noise = spa_noise->GetTable();
289 Int_t NumberOfNoise = 0;
295 for (Int_t i = 0 ; i < spa_noise->GetNRows(); i++)
297 nStrip = (int)(noise[i].id_strip/100000.);
298 idWaf = noise[i].id_strip-10000*((int)(noise[i].id_strip/10000.));
299 iWaf = idWaferToWafer(idWaf);
300 iLad = (int)(idWaf - mSstLayer*1000 - (iWaf+1)*100 - 1);
301 iSide = (noise[i].id_strip - nStrip*100000 - idWaf)/10000;
302 mLadders[iLad]->mWafers[iWaf]->setPedestalSigmaStrip(nStrip, iSide,0, noise[i].n_sigma, dynamicControl);
305 NumberOfNoise = spa_noise->GetNRows();
306 return NumberOfNoise;
313 ssdStripCalib_st *noise = strip_calib->GetTable();
315 Int_t NumberOfNoise = 0;
321 for (Int_t i = 0 ; i < strip_calib->GetNRows(); i++)
323 if (noise[i].
id>0 && noise[i].
id<=76818620) {
324 nStrip = (int)(noise[i].
id/100000.);
325 idWaf = noise[i].id-10000*((int)(noise[i].
id/10000.));
326 iWaf = idWaferToWafer(idWaf);
327 iLad = (int)(idWaf - mSstLayer*1000 - (iWaf+1)*100 - 1);
328 iSide = (noise[i].id - nStrip*100000 - idWaf)/10000;
329 mLadders[iLad]->mWafers[iWaf]->setPedestalSigmaStrip(nStrip, iSide, noise[i].pedestals, noise[i].rms, dynamicControl);
333 return NumberOfNoise;
340 Int_t NumberOfNoise = 0;
341 for(Int_t i=0;i<mNLadder;i++)
343 for(Int_t j=0;j<mNWaferPerLadder;j++)
345 for(Int_t k=0;k<mNStripPerSide;k++)
347 for(Int_t iSide=0;iSide<2;iSide++)
349 mLadders[i]->mWafers[j]->setPedestalSigmaStrip(k+1,iSide,ped,rms,dynamicControl);
355 return NumberOfNoise;
362 ssdNoise_st *noise = strip_noise->GetTable();
364 Int_t NumberOfNoise = 0;
369 Int_t pedestal = 120;
370 LOG_INFO <<
"size of m_noise3 table = " << (int)strip_noise->GetNRows() << endm;
371 for (Int_t i = 0 ; i < strip_noise->GetNRows(); i++)
373 iWaf = noise[i].id-(noise[i].id/mNWaferPerLadder)*mNWaferPerLadder;
374 iLad = noise[i].id/16;
375 for(nStrip=0;nStrip<mNStripPerSide;nStrip++){
377 mLadders[iLad]->mWafers[iWaf]->setPedestalSigmaStrip(nStrip+1, iSide, pedestal, noise[i].rmsp[nStrip], dynamicControl);
380 mLadders[iLad]->mWafers[iWaf]->setPedestalSigmaStrip(nStrip+1, iSide, pedestal, noise[i].rmsn[nStrip], dynamicControl);
384 return NumberOfNoise;
388 Int_t NumberOfNoise = 0;
393 Int_t TotStripSide = kSstNumLadders * kSstNumSensorsPerLadder * kSstNumStripsOnSensor;
394 Int_t TotStripPerLadder = kSstNumSensorsPerLadder * kSstNumStripsOnSensor;
400 for (Int_t i = 0 ; i < (2*TotStripSide); i++){
401 iSide = i/TotStripSide;
402 iLad = (i - (iSide*TotStripSide))/TotStripPerLadder;
403 iWaf = (i - iSide*TotStripSide - iLad*TotStripPerLadder)/kSstNumStripsOnSensor;
404 iStrip = i - iSide*TotStripSide - iLad*TotStripPerLadder - iWaf*kSstNumStripsOnSensor;
405 LOG_DEBUG <<
" i/side/lad/waf/strip/ped/rms : " << i <<
" " << iSide <<
" " << iLad <<
" " << iWaf <<
" " << iStrip <<
" " << (int)noise[0].pedestals[i] <<
" "<< (
int)noise[0].rms[i] << endm;
406 mLadders[iLad]->mWafers[iWaf]->setPedestalSigmaStrip(iStrip+1, iSide, (
int)noise[0].pedestals[i], (
int)noise[0].rms[i], dynamicControl);
409 return NumberOfNoise;
413 Int_t
StSstBarrel::readClusterFromTable(St_scf_cluster *scf_cluster){
414 scf_cluster_st *cluster = scf_cluster->GetTable();
416 Int_t NumberOfCluster = 0;
424 Int_t idMcHit[5] = {0,0,0,0,0};
427 Int_t nFirstStrip = 0;
431 Float_t nNoiseCount = 0;
432 Float_t nStripMean = 0;
435 for (Int_t i = 0 ; i < scf_cluster->GetNRows(); i++)
437 nCluster = (int)(cluster[i].id_cluster/100000.);
438 idWaf = (cluster[i].id_cluster-10000*((int)(cluster[i].id_cluster/10000.)));
439 iSide = (cluster[i].id_cluster-idWaf-nCluster*100000)/10000;
440 iWaf = idWaferToWafer(idWaf);
441 iLad = (int)(idWaf - mSstLayer*1000 - (iWaf+1)*100 - 1);
442 nFirstStrip = (int)(cluster[i].first_strip/100000.);
443 nStrip = cluster[i].n_strip;
444 nFirstAdc = cluster[i].first_adc_count;
445 nLastAdc = cluster[i].last_adc_count;
446 nAdcCount = cluster[i].adc_count;
447 nNoiseCount = cluster[i].noise_count;
448 nStripMean = cluster[i].strip_mean;
449 nFlag = cluster[i].flag;
450 for (e = 0 ; e < 5; e++) idMcHit[e] = cluster[i].id_mchit[e];
451 StSstCluster *newCluster =
new StSstCluster(nCluster, nFirstStrip, nStrip, nAdcCount, nFirstAdc, nLastAdc, nNoiseCount, nStripMean, nFlag, idMcHit);
456 mLadders[iLad]->mWafers[iWaf]->
addCluster(newCluster, iSide);
459 NumberOfCluster = scf_cluster->GetNRows();
460 return NumberOfCluster;
463 Int_t StSstBarrel::writeClusterToTable(St_scf_cluster *scf_cluster){
464 scf_cluster_st cluster;
465 Int_t currRecord = 0;
468 for (Int_t iLad = 0; iLad < mNLadder; iLad++)
469 for (Int_t iWaf = 0; iWaf < mNWaferPerLadder ; iWaf++)
471 Int_t idCurrentWaf = mSstLayer*1000 + (iWaf+1)*100 + (iLad+1);
478 cluster.id = currRecord + 1;
479 cluster.id_cluster = 10000*(10*pClusterP->getNCluster() + 0)+idCurrentWaf;
480 cluster.first_strip = 10000*(10*pClusterP->getFirstStrip()+ 0)+idCurrentWaf;
481 cluster.n_strip = pClusterP->getClusterSize();
482 cluster.adc_count = pClusterP->getTotAdc();
483 cluster.first_adc_count = pClusterP->getFirstAdc();
484 cluster.last_adc_count = pClusterP->getLastAdc();
485 cluster.noise_count = (int)pClusterP->getTotNoise();
486 cluster.flag = pClusterP->getFlag();
487 cluster.strip_mean = pClusterP->getStripMean();
488 for (i = 0 ; i < 5 ; i++)
489 cluster.id_mchit[i] = pClusterP->getIdMcHit(i);
490 scf_cluster->AddAt(&cluster);
492 pClusterP = clusterP->next(pClusterP);
498 cluster.id = currRecord + 1;
499 cluster.id_cluster = 10000*(10*pClusterN->getNCluster() + 1)+idCurrentWaf;
500 cluster.first_strip = 10000*(10*pClusterN->getFirstStrip() + 1)+idCurrentWaf;
501 cluster.n_strip = pClusterN->getClusterSize();
502 cluster.adc_count = pClusterN->getTotAdc();
503 cluster.first_adc_count = pClusterN->getFirstAdc();
504 cluster.last_adc_count = pClusterN->getLastAdc();
505 cluster.noise_count = (int)pClusterN->getTotNoise();
506 cluster.flag = pClusterN->getFlag();
507 cluster.strip_mean = pClusterN->getStripMean();
508 for (i = 0 ; i < 5 ; i++)
509 cluster.id_mchit[i] = pClusterN->getIdMcHit(i);
510 scf_cluster->AddAt(&cluster);
512 pClusterN = clusterN->next(pClusterN);
518 Int_t StSstBarrel::writeClusterToTable(St_scf_cluster *scf_cluster,St_spa_strip *spa_strip){
519 scf_cluster_st cluster;
520 spa_strip_st *on_strip = spa_strip->GetTable();
521 Int_t currRecord = 0;
523 for (Int_t iLad = 0; iLad < mNLadder; iLad++)
524 for (Int_t iWaf = 0; iWaf < mNWaferPerLadder ; iWaf++)
526 Int_t idCurrentWaf = mSstLayer*1000 + (iWaf+1)*100 + (iLad+1);
533 cluster.id = currRecord + 1;
534 cluster.id_cluster = 10000*(10*pClusterP->getNCluster() + 0)+idCurrentWaf;
535 cluster.first_strip = 10000*(10*pClusterP->getFirstStrip()+ 0)+idCurrentWaf;
536 cluster.n_strip = pClusterP->getClusterSize();
537 cluster.adc_count = pClusterP->getTotAdc();
538 cluster.first_adc_count = pClusterP->getFirstAdc();
539 cluster.last_adc_count = pClusterP->getLastAdc();
540 cluster.noise_count = (Int_t) pClusterP->getTotNoise();
541 cluster.flag = pClusterP->getFlag();
542 cluster.strip_mean = pClusterP->getStripMean();
543 for (i = 0 ; i < 5 ; i++)
545 cluster.id_mchit[i] = pClusterP->getIdMcHit(i);
546 if(cluster.id_mchit[i] == 0){
547 cluster.id_mctrack[i]=0;
550 for(Int_t j = 0 ; j < spa_strip->GetNRows(); j++){
551 if(cluster.id_mchit[i] == on_strip[j].id_mchit[i]){
552 cluster.id_mctrack[i] = on_strip[j].id_mctrack[i];
557 scf_cluster->AddAt(&cluster);
559 pClusterP = clusterP->next(pClusterP);
565 cluster.id = currRecord + 1;
566 cluster.id_cluster = 10000*(10*pClusterN->getNCluster() + 1)+idCurrentWaf;
567 cluster.first_strip = 10000*(10*pClusterN->getFirstStrip() + 1)+idCurrentWaf;
568 cluster.n_strip = pClusterN->getClusterSize();
569 cluster.adc_count = pClusterN->getTotAdc();
570 cluster.first_adc_count = pClusterN->getFirstAdc();
571 cluster.last_adc_count = pClusterN->getLastAdc();
572 cluster.noise_count = (Int_t) pClusterN->getTotNoise();
573 cluster.flag = pClusterN->getFlag();
574 cluster.strip_mean = pClusterN->getStripMean();
575 for (i = 0 ; i < 5 ; i++)
577 cluster.id_mchit[i] = pClusterN->getIdMcHit(i);
578 if(cluster.id_mchit[i] == 0)cluster.id_mctrack[i]=0;
580 for(Int_t j = 0 ; j < spa_strip->GetNRows(); j++){
581 if(cluster.id_mchit[i] == on_strip[j].id_mchit[i]){
582 cluster.id_mctrack[i] = on_strip[j].id_mctrack[i];
587 scf_cluster->AddAt(&cluster);
589 pClusterN = clusterN->next(pClusterN);
596 Float_t convMeVToAdc = (int)pow(2.0,mDynamicControl->getnbitEncoding())/(mDynamicControl->getpairCreationEnergy()*mDynamicControl->getadcDynamic()*mDynamicControl->getnElectronInAMip());
599 scf_cluster_st *on_cluster = scf_cluster->GetTable();
601 Int_t i = 0, inContainer = 0, inTable = 0 ;
603 Int_t hw; Float_t q ;
unsigned char c;
605 for (Int_t iLad = 0; iLad < mNLadder; iLad++)
606 for (Int_t iWaf = 0; iWaf < mNWaferPerLadder; iWaf++)
608 Int_t idCurrentWaf = mSstLayer*1000 + (iWaf+1)*100 + (iLad+1);
613 for (i = 0 ; i < 5 ; i++)
615 spt.id_mchit[i] = pSpt->getNMchit(i);
616 spt.id_mctrack[i] = 0;
619 if (spt.id_mchit[i] == 0) spt.id_mctrack[i]=0;
621 for(Int_t j = 0 ; j < scf_cluster->GetNRows(); j++){
622 if(spt.id_mchit[i] == on_cluster[j].id_mchit[i]){
623 spt.id_mctrack[i] = on_cluster[j].id_mctrack[i];
631 for (i = 0 ; i < 3 ; i++){
632 gPos[i] = pSpt->getXg(i);
637 currentSstHit =
new StSstHit(gPos,gPosError,hw,q,c);
638 currentSstHit->setIdTruth(spt.id_mctrack[0],100);
641 Int_t Id_P_Side = pSpt->getIdClusterP();
642 Int_t Id_N_Side = pSpt->getIdClusterN();
647 if(cluster_P_j->getNCluster()==Id_P_Side)
649 cluster_P_j = currentListP_j->next(cluster_P_j);
651 while(cluster_P_j!=currentListP_j->last());
656 if(cluster_N_j->getNCluster()==Id_N_Side)
658 cluster_N_j = currentListN_j->next(cluster_N_j);
660 while(cluster_N_j!=currentListN_j->last());
671 + 16 * idWaferToWaferNumb(idCurrentWaf)
672 + 8192 * (int)cluster_N_j->getStripMean()
673 + 8388608 * ((int)cluster_P_j->getStripMean() - (int)cluster_N_j->getStripMean() +15)
674 + 268435456 * (
int)((cluster_N_j->getClusterSize() > 3) ? 3 : cluster_N_j->getClusterSize()-1)
675 + 1073741824 * (
int)((cluster_P_j->getClusterSize() > 3) ? 3 : cluster_P_j->getClusterSize()-1);
676 currentSstHit->setHardwarePosition(hw);
677 currentSstHit->setLocalPosition(pSpt->getXl(0),pSpt->getXl(1),pSpt->getXl(2));
678 currentSstHit->setADC((
int)convMeVToAdc*(pSpt->getDe(0)+pSpt->getDe(1)),(
int)convMeVToAdc*(pSpt->getDe(0)-pSpt->getDe(1)));
679 inContainer += ssdHitColl->addHit(currentSstHit);
683 spt.flag = pSpt->getFlag();
684 spt.id = 10000*(pSpt->getNPoint())+idCurrentWaf;
685 spt.id_cluster = pSpt->getNCluster();
687 spt.id_match = pSpt->getNMatched();
688 for (i = 0 ; i < 5 ; i++)
690 spt.id_mchit[i] = pSpt->getNMchit(i);
691 spt.id_mctrack[i] = 0;
694 spt.id_wafer = idCurrentWaf;
695 for (i = 0 ; i < 3 ; i++)
699 spt.x[i] = pSpt->getXg(i);
700 spt.xl[i] = pSpt->getXl(i);
702 for (i = 0 ; i < 2 ; i++)
705 spt.de[i] = pSpt->getDe(i);
707 scm_spt->AddAt(&spt);
710 pSpt = sptList->next(pSpt);
718 vector<const StMcSsdHit*> hitCol;
720 int totRatio, idTruth;
721 Float_t convMeVToAdc = (int)pow(2.0,mDynamicControl->getnbitEncoding())/(mDynamicControl->getpairCreationEnergy()*mDynamicControl->getadcDynamic()*mDynamicControl->getnElectronInAMip());
724 LOG_DEBUG <<
"McEvent exists" << endm;
725 myCol = mcEvent->ssdHitCollection();
728 for (
unsigned int iLadder=0; iLadder<myCol->numberOfLadders(); iLadder++) {
729 for (
unsigned int iWafer = 0; iWafer < myCol->ladder(iLadder)->numberOfWafers(); iWafer++) {
730 for (StMcSsdHitIterator iter = myCol->ladder(iLadder)->wafer(iWafer)->hits().begin();
731 iter != myCol->ladder(iLadder)->wafer(iWafer)->hits().end();
735 hitCol.push_back(hit);
741 else{LOG_INFO<<
"No sstMcHitCollection" <<endm;
745 scf_cluster_st *on_cluster = scf_cluster->GetTable();
747 Int_t i = 0, inContainer = 0, inTable = 0;
749 Int_t hw; Float_t q ;
unsigned char c;
751 for (Int_t iLad = 0; iLad < mNLadder; iLad++)
752 for (Int_t iWaf = 0; iWaf < mNWaferPerLadder; iWaf++)
754 Int_t idCurrentWaf = mSstLayer*1000 + (iWaf+1)*100 + (iLad+1);
767 for (i = 0 ; i < 5 ; i++)
769 spt.id_mchit[i] = pSpt->getNMchit(i);
770 spt.id_mctrack[i] = 0;
773 if (spt.id_mchit[i] == 0) spt.id_mctrack[i]=0;
776 for(j = 0 ; j < scf_cluster->GetNRows(); j++){
777 if(spt.id_mchit[i] == on_cluster[j].id_mchit[i]){
778 spt.id_mctrack[i] = on_cluster[j].id_mctrack[i];
779 idClusP = 10000*(10*pSpt->getIdClusterP() + 0)+idCurrentWaf;
780 idClusN = 10000*(10*pSpt->getIdClusterN() + 1)+idCurrentWaf;
784 Calculation_Ratio(idCurrentWaf,idClusP,idClusN,hitCol,&totRatio,&idTruth);
790 for (i = 0 ; i < 3 ; i++){
791 gPos[i] = pSpt->getXg(i);
796 currentSstHit =
new StSstHit(gPos,gPosError,hw,q,c);
798 currentSstHit->setIdTruth(idTruth,(
int)totRatio);
802 Int_t Id_P_Side = pSpt->getIdClusterP();
803 Int_t Id_N_Side = pSpt->getIdClusterN();
809 if(cluster_P_j->getNCluster()==Id_P_Side)
811 cluster_P_j = currentListP_j->next(cluster_P_j);
813 while(cluster_P_j!=currentListP_j->last());
818 if(cluster_N_j->getNCluster()==Id_N_Side)
820 cluster_N_j = currentListN_j->next(cluster_N_j);
822 while(cluster_N_j!=currentListN_j->last());
833 + 16 * idWaferToWaferNumb(idCurrentWaf)
834 + 8192 * (int)cluster_N_j->getStripMean()
835 + 8388608 * ((int)cluster_P_j->getStripMean() - (int)cluster_N_j->getStripMean() +15)
836 + 268435456 * (
int)((cluster_N_j->getClusterSize() > 3) ? 3 : cluster_N_j->getClusterSize()-1)
837 + 1073741824 * (
int)((cluster_P_j->getClusterSize() > 3) ? 3 : cluster_P_j->getClusterSize()-1);
838 currentSstHit->setHardwarePosition(hw);
840 currentSstHit->setLocalPosition(pSpt->getXl(0),pSpt->getXl(1),pSpt->getXl(2));
842 currentSstHit->setADC((
int)convMeVToAdc*(pSpt->getDe(0)+pSpt->getDe(1)),(
int)convMeVToAdc*(pSpt->getDe(0)-pSpt->getDe(1)));
843 inContainer += sstHitColl->addHit(currentSstHit);
847 spt.flag = pSpt->getFlag();
848 spt.id = 10000*(pSpt->getNPoint())+idCurrentWaf;
849 spt.id_cluster = pSpt->getNCluster();
851 spt.id_match = pSpt->getNMatched();
852 for (i = 0 ; i < 5 ; i++)
854 spt.id_mchit[i] = pSpt->getNMchit(i);
855 spt.id_mctrack[i] = 0;
858 spt.id_wafer = idCurrentWaf;
859 for (i = 0 ; i < 3 ; i++)
863 spt.x[i] = pSpt->getXg(i);
864 spt.xl[i] = pSpt->getXl(i);
866 for (i = 0 ; i < 2 ; i++)
869 spt.de[i] = pSpt->getDe(i);
871 scm_spt->AddAt(&spt);
874 pSpt = sptList->next(pSpt);
877 if (hitCol.size()>0 )hitCol.clear();
881 void StSstBarrel::Calculation_Ratio(
int idWafer,
int idClusterP,
int idClusterN,vector<const StMcSsdHit*> hitCol,
int *ratio,
int *idTruth)
883 Float_t charge[2] = {0,0};
886 Float_t adc_DominatorP = 0;
887 Float_t adc_DominatorN = 0;
888 vector<StSstStrip*> ListstripP;
889 vector<StSstStrip*> ListstripN;
890 vector<int> GTrackP(5,0),GTrackN(5,0);
891 int isSplittedP=0,isSplittedN =0;
892 Int_t lad = idWaferToLadderNumb(idWafer);
893 Int_t waf = (int)((idWafer - mSstLayer*1000)/100)-1;
897 int idP = 10000*(10*pClusterP->getNCluster() + 0)+idWafer;
899 charge[0] = pClusterP->getTotAdc();
900 if(pClusterP->getFlag()==1){
902 isSplittedP = isSplit(pClusterP,0,lad,waf);
904 for(Int_t e =0 ;e<5;e++)GTrackP.push_back(pClusterP->getIdMcHit(e));
908 for(
int kk=pClusterP->getFirstStrip();kk<pClusterP->getFirstStrip()+pClusterP->getClusterSize();kk++)
913 if((pStripP->getNStrip()==kk)&&(pStripP->getNStrip()!=lastScan))
915 lastScan = pStripP->getNStrip();
916 ListstripP.push_back(pStripP);
918 pStripP = stripP->next(pStripP);
923 pClusterP = mLadders[lad]->mWafers[waf]->
getClusterP()->next(pClusterP);
928 int idN = 10000*(10*pClusterN->getNCluster() + 1)+idWafer;
930 charge[1] = pClusterN->getTotAdc();
931 if(pClusterN->getFlag()==1){
933 isSplittedN = isSplit(pClusterN,1,lad,waf);
935 for(Int_t e =0 ;e<5;e++)GTrackN.push_back(pClusterN->getIdMcHit(e));
939 for(
int kk=pClusterN->getFirstStrip();kk<pClusterN->getFirstStrip()+pClusterN->getClusterSize();kk++)
944 if((pStripN->getNStrip()==kk)&&(pStripN->getNStrip()!=lastScan))
946 lastScan = pStripN->getNStrip();
947 ListstripN.push_back(pStripN);
949 pStripN = stripN->next(pStripN);
954 pClusterN = mLadders[lad]->mWafers[waf]->
getClusterN()->next(pClusterN);
958 DominatorP = FindMcHit(GTrackP,hitCol);
959 DominatorN = FindMcHit(GTrackN,hitCol);
960 if(DominatorP!=DominatorN) {
965 if((ListstripN.size()>0)&&(ListstripP.size()>0))
967 unsigned int min ,max;
973 max = ListstripP.size()-1;}
977 max = ListstripP.size();}
980 max = ListstripP.size();}
981 for(
unsigned int ee = min;ee<max;ee++){
983 if(DominatorP == tempoStripP->getIdMcTrack(0))
985 adc_DominatorP += tempoStripP->getDigitSig();
996 max = ListstripN.size()-1;
1001 max = ListstripN.size();
1005 max = ListstripN.size();
1007 for(
unsigned int ee = min;ee<max;ee++){
1009 if(DominatorN == tempoStripN->getIdMcTrack(0))
1011 adc_DominatorN += tempoStripN->getDigitSig();
1020 if(charge[0]!=0) ratioP = adc_DominatorP/charge[0];
1021 if(charge[1]!=0) ratioN = adc_DominatorN/charge[1];
1022 if(DominatorP == DominatorN){
1023 *ratio = (int)(100*(ratioP*ratioN));
1024 *idTruth = DominatorP;
1030 if(ListstripP.size()>0) ListstripP.clear();
1031 if(ListstripN.size()>0) ListstripN.clear();
1032 if(GTrackP.size()>0) GTrackP.clear();
1033 if(GTrackN.size()>0) GTrackN.clear();
1036 Int_t StSstBarrel::FindMcHit(
const vector<int> &tempo,
const vector<const StMcSsdHit*> &hitCol)
1038 float ChargeTrack = 0.0;
1040 for(
int e=0;e<5;e++){
1041 for (
unsigned int hit = 0 ;
hit<hitCol.size();
hit++){
1043 if((tempo[e]>0)&&(currHit->key() == tempo[e])&&(currHit->dE()>ChargeTrack)){
1044 ChargeTrack = currHit->dE();
1045 idTrack = currHit->parentTrack()->key();
1052 Int_t StSstBarrel::isSplit(
StSstCluster *currentCluster,
int iSide,
int lad,
int waf){
1059 firstClus = mLadders[lad]->mWafers[waf]->
getClusterP()->first();
1060 lastClus = mLadders[lad]->mWafers[waf]->
getClusterP()->last();
1063 firstClus = mLadders[lad]->mWafers[waf]->
getClusterN()->first();
1064 lastClus = mLadders[lad]->mWafers[waf]->
getClusterN()->last();
1066 if(currentCluster->getNCluster() == firstClus->getNCluster()){
1069 else if(currentCluster->getNCluster() == lastClus->getNCluster()){
1073 nextClus = currentCluster->getNextCluster();
1074 if(nextClus->getFirstStrip() == ((currentCluster->getFirstStrip()+currentCluster->getClusterSize()-1))) {
1076 prevClus = currentCluster->getPrevCluster();
1077 if(currentCluster->getFirstStrip() == ((prevClus->getFirstStrip()+prevClus->getClusterSize()-1))) {
1085 void StSstBarrel::doSideClusterisation(Int_t *barrelNumbOfCluster){
1086 Int_t wafNumbOfCluster[2];
1087 wafNumbOfCluster[0] = 0;
1088 wafNumbOfCluster[1] = 0;
1090 for (Int_t iLad = 0 ; iLad < mNLadder; iLad++)
1091 for (Int_t iWaf = 0 ; iWaf < mNWaferPerLadder; iWaf++)
1093 mLadders[iLad]->mWafers[iWaf]->
doClusterisation(wafNumbOfCluster, mClusterControl);
1094 barrelNumbOfCluster[0] += wafNumbOfCluster[0];
1095 barrelNumbOfCluster[1] += wafNumbOfCluster[1];
1099 void StSstBarrel::doSideClusterisation(Int_t *barrelNumbOfCluster,Int_t WafStatus[20][16]){
1100 Int_t wafNumbOfCluster[2];
1101 wafNumbOfCluster[0] = 0;
1102 wafNumbOfCluster[1] = 0;
1103 for (Int_t iLad = 0 ; iLad < mNLadder; iLad++)
1104 for (Int_t iWaf = 0 ; iWaf < mNWaferPerLadder; iWaf++)
1106 if(WafStatus[iLad][iWaf]!=0){
1107 mLadders[iLad]->mWafers[iWaf]->
doClusterisation(wafNumbOfCluster, mClusterControl);
1108 barrelNumbOfCluster[0] += wafNumbOfCluster[0];
1109 barrelNumbOfCluster[1] += wafNumbOfCluster[1];
1114 Int_t StSstBarrel::doClusterMatching(Float_t *CalibArray){
1115 Int_t NumberOfPackage = 0;
1119 for (Int_t iLad = 0; iLad < mNLadder; iLad++){
1120 for (Int_t iWaf = 0; iWaf < mNWaferPerLadder; iWaf++)
1123 NumberOfPackage += mLadders[iLad]->mWafers[iWaf]->
doFindPackage(mDimensions, mClusterControl);
1124 nPerfect = mLadders[iLad]->mWafers[iWaf]->doSolvePerfect(mDimensions, mClusterControl,CalibArray[(iLad*mNWaferPerLadder)+iWaf]);
1125 if (!nPerfect)
continue;
1126 mLadders[iLad]->mWafers[iWaf]->doStatPerfect(nPerfect, mClusterControl);
1127 nSolved += mLadders[iLad]->mWafers[iWaf]->doSolvePackage(mDimensions, mClusterControl,CalibArray[(iLad*mNWaferPerLadder)+iWaf]);
1130 LOG_INFO<<
"**** Remark: "<<nSolved<<
" solved packages ****" << endm;
1131 return NumberOfPackage;
1135 long nElectronInAMip = dynamicControl->getnElectronInAMip();
1136 long adcDynamic = dynamicControl->getadcDynamic();
1137 Double_t pairCreationEnergy = dynamicControl->getpairCreationEnergy();
1139 const Int_t NAdcChannel = (int)pow(2.0,dynamicControl->getnbitEncoding());
1140 const Double_t convFactor = (pairCreationEnergy*adcDynamic*nElectronInAMip)/NAdcChannel;
1141 for (Int_t iLad = 0; iLad < mNLadder; iLad++)
1142 for (Int_t iWaf = 0; iWaf < mNWaferPerLadder; iWaf++)
1143 mLadders[iLad]->mWafers[iWaf]->convertDigitToAnalog(convFactor);
1146 void StSstBarrel::convertUFrameToOther(){
1147 for (Int_t iLad = 0; iLad < mNLadder; iLad++)
1148 for (Int_t iWaf = 0; iWaf < mNWaferPerLadder; iWaf++)
1150 mLadders[iLad]->mWafers[iWaf]->convertUFrameToLocal(mDimensions);
1151 mLadders[iLad]->mWafers[iWaf]->convertLocalToGlobal();
1155 void StSstBarrel::convertGlobalFrameToOther(){
1156 for (Int_t iLad = 0; iLad < mNLadder; iLad++){
1157 for (Int_t iWaf = 0; iWaf < mNWaferPerLadder; iWaf++)
1159 mLadders[iLad]->mWafers[iWaf]->convertGlobalToLocal();
1160 mLadders[iLad]->mWafers[iWaf]->convertLocalToUFrame(mDetectorLargeEdge, mDetectorSmallEdge, mTheta);
1165 void StSstBarrel::sortListStrip(){
1168 for (Int_t iLad = 0; iLad < mNLadder; iLad++)
1169 for (Int_t iWaf = 0; iWaf < mNWaferPerLadder; iWaf++)
1171 currentList = mLadders[iLad]->mWafers[iWaf]->
getStripP();
1172 isSorted = currentList->isSorted();
1173 if (!isSorted) currentList->sortStrip();
1175 currentList = mLadders[iLad]->mWafers[iWaf]->
getStripN();
1176 isSorted = currentList->isSorted();
1177 if (!isSorted) currentList->sortStrip();
1182 void StSstBarrel::sortListCluster(){
1185 for (Int_t iLad = 0; iLad < mNLadder; iLad++)
1186 for (Int_t iWaf = 0; iWaf < mNWaferPerLadder; iWaf++)
1188 currentList = mLadders[iLad]->mWafers[iWaf]->
getClusterP();
1189 isSorted = currentList->isSorted();
1190 if (!isSorted) currentList->sortCluster();
1192 currentList = mLadders[iLad]->mWafers[iWaf]->
getClusterN();
1193 isSorted = currentList->isSorted();
1194 if (!isSorted) currentList->sortCluster();
1200 mSstLayer = originalBarrel.mSstLayer;
1201 mNLadder = originalBarrel.mNLadder;
1202 mNWaferPerLadder = originalBarrel.mNWaferPerLadder;
1203 mNStripPerSide = originalBarrel.mNStripPerSide;
1206 for (Int_t iLad=0; iLad < mNLadder; iLad++)
1207 mLadders[iLad] =
new StSstLadder(iLad,mSstLayer,mNWaferPerLadder,mNStripPerSide);
1212 mSstLayer = originalBarrel.mSstLayer;
1213 mNLadder = originalBarrel.mNLadder;
1214 mNWaferPerLadder = originalBarrel.mNWaferPerLadder;
1215 mNStripPerSide = originalBarrel.mNStripPerSide;
1218 for (Int_t iLad=0; iLad < mNLadder; iLad++)
1219 mLadders[iLad] =
new StSstLadder(iLad,mSstLayer,mNWaferPerLadder,mNStripPerSide);
1223 Int_t StSstBarrel::idWaferToWaferNumb(Int_t idWafer)
1225 Int_t iW = (int)((idWafer - mSstLayer*1000)/100);
1226 Int_t iL = idWafer - mSstLayer*1000 - iW*100;
1227 return ((iL-1)*mNWaferPerLadder + iW -1);
1230 Int_t StSstBarrel::idWaferToLadderNumb(Int_t idWafer)
1232 Int_t iW = (int)((idWafer - mSstLayer*1000)/100);
1233 Int_t iL = idWafer - mSstLayer*1000 - iW*100;
1237 Int_t StSstBarrel::waferNumbToIdWafer(Int_t waferNumb)
1239 Int_t iL = 1+(int)((waferNumb)/mNWaferPerLadder);
1240 Int_t iW = waferNumb-((iL-1)*mNWaferPerLadder)+1;
1241 return mSstLayer*1000 + iW*100 + iL;
1244 Int_t StSstBarrel::isActiveLadder(Int_t iLadder)
1246 return mActiveLadders[iLadder];
1248 void StSstBarrel::renumHitAfterRemove() {
1251 for (Int_t iLad = 0; iLad < mNLadder; iLad++)
1252 for (Int_t iWaf = 0; iWaf < mNWaferPerLadder; iWaf++) {
1253 iNewLast = mLadders[iLad]->mWafers[iWaf]->
getPoint()->renumHits(iLast);
1260 for (Int_t iLad = 0; iLad < mNLadder; iLad++)
1261 for (Int_t iWaf = 0; iWaf < mNWaferPerLadder; iWaf++) {
1263 StSstPointList *currDeadList = mLadders[iLad]->mWafers[iWaf]->getDeadHits(mDetectorLargeEdge, mDetectorSmallEdge, mStripPitch);
1264 if(currDeadList->getSize()>0){
1266 inactiveHits = inactiveHits->addPointList(currDeadList);
1267 delete currDeadList;
1269 inactiveHits->sortPoint();
1270 return inactiveHits;
1273 void StSstBarrel::convertToStrip(Double_t pairCreationEnergy,
1274 Int_t nstripInACluster,
1277 Double_t parIndRightP,
1278 Double_t parIndRightN,
1279 Double_t parIndLeftP,
1280 Double_t parIndLeftN) {
1282 for (Int_t iLad = 0; iLad < mNLadder; iLad++)
1283 for (Int_t iWaf = 0; iWaf < mNWaferPerLadder; iWaf++) {
1284 mLadders[iLad]->mWafers[iWaf]->convertToStrip(mStripPitch,
1299 void StSstBarrel::addNoiseToStrip(slsCtrl_st *ctrl)
1301 for (Int_t iLad = 0; iLad < mNLadder; iLad++)
1302 for (Int_t iWaf = 0; iWaf < mNWaferPerLadder; iWaf++) {
1303 StSstWafer *wafer = mLadders[iLad]->mWafers[iWaf];
1306 wafer->addNoiseToStripSignal(ctrl[0].nElectronInAMip,ctrl[0].adcDynamic);
1310 Int_t StSstBarrel::readStripFromTable(St_sls_strip *sls_strip)
1312 sls_strip_st *strip = sls_strip->GetTable();
1314 Int_t idWaf = 0, iWaf = 0, iLad = 0;
1318 Int_t idMcHit[5] = {0,0,0,0,0};
1320 Int_t my_counterP =0;
1321 Int_t my_counterN =0;
1322 for (i = 0 ; i < sls_strip->GetNRows(); i++)
1324 nStrip = (int)(strip[i].id_strip/100000.);
1325 idWaf = strip[i].id_strip-10000*((int)(strip[i].id_strip/10000.));
1326 iWaf = (int)((idWaf - mSstLayer*1000)/100)-1;
1327 iLad = idWaf - mSstLayer*1000 - (iWaf+1)*100-1;
1328 iSide = (strip[i].id_strip - nStrip*100000 - idWaf)/10000;
1329 if(iSide==0) my_counterP++;
1330 if(iSide==1) my_counterN++;
1331 for (e = 0 ; e < 5;e++) idMcHit[e] = strip[i].id_mchit[e];
1333 mLadders[iLad]->mWafers[iWaf]->
addStrip(newStrip, iSide);
1335 return sls_strip->GetNRows();
1340 ssdStripCalib_st *noise = strip_calib->GetTable();
1341 Int_t NAdcChannel = (int)pow(2.0,10.0*1.0);
1342 Int_t nElectronInAMip = 22500;
1343 Int_t adcDynamic = 20;
1344 const Float_t AdctoE = (adcDynamic*nElectronInAMip)/(
float)(NAdcChannel);
1345 LOG_DEBUG <<
"AdctoE = " << AdctoE << endm;
1347 Int_t idWaf = 0, iWaf = 0, iLad = 0;
1352 for (i = 0 ; i < strip_calib->GetNRows(); i++)
1354 if (noise[i].
id>0 && noise[i].
id<=76818620) {
1355 nStrip = (int)(noise[i].
id/100000.);
1356 idWaf = noise[i].id-10000*((int)(noise[i].
id/10000.));
1357 iWaf = (int)((idWaf - mSstLayer*1000)/100)-1;
1358 iLad = idWaf - mSstLayer*1000 - (iWaf+1)*100-1;
1359 iSide = (noise[i].id - nStrip*100000 - idWaf)/10000;
1360 StSpaNoise *newStrip =
new StSpaNoise(nStrip ,(
int)(noise[i].pedestals*AdctoE),(
int)((noise[i].rms*AdctoE)/16.));
1361 mLadders[iLad]->mWafers[iWaf]->addNoiseToStripSignal(newStrip,iSide);
1368 Int_t StSstBarrel::readConditionDbFromTable(St_sdm_condition_db *sdm_condition)
1370 sdm_condition_db_st *condition = sdm_condition->GetTable();
1372 Int_t idWaf = 0, iWaf = 0, iLad = 0;
1377 for (i = 0 ; i < sdm_condition->GetNRows(); i++)
1379 if (!(condition[i].is_active))
1381 nStrip = (int)(condition[i].id_strip/100000.);
1382 idWaf = condition[i].id_strip-10000*((int)(condition[i].id_strip/10000.));
1383 iWaf = idWaferToWaferNumb(idWaf);
1384 iLad = (int)(idWaf - mSstLayer*1000 - (iWaf+1)*100 - 1);
1385 iSide = (condition[i].id_strip - nStrip*100000 - idWaf)/10000;
1386 mLadders[iLad]->mWafers[iWaf]->setIsActive(condition[i].is_active, iSide, nStrip);
1389 return sdm_condition->GetNRows();
1392 Int_t StSstBarrel::writeStripToTable(St_spa_strip *spa_strip)
1394 spa_strip_st out_strip;
1396 Int_t currRecord = 0;
1397 for (Int_t iLad = 0; iLad < mNLadder; iLad++)
1398 for (Int_t iWaf = 0; iWaf < mNWaferPerLadder ; iWaf++)
1400 Int_t idCurrentWaf = mSstLayer*1000 +((iWaf+1)*100)+(iLad+1);
1407 out_strip.id = currRecord + 1;
1408 out_strip.adc_count = pStripP->getDigitSig();
1409 out_strip.id_strip = 10000*(10*pStripP->getNStrip() + 0)+idCurrentWaf;
1410 for (Int_t i = 0 ; i < 5 ; i++)
1412 out_strip.id_mchit[i] = pStripP->getIdMcHit(i);
1414 spa_strip->AddAt(&out_strip);
1416 pStripP = stripP->next(pStripP);
1423 out_strip.id = currRecord + 1;
1424 out_strip.adc_count = pStripN->getDigitSig();
1425 out_strip.id_strip = 10000*(10*pStripN->getNStrip() + 1)+idCurrentWaf;
1426 for (Int_t i = 0 ; i < 5 ; i++)
1428 out_strip.id_mchit[i] = pStripN->getIdMcHit(i);
1430 spa_strip->AddAt(&out_strip);
1432 pStripN = stripN->next(pStripN);
1439 Int_t StSstBarrel::writeStripToTable(St_spa_strip *spa_strip,St_sls_strip *sls_strip )
1441 spa_strip_st out_strip;
1442 sls_strip_st *strip = sls_strip->GetTable();
1443 Int_t currRecord = 0;
1444 for (Int_t iLad = 0; iLad < mNLadder; iLad++)
1445 for (Int_t iWaf = 0; iWaf < mNWaferPerLadder ; iWaf++)
1447 Int_t idCurrentWaf = mSstLayer*1000 +((iWaf+1)*100)+(iLad+1);
1453 out_strip.id = currRecord + 1;
1454 out_strip.adc_count = pStripP->getDigitSig();
1455 out_strip.id_strip = 10000*(10*pStripP->getNStrip() + 0)+idCurrentWaf;
1456 for (Int_t i = 0 ; i < 5 ; i++)
1458 out_strip.id_mchit[i] = pStripP->getIdMcHit(i);
1459 if(out_strip.id_mchit[i]==0) {
1460 out_strip.id_mctrack[i]=0;}
1462 for(Int_t j = 0 ; j < sls_strip->GetNRows(); j++){
1463 if(out_strip.id_mchit[i] == strip[j].id_mchit[i])
1464 out_strip.id_mctrack[i] = strip[j].id_mctrack[i];
1468 spa_strip->AddAt(&out_strip);
1470 pStripP = stripP->next(pStripP);
1476 out_strip.id = currRecord + 1;
1477 out_strip.adc_count = pStripN->getDigitSig();
1478 out_strip.id_strip = 10000*(10*pStripN->getNStrip() + 1)+idCurrentWaf;
1479 for (Int_t i = 0 ; i < 5 ; i++)
1481 out_strip.id_mchit[i] = pStripN->getIdMcHit(i);
1482 if(out_strip.id_mchit[i]==0) {
1483 out_strip.id_mctrack[i]=0;}
1485 for(Int_t j = 0 ; j < sls_strip->GetNRows(); j++){
1486 if(out_strip.id_mchit[i] == strip[j].id_mchit[i])
1487 out_strip.id_mctrack[i] = strip[j].id_mctrack[i];
1491 spa_strip->AddAt(&out_strip);
1493 pStripN = stripN->next(pStripN);
1499 void StSstBarrel::doDaqSimulation(slsCtrl_st *ctrl){
1500 for (Int_t iLad = 0; iLad < mNLadder; iLad++)
1501 for (Int_t iWaf = 0; iWaf < mNWaferPerLadder ; iWaf++) {
1502 mLadders[iLad]->mWafers[iWaf]->convertAnalogToDigit(ctrl[0].nElectronInAMip,
1504 ctrl[0].nbitEncoding,
1505 ctrl[0].daqCutValue);
1506 mLadders[iLad]->mWafers[iWaf]->pedestalSubstraction();
1507 mLadders[iLad]->mWafers[iWaf]->zeroSubstraction();
1508 mLadders[iLad]->mWafers[iWaf]->updateStripList();
1512 Int_t StSstBarrel::readNoiseDefaultForSimu(){
1516 Int_t NAdcChannel = (int)pow(2.0,10.0*1.0);
1517 Int_t nElectronInAMip = 22500;
1518 Int_t adcDynamic = 20;
1519 const Float_t AdctoE = (adcDynamic*nElectronInAMip)/(
float)(NAdcChannel);
1520 Int_t NumberOfNoise = 0;
1521 for(Int_t iLad=0;iLad<mNLadder;iLad++)
1523 for(Int_t iWaf=0;iWaf<mNWaferPerLadder;iWaf++)
1525 for(Int_t NStrip=0;NStrip<mNStripPerSide;NStrip++)
1527 for(Int_t iSide=0;iSide<2;iSide++)
1530 mLadders[iLad]->mWafers[iWaf]->addNoiseToStripSignal(newStrip,iSide);
1536 return NumberOfNoise;
StSstBarrel(sstDimensions_st *dimensions, sstConfiguration_st *config=0)
StSstClusterList * getClusterP()
Returns the P-side cluster list attached to this wafer.
Int_t readNoiseFromTable(St_sdm_calib_db *spa_noise, StSstDynamicControl *dynamicControl)
StSstStripList * getStripP()
Returns the P-side strip list attached to this wafer.
Int_t doFindPackage(sstDimensions_st *dimensions, StSstClusterControl *clusterControl)
void addCluster(StSstCluster *ptr, Int_t iSide)
Attaches the ptr cluster on the iSide of the wafer.
StSstPointList * getPoint()
Returns the point list attached to this wafer.
void addStrip(StSstStrip *ptr, Int_t iSide)
StSstClusterList * getClusterN()
Returns the N-side cluster list attached to this wafer.
Event data structure to hold all information from a Monte Carlo simulation. This class is the interfa...
StSstStripList * getStripN()
Returns the N-side strip list attached to this wafer.
void doClusterisation(Int_t *numberOfCluster, StSstClusterControl *clusterControl)