110 #include "St_DataSetIter.h"
111 #include "TObjectSet.h"
117 #include "StMessMgr.h"
118 #include "StSvtClassLibrary/StSvtHybridCollection.hh"
119 #include "StSvtClassLibrary/StSvtHybridData.hh"
120 #include "StSvtClassLibrary/StSvtHybridPixels.hh"
121 #include "StSvtClassLibrary/StSvtData.hh"
122 #include "StSvtClassLibrary/StSvtHybridBadAnodes.hh"
123 #include "StSequence.hh"
124 #include "StSvtAnalysis.hh"
125 #include "StSvtAnalysedHybridClusters.hh"
126 #include "StSvtClusterAnalysisMaker.h"
127 #include "StSvtSeqAdjMaker/StSvtSeqAdjMaker.h"
131 StSvtClusterAnalysisMaker::StSvtClusterAnalysisMaker(
const char *name) :
StMaker(name)
135 mHybridRawData = NULL;
136 mHybridAdjData = NULL;
137 mHybridPixelData = NULL;
140 mSvtBadAnodeSet = NULL;
142 mSvtRawEventColl = NULL;
143 mSvtClusterColl = NULL;
144 mSvtPixelColl = NULL;
149 mSvtAnalClusters = NULL;
152 mTotNumOfClusters = 0;
153 mTotNumOfGoodClusters = 0;
154 mTotNumOfBadClusters = 0;
156 for(
int i = 0; i < 128; i++)
157 for(
int j = 0; j < 240; j++)
158 adcArray[i + j*128] = 0.0;
171 StSvtClusterAnalysisMaker::~StSvtClusterAnalysisMaker()
175 delete mSvtAnalysis; mSvtAnalysis =0;
183 for (
int i=0; i<mTotalNumberOfHybrids;i++) {
193 Int_t StSvtClusterAnalysisMaker::InitRun(
int runumber)
195 if( Debug()) gMessMgr->Debug() <<
"In StSvtClusterAnalysisMaker::Init()"
207 mTotalNumberOfHybrids = mSvtRawEventColl->getTotalNumberOfHybrids();
209 if (Debug()) hfile =
new TFile(
"myrootfile_clus.root",
"RECREATE",
"Demo ROOT file");
211 CreateClusterHist(mTotalNumberOfHybrids);
214 dataSet = GetDataSet(
"StSvtBadAnodes");
220 mSvtAnalysis->LoadAnodeGains();
222 return StMaker::InitRun(runumber);
228 Int_t StSvtClusterAnalysisMaker::GetSvtRawEvent()
232 dataSet = GetDataSet(
"StSvtRawData");
235 if( !mSvtRawEventColl)
return kStWarn;
241 Int_t StSvtClusterAnalysisMaker::GetSvtEvent()
245 dataSet = GetDataSet(
"StSvtData");
253 Int_t StSvtClusterAnalysisMaker::GetSvtCluster()
257 dataSet = GetDataSet(
"StSvtCluster");
260 if( !mSvtClusterColl)
return kStWarn;
266 Int_t StSvtClusterAnalysisMaker::GetSvtPixels()
271 dataSet = GetDataSet(
"StSvtPixels");
274 assert(mSvtPixelColl);
280 Int_t StSvtClusterAnalysisMaker::SetSvtAnalysis()
284 AddConst(mSvtAnalSet);
285 SetOutput(mSvtAnalSet);
298 Int_t StSvtClusterAnalysisMaker::CreateClusterHist(Int_t tNuOfHyb)
302 m_n_seq =
new TH1F(
"NSeqClust",
"No. Pixels on cluster",100,0.,300.);
303 m_nClust =
new TH2F(
"NClust",
"No. clusters per event",1000,0.,1000.,100,0.,3000.);
304 m_SumADCvsTime =
new TH2F(
"SumAdcVsTime" ,
"Time bucket vs Sum ADC",128,0.,128.,1000,0,100);
305 m_PeakADCvsTime =
new TH2F(
"PeakAdcVsTime" ,
"Time bucket vs PeakADC",128,0.,128.,50,0,50);
306 m_sumADC_all =
new TH1F(
"SumADCall",
"Sum of ADC counts in cluster",500,0,500);
321 for (
int barrel = 1;barrel <= mSvtRawEventColl->getNumberOfBarrels();barrel++) {
322 for (
int ladder = 1;ladder <= mSvtRawEventColl->getNumberOfLadders(barrel);ladder++) {
323 for (
int wafer = 1;wafer <= mSvtRawEventColl->getNumberOfWafers(barrel);wafer++) {
324 for (
int hybrid = 1;hybrid <= mSvtRawEventColl->getNumberOfHybrids();hybrid++) {
326 int index = mSvtRawEventColl->getHybridIndex(barrel,ladder,wafer,hybrid);
327 if(index < 0)
continue;
328 sprintf(title1,
"TimAnodecluster");
329 sprintf(titleraw,
"TimAnodeRaw");
330 sprintf(titleadc,
"ADC");
331 sprintf(title2,
"%d", index);
332 title3 = strcat(title1,title2);
333 titlerawc = strcat(titleraw,title2);
334 titleadcc = strcat(titleadc,title2);
335 m_time_anode_clu[index] =
new TH2F(title3 ,
"Time bucket vs anode",240,0.5,240.5,129,-0.5,128.5);
336 m_time_anode_raw[index] =
new TH2F(titlerawc ,
"Time bucket vs anode",240,0.5,240.5,129,-0.5,128.5);
337 m_sumADC[index] =
new TH1F(titleadcc,
"Sum of ADC counts in cluster",200,0,200);
354 if (Debug()) gMessMgr->Debug() <<
"In StSvtClusterAnalysisMaker::Make() ..."
357 if( GetSvtRawEvent()){
358 gMessMgr->Warning() <<
" StSvtClusterAnalysisMaker::Make :No SVT RAW data " << endm;
362 gMessMgr->Warning() <<
" StSvtClusterAnalysisMaker::Make :No SVT seq data " << endm;
365 if( GetSvtCluster()){
366 gMessMgr->Warning() <<
" StSvtClusterAnalysisMaker::Make :No SVT cluster data " << endm;
373 SetClusterAnalysis();
374 if( Debug()) MakeHistograms();
382 Int_t StSvtClusterAnalysisMaker::SetClusterAnalysis()
389 for(
int barrel = 1;barrel <= mSvtAdjEvent->getNumberOfBarrels();barrel++) {
391 for (
int ladder = 1;ladder <= mSvtAdjEvent->getNumberOfLadders(barrel);ladder++) {
393 for (
int wafer = 1;wafer <= mSvtAdjEvent->getNumberOfWafers(barrel);wafer++) {
395 for (
int hybrid = 1;hybrid <=mSvtAdjEvent->getNumberOfHybrids();hybrid++){
398 index = mSvtAdjEvent->getHybridIndex(barrel,ladder,wafer,hybrid);
399 if(index < 0)
continue;
402 if( !mHybridAdjData)
continue;
405 T0Jitter = (float)(mHybridAdjData->getTimeZero());
406 if( T0Jitter < 4. && T0Jitter > 2.){
409 else if( T0Jitter < 5. && T0Jitter > 3.){
410 T0Jitter = 3. - (8./3.);
412 else if( T0Jitter < 6. && T0Jitter > 4.){
413 T0Jitter = 6. - ( 2.*8./3.);
417 if (! mHybridCluster)
continue;
419 if (! mHybridRawData)
continue;
420 mNumOfClusters = mHybridCluster->getNumberOfClusters();
424 mSvtAnalysis->SetPointers(mHybridAdjData,mHybridRawData,
425 mHybridCluster,mSvtBadAnode,
426 mSvtAdjEvent->getTotalNumberOfHybrids(),
427 StSvtSeqMaker->GetPedOffset());
428 mSvtAnalysis->SetHybIndex(index);
429 mSvtAnalysis->FirstAndLastAnodes();
430 mSvtAnalysis->CluFirstTimeBin();
431 mSvtAnalysis->CluLastTimeBin();
432 mSvtAnalysis->MomentAnalysis();
433 mSvtAnalysis->updateTruth();
439 if( mSvtAnalClusters){
440 delete mSvtAnalClusters;
441 mSvtAnalColl->at(index) = 0;
445 mSvtAnalClusters->setMembers(mSvtAnalysis->GetnSvtClu(),
446 mSvtAdjEvent->getProperHybridIndex(
447 barrel,ladder,wafer,hybrid));
448 mSvtAnalClusters->setSvtHit(mSvtAnalysis,T0Jitter);
449 mSvtAnalColl->put_at(mSvtAnalClusters,index);
452 for(
int clu=0; clu<mSvtAnalysis->GetnSvtClu(); clu++){
454 if(Debug() &&
m_sumADC[index])
m_sumADC[index]->Fill(mSvtAnalysis->GetCluCharge(clu));
455 m_SumADCvsTime->Fill((
float)mSvtAnalysis->GetMeanClusterTimeBin(clu),(float)mSvtAnalysis->GetCluCharge(clu));
457 m_PeakADCvsTime->Fill((
float)mSvtAnalysis->GetMeanClusterTimeBin(clu),(float)mSvtAnalysis->GetCluPeakAdc(clu));
459 m_n_seq->Fill(mSvtAnalysis->GetCluNumPixels(clu));
460 m_sumADC_all->Fill((
float)mSvtAnalysis->GetCluCharge(clu));
476 void StSvtClusterAnalysisMaker::printClusterInfo()
480 mTotNumOfGoodClusters = 0;
481 mTotNumOfBadClusters = 0;
483 for(
int barrel = 1;barrel <= mSvtAdjEvent->getNumberOfBarrels();barrel++) {
485 for (
int ladder = 1;ladder <= mSvtAdjEvent->getNumberOfLadders(barrel);ladder++) {
487 for (
int wafer = 1;wafer <= mSvtAdjEvent->getNumberOfWafers(barrel);wafer++) {
489 for (
int hybrid = 1;hybrid <=mSvtAdjEvent->getNumberOfHybrids();hybrid++){
492 index = mSvtAnalColl->getHybridIndex(barrel,ladder,wafer,hybrid);
493 if(index < 0)
continue;
495 if(index == 8 || index == 9 || index == 12 || index == 13)
499 mNumOfClusters = mSvtAnalClusters->numOfHits();
500 mSvtHit = mSvtAnalClusters->svtHit();
502 for(
int i = 0; i < mNumOfClusters; i++)
504 int flag = mSvtHit[i].flag();
507 ++mTotNumOfGoodClusters;
524 Int_t StSvtClusterAnalysisMaker::GetRawData(
int index)
527 int numOfAnodes,numOfSeq,seqStart;
531 numOfAnodes = mHybridRawData->getAnodeList(anodeList);
538 int seq = 0, mseq = 0;
545 mHybridRawData->getListSequences(an,numOfSeq,svtSequence);
546 seqStart = svtSequence[seq].startTimeBin;
547 adc = svtSequence[seq].firstAdc;
551 else if(an == numOfAnodes)
559 }
while(!an && seqStart + mseq < 128);
564 cout<<
"numOfSeq for hybrid index"<<index<<
" = "<<counter<<endl;
571 Int_t StSvtClusterAnalysisMaker::GetPixelData(
int index)
573 cout<<
"hybrid index: "<<index<<endl;
576 for(
int tim = 0; tim < 128; tim++)
579 for(
int an = 1; an <= 240; an++)
582 cout<<
"Pixel"<<
"["<<an - 1<<
"]"<<
"["<<tim<<
"] = "<< mHybridPixelData->getPixelContent(an,tim)<<endl;
592 void StSvtClusterAnalysisMaker::MakeHistograms(){
595 int listAn, actualAn,seq,stTimeBin,len;
606 for(
int barrel = 1;barrel <= mSvtAdjEvent->getNumberOfBarrels();barrel++) {
607 for(
int ladder = 1;ladder <= mSvtAdjEvent->getNumberOfLadders(barrel);ladder++) {
608 for(
int wafer = 1;wafer <= mSvtAdjEvent->getNumberOfWafers(barrel);wafer++) {
609 for(
int hybrid = 1;hybrid <=mSvtAdjEvent->getNumberOfHybrids();hybrid++){
611 index = mSvtAdjEvent->getHybridIndex(barrel,ladder,wafer,hybrid);
612 if(index < 0)
continue;
620 if( !mHybridAdjData)
continue;
622 if ( !mHybridCluster)
continue;
623 mNumOfClusters = mHybridCluster->getNumberOfClusters();
625 TotalClusters+=mNumOfClusters;
626 gMessMgr->Message()<<
"numOfClusters = "<<mNumOfClusters <<
" For index = " << index<<
" " ;
630 for(
int clu = 0; clu < mNumOfClusters; clu++)
633 mTotNumOfClusters += mNumOfClusters;
635 tempMemberInfo[clu] = mHybridCluster->getCluMemInfo(clu);
636 mNumOfMembers = mHybridCluster->getNumberOfMembers(clu);
640 for(
int mem = 0; mem < mNumOfMembers; mem++)
642 listAn = tempMemberInfo[clu][mem].listAnode;
643 seq = tempMemberInfo[clu][mem].seq;
644 actualAn = tempMemberInfo[clu][mem].actualAnode;
645 mHybridAdjData->getListSequences(listAn,mSequence,svtSequence);
648 stTimeBin =svtSequence[seq].startTimeBin;
649 len = svtSequence[seq].length;
650 adc = svtSequence[seq].firstAdc;
654 for(
int k = 0; k < len ; k++)
656 count = (int) adc[k];
662 delete [] tempMemberInfo;
669 gMessMgr->Message()<<
" Found " << TotalClusters <<
" clusters."<< endm;
671 m_nClust->Fill((
float)mNoEvents,(
float)TotalClusters);
674 Int_t StSvtClusterAnalysisMaker::Reset(){
682 mHybridRawData = NULL;
683 mHybridAdjData = NULL;
684 mHybridPixelData = NULL;
686 mSvtRawEventColl = NULL;
687 mSvtClusterColl = NULL;
688 mSvtPixelColl = NULL;
693 mSvtAnalClusters = NULL;
703 if (Debug()) gMessMgr->Debug() <<
"In StSvtClusterAnalysisMaker::Finish() ..."
705 if (Debug()) hfile->Write();
714 int n = mSvtAnalColl->size();
715 mSvtAnalColl->clear();
716 mSvtAnalColl->resize(n);
TH2F * m_nClust
Sum of ADC on hits.
TH2F * m_SumADCvsTime
Timebucket vs anode for raw sequences.
TH1F ** m_sumADC
No. of seq on a cluster.
TH1F * m_sumADC_all
Sum of ADC on hits.
virtual void Clear(Option_t *option="")
User defined functions.
virtual void Clear(Option_t *option="")
User defined functions.
virtual void SetObject(TObject *obj)
The depricated method (left here for the sake of the backward compatibility)
virtual TObject * GetObject() const
The depricated method (left here for the sake of the backward compatibility)
TH2F ** m_time_anode_raw
Timebucket vs anode for clusters.
virtual const char * GetName() const
special overload
TH2F ** m_time_anode_clu
No. of clusters per event.
TH2F * m_PeakADCvsTime
Timebucket vs SUM ADC of clusters.