28 #include "StSsdDaqMaker.h"
29 #include "TDataSetIter.h"
30 #include "StMessMgr.h"
31 #include "StDAQMaker/StDAQReader.h"
32 #include "StDAQMaker/StSSDReader.h"
33 #include "ssdLadderMap.h"
34 #include "tables/St_spa_strip_Table.h"
35 #include "tables/St_ssdConfiguration_Table.h"
36 #include "tables/St_ssdPedStrip_Table.h"
81 LOG_INFO <<
"Read now Databases " << endm;
83 if (IAttr(
".histos")) {
84 occupancy_wafer =
new TH2S(
"occupancy_wafer",
"occupancy per wafer",40,0,40,20,0,20);
85 occupancy_chip =
new TH2S(
"occupancy_chip",
"occupancy per chip",40,0,40,99,0,99);
86 noise_chip =
new TH2S(
"noise_chip",
"mean noise per chip",40,0,40,99,0,99);
87 noise_wafer =
new TH2S(
"noise_wafer",
"mean noise per wafer",40,0,40,20,0,20);
88 noise_chip_P =
new TH2S(
"noise_chip_P",
"mean noise per chip for the P Side ",20,0,20,96,0,96);
89 noise_chip_N =
new TH2S(
"noise_chip_N",
"mean noise per chip for the N Side",20,0,20,96,0,96);
90 pedestal_chip =
new TH2S(
"pedestal_chip",
"pedestal per chip",40,0,40,99,0,99);
91 ped_zero_ladP =
new TH2S(
"ped_zero_ladP",
"map of p-side wafers where strips have ped = 0",20,0,20,15,0,15);
92 ped_zero_ladN =
new TH2S(
"ped_zero_ladN",
"map of n-side wafers where strips have ped = 0",20,0,20,15,0,15);
93 ped_high_ladP =
new TH2S(
"ped_high_ladP",
"map of p-side wafers where strips have ped = 255",20,0,20,15,0,15);
94 ped_high_ladN =
new TH2S(
"ped_high_ladN",
"map of n-side wafers where strips have ped = 255",20,0,20,15,0,15);
95 noise_zero_ladP =
new TH2S(
"noise_zero_ladP",
"map of p-side wafers where strips have noise = 0",20,0,20,15,0,15);
96 noise_zero_ladN =
new TH2S(
"noise_zero_ladN",
"map of n-side wafers where strips have noise = 0",20,0,20,15,0,15);
97 noise_high_ladP =
new TH2S(
"noise_high_ladP",
"map of p-side wafers where strips have noise = 255",20,0,20,15,0,15);
98 noise_high_ladN =
new TH2S(
"noise_high_ladN",
"map of n-side wafers where strips have noise = 255",20,0,20,15,0,15);
99 occupancy =
new TH1F(
"deadStrips",
"number of dead strips",40,0,40);
100 occupancy_wafer->SetXTitle(
"Ladder");
101 occupancy_wafer->SetYTitle(
"Wafer");
102 occupancy_chip->SetXTitle(
"Ladder");
103 occupancy_chip->SetYTitle(
"Chip");
104 noise_chip->SetXTitle(
"Ladder");
105 noise_chip->SetYTitle(
"Chip");
106 noise_chip_P->SetXTitle(
"Ladder");
107 noise_chip_N->SetXTitle(
"Ladder");
108 noise_chip_P->SetYTitle(
"Chip");
109 noise_chip_N->SetYTitle(
"Chip");
110 noise_wafer->SetXTitle(
"Ladder");
111 noise_wafer->SetYTitle(
"Wafer");
112 pedestal_chip->SetXTitle(
"Ladder");
113 pedestal_chip->SetYTitle(
"Chip");
114 occupancy->SetXTitle(
"Ladder");
115 occupancy->SetYTitle(
"#");
116 ped_zero_ladP->SetXTitle(
"Ladder");
117 ped_zero_ladP->SetYTitle(
"Wafer");
118 ped_zero_ladN->SetXTitle(
"Ladder");
119 ped_zero_ladN->SetYTitle(
"Wafer");
120 ped_high_ladP->SetXTitle(
"Ladder");
121 ped_high_ladP->SetYTitle(
"Wafer");
122 ped_high_ladN->SetXTitle(
"Ladder");
123 ped_high_ladN->SetYTitle(
"Wafer");
124 noise_zero_ladP->SetXTitle(
"Ladder");
125 noise_zero_ladP->SetYTitle(
"Wafer");
126 noise_zero_ladN->SetXTitle(
"Ladder");
127 noise_zero_ladN->SetYTitle(
"Wafer");
128 noise_high_ladP->SetXTitle(
"Ladder");
129 noise_high_ladP->SetYTitle(
"Wafer");
130 noise_high_ladN->SetXTitle(
"Ladder");
131 noise_high_ladN->SetYTitle(
"Wafer");
138 LOG_INFO <<
"Init() - Done " << endm;
140 return StMaker::Init();
144 Int_t StSsdDaqMaker::InitRun(
int runumber)
146 LOG_INFO <<
"InitRun(int runumber) - Read now Databases"<<endm;
147 Int_t run = (runumber/1000000)-1;
149 St_ssdConfiguration *configuration = (St_ssdConfiguration*) GetDataBase(
"Geometry/ssd/ssdConfiguration");
151 LOG_ERROR <<
"InitRun("<<runumber<<
") - ERROR - ssdConfiguration==0"<<endm;
154 ssdConfiguration_st *config = (ssdConfiguration_st*) configuration->GetTable() ;
156 LOG_ERROR <<
"InitRun("<<runumber<<
") - ERROR - config==0"<<endm;
162 int totLadderPresent = 0;
164 for (
int ladder = 1; ladder<=config->nMaxLadders;ladder++)
166 LOG_INFO<<
" on sector = " << config->ladderIsPresent[ladder-1];
167 if (config->ladderIsPresent[ladder-1] != 0)
169 mConfig->setLadderIsActive(ladder,config->ladderIsPresent[ladder-1]);
171 PrintConfiguration(run,config);
172 mConfig->setNumberOfLadders(totLadderPresent);
173 mConfig->setNumberOfWafers(config->nMaxWafers/config->nMaxLadders);
174 mConfig->setNumberOfHybrids(2);
175 mConfig->setTotalNumberOfHybrids(2*16*totLadderPresent);
176 mConfig->setTotalNumberOfLadders(config->nMaxLadders);
177 mConfig->setNumberOfStrips(768);
179 mConfig->setConfiguration();
181 LOG_INFO <<
"_____________________________" << endm;
182 LOG_INFO <<
" Via Datababase......." << endm;
183 LOG_INFO <<
".......numberOfSectors = " << config->nMaxSectors << endm;
184 LOG_INFO <<
".......numberOfLadders = " << totLadderPresent << endm;
185 LOG_INFO <<
" .numberOfWafersPerLadder = " << config->nMaxWafers/config->nMaxLadders << endm;
186 LOG_INFO <<
"_____________________________" << endm;
187 LOG_INFO <<
" InitRun() - Done "<<endm;
194 void StSsdDaqMaker::DeclareNTuple(){
195 pFile =
new TFile(
"PedestalFile.root",
"RECREATE");
196 string varlist =
"side:ladder:wafer:strip:pedestal:noise:chip:id_wafer:tot_strip";
197 pTuple =
new TNtuple(
"PedestalNTuple",
"Pedestal Ntuple",varlist.c_str());
198 LOG_INFO <<
"StSsdDaqMaker::DeclareNtuple - Done - "<<endm;
211 int strip_number,id_wafer,id_side,count,my_channel=-9999;
212 int ladderCountN[20]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0} ;
213 int ladderCountP[20]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0} ;
214 int data,pedestal,noise,channel,newchannel,ladder;
char EastWest;
224 for (Int_t i=0;i<9;i++){
225 PedestalNTuple[i] = 0;
227 maxChannel=mConfig->getNumberOfStrips()*mConfig->getNumberOfWafers();
228 TDataSet *daq = GetDataSet(
"StDAQReader");
230 LOG_WARN <<
"Make : StDAQReader Dataset not found - Skipping the event" << endm;
235 LOG_WARN <<
"Make : StDAQReader Object not found - Skipping the event" << endm;
238 if (!(daqReader->SSDPresent())) {
239 LOG_WARN <<
"Make : The SSD was not in the data stream - Skipping the event" << endm;
242 StSSDReader *stssdreader = daqReader->getSSDReader();
245 LOG_WARN <<
"Make : SSD reader not found - Skipping the event" << endm;
249 St_spa_strip *spa_strip = (St_spa_strip *) GetData(
"spa_strip");
252 spa_strip =
new St_spa_strip(
"spa_strip",100000);
255 St_ssdPedStrip *ssdPedStrip = (St_ssdPedStrip *) GetData(
"ssdPedStrip");
258 ssdPedStrip =
new St_ssdPedStrip(
"ssdPedStrip",100000);
261 spa_strip_st out_strip;
262 ssdPedStrip_st out_ped_strip;
265 static const char EW[4]={
'E',
'W',
'p',
'n'};
266 for (id_side=0;id_side<2;id_side++)
268 EastWest=EW[id_side];
269 LOG_DEBUG <<
" process "<<EW[id_side+2]<<
"-side ladders "<< endm;
270 for (ladder=0;ladder<mConfig->getTotalNumberOfLadders();ladder++)
272 if (mConfig->getLadderIsActive(ladder+1)>0)
274 if ((ladder+1)== 4 || (ladder+1)== 6 || (ladder+1)==10 ||
275 (ladder+1)==11 || (ladder+1)==13 || (ladder+1)==15 ||
277 maxChannel=mConfig->getNumberOfStrips()*mConfig->getNumberOfWafers()-1;
278 else maxChannel=mConfig->getNumberOfStrips()*mConfig->getNumberOfWafers();
279 for (newchannel=0;newchannel<maxChannel;newchannel++)
281 if ((ladder+1)== 4 || (ladder+1)== 6 || (ladder+1)==10 ||
282 (ladder+1)==11 || (ladder+1)==13 || (ladder+1)==15 ||
284 channel= newchannel+1;
285 else channel=newchannel;
286 if(stssdreader->getSsdData(ladder+1,EastWest,newchannel,data,pedestal,noise)==0)
295 if (id_side==1) my_channel=maxChannel-1-channel;
296 else my_channel=channel;
300 for (
int kk=0;kk<maxChannel;kk++) {
301 if (ssd_ladder_mapN[kk]==channel) my_channel=kk;
305 for (
int kk=0;kk<maxChannel;kk++) {
306 if (ssd_ladder_mapP[kk]==channel) my_channel=kk;
309 assert(my_channel>=0);
310 strip_number=my_channel-(my_channel/mConfig->getNumberOfStrips())*mConfig->getNumberOfStrips()+1;
312 id_wafer=7000+100*(mConfig->getNumberOfWafers()-(my_channel/mConfig->getNumberOfStrips()))+ladder+1;
314 id_wafer=7000+100*((my_channel/mConfig->getNumberOfStrips())+1)+ladder+1;
315 out_strip.id = count;
316 out_strip.adc_count = data;
317 out_strip.id_strip = 10000*(10*strip_number+id_side)+id_wafer;
318 out_strip.id_mchit[0] = 0;
319 out_strip.id_mchit[1] = 0;
320 out_strip.id_mchit[2] = 0;
321 out_strip.id_mchit[3] = 0;
322 out_strip.id_mchit[4] = 0;
323 spa_strip->AddAt(&out_strip);
324 if (id_side ==0) ladderCountP[ladder]++;
325 else ladderCountN[ladder]++;
343 for (
int kk=0;kk<maxChannel;kk++) {
344 if (ssd_ladder_mapN[kk]==channel) my_channel=kk;
349 for (
int kk=0;kk<maxChannel;kk++) {
350 if (ssd_ladder_mapP[kk]==channel) my_channel=kk;
354 strip_number=my_channel-(my_channel/mConfig->getNumberOfStrips())*mConfig->getNumberOfStrips()+1;
356 id_wafer=7000+100*(mConfig->getNumberOfWafers()-(my_channel/mConfig->getNumberOfStrips()))+ladder+1;
358 id_wafer=7000+100*((my_channel/mConfig->getNumberOfStrips())+1)+ladder+1;
359 out_ped_strip.id = count;
360 out_ped_strip.id_strip = 10000*(10*strip_number+id_side)+id_wafer;
361 out_ped_strip.noise = noise;
362 out_ped_strip.pedestal = pedestal;
363 nStrip=(int)(out_ped_strip.id_strip/100000.);
364 iWaf = (int)((id_wafer - 7*1000)/100 - 1);
365 iLad = (int)(id_wafer - 7*1000 - (iWaf+1)*100 - 1);
367 chip=(int)((nStrip+(768*(iWaf)))/128.);
368 ssdPedStrip->AddAt(&out_ped_strip);
370 ladderCountP[ladder]++;
371 occupancy_wafer->Fill(2*iLad,iWaf,1);
372 occupancy_chip->Fill(2*iLad,chip,1);
373 noise_chip->Fill(2*iLad,chip,(out_ped_strip.noise/(16.)));
374 noise_wafer->Fill(2*iLad,iWaf,(out_ped_strip.noise/(16.)));
375 noise_chip_P->Fill(iLad,chip,(out_ped_strip.noise/(16.)));
376 pedestal_chip->Fill(2*iLad,chip,out_ped_strip.pedestal);
377 if(pedestal==0)ped_zero_ladP->Fill(iLad,iWaf);
378 if(pedestal==255)ped_high_ladP->Fill(iLad,iWaf);
379 if(noise==0)noise_zero_ladP->Fill(iLad,iWaf);
380 if(noise==255)noise_high_ladP->Fill(iLad,iWaf);
385 PedestalNTuple[1]=iLad;
386 PedestalNTuple[2]=iWaf;
387 PedestalNTuple[3]=nStrip+1;
388 PedestalNTuple[4]=out_ped_strip.pedestal;
389 PedestalNTuple[5]=out_ped_strip.noise;
390 PedestalNTuple[6]=(nStrip/128)+1;
391 PedestalNTuple[7]=id_wafer;
392 PedestalNTuple[8]=nStrip+(iWaf-1)*768;
393 pTuple->Fill(PedestalNTuple);
397 ladderCountN[ladder]++;
398 occupancy_wafer->Fill((2*iLad)+1,iWaf,1);
399 occupancy_chip->Fill((2*iLad)+1,chip,1);
400 noise_chip->Fill((2*iLad)+1,chip,(out_ped_strip.noise/(16.)));
401 noise_wafer->Fill((2*iLad)+1,iWaf,(out_ped_strip.noise/(16.)));
402 noise_chip_N->Fill(iLad,chip,(out_ped_strip.noise/(16.)));
403 pedestal_chip->Fill((2*iLad)+1,chip,out_ped_strip.pedestal);
404 if(pedestal==0)ped_zero_ladN->Fill(iLad,iWaf);
405 if(pedestal==255)ped_high_ladN->Fill(iLad,iWaf);
406 if(noise==0)noise_zero_ladN->Fill(iLad,iWaf);
407 if(noise==255)noise_high_ladN->Fill(iLad,iWaf);
410 PedestalNTuple[1]=iLad;
411 PedestalNTuple[2]=iWaf;
412 PedestalNTuple[3]=nStrip-1;
413 PedestalNTuple[4]=out_ped_strip.pedestal;
414 PedestalNTuple[5]=out_ped_strip.noise;
415 PedestalNTuple[6]=(nStrip/128)+1;
416 PedestalNTuple[7]=id_wafer;
417 PedestalNTuple[8]=nStrip+(iWaf-1)*768;
418 pTuple->Fill(PedestalNTuple);
422 for (
int i=0;i<20;i++)
424 occupancy->SetFillColor(2);
425 occupancy->Fill((2*i),(12288-ladderCountP[i]));
426 occupancy->Fill((2*i)+1,(12288-ladderCountN[i]));
437 LOG_DEBUG <<
"Make()/Number of raw data in the SSD ";
438 LOG_DEBUG <<
"Make()/Active Ladders: ";
439 for (
int i=0;i<mConfig->getTotalNumberOfLadders();i++){
440 if (mConfig->getLadderIsActive(i+1)>0) {
442 LOG_DEBUG <<i+1<<
" ";
445 LOG_DEBUG <<
"Make()/Counts (p-side): ";
446 for (
int i=0;i<mConfig->getTotalNumberOfLadders();i++){
447 if (mConfig->getLadderIsActive(i+1)>0) {
449 LOG_DEBUG <<ladderCountP[i]<<
" ";
452 LOG_DEBUG <<
"Make()/Counts (n-side): ";
453 for (
int i=0;i<mConfig->getTotalNumberOfLadders();i++){
454 if (mConfig->getLadderIsActive(i+1)>0) {
456 LOG_DEBUG <<ladderCountN[i]<<
" ";
459 if((spa_strip->GetNRows()==0)&&(ssdPedStrip && ssdPedStrip->GetNRows()!=0)){
460 LOG_INFO <<
"Make()/ Read Pedestal & Noise"<< endm;
461 LOG_INFO <<
"Make()/ssdPedStrip->NRows= "<<ssdPedStrip->GetNRows()<<endm;
464 if((! ssdPedStrip || ssdPedStrip->GetNRows()==0) && (spa_strip->GetNRows()!=0)){
465 LOG_INFO <<
"Make()/ Read Signal from Physics Run"<< endm;
466 LOG_INFO <<
"Make()/ spa_strip->NRows= "<<spa_strip->GetNRows()<<endm;
474 LOG_INFO << Form(
"Finish()") << endm;
476 LOG_INFO <<
"Write Pedestal tuple"<< endm;
483 void StSsdDaqMaker::PrintConfiguration(Int_t runumber,ssdConfiguration_st *config)
487 LOG_INFO <<
"Configuration of ladders for run IV" <<endm;
491 LOG_INFO <<
"Configuration of ladders for run V" << endm;
495 LOG_INFO <<
"Configuration of ladders for run VI"<< endm;
499 LOG_INFO <<
"Configuration of ladders for run VII" << endm;
504 Int_t totladderPresent =0;
505 LOG_INFO <<
"PrintLadderSummary:ladder id :";
506 for (i=1;i<=config->nMaxLadders;i++){
511 LOG_INFO <<
"PrintLadderSummary:Active Ladders on sectors: ";
512 for (i=1;i<=config->nMaxLadders;i++){
514 LOG_INFO <<mConfig->getLadderIsActive(i);
515 if(mConfig->getLadderIsActive(i)>0)totladderPresent++;
519 LOG_INFO <<
"totLadderActive = "<<totladderPresent<<endm;
virtual void AddData(TDataSet *data, const char *dir=".data")
User methods.
virtual Int_t Init()
Init - is a first method the top level StChain calls to initialize all its makers.
virtual TObject * GetObject() const
The depricated method (left here for the sake of the backward compatibility)
virtual ~StSsdDaqMaker()
This is StSsdDaqMaker destructor.
Class to read SSD data from DAQ files.