113 #include "StSsdUtil/StSsdBarrel.hh"
117 #include "StSsdHit.h"
118 #include "StSsdHitCollection.h"
119 #include "StarClassLibrary/StThreeVectorF.hh"
121 #include "tables/St_spa_strip_Table.h"
122 #include "tables/St_ssdPedStrip_Table.h"
123 #include "tables/St_scf_cluster_Table.h"
124 #include "tables/St_scm_spt_Table.h"
125 #include "tables/St_sdm_calib_db_Table.h"
126 #include "tables/St_ssdDimensions_Table.h"
127 #include "tables/St_ssdConfiguration_Table.h"
128 #include "tables/St_ssdWafersPosition_Table.h"
129 #include "tables/St_ssdStripCalib_Table.h"
130 #include "tables/St_slsCtrl_Table.h"
131 #include "tables/St_sls_strip_Table.h"
132 #include "tables/St_spa_strip_Table.h"
133 #include "StSsdUtil/StSsdLadder.hh"
134 #include "StSsdUtil/StSsdWafer.hh"
135 #include "StSsdUtil/StSsdClusterControl.h"
136 #include "StSsdDynamicControl.h"
137 #include "StSsdStripList.hh"
138 #include "StSsdStrip.hh"
139 #include "StSsdUtil/StSsdClusterList.hh"
140 #include "StSsdUtil/StSsdCluster.hh"
141 #include "StSsdUtil/StSsdPointList.hh"
142 #include "StSsdUtil/StSsdPoint.hh"
143 #include "SystemOfUnits.h"
144 #include "StarMagField.h"
146 #include "StMessMgr.h"
148 #include "tables/St_ssdGainCalibWafer_Table.h"
149 #include "tables/St_ssdNoise_Table.h"
151 #include "tables/St_ssdWaferConfiguration_Table.h"
152 #include "StMcEvent/StMcSsdHitCollection.hh"
153 #include "StMcEvent.hh"
154 #include "StEventTypes.h"
155 #include "StMcEventTypes.hh"
157 #include "TDataSetIter.h"
166 memset (first, 0, last-first);
168 setSsdParameters(dimensions);
170 setLorentzShift(dimensions);
172 mNLadder = config[0].nMaxLadders;
173 for (Int_t i=0;i<mNLadder;i++) {
175 if (config && config[0].ladderIsPresent[i]==0)
180 for (Int_t iLad=0; iLad < mNLadder; iLad++){
181 mLadders[iLad] =
new StSsdLadder(iLad,mSsdLayer,mNWaferPerLadder,mNStripPerSide);
182 if (Debug()) mLadders[iLad]->SetDebug(Debug());
186 StSsdBarrel::~StSsdBarrel(){
for (Int_t iLad = 0 ; iLad < mNLadder; iLad++)
delete mLadders[iLad]; fSsdBarrel = 0;}
188 void StSsdBarrel::setSsdParameters(ssdDimensions_st *geom_par){
189 mDimensions = geom_par;
191 mDetectorLargeEdge = 2.*geom_par[0].waferHalfActLength;
192 mDetectorSmallEdge = 2.*geom_par[0].waferHalfActWidth;
194 mNWaferPerLadder = geom_par[0].wafersPerLadder;
195 mNStripPerSide = geom_par[0].stripPerSide;
196 mStripPitch = geom_par[0].stripPitch;
197 mTheta = geom_par[0].stereoAngle;
200 void StSsdBarrel::setLorentzShift(ssdDimensions_st *geom_par){
210 StarMagField::Instance()->BField(center,B);
212 Float_t scale = 1.61;
213 Float_t tan_theta_h = scale*TMath::ATan(TMath::Tan(21*2*TMath::Pi()/360)*(B[2]/40.));
214 Float_t tan_theta_e = scale*TMath::ATan(TMath::Tan( 8*2*TMath::Pi()/360)*(B[2]/40.));
215 mShift_hole = geom_par[0].waferHalfThickness*tan_theta_h;
216 mShift_elec = geom_par[0].waferHalfThickness*tan_theta_e;
220 void StSsdBarrel::debugUnPeu (Int_t monladder, Int_t monwafer){
221 for (Int_t i=0;i<this->getNumberOfLadders();i++)
223 if (this->mLadders[i]->getLadderNumb()==monladder)
225 cout<<
" Ladder "<<monladder<<
" found"<<endl;
226 this->mLadders[i]->debugUnPeu(monwafer);
231 void StSsdBarrel::initLadders(St_ssdWafersPosition *wafpos) {
for (Int_t iLad = 0; iLad < mNLadder; iLad++) mLadders[iLad]->initWafers(wafpos);}
233 void StSsdBarrel::Reset() {
for (Int_t iLad = 0; iLad < mNLadder; iLad++) mLadders[iLad]->Reset();}
235 Int_t StSsdBarrel::readStripFromTable(St_spa_strip *spa_strip){
236 spa_strip_st *strip = spa_strip->GetTable();
238 Int_t NumberOfStrip = 0;
245 Int_t iPedestal = 120;
246 Int_t idMcHit[5] = {0,0,0,0,0};
247 Int_t idMcTrack[5] = {0,0,0,0,0};
249 for (Int_t i = 0 ; i < spa_strip->GetNRows(); i++)
251 nStrip = (int)(strip[i].id_strip/100000.);
252 idWaf = strip[i].id_strip-10000*((int)(strip[i].id_strip/10000.));
253 iWaf = idWaferToWafer(idWaf);
254 iLad = (int)(idWaf - mSsdLayer*1000 - (iWaf+1)*100 - 1);
255 iSide = (strip[i].id_strip - nStrip*100000 - idWaf)/10000;
256 for (e = 0 ; e < 5;e++) {
257 idMcHit[e] = strip[i].id_mchit[e];
258 idMcTrack[e] = strip[i].id_mctrack[e];
260 StSsdStrip *newStrip =
new StSsdStrip(nStrip, strip[i].adc_count, sigma, iPedestal, idMcHit,idMcTrack);
261 mLadders[iLad]->mWafers[iWaf]->
addStrip(newStrip, iSide);
263 NumberOfStrip = spa_strip->GetNRows();
264 return NumberOfStrip;
267 Int_t StSsdBarrel::writeNoiseToFile(St_spa_strip *spa_strip){
268 spa_strip_st *strip = spa_strip->GetTable();
269 St_ssdStripCalib *stripCal =
new St_ssdStripCalib(
"ssdStripCalib",spa_strip->GetNRows());
270 ssdStripCalib_st noise_strip;
271 for (Int_t i = 0 ; i < spa_strip->GetNRows(); i++)
273 noise_strip.id=strip[i].id_strip;
274 noise_strip.pedestals=(
unsigned char) strip[i].id_mchit[0];
275 noise_strip.rms=(
unsigned char) strip[i].adc_count;
276 stripCal->AddAt(&noise_strip);
278 TFile f1(
"ssdStripCalib.root",
"NEW");
281 return spa_strip->GetNRows();
284 Int_t StSsdBarrel::writeNewNoiseToFile3(St_ssdPedStrip *spa_ped_strip,
char myLabel[]){
285 char *name =
new char[100] ;
286 ssdPedStrip_st *strip = spa_ped_strip->GetTable();
287 St_ssdNoise *StripCal =
new St_ssdNoise(
"ssdNoise",spa_ped_strip->GetNRows());
288 ssdNoise_st temp[320];
289 memset(temp, 0, 320*
sizeof(ssdNoise_st));
296 Int_t N = spa_ped_strip->GetNRows();
297 for (Int_t i=0; i< N;i++) {
298 if (strip[i].id_strip>0 && strip[i].id_strip<=76818620) {
299 nStrip = (int)(strip[i].id_strip/100000.);
300 idWaf = strip[i].id_strip-10000*((int)(strip[i].id_strip/10000.));
301 iWaf = (int)((idWaf - mSsdLayer*1000)/100 - 1);
302 iLad = (int)(idWaf - mSsdLayer*1000 - (iWaf+1)*100 - 1);
303 iSide = (strip[i].id_strip - nStrip*100000 - idWaf)/10000;
304 wafer = iLad*mNWaferPerLadder +iWaf;
305 if (iSide == 0) temp[wafer].rmsp[nStrip-1] = (
unsigned char)strip[i].noise;
306 if (iSide == 1) temp[wafer].rmsn[nStrip-1] = (
unsigned char)strip[i].noise;
309 for(Int_t i=0;i<320;i++) {
311 StripCal->AddAt(&temp[i]);
313 sprintf(name,
"%s%s%s",
"ssdNoise.",myLabel,
".root");
314 TFile f1(name,
"RECREATE",
"SSD ped and noise file",9);
317 return spa_ped_strip->GetNRows();
323 Int_t StSsdBarrel::writeNoiseToFile(St_ssdPedStrip *spa_ped_strip,
char myLabel[]){
324 char *name =
new char[100] ;
325 ssdPedStrip_st *strip = spa_ped_strip->GetTable();
326 St_ssdStripCalib *stripCal =
new St_ssdStripCalib(
"ssdStripCalib",spa_ped_strip->GetNRows());
327 ssdStripCalib_st noise_strip;
328 for (Int_t i = 0 ; i < spa_ped_strip->GetNRows(); i++)
330 noise_strip.id=strip[i].id_strip;
331 noise_strip.pedestals= (
unsigned char) strip[i].pedestal;
332 noise_strip.rms=(
unsigned char) strip[i].noise;
333 stripCal->AddAt(&noise_strip);
335 sprintf(name,
"%s%s%s",
"ssdStripCalib.",myLabel,
".root");
336 TFile f1(name,
"RECREATE",
"SSD ped and noise file",9);
339 return spa_ped_strip->GetNRows();
346 sdm_calib_db_st *noise = spa_noise->GetTable();
348 Int_t NumberOfNoise = 0;
354 for (Int_t i = 0 ; i < spa_noise->GetNRows(); i++)
356 nStrip = (int)(noise[i].id_strip/100000.);
357 idWaf = noise[i].id_strip-10000*((int)(noise[i].id_strip/10000.));
358 iWaf = idWaferToWafer(idWaf);
359 iLad = (int)(idWaf - mSsdLayer*1000 - (iWaf+1)*100 - 1);
360 iSide = (noise[i].id_strip - nStrip*100000 - idWaf)/10000;
361 mLadders[iLad]->mWafers[iWaf]->setPedestalSigmaStrip(nStrip, iSide,0, noise[i].n_sigma, dynamicControl);
364 NumberOfNoise = spa_noise->GetNRows();
365 return NumberOfNoise;
372 ssdStripCalib_st *noise = strip_calib->GetTable();
374 Int_t NumberOfNoise = 0;
380 for (Int_t i = 0 ; i < strip_calib->GetNRows(); i++)
382 if (noise[i].
id>0 && noise[i].
id<=76818620) {
383 nStrip = (int)(noise[i].
id/100000.);
384 idWaf = noise[i].id-10000*((int)(noise[i].
id/10000.));
385 iWaf = idWaferToWafer(idWaf);
386 iLad = (int)(idWaf - mSsdLayer*1000 - (iWaf+1)*100 - 1);
387 iSide = (noise[i].id - nStrip*100000 - idWaf)/10000;
388 mLadders[iLad]->mWafers[iWaf]->setPedestalSigmaStrip(nStrip, iSide, noise[i].pedestals, noise[i].rms, dynamicControl);
392 return NumberOfNoise;
399 Int_t NumberOfNoise = 0;
400 for(Int_t i=0;i<mNLadder;i++)
402 for(Int_t j=0;j<mNWaferPerLadder;j++)
404 for(Int_t k=0;k<mNStripPerSide;k++)
406 for(Int_t iSide=0;iSide<2;iSide++)
408 mLadders[i]->mWafers[j]->setPedestalSigmaStrip(k+1,iSide,ped,rms,dynamicControl);
414 return NumberOfNoise;
421 ssdNoise_st *noise = strip_noise->GetTable();
423 Int_t NumberOfNoise = 0;
428 Int_t pedestal = 120;
429 printf(
"size of m_noise3 table = %d\n",(
int)strip_noise->GetNRows());
430 for (Int_t i = 0 ; i < strip_noise->GetNRows(); i++)
432 iWaf = noise[i].id-(noise[i].id/mNWaferPerLadder)*mNWaferPerLadder;
433 iLad = noise[i].id/16;
434 for(nStrip=0;nStrip<mNStripPerSide;nStrip++){
436 mLadders[iLad]->mWafers[iWaf]->setPedestalSigmaStrip(nStrip+1, iSide, pedestal, noise[i].rmsp[nStrip], dynamicControl);
439 mLadders[iLad]->mWafers[iWaf]->setPedestalSigmaStrip(nStrip+1, iSide, pedestal, noise[i].rmsn[nStrip], dynamicControl);
443 return NumberOfNoise;
447 Int_t StSsdBarrel::readClusterFromTable(St_scf_cluster *scf_cluster){
448 scf_cluster_st *cluster = scf_cluster->GetTable();
450 Int_t NumberOfCluster = 0;
458 Int_t idMcHit[5] = {0,0,0,0,0};
461 Int_t nFirstStrip = 0;
465 Float_t nNoiseCount = 0;
466 Float_t nStripMean = 0;
469 for (Int_t i = 0 ; i < scf_cluster->GetNRows(); i++)
471 nCluster = (int)(cluster[i].id_cluster/100000.);
472 idWaf = (cluster[i].id_cluster-10000*((int)(cluster[i].id_cluster/10000.)));
473 iSide = (cluster[i].id_cluster-idWaf-nCluster*100000)/10000;
474 iWaf = idWaferToWafer(idWaf);
475 iLad = (int)(idWaf - mSsdLayer*1000 - (iWaf+1)*100 - 1);
476 nFirstStrip = (int)(cluster[i].first_strip/100000.);
477 nStrip = cluster[i].n_strip;
478 nFirstAdc = cluster[i].first_adc_count;
479 nLastAdc = cluster[i].last_adc_count;
480 nAdcCount = cluster[i].adc_count;
481 nNoiseCount = cluster[i].noise_count;
482 nStripMean = cluster[i].strip_mean;
483 nFlag = cluster[i].flag;
484 for (e = 0 ; e < 5; e++) idMcHit[e] = cluster[i].id_mchit[e];
485 StSsdCluster *newCluster =
new StSsdCluster(nCluster, nFirstStrip, nStrip, nAdcCount, nFirstAdc, nLastAdc, nNoiseCount, nStripMean, nFlag, idMcHit);
490 mLadders[iLad]->mWafers[iWaf]->
addCluster(newCluster, iSide);
493 NumberOfCluster = scf_cluster->GetNRows();
494 return NumberOfCluster;
497 Int_t StSsdBarrel::writeClusterToTable(St_scf_cluster *scf_cluster){
498 scf_cluster_st cluster;
499 Int_t currRecord = 0;
502 for (Int_t iLad = 0; iLad < mNLadder; iLad++)
503 for (Int_t iWaf = 0; iWaf < mNWaferPerLadder ; iWaf++)
505 Int_t idCurrentWaf = mSsdLayer*1000 + (iWaf+1)*100 + (iLad+1);
512 cluster.id = currRecord + 1;
513 cluster.id_cluster = 10000*(10*pClusterP->getNCluster() + 0)+idCurrentWaf;
514 cluster.first_strip = 10000*(10*pClusterP->getFirstStrip()+ 0)+idCurrentWaf;
515 cluster.n_strip = pClusterP->getClusterSize();
516 cluster.adc_count = pClusterP->getTotAdc();
517 cluster.first_adc_count = pClusterP->getFirstAdc();
518 cluster.last_adc_count = pClusterP->getLastAdc();
519 cluster.noise_count = (int)pClusterP->getTotNoise();
520 cluster.flag = pClusterP->getFlag();
521 cluster.strip_mean = pClusterP->getStripMean();
522 for (i = 0 ; i < 5 ; i++)
523 cluster.id_mchit[i] = pClusterP->getIdMcHit(i);
524 scf_cluster->AddAt(&cluster);
526 pClusterP = clusterP->next(pClusterP);
532 cluster.id = currRecord + 1;
533 cluster.id_cluster = 10000*(10*pClusterN->getNCluster() + 1)+idCurrentWaf;
534 cluster.first_strip = 10000*(10*pClusterN->getFirstStrip() + 1)+idCurrentWaf;
535 cluster.n_strip = pClusterN->getClusterSize();
536 cluster.adc_count = pClusterN->getTotAdc();
537 cluster.first_adc_count = pClusterN->getFirstAdc();
538 cluster.last_adc_count = pClusterN->getLastAdc();
539 cluster.noise_count = (int)pClusterN->getTotNoise();
540 cluster.flag = pClusterN->getFlag();
541 cluster.strip_mean = pClusterN->getStripMean();
542 for (i = 0 ; i < 5 ; i++)
543 cluster.id_mchit[i] = pClusterN->getIdMcHit(i);
544 scf_cluster->AddAt(&cluster);
546 pClusterN = clusterN->next(pClusterN);
552 Int_t StSsdBarrel::writeClusterToTable(St_scf_cluster *scf_cluster,St_spa_strip *spa_strip){
553 scf_cluster_st cluster;
554 spa_strip_st *on_strip = spa_strip->GetTable();
555 Int_t currRecord = 0;
557 for (Int_t iLad = 0; iLad < mNLadder; iLad++)
558 for (Int_t iWaf = 0; iWaf < mNWaferPerLadder ; iWaf++)
560 Int_t idCurrentWaf = mSsdLayer*1000 + (iWaf+1)*100 + (iLad+1);
567 cluster.id = currRecord + 1;
568 cluster.id_cluster = 10000*(10*pClusterP->getNCluster() + 0)+idCurrentWaf;
569 cluster.first_strip = 10000*(10*pClusterP->getFirstStrip()+ 0)+idCurrentWaf;
570 cluster.n_strip = pClusterP->getClusterSize();
571 cluster.adc_count = pClusterP->getTotAdc();
572 cluster.first_adc_count = pClusterP->getFirstAdc();
573 cluster.last_adc_count = pClusterP->getLastAdc();
574 cluster.noise_count = (Int_t) pClusterP->getTotNoise();
575 cluster.flag = pClusterP->getFlag();
576 cluster.strip_mean = pClusterP->getStripMean();
577 for (i = 0 ; i < 5 ; i++)
579 cluster.id_mchit[i] = pClusterP->getIdMcHit(i);
580 if(cluster.id_mchit[i] == 0){
581 cluster.id_mctrack[i]=0;
584 for(Int_t j = 0 ; j < spa_strip->GetNRows(); j++){
585 if(cluster.id_mchit[i] == on_strip[j].id_mchit[i]){
586 cluster.id_mctrack[i] = on_strip[j].id_mctrack[i];
591 scf_cluster->AddAt(&cluster);
593 pClusterP = clusterP->next(pClusterP);
599 cluster.id = currRecord + 1;
600 cluster.id_cluster = 10000*(10*pClusterN->getNCluster() + 1)+idCurrentWaf;
601 cluster.first_strip = 10000*(10*pClusterN->getFirstStrip() + 1)+idCurrentWaf;
602 cluster.n_strip = pClusterN->getClusterSize();
603 cluster.adc_count = pClusterN->getTotAdc();
604 cluster.first_adc_count = pClusterN->getFirstAdc();
605 cluster.last_adc_count = pClusterN->getLastAdc();
606 cluster.noise_count = (Int_t) pClusterN->getTotNoise();
607 cluster.flag = pClusterN->getFlag();
608 cluster.strip_mean = pClusterN->getStripMean();
609 for (i = 0 ; i < 5 ; i++)
611 cluster.id_mchit[i] = pClusterN->getIdMcHit(i);
612 if(cluster.id_mchit[i] == 0)cluster.id_mctrack[i]=0;
614 for(Int_t j = 0 ; j < spa_strip->GetNRows(); j++){
615 if(cluster.id_mchit[i] == on_strip[j].id_mchit[i]){
616 cluster.id_mctrack[i] = on_strip[j].id_mctrack[i];
621 scf_cluster->AddAt(&cluster);
623 pClusterN = clusterN->next(pClusterN);
629 Int_t StSsdBarrel::writePointToContainer(St_scm_spt *scm_spt,
StSsdHitCollection* ssdHitColl){
633 Int_t i = 0, inContainer = 0, inTable = 0;
635 Int_t hw; Float_t q ;
unsigned char c;
638 for (Int_t iLad = 0; iLad < mNLadder; iLad++)
639 for (Int_t iWaf = 0; iWaf < mNWaferPerLadder; iWaf++)
641 Int_t idCurrentWaf = mSsdLayer*1000 + (iWaf+1)*100 + (iLad+1);
647 for (i = 0 ; i < 3 ; i++){
648 gPos[i] = pSpt->getXg(i);
653 currentSsdHit =
new StSsdHit(gPos,gPosError,hw,q,c);
654 currentSsdHit->setIdTruth(pSpt->getNMchit(0));
656 currentSsdHit->setHardwarePosition(8+16*idWaferToWaferNumb(idCurrentWaf));
657 currentSsdHit->setLocalPosition(pSpt->getXl(0),pSpt->getXl(1));
659 Int_t Id_P_Side = pSpt->getIdClusterP();
660 Int_t Id_N_Side = pSpt->getIdClusterN();
666 if(cluster_P_j->getNCluster()==Id_P_Side)
668 cluster_P_j = currentListP_j->next(cluster_P_j);
676 if(cluster_N_j->getNCluster()==Id_N_Side)
678 cluster_N_j = currentListN_j->next(cluster_N_j);
690 + 16 * idWaferToWaferNumb(idCurrentWaf)
691 + 8192 * (int)cluster_N_j->getStripMean()
692 + 8388608 * ((int)cluster_P_j->getStripMean() - (int)cluster_N_j->getStripMean() +15)
693 + 268435456 * (
int)((cluster_N_j->getClusterSize() > 3) ? 3 : cluster_N_j->getClusterSize()-1)
694 + 1073741824 * (
int)((cluster_P_j->getClusterSize() > 3) ? 3 : cluster_P_j->getClusterSize()-1);
695 currentSsdHit->setHardwarePosition(hw);
697 inContainer += ssdHitColl->addHit(currentSsdHit);
701 spt.flag = pSpt->getFlag();
702 spt.id = 10000*(pSpt->getNPoint())+idCurrentWaf;
703 spt.id_cluster = pSpt->getNCluster();
705 spt.id_match = pSpt->getNMatched();
706 for (i = 0 ; i < 5 ; i++)
708 spt.id_mchit[i] = pSpt->getNMchit(i);
709 spt.id_mctrack[i] = 0;
712 spt.id_wafer = idCurrentWaf;
713 for (i = 0 ; i < 3 ; i++)
717 spt.x[i] = pSpt->getXg(i);
718 spt.xl[i] = pSpt->getXl(i);
720 for (i = 0 ; i < 2 ; i++)
723 spt.de[i] = pSpt->getDe(i);
725 scm_spt->AddAt(&spt);
728 pSpt = sptList->next(pSpt);
734 Int_t StSsdBarrel::writePointToContainer(St_scm_spt *scm_spt,
StSsdHitCollection* ssdHitColl,St_scf_cluster *scf_cluster){
737 scf_cluster_st *on_cluster = scf_cluster->GetTable();
739 Int_t i = 0, inContainer = 0, inTable = 0 ;
741 Int_t hw; Float_t q ;
unsigned char c;
743 for (Int_t iLad = 0; iLad < mNLadder; iLad++)
744 for (Int_t iWaf = 0; iWaf < mNWaferPerLadder; iWaf++)
746 Int_t idCurrentWaf = mSsdLayer*1000 + (iWaf+1)*100 + (iLad+1);
754 for (i = 0 ; i < 5 ; i++)
756 spt.id_mchit[i] = pSpt->getNMchit(i);
757 spt.id_mctrack[i] = 0;
760 if (spt.id_mchit[i] == 0) spt.id_mctrack[i]=0;
762 for(Int_t j = 0 ; j < scf_cluster->GetNRows(); j++){
763 if(spt.id_mchit[i] == on_cluster[j].id_mchit[i]){
764 spt.id_mctrack[i] = on_cluster[j].id_mctrack[i];
772 for (i = 0 ; i < 3 ; i++){
773 gPos[i] = pSpt->getXg(i);
778 currentSsdHit =
new StSsdHit(gPos,gPosError,hw,q,c);
779 currentSsdHit->setIdTruth(spt.id_mctrack[0],100);
783 Int_t Id_P_Side = pSpt->getIdClusterP();
784 Int_t Id_N_Side = pSpt->getIdClusterN();
790 if(cluster_P_j->getNCluster()==Id_P_Side)
792 cluster_P_j = currentListP_j->next(cluster_P_j);
800 if(cluster_N_j->getNCluster()==Id_N_Side)
802 cluster_N_j = currentListN_j->next(cluster_N_j);
814 + 16 * idWaferToWaferNumb(idCurrentWaf)
815 + 8192 * (int)cluster_N_j->getStripMean()
816 + 8388608 * ((int)cluster_P_j->getStripMean() - (int)cluster_N_j->getStripMean() +15)
817 + 268435456 * (
int)((cluster_N_j->getClusterSize() > 3) ? 3 : cluster_N_j->getClusterSize()-1)
818 + 1073741824 * (
int)((cluster_P_j->getClusterSize() > 3) ? 3 : cluster_P_j->getClusterSize()-1);
819 currentSsdHit->setHardwarePosition(hw);
820 currentSsdHit->setLocalPosition(pSpt->getXl(0),pSpt->getXl(1));
821 inContainer += ssdHitColl->addHit(currentSsdHit);
825 spt.flag = pSpt->getFlag();
826 spt.id = 10000*(pSpt->getNPoint())+idCurrentWaf;
827 spt.id_cluster = pSpt->getNCluster();
829 spt.id_match = pSpt->getNMatched();
830 for (i = 0 ; i < 5 ; i++)
832 spt.id_mchit[i] = pSpt->getNMchit(i);
833 spt.id_mctrack[i] = 0;
836 spt.id_wafer = idCurrentWaf;
837 for (i = 0 ; i < 3 ; i++)
841 spt.x[i] = pSpt->getXg(i);
842 spt.xl[i] = pSpt->getXl(i);
844 for (i = 0 ; i < 2 ; i++)
847 spt.de[i] = pSpt->getDe(i);
849 scm_spt->AddAt(&spt);
852 pSpt = sptList->next(pSpt);
860 vector<const StMcSsdHit*> hitCol;
862 int totRatio, idTruth;
865 if(Debug()){cout <<
"McEvent exists" << endl;}
866 myCol = mcEvent->ssdHitCollection();
869 for (
unsigned int iLadder=0; iLadder<myCol->numberOfLadders(); iLadder++) {
870 for (
unsigned int iWafer = 0; iWafer < myCol->ladder(iLadder)->numberOfWafers(); iWafer++) {
871 for (StMcSsdHitIterator iter = myCol->ladder(iLadder)->wafer(iWafer)->hits().begin();
872 iter != myCol->ladder(iLadder)->wafer(iWafer)->hits().end();
876 hitCol.push_back(hit);
882 else{cout<<
"No ssdMcHitCollection" <<endl;
886 scf_cluster_st *on_cluster = scf_cluster->GetTable();
888 Int_t i = 0, inContainer = 0, inTable = 0;
890 Int_t hw; Float_t q ;
unsigned char c;
892 for (Int_t iLad = 0; iLad < mNLadder; iLad++)
893 for (Int_t iWaf = 0; iWaf < mNWaferPerLadder; iWaf++)
895 Int_t idCurrentWaf = mSsdLayer*1000 + (iWaf+1)*100 + (iLad+1);
908 for (i = 0 ; i < 5 ; i++)
910 spt.id_mchit[i] = pSpt->getNMchit(i);
911 spt.id_mctrack[i] = 0;
914 if (spt.id_mchit[i] == 0) spt.id_mctrack[i]=0;
917 for(j = 0 ; j < scf_cluster->GetNRows(); j++){
918 if(spt.id_mchit[i] == on_cluster[j].id_mchit[i]){
919 spt.id_mctrack[i] = on_cluster[j].id_mctrack[i];
920 idClusP = 10000*(10*pSpt->getIdClusterP() + 0)+idCurrentWaf;
921 idClusN = 10000*(10*pSpt->getIdClusterN() + 1)+idCurrentWaf;
925 Calculation_Ratio(idCurrentWaf,idClusP,idClusN,hitCol,&totRatio,&idTruth);
931 for (i = 0 ; i < 3 ; i++){
932 gPos[i] = pSpt->getXg(i);
937 currentSsdHit =
new StSsdHit(gPos,gPosError,hw,q,c);
939 currentSsdHit->setIdTruth(idTruth,(
int)totRatio);
943 Int_t Id_P_Side = pSpt->getIdClusterP();
944 Int_t Id_N_Side = pSpt->getIdClusterN();
950 if(cluster_P_j->getNCluster()==Id_P_Side)
952 cluster_P_j = currentListP_j->next(cluster_P_j);
958 if(cluster_N_j->getNCluster()==Id_N_Side)
960 cluster_N_j = currentListN_j->next(cluster_N_j);
972 + 16 * idWaferToWaferNumb(idCurrentWaf)
973 + 8192 * (int)cluster_N_j->getStripMean()
974 + 8388608 * ((int)cluster_P_j->getStripMean() - (int)cluster_N_j->getStripMean() +15)
975 + 268435456 * (
int)((cluster_N_j->getClusterSize() > 3) ? 3 : cluster_N_j->getClusterSize()-1)
976 + 1073741824 * (
int)((cluster_P_j->getClusterSize() > 3) ? 3 : cluster_P_j->getClusterSize()-1);
977 currentSsdHit->setHardwarePosition(hw);
978 currentSsdHit->setLocalPosition(pSpt->getXl(0),pSpt->getXl(1));
979 inContainer += ssdHitColl->addHit(currentSsdHit);
983 spt.flag = pSpt->getFlag();
984 spt.id = 10000*(pSpt->getNPoint())+idCurrentWaf;
985 spt.id_cluster = pSpt->getNCluster();
987 spt.id_match = pSpt->getNMatched();
988 for (i = 0 ; i < 5 ; i++)
990 spt.id_mchit[i] = pSpt->getNMchit(i);
991 spt.id_mctrack[i] = 0;
994 spt.id_wafer = idCurrentWaf;
995 for (i = 0 ; i < 3 ; i++)
999 spt.x[i] = pSpt->getXg(i);
1000 spt.xl[i] = pSpt->getXl(i);
1002 for (i = 0 ; i < 2 ; i++)
1005 spt.de[i] = pSpt->getDe(i);
1007 scm_spt->AddAt(&spt);
1010 pSpt = sptList->next(pSpt);
1013 if (hitCol.size()>0 )hitCol.clear();
1017 void StSsdBarrel::Calculation_Ratio(
int idWafer,
int idClusterP,
int idClusterN,vector<const StMcSsdHit*> hitCol,
int *ratio,
int *idTruth)
1019 Float_t charge[2] = {0,0};
1022 Float_t adc_DominatorP = 0;
1023 Float_t adc_DominatorN = 0;
1024 vector<StSsdStrip*> ListstripP;
1025 vector<StSsdStrip*> ListstripN;
1026 vector<int> GTrackP(5,0),GTrackN(5,0);
1027 int isSplittedP=0,isSplittedN =0;
1028 Int_t lad = idWaferToLadderNumb(idWafer);
1029 Int_t waf = (int)((idWafer - mSsdLayer*1000)/100)-1;
1033 int idP = 10000*(10*pClusterP->getNCluster() + 0)+idWafer;
1034 if(idP==idClusterP){
1035 charge[0] = pClusterP->getTotAdc();
1036 if(pClusterP->getFlag()==1){
1038 isSplittedP = isSplit(pClusterP,0,lad,waf);
1040 for(Int_t e =0 ;e<5;e++)GTrackP.push_back(pClusterP->getIdMcHit(e));
1044 for(
int kk=pClusterP->getFirstStrip();kk<pClusterP->getFirstStrip()+pClusterP->getClusterSize();kk++)
1049 if((pStripP->getNStrip()==kk)&&(pStripP->getNStrip()!=lastScan))
1051 lastScan = pStripP->getNStrip();
1052 ListstripP.push_back(pStripP);
1054 pStripP = stripP->next(pStripP);
1059 pClusterP = mLadders[lad]->mWafers[waf]->
getClusterP()->next(pClusterP);
1064 int idN = 10000*(10*pClusterN->getNCluster() + 1)+idWafer;
1065 if(idN==idClusterN){
1066 charge[1] = pClusterN->getTotAdc();
1067 if(pClusterN->getFlag()==1){
1069 isSplittedN = isSplit(pClusterN,1,lad,waf);
1071 for(Int_t e =0 ;e<5;e++)GTrackN.push_back(pClusterN->getIdMcHit(e));
1075 for(
int kk=pClusterN->getFirstStrip();kk<pClusterN->getFirstStrip()+pClusterN->getClusterSize();kk++)
1080 if((pStripN->getNStrip()==kk)&&(pStripN->getNStrip()!=lastScan))
1082 lastScan = pStripN->getNStrip();
1083 ListstripN.push_back(pStripN);
1085 pStripN = stripN->next(pStripN);
1090 pClusterN = mLadders[lad]->mWafers[waf]->
getClusterN()->next(pClusterN);
1094 DominatorP = FindMcHit(GTrackP,hitCol);
1095 DominatorN = FindMcHit(GTrackN,hitCol);
1096 if(DominatorP!=DominatorN) {
1101 if((ListstripN.size()>0)&&(ListstripP.size()>0))
1103 unsigned int min ,max;
1109 max = ListstripP.size()-1;}
1113 max = ListstripP.size();}
1116 max = ListstripP.size();}
1117 for(
unsigned int ee = min;ee<max;ee++){
1119 if(DominatorP == tempoStripP->getIdMcTrack(0))
1121 adc_DominatorP += tempoStripP->getDigitSig();
1132 max = ListstripN.size()-1;
1137 max = ListstripN.size();
1141 max = ListstripN.size();
1143 for(
unsigned int ee = min;ee<max;ee++){
1145 if(DominatorN == tempoStripN->getIdMcTrack(0))
1147 adc_DominatorN += tempoStripN->getDigitSig();
1156 if(charge[0]!=0) ratioP = adc_DominatorP/charge[0];
1157 if(charge[1]!=0) ratioN = adc_DominatorN/charge[1];
1158 if(DominatorP == DominatorN){
1159 *ratio = (int)(100*(ratioP*ratioN));
1160 *idTruth = DominatorP;
1166 if(ListstripP.size()>0) ListstripP.clear();
1167 if(ListstripN.size()>0) ListstripN.clear();
1168 if(GTrackP.size()>0) GTrackP.clear();
1169 if(GTrackN.size()>0) GTrackN.clear();
1172 Int_t StSsdBarrel::FindMcHit(
const vector<int> &tempo,
const vector<const StMcSsdHit*> &hitCol)
1174 float ChargeTrack = 0.0;
1176 for(
int e=0;e<5;e++){
1177 for (
unsigned int hit = 0 ;
hit<hitCol.size();
hit++){
1179 if((tempo[e]>0)&&(currHit->key() == tempo[e])&&(currHit->dE()>ChargeTrack)){
1180 ChargeTrack = currHit->dE();
1181 idTrack = currHit->parentTrack()->key();
1188 Int_t StSsdBarrel::isSplit(
StSsdCluster *currentCluster,
int iSide,
int lad,
int waf){
1195 firstClus = mLadders[lad]->mWafers[waf]->
getClusterP()->first();
1196 lastClus = mLadders[lad]->mWafers[waf]->
getClusterP()->last();
1199 firstClus = mLadders[lad]->mWafers[waf]->
getClusterN()->first();
1200 lastClus = mLadders[lad]->mWafers[waf]->
getClusterN()->last();
1202 if(currentCluster->getNCluster() == firstClus->getNCluster()){
1205 else if(currentCluster->getNCluster() == lastClus->getNCluster()){
1209 nextClus = currentCluster->getNextCluster();
1210 if(nextClus->getFirstStrip() == ((currentCluster->getFirstStrip()+currentCluster->getClusterSize()-1))) {
1212 prevClus = currentCluster->getPrevCluster();
1213 if(currentCluster->getFirstStrip() == ((prevClus->getFirstStrip()+prevClus->getClusterSize()-1))) {
1221 void StSsdBarrel::doSideClusterisation(Int_t *barrelNumbOfCluster){
1222 Int_t wafNumbOfCluster[2];
1223 wafNumbOfCluster[0] = 0;
1224 wafNumbOfCluster[1] = 0;
1226 for (Int_t iLad = 0 ; iLad < mNLadder; iLad++)
1227 for (Int_t iWaf = 0 ; iWaf < mNWaferPerLadder; iWaf++)
1229 mLadders[iLad]->mWafers[iWaf]->
doClusterisation(wafNumbOfCluster, mClusterControl);
1230 barrelNumbOfCluster[0] += wafNumbOfCluster[0];
1231 barrelNumbOfCluster[1] += wafNumbOfCluster[1];
1235 void StSsdBarrel::doSideClusterisation(Int_t *barrelNumbOfCluster,Int_t WafStatus[20][16]){
1236 Int_t wafNumbOfCluster[2];
1237 wafNumbOfCluster[0] = 0;
1238 wafNumbOfCluster[1] = 0;
1239 for (Int_t iLad = 0 ; iLad < mNLadder; iLad++)
1240 for (Int_t iWaf = 0 ; iWaf < mNWaferPerLadder; iWaf++)
1242 if(WafStatus[iLad][iWaf]!=0){
1243 mLadders[iLad]->mWafers[iWaf]->
doClusterisation(wafNumbOfCluster, mClusterControl);
1244 barrelNumbOfCluster[0] += wafNumbOfCluster[0];
1245 barrelNumbOfCluster[1] += wafNumbOfCluster[1];
1250 Int_t StSsdBarrel::doClusterMatching(Float_t *CalibArray){
1251 Int_t NumberOfPackage = 0;
1255 for (Int_t iLad = 0; iLad < mNLadder; iLad++){
1256 for (Int_t iWaf = 0; iWaf < mNWaferPerLadder; iWaf++)
1258 mLadders[iLad]->mWafers[iWaf]->
doLorentzShift(mDimensions,mShift_hole,mShift_elec);
1259 NumberOfPackage += mLadders[iLad]->mWafers[iWaf]->
doFindPackage(mDimensions, mClusterControl);
1260 nPerfect = mLadders[iLad]->mWafers[iWaf]->doSolvePerfect(mDimensions, mClusterControl,CalibArray[(iLad*mNWaferPerLadder)+iWaf]);
1261 if (!nPerfect)
continue;
1262 mLadders[iLad]->mWafers[iWaf]->doStatPerfect(nPerfect, mClusterControl);
1263 nSolved += mLadders[iLad]->mWafers[iWaf]->doSolvePackage(mDimensions, mClusterControl,CalibArray[(iLad*mNWaferPerLadder)+iWaf]);
1266 cout<<
"**** Remark: "<<nSolved<<
" solved packages ****\n";
1267 return NumberOfPackage;
1271 long nElectronInAMip = dynamicControl->getnElectronInAMip();
1272 long adcDynamic = dynamicControl->getadcDynamic();
1273 Double_t pairCreationEnergy = dynamicControl->getpairCreationEnergy();
1275 const Int_t NAdcChannel = (int)pow(2.0,dynamicControl->getnbitEncoding());
1276 const Double_t convFactor = (pairCreationEnergy*adcDynamic*nElectronInAMip)/NAdcChannel;
1277 for (Int_t iLad = 0; iLad < mNLadder; iLad++)
1278 for (Int_t iWaf = 0; iWaf < mNWaferPerLadder; iWaf++)
1279 mLadders[iLad]->mWafers[iWaf]->convertDigitToAnalog(convFactor);
1282 void StSsdBarrel::convertUFrameToOther(){
1283 for (Int_t iLad = 0; iLad < mNLadder; iLad++)
1284 for (Int_t iWaf = 0; iWaf < mNWaferPerLadder; iWaf++)
1286 mLadders[iLad]->mWafers[iWaf]->convertUFrameToLocal(mDimensions);
1287 mLadders[iLad]->mWafers[iWaf]->convertLocalToGlobal();
1291 void StSsdBarrel::convertGlobalFrameToOther(){
1292 for (Int_t iLad = 0; iLad < mNLadder; iLad++){
1293 for (Int_t iWaf = 0; iWaf < mNWaferPerLadder; iWaf++)
1295 mLadders[iLad]->mWafers[iWaf]->convertGlobalToLocal();
1296 mLadders[iLad]->mWafers[iWaf]->convertLocalToUFrame(mDetectorLargeEdge, mDetectorSmallEdge, mTheta);
1301 void StSsdBarrel::sortListStrip(){
1304 for (Int_t iLad = 0; iLad < mNLadder; iLad++)
1305 for (Int_t iWaf = 0; iWaf < mNWaferPerLadder; iWaf++)
1307 currentList = mLadders[iLad]->mWafers[iWaf]->
getStripP();
1308 isSorted = currentList->isSorted();
1309 if (!isSorted) currentList->sortStrip();
1311 currentList = mLadders[iLad]->mWafers[iWaf]->
getStripN();
1312 isSorted = currentList->isSorted();
1313 if (!isSorted) currentList->sortStrip();
1318 void StSsdBarrel::sortListCluster(){
1321 for (Int_t iLad = 0; iLad < mNLadder; iLad++)
1322 for (Int_t iWaf = 0; iWaf < mNWaferPerLadder; iWaf++)
1324 currentList = mLadders[iLad]->mWafers[iWaf]->
getClusterP();
1325 isSorted = currentList->isSorted();
1326 if (!isSorted) currentList->sortCluster();
1328 currentList = mLadders[iLad]->mWafers[iWaf]->
getClusterN();
1329 isSorted = currentList->isSorted();
1330 if (!isSorted) currentList->sortCluster();
1336 mSsdLayer = originalBarrel.mSsdLayer;
1337 mNLadder = originalBarrel.mNLadder;
1338 mNWaferPerLadder = originalBarrel.mNWaferPerLadder;
1339 mNStripPerSide = originalBarrel.mNStripPerSide;
1342 for (Int_t iLad=0; iLad < mNLadder; iLad++)
1343 mLadders[iLad] =
new StSsdLadder(iLad,mSsdLayer,mNWaferPerLadder,mNStripPerSide);
1348 mSsdLayer = originalBarrel.mSsdLayer;
1349 mNLadder = originalBarrel.mNLadder;
1350 mNWaferPerLadder = originalBarrel.mNWaferPerLadder;
1351 mNStripPerSide = originalBarrel.mNStripPerSide;
1354 for (Int_t iLad=0; iLad < mNLadder; iLad++)
1355 mLadders[iLad] =
new StSsdLadder(iLad,mSsdLayer,mNWaferPerLadder,mNStripPerSide);
1359 Int_t StSsdBarrel::idWaferToWaferNumb(Int_t idWafer)
1361 Int_t iW = (int)((idWafer - mSsdLayer*1000)/100);
1362 Int_t iL = idWafer - mSsdLayer*1000 - iW*100;
1363 return ((iL-1)*mNWaferPerLadder + iW -1);
1366 Int_t StSsdBarrel::idWaferToLadderNumb(Int_t idWafer)
1368 Int_t iW = (int)((idWafer - mSsdLayer*1000)/100);
1369 Int_t iL = idWafer - mSsdLayer*1000 - iW*100;
1373 Int_t StSsdBarrel::waferNumbToIdWafer(Int_t waferNumb)
1375 Int_t iL = 1+(int)((waferNumb)/mNWaferPerLadder);
1376 Int_t iW = waferNumb-((iL-1)*mNWaferPerLadder)+1;
1377 return mSsdLayer*1000 + iW*100 + iL;
1380 Int_t StSsdBarrel::isActiveLadder(Int_t iLadder)
1382 return mActiveLadders[iLadder];
1384 void StSsdBarrel::renumHitAfterRemove() {
1387 for (Int_t iLad = 0; iLad < mNLadder; iLad++)
1388 for (Int_t iWaf = 0; iWaf < mNWaferPerLadder; iWaf++) {
1389 iNewLast = mLadders[iLad]->mWafers[iWaf]->
getPoint()->renumHits(iLast);
1396 for (Int_t iLad = 0; iLad < mNLadder; iLad++)
1397 for (Int_t iWaf = 0; iWaf < mNWaferPerLadder; iWaf++) {
1399 StSsdPointList *currDeadList = mLadders[iLad]->mWafers[iWaf]->getDeadHits(mDetectorLargeEdge, mDetectorSmallEdge, mStripPitch);
1400 if(currDeadList->getSize()>0){
1402 inactiveHits = inactiveHits->addPointList(currDeadList);
1403 delete currDeadList;
1405 inactiveHits->sortPoint();
1406 return inactiveHits;
1409 void StSsdBarrel::convertToStrip(Double_t pairCreationEnergy,
1410 Int_t nstripInACluster,
1413 Double_t parIndRightP,
1414 Double_t parIndRightN,
1415 Double_t parIndLeftP,
1416 Double_t parIndLeftN) {
1418 for (Int_t iLad = 0; iLad < mNLadder; iLad++)
1419 for (Int_t iWaf = 0; iWaf < mNWaferPerLadder; iWaf++) {
1420 mLadders[iLad]->mWafers[iWaf]->convertToStrip(mStripPitch,
1435 void StSsdBarrel::addNoiseToStrip(slsCtrl_st *ctrl)
1437 for (Int_t iLad = 0; iLad < mNLadder; iLad++)
1438 for (Int_t iWaf = 0; iWaf < mNWaferPerLadder; iWaf++) {
1439 StSsdWafer *wafer = mLadders[iLad]->mWafers[iWaf];
1442 wafer->addNoiseToStripSignal(ctrl[0].nElectronInAMip,ctrl[0].adcDynamic);
1446 Int_t StSsdBarrel::readStripFromTable(St_sls_strip *sls_strip)
1448 sls_strip_st *strip = sls_strip->GetTable();
1450 Int_t idWaf = 0, iWaf = 0, iLad = 0;
1454 Int_t idMcHit[5] = {0,0,0,0,0};
1456 Int_t my_counterP =0;
1457 Int_t my_counterN =0;
1458 for (i = 0 ; i < sls_strip->GetNRows(); i++)
1460 nStrip = (int)(strip[i].id_strip/100000.);
1461 idWaf = strip[i].id_strip-10000*((int)(strip[i].id_strip/10000.));
1462 iWaf = (int)((idWaf - mSsdLayer*1000)/100)-1;
1463 iLad = idWaf - mSsdLayer*1000 - (iWaf+1)*100-1;
1464 iSide = (strip[i].id_strip - nStrip*100000 - idWaf)/10000;
1465 if(iSide==0) my_counterP++;
1466 if(iSide==1) my_counterN++;
1467 for (e = 0 ; e < 5;e++) idMcHit[e] = strip[i].id_mchit[e];
1469 mLadders[iLad]->mWafers[iWaf]->
addStrip(newStrip, iSide);
1471 return sls_strip->GetNRows();
1476 ssdStripCalib_st *noise = strip_calib->GetTable();
1477 Int_t NAdcChannel = (int)pow(2.0,10.0*1.0);
1478 Int_t nElectronInAMip = 22500;
1479 Int_t adcDynamic = 20;
1480 const Float_t AdctoE = (adcDynamic*nElectronInAMip)/(
float)(NAdcChannel);
1481 if(Debug()) {printf(
"AdctoE = %f\n",AdctoE);}
1483 Int_t idWaf = 0, iWaf = 0, iLad = 0;
1488 for (i = 0 ; i < strip_calib->GetNRows(); i++)
1490 if (noise[i].
id>0 && noise[i].
id<=76818620) {
1491 nStrip = (int)(noise[i].
id/100000.);
1492 idWaf = noise[i].id-10000*((int)(noise[i].
id/10000.));
1493 iWaf = (int)((idWaf - mSsdLayer*1000)/100)-1;
1494 iLad = idWaf - mSsdLayer*1000 - (iWaf+1)*100-1;
1495 iSide = (noise[i].id - nStrip*100000 - idWaf)/10000;
1496 StSpaNoise *newStrip =
new StSpaNoise(nStrip ,(
int)(noise[i].pedestals*AdctoE),(
int)((noise[i].rms*AdctoE)/16.));
1497 mLadders[iLad]->mWafers[iWaf]->addNoiseToStripSignal(newStrip,iSide);
1504 Int_t StSsdBarrel::readConditionDbFromTable(St_sdm_condition_db *sdm_condition)
1506 sdm_condition_db_st *condition = sdm_condition->GetTable();
1508 Int_t idWaf = 0, iWaf = 0, iLad = 0;
1513 for (i = 0 ; i < sdm_condition->GetNRows(); i++)
1515 if (!(condition[i].is_active))
1517 nStrip = (int)(condition[i].id_strip/100000.);
1518 idWaf = condition[i].id_strip-10000*((int)(condition[i].id_strip/10000.));
1519 iWaf = idWaferToWaferNumb(idWaf);
1520 iLad = (int)(idWaf - mSsdLayer*1000 - (iWaf+1)*100 - 1);
1521 iSide = (condition[i].id_strip - nStrip*100000 - idWaf)/10000;
1522 mLadders[iLad]->mWafers[iWaf]->setIsActive(condition[i].is_active, iSide, nStrip);
1525 return sdm_condition->GetNRows();
1528 Int_t StSsdBarrel::writeStripToTable(St_spa_strip *spa_strip)
1530 spa_strip_st out_strip;
1532 Int_t currRecord = 0;
1533 for (Int_t iLad = 0; iLad < mNLadder; iLad++)
1534 for (Int_t iWaf = 0; iWaf < mNWaferPerLadder ; iWaf++)
1536 Int_t idCurrentWaf = mSsdLayer*1000 +((iWaf+1)*100)+(iLad+1);
1544 out_strip.id = currRecord + 1;
1545 out_strip.adc_count = pStripP->getDigitSig();
1546 out_strip.id_strip = 10000*(10*pStripP->getNStrip() + 0)+idCurrentWaf;
1547 for (Int_t i = 0 ; i < 5 ; i++)
1549 out_strip.id_mchit[i] = pStripP->getIdMcHit(i);
1551 spa_strip->AddAt(&out_strip);
1553 pStripP = stripP->next(pStripP);
1560 out_strip.id = currRecord + 1;
1561 out_strip.adc_count = pStripN->getDigitSig();
1562 out_strip.id_strip = 10000*(10*pStripN->getNStrip() + 1)+idCurrentWaf;
1563 for (Int_t i = 0 ; i < 5 ; i++)
1565 out_strip.id_mchit[i] = pStripN->getIdMcHit(i);
1567 spa_strip->AddAt(&out_strip);
1569 pStripN = stripN->next(pStripN);
1576 Int_t StSsdBarrel::writeStripToTable(St_spa_strip *spa_strip,St_sls_strip *sls_strip )
1578 spa_strip_st out_strip;
1579 sls_strip_st *strip = sls_strip->GetTable();
1580 Int_t currRecord = 0;
1581 for (Int_t iLad = 0; iLad < mNLadder; iLad++)
1582 for (Int_t iWaf = 0; iWaf < mNWaferPerLadder ; iWaf++)
1584 Int_t idCurrentWaf = mSsdLayer*1000 +((iWaf+1)*100)+(iLad+1);
1590 out_strip.id = currRecord + 1;
1591 out_strip.adc_count = pStripP->getDigitSig();
1592 out_strip.id_strip = 10000*(10*pStripP->getNStrip() + 0)+idCurrentWaf;
1593 for (Int_t i = 0 ; i < 5 ; i++)
1595 out_strip.id_mchit[i] = pStripP->getIdMcHit(i);
1596 if(out_strip.id_mchit[i]==0) {
1597 out_strip.id_mctrack[i]=0;}
1599 for(Int_t j = 0 ; j < sls_strip->GetNRows(); j++){
1600 if(out_strip.id_mchit[i] == strip[j].id_mchit[i])
1601 out_strip.id_mctrack[i] = strip[j].id_mctrack[i];
1605 spa_strip->AddAt(&out_strip);
1607 pStripP = stripP->next(pStripP);
1613 out_strip.id = currRecord + 1;
1614 out_strip.adc_count = pStripN->getDigitSig();
1615 out_strip.id_strip = 10000*(10*pStripN->getNStrip() + 1)+idCurrentWaf;
1616 for (Int_t i = 0 ; i < 5 ; i++)
1618 out_strip.id_mchit[i] = pStripN->getIdMcHit(i);
1619 if(out_strip.id_mchit[i]==0) {
1620 out_strip.id_mctrack[i]=0;}
1622 for(Int_t j = 0 ; j < sls_strip->GetNRows(); j++){
1623 if(out_strip.id_mchit[i] == strip[j].id_mchit[i])
1624 out_strip.id_mctrack[i] = strip[j].id_mctrack[i];
1628 spa_strip->AddAt(&out_strip);
1630 pStripN = stripN->next(pStripN);
1636 void StSsdBarrel::doDaqSimulation(slsCtrl_st *ctrl){
1637 for (Int_t iLad = 0; iLad < mNLadder; iLad++)
1638 for (Int_t iWaf = 0; iWaf < mNWaferPerLadder ; iWaf++) {
1639 mLadders[iLad]->mWafers[iWaf]->convertAnalogToDigit(ctrl[0].nElectronInAMip,
1641 ctrl[0].nbitEncoding,
1642 ctrl[0].daqCutValue);
1643 mLadders[iLad]->mWafers[iWaf]->pedestalSubstraction();
1644 mLadders[iLad]->mWafers[iWaf]->zeroSubstraction();
1645 mLadders[iLad]->mWafers[iWaf]->updateStripList();
1649 Int_t StSsdBarrel::readNoiseDefaultForSimu(){
1653 Int_t NAdcChannel = (int)pow(2.0,10.0*1.0);
1654 Int_t nElectronInAMip = 22500;
1655 Int_t adcDynamic = 20;
1656 const Float_t AdctoE = (adcDynamic*nElectronInAMip)/(
float)(NAdcChannel);
1657 Int_t NumberOfNoise = 0;
1658 for(Int_t iLad=0;iLad<mNLadder;iLad++)
1660 for(Int_t iWaf=0;iWaf<mNWaferPerLadder;iWaf++)
1662 for(Int_t NStrip=0;NStrip<mNStripPerSide;NStrip++)
1664 for(Int_t iSide=0;iSide<2;iSide++)
1667 mLadders[iLad]->mWafers[iWaf]->addNoiseToStripSignal(newStrip,iSide);
1673 return NumberOfNoise;
StSsdPointList * getPoint()
Returns the point list attached to this wafer.
void addCluster(StSsdCluster *ptr, Int_t iSide)
Attaches the ptr cluster on the iSide of the wafer.
StSsdStripList * getStripP()
Returns the P-side strip list attached to this wafer.
void doLorentzShift(ssdDimensions_st *dimensions, Float_t mShift_hole, Float_t mShift_elec)
StSsdStripList * getStripN()
Returns the N-side strip list attached to this wafer.
StSsdBarrel(ssdDimensions_st *dimensions, ssdConfiguration_st *config=0)
Int_t doFindPackage(ssdDimensions_st *dimensions, StSsdClusterControl *clusterControl)
void addStrip(StSsdStrip *ptr, Int_t iSide)
Int_t readNoiseFromTable(St_sdm_calib_db *spa_noise, StSsdDynamicControl *dynamicControl)
void doClusterisation(Int_t *numberOfCluster, StSsdClusterControl *clusterControl)
StSsdClusterList * getClusterN()
Returns the N-side cluster list attached to this wafer.
StSsdClusterList * getClusterP()
Returns the P-side cluster list attached to this wafer.
Event data structure to hold all information from a Monte Carlo simulation. This class is the interfa...