StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StFgtSanityMaker.cxx
1 
11 #include <string>
12 #include "StFgtSanityMaker.h"
13 #include "StRoot/StEvent/StFgtCollection.h"
14 #include "StRoot/StEvent/StFgtStrip.h"
15 #include "StRoot/StEvent/StEvent.h"
16 #include "StRoot/StFgtUtil/geometry/StFgtGeom.h"
17 #include "StRoot/StFgtDbMaker/StFgtDbMaker.h"
18 
19 //========================================================
20 //========================================================
21 //========================================================
22 
23 StFgtSanityMaker::StFgtSanityMaker( const Char_t* name , const Char_t* dbMkrName ) : StMaker( name ), mDbMkrName( dbMkrName ), mFgtDbMkr(0) {
24 };
25 
26 
27 //========================================================
28 //========================================================
29 //========================================================
30 Int_t StFgtSanityMaker::Init(){
31 
32 
33  GetEvtHddr()->SetEventNumber(1);
34 
35  StEvent* eventPtr=0;
36  eventPtr= (StEvent*)GetInputDS("StEvent");
37  assert(eventPtr);
38 
39  mFgtCollectionPtr=NULL;
40  if(eventPtr) {
41  mFgtCollectionPtr=eventPtr->fgtCollection();
42  } else {
43  eventPtr=new StEvent();
44  AddData(eventPtr);
45  mFgtCollectionPtr=eventPtr->fgtCollection();
46  };
47  if(!mFgtCollectionPtr) {
48  mFgtCollectionPtr=new StFgtCollection();
49  eventPtr->setFgtCollection(mFgtCollectionPtr);
50  LOG_DEBUG <<"::prepareEnvironment() has added a non existing StFgtCollection()"<<endm;
51  } else {
52  //this should be unncessary if the member clear function is called
53  mFgtCollectionPtr->Clear();
54  };
55 
56  mFgtDbMkr = static_cast< StFgtDbMaker* >( GetMaker( mDbMkrName.data() ) );
57 
58  if( !mFgtDbMkr ){
59  LOG_FATAL << "Error finding mFgtDbMkr named '" << mDbMkrName << "'" << endm;
60  assert(1==2);
61  };
62 
63 
64  LOG_INFO << "Using date and time " << mFgtDbMkr->GetDateTime().GetDate() << ", "
65  << mFgtDbMkr->GetDateTime().GetTime() << endm;
66 
67  iEvt=-1;
68  hh=new TH1F("fgt1","Seen APVs per event; # APVs/event",150,-0.5,149.5);
69 
70 
71  return kStOk;
72 };
73 
74 //========================================================
75 //========================================================
76 //========================================================
77 
79 
80  enum {Ntimebin=7};
81  Int_t adcA[Ntimebin];
82  int chCntDet[kFgtNumDiscs][kFgtNumQuads][kFgtApvsPerAssembly*2];
83  int chCntDaq[ kFgtNumRdos ][kFgtNumArms ][kFgtApvsPerAssembly*2];
84  memset(chCntDet,0,sizeof(chCntDet));
85  memset(chCntDaq,0,sizeof(chCntDaq));
86 
87  iEvt++;
88  // cout << "iEvt = " << iEvt << endl;
89  assert( mFgtDbMkr );
90  StFgtDb *fgtTables = mFgtDbMkr->getDbTables();
91  assert(fgtTables);
92 
93  StEvent* eventPtr = (StEvent*)GetInputDS("StEvent");
94  assert(eventPtr);
95 
96  mFgtCollectionPtr = mFgtCollectionPtr=eventPtr->fgtCollection();
97  assert( mFgtCollectionPtr);
98 
99  int lastGeo=-999;
100  for( UInt_t discIdx=0; discIdx<mFgtCollectionPtr->getNumDiscs(); ++discIdx ){
101  StFgtStripCollection *stripCollectionPtr = mFgtCollectionPtr->getStripCollection( discIdx );
102  if( stripCollectionPtr ){
103  StSPtrVecFgtStrip& stripVec = stripCollectionPtr->getStripVec();
104  StSPtrVecFgtStripIterator stripIter;
105 
106  for( stripIter = stripVec.begin(); stripIter != stripVec.end(); ++stripIter ){
107  int rdo=0, arm=-1, apv=-1, chn=-1;
108  Short_t disk=-1, quad=-1, strip=-1; char layer='x';
109  double ordinate=-1,lowerSpan=-1,upperSpan=-1.;
110  (*stripIter)->getElecCoords( rdo, arm, apv, chn );
111  int stat=fgtTables->getStatusFromElecCoord(rdo,arm,apv,chn);
112  if(stat) continue; // drop bad strips
113  int geoId=fgtTables->getGeoIdFromElecCoord(rdo, arm, apv, chn);
114 
115  assert (geoId>=0);
116  StFgtGeom::decodeGeoId(geoId,disk,quad,layer,strip);
117  StFgtGeom::getPhysicalCoordinate(geoId,disk,quad,layer,ordinate,lowerSpan,upperSpan);
118 
119  chCntDet[disk][quad][apv]++;
120  chCntDaq[rdo-1][arm][apv]++;
121 
122  // drop unstable or dead APVs - Jan's private list
123  if(rdo==2 && arm==1 && apv==5) continue;
124  if(rdo==2 && arm==1 ) continue;
125  if(rdo==2 && arm==2 && apv==18) continue;
126  if(rdo==1 && arm==3 && apv==9) continue;
127  if(rdo==2 && arm==3 ) continue;
128  if(rdo==1 && arm==4 && apv==19) continue;
129  if(rdo==1 && arm==4 && apv==21) continue;
130  if(rdo==2 && arm==4 ) continue;
131 
132  double ped=fgtTables->getPedestalFromElecCoord(rdo,arm,apv,chn);
133  double pedSig=fgtTables->getPedestalSigmaFromElecCoord(rdo,arm,apv,chn);
134 
135  memset(adcA,0,sizeof(adcA));
136  float minAdc=9999, maxAdc=-9999, sum=0;
137  int iMin=-1;
138  for(Int_t is=0;is<Ntimebin;is++){
139  adcA[is]=(*stripIter)->getAdc(is);
140  if(adcA[is]<minAdc) { minAdc=adcA[is]; iMin=is;}
141  if(adcA[is]>maxAdc) maxAdc=adcA[is];
142  sum+=adcA[is];
143  }
144 
145  //printf("mm %f %f\n",ped,maxAdc);
146  maxAdc-=minAdc;
147  sum-=minAdc*Ntimebin;
148  if(maxAdc<600) continue;
149  if(maxAdc>3000) continue;
150  if(iMin>0) continue; // require ped is in time bin 0
151  char star=' ';
152  if(abs(lastGeo-geoId)==1) star='*';
153  lastGeo=geoId;
154  printf("\nieve=%d rdo=%d arm=%d apv=%d ch=%d geoId=%d strip=%d%c%c%03d %csumADC-ped=%.1f\n adc-ped[0...6]=",iEvt,rdo,arm,apv,chn,geoId,disk+1,quad+'A',layer,strip,star,sum);
155  for(Int_t is=0;is<Ntimebin;is++) printf(" %.0f ",adcA[is]-minAdc);
156  printf("\n dbPd=%.1f minAdc=%.1f del=%.1f\n",ped,minAdc,ped-minAdc);
157  }
158  }
159  }
160 
161  if(iEvt==0) {
162  printf("JJ eventID=%d FGT sanity (detector view)\n",eventPtr->id());
163  for(int idisc=0;idisc<kFgtNumDiscs;idisc++)
164  for(int iquad=0;iquad<kFgtNumQuads;iquad++){
165  printf("disc=%d quad=%c ",idisc+1,iquad+'A');
166  for(int iapv=0;iapv<kFgtApvsPerAssembly*2;iapv++){
167  if(chCntDet[idisc][iquad][iapv]<=0) continue;
168  printf(" apv%02d:%3d, ",iapv,chCntDet[idisc][iquad][iapv]);
169  }
170  printf("\n");
171  }
172 
173  printf("\nJJ eventID=%d FGT sanity (Daq view)\n",eventPtr->id());
174  for(int irdo=0;irdo<kFgtNumRdos; irdo++)
175  for(int iarm=0;iarm<kFgtNumArms;iarm++) {
176  printf("RDO=%d arm=%d apv:nCh ",irdo+1,iarm);
177  for(int iapv=0;iapv<kFgtApvsPerAssembly*2;iapv++){
178  if(chCntDaq[irdo][iarm][iapv]<=0) continue;
179  printf(" %2d:%3d, ",iapv,chCntDaq[irdo][iarm][iapv]);
180  }
181  printf("\n");
182  }
183  }// end of printout
184 
185  int nSeenApv=0;
186  for(int irdo=0;irdo<kFgtNumRdos; irdo++)
187  for(int iarm=0;iarm<kFgtNumArms;iarm++)
188  for(int iapv=0;iapv<kFgtApvsPerAssembly*2;iapv++)
189  if(chCntDaq[irdo][iarm][iapv]>64) nSeenApv++;
190  hh->Fill(nSeenApv);
191 
192  return kStOK;
193 };
194 
195 
197 
198  cout << "StFgtSanityMaker::Finish()" << endl;
199  hh->Draw();
200  gPad->SetLogy();
201  return StMaker::Finish();
202 };
203 
204 
205 
206 
207 ClassImp( StFgtSanityMaker );
208 
209 /**************************************************************************
210  *
211  * $Log: StFgtSanityMaker.cxx,v $
212  * Revision 1.5 2012/02/07 08:25:29 balewski
213  * *** empty log message ***
214  *
215  * Revision 1.4 2012/02/07 06:14:42 balewski
216  * *** empty log message ***
217  *
218  * Revision 1.3 2012/02/07 05:33:30 balewski
219  * *** empty log message ***
220  *
221  * Revision 1.2 2012/02/06 04:17:36 balewski
222  * added 2012 APV exclusions
223  *
224  * Revision 1.1 2012/02/04 22:03:40 balewski
225  * start
226  *
227  *
228  **************************************************************************/
virtual void AddData(TDataSet *data, const char *dir=".data")
User methods.
Definition: StMaker.cxx:332
Definition: Stypes.h:40
virtual Int_t Finish()
Definition: StMaker.cxx:776
Definition: Stypes.h:41