35 #include "StSvtDriftVelocityMaker.h"
37 #include "StMessMgr.h"
42 #include "StEventTypes.h"
43 #include "StEvent/StPrimaryVertex.h"
44 #include "StEvent/StEvent.h"
45 #include "StarClassLibrary/StSequence.hh"
46 #include "StSvtClassLibrary/StSvtHybridData.hh"
47 #include "StSvtClassLibrary/StSvtData.hh"
48 #include "StSvtClassLibrary/StSvtConfig.hh"
49 #include "StSvtClassLibrary/StSvtHybridPed.hh"
50 #include "StSvtClassLibrary/StSvtHybridDriftVelocity.hh"
51 #include "StSvtClassLibrary/StSvtHybridCollection.hh"
52 #include "StSvtClassLibrary/StSvtHybridPixels.hh"
53 #include "StSvtClusterMaker/StSvtAnalysedHybridClusters.hh"
57 #define N_INJECTOR_LINES 4
64 int n = (
char*)&mDebug - (
char*)&mSvtData +
sizeof(mDebug);
65 memset(&mSvtData,0,n);
77 StSvtDriftVelocityMaker::~StSvtDriftVelocityMaker()
79 delete mSvtDriftVeloc; mSvtDriftVeloc=0;
80 for (
int i=0;i<mNHybridDriftVelocityHisto;i++) {
81 delete mHybridDriftVelocityHisto[i];
82 delete mHybridDriftVelocity2DHisto[i];}
83 delete [] mHybridDriftVelocityHisto;
84 delete [] mHybridDriftVelocity2DHisto;
86 delete mGlobalDriftVelocityHisto;
87 delete mGlobalDriftVelocity2DHisto;
88 delete mCalculatedDriftVelocity;
89 delete mLaserSpotDistL07B3_1;
90 delete mLaserSpotDistL15B3_1;
91 delete mLaserSpotDistL15B3_2;
96 Int_t StSvtDriftVelocityMaker::Init()
102 SetSvtDriftVelocity();
108 char CharString1[100];
109 char CharString2[100];
110 mNHybridDriftVelocityHisto = mSvtRawData->getTotalNumberOfHybrids();
111 mHybridDriftVelocityHisto =
new TH1D*[mNHybridDriftVelocityHisto];
114 mHybridDriftVelocity2DHisto =
new TH2D*[mNHybridDriftVelocityHisto];
117 for (
int barrel = 1;barrel <= mSvtRawData->getNumberOfBarrels();barrel++) {
118 for (
int ladder = 1;ladder <= mSvtRawData->getNumberOfLadders(barrel);ladder++) {
119 for (
int wafer = 1;wafer <= mSvtRawData->getNumberOfWafers(barrel);wafer++) {
120 for (
int hybrid = 1;hybrid <= mSvtRawData->getNumberOfHybrids();hybrid++) {
122 indexHybrid = mSvtRawData->getHybridIndex(barrel, ladder, wafer, hybrid);
124 if (indexHybrid < 0)
continue;
127 if (!hybridDriftVeloc)
130 mSvtRawData->put_at(hybridDriftVeloc,indexHybrid);
132 sprintf(CharString1,
"Histo%d", indexHybrid);
133 sprintf(CharString2,
"2DHisto%d", indexHybrid);
135 hybridHisto =
new TH1D(CharString1, CharString1, mNumTimeBins, mMinimumTB, mMaximumTB);
136 mHybridDriftVelocityHisto[indexHybrid] = hybridHisto;
139 hybrid2DHisto =
new TH2D(CharString1, CharString1, 128, 0, 128, 240, 0, 240);
140 mHybridDriftVelocity2DHisto[indexHybrid] = hybrid2DHisto;
149 mGlobalDriftVelocityHisto =
new TH1D(
"Global1",
"Global1", 640, 0, 128);
150 mGlobalDriftVelocity2DHisto =
new TH2D(
"Global2",
"Global2", 640, 0, 128, 1200, 0, 240);
153 mCalculatedDriftVelocity =
new TH1D(
"Final",
"Final", 432, 0, 431);
154 mLaserSpotDistL07B3_1 =
new TH1D(
"L07B3 Laser Distribution 1",
"L07B3 Laser Distribution 1", 1280, 0, 128);
155 mLaserSpotDistL15B3_1 =
new TH1D(
"L15B3 Laser Distribution 1",
"L15B3 Laser Distribution 1", 1280, 0, 128);
156 mLaserSpotDistL15B3_2 =
new TH1D(
"L15B3 Laser Distribution 2",
"L15B3 Laser Distribution 2", 1280, 0, 128);
158 return StMaker::Init();
161 Int_t StSvtDriftVelocityMaker::SetSvtRawData()
165 dataSet = GetDataSet(
"StSvtRawData");
167 gMessMgr->Warning() <<
" No Svt Raw data set" << endm;
176 gMessMgr->Warning() <<
" No Svt Raw data " << endm;
183 Int_t StSvtDriftVelocityMaker::SetSvtData()
187 dataSet = GetDataSet(
"StSvtAnalResults");
188 if (dataSet) mRaw =
true;
else
199 Int_t StSvtDriftVelocityMaker::SetSvtDriftVelocity()
201 assert(!mSvtDriftVeloc);
213 cout <<
"StSvtDriftVelocityMaker::Make" << endl;
220 FillHistogramsStEvent();
222 cout <<
"Current Event Number is " << ((
StSvtData*)mSvtRawData)->getEventNumber() << endl;
223 cout <<
"Current Run Number is " << ((
StSvtData*)mSvtRawData)->getRunNumber() << endl;
232 Int_t StSvtDriftVelocityMaker::FillHistogramsRaw()
239 int indexHybrid, index, nHits;
244 for (
int barrel = 1;barrel <= mSvtData->getNumberOfBarrels();barrel++) {
245 for (
int ladder = 1;ladder <= mSvtData->getNumberOfLadders(barrel);ladder++) {
246 for (
int wafer = 1;wafer <= mSvtData->getNumberOfWafers(barrel);wafer++) {
247 for (
int hybrid = 1;hybrid <= mSvtData->getNumberOfHybrids();hybrid++) {
249 indexHybrid = mSvtData->getHybridIndex(barrel, ladder, wafer, hybrid);
250 if (indexHybrid < 0)
continue;
255 if (!hybridData)
continue;
257 nHits = hybridData->numOfHits();
258 mHitCounter += nHits;
260 for (index=0; index<nHits; index++) {
262 if (accept(hybridData->svtHit())) {
263 mHybridDriftVelocityHisto[indexHybrid]->Fill(hybridData->WaferPosition()[index].x());
265 if (indexHybrid==293) {
266 if (hybridData->WaferPosition()[index].y()>196.5 && hybridData->WaferPosition()[index].y()<200.5 && hybridData->WaferPosition()[index].x()>60)
267 mLaserSpotDistL07B3_1->Fill(hybridData->WaferPosition()[index].x());
270 if (indexHybrid==416) {
271 if (hybridData->WaferPosition()[index].y()>198.5 && hybridData->WaferPosition()[index].y()<200.5 && hybridData->WaferPosition()[index].x()>60)
272 mLaserSpotDistL15B3_1->Fill(hybridData->WaferPosition()[index].x());
273 if (hybridData->WaferPosition()[index].y()>196.5 && hybridData->WaferPosition()[index].y()<198.5 && hybridData->WaferPosition()[index].x()>60)
274 mLaserSpotDistL15B3_2->Fill(hybridData->WaferPosition()[index].x());
278 mHybridDriftVelocity2DHisto[indexHybrid]->Fill(hybridData->WaferPosition()[index].x(), hybridData->WaferPosition()[index].y());
279 mGlobalDriftVelocityHisto->Fill(hybridData->WaferPosition()[index].x());
280 mGlobalDriftVelocity2DHisto->Fill(hybridData->WaferPosition()[index].x(), hybridData->WaferPosition()[index].y());
295 Int_t StSvtDriftVelocityMaker::FillHistogramsStEvent()
305 event = (
StEvent *) GetInputDS(
"StEvent");
307 cout <<
"StEvent = " <<
event << endl;
309 if (!event)
return kStOK;
312 fSvtConfig->setConfiguration(
"FULL");
317 if (!accept(event))
return kStOK;
325 cout <<
"Number of hits = " << rSvtHitColl->numberOfHits() <<
"." << endl;
326 mHitCounter += rSvtHitColl->numberOfHits();
330 for (
unsigned int br=0; br<rSvtHitColl->numberOfBarrels(); br++) {
331 for (
unsigned int ld=0; ld<rSvtHitColl->barrel(br)->numberOfLadders(); ld++) {
332 for (
unsigned int w=0; w<rSvtHitColl->barrel(br)->ladder(ld)->numberOfWafers(); w++) {
333 StSPtrVecSvtHit& hits = rSvtHitColl->barrel(br)->ladder(ld)->wafer(w)->hits();
334 for (StSvtHitIterator i = hits.begin(); i != hits.end(); i++) {
336 if( accept(sCurrentHit)) {
337 mHybridDriftVelocityHisto[sCurrentHit->index()]->Fill(sCurrentHit->timebucket());
339 mGlobalDriftVelocityHisto->Fill(sCurrentHit->timebucket());
352 Int_t StSvtDriftVelocityMaker::CalcDriftVelocity()
355 double Aver=0, Num=0;
357 Int_t Offset= (mMaximumTB - mMinimumTB)/10;
358 Int_t Start = Offset + mMinimumTB;
359 Int_t End = mMaximumTB - Offset;
361 double DriftVelocity, TotalDriftTime;
364 sprintf(filename,
"Run%d_DV.out", mSvtRawData->getRunNumber());
368 for (i=0; i<mSvtDriftVeloc->getTotalNumberOfHybrids(); i++) {
370 for (j=Start; j<End; j++) {
371 Aver += mHybridDriftVelocityHisto[i]->GetBinContent(j);
380 for (j=mMaximumTB/2; j<mMaximumTB+1; j++) {
381 if (mHybridDriftVelocityHisto[i]->GetBinContent(j) < Aver)
387 for (j=mMaximumTB-2; j>mMaximumTB/2; j--) {
388 if (mHybridDriftVelocityHisto[i]->GetBinContent(j) > Aver)
398 TotalDriftTime = (j-mMinimumTB-mT0Guess)*(128.0/mNumTimeBins)*0.00000004;
400 DriftVelocity = 3.0/TotalDriftTime;
403 mCalculatedDriftVelocity->Fill(i, DriftVelocity);
405 file << i <<
"\t" << DriftVelocity <<
"\t\t" << j*128.0/mNumTimeBins <<
"\n";
411 file <<
"Laser Spot Time Bucket Positions:\n";
413 file <<
"L07B3_1" <<
"\t" << mLaserSpotDistL07B3_1->GetMean() <<
"\n";
414 file <<
"L15B3_1" <<
"\t" << mLaserSpotDistL15B3_1->GetMean() <<
"\n";
415 file <<
"L15B3_2" <<
"\t" << mLaserSpotDistL15B3_2->GetMean() <<
"\n";
423 Int_t StSvtDriftVelocityMaker::GetInjectorLine(
float peak)
429 Int_t StSvtDriftVelocityMaker::GetInjectorLine(
float* peak)
435 Float_t StSvtDriftVelocityMaker::GetClosestToLine(
float peak1,
float peak2)
441 Float_t StSvtDriftVelocityMaker::GetTimeZero(
int anode)
447 Float_t StSvtDriftVelocityMaker::GetDistanceInjectorLine(
int line)
453 Float_t StSvtDriftVelocityMaker::FitVelocity(
int nInjectorsFired,
float* peak,
float t0)
459 Float_t StSvtDriftVelocityMaker::CalcV1(
int anode,
float velocity)
465 Float_t StSvtDriftVelocityMaker::CalcV2(
int anode,
float velocity)
471 Float_t StSvtDriftVelocityMaker::CalcV3(
int anode,
float velocity)
477 Int_t StSvtDriftVelocityMaker::FillAllAnodes()
483 Int_t StSvtDriftVelocityMaker::WriteToDb(Text_t *timestamp)
485 cout <<
"StSvtDriftVelocityMaker::WriteToDb" << endl;
487 if (!GetMaker(
"SvtDb")) {
488 gMessMgr->Warning() <<
" SVT database was not instantiated. Impossible to write! " << endm;
511 for (
int barrel = 1;barrel <= mSvtDriftVeloc->getNumberOfBarrels();barrel++) {
512 for (
int ladder = 1;ladder <= mSvtDriftVeloc->getNumberOfLadders(barrel);ladder++) {
513 for (
int wafer = 1;wafer <= mSvtDriftVeloc->getNumberOfWafers(barrel);wafer++) {
514 for (
int hybrid = 1;hybrid <= mSvtDriftVeloc->getNumberOfHybrids();hybrid++) {
516 indexHybrid = mSvtDriftVeloc->getHybridIndex(barrel, ladder, wafer, hybrid);
518 if (indexHybrid < 0)
continue;
520 delete mHybridDriftVelocityHisto[indexHybrid];
527 delete [] mHybridDriftVelocityHisto;
533 bool StSvtDriftVelocityMaker::accept(
StEvent* event)
541 if( !(event->primaryVertex()))
return 0;
548 bool StSvtDriftVelocityMaker::accept(
StSvtHit*
hit)
553 if( hit->flag() < 100)
return 1;
virtual TObject * GetObject() const
The depricated method (left here for the sake of the backward compatibility)