15 #include "StFstQAMaker.h"
16 #include "StFstHitCollection.h"
18 #include "StRoot/StFstUtil/StFstCollection.h"
19 #include "StRoot/StFstUtil/StFstRawHitCollection.h"
20 #include "StEvent/StFstRawHit.h"
21 #include "StIOMaker/StIOMaker.h"
22 #include "StEvent/StEvent.h"
23 #include "StEvent/StTrack.h"
26 #include "StEvent/StPrimaryVertex.h"
27 #include "StMessMgr.h"
28 #include "StDcaGeometry.h"
29 #if ROOT_VERSION_CODE < 334081
32 #include "TArrayL64.h"
34 #include "TClassTable.h"
40 #include "StThreeVectorF.hh"
41 #include "StDetectorName.h"
46 StFstQAMaker::StFstQAMaker(
const char* name ) :
47 StMaker(name), mEventCounter(0), mDoTreeOutput(false) {
48 for(
int iSensor=0; iSensor<kFstNumSensors; iSensor++) {
49 rawHitMap[iSensor] = NULL;
50 hitMap[iSensor] = NULL;
51 numOfRawHits_EventId[iSensor] = NULL;
54 for(
int iDisk = 0; iDisk < kFstNumDisk; iDisk++) {
55 hitMapOfFST[iDisk] = NULL;
56 hitMapOfAPV[iDisk] = NULL;
57 hitGlobalXY[iDisk] = NULL;
58 hitGlobalRPhi[iDisk] = NULL;
61 for(
unsigned char iTimeBin=0; iTimeBin<kFstNumTimeBins; iTimeBin++)
62 rawHitCharge_TimeBin[iTimeBin] = NULL;
64 rawHitChargeErr = NULL;
65 rawHitMaxTimeBin_APV = NULL;
66 hitCharge_SensorId = NULL;
67 hitChargeErr_SensorId = NULL;
68 maxTimeBin_SensorId = NULL;
69 numOfRawHits_SensorId = NULL;
70 numOfHits_SensorId = NULL;
71 clusterSize_SensorId = NULL;
72 clusterSizeR_SensorId = NULL;
73 clusterSizePhi_SensorId = NULL;
77 Int_t StFstQAMaker::Init()
81 fstRawHitTree =
new TTree(
"fstRawHits",
"fstRawHits_QA");
82 fstRawHitTree->Branch(
"rawHits", &fstRawHit,
"channelId/I:geoId:wedge:sensor:phistrip:rstrip:maxTimeBin:rdo:arm:apv:channel:idTruth:seedHitFlag:EventId:charge[9]/F:chargeErr[9]/F");
84 fstHitTree =
new TTree(
"fstHits",
"fstHits_QA");
85 fstHitTree->Branch(
"hits", &fstHit,
"hitId/I:wedge/I:sensor/I:apv/I:idTruth/I:EventId/I:maxTimeBin/I:clusteringType/I:nRawHits/I:nRawHitsR/I:nRawHitsPhi/I:meanPhiStrip/F:meanRStrip/F:localR/F:localPhi/F:localZ/F:x/F:y/F:z/F:charge/F:chargeErr/F");
87 numOfRawHits_SensorId =
new TH2S(
"numOfRawHits_SensorId",
"The number of RawHits vs. sensor ID", 108, 0, 108, 128, 0, 128);
88 numOfRawHits_SensorId->GetXaxis()->SetTitle(
"Sensor ID");
89 numOfRawHits_SensorId->GetYaxis()->SetTitle(
"Number of Raw Hits");
91 rawHitMaxTimeBin_APV =
new TH2S(
"rawHitMaxTimeBin_APV",
"Max time bin of raw hits vs APV ID", 288, 0, 288, kFstNumTimeBins, 0, kFstNumTimeBins);
92 rawHitMaxTimeBin_APV->GetXaxis()->SetTitle(
"APV ID [48*(RDO-1)+16*ARM+APV]");
93 rawHitMaxTimeBin_APV->GetYaxis()->SetTitle(
"Max Time Bin Index");
96 for(
int iTimeBin=0; iTimeBin<kFstNumTimeBins; iTimeBin++) {
97 sprintf(buffer,
"rawHitCharge_TimeBin%d", iTimeBin);
98 rawHitCharge_TimeBin[iTimeBin] =
new TH2S(buffer, Form(
"ADC of raw hits at time bin %d vs. channel geometry ID",iTimeBin), 288, 0, 36864, 512, 0, kFstMaxAdc);
99 rawHitCharge_TimeBin[iTimeBin]->GetXaxis()->SetTitle(
"Channel ID");
100 rawHitCharge_TimeBin[iTimeBin]->GetYaxis()->SetTitle(
"ADC of Raw Hits");
103 rawHitChargeErr =
new TH2S(
"rawHitChargeErr",
"RMS noise of raw hits vs. channel geometry ID", 288, 0, 36864, 128, 0, 64);
104 rawHitChargeErr->GetXaxis()->SetTitle(
"Channel ID");
105 rawHitChargeErr->GetYaxis()->SetTitle(
"RMS noise of Raw Hits");
107 numOfHits_SensorId =
new TH2S(
"numOfHits_SensorId",
"The number of hits vs. sensor ID", 108, 0, 108, 128, 0, 128);
108 numOfHits_SensorId->GetXaxis()->SetTitle(
"Sensor ID");
109 numOfHits_SensorId->GetYaxis()->SetTitle(
"Number of Hits");
111 hitCharge_SensorId =
new TH2S(
"hitCharge_SensorId",
"ADC of hits vs. sensor ID", 108, 0, 108, 512, 0, kFstMaxAdc);
112 hitCharge_SensorId->GetXaxis()->SetTitle(
"Sensor ID");
113 hitCharge_SensorId->GetYaxis()->SetTitle(
"ADC of Hits");
115 hitChargeErr_SensorId =
new TH2S(
"hitChargeErr_SensorId",
"RMS noise of hits vs. sensor ID", 108, 0, 108, 128, 0, 64);
116 hitChargeErr_SensorId->GetXaxis()->SetTitle(
"Sensor ID");
117 hitChargeErr_SensorId->GetYaxis()->SetTitle(
"RMS noise of Hits");
119 maxTimeBin_SensorId =
new TH2S(
"maxTimeBin_SensorId",
"Max time bin of hits vs. sensor ID", 108, 0, 108, kFstNumTimeBins, 0, kFstNumTimeBins);
120 maxTimeBin_SensorId->GetXaxis()->SetTitle(
"Sensor ID");
121 maxTimeBin_SensorId->GetYaxis()->SetTitle(
"Max Time Bin Index");
123 clusterSize_SensorId =
new TH2S(
"clusterSize_SensorId",
"Cluster size of hits vs. sensor ID", 108, 0, 108, 20, 0, 20);
124 clusterSize_SensorId->GetXaxis()->SetTitle(
"Sensor ID");
125 clusterSize_SensorId->GetYaxis()->SetTitle(
"Cluster Size of Hits");
127 clusterSizeR_SensorId =
new TH2S(
"clusterSizeR_SensorId",
"Cluster size in R of hits vs. sensor ID", 108, 0, 108, 20, 0, 20);
128 clusterSizeR_SensorId->GetXaxis()->SetTitle(
"Sensor ID");
129 clusterSizeR_SensorId->GetYaxis()->SetTitle(
"Cluster Size in R of Hits");
131 clusterSizePhi_SensorId =
new TH2S(
"clusterSizePhi_SensorId",
"Cluster size in #phi of hits vs. sensor ID", 108, 0, 108, 20, 0, 20);
132 clusterSizePhi_SensorId->GetXaxis()->SetTitle(
"Sensor ID");
133 clusterSizePhi_SensorId->GetYaxis()->SetTitle(
"Cluster Size in #phi of hits");
135 for(
int iDisk = 0; iDisk < kFstNumDisk; ++iDisk)
140 HistName = Form(
"hitMapOfFST_Disk%d",iDisk);
141 HistTitle = Form(
"FST hit map in r-phi for Disk%d",iDisk+1);
142 hitMapOfFST[iDisk] =
new TH2S(HistName.Data(), HistTitle.Data(), kFstNumPhiSegPerWedge*kFstNumWedgePerDisk, 0, kFstNumPhiSegPerWedge*kFstNumWedgePerDisk, kFstNumRStripsPerWedge, 0, kFstNumRStripsPerWedge);
143 hitMapOfFST[iDisk]->GetXaxis()->SetTitle(
"PhiStrip");
144 hitMapOfFST[iDisk]->GetYaxis()->SetTitle(
"RStrip");
146 HistName = Form(
"hitMapOfAPV_Disk%d",iDisk);
147 HistTitle = Form(
"FST hit map in APV geometry Id vs. wedge for Disk%d",iDisk+1);
148 hitMapOfAPV[iDisk] =
new TH2S(HistName.Data(), HistTitle.Data(), kFstNumWedgePerDisk, 1, kFstNumWedgePerDisk+1, kFstApvsPerWedge, 0, kFstApvsPerWedge);
149 hitMapOfAPV[iDisk]->GetXaxis()->SetTitle(
"Wedge ID");
150 hitMapOfAPV[iDisk]->GetYaxis()->SetTitle(
"APV geometry ID");
152 HistName = Form(
"hitGlobalXY_Disk%d",iDisk);
153 HistTitle = Form(
"Global X vs. Global Y for Disk%d",iDisk+1);
154 hitGlobalXY[iDisk] =
new TH2F(HistName.Data(), HistTitle.Data(), 140, -35, 35, 140, -35, 35);
155 hitGlobalXY[iDisk]->GetXaxis()->SetTitle(
"Global X [cm]");
156 hitGlobalXY[iDisk]->GetYaxis()->SetTitle(
"Global Y [cm]");
158 HistName = Form(
"hitGlobalRPhi_Disk%d",iDisk);
159 HistTitle = Form(
"Global #phi vs. Global r for Disk%d",iDisk+1);
160 hitGlobalRPhi[iDisk] =
new TH2F(HistName.Data(), HistTitle.Data(), kFstNumPhiSegPerWedge*kFstNumWedgePerDisk/8, -TMath::Pi(), TMath::Pi(), kFstNumRStripsPerWedge, 5, 28);
161 hitGlobalRPhi[iDisk]->GetXaxis()->SetTitle(
"Global #phi [rad.]");
162 hitGlobalRPhi[iDisk]->GetYaxis()->SetTitle(
"Global r [cm]");
166 for(
int iWedge=0; iWedge<kFstNumWedges; iWedge++) {
167 for(
int iSensor=0; iSensor<kFstNumSensorsPerWedge; iSensor++) {
168 sprintf(histtitle,
"Raw Hit phistrip vs. rstrip: Wedge %d Sensor %d", iWedge+1, iSensor);
169 sprintf(buffer,
"rawHitMap_Sensor%d", iWedge*3+iSensor+1);
170 rawHitMap[iWedge*3+iSensor] =
new TH2S(buffer, histtitle, 128, 0, 128, 8, 0, 8);
171 rawHitMap[iWedge*3+iSensor]->GetXaxis()->SetTitle(
"PhiStrip");
172 rawHitMap[iWedge*3+iSensor]->GetYaxis()->SetTitle(
"RStrip");
174 sprintf(histtitle,
"Number of raw hits vs. EventID: Wedge %d Sensor %d", iWedge+1, iSensor);
175 sprintf(buffer,
"numOfRawHitsVsEventId_Sensor%d", iWedge*3+iSensor+1);
176 numOfRawHits_EventId[iWedge*3+iSensor] =
new TProfile(buffer, histtitle, 10000, 0, 10000);
177 numOfRawHits_EventId[iWedge*3+iSensor]->GetXaxis()->SetTitle(
"EventID (Time)");
178 numOfRawHits_EventId[iWedge*3+iSensor]->GetYaxis()->SetTitle(
"<rawhits>");
180 sprintf(histtitle,
"Hit mean phistrip vs. mean rstrip: Wedge %d Sensor %d", iWedge+1, iSensor);
181 sprintf(buffer,
"hitMap_Sensor%d", iWedge*3+iSensor+1);
182 hitMap[iWedge*3+iSensor] =
new TH2S(buffer, histtitle, 128, 0, 128, 8, 0, 8);
183 hitMap[iWedge*3+iSensor]->GetXaxis()->SetTitle(
"Mean PhiStrip");
184 hitMap[iWedge*3+iSensor]->GetYaxis()->SetTitle(
"Mean RStrip");
195 eventPtr = (
StEvent*)GetInputDS(
"StEvent");
198 LOG_WARN <<
"StFstQAMaker::Make : Error getting pointer to StEvent from '" << ClassName() <<
"'" << endm;
204 fstHitCollection = eventPtr->fstHitCollection();
207 if( !fstHitCollection) {
208 LOG_WARN <<
"StFstQAMaker::Make : Error getting pointer to StFstHitCollection from '" << ClassName() <<
"'" << endm;
215 LOG_WARN <<
"StFstQAMaker::Make() - there is no fstDataSet (raw hit) " << endm;
220 if(!fstCollectionPtr) {
221 LOG_WARN <<
"StFstQAMaker::Make() - no fstCollection."<<endm;
226 fstRawHit.channelId = fstRawHit.geoId = fstRawHit.wedge = fstRawHit.sensor = fstRawHit.phistrip = fstRawHit.rstrip = fstRawHit.maxTimeBin = fstRawHit.rdo = fstRawHit.arm = fstRawHit.apv = fstRawHit.channel = fstRawHit.idTruth = fstRawHit.seedHitFlag = fstRawHit.EventId = -1;
227 for(
int iTB=0; iTB<kFstNumTimeBins; iTB++) {
228 fstRawHit.charge[iTB] = 0.;
229 fstRawHit.chargeErr[iTB] = 0.;
231 fstHit.hitId = fstHit.wedge = fstHit.sensor = fstHit.apv = fstHit.idTruth = fstHit.EventId = fstHit.maxTimeBin = fstHit.clusteringType = fstHit.nRawHits = fstHit.nRawHitsR = fstHit.nRawHitsPhi = fstHit.meanPhiStrip = fstHit.meanRStrip = fstHit.localZ = -1;
232 fstHit.x = fstHit.y = fstHit.z = fstHit.charge = fstHit.chargeErr = 0.;
239 LOG_DEBUG <<
"primaryVertex \t" << primXYZ.x() <<
"\t" << primXYZ.y() <<
"\t" << primXYZ.z() << endm;
242 LOG_DEBUG <<
"no primaryVertex found" << endm;
245 if(mEventCounter%100 == 0)
246 LOG_DEBUG <<
"event index: " << mEventCounter << endm;
248 if(fstHitCollection->numberOfHits() > 0) {
249 for(
int wedgeIdx=0; wedgeIdx<kFstNumWedges; wedgeIdx++ ) {
251 unsigned char nClusteringType = fstHitCollection->getClusteringType();
252 for(
int sensorIdx=0; sensorIdx<kFstNumSensorsPerWedge; sensorIdx++) {
254 int sensorIdxTemp = 0;
255 for(
int idx=0; idx<(int)sensorHitCollection->hits().size(); idx++ ){
260 fstHit.hitId = (int)hit->id();
261 fstHit.wedge = (int)hit->getWedge();
262 fstHit.sensor = (int)hit->getSensor();
263 fstHit.maxTimeBin = (int)hit->getMaxTimeBin();
264 fstHit.clusteringType = (int)nClusteringType;
265 fstHit.nRawHits = (int)hit->getNRawHits();
266 fstHit.nRawHitsR = (int)hit->getNRawHitsR();
267 fstHit.nRawHitsPhi = (int)hit->getNRawHitsPhi();
268 fstHit.idTruth = (int)hit->idTruth();
269 fstHit.EventId = (int)eventPtr->id();
270 fstHit.localR = (float)hit->localPosition(0);
271 fstHit.localPhi = (float)hit->localPosition(1);
272 fstHit.localZ = (float)hit->localPosition(2);
273 fstHit.x = (float)P.x();
274 fstHit.y = (float)P.y();
275 fstHit.z = (float)P.z();
276 fstHit.charge = (float)hit->charge();
277 fstHit.chargeErr = (float)hit->getChargeErr();
278 fstHit.apv = (int)hit->getApv();
279 fstHit.meanPhiStrip = (float)hit->getMeanPhiStrip();
280 fstHit.meanRStrip = (float)hit->getMeanRStrip();
284 sensorIdxTemp = ((int)hit->getWedge()-1)*kFstNumSensorsPerWedge + (
int)hit->getSensor();
285 int diskIdxTemp = ((int)hit->getWedge()-1)/kFstNumWedgePerDisk + 1;
286 int wedgeIdxTemp = (int)hit->getWedge() - (diskIdxTemp-1)*kFstNumWedgePerDisk;
287 int phiIdxTemp = (wedgeIdxTemp-1)*kFstNumPhiSegPerWedge+(
int)(hit->getMeanPhiStrip()+0.5);
288 int rIdxTemp = (int)(hit->getMeanRStrip()+0.5);
290 hitMap[sensorIdxTemp]->Fill((
int)(hit->getMeanPhiStrip()+0.5), (int)(hit->getMeanRStrip()+0.5));
291 hitMapOfFST[diskIdxTemp-1]->Fill(phiIdxTemp, rIdxTemp);
292 hitMapOfAPV[diskIdxTemp-1]->Fill(wedgeIdxTemp, (
int)hit->getApv()+(wedgeIdxTemp%2-1)*kFstApvsPerWedge);
293 hitGlobalXY[diskIdxTemp-1]->Fill((
float)P.x(), (float)P.y());
294 hitGlobalRPhi[diskIdxTemp-1]->Fill((
float)P.phi(), (float)P.perp());
296 hitCharge_SensorId->Fill(sensorIdxTemp, (
int)hit->charge());
297 hitChargeErr_SensorId->Fill(sensorIdxTemp, (
int)(hit->getChargeErr()+0.5));
298 maxTimeBin_SensorId->Fill(sensorIdxTemp, (
int)hit->getMaxTimeBin());
299 clusterSize_SensorId->Fill(sensorIdxTemp, (
int)hit->getNRawHits());
300 clusterSizeR_SensorId->Fill(sensorIdxTemp, (
int)hit->getNRawHitsR());
301 clusterSizePhi_SensorId->Fill(sensorIdxTemp, (
int)hit->getNRawHitsPhi());
304 numOfHits_SensorId->Fill(sensorIdxTemp, sensorHitCollection->hits().size());
305 sensorHitCollection->hits().clear();
310 if(fstCollectionPtr->getNumRawHits() > 0) {
311 int counter[kFstNumSensors];
312 for(
int iS=0; iS<kFstNumSensors; iS++)
315 for(
int wedgeIdx=0; wedgeIdx<kFstNumWedges; ++wedgeIdx ){
317 if( rawHitCollectionPtr ){
318 std::vector<StFstRawHit*>& rawHitVec = rawHitCollectionPtr->getRawHitVec();
319 std::vector< StFstRawHit* >::iterator rawHitIter;
321 for( rawHitIter = rawHitVec.begin(); rawHitIter != rawHitVec.end(); ++rawHitIter ){
324 unsigned char wedge = rawHit->
getWedge();
325 unsigned char sensor = rawHit->
getSensor();
326 unsigned char maxTimeBin = rawHit->getMaxTimeBin();
327 int sensorId = (wedge-1)*kFstNumSensorsPerWedge + sensor;
330 for(
unsigned char timeBin = 0; timeBin < kFstNumTimeBins; ++timeBin ) {
331 rawHitCharge_TimeBin[timeBin]->Fill(rawHit->
getGeoId(), (int)rawHit->getCharge( timeBin ));
332 fstRawHit.charge[timeBin] = rawHit->getCharge(timeBin);
333 fstRawHit.chargeErr[timeBin] = rawHit->getChargeErr(timeBin);
335 rawHitChargeErr->Fill(rawHit->
getGeoId(), (int)(rawHit->getChargeErr( maxTimeBin )+0.5));
337 rawHitMaxTimeBin_APV->Fill(((
int)rawHit->
getRdo()-1)*48+(
int)rawHit->
getArm()*16+(int)rawHit->
getApv(), (int)maxTimeBin);
340 fstRawHit.geoId = (int)rawHit->
getGeoId();
341 fstRawHit.wedge = (int)rawHit->
getWedge();
342 fstRawHit.sensor = (int)rawHit->
getSensor();
344 fstRawHit.rstrip = (int)rawHit->
getRStrip();
345 fstRawHit.maxTimeBin = (int)maxTimeBin;
346 fstRawHit.rdo = (int)rawHit->
getRdo();
347 fstRawHit.arm = (int)rawHit->
getArm();
348 fstRawHit.apv = (int)rawHit->
getApv();
349 fstRawHit.channel = (int)rawHit->
getChannel();
350 fstRawHit.idTruth = (int)rawHit->
getIdTruth();
352 fstRawHit.EventId = (int)eventPtr->id();
354 fstRawHitTree->Fill();
356 while (!rawHitVec.empty())
delete rawHitVec.back(), rawHitVec.pop_back();
360 for(
int iS=0; iS<kFstNumSensors; iS++) {
361 numOfRawHits_SensorId->Fill(iS+1, counter[iS]);
362 numOfRawHits_EventId[iS]->Fill((
int)eventPtr->id()/100+1, counter[iS]);
380 LOG_WARN <<
"StFstQAMaker::Init(): No StIOMaker" << endm;
383 TString mRootFilename = TString(ioMaker->GetFile());
384 int found = mRootFilename.Last(
'/');
386 mRootFilename.Replace(0, found + 1,
"");
388 found = mRootFilename.First(
".");
389 if(found == 0) found = mRootFilename.Length();
390 mRootFilename.Replace(found, mRootFilename.Length() - found,
".fstQa.root");
391 LOG_INFO <<
"FST QA File Name: " << mRootFilename << endm;
393 cout <<
"QA file name: " << mRootFilename << endl;
394 TFile *myRootFile =
new TFile(mRootFilename.Data(),
"RECREATE");
396 LOG_WARN <<
"Error recreating file '" << mRootFilename <<
"'" << endl;
401 myRootFile->WriteTObject(fstRawHitTree);
402 myRootFile->WriteTObject(fstHitTree);
404 myRootFile->WriteTObject(numOfRawHits_SensorId);
405 myRootFile->WriteTObject(numOfHits_SensorId);
406 for(
int iTimeBin=0; iTimeBin<kFstNumTimeBins; iTimeBin++)
407 myRootFile->WriteTObject(rawHitCharge_TimeBin[iTimeBin]);
408 myRootFile->WriteTObject(rawHitChargeErr);
409 myRootFile->WriteTObject(hitCharge_SensorId);
410 myRootFile->WriteTObject(hitChargeErr_SensorId);
411 myRootFile->WriteTObject(rawHitMaxTimeBin_APV);
412 myRootFile->WriteTObject(maxTimeBin_SensorId);
413 myRootFile->WriteTObject(clusterSize_SensorId);
414 myRootFile->WriteTObject(clusterSizeR_SensorId);
415 myRootFile->WriteTObject(clusterSizePhi_SensorId);
416 for(
int iWedge=0; iWedge<kFstNumWedges; iWedge++) {
417 for(
int iSensor=0; iSensor<kFstNumSensorsPerWedge; iSensor++) {
418 myRootFile->WriteTObject(rawHitMap[iWedge*3+iSensor]);
419 myRootFile->WriteTObject(hitMap[iWedge*3+iSensor]);
420 myRootFile->WriteTObject(numOfRawHits_EventId[iWedge*3+iSensor]);
423 for(
int iDisk = 0; iDisk < kFstNumDisk; iDisk++)
425 myRootFile->WriteTObject(hitMapOfFST[iDisk]);
426 myRootFile->WriteTObject(hitMapOfAPV[iDisk]);
427 myRootFile->WriteTObject(hitGlobalXY[iDisk]);
428 myRootFile->WriteTObject(hitGlobalRPhi[iDisk]);
unsigned char getChannel() const
0-127
unsigned char getArm() const
0-2
unsigned char getSensor() const
0-2
unsigned char getRStrip() const
0-7
unsigned char getPhiStrip() const
0-127
int getGeoId() const
0-36863
unsigned char getApv() const
0-15
unsigned short getIdTruth() const
for embedding, 0 as background
int getChannelId() const
0-36863
unsigned char getRdo() const
1-6
int getSeedhitflag() const
0 or 1
virtual TObject * GetObject() const
The depricated method (left here for the sake of the backward compatibility)
unsigned char getWedge() const
1-36